Skip to content

Commit 3aa3d9f

Browse files
committed
refactor(S3): turn get_pair_command and get_status_command to methods
This function looks like properties.
1 parent dfcb935 commit 3aa3d9f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tion_btle/s3.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,26 @@ def __init__(self, mac: str):
4040
self._dummy_data = bytearray([0xb3, 0x10, 0x24, 0x14, 0x03, 0x00, 0x15, 0x14, 0x14, 0x8f, 0x00, 0x0c,
4141
0x0a, 0x00, 0x4b, 0x0a, 0x00, 0x33, 0x00, 0x5a])
4242

43+
@property
44+
def pair_command(self) -> bytearray:
45+
return self.create_command(self.command_PAIR)
46+
47+
@property
48+
def get_status_command(self) -> bytearray:
49+
return self.create_command(self.command_REQUEST_PARAMS)
50+
4351
def __try_get_state(self) -> bytearray:
4452
response = self._btle.getServiceByUUID(self.uuid).getCharacteristics()[0].read()
4553
_LOGGER.debug("Response is %s", bytes(response).hex())
4654
return response
4755

4856
def pair(self):
49-
def get_pair_command() -> bytearray:
50-
return self.create_command(self.command_PAIR)
51-
5257
_LOGGER.setLevel("DEBUG")
5358
_LOGGER.debug("Pairing")
5459
_LOGGER.debug("Connecting")
5560
self._do_action(self._connect)
5661
_LOGGER.debug("Sending pair command")
57-
self._send_request(get_pair_command())
62+
self._send_request(self.pair_command)
5863
_LOGGER.debug("Disconnecting")
5964
self._disconnect()
6065
_LOGGER.debug("Done!")
@@ -65,12 +70,8 @@ def create_command(self, command: int) -> bytearray:
6570
self.command_suffix])
6671

6772
def _get_data_from_breezer(self) -> bytearray:
68-
def get_status_command() -> bytearray:
69-
return self.create_command(self.command_REQUEST_PARAMS)
70-
7173
have_data_from_breezer: bool = False
72-
73-
self._do_action(self._try_write, request=get_status_command())
74+
self._do_action(self._try_write, request=self.get_status_command)
7475

7576
i = 0
7677
try:

0 commit comments

Comments
 (0)