Skip to content

Commit 21f893a

Browse files
committed
Remove scan print sort in favour of BSSID/RSSI/Channel (airlift)
1 parent 4d4dea2 commit 21f893a

File tree

1 file changed

+11
-38
lines changed

1 file changed

+11
-38
lines changed

src/network_interfaces/Wippersnapper_AIRLIFT.h

+11-38
Original file line numberDiff line numberDiff line change
@@ -143,45 +143,14 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
143143
return false;
144144
}
145145

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;
166147

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!");
183148
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+
}
185154
WS_DEBUG_PRINT(WiFi.SSID(i));
186155
WS_DEBUG_PRINT(" (");
187156
uint8_t BSSID[WL_MAC_ADDR_LENGTH];
@@ -198,7 +167,11 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
198167
WS_DEBUG_PRINTLN(")");
199168
}
200169

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;
202175
}
203176

204177
/********************************************************/

0 commit comments

Comments
 (0)