Merge pull request #9954 from s-hadinger/zigbee_save_data_60

Zigbee save data to EEPROM every hour
This commit is contained in:
s-hadinger 2020-11-22 18:26:10 +01:00 committed by GitHub
commit 250b08ba61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -227,4 +227,22 @@ void hibernateAllData(void) {
#endif // USE_ZIGBEE_EZSP
}
/*********************************************************************************************\
* Timer to save every 60 minutes
\*********************************************************************************************/
const uint32_t Z_SAVE_DATA_TIMER = 60 * 60 * 1000; // save data every 60 minutes (in ms)
//
// Callback for setting the timer to save Zigbee Data in x seconds
//
int32_t Z_Set_Save_Data_Timer(uint8_t value) {
zigbee_devices.setTimer(0x0000, 0, Z_SAVE_DATA_TIMER, 0, 0, Z_CAT_ALWAYS, 0 /* value */, &Z_SaveDataTimer);
return 0; // continue
}
void Z_SaveDataTimer(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) {
hibernateAllData();
Z_Set_Save_Data_Timer(0); // set a new timer
}
#endif // USE_ZIGBEE

View File

@ -870,6 +870,7 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
ZI_CALL(&Z_Prepare_EEPROM, 0)
ZI_CALL(&Z_Load_Devices, 0)
ZI_CALL(&Z_Load_Data, 0)
ZI_CALL(&Z_Set_Save_Data_Timer, 0)
ZI_CALL(&Z_Query_Bulbs, 0)
ZI_LABEL(ZIGBEE_LABEL_MAIN_LOOP)