Merge pull request #9998 from s-hadinger/zigbee_zbreset_eeprom

Zigbee `ZbReset 1` also erases EEPROM
This commit is contained in:
s-hadinger 2020-11-27 22:00:37 +01:00 committed by GitHub
commit c866f90dbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -391,6 +391,9 @@ void saveZigbeeDevices(void) {
// Erase the flash area containing the ZigbeeData // Erase the flash area containing the ZigbeeData
void eraseZigbeeDevices(void) { void eraseZigbeeDevices(void) {
zigbee_devices.clean(); // avoid writing data to flash after erase zigbee_devices.clean(); // avoid writing data to flash after erase
#ifdef USE_ZIGBEE_EZSP
ZFS_Erase();
#endif // USE_ZIGBEE_EZSP
#ifdef ESP8266 #ifdef ESP8266
// first copy SPI buffer into ram // first copy SPI buffer into ram
uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len); uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len);
@ -410,7 +413,7 @@ void eraseZigbeeDevices(void) {
} }
free(spi_buffer); free(spi_buffer);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (0x%08X - %d bytes)"), z_dev_start, z_block_len); AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("Flash"));
#else // ESP32 #else // ESP32
ZigbeeErase(); ZigbeeErase();
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (%d bytes)"), z_block_len); AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (%d bytes)"), z_block_len);

View File

@ -314,6 +314,14 @@ bool loadZigbeeDevicesFromEEPROM(void) {
zigbee_devices.clean(); // don't write back to Flash what we just loaded zigbee_devices.clean(); // don't write back to Flash what we just loaded
return true; return true;
} }
void ZFS_Erase(void) {
if (zigbee.eeprom_present) {
ZFS::erase();
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("EEPROM"));
}
}
#endif // USE_ZIGBEE_EZSP #endif // USE_ZIGBEE_EZSP
#endif // USE_ZIGBEE #endif // USE_ZIGBEE

View File

@ -136,6 +136,7 @@ void CmndZbReset(void) {
ZigbeeZNPSend(ZIGBEE_FACTORY_RESET, sizeof(ZIGBEE_FACTORY_RESET)); ZigbeeZNPSend(ZIGBEE_FACTORY_RESET, sizeof(ZIGBEE_FACTORY_RESET));
#endif // USE_ZIGBEE_ZNP #endif // USE_ZIGBEE_ZNP
eraseZigbeeDevices(); eraseZigbeeDevices();
// no break - this is intended
case 2: // fall through case 2: // fall through
Settings.zb_txradio_dbm = - abs(Settings.zb_txradio_dbm); Settings.zb_txradio_dbm = - abs(Settings.zb_txradio_dbm);
TasmotaGlobal.restart_flag = 2; TasmotaGlobal.restart_flag = 2;