Zigbee `ZbReset 1` also erases EEPROM

This commit is contained in:
Stephan Hadinger 2020-11-27 21:47:13 +01:00
parent b56109d34e
commit 4cc04b7ceb
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
void eraseZigbeeDevices(void) {
zigbee_devices.clean(); // avoid writing data to flash after erase
#ifdef USE_ZIGBEE_EZSP
ZFS_Erase();
#endif // USE_ZIGBEE_EZSP
#ifdef ESP8266
// first copy SPI buffer into ram
uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len);
@ -410,7 +413,7 @@ void eraseZigbeeDevices(void) {
}
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
ZigbeeErase();
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
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

View File

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