From 8cde6d83f36733e075a15d24689fc6b598ad3afe Mon Sep 17 00:00:00 2001 From: Steve Pinkham Date: Wed, 8 Jul 2026 17:19:00 -0400 Subject: [PATCH] fix(cli): persist 'set freq' across a later savePrefs() The `set freq ` 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 --- zephcore/helpers/CommonCLI.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zephcore/helpers/CommonCLI.cpp b/zephcore/helpers/CommonCLI.cpp index f3eec87..fed1bcd 100644 --- a/zephcore/helpers/CommonCLI.cpp +++ b/zephcore/helpers/CommonCLI.cpp @@ -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");