From f488869f3dbbf7868373c85fce8be333900d3fcb Mon Sep 17 00:00:00 2001 From: sqozz Date: Wed, 6 May 2020 21:09:29 +0200 Subject: [PATCH] Add function to set icon --- sem6000.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sem6000.py b/sem6000.py index d5f8f1d..9b7366e 100644 --- a/sem6000.py +++ b/sem6000.py @@ -105,6 +105,14 @@ class SEMSocket(): self.authenticated = self.authenticated and success return success + def setIcon(self, iconIdx): + cmd = bytearray([0x0f]) + payload = bytearray([0x00, 0x03, iconIdx, 0x00, 0x00, 0x00, 0x00]) + msg = self.BTLEMessage(self, cmd, payload) + + success = msg.send() + return success + @property def name(self): self._name = self._name_char.read().decode("UTF-8") @@ -293,7 +301,13 @@ class SEMSocket(): 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': + if data[3:6] == b'\x00\x03\x00': + # LED set successfully + pass + elif data[3:6] == b'\x00\x05\x00': + # Icon set successfully + pass + else: print("Unknown response for setting icon: ", end="") print(data[3:]) else: