]> mj.ucw.cz Git - home-hw.git/commitdiff
BSB Daemon: Modulation decoded, byte swaps handled more gracefully
authorMartin Mares <mj@ucw.cz>
Sun, 23 Feb 2025 18:48:21 +0000 (19:48 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 23 Feb 2025 18:48:21 +0000 (19:48 +0100)
bsb/daemon/burrow-bsbd.c

index bc1dc2ed0a0df2137f1868eb10c1e83957b48fa1..78dc6172a920c5e6dad3c9c0488bbd9d8dbc5b97 100644 (file)
@@ -278,26 +278,29 @@ static void process_answer(time_t t, byte *p, uint len)
        if (len < 4)
                return;
 
-       u32 addr = get_u32_be(p);       // Two highest-order bytes are swapped
+       // Two highest-order bytes are swapped
+       u32 addr = (p[0] << 16) | (p[1] << 24) | (p[2] << 8) | p[3];
        p += 4;
        len -= 4;
 
        switch (addr) {
-               case 0x053d0834:
-                       // Boiler modulation (format not decoded yet)
+               case 0x3d050834:
+                       // Burner modulation
                        if (len >= 2) {
                                uint mod = get_u16_be(p);
-                               mqtt_publish("burrow/heating/modulation", "%04x %lld", mod, (long long) t);
+                               if (mod > 100)          // If there is no flame, the value is 0x100; otherwise, it's percentage
+                                       mod = 0;
+                               mqtt_publish("burrow/heating/modulation", "%d %lld", mod, (long long) t);
                        }
                        break;
-               case 0x313d052f:
+               case 0x3d31052f:
                        // Hot water temperature
                        if (len >= 3) {
                                int temp = get_s16_be(p + 1);
                                mqtt_publish("burrow/heating/water/temp", "%.2f %lld", temp / 64., (long long) t);
                        }
                        break;
-               case 0x113d051a:
+               case 0x3d11051a:
                        // Boiler return temperature
                        if (len >= 3) {
                                int temp = get_s16_be(p + 1);
@@ -309,7 +312,7 @@ static void process_answer(time_t t, byte *p, uint len)
 
 static u32 query_list[] = {
        0x3d31052f,     // Hot water temperature
-       0x3d050834,     // Boiler modulation
+       0x3d050834,     // Burner modulation
        0x3d31052f,     // Hot water temperature (measure more frequently)
        0x3d11051a,     // Boiler return temperature
 };