100 mosquitto_subscribe(mosq, NULL, topic, 0); |
101 mosquitto_subscribe(mosq, NULL, topic, 0); |
101 free(topic); |
102 free(topic); |
102 topic = xstrcpy((char *)"mbv1.0/co2meters/#"); // Subscribe to co2meter messages. |
103 topic = xstrcpy((char *)"mbv1.0/co2meters/#"); // Subscribe to co2meter messages. |
103 mosquitto_subscribe(mosq, NULL, topic, 0); |
104 mosquitto_subscribe(mosq, NULL, topic, 0); |
104 free(topic); |
105 free(topic); |
|
106 topic = xstrcpy((char *)"mbv1.0/ispindels/#"); // Subscribe to ispindel messages. |
|
107 mosquitto_subscribe(mosq, NULL, topic, 0); |
|
108 free(topic); |
105 topic = NULL; |
109 topic = NULL; |
106 mqtt_status = STATUS_CONNACK_RECVD; |
110 mqtt_status = STATUS_CONNACK_RECVD; |
107 } else { |
111 } else { |
108 syslog(LOG_NOTICE, "MQTT: my_connect_callback: %s\n", mosquitto_connack_string(result)); |
112 syslog(LOG_NOTICE, "MQTT: my_connect_callback: %s\n", mosquitto_connack_string(result)); |
109 } |
113 } |
169 } |
173 } |
170 if (strstr(message->topic, (char *)"fermenters") && strstr(message->topic, (char *)"DLOG")) { |
174 if (strstr(message->topic, (char *)"fermenters") && strstr(message->topic, (char *)"DLOG")) { |
171 fermenter_log(message->topic, (char *)message->payload); |
175 fermenter_log(message->topic, (char *)message->payload); |
172 return; |
176 return; |
173 } |
177 } |
|
178 if (strstr(message->topic, (char *)"fermenters") && strstr(message->topic, (char *)"DCMD")) { |
|
179 return; // just ignore our own commands. |
|
180 } |
174 if (strstr(message->topic, (char *)"co2meters") && strstr(message->topic, (char *)"DBIRTH")) { |
181 if (strstr(message->topic, (char *)"co2meters") && strstr(message->topic, (char *)"DBIRTH")) { |
175 co2meter_birth_data(message->topic, (char *)message->payload); |
182 co2meter_birth_data(message->topic, (char *)message->payload); |
176 return; |
183 return; |
177 } |
184 } |
178 if (strstr(message->topic, (char *)"co2meters") && strstr(message->topic, (char *)"DLOG")) { |
185 if (strstr(message->topic, (char *)"co2meters") && strstr(message->topic, (char *)"DLOG")) { |
179 co2meter_log(message->topic, (char *)message->payload); |
186 co2meter_log(message->topic, (char *)message->payload); |
180 return; |
187 return; |
181 } |
188 } |
|
189 if (strstr(message->topic, (char *)"ispindels") && strstr(message->topic, (char *)"DBIRTH")) { |
|
190 ispindel_birth_data(message->topic, (char *)message->payload); |
|
191 return; |
|
192 } |
182 syslog(LOG_NOTICE, "MQTT: message callback %s :: %d", message->topic, message->payloadlen); |
193 syslog(LOG_NOTICE, "MQTT: message callback %s :: %d", message->topic, message->payloadlen); |
183 } else { |
194 } else { |
184 if (strstr(message->topic, (char *)"NBIRTH")) { |
195 if (strstr(message->topic, (char *)"NBIRTH")) { |
185 // Ignore ?? |
196 // Ignore ?? |
186 fprintf(stdout, "MQTT: %s NULL\n", message->topic); |
197 fprintf(stdout, "MQTT: %s NULL\n", message->topic); |