From abdfae50462b879490dd0020eaf40543d269d60b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 17 Dec 2020 17:20:49 +0100 Subject: [PATCH] Refactor zigbee TFS access --- tasmota/support_esp32.ino | 22 ---------------------- tasmota/xdrv_23_zigbee_4_persistence.ino | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/tasmota/support_esp32.ino b/tasmota/support_esp32.ino index 2f544ba5e..3018b9de8 100644 --- a/tasmota/support_esp32.ino +++ b/tasmota/support_esp32.ino @@ -198,28 +198,6 @@ void NvsInfo(void) { nvs_stats.used_entries, nvs_stats.total_entries, nvs_stats.namespace_count); } -void ZigbeeErase(unsigned nSettingsLen) { -// NvmErase("zb"); -#ifdef USE_TFS - TfsEraseFile("/zb", nSettingsLen); -#endif -} - -void ZigbeeRead(uint8_t *pSettings, unsigned nSettingsLen) { -// NvmLoad("zb", "zigbee", pSettings, nSettingsLen); -#ifdef USE_TFS - TfsLoadFile("/zb", pSettings, nSettingsLen); -#endif -} - -void ZigbeeWrite(const uint8_t *pSettings, unsigned nSettingsLen) { -// NvmSave("zb", "zigbee", pSettings, nSettingsLen); -#ifdef USE_TFS - TfsSaveFile("/zb", pSettings, nSettingsLen); -#endif -} - - // // Flash memory mapping // diff --git a/tasmota/xdrv_23_zigbee_4_persistence.ino b/tasmota/xdrv_23_zigbee_4_persistence.ino index 046077771..91c516194 100644 --- a/tasmota/xdrv_23_zigbee_4_persistence.ino +++ b/tasmota/xdrv_23_zigbee_4_persistence.ino @@ -304,7 +304,9 @@ void loadZigbeeDevices(bool dump_only = false) { AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); return; } - ZigbeeRead(spi_buffer, z_spi_len); +#ifdef USE_TFS + TfsLoadFile("/zb", spi_buffer, z_spi_len); +#endif z_dev_start = spi_buffer; #endif // ESP32 Z_Flashentry flashdata; @@ -367,7 +369,9 @@ void saveZigbeeDevices(void) { ESP.flashRead(z_spi_start_sector * SPI_FLASH_SEC_SIZE, (uint32_t*) spi_buffer, SPI_FLASH_SEC_SIZE); #endif // ESP8266 #ifdef ESP32 - ZigbeeRead(spi_buffer, z_spi_len); +#ifdef USE_TFS + TfsLoadFile("/zb", spi_buffer, z_spi_len); +#endif #endif // ESP32 Z_Flashentry *flashdata = (Z_Flashentry*)(spi_buffer + z_block_offset); @@ -385,7 +389,9 @@ void saveZigbeeDevices(void) { AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data store in Flash (0x%08X - %d bytes)"), z_dev_start, buf_len); #endif // ESP8266 #ifdef ESP32 - ZigbeeWrite(spi_buffer, z_spi_len); +#ifdef USE_TFS + TfsSaveFile("/zb", spi_buffer, z_spi_len); +#endif AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("Flash"), buf_len); #endif // ESP32 free(spi_buffer); @@ -419,7 +425,9 @@ void eraseZigbeeDevices(void) { AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("Flash")); #endif // ESP8266 #ifdef ESP32 - ZigbeeErase(z_block_len); +#ifdef USE_TFS + TfsEraseFile("/zb", z_block_len); +#endif AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (%d bytes)"), z_block_len); #endif // ESP32 }