I'm using the library to establish connections to peripherals. Trying to connect to random devices (as this point in my development any target does the job) I get the following error:
2021-01-07 21:40:41,803 [WARNI] Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/luc/custom_file.py", line 159, in ble_get_battery_level
peripheral = self.ble_peripheral
File "/home/luc/custom_file.py", line 377, in ble_peripheral
self._ble_peripheral = bluepy.btle.Peripheral(
File "/home/luc/.venv/lib/python3.8/site-packages/bluepy/btle.py", line 411, in __init__
self._connect(deviceAddr, addrType, iface, timeout)
File "/home/luc/.venv/lib/python3.8/site-packages/bluepy/btle.py", line 464, in _connect
while rsp['state'][0] == 'tryconn':
TypeError: 'NoneType' object is not subscriptable
I have opened the source code and it seems that rsp becomes Noneon this line, on the first iteration.
while rsp['state'][0] == 'tryconn':
logging.warning("Looping %r %r %r", rsp, rsp["state"], rsp["state"][0])
rsp = self._getResp('stat', timeout) # <-- this line
logging.warning("After loop %r", rsp)
Good morning,
I'm using the library to establish connections to peripherals. Trying to connect to random devices (as this point in my development any target does the job) I get the following error:
I have opened the source code and it seems that
rsp
becomesNone
on this line, on the first iteration.Here is the logged trace:
None
being one of_getResp()
method's return values I guess_connect()
should expect it and step out of the loop gracefully.