From 109c392b0a1e99fca619afa33a94d611899bf0e8 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sun, 29 Dec 2019 18:19:01 +0300 Subject: [PATCH 1/3] test justwifi changes --- code/espurna/config/general.h | 8 ++++++++ code/espurna/wifi.ino | 7 +++++++ code/platformio.ini | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index cf72d2dd09..a3736f9497 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -461,6 +461,14 @@ #define WIFI_SCAN_NETWORKS 1 // Perform a network scan before connecting #endif +#ifndef WIFI_PERIODIC_SCAN_INTERVAL +#define WIFI_PERIODIC_SCAN_INTERVAL 0 // Perform a network scan while connected to find a better suited network. (time value in ms) +#endif + +#ifndef WIFI_PERIODIC_SCAN_RANGE +#define WIFI_PERIODIC_SCAN_RANGE 20 // Minimum RSSI difference of a better network (absolute number, 0...127) +#endif + // Optional hardcoded configuration (up to 2 networks) #ifndef WIFI1_SSID #define WIFI1_SSID "" diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index 64e82e30da..68c91b40b4 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -101,6 +101,8 @@ void _wifiConfigure() { #endif jw.enableScan(getSetting("wifiScan", WIFI_SCAN_NETWORKS).toInt() == 1); + jw.setPeriodicScanInterval(getSetting("wifiScanIntvl", WIFI_PERIODIC_SCAN_INTERVAL).toInt()); + jw.setRSSIThreshold(getSetting("wifiScanRSSI", WIFI_PERIODIC_SCAN_RANGE).toInt()); unsigned char sleep_mode = getSetting("wifiSleep", WIFI_SLEEP_MODE).toInt(); sleep_mode = constrain(sleep_mode, 0, 2); @@ -343,6 +345,11 @@ void _wifiDebugCallback(justwifi_messages_t code, char * parameter) { DEBUG_MSG_P(PSTR("[WIFI] %s\n"), parameter); } + if (code == MESSAGE_FOUND_BETTER_NETWORK) { + DEBUG_MSG_P(PSTR("[WIFI] Reconnecting to %s\n"), parameter); + WiFi.disconnect(); + } + // ------------------------------------------------------------------------- if (code == MESSAGE_CONNECTING) { diff --git a/code/platformio.ini b/code/platformio.ini index dc6f1af3a5..f2c6d77b46 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -117,7 +117,7 @@ lib_deps = https://bitbucket.org/xoseperez/fauxmoesp.git#3.1.0 https://github.com/xoseperez/hlw8012.git#1.1.0 https://github.com/markszabo/IRremoteESP8266#v2.2.0 - https://github.com/xoseperez/justwifi.git#2.0.2 + https://github.com/mcspr/justwifi.git#791098e https://github.com/madpilot/mDNSResolver#4cfcda1 https://github.com/xoseperez/my92xx#3.0.1 MQTT From 56d5228eedba128a778abdb017d6c87bea71e5eb Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sun, 29 Dec 2019 19:15:17 +0300 Subject: [PATCH 2/3] bump --- code/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/platformio.ini b/code/platformio.ini index f2c6d77b46..6f3d466581 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -117,7 +117,7 @@ lib_deps = https://bitbucket.org/xoseperez/fauxmoesp.git#3.1.0 https://github.com/xoseperez/hlw8012.git#1.1.0 https://github.com/markszabo/IRremoteESP8266#v2.2.0 - https://github.com/mcspr/justwifi.git#791098e + https://github.com/mcspr/justwifi.git#cfab8dd https://github.com/madpilot/mDNSResolver#4cfcda1 https://github.com/xoseperez/my92xx#3.0.1 MQTT From c7ef9ac112c4f4e27996387b5bf32173869b9fe9 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sun, 29 Dec 2019 19:57:41 +0300 Subject: [PATCH 3/3] fix scan disconnection --- code/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/platformio.ini b/code/platformio.ini index 6f3d466581..bdea63c47c 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -117,7 +117,7 @@ lib_deps = https://bitbucket.org/xoseperez/fauxmoesp.git#3.1.0 https://github.com/xoseperez/hlw8012.git#1.1.0 https://github.com/markszabo/IRremoteESP8266#v2.2.0 - https://github.com/mcspr/justwifi.git#cfab8dd + https://github.com/mcspr/justwifi.git#387e4df https://github.com/madpilot/mDNSResolver#4cfcda1 https://github.com/xoseperez/my92xx#3.0.1 MQTT