bmsd/nodes.c

changeset 502
a8a6901b5a99
parent 384
442d23455ae4
child 572
7a03181d29a3
--- a/bmsd/nodes.c	Wed Oct 09 22:39:46 2019 +0200
+++ b/bmsd/nodes.c	Thu Oct 10 20:42:39 2019 +0200
@@ -3,7 +3,7 @@
  * @brief Handle nodes status
  * @author Michiel Broek <mbroek at mbse dot eu>
  *
- * Copyright (C) 2018
+ * Copyright (C) 2018-2019
  *
  * This file is part of the bms (Brewery Management System)
  *
@@ -33,6 +33,8 @@
 
 extern int			debug;
 extern sys_fermenter_list	*fermenters;
+extern sys_co2meter_list	*co2meters;
+
 
 
 void node_birth_data(char *topic, char *payload)
@@ -244,6 +246,7 @@
 {
     sys_node_list	*tmpn;
     sys_fermenter_list  *tmpf;
+    sys_co2meter_list	*tmpc;
     time_t		now = time(NULL);
 
     for (tmpn = nodes; tmpn; tmpn = tmpn->next) {
@@ -261,6 +264,16 @@
 		    }
             	}
             }
+
+	    for (tmpc = co2meters; tmpc; tmpc = tmpc->next) {
+		if (strcmp(tmpc->node, tmpn->node) == 0) {
+		    if (tmpc->online) {
+			syslog(LOG_NOTICE, "Timeout co2meter %s/%s", tmpc->node, tmpc->alias);
+			tmpc->online = false;
+			co2meter_mysql_death(tmpc->node, tmpc->alias);
+		    }
+		}
+	    }
 	}
     }
 }

mercurial