diff --git a/src/CHANGES.md b/src/CHANGES.md index 9f2f020d..b22ae189 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.8.107 - 2024-04-08 +* fix boot loop on `reboot on midnight` feature #1542, #1599, #1566, #1571 + ## 0.8.106 - 2024-04-05 * fix bootloop with CMT and NRF on ESP32 #1566 #1562 * possible fix of #1553 diff --git a/src/app.cpp b/src/app.cpp index 0577aa8f..d00a95c2 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -162,7 +162,7 @@ void app::onNetwork(bool gotIp) { ah::Scheduler::resetTicker(); regularTickers(); //reinstall regular tickers every(std::bind(&app::tickSend, this), mConfig->inst.sendInterval, "tSend"); - mMqttReconnect = true; + mTickerInstallOnce = true; mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers! once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2"); } @@ -200,40 +200,37 @@ void app::onNtpUpdate(bool gotTime) { mCalculatedTimezoneOffset = (int8_t)((mConfig->sun.lon >= 0 ? mConfig->sun.lon + 7.5 : mConfig->sun.lon - 7.5) / 15) * 3600; tickCalcSunrise(); } -} -//----------------------------------------------------------------------------- -void app::updateNtp(void) { - #if defined(ENABLE_MQTT) - if (mMqttReconnect && mMqttEnabled) { - mMqtt.tickerSecond(); - everySec(std::bind(&PubMqttType::tickerSecond, &mMqtt), "mqttS"); - everyMin(std::bind(&PubMqttType::tickerMinute, &mMqtt), "mqttM"); - } - #endif /*ENABLE_MQTT*/ + if (mTickerInstallOnce) { + mTickerInstallOnce = false; + #if defined(ENABLE_MQTT) + if (mMqttEnabled) { + mMqtt.tickerSecond(); + everySec(std::bind(&PubMqttType::tickerSecond, &mMqtt), "mqttS"); + everyMin(std::bind(&PubMqttType::tickerMinute, &mMqtt), "mqttM"); + } + #endif /*ENABLE_MQTT*/ - // only install schedulers once even if NTP wasn't successful in first loop - if (mMqttReconnect) { // @TODO: mMqttReconnect is variable which scope has changed if (mConfig->inst.rstValsNotAvail) everyMin(std::bind(&app::tickMinute, this), "tMin"); - 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"); + if(mNtpReceived) { + 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"); - if (mConfig->sys.schedReboot) { - uint32_t rebootTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86410); // reboot 10 secs after midnght - if (rebootTrig <= mTimestamp) { //necessary for times other than midnight to prevent reboot loop - rebootTrig += 86400; + if (mConfig->sys.schedReboot) { + uint32_t rebootTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86410); // reboot 10 secs after midnght + onceAt(std::bind(&app::tickReboot, this), rebootTrig, "midRe"); } - onceAt(std::bind(&app::tickReboot, this), rebootTrig, "midRe"); } } +} +//----------------------------------------------------------------------------- +void app::updateNtp(void) { if(mNtpReceived) onNtpUpdate(true); - - mMqttReconnect = false; } //----------------------------------------------------------------------------- @@ -249,8 +246,6 @@ void app::tickNtpUpdate(void) { updateNtp(); - mMqttReconnect = false; - once(std::bind(&app::tickNtpUpdate, this), nxtTrig, "ntp"); } @@ -548,6 +543,7 @@ void app::resetSystem(void) { mNetworkConnected = false; mNtpReceived = false; + mTickerInstallOnce = false; } //----------------------------------------------------------------------------- diff --git a/src/app.h b/src/app.h index 8861cb5b..70a1fde2 100644 --- a/src/app.h +++ b/src/app.h @@ -447,7 +447,7 @@ class app : public IApp, public ah::Scheduler { #if defined(ENABLE_MQTT) PubMqttType mMqtt; #endif /*ENABLE_MQTT*/ - bool mMqttReconnect = false; + bool mTickerInstallOnce = false; bool mMqttEnabled = false; // sun diff --git a/src/defines.h b/src/defines.h index 10c78548..60af67f6 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 106 +#define VERSION_PATCH 107 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/platformio.ini b/src/platformio.ini index a831f7c2..a6537040 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -301,7 +301,7 @@ build_flags = ${env.build_flags} -DDEF_LED1=17 -DLED_ACTIVE_HIGH -DARDUINO_USB_MODE=1 - #-DARDUINO_USB_CDC_ON_BOOT=1 + -DARDUINO_USB_CDC_ON_BOOT=1 monitor_filters = esp32_exception_decoder, colorize diff --git a/src/web/lang.json b/src/web/lang.json index 57ded1dd..c37e1d92 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -96,7 +96,7 @@ { "token": "TRY_TO_CONNECT", "en": "AhoyDTU is trying to connect to your WiFi", - "de": "AhoyDTU versucht eine Verindung mit deinem Netzwerk herzustellen" + "de": "AhoyDTU versucht eine Verbindung mit Deinem Netzwerk herzustellen" }, { "token": "CONNECTING",