From 01108980dd1c226c86d8931d28eee491b0ff95cf Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 25 May 2022 20:14:22 +0200 Subject: [PATCH] Fix for interval reset --- firmware/config.h | 2 +- firmware/firmware.ino | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/firmware/config.h b/firmware/config.h index 2b2c99e..4199023 100644 --- a/firmware/config.h +++ b/firmware/config.h @@ -10,7 +10,7 @@ #define DELAY_LOOP_MS 50 #define POWERSAVING_SLEEP_S 600 #define EMERGENCY_SLEEP_S 172800 // Sleep for 2 days to recover -#define RESET_ESP_TIME_INTERVAL_MS 3600000 +#define RESET_ESP_TIME_INTERVAL_MS 1200000 // (60*60*6*1000) // reset every 6 hours #define WIND_SENSOR_MEAS_TIME_S 15 #define INITIAL_WEBSERVER_TIME 20 diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 3009661..1e626e5 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -141,16 +141,6 @@ void setup() //It's magic! leave in delay(100); -#ifdef RESET_ESP_TIMEINTERVAL - // if millis() reached interval (1h) restart ESP - if (millis() >= RESET_ESP_TIME_INTERVAL_MS) - { - debug("Resetting firmware intentionally"); - // Push reset button after flashing once or do a manual power cycle to get the functionality working. - ESP.restart(); - } -#endif - #ifdef BATTERY_POWERED debug("battery powered"); _loop(); @@ -262,6 +252,16 @@ void _loop() { } #endif +#ifdef RESET_ESP_TIME_INTERVAL + // if millis() reached interval (1h) restart ESP + if (RESET_ESP_TIME_INTERVAL_MS <= millis()) + { + debug("Resetting firmware intentionally"); + // Push reset button after flashing once or do a manual power cycle to get the functionality working. + ESP.restart(); + } +#endif + #ifndef BATTERY_POWERED if (UPDATE_SENSOR_INTERVAL_S * 1000 / DELAY_LOOP_MS > update_sensor_cnt) { return;