Version 0.0.1, changed data topics to /raw tree

Sat, 26 Apr 2014 22:53:10 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 26 Apr 2014 22:53:10 +0200
changeset 13
7f8432413321
parent 12
102c44bb8c9d
child 14
21901dc95501

Version 0.0.1, changed data topics to /raw tree

configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
thermometers/main.c file | annotate | diff | comparison | revisions
--- a/configure	Thu Apr 24 19:49:30 2014 +0200
+++ b/configure	Sat Apr 26 22:53:10 2014 +0200
@@ -1878,7 +1878,7 @@
 
 
 PACKAGE="mbsePi-apps"
-VERSION="0.0.0"
+VERSION="0.0.1"
 COPYRIGHT="Copyright (C) 2014 Michiel Broek, All Rights Reserved"
 CYEARS="2014"
 
--- a/configure.ac	Thu Apr 24 19:49:30 2014 +0200
+++ b/configure.ac	Sat Apr 26 22:53:10 2014 +0200
@@ -8,7 +8,7 @@
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="mbsePi-apps"
-VERSION="0.0.0"
+VERSION="0.0.1"
 COPYRIGHT="Copyright (C) 2014 Michiel Broek, All Rights Reserved"
 CYEARS="2014"
 AC_SUBST(PACKAGE)
--- a/thermometers/main.c	Thu Apr 24 19:49:30 2014 +0200
+++ b/thermometers/main.c	Sat Apr 26 22:53:10 2014 +0200
@@ -36,6 +36,7 @@
 static int		last_mid_sent = -1;
 static bool		connected = true;
 static bool		disconnect_sent = false;
+static bool		connect_lost = false;
 static bool		shutdown = false;
 static pid_t		pgrp, mypid;
 
@@ -76,6 +77,11 @@
 
 void my_connect_callback(struct mosquitto *mosq, void *obj, int result)
 {
+    if (connect_lost) {
+	connect_lost = false;
+	syslog(LOG_NOTICE, "Reconnect: %s", mosquitto_connack_string(result));
+    }
+
     if (!result) {
 	status = STATUS_CONNACK_RECVD;
     } else {
@@ -94,10 +100,8 @@
 	/*
 	 * The remove server was brought down. We must keep running
 	 */
-	syslog(LOG_NOTICE, "Received DISCONNECT from %s but we want to run", Config.mosq_host);
-	/*
-	 * We need a temp state
-	 */
+	syslog(LOG_NOTICE, "Received DISCONNECT from %s, connection lost", Config.mosq_host);
+	connect_lost = true;
     }
 }
 
@@ -341,12 +345,13 @@
 		device = xstrcat(device, (char *)"/");
 		device = xstrcat(device, tmp1->name);
 		device = xstrcat(device, (char *)"/w1_slave");
-		alias = xstrcpy((char *)"sensor/temperature/");
+		alias = xstrcpy((char *)"/raw/");
 		alias = xstrcat(alias, hostname);
-		alias = xstrcat(alias, (char *)"/");
+		alias = xstrcat(alias, (char *)"/thermometers/w1/");
 		alias = xstrcat(alias, tmp1->master);
 		alias = xstrcat(alias, (char *)"/");
-		alias = xstrcat(alias, tmp1->alias);
+		alias = xstrcat(alias, tmp1->name);
+		alias = xstrcat(alias, (char *)"/temperature");
 
 		/*
 		 * Read sensor data
@@ -383,7 +388,7 @@
 			    	 * Temperature is changed and valid, update and publish this.
 			    	 */
 			    	sprintf(buf, "%.1f", temp / 1000.0);
-			    	if ((rc = mosquitto_publish(mosq, &mid_sent, alias, strlen(buf), buf, qos, 0))) {
+			    	if ((rc = mosquitto_publish(mosq, &mid_sent, alias, strlen(buf), buf, qos, 1))) {
 			            if (rc == MOSQ_ERR_NO_CONN)
 				    	mosquitto_reconnect(mosq);
 			    	    else

mercurial