mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 04:36:31 +00:00
Zigbee avoir erasing ZbData if zigbee is not started
This commit is contained in:
parent
b1371b63cc
commit
0007e7c672
@ -220,6 +220,7 @@ bool hydrateDevicesData(void) {
|
|||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
void hibernateAllData(void) {
|
void hibernateAllData(void) {
|
||||||
if (Rtc.utc_time < START_VALID_TIME) { return; }
|
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;
|
Univ_Write_File f;
|
||||||
const char * storage_class = PSTR("");
|
const char * storage_class = PSTR("");
|
||||||
|
|
||||||
@ -242,9 +243,6 @@ void hibernateAllData(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (f.valid()) {
|
if (f.valid()) {
|
||||||
// first prefix is number of devices
|
|
||||||
uint8_t device_num = zigbee_devices.devicesSize();
|
|
||||||
|
|
||||||
for (const auto & device : zigbee_devices.getDevices()) {
|
for (const auto & device : zigbee_devices.getDevices()) {
|
||||||
// allocte a buffer for a single device
|
// allocte a buffer for a single device
|
||||||
SBuffer buf = hibernateDeviceData(device);
|
SBuffer buf = hibernateDeviceData(device);
|
||||||
|
@ -2177,8 +2177,10 @@ bool Xdrv23(uint8_t function)
|
|||||||
result = DecodeCommand(kZbCommands, ZigbeeCommand, kZbSynonyms);
|
result = DecodeCommand(kZbCommands, ZigbeeCommand, kZbSynonyms);
|
||||||
break;
|
break;
|
||||||
case FUNC_SAVE_BEFORE_RESTART:
|
case FUNC_SAVE_BEFORE_RESTART:
|
||||||
hibernateAllData();
|
if (!zigbee.init_phase) {
|
||||||
restoreDumpAllDevices();
|
hibernateAllData();
|
||||||
|
restoreDumpAllDevices();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user