Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server.on("/scan", HTTP_GET, [](AsyncWebServerRequest *request){
- String json = "[";
- int n = WiFi.scanComplete();
- if(n == -2){
- WiFi.scanNetworks(true);
- } else if(n){
- for (int i = 0; i < n; ++i){
- if(i) json += ",";
- json += "{";
- json += "\"rssi\":"+String(WiFi.RSSI(i));
- json += ",\"ssid\":\""+WiFi.SSID(i)+"\"";
- json += ",\"bssid\":\""+WiFi.BSSIDstr(i)+"\"";
- json += ",\"channel\":"+String(WiFi.channel(i));
- json += ",\"secure\":"+String(WiFi.encryptionType(i));
- json += ",\"hidden\":"+String(WiFi.isHidden(i)?"true":"false");
- json += "}";
- }
- WiFi.scanDelete();
- if(WiFi.scanComplete() == -2){
- WiFi.scanNetworks(true);
- }
- }
- json += "]";
- request->send(200, "application/json", json);
- json = String();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement