diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 2cc23ac4a..0a113a04f 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -2,6 +2,7 @@ * Add Apparent Power and Reactive Power to Energy Monitoring devices (#251) * Add RF Receiver control to module MagicHome to be used on Arilux LC10 (#3792) * Fix I2CScan invalid JSON error message (#3925) + * Fix invalid configuration restores and decode_config.py crc error when savedata = 0 (#3918) * * 6.2.1.8 20180926 * Change status JSON message providing more switch and retain information diff --git a/sonoff/xdrv_02_webserver.ino b/sonoff/xdrv_02_webserver.ino index 5182b7051..6a939dc24 100644 --- a/sonoff/xdrv_02_webserver.ino +++ b/sonoff/xdrv_02_webserver.ino @@ -1013,6 +1013,10 @@ void HandleBackupConfiguration() WebServer->sendHeader(F("Content-Disposition"), attachment); WebServer->send(200, FPSTR(HDR_CTYPE_STREAM), ""); + + uint16_t cfg_crc = Settings.cfg_crc; + Settings.cfg_crc = GetSettingsCrc(); // Calculate crc (again) as it might be wrong when savedata = 0 (#3918) + memcpy(settings_buffer, &Settings, sizeof(Settings)); if (config_xor_on_set) { for (uint16_t i = 2; i < sizeof(Settings); i++) { @@ -1030,6 +1034,8 @@ void HandleBackupConfiguration() #endif SettingsBufferFree(); + + Settings.cfg_crc = cfg_crc; // Restore crc in case savedata = 0 to make sure settings will be noted as changed } void HandleSaveSettings()