[CFG] End preferences when key not found (#1640)

This commit is contained in:
Florian authored and GitHub committed 2023-05-11 12:53:36 -05:00
1 parent b1667190d5
commit e640c8342a
3 files changed
+13 -1

No files matched your search

+6
View File
@@ -51,6 +51,9 @@ void ONOFFConfig_fromJson(JsonObject& ONOFFdata) {
preferences.end();
Log.notice(F("ONOFF config erased" CR));
return; // Erase prevails on save, so skipping save
} else {
Log.notice(F("ONOFF config not found" CR));
preferences.end();
}
}
if (ONOFFdata.containsKey("save") && ONOFFdata["save"].as<bool>()) {
@@ -85,6 +88,9 @@ void ONOFFConfig_load() {
JsonObject jo = jsonBuffer.as<JsonObject>();
ONOFFConfig_fromJson(jo);
Log.notice(F("ONOFF config loaded" CR));
} else {
preferences.end();
Log.notice(F("ONOFF config not found" CR));
}
}
# else
+1 -1
View File
@@ -179,8 +179,8 @@ void MQTTtoSSD1306(char* topicOri, JsonObject& SSD1306data) { // json object dec
preferences.begin(Gateway_Short_Name, false);
if (preferences.isKey("SSD1306Config")) {
success = preferences.remove("SSD1306Config");
preferences.end();
}
preferences.end();
if (success) {
Log.notice(F("SSD1306 config erased" CR));
}
+6
View File
@@ -256,6 +256,9 @@ void BTConfig_fromJson(JsonObject& BTdata, bool startup = false) {
preferences.end();
Log.notice(F("BT config erased" CR));
return; // Erase prevails on save, so skipping save
} else {
preferences.end();
Log.notice(F("BT config not found" CR));
}
}
@@ -310,6 +313,9 @@ void BTConfig_load() {
JsonObject jo = jsonBuffer.as<JsonObject>();
BTConfig_fromJson(jo, true); // Never send MQTT message with config
Log.notice(F("BT config loaded" CR));
} else {
preferences.end();
Log.notice(F("BT config not found" CR));
}
}