25.06.2025, 07:44
Try this:
If you have multiple HDL relay devices then you need to check packet.srcdevice value to determine the status group address.
Code:
if not sock then
require('user.hdl')
sock = socket.udp()
sock:settimeout(60)
sock:setsockname('*', 6000)
HDL.init()
end
data = sock:receive()
if data then
packet, err = HDL.decode(data)
if packet then
if packet.opcode == HDL.cmd.chanregreply then
channel, _, value = packet.additional:byte(1, 3)
if channel == 1 then
grp.checkupdate('1/1/1', value)
elseif chanel == 2 then
grp.checkupdate('1/1/2', value)
elseif chanel == 3 then
grp.checkupdate('1/1/3', value)
elseif chanel == 4 then
grp.checkupdate('1/1/4', value)
end
end
-- packet.additional = lmcore.strtohex(packet.additional)
-- log('HDL packet', packet)
else
log('HDL error', err)
end
end
If you have multiple HDL relay devices then you need to check packet.srcdevice value to determine the status group address.