Use setter for init BTLE payload data

This commit is contained in:
sqozz 2019-06-14 19:51:47 +02:00
parent 4f8b698a14
commit 6c83bccbde

View file

@ -48,10 +48,8 @@ class SEMSocket():
payload = bytearray() payload = bytearray()
payload.append(0x00) payload.append(0x00)
payload.append(0x00) payload.append(0x00)
payload.append(int(self.password[0])) for i in range(4):
payload.append(int(self.password[1])) payload.append(int(self.password[i]))
payload.append(int(self.password[2]))
payload.append(int(self.password[3]))
payload.append(0x00) payload.append(0x00)
payload.append(0x00) payload.append(0x00)
payload.append(0x00) payload.append(0x00)
@ -64,14 +62,10 @@ class SEMSocket():
payload = bytearray() payload = bytearray()
payload.append(0x00) payload.append(0x00)
payload.append(0x01) payload.append(0x01)
payload.append(int(newPassword[0])) for i in range(4):
payload.append(int(newPassword[1])) payload.append(int(self.newPassword[i]))
payload.append(int(newPassword[2])) for i in range(4):
payload.append(int(newPassword[3])) payload.append(int(self.password[i]))
payload.append(int(self.password[0]))
payload.append(int(self.password[1]))
payload.append(int(self.password[2]))
payload.append(int(self.password[3]))
self.password = newPassword self.password = newPassword
msg = self.BTLEMessage(self, cmd, payload) msg = self.BTLEMessage(self, cmd, payload)
msg.send() msg.send()
@ -138,8 +132,8 @@ class SEMSocket():
def __init__(self, btle_device, cmd=bytearray(), payload=bytearray()): def __init__(self, btle_device, cmd=bytearray(), payload=bytearray()):
self.__btle_device = btle_device self.__btle_device = btle_device
self.__cmd = cmd self.cmd = cmd
self.__payload = payload self.payload = payload
@property @property
def cmd(self): def cmd(self):