bmsd/mqtt.c

changeset 502
a8a6901b5a99
parent 501
9c41e865144a
child 567
6bf0afc33e70
--- a/bmsd/mqtt.c	Wed Oct 09 22:39:46 2019 +0200
+++ b/bmsd/mqtt.c	Thu Oct 10 20:42:39 2019 +0200
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2017-2018
+ * Copyright (C) 2017-2019
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -25,6 +25,7 @@
 #include "mqtt.h"
 #include "nodes.h"
 #include "fermenters.h"
+#include "co2meters.h"
 
 
 extern sys_config       Config;
@@ -98,7 +99,7 @@
 	topic = xstrcpy((char *)"mbv1.0/fermenters/#");	// Subscribe to fermenter messages.
 	mosquitto_subscribe(mosq, NULL, topic, 0);
 	free(topic);
-	topic = xstrcpy((char *)"mbv1.0/co2meter/#");	// Subscribe to co2meter messages.
+	topic = xstrcpy((char *)"mbv1.0/co2meters/#");	// Subscribe to co2meter messages.
 	mosquitto_subscribe(mosq, NULL, topic, 0);
 	free(topic);
 	topic = NULL;
@@ -170,6 +171,14 @@
 	    fermenter_log(message->topic, (char *)message->payload);
 	    return;
 	}
+	if (strstr(message->topic, (char *)"co2meters") &&  strstr(message->topic, (char *)"DBIRTH")) {
+            co2meter_birth_data(message->topic, (char *)message->payload);
+            return;
+        }
+        if (strstr(message->topic, (char *)"co2meters") && strstr(message->topic, (char *)"DLOG")) {
+            co2meter_log(message->topic, (char *)message->payload);
+            return;
+        }
 	syslog(LOG_NOTICE, "MQTT: message callback %s :: %d", message->topic, message->payloadlen);
     } else {
 	if (strstr(message->topic, (char *)"NBIRTH")) {

mercurial