implemented /wifi/scan
parent
c6840bc3a2
commit
b8830d6c93
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue