Enhance radio watchdog functionality in Dispatcher to prevent false alarms in quiet mesh environments. Introduce a composite timestamp for radio activity, incorporating last RX, ISR events, and successful TX. Update related methods in Dispatcher and RadioLibWrapper to track radio activity accurately. This improves radio management and troubleshooting capabilities.
This commit is contained in:
1 parent
7e4f75c9a5
commit
961f829321
6 files changed
+28
-2618
No files matched your search
+21
-10
@@ -58,16 +58,26 @@ void Dispatcher::loop() {
|
||||
_err_flags |= ERR_EVENT_STARTRX_TIMEOUT;
|
||||
}
|
||||
|
||||
// Radio watchdog: detect radio stuck in RX mode but not receiving any packets
|
||||
if (is_recv && _radio->getLastRecvMillis() > 0) {
|
||||
unsigned long silent_ms = _ms->getMillis() - _radio->getLastRecvMillis();
|
||||
unsigned long since_recovery = _ms->getMillis() - last_watchdog_recovery;
|
||||
if (silent_ms > RADIO_WATCHDOG_MS && since_recovery > RADIO_WATCHDOG_MS) {
|
||||
_err_flags |= ERR_EVENT_RADIO_WATCHDOG;
|
||||
MESH_DEBUG_PRINTLN("Radio watchdog: silent %lu ms, state=%d, recovering", silent_ms, _radio->getRadioState());
|
||||
_radio->idle();
|
||||
_radio->startRecv();
|
||||
last_watchdog_recovery = _ms->getMillis();
|
||||
// Radio watchdog: detect radio stuck in RX mode but not receiving any packets.
|
||||
// Use a composite "last radio activity" timestamp: the most recent of any valid RX,
|
||||
// any ISR event (even CRC errors), or any successful TX. This prevents false firings
|
||||
// in quiet mesh environments where packets may be more than RADIO_WATCHDOG_MS apart,
|
||||
// while still catching a truly stuck radio (PSRAM starvation → missed ISR → no activity).
|
||||
{
|
||||
unsigned long last_recv = _radio->getLastRecvMillis();
|
||||
unsigned long last_irq = _radio->getLastRadioInterruptMillis();
|
||||
unsigned long last_active = (last_recv > last_irq ? last_recv : last_irq);
|
||||
if (last_radio_active_ms > last_active) last_active = last_radio_active_ms;
|
||||
if (is_recv && last_active > 0) {
|
||||
unsigned long silent_ms = _ms->getMillis() - last_active;
|
||||
unsigned long since_recovery = _ms->getMillis() - last_watchdog_recovery;
|
||||
if (silent_ms > RADIO_WATCHDOG_MS && since_recovery > RADIO_WATCHDOG_MS) {
|
||||
_err_flags |= ERR_EVENT_RADIO_WATCHDOG;
|
||||
MESH_DEBUG_PRINTLN("Radio watchdog: silent %lu ms, state=%d, recovering", silent_ms, _radio->getRadioState());
|
||||
_radio->idle();
|
||||
_radio->startRecv();
|
||||
last_watchdog_recovery = _ms->getMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +91,7 @@ void Dispatcher::loop() {
|
||||
next_tx_time = futureMillis(t * getAirtimeBudgetFactor());
|
||||
|
||||
_radio->onSendFinished();
|
||||
last_radio_active_ms = _ms->getMillis(); // TX success → radio is alive
|
||||
logTx(outbound, 2 + outbound->getPathByteLen() + outbound->payload_len);
|
||||
if (outbound->isRouteFlood()) {
|
||||
n_sent_flood++;
|
||||
|
||||
Reference in new issue
Block a user