Skip to content

Commit f696fe6

Browse files
committed
s3: add logging to pair
1 parent 2c84c06 commit f696fe6

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

tion/s3.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from bluepy import btle
1010
import time
1111

12+
logging.basicConfig(level=logging.DEBUG)
1213
_LOGGER = logging.getLogger(__name__)
1314

1415

@@ -40,11 +41,19 @@ def __try_get_state(self) -> bytearray:
4041
def pair(self):
4142
def get_pair_command() -> bytearray:
4243
return self.create_command(self.command_PAIR)
43-
44-
self._btle.connect(self.mac, btle.ADDR_TYPE_RANDOM)
44+
_LOGGER.setLevel("DEBUG")
45+
_LOGGER.debug("Pairing")
46+
_LOGGER.debug("Connecting")
47+
self._connect()
48+
_LOGGER.debug("Collecting characteristic")
4549
characteristic = self._btle.getServiceByUUID(self.uuid).getCharacteristics()[0]
50+
_LOGGER.debug("Got characteristic %s for pairing", str(characteristic))
51+
pair_command = get_pair_command()
52+
_LOGGER.debug("Sending pair command %s to %s", bytes(pair_command).hex(), str(characteristic))
4653
characteristic.write(bytes(get_pair_command()))
47-
self._btle.disconnect()
54+
_LOGGER.debug("Disconnecting")
55+
self._disconnect()
56+
_LOGGER.debug("Done!")
4857

4958
def create_command(self, command: int) -> bytearray:
5059
command_special = 1 if command == self.command_PAIR else 0

0 commit comments

Comments
 (0)