From ca23d38ef6c6322273f1b1cd6ab4085dfc3d3daf Mon Sep 17 00:00:00 2001 From: mikecarper Date: Mon, 28 Sep 2026 15:45:35 -0700 Subject: [PATCH] Keep get radio reply compatible with Companion apps --- docs/cli_commands.md | 4 ++++ src/helpers/CommonCLI.cpp | 2 +- test/fixtures/cli_settings/main.cpp | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/cli_commands.md b/docs/cli_commands.md index 5df0c5df..bb7fab9c 100644 --- a/docs/cli_commands.md +++ b/docs/cli_commands.md @@ -1191,6 +1191,10 @@ capacity. Remote use follows the existing administrator-command permissions. **Default:** `869.618,62.5,8,5` +`get radio` returns exactly four comma-separated fields for compatibility with +existing Companion apps. On dual-radio builds, use `get radio2` and +`get radio.timing` for profile and timing diagnostics. + **Note:** Requires reboot to apply. If RXPS is enabled and the saved minimum level/preamble cannot safely cover the new radio timing, the command reply reports the effective level and preamble, or `RXPS continuous-fast` when no diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index 22140673..711fd90c 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -4853,8 +4853,8 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep char freq[16], bw[16]; strcpy(freq, StrHelper::ftoa(_prefs->freq)); strcpy(bw, StrHelper::ftoa3(_prefs->bw)); + // The official app parses this reply as exactly four CSV fields. sprintf(reply, "> %s,%s,%d,%d", freq, bw, (uint32_t)_prefs->sf, (uint32_t)_prefs->cr); - _radio_profiles.appendSavedPreamble(reply, 160, _prefs->sf, _prefs->bw); } else if (configKeyEquals(config, "rxdelay")) { sprintf(reply, "> %s", StrHelper::ftoa(_prefs->rx_delay_base)); } else if (configKeyEquals(config, "txdelay")) { diff --git a/test/fixtures/cli_settings/main.cpp b/test/fixtures/cli_settings/main.cpp index 13695e05..a03130ab 100644 --- a/test/fixtures/cli_settings/main.cpp +++ b/test/fixtures/cli_settings/main.cpp @@ -16,7 +16,10 @@ struct RadioProfileCLI { } bool savePrimaryPreamble(uint16_t) { return true; } void appendPreamble(char*, size_t) {} - void appendSavedPreamble(char*, size_t, uint8_t, float) {} + void appendSavedPreamble(char* reply, size_t capacity, uint8_t, float) { + const size_t used = strlen(reply); + if (used < capacity) snprintf(reply + used, capacity - used, ",preamble=16 (auto)"); + } mutable unsigned warning_calls = 0; mutable uint8_t warning_sf = 0; mutable float warning_bw = 0; @@ -138,6 +141,9 @@ int main() { assert(cli._radio_profiles.warning_calls==1 && cli._radio_profiles.warning_sf==8); assert(cli._radio_profiles.warning_bw==125 && cli._radio_profiles.warning_preamble==0); cli.call(sender,"get radio",reply); + // The official app requires exactly four comma-separated radio fields. + // Simulate the production preamble suffix above to catch regressions. + assert(!strcmp(reply,"> 916.000,125.000,8,6")); float freq=0,bw=0; int sf=0,cr=0; assert(sscanf(reply,"> %f,%f,%d,%d",&freq,&bw,&sf,&cr)==4); assert(freq==916 && bw==125 && sf==8 && cr==6);