From 9ef2df21fa5138e83bfd44041311e7b40f18ef22 Mon Sep 17 00:00:00 2001 From: lumapu Date: Wed, 22 Feb 2023 23:28:12 +0100 Subject: [PATCH] merged PR #684, #698, #705 webserial minor overflow fix #660 web `index.html` improve version information #701 fix MQTT sets power limit to zero (0) #692 changed `reset at midnight` with timezone #697 --- src/CHANGES.md | 7 +++++++ src/app.cpp | 6 ++++-- src/defines.h | 2 +- src/hm/hmDefines.h | 2 +- src/plugins/MonochromeDisplay/MonochromeDisplay.h | 10 +++------- src/publisher/pubMqtt.h | 2 ++ src/utils/helper.h | 6 +++++- src/web/html/index.html | 4 +++- src/web/web.h | 4 ++-- 9 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 447054fa5..38f7a57e7 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,13 @@ (starting from release version `0.5.66`) +## 0.5.90 +* merged PR #684, #698, #705 +* webserial minor overflow fix #660 +* web `index.html` improve version information #701 +* fix MQTT sets power limit to zero (0) #692 +* changed `reset at midnight` with timezone #697 + ## 0.5.89 * reduced heap fragmentation (removed `strtok` completely) #644, #645, #682 * added part of mac address to MQTT client ID to seperate multiple ESPs in same network diff --git a/src/app.cpp b/src/app.cpp index eeda50e6e..f3b175b6b 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -193,7 +193,8 @@ void app::tickNtpUpdate(void) { if(mConfig->inst.rstValsNotAvail) everyMin(std::bind(&app::tickMinute, this), "tMin"); if(mConfig->inst.rstYieldMidNight) { - uint32_t midTrig = mTimestamp - ((mTimestamp + MIDNIGHTTICKER_OFFSET) % 86400) + 86400; // next midnight + uint32_t localTime = gTimezone.toLocal(mTimestamp); + uint32_t midTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi"); } } @@ -304,7 +305,8 @@ void app::tickMinute(void) { //----------------------------------------------------------------------------- void app::tickMidnight(void) { // only triggered if 'reset values at midnight is enabled' - uint32_t nxtTrig = mTimestamp - ((mTimestamp + MIDNIGHTTICKER_OFFSET) % 86400) + 86400; // next midnight + uint32_t localTime = gTimezone.toLocal(mTimestamp); + uint32_t nxtTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time onceAt(std::bind(&app::tickMidnight, this), nxtTrig, "mid2"); Inverter<> *iv; diff --git a/src/defines.h b/src/defines.h index 8698cbe1c..36471ae09 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 89 +#define VERSION_PATCH 90 //------------------------------------- typedef struct { diff --git a/src/hm/hmDefines.h b/src/hm/hmDefines.h index aa9fe24fb..19c35a27b 100644 --- a/src/hm/hmDefines.h +++ b/src/hm/hmDefines.h @@ -26,7 +26,7 @@ enum {FLD_UDC = 0, FLD_IDC, FLD_PDC, FLD_YD, FLD_YW, FLD_YT, const char* const fields[] = {"U_DC", "I_DC", "P_DC", "YieldDay", "YieldWeek", "YieldTotal", "U_AC", "I_AC", "P_AC", "F_AC", "Temp", "PF_AC", "Efficiency", "Irradiation","Q_AC", "ALARM_MES_ID","FWVersion","FWBuildYear","FWBuildMonthDay","FWBuildHourMinute","HWPartId", - "active PowerLimit", /*"reactive PowerLimit","Powerfactor",*/ "LastAlarmCode"}; + "active_PowerLimit", /*"reactivePowerLimit","Powerfactor",*/ "LastAlarmCode"}; const char* const notAvail = "n/a"; // mqtt discovery device classes diff --git a/src/plugins/MonochromeDisplay/MonochromeDisplay.h b/src/plugins/MonochromeDisplay/MonochromeDisplay.h index 5cfd85f02..d7880432a 100644 --- a/src/plugins/MonochromeDisplay/MonochromeDisplay.h +++ b/src/plugins/MonochromeDisplay/MonochromeDisplay.h @@ -37,13 +37,10 @@ static uint8_t bmp_arrow[] PROGMEM = { }; -static TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; // Central European Summer Time -static TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, 60}; // Central European Standard Tim - template class MonochromeDisplay { public: - MonochromeDisplay() : mCE(CEST, CET) {} + MonochromeDisplay() {} void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs, uint8_t disp_reset, const char *version) { mCfg = cfg; @@ -166,9 +163,9 @@ class MonochromeDisplay { } else { // Get current time if(mIsLarge) - printText(ah::getDateTimeStr(mCE.toLocal(*mUtcTs)).c_str(), 3); + printText(ah::getDateTimeStr(gTimezone.toLocal(*mUtcTs)).c_str(), 3); else - printText(ah::getTimeStr(mCE.toLocal(*mUtcTs)).c_str(), 3); + printText(ah::getTimeStr(gTimezone.toLocal(*mUtcTs)).c_str(), 3); } mDisplay->sendBuffer(); @@ -215,7 +212,6 @@ class MonochromeDisplay { uint8_t mLineOffsets[5]; display_t *mCfg; HMSYSTEM *mSys; - Timezone mCE; }; #endif /*__MONOCHROME_DISPLAY__*/ diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index a1eac8780..113292b8d 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -339,6 +339,8 @@ class PubMqtt { } void onMessage(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total) { + if(len == 0) + return; DPRINT(DBG_INFO, mqttStr[MQTT_STR_GOT_TOPIC]); DBGPRINTLN(String(topic)); if(NULL == mSubscriptionCb) diff --git a/src/utils/helper.h b/src/utils/helper.h index 179e60783..efd056d23 100644 --- a/src/utils/helper.h +++ b/src/utils/helper.h @@ -11,7 +11,11 @@ #include #include #include -#include +#include + +static TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; // Central European Summer Time +static TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, 60}; // Central European Standard Time +static Timezone gTimezone(CEST, CET); #define CHECK_MASK(a,b) ((a & b) == b) diff --git a/src/web/html/index.html b/src/web/html/index.html index 3a1628b30..6bb584329 100644 --- a/src/web/html/index.html +++ b/src/web/html/index.html @@ -219,7 +219,9 @@

Support this project:

if(getVerInt(version) < getVerInt(release)) p.append(svg(iconInfo, 20, 20, "#00d", "icon"), span("Update available, current released version: " + release), br()); else if(getVerInt(version) > getVerInt(release)) - p.append(svg(iconInfo, 20, 20, "#00d", "icon"), span("You are using a development version, current released version: " + release), br()); + p.append(svg(iconInfo, 20, 20, "#00d", "icon"), span("You are using development version " + version +". In case of issues you may want to try the current stable release: " + release), br()); + else + p.append(svg(iconInfo, 20, 20, "#00d", "icon"), span("You are using the current stable release: " + release), br()); } document.getElementById("warn_info").replaceChildren(p); diff --git a/src/web/web.h b/src/web/web.h index b8468bb6c..d26e7b54c 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -190,7 +190,7 @@ class Web { msg.replace("\r\n", ""); if(mSerialAddTime) { - if((9 + mSerialBufFill) <= WEB_SERIAL_BUF_SIZE) { + if((9 + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { if(mApp->getTimestamp() > 0) { strncpy(&mSerialBuf[mSerialBufFill], mApp->getTimeStr(mApp->getTimezoneOffset()).c_str(), 9); mSerialBufFill += 9; @@ -208,7 +208,7 @@ class Web { mSerialAddTime = true; uint16_t length = msg.length(); - if((length + mSerialBufFill) <= WEB_SERIAL_BUF_SIZE) { + if((length + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { strncpy(&mSerialBuf[mSerialBufFill], msg.c_str(), length); mSerialBufFill += length; }