Fix config crc errors

Fix invalid configuration restores and decode_config.py crc error when savedata = 0 (#3918)
This commit is contained in:
Theo Arends 2018-09-29 13:09:51 +02:00
parent 2252be521a
commit 3b3579f1db
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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()