Versie 0.6.8. Code cleanup. Publish NDATA MQTT bericht iedere 5 minuten of als er een THB wijziging is.

Wed, 18 Jul 2018 13:26:37 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 18 Jul 2018 13:26:37 +0200
changeset 544
e2889b17f48c
parent 543
34e19966114b
child 545
c382a6c58c20

Versie 0.6.8. Code cleanup. Publish NDATA MQTT bericht iedere 5 minuten of als er een THB wijziging is.

configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
thermferm/mqtt.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
thermferm/thermferm.h file | annotate | diff | comparison | revisions
--- a/configure	Tue Jul 17 19:56:58 2018 +0200
+++ b/configure	Wed Jul 18 13:26:37 2018 +0200
@@ -2035,7 +2035,7 @@
 
 
 PACKAGE="mbsePi-apps"
-VERSION="0.6.7"
+VERSION="0.6.8"
 COPYRIGHT="Copyright (C) 2014-2018 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2018"
 
--- a/configure.ac	Tue Jul 17 19:56:58 2018 +0200
+++ b/configure.ac	Wed Jul 18 13:26:37 2018 +0200
@@ -8,7 +8,7 @@
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="mbsePi-apps"
-VERSION="0.6.7"
+VERSION="0.6.8"
 COPYRIGHT="Copyright (C) 2014-2018 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2018"
 AC_SUBST(PACKAGE)
--- a/thermferm/mqtt.c	Tue Jul 17 19:56:58 2018 +0200
+++ b/thermferm/mqtt.c	Wed Jul 18 13:26:37 2018 +0200
@@ -533,24 +533,17 @@
     if (birth) {
 	payload = xstrcat(payload, (char *)"\"uuid\":\"");
 	payload = xstrcat(payload, Config.uuid);
-	payload = xstrcat(payload, (char *)"\"");
-//	comma = true;
-//    }
-
-//    if (birth || flag & MQTT_NODE_CONTROL) {
-//	if (comma)
-//	    payload = xstrcat(payload, (char *)",");
-//    	payload = xstrcat(payload, (char *)"\"nodecontrol\":{\"reboot\":false,\"rebirth\":false,\"nextserver\":false,\"scanrate\":3000}");
-//	comma = true;
-//    }
-
-//    if (birth) {
-//    	if (comma)
-	    payload = xstrcat(payload, (char *)",");
+	payload = xstrcat(payload, (char *)"\",");
 #ifdef HAVE_WIRINGPI_H
 	payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"Raspberry\",\"hardwaremodel\":\"Unknown\"");
 #else
-    	payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"Unknown\",\"hardwaremodel\":\"Unknown\"");
+	if (uname(&ubuf) == 0) {
+	    payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"");
+	    payload = xstrcat(payload, ubuf.machine);
+	    payload = xstrcat(payload, (char *)"\",\"hardwaremodel\":\"Unknown\"");
+	} else {
+    	    payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"Unknown\",\"hardwaremodel\":\"Unknown\"");
+	}
 #endif
 	if (uname(&ubuf) == 0) {
             payload = xstrcat(payload, (char *)",\"os\":\"");
--- a/thermferm/thermferm.c	Tue Jul 17 19:56:58 2018 +0200
+++ b/thermferm/thermferm.c	Wed Jul 18 13:26:37 2018 +0200
@@ -975,7 +975,7 @@
 {
     char                buf[1024], *filename, target_lo[40], target_hi[40], heater[40], cooler[40], fan[40], door[40];
     char		use_heater[40], use_cooler[40], use_fan[40], room_temp[40];
-    time_t		now, last = (time_t)0;
+    time_t		now, last = (time_t)0, ndata = (time_t)0;;
     units_list		*unit;
     profiles_list	*profile;
     prof_step		*step;
@@ -1215,8 +1215,14 @@
 		}
 	    }
 	    row++;
-	    if (updateHT)
+	    /*
+	     * If TH(B) changed. or if 5 minutes without
+	     * update, send the NDATA message.
+	     */
+	    if (updateHT || (now > (ndata + 300))) {
 		publishNData(false, 0);
+		ndata = now;
+	    }
 
 	    LCDunit = 0;
 	    for (unit = Config.units; unit; unit = unit->next) {
--- a/thermferm/thermferm.h	Tue Jul 17 19:56:58 2018 +0200
+++ b/thermferm/thermferm.h	Wed Jul 18 13:26:37 2018 +0200
@@ -209,7 +209,7 @@
 #define	MQTT_FLAG_BIRTH		0x0002		/* Show birth instead of data	*/
 #define MQTT_FLAG_DEATH		0x0004		/* Show death of a unit		*/
 
-#define	MQTT_NODE_CONTROL	0x0001		/* Show node control		*/
+
 
 /*
  * Alarm bits, value above 255 are serious alarms.

mercurial