Skip to content

Commit 75f653e

Browse files
committed
Only stop AP when not restarting
1 parent 9188d7e commit 75f653e

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

examples/NonBlockingCaptivePortal/NonBlockingCaptivePortal.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ void setup() {
5959
});
6060

6161
espConnect.setConnectTimeout(20); // 20 seconds
62-
espConnect.setCaptivePortalTimeout(30); // 30 seconds
63-
espConnect.setAutoRestart(false);
62+
espConnect.setCaptivePortalTimeout(40); // 30 seconds
63+
espConnect.setAutoRestart(true);
6464
espConnect.setBlocking(false);
6565

6666
Serial.println("====> Trying to connect to saved WiFi or will start portal in the background...");

src/MycilaESPConnect.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,12 @@ void Mycila::ESPConnect::loop() {
402402

403403
if (_state == Mycila::ESPConnect::State::PORTAL_TIMEOUT) {
404404
LOGW(TAG, "Portal timeout!");
405-
_stopAP();
406405
if (_autoRestart) {
407406
LOGW(TAG, "Restarting ESP...");
408407
ESP.restart();
409408
} else {
410409
// try to reconnect again with configured settings
410+
_stopAP();
411411
_setState(Mycila::ESPConnect::State::NETWORK_ENABLED);
412412
}
413413
}
@@ -420,7 +420,6 @@ void Mycila::ESPConnect::loop() {
420420
} else if (millis() - _restartRequestTime >= _restartDelay) {
421421
// delay is over restart
422422
LOGW(TAG, "Auto Restart of ESP...");
423-
_stopAP();
424423
ESP.restart();
425424
}
426425
} else {

0 commit comments

Comments
 (0)