96 mosquitto_subscribe(mosq, NULL, topic, 0); |
97 mosquitto_subscribe(mosq, NULL, topic, 0); |
97 free(topic); |
98 free(topic); |
98 topic = xstrcpy((char *)"mbv1.0/fermenters/#"); // Subscribe to fermenter messages. |
99 topic = xstrcpy((char *)"mbv1.0/fermenters/#"); // Subscribe to fermenter messages. |
99 mosquitto_subscribe(mosq, NULL, topic, 0); |
100 mosquitto_subscribe(mosq, NULL, topic, 0); |
100 free(topic); |
101 free(topic); |
101 topic = xstrcpy((char *)"mbv1.0/co2meter/#"); // Subscribe to co2meter messages. |
102 topic = xstrcpy((char *)"mbv1.0/co2meters/#"); // Subscribe to co2meter messages. |
102 mosquitto_subscribe(mosq, NULL, topic, 0); |
103 mosquitto_subscribe(mosq, NULL, topic, 0); |
103 free(topic); |
104 free(topic); |
104 topic = NULL; |
105 topic = NULL; |
105 mqtt_status = STATUS_CONNACK_RECVD; |
106 mqtt_status = STATUS_CONNACK_RECVD; |
106 } else { |
107 } else { |
168 } |
169 } |
169 if (strstr(message->topic, (char *)"fermenters") && strstr(message->topic, (char *)"DLOG")) { |
170 if (strstr(message->topic, (char *)"fermenters") && strstr(message->topic, (char *)"DLOG")) { |
170 fermenter_log(message->topic, (char *)message->payload); |
171 fermenter_log(message->topic, (char *)message->payload); |
171 return; |
172 return; |
172 } |
173 } |
|
174 if (strstr(message->topic, (char *)"co2meters") && strstr(message->topic, (char *)"DBIRTH")) { |
|
175 co2meter_birth_data(message->topic, (char *)message->payload); |
|
176 return; |
|
177 } |
|
178 if (strstr(message->topic, (char *)"co2meters") && strstr(message->topic, (char *)"DLOG")) { |
|
179 co2meter_log(message->topic, (char *)message->payload); |
|
180 return; |
|
181 } |
173 syslog(LOG_NOTICE, "MQTT: message callback %s :: %d", message->topic, message->payloadlen); |
182 syslog(LOG_NOTICE, "MQTT: message callback %s :: %d", message->topic, message->payloadlen); |
174 } else { |
183 } else { |
175 if (strstr(message->topic, (char *)"NBIRTH")) { |
184 if (strstr(message->topic, (char *)"NBIRTH")) { |
176 // Ignore ?? |
185 // Ignore ?? |
177 fprintf(stdout, "MQTT: %s NULL\n", message->topic); |
186 fprintf(stdout, "MQTT: %s NULL\n", message->topic); |