Browse Source

0.8.107

* fix boot loop on `reboot on midnight` feature #1542, #1599, #1566, #1571
pull/1584/head
lumapu 9 months ago
parent
commit
12b4251da9
  1. 3
      src/CHANGES.md
  2. 46
      src/app.cpp
  3. 2
      src/app.h
  4. 2
      src/defines.h
  5. 2
      src/platformio.ini
  6. 2
      src/web/lang.json

3
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

46
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;
}
//-----------------------------------------------------------------------------

2
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

2
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;

2
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

2
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",

Loading…
Cancel
Save