Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bleak troubleshooting #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Bleak troubleshooting #70

wants to merge 2 commits into from

Conversation

undera
Copy link
Owner

@undera undera commented Jun 30, 2020

No description provided.

@LasseD
Copy link

LasseD commented Jul 3, 2020

OS: MacOS 10.14.6

With the latest version of this PR against bleak 0.6.1 I got the same issue as on the master branch: "Bluetooth device is turned off". However. Updating to the recently released 0.7.1 changes the issue at hand.

When running examples/demo.py it does not recognise the Move Hub, so it shows the:

...
10084 DEBUG hub Waiting for builtin devices to appear: (None, None, None, None, None, None, None)
10186 DEBUG hub Waiting for builtin devices to appear: (None, None, None, None, None, None, None)
10290 DEBUG hub Waiting for builtin devices to appear: (None, None, None, None, None, None, None)

until timeout.

Changing back to the master branch gives the following log:

INFO:root:Trying get_connection_bluepy
INFO:root:Trying get_connection_bluegiga
INFO:root:Trying get_connection_gatt
INFO:root:Trying get_connection_bleak
INFO:comms-bleak:Discovering devices... Press green button on Hub
WARNING:bleak.backends.corebluetooth.CentralManagerDelegate:CentralManagerDelegate is not compliant
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManagerDidUpdateState_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Bluetooth powered on
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -42 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -42 (kCBAdvData <nsdict_keys(['kCBAdvDataLocalName', 'kCBAdvDataChannel', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: 80 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: 80 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 6...1: Unknown @ RSSI: -87 (kCBAdvData <nsdict_keys(['kCBAdvDataServiceData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 6...1: Unknown @ RSSI: -87 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -41 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -49 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -41 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 3...7: LEGO Move Hub @ RSSI: 80 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataChannel'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 3...7: LEGO Move Hub @ RSSI: -40 (kCBAdvData <nsdict_keys(['kCBAdvDataLocalName', 'kCBAdvDataChannel', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
INFO:comms:Found LEGO Move Hub at A...9
INFO:comms-bleak:Device matched: <bleak.backends.corebluetooth.device.BLEDeviceCoreBluetooth object at 0x106e4dd90>
WARNING:bleak.backends.corebluetooth.CentralManagerDelegate:CentralManagerDelegate is not compliant
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManagerDidUpdateState_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Bluetooth powered on
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 3...7: LEGO Move Hub @ RSSI: -41 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataChannel'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 3...7: LEGO Move Hub @ RSSI: -42 (kCBAdvData <...'])>)
WARNING:hub:Got only these devices: (None, None, None, None, None, None, None)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pylgbst/comms/cbleak.py", line 50, in
self._connection_thread = threading.Thread(target=lambda: asyncio.run(self._bleak_thread()))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pylgbst/comms/cbleak.py", line 60, in _bleak_thread
await bleak.connect(self.hub_mac, self.hub_name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pylgbst/comms/cbleak.py", line 157, in connect
status = await self._client.connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bleak/backends/corebluetooth/client.py", line 77, in connect
raise BleakError(
bleak.exc.BleakError: Device with address A...9 was not found

After the last line, demo.py simply hangs.

@undera
Copy link
Owner Author

undera commented Jul 4, 2020

I have just tried with master branch on my Linux with bleak 0.7.1, and demo.py worked fine for me. This PR version does not work, still. What I've noticed, is that I have to make sure hub is shut down before each attempt. Otherwise it sometimes "still connected to PC" and does not react to commands.

@AlexNetman
Copy link

Trying with MacOS 10.15
python3 demo.py
image
Should I probably grant some extra permissions that Catalina usually requires?

@undera
Copy link
Owner Author

undera commented Aug 3, 2020

When debugging, you need to set logging level to DEBUG and also make use of bleak connection, instead of default autodetector.

@techbuddy01
Copy link

OS: MacOS 10.14.6

With the latest version of this PR against bleak 0.6.1 I got the same issue as on the master branch: "Bluetooth device is turned off". However. Updating to the recently released 0.7.1 changes the issue at hand.

When running examples/demo.py it does not recognise the Move Hub, so it shows the:

...
10084 DEBUG hub Waiting for builtin devices to appear: (None, None, None, None, None, None, None)
10186 DEBUG hub Waiting for builtin devices to appear: (None, None, None, None, None, None, None)
10290 DEBUG hub Waiting for builtin devices to appear: (None, None, None, None, None, None, None)

until timeout.

Changing back to the master branch gives the following log:

INFO:root:Trying get_connection_bluepy
INFO:root:Trying get_connection_bluegiga
INFO:root:Trying get_connection_gatt
INFO:root:Trying get_connection_bleak
INFO:comms-bleak:Discovering devices... Press green button on Hub
WARNING:bleak.backends.corebluetooth.CentralManagerDelegate:CentralManagerDelegate is not compliant
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManagerDidUpdateState_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Bluetooth powered on
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -42 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -42 (kCBAdvData <nsdict_keys(['kCBAdvDataLocalName', 'kCBAdvDataChannel', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: 80 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: 80 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 6...1: Unknown @ RSSI: -87 (kCBAdvData <nsdict_keys(['kCBAdvDataServiceData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 6...1: Unknown @ RSSI: -87 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -41 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -49 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device A...9: LEGO Move Hub @ RSSI: -41 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 3...7: LEGO Move Hub @ RSSI: 80 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataChannel'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 3...7: LEGO Move Hub @ RSSI: -40 (kCBAdvData <nsdict_keys(['kCBAdvDataLocalName', 'kCBAdvDataChannel', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
INFO:comms:Found LEGO Move Hub at A...9
INFO:comms-bleak:Device matched: <bleak.backends.corebluetooth.device.BLEDeviceCoreBluetooth object at 0x106e4dd90>
WARNING:bleak.backends.corebluetooth.CentralManagerDelegate:CentralManagerDelegate is not compliant
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManagerDidUpdateState_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Bluetooth powered on
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:centralManager_didDiscoverPeripheral_advertisementData_RSSI_
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 3...7: LEGO Move Hub @ RSSI: -41 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataChannel'])>)
DEBUG:bleak.backends.corebluetooth.CentralManagerDelegate:Discovered device 3...7: LEGO Move Hub @ RSSI: -42 (kCBAdvData <...'])>)
WARNING:hub:Got only these devices: (None, None, None, None, None, None, None)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pylgbst/comms/cbleak.py", line 50, in
self._connection_thread = threading.Thread(target=lambda: asyncio.run(self._bleak_thread()))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pylgbst/comms/cbleak.py", line 60, in _bleak_thread
await bleak.connect(self.hub_mac, self.hub_name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pylgbst/comms/cbleak.py", line 157, in connect
status = await self._client.connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bleak/backends/corebluetooth/client.py", line 77, in connect
raise BleakError(
bleak.exc.BleakError: Device with address A...9 was not found

After the last line, demo.py simply hangs.

@LasseD , did you get to resolve this? I'm running into a similar issue.

28354	DEBUG	bleak.backends.corebluetooth.CentralManagerDelegate	Discovered device 1188A870-7A64-4D0C-AA9B-BCB2BF6BF6D2: Unknown @ RSSI: -67 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
28913	WARNING	bleak.backends.corebluetooth.CentralManagerDelegate	CentralManagerDelegate is not compliant
28924	DEBUG	bleak.backends.corebluetooth.CentralManagerDelegate	centralManagerDidUpdateState_
28925	DEBUG	bleak.backends.corebluetooth.CentralManagerDelegate	Bluetooth powered on
28938	DEBUG	bleak.backends.corebluetooth.CentralManagerDelegate	centralManager_didDiscoverPeripheral_advertisementData_RSSI_
28938	DEBUG	bleak.backends.corebluetooth.CentralManagerDelegate	Discovered device 20410C0E-621F-464A-8BA4-A73E2DD3234D: Unknown @ RSSI: -89 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData'])>)
28959	DEBUG	bleak.backends.corebluetooth.CentralManagerDelegate	centralManager_didDiscoverPeripheral_advertisementData_RSSI_
28959	DEBUG	bleak.backends.corebluetooth.CentralManagerDelegate	Discovered device D3EA2946-BA52-4CB3-A5A8-7BB33FB3D1F6: Unknown @ RSSI: -87 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataIsConnectable'])

@LasseD
Copy link

LasseD commented Aug 24, 2020

No. Unfortunately I have not solved it. My approach has been to try to find a python library that would work with any of the LEGO peripherals (Powered Up, SBrick, PFx Brick) every single one of them and their branches fail on Mac. I am seriously considering investing in a Raspberry PI just to see if anything will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants