Skip to content

Commit 2a92205

Browse files
committed
fix for UDP endPacket failing after an attempt to connect to an non existent WiFi network
1 parent 931f0bb commit 2a92205

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ int arduino::WiFiClass::begin(const char* ssid, const char* passphrase, wl_enc_t
6060
_security = ap_list[connected_ap].get_security();
6161
} else {
6262
// 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) {
67+
_currentNetworkStatus = WL_CONNECT_FAILED;
68+
return _currentNetworkStatus;
69+
}
6370
_security = enum2sec(security);
6471
}
6572

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class WiFiClass : public MbedSocketClass {
7474
* param passphrase: Passphrase. Valid characters in a passphrase
7575
* must be between ASCII 32-126 (decimal).
7676
*/
77-
int begin(const char* ssid, const char* passphrase, wl_enc_type security = ENC_TYPE_CCMP);
77+
int begin(const char* ssid, const char* passphrase, wl_enc_type security = ENC_TYPE_UNKNOWN);
7878

7979
// Inherit config methods from the parent class
8080
using MbedSocketClass::config;

0 commit comments

Comments
 (0)