implemented /wifi/scan

develop
Kenneth Barbour 2020-06-30 21:20:32 -04:00
parent c6840bc3a2
commit b8830d6c93
1 changed files with 7 additions and 1 deletions

View File

@ -97,7 +97,13 @@ void handle_weather_current(HttpRequest& req, HttpResponse& res)
// Handle WiFi Scan
void handle_wifi_scan(HttpRequest& req, HttpResponse& res)
{
res.code = 501;
int n = WiFi.scanNetworks();
res.headers.set("Content-Type","application/json");
content.print("{\"networks\":[");
for (int i = 0; i < n; i++) {
content.printf("%s{\"ssid\":\"%s\", \"rssi\":%d}", i==0 ? "" : ",", WiFi.SSID(i).c_str() , WiFi.RSSI(i));
}
content.print("]}");
}
// Handle WiFi Connect/Disconnect/Status