Skip to content

Commit 8cbd9cf

Browse files
authored
Merge pull request #237 from pennam/wifi-begin-fix
wifi: fix race condition waiting for connect result
2 parents 661a316 + 889e4f9 commit 8cbd9cf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libraries/WiFi/src/WiFi.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ int WiFiClass::begin(const char *ssid, const char *passphrase, wl_enc_type secur
2828
if (ret) {
2929
return false;
3030
}
31-
NetworkInterface::begin(false, NET_EVENT_WIFI_MASK);
32-
if (blocking) {
31+
32+
ret = status();
33+
if (ret != WL_CONNECTED && blocking) {
3334
net_mgmt_event_wait_on_iface(sta_iface, NET_EVENT_WIFI_CONNECT_RESULT, NULL, NULL, NULL,
3435
K_FOREVER);
3536
}
37+
NetworkInterface::begin(blocking, NET_EVENT_WIFI_MASK);
3638
return status();
3739
}
3840

0 commit comments

Comments
 (0)