1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-24 02:10:55 +00:00

Fixing rebase errors with littlefs/debug refactor

Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
This commit is contained in:
Lukas Bachschwell 2020-10-18 11:06:38 +02:00
parent a6ddd48abb
commit b71bc81c0d
Signed by: lbsadmin
GPG Key ID: CCC6AA87CC8DF425

View File

@ -22,11 +22,16 @@ void listDir(const char* dirname, uint8_t levels)
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
Serial.printf_P(F("Listing directory: %s\n"), dirname); Serial.printf_P(PSTR("Listing directory: %s\n"), dirname);
} }
#endif #endif
#if defined(ESP32)
File root = SPIFFS.open(dirname); File root = SPIFFS.open(dirname);
#else
File root = LittleFS.open(dirname);
#endif
if (!root) if (!root)
{ {
@ -130,7 +135,8 @@ if (!LittleFS.begin())
Serial.println(SPIFFS.totalBytes()); Serial.println(SPIFFS.totalBytes());
Serial.println(SPIFFS.usedBytes()); Serial.println(SPIFFS.usedBytes());
#else FSInfo fs_info; #else
FSInfo fs_info;
LittleFS.info(fs_info); LittleFS.info(fs_info);
Serial.println(fs_info.totalBytes); Serial.println(fs_info.totalBytes);
@ -146,24 +152,9 @@ void deleteFile(const char* path)
#else #else
bool exists = LittleFS.exists(path); bool exists = LittleFS.exists(path);
#endif #endif
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
Serial.print(exists);
}
#endif
if (!exists) if (!exists)
{ {
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
Serial.print(LittleFS.exists(path));
}
#endif
if (!LittleFS.exists(path))
{
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
@ -174,21 +165,19 @@ void deleteFile(const char* path)
return; return;
} }
#if defined(ESP32) #if defined(DEBUG_ESPUI)
bool didRemove = SPIFFS.remove(path);
#else
bool didRemove = LittleFS.remove(path);
#endif
if (didRemove)
{
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
Serial.printf_P(PSTR("Deleting file: %s\n"), path); Serial.printf_P(PSTR("Deleting file: %s\n"), path);
} }
#endif #endif
if (LittleFS.remove(path)) #if defined(ESP32)
bool didRemove = SPIFFS.remove(path);
#else
bool didRemove = LittleFS.remove(path);
#endif
if (didRemove)
{ {
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
@ -210,15 +199,6 @@ void deleteFile(const char* path)
void writeFile(const char* path, const char* data) void writeFile(const char* path, const char* data)
{ {
#if defined(ESP32)
File file = SPIFFS.open(path, FILE_WRITE);
#else
File file = LittleFS.open(path, FILE_WRITE);
#endif
if (!file)
{
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
@ -226,7 +206,11 @@ void writeFile(const char* path, const char* data)
} }
#endif #endif
#if defined(ESP32)
File file = SPIFFS.open(path, FILE_WRITE);
#else
File file = LittleFS.open(path, FILE_WRITE); File file = LittleFS.open(path, FILE_WRITE);
#endif
if (!file) if (!file)
{ {
@ -397,7 +381,8 @@ void onWsEvent(
{ {
switch (type) switch (type)
{ {
case WS_EVT_DISCONNECT: { case WS_EVT_DISCONNECT:
{
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
@ -408,7 +393,8 @@ void onWsEvent(
break; break;
} }
case WS_EVT_PONG: { case WS_EVT_PONG:
{
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
@ -419,7 +405,8 @@ void onWsEvent(
break; break;
} }
case WS_EVT_ERROR: { case WS_EVT_ERROR:
{
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
@ -430,7 +417,8 @@ void onWsEvent(
break; break;
} }
case WS_EVT_CONNECT: { case WS_EVT_CONNECT:
{
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
@ -450,7 +438,8 @@ void onWsEvent(
} }
break; break;
case WS_EVT_DATA: { case WS_EVT_DATA:
{
String msg = ""; String msg = "";
msg.reserve(len + 1); msg.reserve(len + 1);
@ -900,7 +889,7 @@ void ESPUIClass::updateGauge(uint16_t id, int number, int clientId)
updateControlValue(id, String(number), 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) void ESPUIClass::addGraphPoint(uint16_t id, int nValue, int clientId)
{ {
@ -1076,19 +1065,18 @@ void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const cha
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
Serial.println(F("FS Mount Failed, PLEASE CHECK THE README ON HOW TO PREPARE YOUR ESP!!!!!!!")); Serial.println(F("SPIFFS Mount Failed, PLEASE CHECK THE README ON HOW TO "
"PREPARE YOUR ESP!!!!!!!"));
} }
#endif #endif
server = new AsyncWebServer(80);
ws = new AsyncWebSocket("/ws");
if (!LittleFS.begin()) return;
{ }
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
Serial.println(F("SPIFFS Mount Failed, PLEASE CHECK THE README ON HOW TO " listDir("/", 1);
"PREPARE YOUR ESP!!!!!!!"));
} }
#endif #endif
@ -1099,15 +1087,6 @@ void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const cha
#endif #endif
if (!indexExists) if (!indexExists)
{ {
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
listDir("/", 1);
}
#endif
if (!LittleFS.exists("/index.htm"))
{
#if defined(DEBUG_ESPUI) #if defined(DEBUG_ESPUI)
if (ESPUI.verbosity) if (ESPUI.verbosity)
{ {
@ -1128,8 +1107,6 @@ void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const cha
{ {
ws->setAuthentication(ESPUI.basicAuthUsername, ESPUI.basicAuthPassword); ws->setAuthentication(ESPUI.basicAuthUsername, ESPUI.basicAuthPassword);
} }
server->serveStatic("/", LittleFS, "/").setDefaultFile("index.htm").setAuthentication(username, password);
}
#if defined(ESP32) #if defined(ESP32)
server->serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm").setAuthentication(username, password); server->serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm").setAuthentication(username, password);
#else #else
@ -1145,13 +1122,6 @@ void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const cha
#endif #endif
} }
// Heap for general Servertest
server->on("/heap", HTTP_GET, [](AsyncWebServerRequest *request) {
if (ESPUI.basicAuth && !request->authenticate(ESPUI.basicAuthUsername, ESPUI.basicAuthPassword))
{
server->serveStatic("/", LittleFS, "/").setDefaultFile("index.htm");
}
// Heap for general Servertest // Heap for general Servertest
server->on("/heap", HTTP_GET, [](AsyncWebServerRequest* request) { server->on("/heap", HTTP_GET, [](AsyncWebServerRequest* request) {
if (ESPUI.basicAuth && !request->authenticate(ESPUI.basicAuthUsername, ESPUI.basicAuthPassword)) if (ESPUI.basicAuth && !request->authenticate(ESPUI.basicAuthUsername, ESPUI.basicAuthPassword))