Repeater: TX stall watchdog -- packets queued, nothing sent for 15 min: re-arm, then reboot
pub-release / release (push) Successful in 39m1s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-11-14 11:02:58 +01:00
1 parent 01d66a66ce
commit d9c7b9c008
6 files changed
+167 -4

No files matched your search

+77 -1
View File
@@ -5,6 +5,10 @@
#define RADIO_SILENCE_FILE "/rsilence"
#ifndef RADIO_TXSTALL_MIN
#define RADIO_TXSTALL_MIN 15
#endif
#if defined(NRF52_PLATFORM)
extern "C" {
void enterUf2Dfu(void);
@@ -93,13 +97,16 @@ void NodeMaintenance::begin(FILESYSTEM* fs, NodePrefs* prefs, CommonCLICallbacks
silenceLoad(&backoff);
_silence.begin(millis(), radioActivity(), backoff);
_silence.setMinutes(_prefs->radio_silence_min);
_txstall.begin(millis(), _radio.getPacketsSent(), 0);
_txstall.setMinutes(RADIO_TXSTALL_MIN);
Serial.printf("boot: radio silence watchdog %u min, reboots %lu, backoff x%u\n",
(unsigned) _silence.minutes(), (unsigned long) _silence_reboots,
(unsigned) (1u << _silence.backoff()));
}
void NodeMaintenance::loop() {
void NodeMaintenance::loop(int tx_queued, int tx_due) {
dfuTick();
txStallTick(tx_queued, tx_due);
#ifdef FW_OTA
_fw.loop();
#endif
@@ -123,6 +130,74 @@ void NodeMaintenance::loop() {
if (_silence.takeBackoffCleared()) silenceSave(0);
}
// --- TX stall watchdog ----------------------------------------------------------
// The other half of the silence watchdog: a node that hears fine but no longer
// transmits. mast-three, 14. 11. 2026, during an rxps trial: `sent` frozen for 6+
// hours with the outbound queue full (32), RX counting, no tx_start_fail, no
// tx_timeout, no CAD timeout -- so no adverts, no replies, no admin login over
// the mesh, and nothing the silence watchdog could see. `rxps off` did not bring
// TX back, a reboot did. The cause is not known, so this keys on the symptom:
// packets waiting while the sent counter does not move. Never normal -- the
// longest legitimate holds (airtime budget, CAD retries) are seconds.
// Same staging as the silence watchdog: re-arm the radio (clears latched IRQ
// flags), then reboot. No persisted backoff: a node that cannot send is useless
// either way, and the queue-length/due numbers in the log say where it hung.
void NodeMaintenance::txStallTick(int tx_queued, int tx_due) {
_tx_queued = tx_queued;
_tx_due = tx_due;
uint32_t now = millis();
if (tx_queued <= 0) { // nothing waiting (or not reported): nothing can stall
_txstall.begin(now, _radio.getPacketsSent(), 0);
return;
}
switch (_txstall.poll(now, _radio.getPacketsSent())) {
case RadioSilenceWatchdog::KICK_RX:
Serial.printf("tx stall: %d queued (%d due), nothing sent for %lu min, re-arming radio\n",
tx_queued, tx_due, (unsigned long) (_txstall.quietMs(now) / 60000));
_radio.kickRx();
break;
case RadioSilenceWatchdog::REBOOT:
Serial.printf("tx stall: %d queued (%d due), still nothing sent after %lu min, rebooting\n",
tx_queued, tx_due, (unsigned long) (_txstall.quietMs(now) / 60000));
_silence_reboots++;
silenceSave(_silence.backoff());
delay(100); // let the line out
_board.reboot();
break;
default:
break;
}
}
bool NodeMaintenance::txStallCommand(const char* command, char* reply) {
if (strcmp(command, "get radio.txstall") == 0) {
if (_tx_queued < 0) {
strcpy(reply, "> n/a (this role does not report its queue)");
} else if (_txstall.minutes() == 0) {
strcpy(reply, "> off");
} else {
sprintf(reply, "> %u min, queued %d (due %d), no TX for %lu min, stage %u",
(unsigned) _txstall.minutes(), _tx_queued, _tx_due,
_tx_queued > 0 ? (unsigned long) (_txstall.quietMs(millis()) / 60000) : 0UL,
(unsigned) _txstall.stage());
}
return true;
}
if (memcmp(command, "set radio.txstall ", 18) == 0) {
const char* arg = &command[18];
bool numeric = *arg != 0 && strspn(arg, "0123456789") == strlen(arg);
int m = strcmp(arg, "off") == 0 ? 0 : (numeric ? atoi(arg) : -1);
if (m < 0 || m > RadioSilenceWatchdog::MAX_MINUTES) {
sprintf(reply, "ERR - minutes 0..%u (0/off = disabled)", (unsigned) RadioSilenceWatchdog::MAX_MINUTES);
return true;
}
_txstall.setMinutes((uint16_t) m);
strcpy(reply, "OK (until reboot)");
return true;
}
return false;
}
bool NodeMaintenance::silenceCommand(const char* command, char* reply) {
if (strcmp(command, "get radio.reboots") == 0) {
sprintf(reply, "> %lu", (unsigned long) _silence_reboots);
@@ -255,6 +330,7 @@ bool NodeMaintenance::handleCommand(uint32_t sender_timestamp, const char* comma
if (_fw.handleCommand(sender_timestamp, command, reply)) return true;
#endif
if (silenceCommand(command, reply)) return true;
if (txStallCommand(command, reply)) return true;
if (strcmp(command, "get boot") == 0) {
#if defined(NRF52_PLATFORM)
if (_hardfault_seen) {