Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WiFi: scan Networks only if security type is unknown
  • Loading branch information
pennam committed Oct 22, 2024
commit e47254c422cbbb28cdee4f8ed89768adcc70d0bf
22 changes: 11 additions & 11 deletions libraries/WiFi/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ int arduino::WiFiClass::begin(const char* ssid, const char* passphrase, wl_enc_t

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

scanNetworks();

if (isVisible(ssid)) {
// Set the network security mode from the scan result.
_security = ap_list[connected_ap].get_security();
} else {
// For hidden networks, the security mode must be set explicitly.
// if ENC_TYPE_UNKNOWN this means that is the default value and so the user
// has not set it... no worth trying, it is probably an unknown (not hidden)
// interface
if(security == ENC_TYPE_UNKNOWN) {
if(security == ENC_TYPE_UNKNOWN) {
scanNetworks();
if (isVisible(ssid)) {
// Set the network security mode from the scan result.
_security = ap_list[connected_ap].get_security();
} else {
// For hidden networks, the security mode must be set explicitly.
// if ENC_TYPE_UNKNOWN this means that is the default value and so the user
// has not set it... no worth trying, it is probably an unknown (not hidden)
// interface
_currentNetworkStatus = WL_CONNECT_FAILED;
return _currentNetworkStatus;
}
} else {
_security = enum2sec(security);
}

Expand Down