fix(mesh/tx): requeue failed transmits with backoff instead of dropping

A TX that fails to start (startTransmit error) or never completes
(send-complete IRQ lost) was released permanently — with an nRF52
SoftDevice servicing BLE connection events this silently ate ~40 % of
DIRECT-route forwards (measured A/B on mast-three: direct_rx +5 / direct_tx
+3 with an idle BLE connection, 5/5 with BLE off). Flood redundancy
masked the same loss for flood traffic.

Retry up to MESH_TX_RETRIES (3) with a short growing backoff; a
duplicate on air is harmless (hasSeen dedup). New tallies
tx_start_fail/tx_timeout in stats-packets + ERR_EVENT_TX_* flags make
this failure class visible at last.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Fable 5 committed 2026-07-21 13:43:34 +02:00
1 parent c5fb0fb4ce
commit 6e076a6e8d
5 files changed
+54 -11

No files matched your search

+14
View File
@@ -108,6 +108,17 @@ typedef uint32_t DispatcherAction;
#define ERR_EVENT_FULL (1 << 0)
#define ERR_EVENT_CAD_TIMEOUT (1 << 1)
#define ERR_EVENT_STARTRX_TIMEOUT (1 << 2)
#define ERR_EVENT_TX_START_FAIL (1 << 3) // CUSTOM (TeTeHacko): startSendRaw() returned error (radio busy/SPI hiccup)
#define ERR_EVENT_TX_TIMEOUT (1 << 4) // CUSTOM (TeTeHacko): send-complete IRQ never came before outbound_expiry
// CUSTOM (TeTeHacko): how many times a failed TX (start fail or send timeout) is
// requeued before the packet is finally dropped. Transient failures are common
// when the nRF52 SoftDevice (BLE connection events) preempts the LoRa driver —
// measured ~40 % direct-forward loss with an idle BLE connection. A short retry
// converts those losses into ~100-300 ms of extra latency.
#ifndef MESH_TX_RETRIES
#define MESH_TX_RETRIES 3
#endif
/**
* \brief The low-level task that manages detecting incoming Packets, and the queueing
@@ -123,6 +134,7 @@ class Dispatcher {
bool prev_isrecv_mode;
uint32_t n_sent_flood, n_sent_direct;
uint32_t n_recv_flood, n_recv_direct;
uint32_t n_tx_start_fail, n_tx_timeout; // CUSTOM (TeTeHacko): TX failure tallies (see MESH_TX_RETRIES)
unsigned long tx_budget_ms;
unsigned long last_budget_update;
unsigned long duty_cycle_window_ms;
@@ -184,6 +196,8 @@ public:
uint32_t getNumSentDirect() const { return n_sent_direct; }
uint32_t getNumRecvFlood() const { return n_recv_flood; }
uint32_t getNumRecvDirect() const { return n_recv_direct; }
uint32_t getNumTxStartFail() const { return n_tx_start_fail; } // CUSTOM (TeTeHacko)
uint32_t getNumTxTimeout() const { return n_tx_timeout; } // CUSTOM (TeTeHacko)
void resetStats() {
n_sent_flood = n_sent_direct = n_recv_flood = n_recv_direct = 0;
_err_flags = 0;