Sleep between noise-floor samples and reduce idle refreshes
This commit is contained in:
1 parent
50428f0fb7
commit
dd7a10f9aa
38 files changed
+955
-121
No files matched your search
@@ -549,6 +549,11 @@ void Dispatcher::logPacketLine(const char* direction, const Packet* packet,
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Dispatcher::getNextNoiseFloorWakeDelay(uint32_t& delay_millis) const {
|
||||
return radio_available
|
||||
&& _radio->getNoiseFloorWakeDelay(_ms->getMillis(), delay_millis);
|
||||
}
|
||||
|
||||
bool Dispatcher::getNextQueueWakeDelay(uint32_t& delay_millis) const {
|
||||
if (isDualRadioActive()) { delay_millis = 0; return true; }
|
||||
#if MESH_ENABLE_FOREIGN_RADIO
|
||||
|
||||
@@ -215,6 +215,15 @@ public:
|
||||
return getNoiseFloorCalibrationSecondsRemaining();
|
||||
}
|
||||
virtual bool isCalibratingNoiseFloor() const { return false; }
|
||||
// MCU service deadline only: RF calibration can continue in continuous RX
|
||||
// while the CPU idles between readings. Unknown implementations retain the
|
||||
// conservative whole-batch veto rather than inventing a safe sample gap.
|
||||
virtual bool getNoiseFloorWakeDelay(uint32_t now, uint32_t& delay_ms) const {
|
||||
(void)now;
|
||||
if (!isCalibratingNoiseFloor()) return false;
|
||||
delay_ms = 0;
|
||||
return true;
|
||||
}
|
||||
// A failed receive start may need a later retry without keeping the MCU
|
||||
// awake. Transports without a deferred receive retry retain their cadence.
|
||||
virtual bool getReceiveRetryDelay(uint32_t now, uint32_t& delay_ms) const {
|
||||
@@ -615,6 +624,9 @@ protected:
|
||||
uint32_t getTransmitAirtime(const Packet* packet, int wire_length) const;
|
||||
|
||||
public:
|
||||
// Kept separate from whole-second queue sleep policy: a 50 ms calibration
|
||||
// deadline needs a bounded millisecond wake, not a zero-second queue veto.
|
||||
bool getNextNoiseFloorWakeDelay(uint32_t& delay_millis) const;
|
||||
void begin();
|
||||
void loop();
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
|
||||
@@ -179,6 +179,18 @@ public:
|
||||
#if defined(ARDUINO)
|
||||
if (powerdiag::enabled()) powerdiag::sleepEnd(micros());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
// Bounded MCU idle without changing the radio's receive mode. Interrupt-idle
|
||||
// ports keep their existing periodic-clock wake contract; timed sleepers
|
||||
// override this to provide a real sub-second timer. An unknown timed port
|
||||
// must not round a short deadline up and sleep past it.
|
||||
virtual void sleepMilliseconds(uint32_t millisecs) {
|
||||
if (millisecs == 0) return;
|
||||
#if defined(NRF52_PLATFORM) || defined(RP2040_PLATFORM) || defined(STM32_PLATFORM)
|
||||
sleep(0);
|
||||
#else
|
||||
if (millisecs >= 1000UL) sleep(millisecs / 1000UL);
|
||||
#endif
|
||||
}
|
||||
virtual uint32_t getGpio() { return 0; }
|
||||
|
||||
@@ -128,6 +128,15 @@ public:
|
||||
}
|
||||
|
||||
void sleep(uint32_t secs) override {
|
||||
sleepMicroseconds(static_cast<uint64_t>(secs) * 1000000ULL);
|
||||
}
|
||||
|
||||
void sleepMilliseconds(uint32_t millisecs) override {
|
||||
if (millisecs != 0)
|
||||
sleepMicroseconds(static_cast<uint64_t>(millisecs) * 1000ULL, true);
|
||||
}
|
||||
|
||||
void sleepMicroseconds(uint64_t wake_us, bool require_timer = false) {
|
||||
using mesh::powerdiag::Reason;
|
||||
const bool diagnostics = mesh::powerdiag::enabled();
|
||||
// Native USB loses its connection in light sleep. An enumerated host
|
||||
@@ -167,8 +176,14 @@ public:
|
||||
// Otherwise its real elapsed time would be mislabelled as blocked time.
|
||||
esp_err_t setup_error = ESP_OK;
|
||||
// Configure timer wakeup
|
||||
if (secs > 0) {
|
||||
const esp_err_t error = esp_sleep_enable_timer_wakeup(secs * 1000000ULL); // Wake up periodically to do scheduled jobs
|
||||
if (wake_us > 0) {
|
||||
const esp_err_t error = esp_sleep_enable_timer_wakeup(wake_us);
|
||||
// A calibration slice must not inherit an old, longer timer after a
|
||||
// setup failure. Keep the legacy seconds API's policy unchanged.
|
||||
if (require_timer && error != ESP_OK) {
|
||||
if (diagnostics) mesh::powerdiag::boardError(error, millis());
|
||||
return;
|
||||
}
|
||||
if (diagnostics && error != ESP_OK) setup_error = error;
|
||||
}
|
||||
|
||||
@@ -181,7 +196,7 @@ public:
|
||||
const int button_gpio = -1;
|
||||
#endif
|
||||
if (!radio_wakeup && button_gpio < 0) {
|
||||
if (secs > 0) {
|
||||
if (wake_us > 0) {
|
||||
if (diagnostics) mesh::powerdiag::sleepBegin(micros());
|
||||
const esp_err_t error = esp_light_sleep_start();
|
||||
if (diagnostics) {
|
||||
|
||||
@@ -17,6 +17,11 @@ inline uint32_t powerSaveSleepSeconds(uint32_t delay_ms) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline uint32_t limitSleepMilliseconds(uint32_t max_seconds, uint32_t deadline_ms) {
|
||||
const uint64_t maximum_ms = static_cast<uint64_t>(max_seconds) * 1000ULL;
|
||||
return deadline_ms < maximum_ms ? deadline_ms : static_cast<uint32_t>(maximum_ms);
|
||||
}
|
||||
|
||||
inline uint16_t medianVoltage(uint16_t a, uint16_t b, uint16_t c) {
|
||||
if (a > b) { uint16_t t = a; a = b; b = t; }
|
||||
if (b > c) { uint16_t t = b; b = c; c = t; }
|
||||
|
||||
@@ -31,7 +31,12 @@ public:
|
||||
}
|
||||
bool complete() const { return _count == SAMPLE_COUNT; }
|
||||
bool ready(uint32_t now) const {
|
||||
return !complete() && (_count == 0 || uint32_t(now - _last_sample_at) >= SAMPLE_INTERVAL_MS);
|
||||
return !complete() && sampleDelay(now) == 0;
|
||||
}
|
||||
uint32_t sampleDelay(uint32_t now) const {
|
||||
if (_count == 0 || complete()) return 0;
|
||||
const uint32_t elapsed = now - _last_sample_at;
|
||||
return elapsed >= SAMPLE_INTERVAL_MS ? 0 : SAMPLE_INTERVAL_MS - elapsed;
|
||||
}
|
||||
uint8_t heldBlocks() const { return _held_blocks; }
|
||||
|
||||
|
||||
@@ -23,10 +23,11 @@ extern "C" caddr_t _sbrk(int increment);
|
||||
|
||||
// Bounded noise-floor calibration in continuous RX, including RXPS refreshes.
|
||||
// Requests are coalesced so retries cannot repeatedly force continuous RX.
|
||||
#define NF_CALIB_INTERVAL_MS 2000UL // continuous-RX refresh / forced-window cooldown
|
||||
// A quiet block needs about 3.2 s of continuous RX. Do not reopen one after
|
||||
// only 2 s of duty cycling: routine maintenance would defeat RX power saving.
|
||||
#define NF_CALIB_INTERVAL_MS (60UL * 1000UL)
|
||||
#define NF_RXPS_REFRESH_INTERVAL_MS (60UL * 1000UL)
|
||||
// A successful baseline need not hold the radio in continuous RX every minute.
|
||||
// Rejected rise/failed attempts retain the shorter retry, not this lazy cadence.
|
||||
#define NF_LAZY_REFRESH_INTERVAL_MS (5UL * 60UL * 1000UL)
|
||||
#define NF_CALIB_TIMEOUT_MS NoiseFloorEstimator::WINDOW_TIMEOUT_MS
|
||||
#define NF_CONTINUOUS_TIMEOUT_MS NoiseFloorEstimator::WINDOW_TIMEOUT_MS
|
||||
#define NF_CALIB_SETTLE_MS RadioLibWrapper::NoiseFloorSettleMillis
|
||||
@@ -232,6 +233,7 @@ void RadioLibWrapper::begin() {
|
||||
_floor_estimator.reset(true);
|
||||
_secondary_floor_estimator.reset(true);
|
||||
_nf_calib_active = false;
|
||||
_nf_window_armed = _nf_lazy_refresh = _nf_refresh_attempted = false;
|
||||
_nf_last_calib = 0;
|
||||
_nf_sample_from = 0;
|
||||
_nf_refresh_requested = true; // establish one baseline after startup
|
||||
@@ -784,6 +786,7 @@ void RadioLibWrapper::serviceProfileScan() {
|
||||
_nf_refresh_requested = true;
|
||||
_nf_last_calib = 0;
|
||||
_nf_calib_deadline = 0;
|
||||
_nf_window_armed = _nf_lazy_refresh = _nf_refresh_attempted = false;
|
||||
_floor_estimator.reset(true);
|
||||
_secondary_floor_estimator.reset(true);
|
||||
_profile_refresh_required = true; // refresh side detectors even if the tuple is unchanged
|
||||
@@ -824,6 +827,7 @@ void RadioLibWrapper::serviceProfileScan() {
|
||||
_nf_refresh_requested = true;
|
||||
_nf_last_calib = 0;
|
||||
_nf_calib_deadline = 0;
|
||||
_nf_window_armed = _nf_lazy_refresh = _nf_refresh_attempted = false;
|
||||
_floor_estimator.reset(true);
|
||||
_secondary_floor_estimator.reset(true);
|
||||
}
|
||||
@@ -970,13 +974,7 @@ void RadioLibWrapper::triggerNoiseFloorCalibrate(int threshold) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_rx_ps_enabled && !_rx_ps_continuous_fallback) {
|
||||
requestPeriodicNoiseFloorRefresh();
|
||||
} else {
|
||||
// RX is already continuous. Keep the original maintenance-tick behavior;
|
||||
// only passive retry probes apply the existing two-second age check.
|
||||
requestNoiseFloorRefresh();
|
||||
}
|
||||
requestPeriodicNoiseFloorRefresh();
|
||||
}
|
||||
|
||||
void RadioLibWrapper::recalibrateNoiseFloor() {
|
||||
@@ -986,29 +984,34 @@ void RadioLibWrapper::recalibrateNoiseFloor() {
|
||||
_noise_floor_secondary_valid = false;
|
||||
_nf_refresh_requested = true;
|
||||
_nf_last_calib = 0;
|
||||
_nf_lazy_refresh = _nf_refresh_attempted = false;
|
||||
_floor_estimator.reset(true);
|
||||
_secondary_floor_estimator.reset(true);
|
||||
|
||||
const unsigned long now = millis();
|
||||
_nf_sample_from = now + NF_CALIB_SETTLE_MS;
|
||||
_nf_sample_from = uint32_t(now) + (_rx_ps_armed ? 0 : NF_CALIB_SETTLE_MS);
|
||||
if (_nf_calib_active) {
|
||||
// Keep an already-open continuous-RX calibration window active, but restart
|
||||
// its sample and timeout bounds around the newly selected gain path.
|
||||
_nf_calib_deadline = now + NF_CALIB_TIMEOUT_MS;
|
||||
_nf_window_armed = true;
|
||||
} else {
|
||||
// Continuous RX starts its deadline in loop(); RX power saving opens a
|
||||
// bounded continuous-RX window in noiseFloorCalibCheck().
|
||||
_nf_calib_deadline = 0;
|
||||
_nf_window_armed = false;
|
||||
}
|
||||
}
|
||||
|
||||
void RadioLibWrapper::requestPeriodicNoiseFloorRefresh() {
|
||||
const uint32_t interval = _rx_ps_enabled && !_rx_ps_continuous_fallback
|
||||
? NF_RXPS_REFRESH_INTERVAL_MS : NF_CALIB_INTERVAL_MS;
|
||||
const uint32_t interval = _nf_lazy_refresh ? NF_LAZY_REFRESH_INTERVAL_MS
|
||||
: (_rx_ps_enabled && !_rx_ps_continuous_fallback
|
||||
? NF_RXPS_REFRESH_INTERVAL_MS : NF_CALIB_INTERVAL_MS);
|
||||
// Startup must not wait for a maintenance tick. Subsequent attempts, even
|
||||
// failed ones, need a real rest interval. Forced RF-path/AGC recalibration
|
||||
// bypasses this routine policy and retains its existing prompt behavior.
|
||||
if (_profiles.enabled() || (!_noise_floor_valid && _nf_last_calib == 0)
|
||||
if (_profiles.enabled()
|
||||
|| (!_noise_floor_valid && _nf_last_calib == 0 && !_nf_refresh_attempted)
|
||||
|| static_cast<uint32_t>(millis() - _nf_last_calib) >= interval) {
|
||||
requestNoiseFloorRefresh();
|
||||
}
|
||||
@@ -1017,9 +1020,12 @@ void RadioLibWrapper::requestPeriodicNoiseFloorRefresh() {
|
||||
void RadioLibWrapper::requestNoiseFloorRefresh() {
|
||||
if (_nf_refresh_requested) return;
|
||||
_nf_refresh_requested = true;
|
||||
_nf_lazy_refresh = false;
|
||||
_floor_estimator.reset();
|
||||
_secondary_floor_estimator.reset();
|
||||
_nf_calib_deadline = 0; // starts when continuous RX is actually available
|
||||
_nf_window_armed = false;
|
||||
_nf_sample_from = uint32_t(millis()) + (_rx_ps_armed ? 0 : NF_CALIB_SETTLE_MS);
|
||||
}
|
||||
|
||||
void RadioLibWrapper::doResetAGC() {
|
||||
@@ -1189,27 +1195,32 @@ bool RadioLibWrapper::isPacketPendingOrReceiving() {
|
||||
}
|
||||
|
||||
void RadioLibWrapper::noiseFloorCalibCheck(unsigned long now) {
|
||||
const uint32_t now_ms = static_cast<uint32_t>(now);
|
||||
if (_nf_calib_active) {
|
||||
if (!_rx_ps_enabled
|
||||
|| ((long)(now - _nf_calib_deadline) >= 0
|
||||
|| (static_cast<int32_t>(now_ms - uint32_t(_nf_calib_deadline)) >= 0
|
||||
&& !_floor_estimator.complete())) {
|
||||
// powersaving turned off mid-window, or the batch couldn't complete
|
||||
// (busy channel) - keep the previous floor
|
||||
endNoiseFloorCalib(now);
|
||||
} else if (_rx_ps_armed && !isPacketPendingOrReceiving()) {
|
||||
} else if (_rx_ps_armed
|
||||
&& static_cast<int32_t>(now_ms - uint32_t(_nf_sample_from)) >= 0) {
|
||||
// A packet can delay the transition from RXPS to continuous RX. Retry
|
||||
// once the radio is idle without discarding a pending interrupt.
|
||||
requestRestartRecv();
|
||||
// at a bounded cadence without discarding a pending interrupt.
|
||||
_nf_sample_from = now_ms + NoiseFloorEstimator::SAMPLE_INTERVAL_MS;
|
||||
if (!isPacketPendingOrReceiving()) requestRestartRecv();
|
||||
}
|
||||
} else if (_nf_refresh_requested && _rx_ps_enabled && _rx_ps_armed && state == STATE_RX
|
||||
&& ((!_noise_floor_valid && _nf_last_calib == 0)
|
||||
|| now - _nf_last_calib >= NF_CALIB_INTERVAL_MS)
|
||||
&& !isPacketPendingOrReceiving()) {
|
||||
&& static_cast<int32_t>(now_ms - uint32_t(_nf_sample_from)) >= 0) {
|
||||
// never interrupt an ongoing reception to calibrate (a TX in flight is
|
||||
// already excluded by state == STATE_RX); retries next loop iteration
|
||||
// already excluded by state == STATE_RX). A requested forced baseline is
|
||||
// prompt; routine cooldown was enforced before creating the request.
|
||||
_nf_sample_from = now_ms + NoiseFloorEstimator::SAMPLE_INTERVAL_MS;
|
||||
if (isPacketPendingOrReceiving()) return;
|
||||
_nf_calib_active = true;
|
||||
_nf_calib_deadline = now + NF_CALIB_TIMEOUT_MS;
|
||||
_nf_sample_from = now + NF_CALIB_SETTLE_MS;
|
||||
_nf_calib_deadline = now_ms + NF_CALIB_TIMEOUT_MS;
|
||||
_nf_window_armed = true;
|
||||
_nf_sample_from = now_ms + NF_CALIB_SETTLE_MS;
|
||||
_floor_estimator.reset();
|
||||
if (!isPacketPendingOrReceiving()) {
|
||||
requestRestartRecv(); // startReceiveMode() selects continuous RX
|
||||
@@ -1222,6 +1233,8 @@ void RadioLibWrapper::endNoiseFloorCalib(unsigned long now) {
|
||||
_nf_refresh_requested = false;
|
||||
_nf_last_calib = now;
|
||||
_nf_calib_deadline = 0;
|
||||
_nf_window_armed = false;
|
||||
_nf_refresh_attempted = true;
|
||||
// force a receive re-arm back into duty-cycle mode, but don't clobber a
|
||||
// completed-but-unread packet or an in-flight TX (recvRaw()/onSendFinished()
|
||||
// will re-arm right after those anyway; same guard style as setRxPowerSaving)
|
||||
@@ -1802,14 +1815,16 @@ void RadioLibWrapper::loop() {
|
||||
}
|
||||
if (_nf_refresh_requested
|
||||
&& (!_rx_ps_enabled || _rx_ps_continuous_fallback)
|
||||
&& _nf_calib_deadline == 0
|
||||
&& !_nf_window_armed
|
||||
&& state == STATE_RX) {
|
||||
// Measure the awake-time bound from actual continuous RX, not from begin()
|
||||
// or a request made while the radio is idle, transmitting, or starting up.
|
||||
_nf_calib_deadline = now + NF_CONTINUOUS_TIMEOUT_MS;
|
||||
_nf_calib_deadline = uint32_t(now) + NF_CONTINUOUS_TIMEOUT_MS;
|
||||
_nf_window_armed = true;
|
||||
}
|
||||
if (_nf_refresh_requested && _floor_estimator.complete()) {
|
||||
if (_floor_estimator.publish(_noise_floor_centi_dbm, _noise_floor_valid)) {
|
||||
_nf_lazy_refresh = _floor_estimator.publish(_noise_floor_centi_dbm, _noise_floor_valid);
|
||||
if (_nf_lazy_refresh) {
|
||||
_noise_floor_valid = true;
|
||||
// Retain the whole-dB API/wire format and the fractional display value.
|
||||
_noise_floor = (_noise_floor_centi_dbm - 50) / 100;
|
||||
@@ -1817,6 +1832,8 @@ void RadioLibWrapper::loop() {
|
||||
_nf_refresh_requested = false;
|
||||
_nf_last_calib = now;
|
||||
_nf_calib_deadline = 0;
|
||||
_nf_window_armed = false;
|
||||
_nf_refresh_attempted = true;
|
||||
|
||||
MESH_DEBUG_PRINTLN("RadioLibWrapper: noise_floor = %d", (int)_noise_floor);
|
||||
|
||||
@@ -1828,14 +1845,17 @@ void RadioLibWrapper::loop() {
|
||||
|
||||
if (_nf_refresh_requested
|
||||
&& (!_rx_ps_enabled || _rx_ps_continuous_fallback)
|
||||
&& _nf_calib_deadline != 0
|
||||
&& (long)(now - _nf_calib_deadline) >= 0) {
|
||||
&& _nf_window_armed
|
||||
&& static_cast<int32_t>(uint32_t(now) - uint32_t(_nf_calib_deadline)) >= 0) {
|
||||
// A continuously busy channel can reject every candidate sample. Do not
|
||||
// keep the MCU awake indefinitely; retain the previous floor and let the
|
||||
// next scheduled calibration request retry an invalid startup baseline.
|
||||
_nf_refresh_requested = false;
|
||||
_nf_last_calib = now;
|
||||
_nf_calib_deadline = 0;
|
||||
_nf_window_armed = false;
|
||||
_nf_lazy_refresh = false;
|
||||
_nf_refresh_attempted = true;
|
||||
_floor_estimator.reset();
|
||||
}
|
||||
|
||||
@@ -1848,12 +1868,12 @@ void RadioLibWrapper::loop() {
|
||||
// ~-127 dBm garbage).
|
||||
if (!_rx_ps_armed
|
||||
&& _floor_estimator.ready(static_cast<uint32_t>(now))
|
||||
&& !(_nf_sample_from != 0 && (long)(now - _nf_sample_from) < 0)
|
||||
&& !isChipBusy() && !isPacketPendingOrReceiving()) {
|
||||
&& static_cast<int32_t>(uint32_t(now) - uint32_t(_nf_sample_from)) >= 0) {
|
||||
// Silent RX loss can leave software in STATE_RX while standby RSSI is
|
||||
// meaningless. Reject that observation before it can lower the floor.
|
||||
// Space rejected attempts too; an empty block must not hammer SPI.
|
||||
_nf_sample_from = now + NoiseFloorEstimator::SAMPLE_INTERVAL_MS;
|
||||
_nf_sample_from = uint32_t(now) + NoiseFloorEstimator::SAMPLE_INTERVAL_MS;
|
||||
if (isChipBusy() || isPacketPendingOrReceiving()) return;
|
||||
if (readReceiveMode() == 0) {
|
||||
_floor_estimator.reset(true);
|
||||
return;
|
||||
@@ -1882,7 +1902,8 @@ void RadioLibWrapper::startRecv() {
|
||||
state = STATE_RX;
|
||||
// RSSI is unsettled after every RX entry, including CAD/TX completion.
|
||||
// Keep the partial block, but wait for the frontend before its next sample.
|
||||
_nf_sample_from = millis() + NF_CALIB_SETTLE_MS;
|
||||
_nf_sample_from = uint32_t(millis())
|
||||
+ (_rx_ps_armed ? 0 : NF_CALIB_SETTLE_MS);
|
||||
_startrx_fails = 0;
|
||||
_rx_retry_pending = false;
|
||||
_rx_retry_delay_ms = 0;
|
||||
@@ -1968,6 +1989,34 @@ bool RadioLibWrapper::getReceiveRetryDelay(uint32_t now, uint32_t& delay_ms) con
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RadioLibWrapper::getNoiseFloorWakeDelay(uint32_t now, uint32_t& delay_ms) const {
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
if (_beacon_owned) return false;
|
||||
#endif
|
||||
// Dual-profile scanning and foreign owners retain their existing cadence.
|
||||
// Failed RX startup has its separate retry deadline, not an active batch.
|
||||
if (_cw_active || _profiles.enabled() || state != STATE_RX
|
||||
|| (!_nf_refresh_requested && !_nf_calib_active)) return false;
|
||||
if (_floor_estimator.complete()
|
||||
|| (!_nf_window_armed && !_rx_ps_armed)) {
|
||||
delay_ms = 0; // Publish or establish the continuous-RX timeout first.
|
||||
return true;
|
||||
}
|
||||
|
||||
const int32_t until_attempt = static_cast<int32_t>(uint32_t(_nf_sample_from) - now);
|
||||
delay_ms = until_attempt > 0 ? uint32_t(until_attempt) : 0;
|
||||
if (!_rx_ps_armed) {
|
||||
const uint32_t until_sample = _floor_estimator.sampleDelay(now);
|
||||
if (until_sample > delay_ms) delay_ms = until_sample;
|
||||
}
|
||||
if (_nf_window_armed) {
|
||||
const int32_t until_timeout = static_cast<int32_t>(uint32_t(_nf_calib_deadline) - now);
|
||||
const uint32_t timeout = until_timeout > 0 ? uint32_t(until_timeout) : 0;
|
||||
if (timeout < delay_ms) delay_ms = timeout;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// RX PowerSaving
|
||||
bool RadioLibWrapper::setRxPowerSaving(bool enabled, uint32_t rx_us, uint32_t sleep_us) {
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
|
||||
@@ -171,6 +171,12 @@ protected:
|
||||
// refresh briefly drops to continuous RX, publishes an average, then re-arms
|
||||
// the duty cycle.
|
||||
bool _nf_calib_active;
|
||||
// Explicit arming distinguishes a legitimate wrapped deadline of zero.
|
||||
bool _nf_window_armed = false;
|
||||
// Only an accepted full block earns the lazy routine cadence. Held rises
|
||||
// and failed/timeout attempts retain a one-minute retry without hot polling.
|
||||
bool _nf_lazy_refresh = false;
|
||||
bool _nf_refresh_attempted = false;
|
||||
unsigned long _nf_last_calib; // millis of last completed/attempted window
|
||||
unsigned long _nf_calib_deadline; // abort window if the batch can't complete
|
||||
unsigned long _nf_sample_from; // no samples before this (RX entry settle)
|
||||
@@ -532,14 +538,15 @@ public:
|
||||
// true while the watchdog is actively watching for BUSY transitions; used by
|
||||
// the app's hasPendingWork() to keep the MCU out of light sleep for the window
|
||||
bool isWatchdogObserving() const { return _wd_observe_until != 0; }
|
||||
// true while a noise-floor batch needs prompt loop service; the app's
|
||||
// hasPendingWork() keeps the MCU awake for the bounded spaced-sample window.
|
||||
// Full-batch RF ownership for UI and recovery guards. CPU idle between
|
||||
// readings is governed separately by getNoiseFloorWakeDelay().
|
||||
bool isCalibratingNoiseFloor() const override {
|
||||
return isInRecvMode() && !_rx_ps_armed && (_nf_calib_active
|
||||
|| (_nf_refresh_requested
|
||||
&& (!_rx_ps_enabled || _rx_ps_continuous_fallback)));
|
||||
}
|
||||
bool getReceiveRetryDelay(uint32_t now, uint32_t& delay_ms) const override;
|
||||
bool getNoiseFloorWakeDelay(uint32_t now, uint32_t& delay_ms) const override;
|
||||
void resetStats() { n_recv = n_sent = n_recv_errors = 0; }
|
||||
|
||||
uint8_t getRadioState() const override;
|
||||
|
||||
Reference in new issue
Block a user