Browse Source
Wifi getAvailNetworks sort by RSSI signal strength
pull/372/head
Sven Naumann
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
9 additions and
2 deletions
-
tools/esp8266/ahoywifi.cpp
|
|
@ -223,9 +223,16 @@ void ahoywifi::getAvailNetworks(JsonObject obj) { |
|
|
|
|
|
|
|
int n = WiFi.scanComplete(); |
|
|
|
if(n > 0) { |
|
|
|
int sort[n]; |
|
|
|
for (int i = 0; i < n; i++) |
|
|
|
sort[i] = i; |
|
|
|
for (int i = 0; i < n; i++) |
|
|
|
for (int j = i + 1; j < n; j++) |
|
|
|
if (WiFi.RSSI(sort[j]) > WiFi.RSSI(sort[i])) |
|
|
|
std::swap(sort[i], sort[j]); |
|
|
|
for (int i = 0; i < n; ++i) { |
|
|
|
nets[i]["ssid"] = WiFi.SSID(i); |
|
|
|
nets[i]["rssi"] = WiFi.RSSI(i); |
|
|
|
nets[i]["ssid"] = WiFi.SSID(sort[i]); |
|
|
|
nets[i]["rssi"] = WiFi.RSSI(sort[i]); |
|
|
|
} |
|
|
|
WiFi.scanDelete(); |
|
|
|
} |
|
|
|