From dc5c7020cc37ef32fbf8977e48cab5ff2c716a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 13 Feb 2017 20:29:04 +0100 Subject: [PATCH] Do not scan networks if just one network defined --- code/espurna/wifi.ino | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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() {