From 94438b496d36c0466a1d39e7c2cce4e7dae3a00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 9 Jan 2018 23:54:30 +0100 Subject: [PATCH 1/5] Add more debug info to MQTT module --- code/espurna/mqtt.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index 4e4e101a..5e98781c 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -508,8 +508,9 @@ void mqttSetBrokerIfNone(IPAddress ip, unsigned int port) { void mqttSetup() { - DEBUG_MSG_P(PSTR("[MQTT] Async %s, Autoconnect %s\n"), + DEBUG_MSG_P(PSTR("[MQTT] Async %s, SSL %s, Autoconnect %s\n"), MQTT_USE_ASYNC ? "ENABLED" : "DISABLED", + ASYNC_TCP_SSL_ENABLED ? "ENABLED" : "DISABLED", MQTT_AUTOCONNECT ? "ENABLED" : "DISABLED" ); From 68fbf6a730fde510bbfe76dda402cc101674e4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 10 Jan 2018 16:42:43 +0100 Subject: [PATCH 2/5] Version 1.11.5a --- code/espurna/config/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/espurna/config/version.h b/code/espurna/config/version.h index e637757a..48c91819 100644 --- a/code/espurna/config/version.h +++ b/code/espurna/config/version.h @@ -1,5 +1,5 @@ #define APP_NAME "ESPURNA" -#define APP_VERSION "1.11.4" +#define APP_VERSION "1.11.5a" #define APP_AUTHOR "xose.perez@gmail.com" #define APP_WEBSITE "http://tinkerman.cat" #define CFG_VERSION 3 From 8a7b0a2021526f7718196a57f0f303e60f6fb988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 10 Jan 2018 16:43:26 +0100 Subject: [PATCH 3/5] Rename terminal commands: reset.wifi to wifi.reset, reset.mqtt to mqtt.reset. Added wiki.scan --- code/espurna/settings.ino | 25 ++++++++++++--------- code/espurna/wifi.ino | 46 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index 6536952c..4845fc3a 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -308,6 +308,14 @@ void settingsSetup() { }); #endif + #if MQTT_SUPPORT + Embedis::command( F("MQTT.RESET"), [](Embedis* e) { + mqttConfigure(); + mqttDisconnect(); + DEBUG_MSG_P(PSTR("+OK\n")); + }); + #endif + #if NOFUSS_SUPPORT Embedis::command( F("NOFUSS"), [](Embedis* e) { DEBUG_MSG_P(PSTR("+OK\n")); @@ -337,22 +345,19 @@ void settingsSetup() { deferredReset(100, CUSTOM_RESET_TERMINAL); }); - #if MQTT_SUPPORT - Embedis::command( F("RESET.MQTT"), [](Embedis* e) { - mqttConfigure(); - mqttDisconnect(); - DEBUG_MSG_P(PSTR("+OK\n")); - }); - #endif + Embedis::command( F("UPTIME"), [](Embedis* e) { + DEBUG_MSG_P(PSTR("Uptime: %d seconds\n"), getUptime()); + DEBUG_MSG_P(PSTR("+OK\n")); + }); - Embedis::command( F("RESET.WIFI"), [](Embedis* e) { + Embedis::command( F("WIFI.RESET"), [](Embedis* e) { wifiConfigure(); wifiDisconnect(); DEBUG_MSG_P(PSTR("+OK\n")); }); - Embedis::command( F("UPTIME"), [](Embedis* e) { - DEBUG_MSG_P(PSTR("Uptime: %d seconds\n"), getUptime()); + Embedis::command( F("WIFI.SCAN"), [](Embedis* e) { + wifiScan(); DEBUG_MSG_P(PSTR("+OK\n")); }); diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index 528a584d..7232bf71 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -111,8 +111,7 @@ void wifiConfigure() { } } - // Scan for best network only if we have more than 1 defined - jw.scanNetworks(i>1); + jw.scanNetworks(true); } @@ -144,12 +143,55 @@ void wifiStatus() { DEBUG_MSG_P(PSTR("[WIFI] DNS %s\n"), WiFi.dnsIP().toString().c_str()); DEBUG_MSG_P(PSTR("[WIFI] MASK %s\n"), WiFi.subnetMask().toString().c_str()); DEBUG_MSG_P(PSTR("[WIFI] HOST %s\n"), WiFi.hostname().c_str()); + DEBUG_MSG_P(PSTR("[WIFI] RSSI %d\n"), WiFi.RSSI()); } DEBUG_MSG_P(PSTR("[WIFI] ----------------------------------------------\n")); } +void wifiScan() { + + DEBUG_MSG_P(PSTR("[WIFI] Start scanning\n")); + + unsigned char result = WiFi.scanNetworks(); + + if (result == WIFI_SCAN_FAILED) { + DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n")); + } else if (result == 0) { + DEBUG_MSG_P(PSTR("[WIFI] No networks found\n")); + } else { + + DEBUG_MSG_P(PSTR("[WIFI] %d networks found:\n"), result); + + // Populate defined networks with scan data + for (int8_t i = 0; i < result; ++i) { + + String ssid_scan; + int32_t rssi_scan; + uint8_t sec_scan; + uint8_t* BSSID_scan; + int32_t chan_scan; + bool hidden_scan; + + WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan); + + DEBUG_MSG_P(PSTR("[WIFI] - BSSID: %02X:%02X:%02X:%02X:%02X:%02X SEC: %s RSSI: %3d CH: %2d SSID: %s\n"), + BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], BSSID_scan[6], + (sec_scan != ENC_TYPE_NONE ? "YES" : "NO "), + rssi_scan, + chan_scan, + (char *) ssid_scan.c_str() + ); + + } + + } + + WiFi.scanDelete(); + +} + bool wifiClean(unsigned char num) { bool changed = false; From be1d716b795cb8cf5a88e165b00e615a920c0280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 10 Jan 2018 16:43:59 +0100 Subject: [PATCH 4/5] Added ESPurna Switch board support --- code/platformio.ini | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/code/platformio.ini b/code/platformio.ini index 754973a7..e90c2308 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -167,6 +167,16 @@ upload_flags = --auth=fibonacci --port 8266 monitor_baud = 115200 extra_scripts = ${common.extra_scripts} +[env:tinkerman-espurna-switch] +platform = ${common.platform} +framework = arduino +board = esp12e +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_SWITCH +monitor_baud = 115200 +extra_scripts = ${common.extra_scripts} + # ------------------------------------------------------------------------------ [env:itead-sonoff-basic] From 93cd43d0c4088bb2f3acff5c9d385432e0ff77fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 10 Jan 2018 16:44:47 +0100 Subject: [PATCH 5/5] Increase zeroconf discovery time. Check if any devices have been found. --- code/ota.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/ota.py b/code/ota.py index e66cc7f5..1318be38 100644 --- a/code/ota.py +++ b/code/ota.py @@ -183,9 +183,13 @@ if __name__ == '__main__': # Look for sevices zeroconf = Zeroconf() browser = ServiceBrowser(zeroconf, "_arduino._tcp.local.", handlers=[on_service_state_change]) - sleep(1) + sleep(5) zeroconf.close() + if len(devices) == 0: + print "Nothing found!\n" + sys.exit(0) + # Sort list field = args.sort.lower() if field not in devices[0]: