From 68a38d0b3836c3bbf6df77cfb1b99b330c742c0a Mon Sep 17 00:00:00 2001
From: fvanroie
Date: Sat, 14 Nov 2020 14:02:35 +0100
Subject: [PATCH] Prepare for LittleFS
---
include/hasp_conf.h | 40 ++++++++++----
platformio.ini | 2 +
src/hasp.cpp | 11 ++--
src/hasp_config.cpp | 52 +++++++++---------
src/hasp_dispatch.cpp | 20 +++----
src/{hasp_spiffs.cpp => hasp_filesystem.cpp} | 37 ++++++-------
src/hasp_filesystem.h | 30 +++++++++++
src/hasp_gui.cpp | 22 +++-----
src/hasp_http.cpp | 57 +++++++++-----------
src/hasp_mdns.cpp | 8 ---
src/hasp_spiffs.h | 11 ----
user_setups/esp32/d1-mini-esp32_ili9341.ini | 5 ++
12 files changed, 159 insertions(+), 136 deletions(-)
rename src/{hasp_spiffs.cpp => hasp_filesystem.cpp} (73%)
create mode 100644 src/hasp_filesystem.h
delete mode 100644 src/hasp_spiffs.h
diff --git a/include/hasp_conf.h b/include/hasp_conf.h
index 126f93d5..0bcad137 100644
--- a/include/hasp_conf.h
+++ b/include/hasp_conf.h
@@ -42,7 +42,15 @@
#define HASP_HAS_FILESYSTEM (ARDUINO_ARCH_ESP32 > 0 || ARDUINO_ARCH_ESP8266 > 0)
#ifndef HASP_USE_SPIFFS
+#ifndef HASP_USE_LITTLEFS
#define HASP_USE_SPIFFS (HASP_HAS_FILESYSTEM)
+#else
+#define HASP_USE_SPIFFS (HASP_USE_LITTLEFS <= 0)
+#endif
+#endif
+
+#ifndef HASP_USE_LITTLEFS
+#define HASP_USE_LITTLEFS (HASP_USE_SPIFFS <= 0)
#endif
#ifndef HASP_USE_EEPROM
@@ -91,12 +99,22 @@
#include "SPIFFS.h"
#endif
#include // Include the SPIFFS library
-#include "hasp_spiffs.h"
+#include "hasp_filesystem.h"
+#endif
+#if HASP_USE_LITTLEFS > 0
+#if defined(ARDUINO_ARCH_ESP32)
+#include
+#endif
+#include // Include the FS library
+#include "hasp_filesystem.h"
+#endif
+
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
#include "lv_zifont.h"
#endif
-#endif // SPIFFS
+#endif
#if HASP_USE_EEPROM > 0
#include "hasp_eeprom.h"
@@ -110,13 +128,13 @@
#if defined(ARDUINO_ARCH_ESP32)
#include
-#define ETH_ADDR 0
-#define ETH_POWER_PIN -1
-#define ETH_MDC_PIN 23
-#define ETH_MDIO_PIN 18
-#define NRST 5
-#define ETH_TYPE ETH_PHY_LAN8720
-#define ETH_CLKMODE ETH_CLOCK_GPIO17_OUT
+#define ETH_ADDR 0
+#define ETH_POWER_PIN -1
+#define ETH_MDC_PIN 23
+#define ETH_MDIO_PIN 18
+#define NRST 5
+#define ETH_TYPE ETH_PHY_LAN8720
+#define ETH_CLKMODE ETH_CLOCK_GPIO17_OUT
#include "hasp_ethernet_esp32.h"
#warning Using ESP32 Ethernet LAN8720
@@ -142,6 +160,10 @@
#include "hasp_mqtt.h"
#endif
+#if HASP_USE_GPIO > 0
+#include "hasp_gpio.h"
+#endif
+
#if HASP_USE_HTTP > 0
#include "hasp_http.h"
#endif
diff --git a/platformio.ini b/platformio.ini
index 13fa1642..d08b28fd 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -95,6 +95,7 @@ esp8266_flags=
-D HASP_USE_SYSLOG=1
-D HASP_USE_TELNET=1
-D HASP_USE_SPIFFS=1
+ -D HASP_USE_LITTLEFS=0
-D HASP_USE_EEPROM=1
-D HASP_USE_GPIO=1
-D HASP_USE_ETHERNET=0
@@ -110,6 +111,7 @@ esp32_flags=
-D HASP_USE_SYSLOG=1
-D HASP_USE_TELNET=1
-D HASP_USE_SPIFFS=1
+ -D HASP_USE_LITTLEFS=0
-D HASP_USE_EEPROM=1
-D HASP_USE_GPIO=1
diff --git a/src/hasp.cpp b/src/hasp.cpp
index b455a15f..ed4e6607 100644
--- a/src/hasp.cpp
+++ b/src/hasp.cpp
@@ -15,6 +15,7 @@
#include "hasp_debug.h"
#include "hasp_config.h"
#include "hasp_dispatch.h"
+//#include "hasp_filesystem.h" included in hasp_conf.h
#include "hasp_wifi.h"
#include "hasp_gui.h"
#include "hasp_tft.h"
@@ -404,7 +405,7 @@ void haspSetup()
/* ********** Font Initializations ********** */
-#if HASP_USE_SPIFFS > 0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
lv_zifont_init();
@@ -1006,22 +1007,22 @@ void haspNewObject(const JsonObject & config, uint8_t & saved_page_id)
void haspLoadPage(const char * pages)
{
-#if HASP_USE_SPIFFS > 0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
if(pages[0] == '\0') return;
- if(!SPIFFS.begin()) {
+ if(!filesystemSetup()) {
Log.error(TAG_HASP, F("FS not mounted. Failed to load %s"), pages);
return;
}
- if(!SPIFFS.exists(pages)) {
+ if(!HASP_FS.exists(pages)) {
Log.error(TAG_HASP, F("Non existing file %s"), pages);
return;
}
Log.notice(TAG_HASP, F("Loading file %s"), pages);
- File file = SPIFFS.open(pages, "r");
+ File file = HASP_FS.open(pages, "r");
dispatchParseJsonl(file);
file.close();
diff --git a/src/hasp_config.cpp b/src/hasp_config.cpp
index a09ade94..1d554d21 100644
--- a/src/hasp_config.cpp
+++ b/src/hasp_config.cpp
@@ -3,24 +3,20 @@
#include "ArduinoJson.h"
#include "StreamUtils.h"
+#include "hasp_conf.h"
+
#include "hasp_config.h"
#include "hasp_debug.h"
#include "hasp_gui.h"
-#include "hasp_ota.h"
-#include "hasp_spiffs.h"
-#include "hasp_telnet.h"
-#include "hasp_gpio.h"
+
+//#include "hasp_ota.h" included in conf
+//#include "hasp_filesystem.h" included in conf
+//#include "hasp_telnet.h" included in conf
+//#include "hasp_gpio.h" included in conf
+
//#include "hasp_eeprom.h"
#include "hasp.h"
-#include "hasp_conf.h"
-
-#if HASP_USE_SPIFFS > 0
-#include // Include the SPIFFS library
-#if defined(ARDUINO_ARCH_ESP32)
-#include "SPIFFS.h"
-#endif
-#endif
#if HASP_USE_EEPROM > 0
#include "EEPROM.h"
#endif
@@ -74,13 +70,13 @@ void configStartDebug(bool setupdebug, String & configFile)
{
if(setupdebug) {
debugStart(); // Debug started, now we can use it; HASP header sent
-#if HASP_USE_SPIFFS > 0
- Log.notice(TAG_CONF, F("FILE: [SUCCESS] SPI flash FS mounted"));
- spiffsInfo();
- spiffsList();
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ Log.notice(TAG_CONF, F("[SUCCESS] SPI flash FS mounted"));
+ filesystemInfo();
+ filesystemList();
#endif
}
-#if HASP_USE_SPIFFS > 0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
Log.notice(TAG_CONF, F("Loading %s"), configFile.c_str());
#else
Log.notice(TAG_CONF, F("reading EEPROM"));
@@ -94,8 +90,8 @@ void configGetConfig(JsonDocument & settings, bool setupdebug = false)
configFile = String(FPSTR(HASP_CONFIG_FILE));
DeserializationError error;
-#if HASP_USE_SPIFFS > 0
- File file = SPIFFS.open(configFile, "r");
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ File file = HASP_FS.open(configFile, "r");
if(file) {
size_t size = file.size();
@@ -143,14 +139,14 @@ void configGetConfig(JsonDocument & settings, bool setupdebug = false)
}
configStartDebug(setupdebug, configFile);
-#if HASP_USE_SPIFFS > 0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
Log.error(TAG_CONF, F("Failed to load %s"), configFile.c_str());
#endif
}
/*
void configBackupToEeprom()
{
-#if HASP_USE_SPIFFS>0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
String configFile((char *)0);
configFile.reserve(128);
configFile = String(FPSTR(HASP_CONFIG_FILE));
@@ -159,7 +155,7 @@ void configBackupToEeprom()
uint8_t buffer[128];
size_t index = 0;
- File file = SPIFFS.open(configFile, "r");
+ File file = HASP_FS.open(configFile, "r");
if(file) {
while(size_t count = file.read(buffer, sizeof(buffer)) > 0) {
@@ -281,8 +277,8 @@ void configWriteConfig()
// changed |= otaGetConfig(settings[F("ota")].as());
if(writefile) {
-#if HASP_USE_SPIFFS > 0
- File file = SPIFFS.open(configFile, "w");
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ File file = HASP_FS.open(configFile, "w");
if(file) {
Log.notice(TAG_CONF, F("Writing %s"), configFile.c_str());
size_t size = serializeJson(doc, file);
@@ -344,8 +340,8 @@ void configSetup()
continue;
#endif
} else {
-#if HASP_USE_SPIFFS > 0
- if(!SPIFFS.begin()) {
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ if(!filesystemSetup()) {
Log.error(TAG_CONF, F("FILE: SPI flash init failed. Unable to mount FS: Using default settings..."));
return;
}
@@ -454,8 +450,8 @@ bool configClear()
Log.error(TAG_CONF, F("Failed to clear to EEPROM"));
return false;
}
-#elif HASP_USE_SPIFFS > 0
- return SPIFFS.format();
+#elif HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ return HASP_FS.format();
#else
return false;
#endif
diff --git a/src/hasp_dispatch.cpp b/src/hasp_dispatch.cpp
index 85d8543d..f62f4d3d 100644
--- a/src/hasp_dispatch.cpp
+++ b/src/hasp_dispatch.cpp
@@ -3,17 +3,16 @@
#include "StringStream.h"
#include "CharStream.h"
+#include "hasp_conf.h"
+
#include "hasp_dispatch.h"
#include "hasp_config.h"
#include "hasp_debug.h"
-#include "hasp_gpio.h"
#include "hasp_gui.h"
#include "hasp_oobe.h"
#include "hasp_hal.h"
#include "hasp.h"
-#include "hasp_conf.h"
-
inline bool isON(const char * payload)
{
return strcasecmp_P(payload, PSTR("ON")) == 0;
@@ -38,8 +37,8 @@ bool dispatch_factory_reset()
{
bool formated, erased = true;
-#if HASP_USE_SPIFFS > 0
- formated = SPIFFS.format();
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ formated = HASP_FS.format();
#endif
#if HASP_USE_EEPROM > 0
@@ -209,12 +208,13 @@ void dispatchCommand(const char * topic, const char * payload)
#endif
} else if(!strcmp_P(topic, PSTR("mqtthost")) || !strcmp_P(topic, PSTR("mqttport")) ||
- !strcmp_P(topic, PSTR("mqttuser")) || !strcmp_P(topic, PSTR("mqttpass"))) {
- char item[5];
- memset(item, 0, sizeof(item));
- strncpy(item, topic + 4, 4);
+ !strcmp_P(topic, PSTR("mqttport")) || !strcmp_P(topic, PSTR("mqttuser")) ||
+ !strcmp_P(topic, PSTR("hostname"))) {
+ // char item[5];
+ // memset(item, 0, sizeof(item));
+ // strncpy(item, topic + 4, 4);
DynamicJsonDocument settings(45);
- settings[item] = payload;
+ settings[topic + 4] = payload;
mqttSetConfig(settings.as());
} else {
diff --git a/src/hasp_spiffs.cpp b/src/hasp_filesystem.cpp
similarity index 73%
rename from src/hasp_spiffs.cpp
rename to src/hasp_filesystem.cpp
index 54e199b8..5ae50f39 100644
--- a/src/hasp_spiffs.cpp
+++ b/src/hasp_filesystem.cpp
@@ -4,16 +4,9 @@
#include "hasp_conf.h"
#include "hasp_debug.h"
-#include "hasp_spiffs.h"
+#include "hasp_filesystem.h"
-#if HASP_USE_SPIFFS > 0
-#if defined(ARDUINO_ARCH_ESP32)
-#include "SPIFFS.h"
-#endif
-#include
-#endif
-
-void spiffsInfo()
+void filesystemInfo()
{ // Get all information of your SPIFFS
#if 0
FSInfo fs_info;
@@ -68,7 +61,7 @@ void spiffsInfo()
#endif
}
-void spiffsList()
+void filesystemList()
{
#if HASP_USE_SPIFFS > 0
#if defined(ARDUINO_ARCH_ESP8266)
@@ -76,42 +69,46 @@ void spiffsList()
#else
if(!SPIFFS.begin(true)) {
#endif
- Log.error(TAG_FILE,F("Flash file system not mouted."));
+ Log.error(TAG_FILE, F("Flash file system not mouted."));
} else {
- Log.verbose(TAG_FILE,F("Listing files on the internal flash:"));
+ Log.verbose(TAG_FILE, F("Listing files on the internal flash:"));
#if defined(ARDUINO_ARCH_ESP32)
File root = SPIFFS.open("/");
File file = root.openNextFile();
while(file) {
- Log.verbose(TAG_FILE,F(" * %s (%u bytes)"), file.name(), (uint32_t)file.size());
+ Log.verbose(TAG_FILE, F(" * %s (%u bytes)"), file.name(), (uint32_t)file.size());
file = root.openNextFile();
}
#endif
#if defined(ARDUINO_ARCH_ESP8266)
Dir dir = SPIFFS.openDir("/");
while(dir.next()) {
- Log.notice(TAG_FILE,F(" * %s (%u bytes)"), dir.fileName().c_str(), (uint32_t)dir.fileSize());
+ Log.notice(TAG_FILE, F(" * %s (%u bytes)"), dir.fileName().c_str(), (uint32_t)dir.fileSize());
}
#endif
}
#endif
}
-void spiffsSetup()
+bool filesystemSetup()
{
// no SPIFFS settings, as settings depend on SPIFFS
-#if HASP_USE_SPIFFS > 0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
#if defined(ARDUINO_ARCH_ESP8266)
- if(!SPIFFS.begin()) {
+ if(!HASP_FS.begin()) {
#else
- if(!SPIFFS.begin(true)) {
+ if(!HASP_FS.begin(true)) {
#endif
- Log.error(TAG_FILE,F("SPI flash init failed. Unable to mount FS."));
+ Log.error(TAG_FILE, F("SPI flash init failed. Unable to mount FS."));
+ return false;
} else {
- Log.verbose(TAG_FILE,F("SPI Flash FS mounted"));
+ Log.verbose(TAG_FILE, F("SPI Flash FS mounted"));
+ return true;
}
#endif
+
+ return false;
}
\ No newline at end of file
diff --git a/src/hasp_filesystem.h b/src/hasp_filesystem.h
new file mode 100644
index 00000000..a7b944ac
--- /dev/null
+++ b/src/hasp_filesystem.h
@@ -0,0 +1,30 @@
+#ifndef HASP_FILESYSTEM_H
+#define HASP_FILESYSTEM_H
+
+#include
+
+bool filesystemSetup(void);
+
+void filesystemList();
+void filesystemInfo();
+
+
+#if defined(ARDUINO_ARCH_ESP32)
+#include
+#include
+
+#if HASP_USE_SPIFFS > 0
+#include "SPIFFS.h"
+extern FS * HASP_FS = &SPIFFS;
+#elif HASP_USE_LITTLEFS > 0
+#include "LittleFS.h"
+#define HASP_FS LITTLEFS
+#endif
+
+#elif defined(ARDUINO_ARCH_ESP8266)
+#include
+#include
+#define HASP_FS SPIFFS
+#endif
+
+#endif
diff --git a/src/hasp_gui.cpp b/src/hasp_gui.cpp
index fc4d761c..5b894cfb 100644
--- a/src/hasp_gui.cpp
+++ b/src/hasp_gui.cpp
@@ -21,6 +21,7 @@
//#include "lv_zifont.h"
+#include "hasp_conf.h"
#include "hasp_debug.h"
#include "hasp_config.h"
#include "hasp_dispatch.h"
@@ -39,16 +40,9 @@
#define TOUCH_DRIVER 99
#endif
-#if HASP_USE_SPIFFS > 0
-#if defined(ARDUINO_ARCH_ESP32)
-#include "SPIFFS.h"
-#endif
-#include // Include the SPIFFS library
-#endif
-
#define BACKLIGHT_CHANNEL 15 // pwm channel 0-15
-#if HASP_USE_SPIFFS > 0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
File pFileOut;
#endif
@@ -609,8 +603,8 @@ void guiSetup()
lv_obj_t * mouse_layer = lv_disp_get_layer_sys(NULL); // default display
#if defined(ARDUINO_ARCH_ESP32)
- LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/
- cursor = lv_img_create(mouse_layer, NULL); /*Create an image object for the cursor */
+ LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/
+ cursor = lv_img_create(mouse_layer, NULL); /*Create an image object for the cursor */
lv_img_set_src(cursor, &mouse_cursor_icon); /*Set the image source*/
#else
cursor = lv_obj_create(mouse_layer, NULL); // show cursor object on every page
@@ -822,7 +816,7 @@ bool guiSetConfig(const JsonObject & settings)
}
/* **************************** SCREENSHOTS ************************************** */
-#if HASP_USE_SPIFFS > 0 || HASP_USE_HTTP > 0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 || HASP_USE_HTTP > 0
static void guiSetBmpHeader(uint8_t * buffer_p, int32_t data)
{
@@ -887,9 +881,9 @@ void gui_flush_not_complete()
{
Log.warning(TAG_GUI, F("GUI: Pixelbuffer not completely sent"));
}
-#endif // HASP_USE_SPIFFS > 0 || HASP_USE_HTTP > 0
+#endif // HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 || HASP_USE_HTTP > 0
-#if HASP_USE_SPIFFS > 0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
/* Flush VDB bytes to a file */
static void gui_screenshot_to_file(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p)
{
@@ -914,7 +908,7 @@ void guiTakeScreenshot(const char * pFileName)
uint8_t buffer[128];
gui_get_bitmap_header(buffer, sizeof(buffer));
- pFileOut = SPIFFS.open(pFileName, "w");
+ pFileOut = HASP_FS.open(pFileName, "w");
if(pFileOut) {
size_t len = pFileOut.write(buffer, 122);
diff --git a/src/hasp_http.cpp b/src/hasp_http.cpp
index aaec33fe..998d3b11 100644
--- a/src/hasp_http.cpp
+++ b/src/hasp_http.cpp
@@ -13,24 +13,11 @@
#include "hasp_gui.h"
#include "hasp_hal.h"
-#include "hasp_gpio.h"
#include "hasp_debug.h"
#include "hasp_config.h"
#include "hasp_dispatch.h"
#include "hasp.h"
-#include "hasp_conf.h"
-
-#if defined(ARDUINO_ARCH_ESP32)
-#include "SPIFFS.h"
-#include
-#include
-#include
-#elif defined(ARDUINO_ARCH_ESP8266)
-#include
-#include
-#endif
-
#if HASP_USE_HTTP > 0
bool httpEnable = true;
@@ -38,7 +25,6 @@ bool webServerStarted = false;
uint16_t httpPort = 80;
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
-FS * filesystem = &SPIFFS;
File fsUploadFile;
#endif
@@ -249,8 +235,8 @@ void webHandleRoot()
httpMessage +=
F("
");
-#if HASP_USE_SPIFFS > 0
- if(SPIFFS.exists(F("/edit.htm.gz"))) {
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
+ if(HASP_FS.exists(F("/edit.htm.gz"))) {
httpMessage += F("");
}
@@ -447,6 +433,15 @@ void webHandleInfo()
httpMessage += F("
Memory Fragmentation: ");
httpMessage += String(halGetHeapFragmentation());
+#if ARDUINO_ARCH_ESP32
+ if(psramFound()) {
+ httpMessage += F("
Free PSRam: ");
+ httpMessage += halFormatBytes(ESP.getFreePsram());
+ httpMessage += F("
PSRam Size: ");
+ httpMessage += halFormatBytes(ESP.getPsramSize());
+ }
+#endif
+
/* LVGL Stats */
lv_mem_monitor_t mem_mon;
lv_mem_monitor(&mem_mon);
@@ -696,7 +691,7 @@ void webHandleFirmwareUpdate()
}
#endif
-#if HASP_USE_SPIFFS > 0
+#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
bool handleFileRead(String path)
{
if(!httpIsAuthenticated(F("fileread"))) return false;
@@ -706,10 +701,10 @@ bool handleFileRead(String path)
path += F("index.htm");
}
String pathWithGz = path + F(".gz");
- if(filesystem->exists(pathWithGz) || filesystem->exists(path)) {
- if(filesystem->exists(pathWithGz)) path += F(".gz");
+ if(HASP_FS.exists(pathWithGz) || HASP_FS.exists(path)) {
+ if(HASP_FS.exists(pathWithGz)) path += F(".gz");
- File file = filesystem->open(path, "r");
+ File file = HASP_FS.open(path, "r");
String contentType = getContentType(path);
if(path == F("/edit.htm.gz")) {
contentType = F("text/html");
@@ -738,7 +733,7 @@ void handleFileUpload()
filename += upload->filename;
}
if(filename.length() < 32) {
- fsUploadFile = filesystem->open(filename, "w");
+ fsUploadFile = HASP_FS.open(filename, "w");
Log.notice(TAG_HTTP, F("handleFileUpload Name: %s"), filename.c_str());
haspProgressMsg(fsUploadFile.name());
} else {
@@ -782,10 +777,10 @@ void handleFileDelete()
if(path == "/") {
return webServer.send_P(500, mimetype, PSTR("BAD PATH"));
}
- if(!filesystem->exists(path)) {
+ if(!HASP_FS.exists(path)) {
return webServer.send_P(404, mimetype, PSTR("FileNotFound"));
}
- filesystem->remove(path);
+ HASP_FS.remove(path);
webServer.send_P(200, mimetype, PSTR(""));
// path.clear();
}
@@ -802,10 +797,10 @@ void handleFileCreate()
if(path == "/") {
return webServer.send(500, PSTR("text/plain"), PSTR("BAD PATH"));
}
- if(filesystem->exists(path)) {
+ if(HASP_FS.exists(path)) {
return webServer.send(500, PSTR("text/plain"), PSTR("FILE EXISTS"));
}
- File file = filesystem->open(path, "w");
+ File file = HASP_FS.open(path, "w");
if(file) {
file.close();
} else {
@@ -829,7 +824,7 @@ void handleFileList()
path.clear();
#if defined(ARDUINO_ARCH_ESP32)
- File root = SPIFFS.open("/");
+ File root = HASP_FS.open("/", FILE_READ);
File file = root.openNextFile();
String output = "[";
@@ -854,7 +849,7 @@ void handleFileList()
output += "]";
webServer.send(200, PSTR("text/json"), output);
#elif defined(ARDUINO_ARCH_ESP8266)
- Dir dir = filesystem->openDir(path);
+ Dir dir = HASP_FS.openDir(path);
String output = "[";
while(dir.next()) {
File entry = dir.openFile("r");
@@ -1489,7 +1484,7 @@ void webHandleHaspConfig()
httpMessage += F("Default Font