@@ -38,10 +38,6 @@ bool ESP8266WiFiMulti::addAP(const char* ssid, const char *passphrase) {
38
38
return APlistAdd (ssid, passphrase);
39
39
}
40
40
41
- int ESP8266WiFiMulti::count (void ) {
42
- return APlist.size ();
43
- }
44
-
45
41
wl_status_t ESP8266WiFiMulti::run (void ) {
46
42
47
43
wl_status_t status = WiFi.status ();
@@ -71,7 +67,7 @@ wl_status_t ESP8266WiFiMulti::run(void) {
71
67
72
68
if (scanResult > 0 ) {
73
69
// scan done, analyze
74
- WifiAPlist_t bestNetwork { NULL , NULL };
70
+ WifiAPEntry bestNetwork { NULL , NULL };
75
71
int bestNetworkDb = INT_MIN;
76
72
uint8 bestBSSID[6 ];
77
73
int32_t bestChannel;
@@ -92,16 +88,14 @@ wl_status_t ESP8266WiFiMulti::run(void) {
92
88
WiFi.getNetworkInfo (i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan);
93
89
94
90
bool known = false ;
95
- for (uint32_t x = 0 ; x < APlist.size (); x++) {
96
- WifiAPlist_t entry = APlist[x];
97
-
91
+ for (auto entry : APlist) {
98
92
if (ssid_scan == entry.ssid ) { // SSID match
99
93
known = true ;
100
94
if (rssi_scan > bestNetworkDb) { // best network
101
95
if (sec_scan == ENC_TYPE_NONE || entry.passphrase ) { // check for passphrase if not open wlan
102
96
bestNetworkDb = rssi_scan;
103
97
bestChannel = chan_scan;
104
- memcpy (( void *) & bestNetwork, ( void *) & entry, sizeof (bestNetwork)) ;
98
+ bestNetwork = entry;
105
99
memcpy ((void *) &bestBSSID, (void *) BSSID_scan, sizeof (bestBSSID));
106
100
}
107
101
}
@@ -183,15 +177,16 @@ wl_status_t ESP8266WiFiMulti::run(void) {
183
177
184
178
bool ESP8266WiFiMulti::APlistAdd (const char * ssid, const char *passphrase) {
185
179
186
- WifiAPlist_t newAP;
180
+ WifiAPEntry newAP;
187
181
188
182
if (!ssid || *ssid == 0x00 || strlen (ssid) > 31 ) {
189
183
// fail SSID to long or missing!
190
184
DEBUG_WIFI_MULTI (" [WIFI][APlistAdd] no ssid or ssid to long\n " );
191
185
return false ;
192
186
}
193
187
194
- if (passphrase && strlen (passphrase) > 63 ) {
188
+ // for passphrase, max is 63 ascii + null. For psk, 64hex + null.
189
+ if (passphrase && strlen (passphrase) > 64 ) {
195
190
// fail passphrase to long!
196
191
DEBUG_WIFI_MULTI (" [WIFI][APlistAdd] passphrase to long\n " );
197
192
return false ;
@@ -222,8 +217,7 @@ bool ESP8266WiFiMulti::APlistAdd(const char* ssid, const char *passphrase) {
222
217
}
223
218
224
219
void ESP8266WiFiMulti::APlistClean (void ) {
225
- for (uint32_t i = 0 ; i < APlist.size (); i++) {
226
- WifiAPlist_t entry = APlist[i];
220
+ for (auto entry : APlist) {
227
221
if (entry.ssid ) {
228
222
free (entry.ssid );
229
223
}
0 commit comments