#undef P
};
+static int get_s16_be(const byte *x)
+{
+ int val = get_u16_be(x);
+ if (val >= 0x8000)
+ return val - 0x10000;
+ else
+ return val;
+}
+
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++) {
switch (addr) {
case 0x05000219:
if (len >= 4) {
- uint temp = get_u16_be(p);
+ 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.);
case 0x05000229:
// AGU.2 status
if (len >= 2) {
- uint temp = get_u16_be(p);
+ int temp = get_s16_be(p);
mqtt_publish("burrow/heating/circuit1/mix-temp", "%.2f", temp / 64.);
}
break;
case 0x3d2d0215:
// Room 1 status
if (len >= 2) {
- uint temp = get_u16_be(p);
+ int temp = get_s16_be(p);
mqtt_publish("burrow/heating/circuit1/room-temp", "%.2f", temp / 64.);
}
break;
case 0x3e2e0215:
// Room 2 status
if (len >= 2) {
- uint temp = get_u16_be(p);
+ int temp = get_s16_be(p);
mqtt_publish("burrow/heating/circuit2/room-temp", "%.2f", temp / 64.);
}
break;