mirror of https://github.com/arendst/Tasmota.git
Remove obsolete USE_TFS
This commit is contained in:
parent
d6a24c6fe7
commit
9722f6b666
|
@ -2083,9 +2083,6 @@ void CmndDriver(void)
|
|||
|
||||
void CmndInfo(void) {
|
||||
NvsInfo();
|
||||
#ifdef USE_TFS
|
||||
TfsInfo();
|
||||
#endif
|
||||
ResponseCmndDone();
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ void SettingsErase(uint8_t type) {
|
|||
}
|
||||
|
||||
void SettingsRead(void *data, size_t size) {
|
||||
#ifdef USE_TFS
|
||||
#ifdef USE_UFILESYS
|
||||
// if (!TfsLoadFile("/settings", (uint8_t*)data, size)) {
|
||||
NvmLoad("main", "Settings", data, size);
|
||||
// }
|
||||
|
@ -182,7 +182,7 @@ void SettingsRead(void *data, size_t size) {
|
|||
}
|
||||
|
||||
void SettingsWrite(const void *pSettings, unsigned nSettingsLen) {
|
||||
#ifdef USE_TFS
|
||||
#ifdef USE_UFILESYS
|
||||
// TfsSaveFile("/settings", (const uint8_t*)pSettings, nSettingsLen);
|
||||
#endif
|
||||
NvmSave("main", "Settings", pSettings, nSettingsLen);
|
||||
|
|
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
support_filesystem.ino - Filesystem support for Tasmota
|
||||
|
||||
Copyright (C) 2021 Theo Arends
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*********************************************************************************************\
|
||||
* ESP32 Filesystem Support
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifdef ESP32
|
||||
|
||||
#ifdef USE_TFS
|
||||
|
||||
//#define USE_LITTLEFS // LittleFS not tested yet as currently ESP8266 only
|
||||
//#define USE_FFAT // FFat minimal 983k partition (4096 sector size) - tested
|
||||
#define USE_SPIFFS // SPIFFS - tested
|
||||
|
||||
#ifdef USE_LITTLEFS
|
||||
#include <LittleFS.h>
|
||||
#define TASMOTA_FS LittleFS
|
||||
#endif
|
||||
#ifdef USE_FFAT
|
||||
#include <FFat.h>
|
||||
#define TASMOTA_FS FFat
|
||||
#endif
|
||||
#ifdef USE_SPIFFS
|
||||
#include <SPIFFS.h>
|
||||
#define TASMOTA_FS SPIFFS
|
||||
#endif
|
||||
|
||||
bool TfsInit(void) {
|
||||
static uint8_t FsMounted = 0;
|
||||
|
||||
if (FsMounted) { return FsMounted -1; }
|
||||
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Mounting..."));
|
||||
if (!TASMOTA_FS.begin()) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Formatting..."));
|
||||
TASMOTA_FS.format();
|
||||
if (!TASMOTA_FS.begin()) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Failed"));
|
||||
FsMounted = 1; // false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Mounted"));
|
||||
FsMounted = 2; // true
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TfsFileExists(const char *fname){
|
||||
if (!TfsInit()) { return false; }
|
||||
|
||||
bool yes = false;
|
||||
File file = TASMOTA_FS.open(fname, "r");
|
||||
if (!file.isDirectory()) {
|
||||
yes = true;
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: File not found"));
|
||||
}
|
||||
file.close();
|
||||
return yes;
|
||||
}
|
||||
|
||||
bool TfsSaveFile(const char *fname, const uint8_t *buf, uint32_t len) {
|
||||
if (!TfsInit()) { return false; }
|
||||
|
||||
File file = TASMOTA_FS.open(fname, "w");
|
||||
if (!file) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Save failed"));
|
||||
return false;
|
||||
}
|
||||
|
||||
file.write(buf, len);
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TfsEraseFile(const char *fname, uint32_t len) {
|
||||
if (!TfsInit()) { return false; }
|
||||
|
||||
File file = TASMOTA_FS.open(fname, "w");
|
||||
if (!file) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Erase failed"));
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t init_value = 0xff;
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
file.write(&init_value, 1);
|
||||
}
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TfsLoadFile(const char *fname, uint8_t *buf, uint32_t len) {
|
||||
if (!TfsInit()) { return false; }
|
||||
if (!TfsFileExists(fname)) { return false; }
|
||||
|
||||
File file = TASMOTA_FS.open(fname, "r");
|
||||
if (!file) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: File not found"));
|
||||
return false;
|
||||
}
|
||||
|
||||
file.read(buf, len);
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TfsInfo(void) {
|
||||
if (!TfsInit()) { return; }
|
||||
|
||||
uint32_t total_bytes = TASMOTA_FS.totalBytes();
|
||||
#ifdef USE_SPIFFS
|
||||
uint32_t used_bytes = TASMOTA_FS.usedBytes();
|
||||
#endif // USE_SPIFFS
|
||||
#ifdef USE_FFAT
|
||||
uint32_t used_bytes = total_bytes - TASMOTA_FS.freeBytes();
|
||||
#endif // USE_FFAT
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Used %d/%d bytes"), used_bytes, total_bytes);
|
||||
|
||||
File root = TASMOTA_FS.open("/");
|
||||
File file = root.openNextFile();
|
||||
while (file) {
|
||||
String filename = file.name();
|
||||
size_t filesize = file.size();
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: File %s, size %d"), filename.c_str(), filesize);
|
||||
file = root.openNextFile();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // USE_TFS
|
||||
#endif // ESP32
|
|
@ -107,13 +107,8 @@ String EthernetMacAddress(void);
|
|||
#define ARDUINO_CORE_RELEASE ARDUINO_ESP32_RELEASE
|
||||
#endif // ARDUINO_ESP32_RELEASE
|
||||
|
||||
//#define USE_TFS
|
||||
#define USE_UFILESYS
|
||||
|
||||
#ifdef USE_SCRIPT
|
||||
#undef USE_TFS
|
||||
#endif // USE_SCRIPT
|
||||
|
||||
// Hardware has no ESP32
|
||||
#undef USE_TUYA_DIMMER
|
||||
#undef USE_PWM_DIMMER
|
||||
|
|
|
@ -304,11 +304,8 @@ void loadZigbeeDevices(bool dump_only = false) {
|
|||
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer"));
|
||||
return;
|
||||
}
|
||||
#ifdef USE_TFS
|
||||
TfsLoadFile("/zb", spi_buffer, z_spi_len);
|
||||
#endif
|
||||
#ifdef USE_UFILESYS
|
||||
UfsLoadFile("/zb", spi_buffer, z_spi_len);
|
||||
TfsLoadFile("/zb", spi_buffer, z_spi_len);
|
||||
#endif
|
||||
z_dev_start = spi_buffer;
|
||||
#endif // ESP32
|
||||
|
@ -372,11 +369,8 @@ 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
|
||||
#ifdef USE_TFS
|
||||
TfsLoadFile("/zb", spi_buffer, z_spi_len);
|
||||
#endif
|
||||
#ifdef USE_UFILESYS
|
||||
UfsLoadFile("/zb", spi_buffer, z_spi_len);
|
||||
TfsLoadFile("/zb", spi_buffer, z_spi_len);
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
||||
|
@ -395,11 +389,8 @@ 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
|
||||
#ifdef USE_TFS
|
||||
TfsSaveFile("/zb", spi_buffer, z_spi_len);
|
||||
#endif
|
||||
#ifdef USE_UFILESYS
|
||||
UfsSaveFile("/zb", spi_buffer, z_spi_len);
|
||||
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
|
||||
|
@ -434,11 +425,8 @@ void eraseZigbeeDevices(void) {
|
|||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("Flash"));
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
#ifdef USE_TFS
|
||||
TfsEraseFile("/zb", z_block_len);
|
||||
#endif
|
||||
#ifdef USE_UFILESYS
|
||||
UfsInitFile("/zb", z_block_len, 0xFF);
|
||||
TfsInitFile("/zb", z_block_len, 0xFF);
|
||||
#endif
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (%d bytes)"), z_block_len);
|
||||
#endif // ESP32
|
||||
|
|
|
@ -149,22 +149,22 @@ void UfsInit(void) {
|
|||
return;
|
||||
}
|
||||
|
||||
bool UfsFileExists(const char *fname){
|
||||
bool TfsFileExists(const char *fname){
|
||||
if (!ufs_type) { return false; }
|
||||
|
||||
bool yes = ufsp->exists(fname);
|
||||
bool yes = ffsp->exists(fname);
|
||||
if (!yes) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: File not found"));
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: File not found"));
|
||||
}
|
||||
return yes;
|
||||
}
|
||||
|
||||
bool UfsSaveFile(const char *fname, const uint8_t *buf, uint32_t len) {
|
||||
bool TfsSaveFile(const char *fname, const uint8_t *buf, uint32_t len) {
|
||||
if (!ufs_type) { return false; }
|
||||
|
||||
File file = ufsp->open(fname, "w");
|
||||
File file = ffsp->open(fname, "w");
|
||||
if (!file) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: Save failed"));
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Save failed"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -173,12 +173,12 @@ bool UfsSaveFile(const char *fname, const uint8_t *buf, uint32_t len) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool UfsInitFile(const char *fname, uint32_t len, uint8_t init_value) {
|
||||
bool TfsInitFile(const char *fname, uint32_t len, uint8_t init_value) {
|
||||
if (!ufs_type) { return false; }
|
||||
|
||||
File file = ufsp->open(fname, "w");
|
||||
File file = ffsp->open(fname, "w");
|
||||
if (!file) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: Erase failed"));
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Erase failed"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -189,13 +189,13 @@ bool UfsInitFile(const char *fname, uint32_t len, uint8_t init_value) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool UfsLoadFile(const char *fname, uint8_t *buf, uint32_t len) {
|
||||
bool TfsLoadFile(const char *fname, uint8_t *buf, uint32_t len) {
|
||||
if (!ufs_type) { return false; }
|
||||
if (!UfsFileExists(fname)) { return false; }
|
||||
if (!TfsFileExists(fname)) { return false; }
|
||||
|
||||
File file = ufsp->open(fname, "r");
|
||||
File file = ffsp->open(fname, "r");
|
||||
if (!file) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: File not found"));
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: File not found"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue