Versie 0.6.7. Globale uuid toegevoegd voor de NBIRTH payload.

Mon, 16 Jul 2018 17:23:22 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 16 Jul 2018 17:23:22 +0200
changeset 540
5a26429abbf8
parent 539
300b5c4cd977
child 541
a5530abb16dd

Versie 0.6.7. Globale uuid toegevoegd voor de NBIRTH payload.

configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
thermferm/mqtt.c file | annotate | diff | comparison | revisions
thermferm/rdconfig.c file | annotate | diff | comparison | revisions
thermferm/thermferm.h file | annotate | diff | comparison | revisions
--- a/configure	Mon Jul 16 11:41:46 2018 +0200
+++ b/configure	Mon Jul 16 17:23:22 2018 +0200
@@ -2035,7 +2035,7 @@
 
 
 PACKAGE="mbsePi-apps"
-VERSION="0.6.6"
+VERSION="0.6.7"
 COPYRIGHT="Copyright (C) 2014-2018 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2018"
 
--- a/configure.ac	Mon Jul 16 11:41:46 2018 +0200
+++ b/configure.ac	Mon Jul 16 17:23:22 2018 +0200
@@ -8,7 +8,7 @@
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="mbsePi-apps"
-VERSION="0.6.6"
+VERSION="0.6.7"
 COPYRIGHT="Copyright (C) 2014-2018 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2018"
 AC_SUBST(PACKAGE)
--- a/thermferm/mqtt.c	Mon Jul 16 11:41:46 2018 +0200
+++ b/thermferm/mqtt.c	Mon Jul 16 17:23:22 2018 +0200
@@ -530,7 +530,16 @@
     payload = payload_header();
     payload = xstrcat(payload, (char *)"{");
 
+    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;
     }
--- a/thermferm/rdconfig.c	Mon Jul 16 11:41:46 2018 +0200
+++ b/thermferm/rdconfig.c	Mon Jul 16 17:23:22 2018 +0200
@@ -75,6 +75,9 @@
     if (Config.mqtt_password)
 	free(Config.mqtt_password);
     Config.mqtt_password = NULL;
+    if (Config.uuid)
+	free(Config.uuid);
+    Config.uuid = NULL;
  
     for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) {
 	if (tmp2->uuid)
@@ -219,6 +222,10 @@
 	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 	return 1;
     }
+    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", Config.uuid)) < 0) {
+	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+	return 1;
+    }
     if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) {
 	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 	return 1;
@@ -2219,6 +2226,9 @@
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_PASS"))) {
 	    Config.mqtt_password = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) {
+	    Config.uuid= (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	}
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCDS"))) {
 	    parseLCDs(doc, cur);
 	}
@@ -2243,6 +2253,17 @@
     free(mypath);
     mypath = NULL;
 
+    /*
+     * If the system uuid is not set, do it now.
+     */
+    if (Config.uuid == NULL) {
+	uuid_t		uu;
+
+	Config.uuid = malloc(37);
+	uuid_generate(uu);
+	uuid_unparse(uu, Config.uuid);
+    }
+
     return rc;
 }
 
--- a/thermferm/thermferm.h	Mon Jul 16 11:41:46 2018 +0200
+++ b/thermferm/thermferm.h	Mon Jul 16 17:23:22 2018 +0200
@@ -366,6 +366,7 @@
     int			mqtt_port;		/* MQTT port to connect to	*/
     char		*mqtt_username;		/* MQTT username		*/
     char		*mqtt_password;		/* MQTT password		*/
+    char		*uuid;			/* System uuid			*/
 } sys_config;
 
 

mercurial