From ad9b3494cf53b7a0cc319ce601138d0d36886681 Mon Sep 17 00:00:00 2001 From: Visualapproach Date: Mon, 17 Jun 2024 13:36:02 +0200 Subject: [PATCH] small fixes: reset wifi bug + write reboot info bug --- Code/lib/BWC_unified/FW_VERSION.h | 2 +- Code/lib/BWC_unified/bwc.cpp | 4 +++- Code/src/main.cpp | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Code/lib/BWC_unified/FW_VERSION.h b/Code/lib/BWC_unified/FW_VERSION.h index cb7d133e..fc3d2b28 100644 --- a/Code/lib/BWC_unified/FW_VERSION.h +++ b/Code/lib/BWC_unified/FW_VERSION.h @@ -1 +1 @@ -#define FW_VERSION "2024-06-10-2016" +#define FW_VERSION "2024-06-17-1334" diff --git a/Code/lib/BWC_unified/bwc.cpp b/Code/lib/BWC_unified/bwc.cpp index ef3c788c..1ad68578 100644 --- a/Code/lib/BWC_unified/bwc.cpp +++ b/Code/lib/BWC_unified/bwc.cpp @@ -176,6 +176,7 @@ void BWC::begin(){ void BWC::loop(){ ++loop_count; + // if(loop_count % 100 == 0) Serial.printf_P(PSTR("bwc loop %d\n"), millis()); #ifdef ESP8266 ESP.wdtFeed(); #endif @@ -1509,7 +1510,7 @@ void BWC::_saveCommandQueue(){ Serial.println(F("Failed to save cmdq.json")); return; } else { - Serial.println(F("Wrote cmdq.json")); + Serial.println(F("Writing cmdq.json")); } /*Do not save instant reboot command. Don't ask me how I know.*/ if(_command_que.size()) @@ -1535,6 +1536,7 @@ void BWC::_saveCommandQueue(){ // Serial.println(s); } file.close(); + Serial.println(F("Done!")); //revive the dog // ESP.wdtEnable(0); } diff --git a/Code/src/main.cpp b/Code/src/main.cpp index f71d78ab..77effed1 100644 --- a/Code/src/main.cpp +++ b/Code/src/main.cpp @@ -185,6 +185,8 @@ void loop() delay(3000); } //handleAUX(); + // static int temp_counter = 0; + // if(++temp_counter % 100 == 0) BWC_LOG_P(PSTR("main loop %d\n"), millis()); } /* Debugging to file, normally not used */ @@ -441,10 +443,12 @@ void checkNTP() if(now < 8 * 3600 * 2) { if (++ntpTryNumber == 10) { + ntpTryNumber = 0; //reset until next check ntpCheck_ticker.detach(); } - return; - } + return; + } + ntpCheck_ticker.detach(); //time is set, don't check again struct tm timeinfo; gmtime_r(&now, &timeinfo); time_t boot_timestamp = getBootTime(); @@ -1465,8 +1469,8 @@ void resetWiFi() updateMqttTimer.detach(); updateWSTimer.detach(); if(ntpCheck_ticker.active()) ntpCheck_ticker.detach(); - bwc->stop(); bwc->saveSettings(); + bwc->stop(); delay(1000); #if defined(ESP8266) ESP.eraseConfig();