From 43f043d24eec0c573dc45d70318914126f466874 Mon Sep 17 00:00:00 2001 From: cotestatnt Date: Fri, 12 Jan 2024 18:38:46 +0100 Subject: [PATCH] withWebSocket.ino fix --- examples/csvLogger/csvLogger.ino | 1 - examples/withWebSocket/withWebSocket.ino | 19 +++---------------- src/AsyncFsWebServer.cpp | 4 +++- src/AsyncFsWebServer.h | 7 ------- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/examples/csvLogger/csvLogger.ino b/examples/csvLogger/csvLogger.ino index 36ee5a11..3a00e941 100644 --- a/examples/csvLogger/csvLogger.ino +++ b/examples/csvLogger/csvLogger.ino @@ -5,7 +5,6 @@ AsyncFsWebServer server(80, LittleFS, "myServer"); bool captiveRun = false; - // Timezone definition to get properly time from NTP server #define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3" #include diff --git a/examples/withWebSocket/withWebSocket.ino b/examples/withWebSocket/withWebSocket.ino index 8df531be..b1d82721 100644 --- a/examples/withWebSocket/withWebSocket.ino +++ b/examples/withWebSocket/withWebSocket.ino @@ -165,22 +165,6 @@ void setup() { Serial.begin(115200); delay(1000); - // Try to connect to stored SSID, start AP if fails after timeout - // IPAddress myIP = server.startWiFi(15000, "ESP_AP", "123456789"); - - WiFi.begin("iPhoneAP", "aat191ee"); - - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - - Serial.println(""); - Serial.println("WiFi connected"); - Serial.println("IP address: "); - Serial.println(WiFi.localIP()); - - // FILESYSTEM INIT if (startFilesystem()) { // Load configuration (if not present, default will be created when webserver will start) @@ -190,6 +174,9 @@ void setup() { Serial.println(F("Application options NOT loaded!")); } + // Try to connect to stored SSID, start AP if fails after timeout + IPAddress myIP = server.startWiFi(15000, "ESP_AP", "123456789"); + // Configure /setup page server.addOptionBox("My Options"); server.addOption("LED Pin", ledPin); diff --git a/src/AsyncFsWebServer.cpp b/src/AsyncFsWebServer.cpp index a823892f..ef42b16b 100644 --- a/src/AsyncFsWebServer.cpp +++ b/src/AsyncFsWebServer.cpp @@ -55,7 +55,9 @@ bool AsyncFsWebServer::init(AwsEventHandler wsHandle) { }); on("/get_config", HTTP_GET, [](AsyncWebServerRequest *request) { - request->send(200, "text/plain", CONFIG_FOLDER CONFIG_FILE); + // We need top remove the first "/" char + String name = CONFIG_FOLDER CONFIG_FILE; + request->send(200, "text/plain", name.substring(1)); }); onNotFound( std::bind(&AsyncFsWebServer::notFound, this, _1)); diff --git a/src/AsyncFsWebServer.h b/src/AsyncFsWebServer.h index 6d1c3c61..a1ef1948 100644 --- a/src/AsyncFsWebServer.h +++ b/src/AsyncFsWebServer.h @@ -82,12 +82,6 @@ class AsyncFsWebServer : public AsyncWebServer void setTaskWdt(uint32_t timeout); - /* - Add an option which contain "raw" HTML code to be injected in /setup page - Th HTML code will be written in a file with named as option id - */ - void addSource(const char* source, const char* tag, bool overWrite = false) ; - /* Create a dir if not exist on uploading files */ @@ -241,7 +235,6 @@ class AsyncFsWebServer : public AsyncWebServer ///////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////// BACKWARD COMPATIBILITY ONLY ///////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////// - bool optionToFile(const char* f, const char* id, bool ow) {return setup.optionToFile(f, id, ow);} void addHTML(const char* h, const char* id, bool ow = false) {setup.addHTML(h, id, ow);} void addCSS(const char* c, const char* id, bool ow = false){setup.addCSS(c, id, ow);} void addJavascript(const char* s, const char* id, bool ow = false) {setup.addJavascript(s, id, ow);}