@@ -143,45 +143,14 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
143
143
return false ;
144
144
}
145
145
146
- WiFiNetwork networks[WS_MAX_SORTED_NETWORKS];
147
- uint8_t numSavedNetworks = 0 ;
148
-
149
- // Store the scanned networks in the array
150
- for (int i = 0 ; i < n; ++i) {
151
- if (i < WS_MAX_SORTED_NETWORKS) {
152
- strncpy (networks[i].ssid , WiFi.SSID (i), sizeof (networks[i].ssid ));
153
- networks[i].ssid [sizeof (networks[i].ssid ) - 1 ] = ' \0 ' ;
154
- networks[i].rssi = WiFi.RSSI (i);
155
- numSavedNetworks++;
156
- } else {
157
- WS_DEBUG_PRINT (" ERROR: Too many networks found! (>" );
158
- WS_DEBUG_PRINT (WS_MAX_SORTED_NETWORKS);
159
- WS_DEBUG_PRINT (" ) Ignoring " );
160
- WS_DEBUG_PRINT (WiFi.SSID (i));
161
- WS_DEBUG_PRINT (" (" );
162
- WS_DEBUG_PRINT (WiFi.RSSI (i));
163
- WS_DEBUG_PRINTLN (" )" );
164
- }
165
- }
146
+ bool foundNetwork = false ;
166
147
167
- // Sort the networks by RSSI in descending order
168
- std::sort (networks, networks + numSavedNetworks, compareByRSSI);
169
-
170
- // Was the network within secrets.json found?
171
- for (int i = 0 ; i < numSavedNetworks; ++i) {
172
- if (strcmp (_ssid, networks[i].ssid ) == 0 ) {
173
- WS_DEBUG_PRINT (" SSID (" );
174
- WS_DEBUG_PRINT (_ssid);
175
- WS_DEBUG_PRINT (" ) found! RSSI: " );
176
- WS_DEBUG_PRINTLN (networks[i].rssi );
177
- return true ;
178
- }
179
- }
180
-
181
- // User-set network not found, print scan results to serial console
182
- WS_DEBUG_PRINTLN (" ERROR: Your requested WiFi network was not found!" );
183
148
WS_DEBUG_PRINTLN (" WipperSnapper found these WiFi networks:" );
184
- for (uint8_t i = 0 ; i < n; ++i) {
149
+ for (uint8_t i = 0 ; i < n; i++) {
150
+ if (strcmp (WiFi.SSID (i), _ssid) == 0 ) {
151
+ foundNetwork = true ;
152
+ break ;
153
+ }
185
154
WS_DEBUG_PRINT (WiFi.SSID (i));
186
155
WS_DEBUG_PRINT (" (" );
187
156
uint8_t BSSID[WL_MAC_ADDR_LENGTH];
@@ -198,7 +167,11 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
198
167
WS_DEBUG_PRINTLN (" )" );
199
168
}
200
169
201
- return false ;
170
+ if (foundNetwork == 0 ) {
171
+ WS_DEBUG_PRINTLN (" ERROR: Your requested WiFi network was not found!" );
172
+ return false ;
173
+ }
174
+ return true ;
202
175
}
203
176
204
177
/* *******************************************************/
0 commit comments