fix(companion): CLI NaN, APC on TX changes, tz-aware alarm, late ACKs, ping timeout and widths, TX limits

- set af / dutycycle / rxdelay reject nan.
- A TX power change from the app or CLI re-baselines APC.
- CMD_SET_RADIO_PARAMS stores repeat as 0/1.
- The alarm reschedules itself when the time zone changes.
- A late ACK for an earlier DM attempt marks it delivered.
- A new auto-advert interval counts from the last advert.
- Both UIs take the TX power range from radioctl, up to MAX_LORA_TX_POWER
  (30 dBm on the GAT562 30S).
- The ping timeout comes from the airtime; 3-byte path hash mode pings with
  4-byte trace hashes, and trace flags are right for width 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-12 18:00:49 +02:00
co-authored by Claude Opus 5.5
parent cd294613ea
commit 28d8291e33
14 changed files with 76 additions and 29 deletions
+8 -3
View File
@@ -25,8 +25,9 @@ int MyMesh::getDiscoverResults(DiscoverResult dest[], int max_count) {
// ── Ping/Trace functionality ─────────────────────────────────────────────────
uint32_t MyMesh::sendPing(const uint8_t* dest_pubkey, uint8_t hash_width) {
if (hash_width == 0 || hash_width > 2) return 0;
uint32_t MyMesh::sendPing(const uint8_t* dest_pubkey, uint8_t hash_width, uint32_t* est_timeout) {
// A trace's hashes are 1 << flags bytes wide: 1, 2, 4 (no 3).
if (hash_width != 1 && hash_width != 2 && hash_width != 4) return 0;
// Generate random tag and auth code
uint32_t tag, auth;
@@ -61,9 +62,13 @@ uint32_t MyMesh::sendPing(const uint8_t* dest_pubkey, uint8_t hash_width) {
memcpy(path, dest_pubkey, path_len);
// Create and send trace packet
auto pkt = createTrace(tag, auth, hash_width - 1); // flags = hash_width - 1
auto pkt = createTrace(tag, auth, hash_width == 4 ? 2 : hash_width - 1); // flags = log2(hash_width)
if (pkt) {
sendDirect(pkt, path, path_len);
if (est_timeout) { // as CMD_SEND_TRACE_PATH answers the app: from the airtime, one hop
uint32_t t = _radio->getEstAirtimeFor(pkt->payload_len + pkt->path_len + 2);
*est_timeout = calcDirectTimeoutMillisFor(t, 1);
}
return tag;
}