Merge IoTThinks PowerSaving v16 updates
# Conflicts: # examples/companion_radio/MyMesh.cpp # examples/simple_repeater/MyMesh.cpp # examples/simple_repeater/UITask.cpp # examples/simple_repeater/UITask.h # examples/simple_room_server/MyMesh.cpp # examples/simple_room_server/MyMesh.h # examples/simple_sensor/SensorMesh.cpp # examples/simple_sensor/SensorMesh.h # src/Dispatcher.cpp # src/Dispatcher.h # src/helpers/CommonCLI.cpp # src/helpers/CommonCLI.h # src/helpers/radiolib/CustomLR1110.h # src/helpers/radiolib/CustomLR1110Wrapper.h # src/helpers/radiolib/CustomSX1262.h # src/helpers/radiolib/CustomSX1262Wrapper.h # src/helpers/radiolib/RadioLibWrappers.cpp # src/helpers/radiolib/RadioLibWrappers.h # variants/rak4631/platformio.ini # variants/thinknode_m3/variant.cpp # variants/thinknode_m3/variant.h # variants/thinknode_m6/variant.cpp # variants/thinknode_m6/variant.h
This commit is contained in:
commit
9bec10b41a
34 files changed
+217
-44
No files matched your search
@@ -461,6 +461,32 @@ disabled.
|
||||
|
||||
---
|
||||
|
||||
#### View or change RX duty-cycle power saving
|
||||
**Usage:**
|
||||
- `get radio.rxps`
|
||||
- `get rxps.wd`
|
||||
- `set radio.rxps off`
|
||||
- `set radio.rxps on`
|
||||
- `set radio.rxps conservative`
|
||||
- `set radio.rxps balanced`
|
||||
- `set radio.rxps <1-10>`
|
||||
- `set radio.rxps level <1-10>`
|
||||
- `set radio.rxps level <1-10> preamble <16|32>`
|
||||
- `set radio.rxps <rx_us> <sleep_us>`
|
||||
|
||||
**Parameters:**
|
||||
- `rx_us`, `sleep_us`: Receive and sleep durations in microseconds (`1000`-`30000000`).
|
||||
- `level`: A power-saving level from `1` (most conservative) to `10` (least power saving).
|
||||
- `preamble`: LoRa preamble length in symbols; `16` or `32`.
|
||||
|
||||
**Notes:**
|
||||
- `get rxps.wd` reports the RXPS watchdog's soft and hard recovery counts.
|
||||
- `on` and `conservative` select level `1` with a 16-symbol preamble; `balanced` selects level `5` with a 16-symbol preamble.
|
||||
- Level-based settings automatically recalculate their timings when the spreading factor or bandwidth changes. Custom `<rx_us> <sleep_us>` timings remain fixed.
|
||||
- The selected mode is applied immediately, persisted, and restored after reboot.
|
||||
|
||||
---
|
||||
|
||||
#### View or change the LoRa FEM receive-path gain state on supported boards
|
||||
**Usage:**
|
||||
- `get radio.fem.rxgain`
|
||||
|
||||
@@ -33,7 +33,12 @@ static const uint32_t COMMAND_RADIO_APPLY_TIMEOUT_MS = 5000UL;
|
||||
#endif
|
||||
|
||||
#if RXPS_FIXED_ENABLED
|
||||
#error "RXPS must remain disabled for companion firmware"
|
||||
#if RXPS_FIXED_LEVEL < 1 || RXPS_FIXED_LEVEL > 10
|
||||
#error "RXPS_FIXED_LEVEL must be between 1 and 10"
|
||||
#endif
|
||||
#if RXPS_FIXED_PREAMBLE != 16 && RXPS_FIXED_PREAMBLE != 32
|
||||
#error "RXPS_FIXED_PREAMBLE must be 16 or 32"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define CMD_APP_START 1
|
||||
|
||||
@@ -799,7 +799,7 @@ bool UITask::isButtonPressed() const {
|
||||
}
|
||||
|
||||
void UITask::loop() {
|
||||
if (_serial->takePairingRequest()) {
|
||||
if (_interfaceManager->takePairingRequest()) {
|
||||
showPairingPin();
|
||||
}
|
||||
|
||||
|
||||
@@ -149,11 +149,21 @@ void UITask::renderCurrScreen() {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
IPAddress ip = WiFi.localIP();
|
||||
_display->setCursor(0, 40);
|
||||
_display->setColor(DisplayDriver::LIGHT);
|
||||
_display->setColor(UIColor::primary_txt);
|
||||
snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
_display->print(tmp);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
_display->setCursor(0, 40);
|
||||
snprintf(tmp, sizeof(tmp), "BAT: %.2fV", _board->getBattMilliVolts() / 1000.0f);
|
||||
_display->print(tmp);
|
||||
}
|
||||
|
||||
// Keep power-saving state visible even when the MQTT IP occupies row 40.
|
||||
_display->setCursor(0, 50);
|
||||
snprintf(tmp, sizeof(tmp), "PowerSaving: %s", _node_prefs->powersaving_enabled ? "ON" : "off");
|
||||
_display->print(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,4 +19,4 @@ public:
|
||||
void begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version);
|
||||
|
||||
void loop();
|
||||
};
|
||||
};
|
||||
@@ -13,6 +13,14 @@ extra_configs =
|
||||
variants/*/platformio.ini
|
||||
platformio.local.ini
|
||||
|
||||
[companion_rxps]
|
||||
custom_rxps_level = 5
|
||||
custom_rxps_preamble = 16
|
||||
build_flags =
|
||||
-D RXPS_FIXED_ENABLED=1
|
||||
-D RXPS_FIXED_LEVEL=${companion_rxps.custom_rxps_level}
|
||||
-D RXPS_FIXED_PREAMBLE=${companion_rxps.custom_rxps_preamble}
|
||||
|
||||
[arduino_base]
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
|
||||
+9
-4
@@ -405,6 +405,8 @@ bool Dispatcher::tryParsePacket(Packet* pkt, const uint8_t* raw, int len) {
|
||||
void Dispatcher::checkRecv() {
|
||||
Packet* pkt;
|
||||
float score;
|
||||
float snr;
|
||||
float rssi;
|
||||
uint32_t air_time;
|
||||
{
|
||||
uint8_t raw[MAX_TRANS_UNIT+1];
|
||||
@@ -415,15 +417,17 @@ void Dispatcher::checkRecv() {
|
||||
#else
|
||||
radio_liveness.noteActivity(_ms->getMillis());
|
||||
#endif
|
||||
logRxRaw(_radio->getLastSNR(), _radio->getLastRSSI(), raw, len);
|
||||
snr = _radio->getLastSNR();
|
||||
rssi = _radio->getLastRSSI();
|
||||
logRxRaw(snr, rssi, raw, len);
|
||||
|
||||
pkt = _mgr->allocNew();
|
||||
if (pkt == NULL) {
|
||||
MESH_DEBUG_PRINTLN("%s Dispatcher::checkRecv(): WARNING: received data, no unused packets available!", getLogDateTime());
|
||||
} else {
|
||||
if (tryParsePacket(pkt, raw, len)) {
|
||||
pkt->_snr = _radio->getLastSNR() * 4.0f;
|
||||
score = _radio->packetScore(_radio->getLastSNR(), len);
|
||||
pkt->_snr = snr * 4.0f;
|
||||
score = _radio->packetScore(snr, len);
|
||||
air_time = _radio->getEstAirtimeFor(len);
|
||||
rx_air_time += air_time;
|
||||
} else {
|
||||
@@ -439,7 +443,7 @@ void Dispatcher::checkRecv() {
|
||||
#if MESH_PACKET_LOGGING
|
||||
logPacketStart("RX", pkt, pkt->getRawLength());
|
||||
Serial.printf(" SNR=%d RSSI=%d score=%d time=%d", (int)pkt->getSNR(),
|
||||
(int)_radio->getLastRSSI(), (int)(score * 1000), air_time);
|
||||
(int)rssi, (int)(score * 1000), air_time);
|
||||
|
||||
static uint8_t packet_hash[MAX_HASH_SIZE];
|
||||
pkt->calculatePacketHash(packet_hash);
|
||||
@@ -468,6 +472,7 @@ void Dispatcher::checkRecv() {
|
||||
processRecvPacket(pkt);
|
||||
}
|
||||
}
|
||||
_radio->onReceiveProcessed();
|
||||
}
|
||||
|
||||
void Dispatcher::processRecvPacket(Packet* pkt) {
|
||||
|
||||
@@ -40,6 +40,9 @@ public:
|
||||
*/
|
||||
virtual int recvRaw(uint8_t* bytes, int sz) = 0;
|
||||
|
||||
/** Called after the received packet and its radio metadata have been processed. */
|
||||
virtual void onReceiveProcessed() { }
|
||||
|
||||
/**
|
||||
* \returns estimated transmit air-time needed for packet of 'len_bytes', in milliseconds.
|
||||
*/
|
||||
|
||||
@@ -34,9 +34,6 @@ public:
|
||||
float getCurrentRSSI() override {
|
||||
return ((CustomLLCC68 *)_radio)->getRSSI(false);
|
||||
}
|
||||
float getLastRSSI() const override { return ((CustomLLCC68 *)_radio)->getRSSI(); }
|
||||
float getLastSNR() const override { return ((CustomLLCC68 *)_radio)->getSNR(); }
|
||||
|
||||
float packetScore(float snr, int packet_len) override {
|
||||
int sf = ((CustomLLCC68 *)_radio)->spreadingFactor;
|
||||
return packetScoreInt(snr, sf, packet_len);
|
||||
|
||||
@@ -31,18 +31,27 @@ class CustomLR1110 : public LR1110 {
|
||||
int16_t startReceiveDutyCycle(uint32_t rxPeriod, uint32_t sleepPeriod,
|
||||
RadioLibIrqFlags_t irqFlags = RADIOLIB_IRQ_RX_DEFAULT_FLAGS,
|
||||
RadioLibIrqFlags_t irqMask = RADIOLIB_IRQ_RX_DEFAULT_MASK) {
|
||||
// RadioLib's LR11x0 duty-cycle path stages RX but does not call
|
||||
// launchMode(), where the software RF switch is normally set to RX.
|
||||
// RadioLib 7.6 does not expose LR11x0::tcxoDelay. MeshCore initializes
|
||||
// these radios with RadioLib's 5000 us default TCXO delay.
|
||||
const uint32_t transitionTime = 5000 + 1000;
|
||||
uint32_t symbolPeriod = (uint32_t)(((1000.0f * (float)(1UL << this->spreadingFactor)) /
|
||||
this->bandwidthKhz) + 0.999f);
|
||||
uint32_t transitionTime = this->tcxoDelay + 1000;
|
||||
if (sleepPeriod <= transitionTime) {
|
||||
return RADIOLIB_ERR_INVALID_SLEEP_PERIOD;
|
||||
}
|
||||
sleepPeriod -= transitionTime;
|
||||
uint32_t programmedSleepPeriod = sleepPeriod - transitionTime;
|
||||
|
||||
uint32_t rxPeriodRaw = (rxPeriod * 32768UL) / 1000000UL;
|
||||
uint32_t sleepPeriodRaw = (sleepPeriod * 32768UL) / 1000000UL;
|
||||
// PreambleDetected restarts the timeout at 2*rx + sleep. LR1110 testing
|
||||
// established 78 ms RX / 26.851 ms sleep as the production minimum at
|
||||
// SF8, BW 62.5 kHz. Preamble + 11 symbols plus 1 ms preserves that margin.
|
||||
uint64_t requiredExtendedPeriod =
|
||||
((uint64_t)this->preambleLengthLoRa + 11ULL) * symbolPeriod + 1000ULL;
|
||||
uint64_t extendedPeriod = 2ULL * rxPeriod + programmedSleepPeriod;
|
||||
if (extendedPeriod < requiredExtendedPeriod) {
|
||||
rxPeriod = (uint32_t)((requiredExtendedPeriod - programmedSleepPeriod + 1ULL) / 2ULL);
|
||||
}
|
||||
|
||||
uint32_t rxPeriodRaw = (uint32_t)(((uint64_t)rxPeriod * 32768UL) / 1000000UL);
|
||||
uint32_t sleepPeriodRaw =
|
||||
(uint32_t)(((uint64_t)programmedSleepPeriod * 32768UL) / 1000000UL);
|
||||
|
||||
if ((rxPeriodRaw & 0xFF000000) || (rxPeriodRaw == 0)) {
|
||||
return RADIOLIB_ERR_INVALID_RX_PERIOD;
|
||||
@@ -52,6 +61,14 @@ class CustomLR1110 : public LR1110 {
|
||||
return RADIOLIB_ERR_INVALID_SLEEP_PERIOD;
|
||||
}
|
||||
|
||||
// Semtech requires Standby RC and an explicitly configured RTC source
|
||||
// before SetRxDutyCycle. RadioLib does neither in its LoRa RXPS path.
|
||||
int16_t state = standby(RADIOLIB_LR11X0_STANDBY_RC);
|
||||
RADIOLIB_ASSERT(state);
|
||||
state = configLfClock(
|
||||
RADIOLIB_LR11X0_LF_CLK_RC | RADIOLIB_LR11X0_LF_BUSY_RELEASE_ENABLED);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
RadioModeConfig_t cfg = {
|
||||
.receive = {
|
||||
.timeout = RADIOLIB_LR11X0_RX_TIMEOUT_INF,
|
||||
@@ -60,10 +77,11 @@ class CustomLR1110 : public LR1110 {
|
||||
.len = 0,
|
||||
}
|
||||
};
|
||||
int16_t state = this->stageMode(RADIOLIB_RADIO_MODE_RX, &cfg);
|
||||
state = this->stageMode(RADIOLIB_RADIO_MODE_RX, &cfg);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
this->mod->setRfSwitchState(Module::MODE_RX);
|
||||
// Send the already converted values. RadioLib 7.7.1 converts them again
|
||||
// with 32-bit arithmetic, which overflows for periods above about 131 ms.
|
||||
return this->setRxDutyCycle(rxPeriodRaw, sleepPeriodRaw, RADIOLIB_LR11X0_RX_DUTY_CYCLE_MODE_RX);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,9 +90,6 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
float getLastRSSI() const override { return ((CustomLR1110 *)_radio)->getRSSI(); }
|
||||
float getLastSNR() const override { return ((CustomLR1110 *)_radio)->getSNR(); }
|
||||
|
||||
uint8_t getSpreadingFactor() const override { return ((CustomLR1110 *)_radio)->getSpreadingFactor(); }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -29,9 +29,6 @@ public:
|
||||
float getCurrentRSSI() override {
|
||||
return ((CustomSTM32WLx *)_radio)->getRSSI(false);
|
||||
}
|
||||
float getLastRSSI() const override { return ((CustomSTM32WLx *)_radio)->getRSSI(); }
|
||||
float getLastSNR() const override { return ((CustomSTM32WLx *)_radio)->getSNR(); }
|
||||
|
||||
float packetScore(float snr, int packet_len) override {
|
||||
int sf = ((CustomSTM32WLx *)_radio)->spreadingFactor;
|
||||
return packetScoreInt(snr, sf, packet_len);
|
||||
|
||||
@@ -41,8 +41,6 @@ public:
|
||||
float getCurrentRSSI() override {
|
||||
return ((CustomSX1262 *)_radio)->getRSSI(false);
|
||||
}
|
||||
float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); }
|
||||
float getLastSNR() const override { return ((CustomSX1262 *)_radio)->getSNR(); }
|
||||
|
||||
float packetScore(float snr, int packet_len) override {
|
||||
int sf = ((CustomSX1262 *)_radio)->spreadingFactor;
|
||||
|
||||
@@ -38,9 +38,6 @@ public:
|
||||
float getCurrentRSSI() override {
|
||||
return ((CustomSX1268 *)_radio)->getRSSI(false);
|
||||
}
|
||||
float getLastRSSI() const override { return ((CustomSX1268 *)_radio)->getRSSI(); }
|
||||
float getLastSNR() const override { return ((CustomSX1268 *)_radio)->getSNR(); }
|
||||
|
||||
float packetScore(float snr, int packet_len) override {
|
||||
int sf = ((CustomSX1268 *)_radio)->spreadingFactor;
|
||||
return packetScoreInt(snr, sf, packet_len);
|
||||
|
||||
@@ -31,9 +31,6 @@ public:
|
||||
float getCurrentRSSI() override {
|
||||
return ((CustomSX1276 *)_radio)->getRSSI(false);
|
||||
}
|
||||
float getLastRSSI() const override { return ((CustomSX1276 *)_radio)->getRSSI(); }
|
||||
float getLastSNR() const override { return ((CustomSX1276 *)_radio)->getSNR(); }
|
||||
|
||||
float packetScore(float snr, int packet_len) override {
|
||||
int sf = ((CustomSX1276 *)_radio)->spreadingFactor;
|
||||
return packetScoreInt(snr, sf, packet_len);
|
||||
|
||||
@@ -45,6 +45,9 @@ void RadioLibWrapper::begin() {
|
||||
_noise_floor_valid = false;
|
||||
_threshold = 0;
|
||||
_cad_enabled = false;
|
||||
_last_rssi = 0;
|
||||
_last_snr = 0;
|
||||
_rx_hold_continuous = false;
|
||||
|
||||
// start average out some samples
|
||||
_num_floor_samples = 0;
|
||||
@@ -178,6 +181,7 @@ bool RadioLibWrapper::setRxBoostedGainMode(bool enabled) {
|
||||
|
||||
void RadioLibWrapper::idle() {
|
||||
_radio->standby();
|
||||
_rx_hold_continuous = false;
|
||||
state = STATE_IDLE; // need another startReceive()
|
||||
}
|
||||
|
||||
@@ -552,9 +556,18 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
|
||||
if (state & STATE_INT_READY) {
|
||||
last_radio_interrupt_millis = millis(); // ISR fired -> radio hardware is alive
|
||||
if (isPacketReady()) {
|
||||
if (_rx_ps_armed) {
|
||||
// RxDone stops the active receive window, but the duty-cycle RTC can
|
||||
// still be running. Stop it before reading and re-arming another mode.
|
||||
stopReceiveDutyCycle();
|
||||
}
|
||||
len = _radio->getPacketLength();
|
||||
if (len > 0) {
|
||||
if (len > sz) { len = sz; }
|
||||
// Cache packet status before readData() and before any new receive is
|
||||
// started. Both operations may replace the radio's packet metadata.
|
||||
_last_snr = _radio->getSNR();
|
||||
_last_rssi = _radio->getRSSI();
|
||||
int err = _radio->readData(bytes, len);
|
||||
if (err != RADIOLIB_ERR_NONE) {
|
||||
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: readData(%d)", err);
|
||||
@@ -570,17 +583,55 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
|
||||
state = STATE_IDLE; // need another startReceive()
|
||||
}
|
||||
|
||||
if (len > 0 && _rx_ps_enabled) {
|
||||
// Dispatcher still needs the just-cached RSSI/SNR. Keep the receiver in
|
||||
// ordinary continuous mode until it has parsed and scored this packet,
|
||||
// then onReceiveProcessed() restores the duty cycle.
|
||||
_rx_hold_continuous = true;
|
||||
int err = _radio->startReceive();
|
||||
if (err == RADIOLIB_ERR_NONE) {
|
||||
state = STATE_RX;
|
||||
if (_nf_calib_active) {
|
||||
_nf_sample_from = millis() + NF_CALIB_SETTLE_MS;
|
||||
}
|
||||
} else {
|
||||
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startReceive after packet (%d)", err);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
if (state != STATE_RX) {
|
||||
startRecv();
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
void RadioLibWrapper::onReceiveProcessed() {
|
||||
if (!_rx_hold_continuous) return;
|
||||
|
||||
if ((state & ~STATE_INT_READY) == STATE_TX_WAIT) {
|
||||
_rx_hold_continuous = false;
|
||||
return;
|
||||
}
|
||||
// A second packet may have completed while Dispatcher handled the first.
|
||||
// Leave continuous RX intact until recvRaw() consumes that pending packet.
|
||||
if ((state & STATE_INT_READY) != 0 || isReceivingPacket()) {
|
||||
return;
|
||||
}
|
||||
|
||||
_rx_hold_continuous = false;
|
||||
if (!_rx_ps_enabled || _nf_calib_active) return;
|
||||
|
||||
state = STATE_IDLE;
|
||||
startRecv();
|
||||
}
|
||||
|
||||
uint32_t RadioLibWrapper::getEstAirtimeFor(int len_bytes) {
|
||||
return _radio->getTimeOnAir(len_bytes) / 1000;
|
||||
}
|
||||
|
||||
bool RadioLibWrapper::startSendRaw(const uint8_t* bytes, int len) {
|
||||
_rx_hold_continuous = false;
|
||||
if (_rx_ps_armed) {
|
||||
// stop the duty-cycle sequencer before SetTx, otherwise its next RTC
|
||||
// event can fire mid-transmission and abort the TX
|
||||
@@ -653,6 +704,11 @@ bool RadioLibWrapper::isChannelActive() {
|
||||
|
||||
// cad: hardware channel activity detection
|
||||
if (_cad_enabled) {
|
||||
if (_rx_ps_armed) {
|
||||
// CAD cannot safely run on top of an active duty-cycle sequencer: its
|
||||
// pending RTC event can force standby in the middle of the scan.
|
||||
stopReceiveDutyCycle();
|
||||
}
|
||||
int16_t result = performChannelScan();
|
||||
// scanChannel() triggers DIO interrupt (CAD done) which sets STATE_INT_READY
|
||||
// via setFlag() ISR. Clear it before restarting RX so recvRaw() doesn't
|
||||
@@ -698,10 +754,10 @@ uint8_t RadioLibWrapper::getRadioState() const {
|
||||
}
|
||||
|
||||
float RadioLibWrapper::getLastRSSI() const {
|
||||
return _radio->getRSSI();
|
||||
return _last_rssi;
|
||||
}
|
||||
float RadioLibWrapper::getLastSNR() const {
|
||||
return _radio->getSNR();
|
||||
return _last_snr;
|
||||
}
|
||||
|
||||
float RadioLibWrapper::packetScoreInt(float snr, int sf, int packet_len) {
|
||||
|
||||
@@ -25,6 +25,7 @@ protected:
|
||||
mesh::MainBoard* _board;
|
||||
uint32_t n_recv, n_sent, n_recv_errors;
|
||||
int16_t _noise_floor, _threshold;
|
||||
float _last_rssi, _last_snr;
|
||||
bool _cad_enabled;
|
||||
bool _noise_floor_valid;
|
||||
bool _nf_refresh_requested;
|
||||
@@ -35,6 +36,7 @@ protected:
|
||||
uint8_t _preamble_sf;
|
||||
bool _rx_ps_enabled;
|
||||
bool _rx_ps_armed; // radio is currently in RX duty-cycle mode
|
||||
bool _rx_hold_continuous; // keep plain RX active until Dispatcher consumes cached metadata
|
||||
uint32_t _rx_ps_rx_us;
|
||||
uint32_t _rx_ps_sleep_us;
|
||||
|
||||
@@ -109,6 +111,7 @@ public:
|
||||
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board)
|
||||
: _radio(&radio), _board(&board), _noise_floor_valid(false), _nf_refresh_requested(true),
|
||||
_preamble_sf(0), _rx_ps_enabled(false), _rx_ps_armed(false),
|
||||
_rx_hold_continuous(false),
|
||||
_rx_ps_rx_us(RX_PS_FALLBACK_RX_US), _rx_ps_sleep_us(RX_PS_FALLBACK_SLEEP_US),
|
||||
_wd_last_busy(false), _wd_stage(0), _wd_strikes(0), _startrx_fails(0), _wd_last_transition(0),
|
||||
_wd_stuck_thresh(0), _wd_observe_until(0), _wd_observe_ms(0),
|
||||
@@ -117,6 +120,7 @@ public:
|
||||
_nf_calib_active(false), _nf_last_calib(0), _nf_calib_deadline(0), _nf_sample_from(0)
|
||||
{
|
||||
n_recv = n_sent = n_recv_errors = n_wd_soft = n_wd_hard = 0;
|
||||
_last_rssi = _last_snr = 0;
|
||||
last_recv_millis = 0;
|
||||
last_radio_interrupt_millis = 0;
|
||||
_cad_enabled = false;
|
||||
@@ -125,6 +129,7 @@ public:
|
||||
void begin() override;
|
||||
virtual void powerOff() { _radio->standby(); _radio->sleep(); }
|
||||
int recvRaw(uint8_t* bytes, int sz) override;
|
||||
void onReceiveProcessed() override;
|
||||
uint32_t getEstAirtimeFor(int len_bytes) override;
|
||||
bool startSendRaw(const uint8_t* bytes, int len) override;
|
||||
bool isSendComplete() override;
|
||||
@@ -190,8 +195,8 @@ public:
|
||||
unsigned long getLastRecvMillis() const override { return last_recv_millis; }
|
||||
unsigned long getLastRadioInterruptMillis() const override { return last_radio_interrupt_millis; }
|
||||
|
||||
virtual float getLastRSSI() const override;
|
||||
virtual float getLastSNR() const override;
|
||||
float getLastRSSI() const override final;
|
||||
float getLastSNR() const override final;
|
||||
|
||||
float packetScore(float snr, int packet_len) override { return packetScoreInt(snr, 10, packet_len); } // assume sf=10
|
||||
|
||||
|
||||
@@ -24,8 +24,20 @@ bool SH1106Display::begin()
|
||||
{
|
||||
// Wire must already be initialised by board.begin() before this is called.
|
||||
// Boards with non-standard SH1106 addresses should define DISPLAY_ADDRESS
|
||||
// in their variant/platformio configuration.
|
||||
return i2c_probe(Wire, DISPLAY_ADDRESS) && display.begin(DISPLAY_ADDRESS, true);
|
||||
// in their variant/platformio configuration. Some board revisions may have
|
||||
// different solder-bridge address configurations, so variants can also
|
||||
// provide DISPLAY_ADDRESS_ALT as a fallback.
|
||||
if (i2c_probe(Wire, DISPLAY_ADDRESS) && display.begin(DISPLAY_ADDRESS, true)) {
|
||||
return true;
|
||||
}
|
||||
#ifdef DISPLAY_ADDRESS_ALT
|
||||
if (DISPLAY_ADDRESS_ALT != DISPLAY_ADDRESS &&
|
||||
i2c_probe(Wire, DISPLAY_ADDRESS_ALT) &&
|
||||
display.begin(DISPLAY_ADDRESS_ALT, true)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void SH1106Display::turnOn()
|
||||
|
||||
@@ -179,6 +179,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${Heltec_t096.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -209,6 +210,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${Heltec_t096.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
|
||||
@@ -100,6 +100,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D MAX_CONTACTS=350
|
||||
@@ -124,6 +125,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D MAX_CONTACTS=350
|
||||
@@ -236,6 +238,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${Heltec_t114_with_display.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -260,6 +263,7 @@ board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${Heltec_t114_with_display.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
|
||||
@@ -333,6 +333,7 @@ lib_deps =
|
||||
extends = Heltec_tracker_v2
|
||||
build_flags =
|
||||
${Heltec_tracker_v2.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -359,6 +360,7 @@ build_flags =
|
||||
extends = Heltec_tracker_v2
|
||||
build_flags =
|
||||
${Heltec_tracker_v2.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -390,6 +392,7 @@ build_flags =
|
||||
extends = Heltec_tracker_v2
|
||||
build_flags =
|
||||
${Heltec_tracker_v2.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
|
||||
@@ -425,6 +425,7 @@ lib_deps =
|
||||
extends = heltec_v4_oled
|
||||
build_flags =
|
||||
${heltec_v4_oled.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -451,6 +452,7 @@ build_flags =
|
||||
extends = heltec_v4_oled
|
||||
build_flags =
|
||||
${heltec_v4_oled.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -481,6 +483,7 @@ build_flags =
|
||||
extends = heltec_v4_oled
|
||||
build_flags =
|
||||
${heltec_v4_oled.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
|
||||
@@ -20,6 +20,7 @@ build_flags =
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D DISPLAY_CLASS=SH1106Display
|
||||
-D DISPLAY_ADDRESS=0x3D
|
||||
-D DISPLAY_ADDRESS_ALT=0x3C
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_TX_LED=6
|
||||
-D PIN_BOARD_SDA=17
|
||||
|
||||
@@ -253,6 +253,7 @@ board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${rak4631.build_flags}
|
||||
-D RAK4631_COMPANION_FORCE_LDO=1
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D PIN_USER_BTN=9
|
||||
-D PIN_USER_BTN_ANA=31
|
||||
@@ -309,6 +310,7 @@ board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${rak4631.build_flags}
|
||||
-D RAK4631_COMPANION_FORCE_LDO=1
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D PIN_USER_BTN=9
|
||||
-D PIN_USER_BTN_ANA=31
|
||||
|
||||
@@ -74,6 +74,7 @@ extends = t1000-e
|
||||
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
|
||||
board_upload.maximum_size = 708608
|
||||
build_flags = ${t1000-e.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -99,6 +100,7 @@ extends = t1000-e
|
||||
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
|
||||
board_upload.maximum_size = 708608
|
||||
build_flags = ${t1000-e.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
|
||||
@@ -75,6 +75,7 @@ extends = ThinkNode_M3
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 708608
|
||||
build_flags = ${ThinkNode_M3.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -100,6 +101,7 @@ extends = ThinkNode_M3
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 708608
|
||||
build_flags = ${ThinkNode_M3.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
|
||||
@@ -90,6 +90,10 @@ void initVariant()
|
||||
|
||||
pinMode(PIN_GPS_POWER, OUTPUT);
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
// PIN_GPS_RESET (pin 25 / REINIT) is intentionally left floating (input).
|
||||
// Driving it HIGH holds the L76K silent, so it never streams NMEA and the
|
||||
// firmware reports "no GPS". Letting it float lets the module run.
|
||||
// See GPS_RESET (-1) in variant.h.
|
||||
|
||||
// Power on gps but in standby
|
||||
digitalWrite(PIN_GPS_EN, !GPS_EN_ACTIVE);
|
||||
|
||||
@@ -97,8 +97,11 @@
|
||||
|
||||
#define PIN_GPS_POWER (14)
|
||||
#define PIN_GPS_EN (21) // STANDBY
|
||||
#define PIN_GPS_RESET (25) // REINIT
|
||||
#define PIN_GPS_RESET (25) // REINIT; must float during normal operation
|
||||
#define GPS_POWER_ACTIVE HIGH
|
||||
// The M3's L76K streams NMEA on its own and must not have its REINIT pin driven.
|
||||
// Tell the location provider there is no reset pin so it never touches pin 25
|
||||
// (driving it HIGH holds the module silent).
|
||||
#define GPS_EN_ACTIVE HIGH
|
||||
#define GPS_RESET (-1)
|
||||
#define GPS_BAUDRATE 9600
|
||||
|
||||
@@ -82,7 +82,7 @@ build_flags =
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
-D QSPIFLASH=1
|
||||
|
||||
@@ -30,4 +30,8 @@ void initVariant() {
|
||||
digitalWrite(PIN_GPS_STANDBY, HIGH);
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, HIGH);
|
||||
// PIN_GPS_RESET (pin 29 / REINIT) is intentionally left floating (input).
|
||||
// Driving it HIGH holds the L76K silent, so it never streams NMEA and the
|
||||
// firmware reports "no GPS". Letting it float lets the module run.
|
||||
// See GPS_RESET (-1) in variant.h.
|
||||
}
|
||||
@@ -104,6 +104,10 @@
|
||||
#define PIN_GPS_EN (6) // EN
|
||||
// The L76K REINIT pad must float during normal operation. Driving GPIO29 as
|
||||
// a reset line leaves some M6 units unable to acquire or retain a fix.
|
||||
#define PIN_GPS_RESET (29) // REINIT - must FLOAT; driving it (esp. HIGH) silences the L76K
|
||||
// The M6's L76K streams NMEA on its own and must not have its REINIT pin driven.
|
||||
// Tell the location provider there is no reset pin so it never touches pin 29
|
||||
// (driving it HIGH holds the module silent).
|
||||
#define GPS_RESET (-1)
|
||||
#define PIN_GPS_STANDBY (30) // STANDBY
|
||||
#define PIN_GPS_PPS (31)
|
||||
|
||||
@@ -50,6 +50,7 @@ board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
|
||||
board_upload.maximum_size = 708608
|
||||
build_flags =
|
||||
${Xiao_nrf52.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -73,6 +74,7 @@ board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
|
||||
board_upload.maximum_size = 708608
|
||||
build_flags =
|
||||
${Xiao_nrf52.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
|
||||
@@ -94,6 +94,7 @@ lib_deps =
|
||||
extends = Xiao_S3
|
||||
build_flags =
|
||||
${Xiao_S3.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -121,6 +122,7 @@ extends = env:Xiao_S3_companion_radio_ble
|
||||
extends = Xiao_S3
|
||||
build_flags =
|
||||
${Xiao_S3.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
|
||||
@@ -204,6 +204,7 @@ lib_deps =
|
||||
extends = Xiao_S3_WIO
|
||||
build_flags =
|
||||
${Xiao_S3_WIO.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -227,6 +228,7 @@ lib_deps =
|
||||
extends = Xiao_S3_WIO
|
||||
build_flags =
|
||||
${Xiao_S3_WIO.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -254,6 +256,7 @@ extends = env:Xiao_S3_WIO_companion_radio_ble
|
||||
extends = Xiao_S3_WIO
|
||||
build_flags =
|
||||
${Xiao_S3_WIO.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
@@ -282,6 +285,7 @@ build_src_filter = ${Xiao_S3_WIO.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
build_flags =
|
||||
${Xiao_S3_WIO.build_flags}
|
||||
${companion_rxps.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
|
||||
Reference in new issue
Block a user