mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2025-09-29 07:40:56 +02:00
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:
@@ -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
|
||||||
|
@@ -1,13 +1,20 @@
|
|||||||
#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
|
||||||
|
|
||||||
|
//#define USE_LittleFS
|
||||||
|
//#define USE_FatFS // Only ESP32
|
||||||
|
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#ifdef USE_LittleFS
|
#ifdef USE_LittleFS
|
||||||
#define SPIFFS LITTLEFS
|
#define MYFS LITTLEFS
|
||||||
#include <LITTLEFS.h>
|
#include "LITTLEFS.h"
|
||||||
|
#elif defined(USE_FatFS)
|
||||||
|
#define MYFS FFat
|
||||||
|
#include "FFat.h"
|
||||||
#else
|
#else
|
||||||
|
#define MYFS SPIFFS
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
@@ -15,17 +22,22 @@
|
|||||||
#include <AsyncTCP.h>
|
#include <AsyncTCP.h>
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
#ifdef USE_LittleFS
|
#ifdef USE_LittleFS
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#define SPIFFS LittleFS
|
#define MYFS LittleFS
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
|
#elif defined(USE_FatFS)
|
||||||
|
#error "FatFS only on ESP32 for now!"
|
||||||
|
#else
|
||||||
|
#define MYFS SPIFFS
|
||||||
#endif
|
#endif
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ESPAsyncTCP.h>
|
#include <ESPAsyncTCP.h>
|
||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <SPIFFSEditor.h>
|
#include <SPIFFSEditor.h>
|
||||||
|
|
||||||
|
|
||||||
// SKETCH BEGIN
|
// SKETCH BEGIN
|
||||||
AsyncWebServer server(80);
|
AsyncWebServer server(80);
|
||||||
AsyncWebSocket ws("/ws");
|
AsyncWebSocket ws("/ws");
|
||||||
@@ -103,10 +115,9 @@ void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* ssid = "*****";
|
||||||
const char* ssid = "*******";
|
const char* password = "*****";
|
||||||
const char* password = "*******";
|
const char* hostName = "esp-async";
|
||||||
const char * hostName = "esp-async";
|
|
||||||
const char* http_username = "admin";
|
const char* http_username = "admin";
|
||||||
const char* http_password = "admin";
|
const char* http_password = "admin";
|
||||||
|
|
||||||
@@ -123,6 +134,9 @@ void setup(){
|
|||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Serial.print(F("*CONNECTED* IP:"));
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
//Send OTA events to the browser
|
//Send OTA events to the browser
|
||||||
ArduinoOTA.onStart([]() { events.send("Update Start", "ota"); });
|
ArduinoOTA.onStart([]() { events.send("Update Start", "ota"); });
|
||||||
ArduinoOTA.onEnd([]() { events.send("Update End", "ota"); });
|
ArduinoOTA.onEnd([]() { events.send("Update End", "ota"); });
|
||||||
@@ -143,7 +157,7 @@ void setup(){
|
|||||||
|
|
||||||
MDNS.addService("http","tcp",80);
|
MDNS.addService("http","tcp",80);
|
||||||
|
|
||||||
SPIFFS.begin();
|
MYFS.begin();
|
||||||
|
|
||||||
ws.onEvent(onWsEvent);
|
ws.onEvent(onWsEvent);
|
||||||
server.addHandler(&ws);
|
server.addHandler(&ws);
|
||||||
@@ -154,16 +168,16 @@ void setup(){
|
|||||||
server.addHandler(&events);
|
server.addHandler(&events);
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
server.addHandler(new SPIFFSEditor(SPIFFS, http_username,http_password));
|
server.addHandler(new SPIFFSEditor(MYFS, http_username,http_password));
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
server.addHandler(new SPIFFSEditor(http_username,http_password));
|
server.addHandler(new SPIFFSEditor(http_username,http_password, MYFS));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
server.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request){
|
server.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
request->send(200, "text/plain", String(ESP.getFreeHeap()));
|
request->send(200, "text/plain", String(ESP.getFreeHeap()));
|
||||||
});
|
});
|
||||||
|
|
||||||
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm");
|
server.serveStatic("/", MYFS, "/").setDefaultFile("index.htm");
|
||||||
|
|
||||||
server.onNotFound([](AsyncWebServerRequest *request){
|
server.onNotFound([](AsyncWebServerRequest *request){
|
||||||
Serial.printf("NOT_FOUND: ");
|
Serial.printf("NOT_FOUND: ");
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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();
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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,
|
||||||
|
Reference in New Issue
Block a user