va_end(args);
}
+static void mqtt_publish_ephemeral(const char *topic, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+
+ if (mqtt_connected) {
+ char m[256];
+ int l = vsnprintf(m, sizeof(m), fmt, args);
+ int err = mosquitto_publish(mosq, NULL, topic, l, m, 0, false);
+ if (err != MOSQ_ERR_SUCCESS)
+ msg(L_ERROR, "Mosquitto: Publish failed, error=%d", err);
+ }
+
+ va_end(args);
+}
+
static void mqtt_conn_callback(struct mosquitto *mosq UNUSED, void *obj UNUSED, int status)
{
if (!status) {
{
for (uint i=0; i < ARRAY_SIZE(stat_names) && 4*i + 3 < (uint) len; i++) {
char item[64];
- snprintf(item, sizeof(item), "burrow/bsb/stats/%s", stat_names[i]);
+ snprintf(item, sizeof(item), "bsb/stats/%s", stat_names[i]);
mqtt_publish(item, "%u", (uint) get_u32_le(resp+4*i), t);
}
}
char hex[3*len + 1];
mem_to_hex(hex, pkt, len, ' ');
- mqtt_publish("bsb/frame", "%s", hex, t);
+ mqtt_publish_ephemeral("bsb/frame", "%s", hex, t);
msg(L_DEBUG, "<< %s", hex);