From 9a6f7360da6dc0fd6002ba93a62407bc59ec3667 Mon Sep 17 00:00:00 2001 From: ESPEasy release bot Date: Wed, 14 Feb 2018 04:00:21 +0100 Subject: [PATCH 1/5] automaticly updated release notes for v2.0-20180214 --- dist/Release_notes.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dist/Release_notes.txt b/dist/Release_notes.txt index 399ced9ff..64cac82ec 100644 --- a/dist/Release_notes.txt +++ b/dist/Release_notes.txt @@ -1,3 +1,18 @@ +------------------------------------------------- +Changes in release v2.0-20180214 (since v2.0-20180213) +------------------------------------------------- + +Release date: Wed Feb 14 04:00:21 CET 2018 + +Edwin Eefting (3): + workaround for PUYA flash chips with write issues #650 + travis build fix for PUYA + updated deploy script for PUYA + +Gijs Noorlander (1): + [v2.0] Blynk controller (#865) + + ------------------------------------------------- Changes in release v2.0-20180213 (since v2.0-20180212) ------------------------------------------------- From 1e9dc1d14ca155fd666cd7d215ecc67ffd0f49eb Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Fri, 16 Feb 2018 21:26:18 +0100 Subject: [PATCH 2/5] [issue 866] Try to stop logging to serial when serial is not read. (#868) First attempt, not clear yet how to detect it. See #866 Also preparation for future improvement on logging. (to detect whether there is some logging active so Strings may not have to be prepared. --- src/ESPEasy.ino | 4 ++++ src/Misc.ino | 53 ++++++++++++++++++++++++++++++++++++----------- src/WebServer.ino | 8 +++++++ 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/src/ESPEasy.ino b/src/ESPEasy.ino index 195d97218..00e28eeeb 100644 --- a/src/ESPEasy.ino +++ b/src/ESPEasy.ino @@ -129,6 +129,10 @@ #define DEFAULT_TIME_ZONE 0 // Time Offset (in minutes) #define DEFAULT_USE_DST false // (true|false) Use Daily Time Saving +#define LOG_TO_SERIAL 1 +#define LOG_TO_SYSLOG 2 +#define LOG_TO_WEBLOG 3 +#define LOG_TO_SDCARD 4 #define DEFAULT_SYSLOG_IP "" // Syslog IP Address #define DEFAULT_SYSLOG_LEVEL 0 // Syslog Log Level #define DEFAULT_SERIAL_LOG_LEVEL LOG_LEVEL_INFO // Serial Log Level diff --git a/src/Misc.ino b/src/Misc.ino index a9afa2547..7ef1a5556 100644 --- a/src/Misc.ino +++ b/src/Misc.ino @@ -1217,26 +1217,55 @@ void addLog(byte logLevel, const __FlashStringHelper* flashString) addLog(logLevel, s.c_str()); } +bool SerialAvailableForWrite() { + if (!Settings.UseSerial) return false; + if (!Serial.availableForWrite()) return false; // UART FIFO overflow or TX disabled. + return true; +} + +boolean loglevelActiveFor(byte destination, byte logLevel) { + byte logLevelSettings = 0; + switch (destination) { + case LOG_TO_SERIAL: { + if (!SerialAvailableForWrite()) return false; + logLevelSettings = Settings.SerialLogLevel; + break; + } + case LOG_TO_SYSLOG: { + logLevelSettings = Settings.SyslogLevel; + break; + } + case LOG_TO_WEBLOG: { + logLevelSettings = Settings.WebLogLevel; + break; + } + case LOG_TO_SDCARD: { + logLevelSettings = Settings.SDLogLevel; + break; + } + default: + return false; + } + return loglevelActive(logLevel, logLevelSettings); +} + + boolean loglevelActive(byte logLevel, byte logLevelSettings) { return (logLevel <= logLevelSettings); } -void addLog(byte loglevel, const char *line) +void addLog(byte logLevel, const char *line) { - if (Settings.UseSerial) - if (loglevelActive(loglevel, Settings.SerialLogLevel)) - Serial.println(line); - - if (loglevelActive(loglevel, Settings.SyslogLevel)) + if (loglevelActiveFor(LOG_TO_SERIAL, logLevel)) { + Serial.println(line); + } + if (loglevelActiveFor(LOG_TO_SYSLOG, logLevel)) { syslog(line); - - if (loglevelActive(loglevel, Settings.WebLogLevel)) - { + } + if (loglevelActiveFor(LOG_TO_WEBLOG, logLevel)) { Logging.add(line); } - - if (loglevelActive(loglevel, Settings.SDLogLevel)) - { + if (loglevelActiveFor(LOG_TO_SDCARD, logLevel)) { File logFile = SD.open("log.dat", FILE_WRITE); if (logFile) logFile.println(line); diff --git a/src/WebServer.ino b/src/WebServer.ino index 252c65011..cea0026bc 100644 --- a/src/WebServer.ino +++ b/src/WebServer.ino @@ -4173,6 +4173,14 @@ void handle_sysinfo() { reply += F("Warm boot count:"); reply += RTC.bootCounter; + reply += F("Serial Port available:"); + reply += String(SerialAvailableForWrite()); + reply += F(" ("); + reply += Serial.availableForWrite(); + reply += F(" , "); + reply += Serial.available(); + reply += F(")"); + reply += F("STA MAC:"); uint8_t mac[] = {0, 0, 0, 0, 0, 0}; uint8_t* macread = WiFi.macAddress(mac); From ce02c9e039865a80812ae3a7be8d52142809288d Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Fri, 16 Feb 2018 21:27:58 +0100 Subject: [PATCH 3/5] [issue #853] Favicon.ico (#874) * [issue #853] Favicon.ico Added a very small favicon.ico of the ESPeasy logo. (1150 Bytes, 16x16) * [Favicon] Added instructions to change icon. In the comments. Just use 'xxd' from the (Linux) commandline. --- src/WebServer.ino | 110 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/src/WebServer.ino b/src/WebServer.ino index cea0026bc..380712013 100644 --- a/src/WebServer.ino +++ b/src/WebServer.ino @@ -88,6 +88,7 @@ void WebServerInit() WebServer.on("/rules", handle_rules); WebServer.on("/sysinfo", handle_sysinfo); WebServer.on("/pinstates", handle_pinstates); + WebServer.on("/favicon.ico", handle_favicon); if (ESP.getFlashChipRealSize() > 524288) httpUpdater.setup(&WebServer); @@ -4287,3 +4288,112 @@ String getValueSymbol(byte index) ret += F(";"); return ret; } + + +/*********************************************************************************************\ + * ESP Easy logo Favicon.ico 16x16 8 bit +\*********************************************************************************************/ +// Generated using xxd: xxd -i favicon.ico > favicon.ino +static const char favicon_8b_ico[] PROGMEM = { + 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x00, + 0x20, 0x00, 0x68, 0x04, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x12, 0x0b, + 0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xef, 0xc0, 0x89, 0x11, 0xfe, 0xfb, 0xf8, 0xac, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xf3, + 0xe9, 0xac, 0xef, 0xc0, 0x89, 0x11, 0xfe, 0xfb, 0xf8, 0xac, 0xf1, 0xc8, + 0x95, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xf1, 0xc8, 0x95, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xef, 0xc2, + 0x8a, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfc, 0xf3, 0xe9, 0xac, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd9, 0x69, + 0x00, 0xff, 0xd9, 0x69, 0x00, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xc2, + 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xd9, 0x69, 0x00, 0xff, 0xd9, 0x69, 0x00, 0xff, 0xef, 0xc2, + 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xf1, 0xc8, 0x95, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xc2, + 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc2, + 0x8a, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xc8, 0x95, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xc2, + 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xc8, + 0x95, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xf1, 0xc8, 0x95, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc2, + 0x8a, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc2, + 0x8a, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xd8, 0x63, 0x00, 0xff, 0xef, 0xbc, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xbc, 0x80, 0xff, 0xd8, 0x63, + 0x00, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xf1, + 0xe6, 0xac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xc8, 0x95, 0xff, 0xf1, 0xc8, + 0x95, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc2, + 0x8a, 0xff, 0xf1, 0xc8, 0x95, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xef, 0xc2, 0x8a, 0xff, 0xf1, 0xc8, 0x95, 0xff, 0xfe, 0xfb, + 0xf8, 0xac, 0xef, 0xc0, 0x89, 0x11, 0xfb, 0xf1, 0xe6, 0xac, 0xfe, 0xfa, + 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfa, + 0xf5, 0xff, 0xfe, 0xfa, 0xf5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfb, + 0xf8, 0xac, 0xef, 0xc0, 0x89, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +unsigned int favicon_8b_ico_len = 1150; + +void handle_favicon() { + WebServer.send_P(200, PSTR("image/x-icon"), favicon_8b_ico, favicon_8b_ico_len); +} From 0e0e7be95aa28de94ab95e5bcd00c8bf04fe9903 Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Fri, 16 Feb 2018 21:29:44 +0100 Subject: [PATCH 4/5] [OLED Framed] ESP Easy logo (#876) --- .../OLED_SSD1306_SH1106_images.h | 47 +++++++------------ src/_P036_FrameOLED.ino | 12 +++-- 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/lib/esp8266-oled-ssd1306/OLED_SSD1306_SH1106_images.h b/lib/esp8266-oled-ssd1306/OLED_SSD1306_SH1106_images.h index 8c35854cf..095ac8e22 100644 --- a/lib/esp8266-oled-ssd1306/OLED_SSD1306_SH1106_images.h +++ b/lib/esp8266-oled-ssd1306/OLED_SSD1306_SH1106_images.h @@ -1,31 +1,21 @@ -#define WiFi_Logo_width 60 -#define WiFi_Logo_height 36 -const char WiFi_Logo_bits[] PROGMEM = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, - 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, - 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, - 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, - 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, - 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, - 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, - 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, - 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, - 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, - 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, - 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, - 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, - 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, - 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, - 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, - 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, - 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; +#define espeasy_logo_width 36 +#define espeasy_logo_height 36 +const char espeasy_logo_bits[] PROGMEM= { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x60, 0x40, 0xc0, 0x00, 0x00, 0x70, 0xf0, 0xe0, + 0x01, 0x00, 0x78, 0xf8, 0xf0, 0x01, 0x00, 0x3c, 0x7c, 0xf8, 0x00, 0x00, + 0x1e, 0x3e, 0x7c, 0x00, 0x00, 0x0f, 0x1f, 0x3e, 0x00, 0x80, 0x87, 0x0f, + 0x1f, 0x00, 0xc0, 0xc3, 0x87, 0x0f, 0x00, 0xe0, 0xe1, 0xc3, 0x07, 0x00, + 0xf0, 0xf0, 0xe1, 0xc3, 0x00, 0x78, 0xf8, 0xf0, 0xe1, 0x01, 0x30, 0x7c, + 0xf8, 0xf0, 0x00, 0x00, 0x3e, 0x7c, 0x78, 0x00, 0x00, 0x1f, 0x3e, 0x3c, + 0x00, 0x80, 0x0f, 0x1f, 0x1e, 0x00, 0xc0, 0x87, 0x0f, 0x0f, 0x00, 0xe0, + 0xc3, 0x87, 0x07, 0x00, 0xf0, 0xe1, 0xc3, 0x03, 0x00, 0xf0, 0xf0, 0xe1, + 0x01, 0x00, 0x78, 0xf8, 0xf0, 0x00, 0x00, 0x30, 0x7c, 0x78, 0x00, 0x00, + 0x00, 0x3e, 0x3c, 0x00, 0x00, 0x00, 0x1f, 0x1e, 0x00, 0x00, 0x80, 0x0f, + 0x0f, 0x78, 0x00, 0xc0, 0x87, 0x07, 0xfc, 0x00, 0xe0, 0xc3, 0x03, 0xfc, + 0x01, 0xf0, 0xe1, 0x01, 0xfc, 0x01, 0xf8, 0xf0, 0x00, 0xfc, 0x00, 0x78, + 0x70, 0x00, 0x78, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; const char activeSymbole[] PROGMEM = { B00000000, @@ -48,4 +38,3 @@ const char inactiveSymbole[] PROGMEM = { B00000000, B00000000 }; - diff --git a/src/_P036_FrameOLED.ino b/src/_P036_FrameOLED.ino index 667115312..2c7673404 100644 --- a/src/_P036_FrameOLED.ino +++ b/src/_P036_FrameOLED.ino @@ -225,7 +225,7 @@ boolean Plugin_036(byte function, struct EventStruct *event, String& string) // Display the device name, logo, time and wifi display_header(); - // display_logo(); + display_logo(); display->display(); // Set up the display timer @@ -503,8 +503,14 @@ void display_title(String& title) { } void display_logo() { - // draw an xbm image. - display->drawXbm(34, 14, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits); + display->setTextAlignment(TEXT_ALIGN_LEFT); + display->setFont(ArialMT_Plain_16); + display->setColor(BLACK); + display->fillRect(0, 14, 128, 64); + display->setColor(WHITE); + display->drawString(65, 15, F("ESP")); + display->drawString(65, 34, F("Easy")); + display->drawXbm(24, 14, espeasy_logo_width, espeasy_logo_height, espeasy_logo_bits); } // Draw the frame position From a93a078c0b8ae4090c22717eacc8bc8ba92ad780 Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Fri, 16 Feb 2018 21:32:53 +0100 Subject: [PATCH 5/5] [issue #869] Added 'LWT' to last will topic and improved CPU load (#883) * [issue #869] Added 'LWT' to last will topic and improved CPU load See #869 for discussion on Last Will Topic. Also changed the way it tried to reconnect to make it return a lot faster when connection is not (yet) possible and call the PubSubClient::loop() at a much slower pace to reduce CPU usage. (See #847) This higher CPU load was probably introduced when fixing #683. * [MQTT] Fix error reporting success status with longer payloads Applied PR https://github.com/knolleary/pubsubclient/pull/360/files * made MQTT_CALLBACK_SIGNATURE for esp32 functional Applied PR https://github.com/knolleary/pubsubclient/pull/336 --- lib/pubsubclient/src/PubSubClient.cpp | 2 +- lib/pubsubclient/src/PubSubClient.h | 2 +- src/Controller.ino | 83 +++++++++++++-------------- src/ESPEasy.ino | 23 ++++++-- 4 files changed, 60 insertions(+), 50 deletions(-) diff --git a/lib/pubsubclient/src/PubSubClient.cpp b/lib/pubsubclient/src/PubSubClient.cpp index f26f0532b..c00c65453 100644 --- a/lib/pubsubclient/src/PubSubClient.cpp +++ b/lib/pubsubclient/src/PubSubClient.cpp @@ -420,7 +420,7 @@ boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsig lastOutActivity = millis(); - return rc == tlen + 4 + plength; + return rc == tlen + 3 + llen + plength; } boolean PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length) { diff --git a/lib/pubsubclient/src/PubSubClient.h b/lib/pubsubclient/src/PubSubClient.h index d82d6ae7b..c6f8e6757 100644 --- a/lib/pubsubclient/src/PubSubClient.h +++ b/lib/pubsubclient/src/PubSubClient.h @@ -73,7 +73,7 @@ #define MQTTQOS1 (1 << 1) #define MQTTQOS2 (2 << 1) -#ifdef ESP8266 +#if defined(ESP8266) || defined(ESP32) #include #define MQTT_CALLBACK_SIGNATURE std::function callback #else diff --git a/src/Controller.ino b/src/Controller.ino index 0dc7b60fe..1ac682367 100644 --- a/src/Controller.ino +++ b/src/Controller.ino @@ -120,9 +120,9 @@ void callback(char* c_topic, byte* b_payload, unsigned int length) { /*********************************************************************************************\ * Connect to MQTT message broker \*********************************************************************************************/ -void MQTTConnect(int controller_idx) +bool MQTTConnect(int controller_idx) { - if (!WiFiConnected(100)) return; + if (!WiFiConnected(100)) return false; if (MQTTclient.connected()) MQTTclient.disconnect(); ControllerSettingsStruct ControllerSettings; @@ -137,61 +137,56 @@ void MQTTConnect(int controller_idx) // MQTT needs a unique clientname to subscribe to broker String clientid = F("ESPClient_"); clientid += WiFi.macAddress(); - String subscribeTo = ""; String LWTTopic = ControllerSettings.Subscribe; LWTTopic.replace(F("/#"), F("/status")); LWTTopic.replace(F("%sysname%"), Settings.Name); + LWTTopic += F("/LWT"); // Extend the topic for status updates of connected/disconnected status. - for (byte x = 1; x < 3; x++) - { - String log = ""; - boolean MQTTresult = false; + boolean MQTTresult = false; + uint8_t willQos = 0; + boolean willRetain = true; - if ((SecuritySettings.ControllerUser[controller_idx] != 0) && (SecuritySettings.ControllerPassword[controller_idx] != 0)) - MQTTresult = MQTTclient.connect(clientid.c_str(), SecuritySettings.ControllerUser[controller_idx], SecuritySettings.ControllerPassword[controller_idx], LWTTopic.c_str(), 0, 0, "Connection Lost"); - else - MQTTresult = MQTTclient.connect(clientid.c_str(), LWTTopic.c_str(), 0, 0, "Connection Lost"); - yield(); - - if (MQTTresult) - { - MQTTclient_should_reconnect = false; - log = F("MQTT : Connected to broker with client ID: "); - log += clientid; - addLog(LOG_LEVEL_INFO, log); - subscribeTo = ControllerSettings.Subscribe; - subscribeTo.replace(F("%sysname%"), Settings.Name); - MQTTclient.subscribe(subscribeTo.c_str()); - log = F("Subscribed to: "); - log += subscribeTo; - addLog(LOG_LEVEL_INFO, log); - - MQTTclient.publish(LWTTopic.c_str(), "Connected"); - - statusLED(true); - return; // end loop if succesfull - } - else - { - log = F("MQTT : Failed to connect to broker"); - addLog(LOG_LEVEL_ERROR, log); - } - - delay(500); + if ((SecuritySettings.ControllerUser[controller_idx] != 0) && (SecuritySettings.ControllerPassword[controller_idx] != 0)) { + MQTTresult = MQTTclient.connect(clientid.c_str(), SecuritySettings.ControllerUser[controller_idx], SecuritySettings.ControllerPassword[controller_idx], + LWTTopic.c_str(), willQos, willRetain, "Connection Lost"); + } else { + MQTTresult = MQTTclient.connect(clientid.c_str(), LWTTopic.c_str(), willQos, willRetain, "Connection Lost"); } + yield(); + + if (!MQTTresult) { + addLog(LOG_LEVEL_ERROR, F("MQTT : Failed to connect to broker")); + return false; + } + MQTTclient_should_reconnect = false; + String log = F("MQTT : Connected to broker with client ID: "); + log += clientid; + addLog(LOG_LEVEL_INFO, log); + String subscribeTo = ControllerSettings.Subscribe; + subscribeTo.replace(F("%sysname%"), Settings.Name); + MQTTclient.subscribe(subscribeTo.c_str()); + log = F("Subscribed to: "); + log += subscribeTo; + addLog(LOG_LEVEL_INFO, log); + + if (MQTTclient.publish(LWTTopic.c_str(), "Connected")) { + statusLED(true); + return true; // end loop if succesfull + } + return false; } /*********************************************************************************************\ * Check connection MQTT message broker \*********************************************************************************************/ -void MQTTCheck(int controller_idx) +bool MQTTCheck(int controller_idx) { byte ProtocolIndex = getProtocolIndex(Settings.Protocol[controller_idx]); if (Protocol[ProtocolIndex].usesMQTT) { - if (MQTTclient_should_reconnect || !WiFiConnected(100) || !MQTTclient.connected()) + if (MQTTclient_should_reconnect || !WiFiConnected(10) || !MQTTclient.connected()) { if (MQTTclient_should_reconnect) { addLog(LOG_LEVEL_ERROR, F("MQTT : Intentional reconnect")); @@ -199,11 +194,13 @@ void MQTTCheck(int controller_idx) addLog(LOG_LEVEL_ERROR, F("MQTT : Connection lost")); connectionFailures += 2; } - MQTTConnect(controller_idx); - } - else if (connectionFailures) + return MQTTConnect(controller_idx); + } else if (connectionFailures) { connectionFailures--; + } } + // When no MQTT protocol is enabled, all is fine. + return true; } diff --git a/src/ESPEasy.ino b/src/ESPEasy.ino index 00e28eeeb..a95b0e7f5 100644 --- a/src/ESPEasy.ino +++ b/src/ESPEasy.ino @@ -906,6 +906,7 @@ unsigned long timer100ms; unsigned long timer20ms; unsigned long timer1s; unsigned long timerwd; +unsigned long timermqtt; unsigned long lastSend; unsigned int NC_Count = 0; unsigned int C_Count = 0; @@ -1104,6 +1105,7 @@ void setup() timer100ms = 0; // timer for periodic actions 10 x per/sec timer1s = 0; // timer for periodic actions once per/sec timerwd = 0; // timer for watchdog once per 30 sec + timermqtt = 0; // Timer for the MQTT keep alive loop. PluginInit(); CPluginInit(); @@ -1119,12 +1121,14 @@ void setup() if (Settings.UDPPort != 0) portUDP.begin(Settings.UDPPort); +/* // Setup MQTT Client // ToDo TD-er: Controller index is forced to the first enabled MQTT controller. int enabledMqttController = firstEnabledMQTTController(); if (enabledMqttController >= 0) { MQTTConnect(enabledMqttController); } +*/ sendSysInfoUDP(3); @@ -1206,12 +1210,21 @@ void loop() if (timeOutReached(timer1s)) runOncePerSecond(); - } - //dont do this in backgroundtasks(), otherwise causes crashes. (https://github.com/letscontrolit/ESPEasy/issues/683) - int enabledMqttController = firstEnabledMQTTController(); - if (enabledMqttController >= 0) { - MQTTclient.loop(); + if (timeOutReached(timermqtt)) { + // MQTT_KEEPALIVE = 15 seconds. + timermqtt = millis() + 250; + //dont do this in backgroundtasks(), otherwise causes crashes. (https://github.com/letscontrolit/ESPEasy/issues/683) + int enabledMqttController = firstEnabledMQTTController(); + if (enabledMqttController >= 0) { + if (!MQTTclient.loop()) { + if (!MQTTCheck(enabledMqttController)) { + // Check failed, no need to retry it immediately. + timermqtt = millis() + 500; + } + } + } + } } backgroundtasks();