diff --git a/examples/AdvancedCaptivePortal/AdvancedCaptivePortal.ino b/examples/AdvancedCaptivePortal/AdvancedCaptivePortal.ino index 3f62e05..7a0391c 100644 --- a/examples/AdvancedCaptivePortal/AdvancedCaptivePortal.ino +++ b/examples/AdvancedCaptivePortal/AdvancedCaptivePortal.ino @@ -37,6 +37,10 @@ void setup() { switch (state) { case ESPConnectState::NETWORK_CONNECTED: case ESPConnectState::AP_STARTED: + // serve your home page here + server.on("/", HTTP_GET, [&](AsyncWebServerRequest* request) { + return request->send(200, "text/plain", "Hello World!"); + }).setFilter([](__unused AsyncWebServerRequest* request) { return ESPConnect.getState() != ESPConnectState::PORTAL_STARTED; }); server.begin(); break; @@ -55,11 +59,6 @@ void setup() { preferences.putString("password", ESPConnect.getConfiguredWiFiPassword().c_str()); } preferences.end(); - - // serve your home page here - server.on("/", HTTP_GET, [&](AsyncWebServerRequest* request) { - return request->send(200, "text/plain", "Hello World!"); - }).setFilter([](__unused AsyncWebServerRequest* request) { return ESPConnect.getState() != ESPConnectState::PORTAL_STARTED; }); break; } diff --git a/examples/NonBlockingCaptivePortal/NonBlockingCaptivePortal.ino b/examples/NonBlockingCaptivePortal/NonBlockingCaptivePortal.ino index 32bf273..89f481f 100644 --- a/examples/NonBlockingCaptivePortal/NonBlockingCaptivePortal.ino +++ b/examples/NonBlockingCaptivePortal/NonBlockingCaptivePortal.ino @@ -41,6 +41,10 @@ void setup() { switch (state) { case ESPConnectState::NETWORK_CONNECTED: case ESPConnectState::AP_STARTED: + // serve your home page here + server.on("/", HTTP_GET, [&](AsyncWebServerRequest* request) { + return request->send(200, "text/plain", "Hello World!"); + }).setFilter([](__unused AsyncWebServerRequest* request) { return ESPConnect.getState() != ESPConnectState::PORTAL_STARTED; }); server.begin(); break; @@ -48,13 +52,6 @@ void setup() { server.end(); break; - case ESPConnectState::PORTAL_COMPLETE: - // serve your home page here - server.on("/", HTTP_GET, [&](AsyncWebServerRequest* request) { - return request->send(200, "text/plain", "Hello World!"); - }).setFilter([](__unused AsyncWebServerRequest* request) { return ESPConnect.getState() != ESPConnectState::PORTAL_STARTED; }); - break; - default: break; }