Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.

Sun, 05 Apr 2020 19:17:17 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 05 Apr 2020 19:17:17 +0200
changeset 51
5035385299f6
parent 50
aae0056bc20b
child 52
90a36619b07b

Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.

main/co2meter.c file | annotate | diff | comparison | revisions
main/task_user.c file | annotate | diff | comparison | revisions
--- 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);
--- 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--;
+    }
 }
 
 

mercurial