mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-22 10:42:10 +10:00
new sort
This commit is contained in:
+12
-1
@@ -354,7 +354,7 @@ void WiFiManager::handleWifi(boolean scan) {
|
|||||||
page += F("No networks found. Refresh to scan again.");
|
page += F("No networks found. Refresh to scan again.");
|
||||||
} else {
|
} else {
|
||||||
//sort networks
|
//sort networks
|
||||||
int indices[n];
|
/*int indices[n];
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
indices[i] = i;
|
indices[i] = i;
|
||||||
@@ -370,7 +370,18 @@ void WiFiManager::handleWifi(boolean scan) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
int indices[n];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
indices[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(indices, indices+n, [](const int & a, const int & b) -> bool
|
||||||
|
{
|
||||||
|
return WiFi.RSSI(a) > WiFi.RSSI(b);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//display networks in page
|
//display networks in page
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
DEBUG_WM(WiFi.SSID(indices[i]));
|
DEBUG_WM(WiFi.SSID(indices[i]));
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
const char HTTP_200[] PROGMEM = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
|
const char HTTP_200[] PROGMEM = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user