[CFG] End preferences when key not found (#1640)
This commit is contained in:
1 parent
b1667190d5
commit
e640c8342a
3 files changed
+13
-1
No files matched your search
@@ -51,6 +51,9 @@ void ONOFFConfig_fromJson(JsonObject& ONOFFdata) {
|
|||||||
preferences.end();
|
preferences.end();
|
||||||
Log.notice(F("ONOFF config erased" CR));
|
Log.notice(F("ONOFF config erased" CR));
|
||||||
return; // Erase prevails on save, so skipping save
|
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>()) {
|
if (ONOFFdata.containsKey("save") && ONOFFdata["save"].as<bool>()) {
|
||||||
@@ -85,6 +88,9 @@ void ONOFFConfig_load() {
|
|||||||
JsonObject jo = jsonBuffer.as<JsonObject>();
|
JsonObject jo = jsonBuffer.as<JsonObject>();
|
||||||
ONOFFConfig_fromJson(jo);
|
ONOFFConfig_fromJson(jo);
|
||||||
Log.notice(F("ONOFF config loaded" CR));
|
Log.notice(F("ONOFF config loaded" CR));
|
||||||
|
} else {
|
||||||
|
preferences.end();
|
||||||
|
Log.notice(F("ONOFF config not found" CR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
|
|||||||
@@ -179,8 +179,8 @@ void MQTTtoSSD1306(char* topicOri, JsonObject& SSD1306data) { // json object dec
|
|||||||
preferences.begin(Gateway_Short_Name, false);
|
preferences.begin(Gateway_Short_Name, false);
|
||||||
if (preferences.isKey("SSD1306Config")) {
|
if (preferences.isKey("SSD1306Config")) {
|
||||||
success = preferences.remove("SSD1306Config");
|
success = preferences.remove("SSD1306Config");
|
||||||
preferences.end();
|
|
||||||
}
|
}
|
||||||
|
preferences.end();
|
||||||
if (success) {
|
if (success) {
|
||||||
Log.notice(F("SSD1306 config erased" CR));
|
Log.notice(F("SSD1306 config erased" CR));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,6 +256,9 @@ void BTConfig_fromJson(JsonObject& BTdata, bool startup = false) {
|
|||||||
preferences.end();
|
preferences.end();
|
||||||
Log.notice(F("BT config erased" CR));
|
Log.notice(F("BT config erased" CR));
|
||||||
return; // Erase prevails on save, so skipping save
|
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>();
|
JsonObject jo = jsonBuffer.as<JsonObject>();
|
||||||
BTConfig_fromJson(jo, true); // Never send MQTT message with config
|
BTConfig_fromJson(jo, true); // Never send MQTT message with config
|
||||||
Log.notice(F("BT config loaded" CR));
|
Log.notice(F("BT config loaded" CR));
|
||||||
|
} else {
|
||||||
|
preferences.end();
|
||||||
|
Log.notice(F("BT config not found" CR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user