diff --git a/ESP32_AP-Flasher/include/storage.h b/ESP32_AP-Flasher/include/storage.h index a55dab09..9cd265d9 100644 --- a/ESP32_AP-Flasher/include/storage.h +++ b/ESP32_AP-Flasher/include/storage.h @@ -26,6 +26,7 @@ class DynStorage { DynStorage(); void begin(); void listFiles(); + size_t freeSpace(); private: bool isInited; diff --git a/ESP32_AP-Flasher/src/storage.cpp b/ESP32_AP-Flasher/src/storage.cpp index f923ac0e..fe40ccb6 100644 --- a/ESP32_AP-Flasher/src/storage.cpp +++ b/ESP32_AP-Flasher/src/storage.cpp @@ -44,8 +44,13 @@ static void initSDCard() { } #endif -void copyToSD(FS &sourceFS, const char* source_path){ - File root = sourceFS.open(source_path); +size_t DynStorage::freeSpace(){ + this->begin(); +#ifdef HAS_SDCARD + return SD.totalBytes() - SD.usedBytes(); +#endif + return LittleFS.totalBytes() - LittleFS.usedBytes(); +} void copyFile(File in, File out) { Serial.print("Copying "); diff --git a/ESP32_AP-Flasher/src/web.cpp b/ESP32_AP-Flasher/src/web.cpp index 5432cb5e..cff410b4 100644 --- a/ESP32_AP-Flasher/src/web.cpp +++ b/ESP32_AP-Flasher/src/web.cpp @@ -136,7 +136,7 @@ void wsSendSysteminfo() { sys["heap"] = ESP.getFreeHeap(); sys["recordcount"] = tagDB.size(); sys["dbsize"] = tagDB.size() * sizeof(tagRecord); - sys["littlefsfree"] = LittleFS.totalBytes() - LittleFS.usedBytes(); + sys["littlefsfree"] = Storage.freeSpace(); sys["apstate"] = apInfo.state; sys["runstate"] = config.runStatus;