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;
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;
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;
}
}