fix(cli): persist 'set freq' across a later savePrefs()

The `set freq <mhz>` handler saved the new frequency to prefs, then
reverted _prefs->freq to the old value in RAM to keep the running radio
on the old params until reboot. But _prefs is the source of truth for
every savePrefs(), so:
  - `get freq` / `get radio` reported the old value right after a
    successful `set freq`;
  - the next savePrefs() from any other `set` command (e.g. `set rxduty`)
    rewrote the old freq back over the persisted new one, losing the
    change on reboot.

Mirror the `set radio` handler: keep _prefs->freq = f and freeze the
running radio on the old freq via freezeRadioParams() instead of
reverting the pref. Semantics unchanged (applies at reboot; the live
radio stays on the old freq until then); _prefs now correctly retains
the new value so `get` reflects it and later saves can't clobber it.
freezeRadioParams() is implemented for the Repeater and Room Server
roles; the CommonCLI base default is a no-op, so other roles are
unaffected.

Verified on Seeed XIAO MG24 + Wio-SX1262 (Repeater role, built from
release v20260704.220543 + this patch): `set freq 903.0` is retained by
`get freq` immediately and survives an intervening `set rxduty` + reboot.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Steve Pinkham
2026-07-08 17:19:00 -04:00
co-authored by Claude Opus 4.8
parent 4c4218a6b5
commit 8cde6d83f3
+5 -1
View File
@@ -852,7 +852,11 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
float old_freq = _prefs->freq;
_prefs->freq = f;
savePrefs();
_prefs->freq = old_freq;
/* Keep _prefs->freq = f in RAM so a later savePrefs() (from any
* other "set" command before reboot) can't rewrite the old freq
* back; freeze the running radio on the old freq until reboot,
* mirroring the "set radio" handler above. */
_callbacks->freezeRadioParams(old_freq, _prefs->bw, _prefs->sf, _prefs->cr);
strcpy(reply, "OK - reboot to apply");
} else {
strcpy(reply, "Error: range 150-2500 MHz");