192 char buf[128]; |
192 char buf[128]; |
193 |
193 |
194 if (mqtt_use) { |
194 if (mqtt_use) { |
195 /* |
195 /* |
196 * Final publish 0 to clients/<hostname>/thermferm/state |
196 * Final publish 0 to clients/<hostname>/thermferm/state |
|
197 * After that, remove the retained topic. |
197 */ |
198 */ |
198 syslog(LOG_NOTICE, "MQTT disconnecting"); |
199 syslog(LOG_NOTICE, "MQTT disconnecting"); |
199 sprintf(buf, "0"); |
200 sprintf(buf, "0"); |
200 mosquitto_publish(mosq, &mqtt_mid_sent, state, strlen(buf), buf, mqtt_qos, true); |
201 mosquitto_publish(mosq, &mqtt_mid_sent, state, strlen(buf), buf, mqtt_qos, true); |
|
202 mosquitto_publish(mosq, &mqtt_mid_sent, state, 0, NULL, mqtt_qos, true); |
201 mqtt_last_mid = mqtt_mid_sent; |
203 mqtt_last_mid = mqtt_mid_sent; |
202 mqtt_status = STATUS_WAITING; |
204 mqtt_status = STATUS_WAITING; |
203 mqtt_my_shutdown = TRUE; |
205 mqtt_my_shutdown = TRUE; |
204 |
206 |
205 do { |
207 do { |
266 mosquitto_publish(mosq, &mqtt_mid_sent, topic, strlen(buf), buf, mqtt_qos, 1); |
268 mosquitto_publish(mosq, &mqtt_mid_sent, topic, strlen(buf), buf, mqtt_qos, 1); |
267 } |
269 } |
268 #endif |
270 #endif |
269 } |
271 } |
270 |
272 |
|
273 |
|
274 |
|
275 void mqtt_publish_clear(char *uuid, char *tail) |
|
276 { |
|
277 #ifdef HAVE_MOSQUITTO_H |
|
278 char topic[1024]; |
|
279 |
|
280 if (mqtt_use) { |
|
281 snprintf(topic, 1023, "bmsd/%s/%s/%s", my_hostname, uuid, tail); |
|
282 mosquitto_publish(mosq, &mqtt_mid_sent, topic, 0, NULL, mqtt_qos, 1); |
|
283 } |
|
284 #endif |
|
285 } |
|
286 |