Keep get radio reply compatible with Companion apps

This commit is contained in:
mikecarper committed 2026-09-28 15:47:24 -07:00
1 parent a645b6c518
commit ca23d38ef6
3 files changed
+12 -2

No files matched your search

+4
View File
@@ -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
+1 -1
View File
@@ -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")) {
+7 -1
View File
@@ -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);