mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-20 06:27:01 +01:00
fixed offset in berry driver for new msg format
This commit is contained in:
@@ -167,11 +167,11 @@ class Nextion : Driver
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
# encode using custom protocol 55 BB [payload length] [payload] [crc] [crc]
|
# encode using custom protocol 55 BB [payload length] [payload length] [payload] [crc] [crc]
|
||||||
def encode(payload)
|
def encode(payload)
|
||||||
var b = bytes()
|
var b = bytes()
|
||||||
b += self.header
|
b += self.header
|
||||||
b.add(size(payload), 1) # add size as 1 byte
|
b.add(size(payload), 2) # add size as 2 bytes, little endian
|
||||||
b += bytes().fromstring(payload)
|
b += bytes().fromstring(payload)
|
||||||
var msg_crc = self.crc16(b)
|
var msg_crc = self.crc16(b)
|
||||||
b.add(msg_crc, 2) # crc 2 bytes, little endian
|
b.add(msg_crc, 2) # crc 2 bytes, little endian
|
||||||
@@ -303,13 +303,14 @@ class Nextion : Driver
|
|||||||
self.flash_nextion()
|
self.flash_nextion()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# Recive messages using custom protocol 55 BB [payload length] [payload] [crc] [crc]
|
# Recive messages using custom protocol 55 BB [payload length] [payload length] [payload] [crc] [crc]
|
||||||
if msg[0..1] == self.header
|
if msg[0..1] == self.header
|
||||||
var lst = self.split_55(msg)
|
var lst = self.split_55(msg)
|
||||||
for i:0..size(lst)-1
|
for i:0..size(lst)-1
|
||||||
msg = lst[i]
|
msg = lst[i]
|
||||||
var j = msg[2]+2
|
#var j = msg[2]+2
|
||||||
msg = msg[3..j]
|
var j = size(msg) - 3
|
||||||
|
msg = msg[4..j]
|
||||||
if size(msg) > 2
|
if size(msg) > 2
|
||||||
var jm = string.format("{\"CustomRecv\":\"%s\"}",msg.asstring())
|
var jm = string.format("{\"CustomRecv\":\"%s\"}",msg.asstring())
|
||||||
tasmota.publish_result(jm, "RESULT")
|
tasmota.publish_result(jm, "RESULT")
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ header = binascii.unhexlify('55BB')
|
|||||||
|
|
||||||
print("length:", len(value))
|
print("length:", len(value))
|
||||||
|
|
||||||
length = len(value).to_bytes(1, 'little')
|
length = len(value).to_bytes(2, 'little')
|
||||||
|
|
||||||
bytes_payload = header + length + payload
|
bytes_payload = header + length + payload
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user