Commit 02f06940 authored by PhiBo's avatar PhiBo 🚀

Improve ssid scan

parent 191c874c
......@@ -193,12 +193,12 @@ void handleScanSSID()
String ssid;
uint8_t first = 1;
// reserve some memory
data.reserve(600);
if (server->method() == HTTP_GET) {
query = server->arg("q");
int n = WiFi.scanNetworks();
if (n == 0) {
server->send(404, "text/plain", "[]");
} else {
data = "[";
for (int i = 0; i < n; ++i) {
ssid = WiFi.SSID(i);
......@@ -230,8 +230,7 @@ void handleScanSSID()
}
}
data += "]";
server->send(200, "text/plain", data);
}
server->send(200, "application/json", data);
}
}
......
......@@ -61,11 +61,11 @@ void setup() {
server->on("/action/register", handleRegister);
server->on("/action/restart", handleRestart);
server->on("/action/save", handleSave);
server->on("/action/wifi/ssids", handleScanSSID);
server->on("/config/api/hostname", handleAPIHostname);
server->on("/config/api/port", handleAPIPort);
server->on("/config/wifi/sta/ssid", handleSSID);
server->on("/config/wifi/sta/password", handlePassword);
server->on("/info/wifi/ssids", handleScanSSID);
server->on("/setup", []() {
server->setContentLength(sizeof(PAGE_setup));
server->sendHeader("Content-Encoding", "gzip");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment