From e22c1cb8ebcb818171bc66a7ba4c4b403c46edf0 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 1 Mar 2020 17:24:08 +0100 Subject: [PATCH] BSB Daemon: MQTT timestamps --- bsb/daemon/burrow-bsbd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bsb/daemon/burrow-bsbd.c b/bsb/daemon/burrow-bsbd.c index 98fec4c..b775924 100644 --- a/bsb/daemon/burrow-bsbd.c +++ b/bsb/daemon/burrow-bsbd.c @@ -188,11 +188,11 @@ static void process_stats(time_t t, byte *resp, uint len) for (uint i=0; i < ARRAY_SIZE(stat_names) && 4*i + 3 < (uint) len; i++) { char item[64]; snprintf(item, sizeof(item), "bsb/stats/%s", stat_names[i]); - mqtt_publish(item, "%u", (uint) get_u32_le(resp+4*i), t); + mqtt_publish(item, "%u %lld", (uint) get_u32_le(resp+4*i), (long long) t); } } -static void process_info(byte *p, uint len) +static void process_info(time_t t, byte *p, uint len) { if (len < 4) return; @@ -206,42 +206,42 @@ static void process_info(byte *p, uint len) if (len >= 4) { int temp = get_s16_be(p); uint press = get_u16_be(p + 2); - mqtt_publish("burrow/heating/outside-temp", "%.2f", temp / 64.); - mqtt_publish("burrow/heating/water-pressure", "%.1f", press / 10.); + mqtt_publish("burrow/heating/outside-temp", "%.2f %lld", temp / 64., (long long) t); + mqtt_publish("burrow/heating/water-pressure", "%.1f %lld", press / 10., (long long) t); } break; case 0x05000229: // AGU.2 status if (len >= 2) { int temp = get_s16_be(p); - mqtt_publish("burrow/heating/circuit1/mix-temp", "%.2f", temp / 64.); + mqtt_publish("burrow/heating/circuit1/mix-temp", "%.2f %lld", temp / 64., (long long) t); } break; case 0x05040227: // AGU.2 control if (len >= 2) { uint m = get_u16_be(p); - mqtt_publish("burrow/heating/circuit1/mix-valve", "%u", m); + mqtt_publish("burrow/heating/circuit1/mix-valve", "%u %lld", m, (long long) t); } break; case 0x3d2d0215: // Room 1 status if (len >= 2) { int temp = get_s16_be(p); - mqtt_publish("burrow/heating/circuit1/room-temp", "%.2f", temp / 64.); + mqtt_publish("burrow/heating/circuit1/room-temp", "%.2f %lld", temp / 64., (long long) t); } break; case 0x3e2e0215: // Room 2 status if (len >= 2) { int temp = get_s16_be(p); - mqtt_publish("burrow/heating/circuit2/room-temp", "%.2f", temp / 64.); + mqtt_publish("burrow/heating/circuit2/room-temp", "%.2f %lld", temp / 64., (long long) t); } break; } } -static void process_answer(byte *p, uint len) +static void process_answer(time_t t, byte *p, uint len) { if (len < 4) return; @@ -285,10 +285,10 @@ static void process_frame(time_t t, byte *pkt, uint len) switch (pkt[BF_OP]) { case BSB_OP_INFO: - process_info(body, body_len); + process_info(t, body, body_len); break; case BSB_OP_ANSWER: - process_answer(body, body_len); + process_answer(t, body, body_len); break; } } -- 2.39.2