-
Notifications
You must be signed in to change notification settings - Fork 306
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
Devices that do not include a service UUID in advertising data cannot be detected on macOS 12.0 to 12.2 unless running in app created by py2app #720
Comments
Very good to keep an issue alive for this. |
I did a deep dive into the logs in Console.app (enabled debug and info messages and filtered on My theory is that Apple is bringing macOS closer inline with iOS. So the comments in the CoreBluetooth docs about foreground and background scanning now apply to macOS as well. In order for your Python script to be considered a foreground app, it has to be a .app with an icon in the dock (doesn't necessarily have to have a visible window) and the app has to have a valid signature (done automatically by The reason scripts that are run in a terminal window fail is because the Python Framework includes a Python.app. The bluetoothd daemon sees that the process running your script is the Python.app but the foreground app is the Terminal.app, so it considers your Python script as a background app and therefore background scanning rules apply. The reason Python includes a Python.app is so that it can launch programs that use graphical user interfaces. So you might think if you just open a window (i.e. Finally, the |
If bleak is running in a .app (e.g. created with py2app), then scanning in macOS 12 works as it did in previous versions, so we don't need to log the error. We can determine this by checking the bundle id since Python itself is a .app and has a bundle id. Related: #720
Hi everyone, Anyone tried a similar workaround with PyInstaller? Cheers |
@dlech have you have any updates on your research on this topic? I've been able to reproduce it with a very minimalist console application on XCode (https://github.com/kdewald/MontereyBluetoothError). My theory is that there is some problem between the TCC and the Bluetooth subsystems on Monterey, as looking at the logs shows that certain authorization steps do not happen when running console applications, even though they have Bluetooth authorization. |
I haven't done any further research. Reiterating what I have already said, the |
Good news! It looks like Apple has fixed the issue in macOS 12.3 Beta (21E5196i). |
Description
This is basically the same issue as #635. That issue was closed because there is now a workaround available in Bleak v0.14.0 that works in most cases. However, there is one case that doesn't have an acceptable workaround. If a device does not include a service UUID in the advertising data, then the advertising data from that device cannot be received in Bleak.
Call to action
This is a regression from previous versions of macOS. Please everyone report this issue to Apple using the Feedback Assistant app. If enough people report it, hopefully they will prioritize fixing it.
Workaround
This isn't great, but it is possible to convert your Python script to an app using py2app to work around the issue. Here is an example
setup.py
that can be uses as a starting point:Then run
python setup.py py2app
to build the .app.If your script does not have a graphical user interface, you can run it with:
See
man open
for more info.Control C doesn't work to stop the program, but you can secondary-click on the icon that is created in the dock and force quit if needed.
The text was updated successfully, but these errors were encountered: