mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-09-01 20:09:17 +00:00
fix CLI radio settings applied immediately instead after reboot
This commit is contained in:
@@ -629,11 +629,22 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||
uint8_t cr = num > 3 ? atoi(parts[3]) : 0;
|
||||
if (freq >= 150.0f && freq <= 2500.0f && sf >= 5 && sf <= 12 &&
|
||||
cr >= 5 && cr <= 8 && bw >= 7.0f && bw <= 500.0f) {
|
||||
_prefs->sf = sf;
|
||||
_prefs->cr = cr;
|
||||
/* Snapshot current runtime params — the radio driver reads _prefs live,
|
||||
* so restoring them after the disk write keeps the radio on current
|
||||
* settings until reboot loads the new values from flash. */
|
||||
float old_freq = _prefs->freq;
|
||||
float old_bw = _prefs->bw;
|
||||
uint8_t old_sf = _prefs->sf;
|
||||
uint8_t old_cr = _prefs->cr;
|
||||
_prefs->freq = freq;
|
||||
_prefs->bw = bw;
|
||||
_prefs->bw = bw;
|
||||
_prefs->sf = sf;
|
||||
_prefs->cr = cr;
|
||||
_callbacks->savePrefs();
|
||||
_prefs->freq = old_freq;
|
||||
_prefs->bw = old_bw;
|
||||
_prefs->sf = old_sf;
|
||||
_prefs->cr = old_cr;
|
||||
strcpy(reply, "OK - reboot to apply");
|
||||
} else {
|
||||
strcpy(reply, "Error: freq 150-2500, bw 7-500, sf 5-12, cr 5-8");
|
||||
@@ -755,8 +766,10 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||
} else if (sender_timestamp == 0 && memcmp(config, "freq ", 5) == 0) {
|
||||
float f = atof(&config[5]);
|
||||
if (f >= 150.0f && f <= 2500.0f) {
|
||||
float old_freq = _prefs->freq;
|
||||
_prefs->freq = f;
|
||||
savePrefs();
|
||||
_prefs->freq = old_freq;
|
||||
strcpy(reply, "OK - reboot to apply");
|
||||
} else {
|
||||
strcpy(reply, "Error: range 150-2500 MHz");
|
||||
|
||||
Reference in New Issue
Block a user