File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 2323
2424#ifdef BOARD_HAS_WIFI /* Only compile if the board has WiFi */
2525
26+ /* *****************************************************************************
27+ CONSTANTS
28+ ******************************************************************************/
29+ #if defined(ARDUINO_ARCH_ESP8266)
30+ static int const ESP_WIFI_CONNECTION_TIMEOUT = 3000 ;
31+ #elif defined(ARDUINO_ARCH_ESP32)
32+ static int const ESP_WIFI_CONNECTION_TIMEOUT = 1000 ;
33+ #endif
34+
2635/* *****************************************************************************
2736 CTOR/DTOR
2837 ******************************************************************************/
@@ -93,12 +102,14 @@ NetworkConnectionState WiFiConnectionHandler::update_handleConnecting()
93102 if (WiFi.status () != WL_CONNECTED)
94103 {
95104 WiFi.begin (_ssid, _pass);
96- #if defined(ARDUINO_ARCH_ESP8266)
97- WiFi.waitForConnectResult ();
98- #endif
99- #if defined(ARDUINO_ARCH_ESP32)
100- WiFi.waitForConnectResult (1000 );
105+ #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
106+ /* Wait connection otherwise board won't connect */
107+ unsigned long start = millis ();
108+ while ((WiFi.status () != WL_CONNECTED) && (millis () - start) < ESP_WIFI_CONNECTION_TIMEOUT) {
109+ delay (100 );
110+ }
101111#endif
112+
102113 }
103114
104115 if (WiFi.status () != NETWORK_CONNECTED)
You can’t perform that action at this time.
0 commit comments