Skip to content

Commit e47254c

Browse files
committed
WiFi: scan Networks only if security type is unknown
1 parent f44a0aa commit e47254c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Diff for: libraries/WiFi/src/WiFi.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@ int arduino::WiFiClass::begin(const char* ssid, const char* passphrase, wl_enc_t
5353

5454
wifi_if->attach(&arduino::WiFiClass::statusCallback);
5555

56-
scanNetworks();
57-
58-
if (isVisible(ssid)) {
59-
// Set the network security mode from the scan result.
60-
_security = ap_list[connected_ap].get_security();
61-
} else {
62-
// For hidden networks, the security mode must be set explicitly.
63-
// if ENC_TYPE_UNKNOWN this means that is the default value and so the user
64-
// has not set it... no worth trying, it is probably an unknown (not hidden)
65-
// interface
66-
if(security == ENC_TYPE_UNKNOWN) {
56+
if(security == ENC_TYPE_UNKNOWN) {
57+
scanNetworks();
58+
if (isVisible(ssid)) {
59+
// Set the network security mode from the scan result.
60+
_security = ap_list[connected_ap].get_security();
61+
} else {
62+
// For hidden networks, the security mode must be set explicitly.
63+
// if ENC_TYPE_UNKNOWN this means that is the default value and so the user
64+
// has not set it... no worth trying, it is probably an unknown (not hidden)
65+
// interface
6766
_currentNetworkStatus = WL_CONNECT_FAILED;
6867
return _currentNetworkStatus;
6968
}
69+
} else {
7070
_security = enum2sec(security);
7171
}
7272

0 commit comments

Comments
 (0)