File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99from bluepy import btle
1010import 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
You can’t perform that action at this time.
0 commit comments