From 3cf1aa7f499e6e6fafc7346aaca731b51e3eab90 Mon Sep 17 00:00:00 2001 From: Lukas Bachschwell Date: Thu, 24 Sep 2020 21:56:32 +0200 Subject: [PATCH] Fix littleFS does not exist on esp32 Signed-off-by: Lukas Bachschwell --- src/ESPUI.cpp | 36 +++++++++++++++++------------------- src/ESPUI.h | 4 ++-- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/ESPUI.cpp b/src/ESPUI.cpp index 9474be6..eba95e6 100644 --- a/src/ESPUI.cpp +++ b/src/ESPUI.cpp @@ -26,7 +26,7 @@ void listDir(const char* dirname, uint8_t levels) } #endif - File root = LittleFS.open(dirname); + File root = SPIFFS.open(dirname); if (!root) { @@ -119,11 +119,10 @@ void ESPUIClass::list() listDir("/", 1); #if defined(ESP32) - Serial.println(LittleFS.totalBytes()); - Serial.println(LittleFS.usedBytes()); + Serial.println(SPIFFS.totalBytes()); + Serial.println(SPIFFS.usedBytes()); -#else - FSInfo fs_info; +#else FSInfo fs_info; LittleFS.info(fs_info); Serial.println(fs_info.totalBytes); @@ -263,9 +262,9 @@ void ESPUIClass::prepareFileSystem() #endif #if defined(ESP32) - LittleFS.format(); + SPIFFS.format(); - if (!LittleFS.begin(true)) + if (!SPIFFS.begin(true)) { #if defined(DEBUG_ESPUI) if (this->verbosity) @@ -347,7 +346,11 @@ void ESPUIClass::prepareFileSystem() #endif +#if defined(ESP32) + SPIFFS.end(); +#else LittleFS.end(); +#endif } // Handle Websockets Communication @@ -356,8 +359,7 @@ void onWsEvent( { switch (type) { - case WS_EVT_DISCONNECT: - { + case WS_EVT_DISCONNECT: { #if defined(DEBUG_ESPUI) if (ESPUI.verbosity) { @@ -368,8 +370,7 @@ void onWsEvent( break; } - case WS_EVT_PONG: - { + case WS_EVT_PONG: { #if defined(DEBUG_ESPUI) if (ESPUI.verbosity) { @@ -380,8 +381,7 @@ void onWsEvent( break; } - case WS_EVT_ERROR: - { + case WS_EVT_ERROR: { #if defined(DEBUG_ESPUI) if (ESPUI.verbosity) { @@ -392,8 +392,7 @@ void onWsEvent( break; } - case WS_EVT_CONNECT: - { + case WS_EVT_CONNECT: { #if defined(DEBUG_ESPUI) if (ESPUI.verbosity) { @@ -413,8 +412,7 @@ void onWsEvent( } break; - case WS_EVT_DATA: - { + case WS_EVT_DATA: { String msg = ""; msg.reserve(len + 1); @@ -544,7 +542,7 @@ void onWsEvent( else if (msg.startsWith("tabvalue:")) { c->callback(c, client->id()); - } + } else if (msg.startsWith(F("svalue:"))) { c->value = msg.substring(msg.indexOf(':') + 1, msg.lastIndexOf(':')); @@ -864,7 +862,7 @@ void ESPUIClass::updateGauge(uint16_t id, int number, int clientId) updateControlValue(id, String(number), clientId); } -void ESPUIClass::clearGraph(uint16_t id, int clientId) {} +void ESPUIClass::clearGraph(uint16_t id, int clientId) { } void ESPUIClass::addGraphPoint(uint16_t id, int nValue, int clientId) { diff --git a/src/ESPUI.h b/src/ESPUI.h index 0df6584..a636f32 100644 --- a/src/ESPUI.h +++ b/src/ESPUI.h @@ -10,10 +10,10 @@ #include "stdlib_noniso.h" #if defined(ESP32) - #include #include +#include "FS.h" #include "LittleFS.h" #include "WiFi.h" @@ -163,7 +163,7 @@ public: color(control.color), parentControl(control.parentControl), next(control.next) - {} + { } private: static uint16_t idCounter;