feat(repeater): report the TX-failure counters in the RF status reply

A repeater that keeps failing to get its transmits out looks perfectly
healthy over RF: sent/airtime just stop growing and nothing in the status
says why. The Dispatcher already counts those failures (n_tx_start_fail,
n_tx_timeout, from the requeue path); this puts them on the air.

Appended at the END of RepeaterStats on purpose, because the struct goes out
byte-for-byte and clients parse it by fixed offsets. Upstream grew the same
frame the same way -- meshcore-py's parse_status() reads recv_errors only
`if len(data) >= offset + 56`, with the comment "appended in firmware
v1.12.0" -- so older clients keep working and simply do not see the new
fields. Verified against the installed parser before writing this.

A static_assert pins sizeof(RepeaterStats) == 64 (56 + 8, padding-free):
reordering a field or gaining padding would silently shift every offset
after it, and that is not something to leave to review.

Room server keeps its own, already-different stats struct -- not touched.

Builds: SenseCap_Solar_repeater, SenseCap_Solar_repeater_ble, t1000e_repeater.
NOT field-tested yet: needs a repeater flashed with this and queried over RF.
Reading the two values also needs the consumer side extended (the library
parser stops at 56 bytes by design).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5 committed 2026-08-19 19:42:20 +02:00
1 parent 1614cb3e48
commit f80fcc0587
2 files changed
+22

No files matched your search

+2
View File
@@ -497,6 +497,8 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
stats.n_flood_dups = ((SimpleMeshTables *)getTables())->getNumFloodDups();
stats.total_rx_air_time_secs = getReceiveAirTime() / 1000;
stats.n_recv_errors = radio_driver.getPacketsRecvErrors();
stats.n_tx_start_fail = getNumTxStartFail(); // CUSTOM (TeTeHacko)
stats.n_tx_timeout = getNumTxTimeout(); // CUSTOM (TeTeHacko)
memcpy(&reply_data[4], &stats, sizeof(stats));
return 4 + sizeof(stats); // reply_len
+20
View File
@@ -57,8 +57,28 @@ struct RepeaterStats {
uint16_t n_direct_dups, n_flood_dups;
uint32_t total_rx_air_time_secs;
uint32_t n_recv_errors;
// CUSTOM (TeTeHacko): appended at the END on purpose. Clients parse this
// struct by fixed offsets, so fields added here are simply invisible to older
// ones instead of shifting everything after them -- the same way upstream
// grew its companion stats frame (docs/stats_binary_frames.md documents a
// 26-byte "legacy" and a 30-byte frame that appends recv_errors).
//
// These two come from the Dispatcher requeue counters. Without them a
// repeater that keeps failing to get its transmits out looks perfectly
// healthy in every other field: sent/airtime just stop growing, and there is
// nothing in the status that says why.
uint32_t n_tx_start_fail, n_tx_timeout;
};
// This struct goes on the air byte-for-byte, so its size is part of the
// protocol: 56 bytes up to n_recv_errors (what upstream clients expect and
// gate on -- meshcore-py's parse_status() reads recv_errors only
// `if len(data) >= offset + 56`), plus the 8 appended here. Reordering a field
// or letting the compiler insert padding would silently shift every offset
// after it, so pin the number instead of trusting review.
static_assert(sizeof(RepeaterStats) == 64,
"RepeaterStats is a wire format: append only, keep it padding-free");
#ifndef MAX_CLIENTS
#define MAX_CLIENTS 32
#endif