From 24cc3deba827316ef902d1dda02776f578f54027 Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Wed, 23 Oct 2024 10:48:54 +0200 Subject: [PATCH] update sample --- examples/SimpleServer/SimpleServer.ino | 33 +++++++++++++------------- platformio.ini | 4 ++-- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/examples/SimpleServer/SimpleServer.ino b/examples/SimpleServer/SimpleServer.ino index 2c934ea..dc30cfd 100644 --- a/examples/SimpleServer/SimpleServer.ino +++ b/examples/SimpleServer/SimpleServer.ino @@ -183,6 +183,20 @@ void setup() { Serial.begin(115200); +#ifndef CONFIG_IDF_TARGET_ESP32H2 + // WiFi.mode(WIFI_STA); + // WiFi.begin("YOUR_SSID", "YOUR_PASSWORD"); + // if (WiFi.waitForConnectResult() != WL_CONNECTED) { + // Serial.printf("WiFi Failed!\n"); + // return; + // } + // Serial.print("IP Address: "); + // Serial.println(WiFi.localIP()); + + WiFi.mode(WIFI_AP); + WiFi.softAP("esp-captive"); +#endif + #ifdef ESP32 LittleFS.begin(true); #else @@ -201,20 +215,6 @@ void setup() { } } -#ifndef CONFIG_IDF_TARGET_ESP32H2 - // WiFi.mode(WIFI_STA); - // WiFi.begin("YOUR_SSID", "YOUR_PASSWORD"); - // if (WiFi.waitForConnectResult() != WL_CONNECTED) { - // Serial.printf("WiFi Failed!\n"); - // return; - // } - // Serial.print("IP Address: "); - // Serial.println(WiFi.localIP()); - - WiFi.mode(WIFI_AP); - WiFi.softAP("esp-captive"); -#endif - // curl -v -X GET http://192.168.4.1/handler-not-sending-response server.on("/handler-not-sending-response", HTTP_GET, [](AsyncWebServerRequest* request) { // handler forgot to send a response to the client => 501 Not Implemented @@ -389,9 +389,8 @@ void setup() { request->send(200, "text/html", htmlContent); }); - server.on("/file", HTTP_GET, [](AsyncWebServerRequest* request) { - request->send(LittleFS, "/index.txt"); - }); + // curl -v -X GET http://192.168.4.1/index.txt + server.serveStatic("/index.txt", LittleFS, "/index.txt"); // Issue #14: assert failed: tcp_update_rcv_ann_wnd (needs help to test fix) // > curl -v http://192.168.4.1/issue-14 diff --git a/platformio.ini b/platformio.ini index 2fd60e7..046bf57 100644 --- a/platformio.ini +++ b/platformio.ini @@ -2,10 +2,10 @@ default_envs = arduino-2, arduino-3, arduino-310rc1, esp8266, raspberrypi lib_dir = . ; src_dir = examples/CaptivePortal -; src_dir = examples/SimpleServer +src_dir = examples/SimpleServer ; src_dir = examples/StreamFiles ; src_dir = examples/Filters -src_dir = examples/Issue85 +; src_dir = examples/Issue85 [env] framework = arduino