Skip to content

Commit 99dd1a4

Browse files
committed
Call waitForConnectResult after WiFi.begin()
- On ESP32 the call will block execution up to 1s - On ESP8266 the call will block execution up to 30s
1 parent 7d541f9 commit 99dd1a4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Arduino_WiFiConnectionHandler.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ NetworkConnectionState WiFiConnectionHandler::update_handleInit()
9090

9191
NetworkConnectionState WiFiConnectionHandler::update_handleConnecting()
9292
{
93-
#if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_ESP32)
9493
if (WiFi.status() != WL_CONNECTED)
9594
{
9695
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);
101+
#endif
97102
}
98-
#endif /* #if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_ESP32) */
99103

100104
if (WiFi.status() != NETWORK_CONNECTED)
101105
{

0 commit comments

Comments
 (0)