From 271e1bc5bfd5cbd74eee476a03fcf285ee919d21 Mon Sep 17 00:00:00 2001 From: sqozz Date: Wed, 6 May 2020 19:58:50 +0200 Subject: [PATCH] Add function to set the plug icon --- sem6000.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sem6000.py b/sem6000.py index 1a2438a..fe7b397 100644 --- a/sem6000.py +++ b/sem6000.py @@ -231,14 +231,21 @@ class SEMSocket(): self.__btle_device = btle_device def handleNotification(self, cHandle, data): + if len(data) <= 3: + print("Notification data seems invalid or incomplete. Could not parse: ", end="") + print(data) + return + message_type = data[2] if message_type == 0x00: if data[4] == 0x01: print("Checksum error!") else: print("Unknown error:", data) - elif message_type == 0x01: - print("Time synced") + elif message_type == 0x01: #sync time response + if not data[3:] == b'\x00\x00\x02\xff\xff': + print("Time synced failed with unknown data: ", end="") + print(data) elif message_type == 0x02: #set name response if not data[3:] == b'\x00\x00\x03\xff\xff': print("Set name failed with unknown data: ", end="") @@ -271,6 +278,10 @@ class SEMSocket(): self.__btle_device.authenticated = not data[4] else: print("5th byte of login-response is > 1:", data) + elif message_type == 0x0f: #set icon response + if not data[3:] == b'\x00\x03\x00\x13\xff\xff': + print("Unknown response for setting icon: ", end="") + print(data[3:]) else: print ("Unknown message from Handle: 0x" + format(cHandle,'02X') + " Value: "+ format(data))