diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index 26d8e474..45afe9fc 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -49,12 +49,14 @@ bool createAP() { } void wifiConfigure() { - jw.scanNetworks(true); + jw.setHostname(getSetting("hostname", HOSTNAME).c_str()); jw.setSoftAP(getSetting("hostname", HOSTNAME).c_str(), getSetting("adminPass", ADMIN_PASS).c_str(), AP_MODE_IP, AP_MODE_GW, AP_MODE_MASK); jw.setAPMode(AP_MODE); jw.cleanNetworks(); - for (int i = 0; i< WIFI_MAX_NETWORKS; i++) { + + int i; + for (i = 0; i< WIFI_MAX_NETWORKS; i++) { if (getSetting("ssid" + String(i)).length() == 0) break; if (getSetting("ip" + String(i)).length() == 0) { jw.addNetwork( @@ -72,6 +74,10 @@ void wifiConfigure() { ); } } + + // Scan for best network only if we have more than 1 defined + jw.scanNetworks(i>1); + } void wifiSetup() {