-
Notifications
You must be signed in to change notification settings - Fork 9
Packet Validation
David Bonnes edited this page Jan 5, 2020
·
3 revisions
The basic packet structure is:
aaa XX bbb DEVICE_ID DEVICE_ID DEVICE_ID CODE nnn PAYLOAD.....
The first step of processing a packet is to determine if a packet is valid. Only then is it worth decoding the payload.
The elements of message (received) packets and command (sent) packets include the following fields, represented here as regex expressions (using Python):
a = "(-{3}|\d{3})" # RSSI value or sequence number
b = "( I|RP|RQ| W)" # packet type (note the space before the I, W)
c = "(-{2}:-{6}|\d{2}:\d{6})" # device Id (each packet has three)
d = "[0-9A-F]{4}" # command code
e = "\d{3}" # payload length, in bytes
f = "([0-9A-F]{2})+" # payload, 1-48 bytes in length
The packet structure for (received) messages is:
MESSAGE_REGEX = re.compile(f"^{a} {b} {a} {c} {c} {c} {d} {e} {f}$")
Unlike commands, they include an RSSI field. Thus, an example of packet validation could be:
if not MESSAGE_REGEX.match(raw_packet):
raise ValueError(f"Packet structure is not valid, >> {raw_packet} <<")
if len(raw_packet[50:]) != 2 * int(raw_packet[46:49]):
raise ValueError(f"Packet payload length is incorrect, >> {raw_packet} <<")
if int(raw_packet[46:49]) > 48:
raise ValueError(f"Packet payload length excessive, >> {raw_packet} <<"t)
The packet structure for (sent) commands should be:
COMMAND_REGEX = re.compile(f"^{b} {a} {c} {c} {c} {d} {e} {f}$")
Sent packets do not have a RSSI field. Note that for commands useful types (field {b}
, above) are probably restricted to RQ
and W
.
0001
RF Check0004
Zone name0008
Relay demand0009
Relay failsafe000A
Zone config000C
Zone actuators0016
RF signal test0100
Localisation0404
Zone schedule0418
System fault1030
Mix zone config1060
Battery state10A0
DHW setpoint10E0
Device info1100
Boiler relay info1260
DHW temperature12B0
Window sensor1F09
System Sync1F41
DHW mode1FC9
RF bind1FD4
Opentherm ticker22C9
UFH setpoint22D9
Boiler setpoint2309
Zone setpoint2349
Setpoint override2E04
Controller mode30C9
Zone temperature313F
System datetime3150
Heat demand3220
Opentherm message3B00
Actuator sync3EF0
Actuator info3EF1
Actuator unknown
0002
External sensor0005
Zone management0006
Schedule sync000E
Unknown01D0
Unknown01E9
Unknown042F
Unknown1280
Outdoor humidity1290
Outdoor temp12A0
Indoor humidity2249
Now/next setpoint22D0
UFH unknown22F1
Ventilation unit command22F3
Ventilation unit temp. high2389
Unknown2D49
Unknown3120
Unknown31D9
HVAC Unknown31DA
HVAC Unknown31E0
HVAC Unknown