Skip to content

Commit

Permalink
Fix handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Aug 8, 2024
1 parent 38caffe commit fb18369
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
9 changes: 4 additions & 5 deletions examples/AdvancedCaptivePortal/AdvancedCaptivePortal.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down
11 changes: 4 additions & 7 deletions examples/NonBlockingCaptivePortal/NonBlockingCaptivePortal.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,17 @@ 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;

case ESPConnectState::NETWORK_DISCONNECTED:
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;
}
Expand Down

0 comments on commit fb18369

Please sign in to comment.