File tree 1 file changed +16
-5
lines changed
1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 23
23
24
24
#ifdef BOARD_HAS_WIFI /* Only compile if the board has WiFi */
25
25
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
+
26
35
/* *****************************************************************************
27
36
CTOR/DTOR
28
37
******************************************************************************/
@@ -93,12 +102,14 @@ NetworkConnectionState WiFiConnectionHandler::update_handleConnecting()
93
102
if (WiFi.status () != WL_CONNECTED)
94
103
{
95
104
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
+ }
101
111
#endif
112
+
102
113
}
103
114
104
115
if (WiFi.status () != NETWORK_CONNECTED)
You can’t perform that action at this time.
0 commit comments