Merge pull request #11961 from s-hadinger/zigbee_avoid_erase_zbdata

Zigbee avoid erasing ZbData if zigbee is not started
This commit is contained in:
s-hadinger 2021-04-30 13:32:25 +02:00 committed by GitHub
commit ec2ea83582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -220,6 +220,7 @@ bool hydrateDevicesData(void) {
\*********************************************************************************************/
void hibernateAllData(void) {
if (Rtc.utc_time < START_VALID_TIME) { return; }
if (zigbee_devices.devicesSize() == 0) { return; } // safe-guard, if data is empty, don't save anything
Univ_Write_File f;
const char * storage_class = PSTR("");
@ -242,9 +243,6 @@ void hibernateAllData(void) {
#endif
if (f.valid()) {
// first prefix is number of devices
uint8_t device_num = zigbee_devices.devicesSize();
for (const auto & device : zigbee_devices.getDevices()) {
// allocte a buffer for a single device
SBuffer buf = hibernateDeviceData(device);

View File

@ -2177,8 +2177,10 @@ bool Xdrv23(uint8_t function)
result = DecodeCommand(kZbCommands, ZigbeeCommand, kZbSynonyms);
break;
case FUNC_SAVE_BEFORE_RESTART:
hibernateAllData();
restoreDumpAllDevices();
if (!zigbee.init_phase) {
hibernateAllData();
restoreDumpAllDevices();
}
break;
}
}