bmsd/mqtt.c

branch
stable
changeset 665
4d01937ae7af
parent 590
a43b8b85d8b3
child 679
48f8f3fce7c0
--- a/bmsd/mqtt.c	Fri Oct 18 13:20:35 2019 +0200
+++ b/bmsd/mqtt.c	Fri May 01 16:37:31 2020 +0200
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2017-2019
+ * Copyright (C) 2017-2020
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -26,6 +26,7 @@
 #include "nodes.h"
 #include "fermenters.h"
 #include "co2meters.h"
+#include "ispindels.h"
 
 
 extern sys_config       Config;
@@ -102,6 +103,9 @@
 	topic = xstrcpy((char *)"mbv1.0/co2meters/#");	// Subscribe to co2meter messages.
 	mosquitto_subscribe(mosq, NULL, topic, 0);
 	free(topic);
+	topic = xstrcpy((char *)"mbv1.0/ispindels/#");  // Subscribe to ispindel messages.
+        mosquitto_subscribe(mosq, NULL, topic, 0);
+        free(topic);
 	topic = NULL;
        	mqtt_status = STATUS_CONNACK_RECVD;
     } else {
@@ -171,6 +175,9 @@
 	    fermenter_log(message->topic, (char *)message->payload);
 	    return;
 	}
+	if (strstr(message->topic, (char *)"fermenters") && strstr(message->topic, (char *)"DCMD")) {
+            return; // just ignore our own commands.
+        }
 	if (strstr(message->topic, (char *)"co2meters") &&  strstr(message->topic, (char *)"DBIRTH")) {
             co2meter_birth_data(message->topic, (char *)message->payload);
             return;
@@ -179,6 +186,10 @@
             co2meter_log(message->topic, (char *)message->payload);
             return;
         }
+	if (strstr(message->topic, (char *)"ispindels") && strstr(message->topic, (char *)"DBIRTH")) {
+	    ispindel_birth_data(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