Skip to content

Commit 39a8b11

Browse files
authored
Merge pull request #26 from Dutch-MeshCore/fix/dmc-observer-dev-mqtt-prefs-persist
fix(cli): persist mqtt.config, mqtt.filter.interval and slot extras
2 parents 5d7949b + eab2f9e commit 39a8b11

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/helpers/CommonCLI_Observer.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf
358358
// Opt-in publish of the node config to the `config` topic. Accepts 1/on.
359359
_mqtt_prefs.mqtt_config_enabled =
360360
(config[12] == '1' || memcmp(&config[12], "on", 2) == 0) ? 1 : 0;
361-
savePrefs();
361+
if (!persistObserverPrefs(reply)) return true;
362362
strcpy(reply, "OK");
363363
} else if (memcmp(config, "mqtt.tx ", 8) == 0) {
364364
if (memcmp(&config[8], "advert", 6) == 0) {
@@ -392,15 +392,15 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf
392392
uint32_t secs = _atoi(&config[21]);
393393
if (secs == 0) {
394394
_mqtt_prefs.mqtt_filter_interval = 0;
395-
savePrefs();
395+
if (!persistObserverPrefs(reply)) return true;
396396
_callbacks->restartBridge();
397397
strcpy(reply, "OK - filter stats publishing disabled, bridge restarted");
398398
} else {
399399
uint32_t ms = secs * 1000UL;
400400
if (ms < MQTT_FILTER_STATS_MIN_INTERVAL_MS) ms = MQTT_FILTER_STATS_MIN_INTERVAL_MS;
401401
if (ms > MQTT_FILTER_STATS_MAX_INTERVAL_MS) ms = MQTT_FILTER_STATS_MAX_INTERVAL_MS;
402402
_mqtt_prefs.mqtt_filter_interval = ms;
403-
savePrefs();
403+
if (!persistObserverPrefs(reply)) return true;
404404
_callbacks->restartBridge();
405405
sprintf(reply, "OK - filter interval set to %lu s (%lu ms), bridge restarted",
406406
(unsigned long)(ms / 1000), (unsigned long)ms);
@@ -693,7 +693,7 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf
693693
return true;
694694
}
695695
_mqtt_prefs.mqtt_slot_extras[slot] = mask;
696-
savePrefs();
696+
if (!persistObserverPrefs(reply)) return true;
697697
sprintf(reply, "OK - slot %d extras %s", slot + 1, v);
698698
} else {
699699
sprintf(reply, "unknown config: %s", config);

0 commit comments

Comments
 (0)