diff --git a/examples/CaptivePortal/CaptivePortal.ino b/examples/CaptivePortal/CaptivePortal.ino index 2d0de89..2cc5851 100644 --- a/examples/CaptivePortal/CaptivePortal.ino +++ b/examples/CaptivePortal/CaptivePortal.ino @@ -29,7 +29,9 @@ class CaptiveRequestHandler : public AsyncWebHandler { response->print("
This is out captive portal front page.
"); response->printf("You were trying to reach: http://%s%s
", request->host().c_str(), request->url().c_str()); +#ifndef CONFIG_IDF_TARGET_ESP32H2 response->printf("Try opening this link instead
", WiFi.softAPIP().toString().c_str()); +#endif response->print(""); request->send(response); } @@ -40,6 +42,7 @@ void setup() { Serial.println(); Serial.println("Configuring access point..."); +#ifndef CONFIG_IDF_TARGET_ESP32H2 if (!WiFi.softAP("esp-captive")) { Serial.println("Soft AP creation failed."); while (1) @@ -47,6 +50,8 @@ void setup() { } dnsServer.start(53, "*", WiFi.softAPIP()); +#endif + server.addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER); // only when requested from AP // more handlers... server.begin(); diff --git a/examples/Filters/Filters.ino b/examples/Filters/Filters.ino index f031a1f..b7bbcff 100644 --- a/examples/Filters/Filters.ino +++ b/examples/Filters/Filters.ino @@ -31,7 +31,9 @@ class CaptiveRequestHandler : public AsyncWebHandler { response->print("This is out captive portal front page.
"); response->printf("You were trying to reach: http://%s%s
", request->host().c_str(), request->url().c_str()); +#ifndef CONFIG_IDF_TARGET_ESP32H2 response->printf("Try opening this link instead
", WiFi.softAPIP().toString().c_str()); +#endif response->print(""); request->send(response); } @@ -46,15 +48,21 @@ void setup() { server .on("/", HTTP_GET, [](AsyncWebServerRequest* request) { Serial.println("Captive portal request..."); +#ifndef CONFIG_IDF_TARGET_ESP32H2 Serial.println("WiFi.localIP(): " + WiFi.localIP().toString()); +#endif Serial.println("request->client()->localIP(): " + request->client()->localIP().toString()); #if ESP_IDF_VERSION_MAJOR >= 5 + #ifndef CONFIG_IDF_TARGET_ESP32H2 Serial.println("WiFi.type(): " + String((int)WiFi.localIP().type())); + #endif Serial.println("request->client()->type(): " + String((int)request->client()->localIP().type())); #endif +#ifndef CONFIG_IDF_TARGET_ESP32H2 Serial.println(WiFi.localIP() == request->client()->localIP() ? "should be: ON_STA_FILTER" : "should be: ON_AP_FILTER"); Serial.println(WiFi.localIP() == request->client()->localIP()); Serial.println(WiFi.localIP().toString() == request->client()->localIP().toString()); +#endif request->send(200, "text/plain", "This is the captive portal"); hit1 = true; }) @@ -63,15 +71,21 @@ void setup() { server .on("/", HTTP_GET, [](AsyncWebServerRequest* request) { Serial.println("Website request..."); +#ifndef CONFIG_IDF_TARGET_ESP32H2 Serial.println("WiFi.localIP(): " + WiFi.localIP().toString()); +#endif Serial.println("request->client()->localIP(): " + request->client()->localIP().toString()); #if ESP_IDF_VERSION_MAJOR >= 5 + #ifndef CONFIG_IDF_TARGET_ESP32H2 Serial.println("WiFi.type(): " + String((int)WiFi.localIP().type())); + #endif Serial.println("request->client()->type(): " + String((int)request->client()->localIP().type())); #endif +#ifndef CONFIG_IDF_TARGET_ESP32H2 Serial.println(WiFi.localIP() == request->client()->localIP() ? "should be: ON_STA_FILTER" : "should be: ON_AP_FILTER"); Serial.println(WiFi.localIP() == request->client()->localIP()); Serial.println(WiFi.localIP().toString() == request->client()->localIP().toString()); +#endif request->send(200, "text/plain", "This is the website"); hit2 = true; }) @@ -92,12 +106,15 @@ void setup() { // dnsServer.stop(); // WiFi.softAPdisconnect(); +#ifndef CONFIG_IDF_TARGET_ESP32H2 WiFi.persistent(false); WiFi.begin("IoT"); while (WiFi.status() != WL_CONNECTED) { delay(500); } Serial.println("Connected to WiFi with IP address: " + WiFi.localIP().toString()); +#endif + server.begin(); // while (!hit2) { diff --git a/examples/SimpleServer/SimpleServer.ino b/examples/SimpleServer/SimpleServer.ino index f3a1605..081541c 100644 --- a/examples/SimpleServer/SimpleServer.ino +++ b/examples/SimpleServer/SimpleServer.ino @@ -38,6 +38,7 @@ 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) { @@ -49,6 +50,7 @@ void setup() { WiFi.mode(WIFI_AP); WiFi.softAP("esp-captive"); +#endif server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) { request->send(200, "text/plain", "Hello, world"); diff --git a/examples/StreamFiles/StreamFiles.ino b/examples/StreamFiles/StreamFiles.ino index 2a2c1b6..508298d 100644 --- a/examples/StreamFiles/StreamFiles.ino +++ b/examples/StreamFiles/StreamFiles.ino @@ -23,9 +23,12 @@ void setup() { LittleFS.begin(); +#ifndef CONFIG_IDF_TARGET_ESP32H2 WiFi.mode(WIFI_AP); WiFi.softAP("esp-captive"); + dnsServer.start(53, "*", WiFi.softAPIP()); +#endif File file1 = LittleFS.open("/header.html", "w"); file1.print("