diff --git a/tools/esp8266/ahoywifi.cpp b/tools/esp8266/ahoywifi.cpp index 9823ea23..54ada30a 100644 --- a/tools/esp8266/ahoywifi.cpp +++ b/tools/esp8266/ahoywifi.cpp @@ -209,24 +209,25 @@ time_t ahoywifi::getNtpTime(void) { } +//----------------------------------------------------------------------------- +void ahoywifi::scanAvailNetworks(void) { + int n = WiFi.scanComplete(); + if(n == -2) + WiFi.scanNetworks(true); +} + + //----------------------------------------------------------------------------- void ahoywifi::getAvailNetworks(JsonObject obj) { JsonArray nets = obj.createNestedArray("networks"); int n = WiFi.scanComplete(); - if(n == -2) { - WiFi.scanNetworks(true); - } else if(n) { + if(n > 0) { for (int i = 0; i < n; ++i) { nets[i]["ssid"] = WiFi.SSID(i); nets[i]["rssi"] = WiFi.RSSI(i); - // TODO: does github workflow use another version of this library? - // ahoywifi.cpp:223:38: error: 'class WiFiClass' has no member named 'isHidden' - //nets[i]["hidden"] = WiFi.isHidden(i) ? true : false; } WiFi.scanDelete(); - if(WiFi.scanComplete() == -2) - WiFi.scanNetworks(true); } } diff --git a/tools/esp8266/ahoywifi.h b/tools/esp8266/ahoywifi.h index 9a3239fd..cf3c779d 100644 --- a/tools/esp8266/ahoywifi.h +++ b/tools/esp8266/ahoywifi.h @@ -30,6 +30,7 @@ class ahoywifi { bool setupStation(uint32_t timeout); bool getApActive(void); time_t getNtpTime(void); + void scanAvailNetworks(void); void getAvailNetworks(JsonObject obj); private: diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index befe017c..6f403fec 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -609,6 +609,12 @@ bool app::getWifiApActive(void) { } +//----------------------------------------------------------------------------- +void app::scanAvailNetworks(void) { + mWifi->scanAvailNetworks(); +} + + //----------------------------------------------------------------------------- void app::getAvailNetworks(JsonObject obj) { mWifi->getAvailNetworks(obj); diff --git a/tools/esp8266/app.h b/tools/esp8266/app.h index e2e1adcc..fdb8ba93 100644 --- a/tools/esp8266/app.h +++ b/tools/esp8266/app.h @@ -68,6 +68,7 @@ class app { void saveValues(void); void resetPayload(Inverter<>* iv); bool getWifiApActive(void); + void scanAvailNetworks(void); void getAvailNetworks(JsonObject obj); uint8_t getIrqPin(void) { diff --git a/tools/esp8266/html/api.js b/tools/esp8266/html/api.js index a959ed74..eb2791ee 100644 --- a/tools/esp8266/html/api.js +++ b/tools/esp8266/html/api.js @@ -77,6 +77,13 @@ function sel(name, opt, selId) { return e; } +function selDelAllOpt(sel) { + var i, l = sel.options.length - 1; + for(i = l; i >= 0; i--) { + sel.remove(i); + } +} + function opt(val, html) { o = document.createElement('option'); o.value = val; diff --git a/tools/esp8266/html/setup.html b/tools/esp8266/html/setup.html index e88af4e1..c2985886 100644 --- a/tools/esp8266/html/setup.html +++ b/tools/esp8266/html/setup.html @@ -44,9 +44,11 @@