Fix bugs in save configuration

This commit is contained in:
fvanroie 2020-04-12 19:36:09 +02:00
parent 3e1f6b1acf
commit 1333f632b7
3 changed files with 12 additions and 12 deletions

View File

@ -930,7 +930,7 @@ bool haspGetConfig(const JsonObject & settings)
if(haspThemeId != settings[FPSTR(F_CONFIG_THEME)].as<uint8_t>()) changed = true; if(haspThemeId != settings[FPSTR(F_CONFIG_THEME)].as<uint8_t>()) changed = true;
settings[FPSTR(F_CONFIG_THEME)] = haspThemeId; settings[FPSTR(F_CONFIG_THEME)] = haspThemeId;
if(haspThemeHue != settings[FPSTR(F_CONFIG_HUE)].as<uint8_t>()) changed = true; if(haspThemeHue != settings[FPSTR(F_CONFIG_HUE)].as<uint16_t>()) changed = true;
settings[FPSTR(F_CONFIG_HUE)] = haspThemeHue; settings[FPSTR(F_CONFIG_HUE)] = haspThemeHue;
if(strcmp(haspZiFontPath, settings[FPSTR(F_CONFIG_ZIFONT)].as<String>().c_str()) != 0) changed = true; if(strcmp(haspZiFontPath, settings[FPSTR(F_CONFIG_ZIFONT)].as<String>().c_str()) != 0) changed = true;

View File

@ -163,7 +163,7 @@ void configWriteConfig()
configFile = String(FPSTR(HASP_CONFIG_FILE)); configFile = String(FPSTR(HASP_CONFIG_FILE));
/* Read Config File */ /* Read Config File */
DynamicJsonDocument settings(6 * 256); DynamicJsonDocument settings(8 * 256);
Log.notice(F("CONF: Config LOADING first %s"), configFile.c_str()); Log.notice(F("CONF: Config LOADING first %s"), configFile.c_str());
configGetConfig(settings, false); configGetConfig(settings, false);
Log.trace(F("CONF: Config LOADED first %s"), configFile.c_str()); Log.trace(F("CONF: Config LOADED first %s"), configFile.c_str());
@ -172,13 +172,13 @@ void configWriteConfig()
bool changed = false; bool changed = false;
#if HASP_USE_WIFI #if HASP_USE_WIFI
changed = wifiGetConfig(settings[F("wifi")].to<JsonObject>()); changed = wifiGetConfig(settings[F("wifi")].as<JsonObject>());
if(changed) { if(changed) {
Log.verbose(F("WIFI: Settings changed")); Log.verbose(F("WIFI: Settings changed"));
writefile = true; writefile = true;
} }
#if HASP_USE_MQTT #if HASP_USE_MQTT
changed = mqttGetConfig(settings[F("mqtt")].to<JsonObject>()); changed = mqttGetConfig(settings[F("mqtt")].as<JsonObject>());
if(changed) { if(changed) {
Log.verbose(F("MQTT: Settings changed")); Log.verbose(F("MQTT: Settings changed"));
configOutput(settings[F("mqtt")]); configOutput(settings[F("mqtt")]);
@ -186,7 +186,7 @@ void configWriteConfig()
} }
#endif #endif
#if HASP_USE_TELNET #if HASP_USE_TELNET
changed = telnetGetConfig(settings[F("telnet")].to<JsonObject>()); changed = telnetGetConfig(settings[F("telnet")].as<JsonObject>());
if(changed) { if(changed) {
Log.verbose(F("TELNET: Settings changed")); Log.verbose(F("TELNET: Settings changed"));
configOutput(settings[F("telnet")]); configOutput(settings[F("telnet")]);
@ -194,14 +194,14 @@ void configWriteConfig()
} }
#endif #endif
#if HASP_USE_MDNS #if HASP_USE_MDNS
changed = mdnsGetConfig(settings[F("mdns")].to<JsonObject>()); changed = mdnsGetConfig(settings[F("mdns")].as<JsonObject>());
if(changed) { if(changed) {
Log.verbose(F("MDNS: Settings changed")); Log.verbose(F("MDNS: Settings changed"));
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_HTTP #if HASP_USE_HTTP
changed = httpGetConfig(settings[F("http")].to<JsonObject>()); changed = httpGetConfig(settings[F("http")].as<JsonObject>());
if(changed) { if(changed) {
Log.verbose(F("HTTP: Settings changed")); Log.verbose(F("HTTP: Settings changed"));
configOutput(settings[F("http")]); configOutput(settings[F("http")]);
@ -210,19 +210,19 @@ void configWriteConfig()
#endif #endif
#endif #endif
changed = debugGetConfig(settings[F("debug")].to<JsonObject>()); changed = debugGetConfig(settings[F("debug")].as<JsonObject>());
if(changed) { if(changed) {
Log.verbose(F("DEBUG: Settings changed")); Log.verbose(F("DEBUG: Settings changed"));
writefile = true; writefile = true;
} }
changed = guiGetConfig(settings[F("gui")].to<JsonObject>()); changed = guiGetConfig(settings[F("gui")].as<JsonObject>());
if(changed) { if(changed) {
Log.verbose(F("GUI: Settings changed")); Log.verbose(F("GUI: Settings changed"));
writefile = true; writefile = true;
} }
changed = haspGetConfig(settings[F("hasp")].to<JsonObject>()); changed = haspGetConfig(settings[F("hasp")].as<JsonObject>());
if(changed) { if(changed) {
Log.verbose(F("HASP: Settings changed")); Log.verbose(F("HASP: Settings changed"));
writefile = true; writefile = true;
@ -238,7 +238,7 @@ void configWriteConfig()
file.close(); file.close();
if(size > 0) { if(size > 0) {
Log.verbose(F("CONF: [SUCCESS] Saved %s"), configFile.c_str()); Log.verbose(F("CONF: [SUCCESS] Saved %s"), configFile.c_str());
// configBackupToEeprom(); configBackupToEeprom();
return; return;
} }
} }

View File

@ -822,7 +822,7 @@ bool guiGetConfig(const JsonObject & settings)
if(guiSleepTime2 != settings[FPSTR(F_GUI_IDLEPERIOD2)].as<uint16_t>()) changed = true; if(guiSleepTime2 != settings[FPSTR(F_GUI_IDLEPERIOD2)].as<uint16_t>()) changed = true;
settings[FPSTR(F_GUI_IDLEPERIOD2)] = guiSleepTime2; settings[FPSTR(F_GUI_IDLEPERIOD2)] = guiSleepTime2;
if(guiBacklightPin != settings[FPSTR(F_GUI_BACKLIGHTPIN)].as<uint8_t>()) changed = true; if(guiBacklightPin != settings[FPSTR(F_GUI_BACKLIGHTPIN)].as<int8_t>()) changed = true;
settings[FPSTR(F_GUI_BACKLIGHTPIN)] = guiBacklightPin; settings[FPSTR(F_GUI_BACKLIGHTPIN)] = guiBacklightPin;
if(guiRotation != settings[FPSTR(F_GUI_ROTATION)].as<uint8_t>()) changed = true; if(guiRotation != settings[FPSTR(F_GUI_ROTATION)].as<uint8_t>()) changed = true;