11#include " WiFi.h"
22
3- bool arduino::WiFiClass::isVisible (char * ssid) {
3+ bool arduino::WiFiClass::isVisible (const char * ssid) {
44 for (int i=0 ; i<10 ; i++) {
55 if (strncmp (ap_list[i].get_ssid (), ssid, 32 ) == 0 ) {
66 connected_ap = i;
@@ -15,7 +15,7 @@ arduino::IPAddress arduino::WiFiClass::ipAddressFromSocketAddress(SocketAddress
1515 return IPAddress (address.bytes [0 ], address.bytes [1 ], address.bytes [2 ], address.bytes [3 ]);
1616}
1717
18- int arduino::WiFiClass::begin (char * ssid, const char *passphrase) {
18+ int arduino::WiFiClass::begin (const char * ssid, const char *passphrase) {
1919 if (_ssid) free (_ssid);
2020
2121 _ssid = (char *)malloc (33 );
@@ -30,18 +30,18 @@ int arduino::WiFiClass::begin(char* ssid, const char *passphrase) {
3030 if (wifi_if == nullptr ) return WL_CONNECT_FAILED;
3131 }
3232
33- // too long? break it off
34- if (strlen (ssid) > 32 ) ssid[32 ] = 0 ;
3533 memcpy (_ssid, ssid, 33 );
34+ // too long? break it off
35+ if (strlen (ssid) > 32 ) _ssid[32 ] = 0 ;
3636
3737 scanNetworks ();
3838 // use scan result to populate security field
39- if (!isVisible (ssid )) {
39+ if (!isVisible (_ssid )) {
4040 _currentNetworkStatus = WL_CONNECT_FAILED;
4141 return _currentNetworkStatus;
4242 }
4343
44- nsapi_error_t ret = wifi_if->connect (ssid , passphrase, ap_list[connected_ap].get_security ());
44+ nsapi_error_t ret = wifi_if->connect (_ssid , passphrase, ap_list[connected_ap].get_security ());
4545
4646 _currentNetworkStatus = ret == NSAPI_ERROR_OK ? WL_CONNECTED : WL_CONNECT_FAILED;
4747 return _currentNetworkStatus;
0 commit comments