File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 5454#define WIFI_CLIENT_RETRY_TIMEOUT (5 * 60 * 1000)
5555#endif
5656
57+ #ifndef WIFI_CLIENT_DISCONNECTS_BEFORE_AP
58+ #define WIFI_CLIENT_DISCONNECTS_BEFORE_AP 2
59+ #endif
60+
5761// Used to change the ADC channel used for seeding the rndom number generator
5862// Should be set to an unconnected pin
5963#ifndef RANDOM_SEED_CHANNEL
Original file line number Diff line number Diff line change @@ -214,9 +214,11 @@ static void net_wifi_onStationModeDisconnected(const WiFiEventStationModeDisconn
214214
215215 client_disconnects++;
216216
217- if (net_wifi_mode_is_sta ()) {
218- startClient ();
219- }
217+ // Clear the WiFi state and tru to connect again
218+ WiFi.disconnect ();
219+ WiFi.mode (WIFI_OFF);
220+
221+ startClient ();
220222}
221223
222224static void net_wifi_onAPModeStationConnected (const WiFiEventSoftAPModeStationConnected &event) {
@@ -468,7 +470,7 @@ net_loop()
468470 if (isClientOnly && !WiFi.isConnected ())
469471 {
470472 // If we have failed to connect turn on the AP
471- if (client_disconnects > 2 ) {
473+ if (client_disconnects > WIFI_CLIENT_DISCONNECTS_BEFORE_AP ) {
472474 startAP ();
473475 client_retry = true ;
474476 client_retry_time = millis () + WIFI_CLIENT_RETRY_TIMEOUT;
@@ -478,8 +480,7 @@ net_loop()
478480 // Remain in AP mode for 5 Minutes before resetting
479481 if (isApOnly && 0 == apClients && client_retry && millis () > client_retry_time) {
480482 DEBUG.println (" client re-try, resetting" );
481- delay (50 );
482- ESPAL.reset ();
483+ net_wifi_restart ();
483484 }
484485
485486 if (dnsServerStarted) {
You can’t perform that action at this time.
0 commit comments