From eab2f9e1c152c54e87c623ab216d7d534680045b Mon Sep 17 00:00:00 2001 From: Elektr0Vodka <211697683+Elektr0Vodka@users.noreply.github.com> Date: Mon, 19 Oct 2026 18:20:59 +0200 Subject: [PATCH] fix(cli): persist mqtt.config, mqtt.filter.interval and slot extras These three DMC setters change MQTTPrefs but saved with plain savePrefs(). Since 75f3e446 that only writes /prefs.json (save_mqtt defaults to false), so the change replied OK, applied until reboot, and was then lost. The failure path also skipped the observer rollback. They now use persistObserverPrefs(reply), like every other observer setter: written to /mqtt.json, rolled back with an error if the write fails. The setters were written while savePrefs() still saved both files; the catch-up that brought in 75f3e446 merged without a conflict. Verified: heltec_v4_repeater_observer_mqtt builds. No native test covers CommonCLI_Observer.cpp. --- src/helpers/CommonCLI_Observer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helpers/CommonCLI_Observer.cpp b/src/helpers/CommonCLI_Observer.cpp index b9c698393e..65a6fe816f 100644 --- a/src/helpers/CommonCLI_Observer.cpp +++ b/src/helpers/CommonCLI_Observer.cpp @@ -358,7 +358,7 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf // Opt-in publish of the node config to the `config` topic. Accepts 1/on. _mqtt_prefs.mqtt_config_enabled = (config[12] == '1' || memcmp(&config[12], "on", 2) == 0) ? 1 : 0; - savePrefs(); + if (!persistObserverPrefs(reply)) return true; strcpy(reply, "OK"); } else if (memcmp(config, "mqtt.tx ", 8) == 0) { if (memcmp(&config[8], "advert", 6) == 0) { @@ -392,7 +392,7 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf uint32_t secs = _atoi(&config[21]); if (secs == 0) { _mqtt_prefs.mqtt_filter_interval = 0; - savePrefs(); + if (!persistObserverPrefs(reply)) return true; _callbacks->restartBridge(); strcpy(reply, "OK - filter stats publishing disabled, bridge restarted"); } else { @@ -400,7 +400,7 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf if (ms < MQTT_FILTER_STATS_MIN_INTERVAL_MS) ms = MQTT_FILTER_STATS_MIN_INTERVAL_MS; if (ms > MQTT_FILTER_STATS_MAX_INTERVAL_MS) ms = MQTT_FILTER_STATS_MAX_INTERVAL_MS; _mqtt_prefs.mqtt_filter_interval = ms; - savePrefs(); + if (!persistObserverPrefs(reply)) return true; _callbacks->restartBridge(); sprintf(reply, "OK - filter interval set to %lu s (%lu ms), bridge restarted", (unsigned long)(ms / 1000), (unsigned long)ms); @@ -693,7 +693,7 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf return true; } _mqtt_prefs.mqtt_slot_extras[slot] = mask; - savePrefs(); + if (!persistObserverPrefs(reply)) return true; sprintf(reply, "OK - slot %d extras %s", slot + 1, v); } else { sprintf(reply, "unknown config: %s", config);