Updates to test ffat partition alternative on esp32, see https://github.com/lorol/arduino-esp32fatfs-plugin

examples/ESP_AsyncFSBrowser
examples/SmartSwitch
updated ACE editor js. css. gz components in example's /data folder 
(they are used by SPIFFSEditor)
This commit is contained in:
lorol
2020-07-10 07:53:21 -04:00
parent 0823e9d940
commit 1f3541b1dd
12 changed files with 285 additions and 253 deletions

View File

@@ -1,5 +1,5 @@
# In this fork # In this fork
- SPIFFSEditor improvements - SPIFFSEditor modifications
- Added [extras](https://github.com/lorol/ESPAsyncWebServer/tree/master/extras) folder with (Win) tools for re-packing, editing, updating and compressing html to binary arrays embedded to source - Added [extras](https://github.com/lorol/ESPAsyncWebServer/tree/master/extras) folder with (Win) tools for re-packing, editing, updating and compressing html to binary arrays embedded to source
- Added a [SmartSwitch](https://github.com/lorol/ESPAsyncWebServer/tree/master/examples/SmartSwitch) example to test code features - Added a [SmartSwitch](https://github.com/lorol/ESPAsyncWebServer/tree/master/examples/SmartSwitch) example to test code features
- Applied the memory optimizations from [sascha432](https://github.com/sascha432/ESPAsyncWebServer) fork - Applied the memory optimizations from [sascha432](https://github.com/sascha432/ESPAsyncWebServer) fork
@@ -9,7 +9,7 @@
- [Additions to this README.md from jendakol' PR](https://github.com/me-no-dev/ESPAsyncWebServer/pull/770) - [Additions to this README.md from jendakol' PR](https://github.com/me-no-dev/ESPAsyncWebServer/pull/770)
- [Respond with file content using a callback and extra headers](#respond-with-file-content-using-a-callback-and-extra-headers) - [Respond with file content using a callback and extra headers](#respond-with-file-content-using-a-callback-and-extra-headers)
- [Serving static files by custom handling](#serving-static-files-by-custom-handling) - [Serving static files by custom handling](#serving-static-files-by-custom-handling)
- Added LittleFS choice for both [esp8266](https://github.com/esp8266/Arduino/tree/master/libraries/LittleFS) / [esp32](https://github.com/lorol/LITTLEFS) , see [SmartSwitch](https://github.com/lorol/ESPAsyncWebServer/blob/master/examples/SmartSwitch/SmartSwitch.ino#L16 ) - Added LittleFS choice for both [esp8266](https://github.com/esp8266/Arduino/tree/master/libraries/LittleFS) / [esp32](https://github.com/lorol/LITTLEFS) , and FatFS tests for esp32 see [SmartSwitch](https://github.com/lorol/ESPAsyncWebServer/blob/master/examples/SmartSwitch/SmartSwitch.ino#L16 )
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
# ESPAsyncWebServer # ESPAsyncWebServer

View File

@@ -1,234 +1,248 @@
#define USE_LittleFS // possible only for ESP8266 for now // Defaulut is SPIFFS, FatFS: only on ESP32, also choose partition scheme w/ ffat.
// Comment 2 lines below or uncomment only one of them
#include <ArduinoOTA.h>
//#define USE_LittleFS
#ifdef ESP32 //#define USE_FatFS // Only ESP32
#include <FS.h>
#ifdef USE_LittleFS #include <ArduinoOTA.h>
#define SPIFFS LITTLEFS #ifdef ESP32
#include <LITTLEFS.h> #include <FS.h>
#else #ifdef USE_LittleFS
#include <SPIFFS.h> #define MYFS LITTLEFS
#endif #include "LITTLEFS.h"
#include <ESPmDNS.h> #elif defined(USE_FatFS)
#include <WiFi.h> #define MYFS FFat
#include <AsyncTCP.h> #include "FFat.h"
#elif defined(ESP8266) #else
#ifdef USE_LittleFS #define MYFS SPIFFS
#include <FS.h> #include <SPIFFS.h>
#define SPIFFS LittleFS #endif
#include <LittleFS.h> #include <ESPmDNS.h>
#endif #include <WiFi.h>
#include <ESP8266WiFi.h> #include <AsyncTCP.h>
#include <ESPAsyncTCP.h> #elif defined(ESP8266)
#include <ESP8266mDNS.h> #ifdef USE_LittleFS
#endif #include <FS.h>
#include <ESPAsyncWebServer.h> #define MYFS LittleFS
#include <SPIFFSEditor.h> #include <LittleFS.h>
#elif defined(USE_FatFS)
// SKETCH BEGIN #error "FatFS only on ESP32 for now!"
AsyncWebServer server(80); #else
AsyncWebSocket ws("/ws"); #define MYFS SPIFFS
AsyncEventSource events("/events"); #endif
#include <ESP8266WiFi.h>
void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){ #include <ESPAsyncTCP.h>
if(type == WS_EVT_CONNECT){ #include <ESP8266mDNS.h>
Serial.printf("ws[%s][%u] connect\n", server->url(), client->id()); #endif
client->printf("Hello Client %u :)", client->id()); #include <ESPAsyncWebServer.h>
client->ping(); #include <SPIFFSEditor.h>
} else if(type == WS_EVT_DISCONNECT){
Serial.printf("ws[%s][%u] disconnect\n", server->url(), client->id());
} else if(type == WS_EVT_ERROR){ // SKETCH BEGIN
Serial.printf("ws[%s][%u] error(%u): %s\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data); AsyncWebServer server(80);
} else if(type == WS_EVT_PONG){ AsyncWebSocket ws("/ws");
Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:""); AsyncEventSource events("/events");
} else if(type == WS_EVT_DATA){
AwsFrameInfo * info = (AwsFrameInfo*)arg; void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){
String msg = ""; if(type == WS_EVT_CONNECT){
if(info->final && info->index == 0 && info->len == len){ Serial.printf("ws[%s][%u] connect\n", server->url(), client->id());
//the whole message is in a single frame and we got all of it's data client->printf("Hello Client %u :)", client->id());
Serial.printf("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT)?"text":"binary", info->len); client->ping();
} else if(type == WS_EVT_DISCONNECT){
if(info->opcode == WS_TEXT){ Serial.printf("ws[%s][%u] disconnect\n", server->url(), client->id());
for(size_t i=0; i < info->len; i++) { } else if(type == WS_EVT_ERROR){
msg += (char) data[i]; Serial.printf("ws[%s][%u] error(%u): %s\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data);
} } else if(type == WS_EVT_PONG){
} else { Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:"");
char buff[3]; } else if(type == WS_EVT_DATA){
for(size_t i=0; i < info->len; i++) { AwsFrameInfo * info = (AwsFrameInfo*)arg;
sprintf(buff, "%02x ", (uint8_t) data[i]); String msg = "";
msg += buff ; if(info->final && info->index == 0 && info->len == len){
} //the whole message is in a single frame and we got all of it's data
} Serial.printf("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT)?"text":"binary", info->len);
Serial.printf("%s\n",msg.c_str());
if(info->opcode == WS_TEXT){
if(info->opcode == WS_TEXT) for(size_t i=0; i < info->len; i++) {
client->text("I got your text message"); msg += (char) data[i];
else }
client->binary("I got your binary message"); } else {
} else { char buff[3];
//message is comprised of multiple frames or the frame is split into multiple packets for(size_t i=0; i < info->len; i++) {
if(info->index == 0){ sprintf(buff, "%02x ", (uint8_t) data[i]);
if(info->num == 0) msg += buff ;
Serial.printf("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary"); }
Serial.printf("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len); }
} Serial.printf("%s\n",msg.c_str());
Serial.printf("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT)?"text":"binary", info->index, info->index + len); if(info->opcode == WS_TEXT)
client->text("I got your text message");
if(info->opcode == WS_TEXT){ else
for(size_t i=0; i < len; i++) { client->binary("I got your binary message");
msg += (char) data[i]; } else {
} //message is comprised of multiple frames or the frame is split into multiple packets
} else { if(info->index == 0){
char buff[3]; if(info->num == 0)
for(size_t i=0; i < len; i++) { Serial.printf("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
sprintf(buff, "%02x ", (uint8_t) data[i]); Serial.printf("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len);
msg += buff ; }
}
} Serial.printf("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT)?"text":"binary", info->index, info->index + len);
Serial.printf("%s\n",msg.c_str());
if(info->opcode == WS_TEXT){
if((info->index + len) == info->len){ for(size_t i=0; i < len; i++) {
Serial.printf("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len); msg += (char) data[i];
if(info->final){ }
Serial.printf("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary"); } else {
if(info->message_opcode == WS_TEXT) char buff[3];
client->text("I got your text message"); for(size_t i=0; i < len; i++) {
else sprintf(buff, "%02x ", (uint8_t) data[i]);
client->binary("I got your binary message"); msg += buff ;
} }
} }
} Serial.printf("%s\n",msg.c_str());
}
} if((info->index + len) == info->len){
Serial.printf("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len);
if(info->final){
const char* ssid = "*******"; Serial.printf("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
const char* password = "*******"; if(info->message_opcode == WS_TEXT)
const char * hostName = "esp-async"; client->text("I got your text message");
const char* http_username = "admin"; else
const char* http_password = "admin"; client->binary("I got your binary message");
}
void setup(){ }
Serial.begin(115200); }
Serial.setDebugOutput(true); }
WiFi.mode(WIFI_AP_STA); }
WiFi.softAP(hostName);
WiFi.begin(ssid, password); const char* ssid = "*****";
if (WiFi.waitForConnectResult() != WL_CONNECTED) { const char* password = "*****";
Serial.printf("STA: Failed!\n"); const char* hostName = "esp-async";
WiFi.disconnect(false); const char* http_username = "admin";
delay(1000); const char* http_password = "admin";
WiFi.begin(ssid, password);
} void setup(){
Serial.begin(115200);
//Send OTA events to the browser Serial.setDebugOutput(true);
ArduinoOTA.onStart([]() { events.send("Update Start", "ota"); }); WiFi.mode(WIFI_AP_STA);
ArduinoOTA.onEnd([]() { events.send("Update End", "ota"); }); WiFi.softAP(hostName);
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { WiFi.begin(ssid, password);
char p[32]; if (WiFi.waitForConnectResult() != WL_CONNECTED) {
sprintf(p, "Progress: %u%%\n", (progress/(total/100))); Serial.printf("STA: Failed!\n");
events.send(p, "ota"); WiFi.disconnect(false);
}); delay(1000);
ArduinoOTA.onError([](ota_error_t error) { WiFi.begin(ssid, password);
if(error == OTA_AUTH_ERROR) events.send("Auth Failed", "ota"); }
else if(error == OTA_BEGIN_ERROR) events.send("Begin Failed", "ota");
else if(error == OTA_CONNECT_ERROR) events.send("Connect Failed", "ota"); Serial.print(F("*CONNECTED* IP:"));
else if(error == OTA_RECEIVE_ERROR) events.send("Recieve Failed", "ota"); Serial.println(WiFi.localIP());
else if(error == OTA_END_ERROR) events.send("End Failed", "ota");
}); //Send OTA events to the browser
ArduinoOTA.setHostname(hostName); ArduinoOTA.onStart([]() { events.send("Update Start", "ota"); });
ArduinoOTA.begin(); ArduinoOTA.onEnd([]() { events.send("Update End", "ota"); });
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
MDNS.addService("http","tcp",80); char p[32];
sprintf(p, "Progress: %u%%\n", (progress/(total/100)));
SPIFFS.begin(); events.send(p, "ota");
});
ws.onEvent(onWsEvent); ArduinoOTA.onError([](ota_error_t error) {
server.addHandler(&ws); if(error == OTA_AUTH_ERROR) events.send("Auth Failed", "ota");
else if(error == OTA_BEGIN_ERROR) events.send("Begin Failed", "ota");
events.onConnect([](AsyncEventSourceClient *client){ else if(error == OTA_CONNECT_ERROR) events.send("Connect Failed", "ota");
client->send("hello!",NULL,millis(),1000); else if(error == OTA_RECEIVE_ERROR) events.send("Recieve Failed", "ota");
}); else if(error == OTA_END_ERROR) events.send("End Failed", "ota");
server.addHandler(&events); });
ArduinoOTA.setHostname(hostName);
#ifdef ESP32 ArduinoOTA.begin();
server.addHandler(new SPIFFSEditor(SPIFFS, http_username,http_password));
#elif defined(ESP8266) MDNS.addService("http","tcp",80);
server.addHandler(new SPIFFSEditor(http_username,http_password));
#endif MYFS.begin();
server.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request){ ws.onEvent(onWsEvent);
request->send(200, "text/plain", String(ESP.getFreeHeap())); server.addHandler(&ws);
});
events.onConnect([](AsyncEventSourceClient *client){
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm"); client->send("hello!",NULL,millis(),1000);
});
server.onNotFound([](AsyncWebServerRequest *request){ server.addHandler(&events);
Serial.printf("NOT_FOUND: ");
if(request->method() == HTTP_GET) #ifdef ESP32
Serial.printf("GET"); server.addHandler(new SPIFFSEditor(MYFS, http_username,http_password));
else if(request->method() == HTTP_POST) #elif defined(ESP8266)
Serial.printf("POST"); server.addHandler(new SPIFFSEditor(http_username,http_password, MYFS));
else if(request->method() == HTTP_DELETE) #endif
Serial.printf("DELETE");
else if(request->method() == HTTP_PUT) server.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request){
Serial.printf("PUT"); request->send(200, "text/plain", String(ESP.getFreeHeap()));
else if(request->method() == HTTP_PATCH) });
Serial.printf("PATCH");
else if(request->method() == HTTP_HEAD) server.serveStatic("/", MYFS, "/").setDefaultFile("index.htm");
Serial.printf("HEAD");
else if(request->method() == HTTP_OPTIONS) server.onNotFound([](AsyncWebServerRequest *request){
Serial.printf("OPTIONS"); Serial.printf("NOT_FOUND: ");
else if(request->method() == HTTP_GET)
Serial.printf("UNKNOWN"); Serial.printf("GET");
Serial.printf(" http://%s%s\n", request->host().c_str(), request->url().c_str()); else if(request->method() == HTTP_POST)
Serial.printf("POST");
if(request->contentLength()){ else if(request->method() == HTTP_DELETE)
Serial.printf("_CONTENT_TYPE: %s\n", request->contentType().c_str()); Serial.printf("DELETE");
Serial.printf("_CONTENT_LENGTH: %u\n", request->contentLength()); else if(request->method() == HTTP_PUT)
} Serial.printf("PUT");
else if(request->method() == HTTP_PATCH)
int headers = request->headers(); Serial.printf("PATCH");
int i; else if(request->method() == HTTP_HEAD)
for(i=0;i<headers;i++){ Serial.printf("HEAD");
AsyncWebHeader* h = request->getHeader(i); else if(request->method() == HTTP_OPTIONS)
Serial.printf("_HEADER[%s]: %s\n", h->name().c_str(), h->value().c_str()); Serial.printf("OPTIONS");
} else
Serial.printf("UNKNOWN");
int params = request->params(); Serial.printf(" http://%s%s\n", request->host().c_str(), request->url().c_str());
for(i=0;i<params;i++){
AsyncWebParameter* p = request->getParam(i); if(request->contentLength()){
if(p->isFile()){ Serial.printf("_CONTENT_TYPE: %s\n", request->contentType().c_str());
Serial.printf("_FILE[%s]: %s, size: %u\n", p->name().c_str(), p->value().c_str(), p->size()); Serial.printf("_CONTENT_LENGTH: %u\n", request->contentLength());
} else if(p->isPost()){ }
Serial.printf("_POST[%s]: %s\n", p->name().c_str(), p->value().c_str());
} else { int headers = request->headers();
Serial.printf("_GET[%s]: %s\n", p->name().c_str(), p->value().c_str()); int i;
} for(i=0;i<headers;i++){
} AsyncWebHeader* h = request->getHeader(i);
Serial.printf("_HEADER[%s]: %s\n", h->name().c_str(), h->value().c_str());
request->send(404); }
});
server.onFileUpload([](AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, size_t len, bool final){ int params = request->params();
if(!index) for(i=0;i<params;i++){
Serial.printf("UploadStart: %s\n", filename.c_str()); AsyncWebParameter* p = request->getParam(i);
Serial.printf("%s", (const char*)data); if(p->isFile()){
if(final) Serial.printf("_FILE[%s]: %s, size: %u\n", p->name().c_str(), p->value().c_str(), p->size());
Serial.printf("UploadEnd: %s (%u)\n", filename.c_str(), index+len); } else if(p->isPost()){
}); Serial.printf("_POST[%s]: %s\n", p->name().c_str(), p->value().c_str());
server.onRequestBody([](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total){ } else {
if(!index) Serial.printf("_GET[%s]: %s\n", p->name().c_str(), p->value().c_str());
Serial.printf("BodyStart: %u\n", total); }
Serial.printf("%s", (const char*)data); }
if(index + len == total)
Serial.printf("BodyEnd: %u\n", total); request->send(404);
}); });
server.begin(); server.onFileUpload([](AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, size_t len, bool final){
} if(!index)
Serial.printf("UploadStart: %s\n", filename.c_str());
void loop(){ Serial.printf("%s", (const char*)data);
ArduinoOTA.handle(); if(final)
ws.cleanupClients(); Serial.printf("UploadEnd: %s (%u)\n", filename.c_str(), index+len);
} });
server.onRequestBody([](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total){
if(!index)
Serial.printf("BodyStart: %u\n", total);
Serial.printf("%s", (const char*)data);
if(index + len == total)
Serial.printf("BodyEnd: %u\n", total);
});
server.begin();
}
void loop(){
ArduinoOTA.handle();
ws.cleanupClients();
}

View File

@@ -13,7 +13,12 @@ Multiple clients can be connected at same time, they see each other requests
Use latest ESP core lib (from Github) Use latest ESP core lib (from Github)
*/ */
// Defaulut is SPIFFS, FatFS: only on ESP32
// Comment 2 lines below or uncomment only one of them
#define USE_LittleFS #define USE_LittleFS
//#define USE_FatFS // select partition scheme w/ ffat!
#define USE_WFM // to use ESPAsyncWiFiManager #define USE_WFM // to use ESPAsyncWiFiManager
//#define DEL_WFM // delete Wifi credentials stored //#define DEL_WFM // delete Wifi credentials stored
@@ -42,10 +47,17 @@ Use latest ESP core lib (from Github)
#ifdef ESP32 #ifdef ESP32
#include <FS.h> #include <FS.h>
#ifdef USE_LittleFS #ifdef USE_LittleFS
#define SPIFFS LITTLEFS #define HSTNM "ssw32-littlefs"
#include <LITTLEFS.h> #define MYFS LITTLEFS
#include "LITTLEFS.h"
#elif defined(USE_FatFS)
#define HSTNM "ssw32-ffat"
#define MYFS FFat
#include "FFat.h"
#else #else
#define MYFS SPIFFS
#include <SPIFFS.h> #include <SPIFFS.h>
#define HSTNM "ssw32-spiffs"
#endif #endif
#include <ESPmDNS.h> #include <ESPmDNS.h>
#include <WiFi.h> #include <WiFi.h>
@@ -53,8 +65,14 @@ Use latest ESP core lib (from Github)
#elif defined(ESP8266) #elif defined(ESP8266)
#ifdef USE_LittleFS #ifdef USE_LittleFS
#include <FS.h> #include <FS.h>
#define SPIFFS LittleFS #define HSTNM "ssw8266-littlefs"
#define MYFS LittleFS
#include <LittleFS.h> #include <LittleFS.h>
#elif defined(USE_FatFS)
#error "FatFS only on ESP32 for now!"
#else
#define HSTNM "ssw8266-spiffs"
#define MYFS SPIFFS
#endif #endif
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h> #include <ESPAsyncTCP.h>
@@ -120,7 +138,7 @@ AsyncWebSocket ws("/ws");
const char* password = "MYROUTERPASSWD"; const char* password = "MYROUTERPASSWD";
#endif #endif
const char* hostName = "smartsw"; const char* hostName = HSTNM;
// RTC // RTC
static timeval tv; static timeval tv;
@@ -532,7 +550,7 @@ void setup(){
Serial.printf("Temp set %+2.1f\n", ee.tempe); Serial.printf("Temp set %+2.1f\n", ee.tempe);
//FS //FS
if (SPIFFS.begin()) { if (MYFS.begin()) {
Serial.print(F("FS mounted\n")); Serial.print(F("FS mounted\n"));
} else { } else {
Serial.print(F("FS mount failed\n")); Serial.print(F("FS mount failed\n"));
@@ -551,19 +569,19 @@ void setup(){
#ifdef ESP32 #ifdef ESP32
#ifdef USE_AUTH_STAT #ifdef USE_AUTH_STAT
server.addHandler(new SPIFFSEditor(SPIFFS, http_username,http_password)); server.addHandler(new SPIFFSEditor(MYFS, http_username,http_password));
#elif defined(USE_AUTH_COOKIE) #elif defined(USE_AUTH_COOKIE)
server.addHandler(new SPIFFSEditor(SPIFFS)).setFilter(myHandshake); server.addHandler(new SPIFFSEditor(MYFS)).setFilter(myHandshake);
#else #else
server.addHandler(new SPIFFSEditor(SPIFFS)); server.addHandler(new SPIFFSEditor(MYFS));
#endif #endif
#elif defined(ESP8266) #elif defined(ESP8266)
#ifdef USE_AUTH_STAT #ifdef USE_AUTH_STAT
server.addHandler(new SPIFFSEditor(http_username,http_password)); server.addHandler(new SPIFFSEditor(http_username,http_password,MYFS));
#elif defined(USE_AUTH_COOKIE) #elif defined(USE_AUTH_COOKIE)
server.addHandler(new SPIFFSEditor()).setFilter(myHandshake); server.addHandler(new SPIFFSEditor("","",MYFS)).setFilter(myHandshake);
#else #else
server.addHandler(new SPIFFSEditor()); server.addHandler(new SPIFFSEditor("","",MYFS));
#endif #endif
#endif #endif
@@ -668,13 +686,13 @@ void setup(){
// above paths need individual auth //////////////////////////////////////////////// // above paths need individual auth ////////////////////////////////////////////////
#ifdef USE_AUTH_COOKIE #ifdef USE_AUTH_COOKIE
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm").setFilter(myHandshake); server.serveStatic("/", MYFS, "/").setDefaultFile("index.htm").setFilter(myHandshake);
server.serveStatic("/", SPIFFS, "/login/").setDefaultFile("index.htm"); server.serveStatic("/", MYFS, "/login/").setDefaultFile("index.htm");
#else #else
#ifdef USE_AUTH_STAT #ifdef USE_AUTH_STAT
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm").setAuthentication(http_username,http_password); server.serveStatic("/", MYFS, "/").setDefaultFile("index.htm").setAuthentication(http_username,http_password);
#else #else
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm"); server.serveStatic("/", MYFS, "/").setDefaultFile("index.htm");
#endif #endif
#endif #endif
@@ -694,7 +712,7 @@ void setup(){
ArduinoOTA.setHostname(hostName); ArduinoOTA.setHostname(hostName);
ArduinoOTA.onStart([]() { ArduinoOTA.onStart([]() {
Serial.print(F("OTA Started ...\n")); Serial.print(F("OTA Started ...\n"));
SPIFFS.end(); // Clean FS MYFS.end(); // Clean FS
ws.textAll("Now,OTA"); // for all clients ws.textAll("Now,OTA"); // for all clients
ws.enable(false); ws.enable(false);
ws.closeAll(); ws.closeAll();

View File

@@ -2,7 +2,7 @@
//File: edit.htm.gz, Size: 4503 //File: edit.htm.gz, Size: 4503
#define edit_htm_gz_len 4503 #define edit_htm_gz_len 4503
const uint8_t edit_htm_gz[] PROGMEM = { const uint8_t edit_htm_gz[] PROGMEM = {
0x1F,0x8B,0x08,0x08,0x0F,0x7A,0xFF,0x5E,0x02,0x00,0x65,0x64,0x69,0x74,0x2E,0x68,0x74,0x6D,0x00,0xB5, 0x1F,0x8B,0x08,0x08,0x1C,0xAD,0x07,0x5F,0x02,0x00,0x65,0x64,0x69,0x74,0x2E,0x68,0x74,0x6D,0x00,0xB5,
0x1A,0x0B,0x5B,0xDB,0x36,0xF0,0xAF,0x18,0x6F,0x63,0xF6,0xE2,0x38,0x0E,0x50,0xD6,0x3A,0x18,0x16,0x1E, 0x1A,0x0B,0x5B,0xDB,0x36,0xF0,0xAF,0x18,0x6F,0x63,0xF6,0xE2,0x38,0x0E,0x50,0xD6,0x3A,0x18,0x16,0x1E,
0xEB,0xBB,0x50,0x12,0xDA,0xD1,0x8E,0xED,0x53,0x6C,0x25,0x56,0xB1,0x25,0xCF,0x96,0x09,0x34,0xCD,0x7F, 0xEB,0xBB,0x50,0x12,0xDA,0xD1,0x8E,0xED,0x53,0x6C,0x25,0x56,0xB1,0x25,0xCF,0x96,0x09,0x34,0xCD,0x7F,
0xDF,0x49,0xF2,0x93,0x84,0xEE,0xF1,0x6D,0xA5,0x60,0x49,0xA7,0x3B,0xDD,0x9D,0xEE,0x25,0xD9,0x7B,0x1B, 0xDF,0x49,0xF2,0x93,0x84,0xEE,0xF1,0x6D,0xA5,0x60,0x49,0xA7,0x3B,0xDD,0x9D,0xEE,0x25,0xD9,0x7B,0x1B,