# HG changeset patch # User Michiel Broek # Date 1586107037 -7200 # Node ID 5035385299f6b309c0dd2e4fb37f91c7f0c2fe44 # Parent aae0056bc20b91496efd8c00f73c55b3016ede5e Added alarm timer watchdog. This resets the loop if not finished in 30 seconds. diff -r aae0056bc20b -r 5035385299f6 main/co2meter.c --- a/main/co2meter.c Thu Apr 02 11:45:36 2020 +0200 +++ b/main/co2meter.c Sun Apr 05 19:17:17 2020 +0200 @@ -27,7 +27,7 @@ extern WIFI_State *wifi_state; ///< WiFi state extern EventGroupHandle_t xEventGroupUser; extern int count_pub; ///< Published MQTT messages in transit - +extern uint32_t AlarmTimer; ///< Alarm timer @@ -156,6 +156,7 @@ Main_Loop1 = ML1_CONNECT; request_ds18b20(); request_adc(); + AlarmTimer = 30; if (! ready_WiFi()) { /* If WiFi was lost, try a new connection */ ESP_LOGI(TAG, "Try WiFi restore"); request_WiFi(); @@ -269,6 +270,7 @@ case ML1_DONE: /* Wait here until the timer resets the loop */ + AlarmTimer = 0; break; } vTaskDelay(10 / portTICK_PERIOD_MS); diff -r aae0056bc20b -r 5035385299f6 main/task_user.c --- a/main/task_user.c Thu Apr 02 11:45:36 2020 +0200 +++ b/main/task_user.c Sun Apr 05 19:17:17 2020 +0200 @@ -12,6 +12,7 @@ esp_timer_handle_t timerHandle; ///< Seconds timer uint32_t SecsCount = 0; ///< Seconds counter uint32_t UserTimer = 0; ///< User inactive timeout +uint32_t AlarmTimer = 0; ///< Alarm timer int Main_Loop2 = -1; ///< Effective menu int New_Loop2 = ML2_INIT; ///< New menu int SubMenu = 0; ///< Submenu number @@ -75,6 +76,15 @@ if (UserTimer) { UserTimer--; } + + if (AlarmTimer == 1) { + ESP_LOGI(TAG, "Alarm Timer timeout"); + Main_Loop1 = ML1_INIT; + } + + if (AlarmTimer) { + AlarmTimer--; + } }