-
Notifications
You must be signed in to change notification settings - Fork 305
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
No results when scanning on MacOS 12 #635
Comments
|
Hello @dlech. Apologies, I should have mentioned I did read the troubleshooting section, open issues, etc. I enabled the debug env var, but it did not show anything interesting:
The code I am running is exactly the detection_callback.py code you pointed to. I did a packet capture, but I'm unable to determine if there is any useful information in there. I can post it somewhere if it would be useful. |
I can look at the packet capture if you attach it to the issue (just put it in a .zip file). |
bleakMacOS.pklg.zip |
Thanks for the info. I'm able to reproduce the issue on my Mac as well now. I also found https://stackoverflow.com/q/69661809/1976323, so I don't think it is just Bleak. I would suggest filing a bug with Apple. |
This thread hints that there is a bug in macOS and they were able to work around it, but I don't think it is open source, so I don't know what the fix is. https://forums.zwift.com/t/macos-monterey-cannot-establish-bluetooth-connection/554193/27 |
I tried this workaround but it doesn't seem to make a difference. |
Confirming this is still an issue in macOS 13 |
Just want to echo that I'm encountering the same issue in monterey. |
I see there are changes on https://github.com/ronaldoussoren/pyobjc, but not a new version since Jun 7, 2021. Probably this could help to solve the issue. |
What specific changes might be related to Bluetooth? I have already tried https://pypi.org/project/pyobjc/8.0b1/. |
PyObjC v8.0 is out now and it doesn't fix the problem |
I can conform that. This really needs to be fixed! It's a showstopper for me |
Please report the issue to Apple using the Feedback Assistant app. I'm not sure what else we can do since the problem seems to come from an undocumented change in the OS. If enough people report the issue, maybe they will prioritize it. |
Can someone who understands this help me wrap my head around why I can still scan for devices using Chrome's Web Bluetooth, but can't with bleak? Is there somehow a different set of library functions exposed in c++? Is this a bug at the pyobjc level? I've been trying to read the chromium source code but must admit I'm struggling. |
I am unfamiliar with the framework that Web Bluetooth uses but bleak is built on top of Core Bluetooth which is currently broken in macOS Monterey... |
Since tools such as "LightBlue", which I like to use to develop in the BLE environment, and others work perfectly, the fault - in my humble opinion - is more likely to be with the PyObjc Framework CoreBlueooth or even within Bleak. Stupid question: I digged into the code "behind"
and
See bleak/bleak/backends/scanner.py Line 166 in fc07589
How can this method ever return a list of devices? It has no return. However, no exception is raised for me either. |
Ah, sorry. Stupid me. It's abstract. I need to look in the respective implementation which is here: bleak/bleak/backends/corebluetooth/scanner.py Line 115 in e492699
|
Okay, thx! |
On macos the service_uuids need to be filled. Main issue for beginners is to retrieve some valid uuids. Instead of using an external tool like nRF we could use predefined ones in bleak/uuids. Implementation works with 128bit and 16bit UUIDs. Related-to hbldh#635 Signed-off-by: Marc Koderer <marc@koderer.com>
The current implementation works also with 16-bit. For 16-bit the mac implementation will automatically extend it by the default 128-bit mask:
|
Thanks for sharing. I'm surprised it works even works from the command line. 👍 |
On macos the service_uuids need to be filled. Main issue for beginners is to retrieve some valid uuids. Instead of using an external tool like nRF we could use predefined ones in bleak/uuids. Implementation works with 128bit and 16bit UUIDs. Related-to hbldh#635 Signed-off-by: Marc Koderer <marc@koderer.com>
On macos the service_uuids need to be filled. Main issue for beginners is to retrieve some valid uuids. Instead of using an external tool like nRF we could use predefined ones in bleak/uuids. Implementation works with 128bit and 16bit UUIDs. Related-to hbldh#635 Signed-off-by: Marc Koderer <marc@koderer.com>
Not sure if this is already known here but Bluetility UI works on my mac without any specific service uuids. |
I think the difference is that it is an app (and possibly in addition to that it requests permission) and is not a command line tool like Python. There are several other comments in this issue that also noticed this that may be of interest. |
Added ----- * Added ``service_uuids`` kwarg to ``BleakScanner``. This can be used to work around issue of scanning not working on macOS 12. Fixes #230. Works around #635. * Added UUIDs for LEGO Powered Up Smart Hubs. Changed ------- * Changed WinRT backend to use GATT session status instead of actual device connection status. * Changed handling of scan response data on WinRT backend. Advertising data and scan response data is now combined in callbacks like other platforms. * Updated ``bleak-winrt`` dependency to v1.1.0. Fixes #698. Fixed ----- * Fixed ``InvalidStateError`` in CoreBluetooth backend when read and notification of the same characteristic are used. Fixes #675. * Fixed reading a characteristic on CoreBluetooth backend also triggers notification callback. * Fixed in Linux, scanner callback not setting metadata parameters. Merged #715.
Added ----- * Added ``service_uuids`` kwarg to ``BleakScanner``. This can be used to work around issue of scanning not working on macOS 12. Fixes #230. Works around #635. * Added UUIDs for LEGO Powered Up Smart Hubs. Changed ------- * Changed WinRT backend to use GATT session status instead of actual device connection status. * Changed handling of scan response data on WinRT backend. Advertising data and scan response data is now combined in callbacks like other platforms. * Updated ``bleak-winrt`` dependency to v1.1.0. Fixes #698. Fixed ----- * Fixed ``InvalidStateError`` in CoreBluetooth backend when read and notification of the same characteristic are used. Fixes #675. * Fixed reading a characteristic on CoreBluetooth backend also triggers notification callback. * Fixed in Linux, scanner callback not setting metadata parameters. Merged #715.
FYI, I've added a summary of the findings of this issue with additional insights at #720 (comment). |
Any updates on this issue? I'm currently experiencing problems trying to connect to a BLE device using a script with Bleak in Python. |
Apple fixed the bug in macOS 12.2. If you still have problems the best way to get help is to start a new discussion and include you code, error messages and logs. |
Description
I installed bleak via pip, and used the scanning example from the docs. When the code is run, no devices are found. I can run a different BLE scanner and see many devices. Running as root doesn't change anything.
Happy to help investigate, but I'm not sure where to go from here.
The text was updated successfully, but these errors were encountered: