From 6c83bccbde6efd6fe65cacbc538e98ca18842f35 Mon Sep 17 00:00:00 2001 From: sqozz Date: Fri, 14 Jun 2019 19:51:47 +0200 Subject: [PATCH] Use setter for init BTLE payload data --- sem6000.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/sem6000.py b/sem6000.py index 5079212..a5d4989 100644 --- a/sem6000.py +++ b/sem6000.py @@ -48,10 +48,8 @@ class SEMSocket(): payload = bytearray() payload.append(0x00) payload.append(0x00) - payload.append(int(self.password[0])) - payload.append(int(self.password[1])) - payload.append(int(self.password[2])) - payload.append(int(self.password[3])) + for i in range(4): + payload.append(int(self.password[i])) payload.append(0x00) payload.append(0x00) payload.append(0x00) @@ -64,14 +62,10 @@ class SEMSocket(): payload = bytearray() payload.append(0x00) payload.append(0x01) - payload.append(int(newPassword[0])) - payload.append(int(newPassword[1])) - payload.append(int(newPassword[2])) - payload.append(int(newPassword[3])) - payload.append(int(self.password[0])) - payload.append(int(self.password[1])) - payload.append(int(self.password[2])) - payload.append(int(self.password[3])) + for i in range(4): + payload.append(int(self.newPassword[i])) + for i in range(4): + payload.append(int(self.password[i])) self.password = newPassword msg = self.BTLEMessage(self, cmd, payload) msg.send() @@ -138,8 +132,8 @@ class SEMSocket(): def __init__(self, btle_device, cmd=bytearray(), payload=bytearray()): self.__btle_device = btle_device - self.__cmd = cmd - self.__payload = payload + self.cmd = cmd + self.payload = payload @property def cmd(self):