Zigbee avoir erasing ZbData if zigbee is not started

This commit is contained in:
Stephan Hadinger 2021-04-30 12:34:00 +02:00
parent b1371b63cc
commit 0007e7c672
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;
}
}