forked from sqozz/sem6000
Add function to set the plug icon
This commit is contained in:
parent
b931fb0a41
commit
271e1bc5bf
15
sem6000.py
15
sem6000.py
|
@ -231,14 +231,21 @@ class SEMSocket():
|
||||||
self.__btle_device = btle_device
|
self.__btle_device = btle_device
|
||||||
|
|
||||||
def handleNotification(self, cHandle, data):
|
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]
|
message_type = data[2]
|
||||||
if message_type == 0x00:
|
if message_type == 0x00:
|
||||||
if data[4] == 0x01:
|
if data[4] == 0x01:
|
||||||
print("Checksum error!")
|
print("Checksum error!")
|
||||||
else:
|
else:
|
||||||
print("Unknown error:", data)
|
print("Unknown error:", data)
|
||||||
elif message_type == 0x01:
|
elif message_type == 0x01: #sync time response
|
||||||
print("Time synced")
|
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
|
elif message_type == 0x02: #set name response
|
||||||
if not data[3:] == b'\x00\x00\x03\xff\xff':
|
if not data[3:] == b'\x00\x00\x03\xff\xff':
|
||||||
print("Set name failed with unknown data: ", end="")
|
print("Set name failed with unknown data: ", end="")
|
||||||
|
@ -271,6 +278,10 @@ class SEMSocket():
|
||||||
self.__btle_device.authenticated = not data[4]
|
self.__btle_device.authenticated = not data[4]
|
||||||
else:
|
else:
|
||||||
print("5th byte of login-response is > 1:", data)
|
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:
|
else:
|
||||||
print ("Unknown message from Handle: 0x" + format(cHandle,'02X') + " Value: "+ format(data))
|
print ("Unknown message from Handle: 0x" + format(cHandle,'02X') + " Value: "+ format(data))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue