-
Notifications
You must be signed in to change notification settings - Fork 294
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
Release/0.14.0 #727
Merged
Merged
Release/0.14.0 #727
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
we have Android support now.
This is a non-standard topic, but communications is for things like email and fax, so it doesn't seem like the right fit. There is already a similar "Topic :: System :: Hardware :: Universal Serial Bus (USB)".
In the CoreBluetooth backend, futures are used to pass results/errors from the delegate callbacks to methods that are waiting for them. The futures are stored as part of the object state so that the delegates can access them. Prior to this change, completed futures were not removed from the object status. This worked most of the time because a second call of the same method would replace the completed future from the prior call. However, in the case of notifications and reads, the same delegate callback is shared with two methods. So when both of these were used, notifications would attempt to complete the already completed read future which raises an InvalidStateError. Fixes #675.
This updates CoreBluetooth to read the changed value in the delegate callback and pass it back to the BleakClient method via the future object. By reading the value in the delegate callback rather than the method scheduled by call_soon_threadsafe(), we ensure that we get the original value from the delegate callback and not a possibly changed value later.
This removes `return True` from several PeripheralDelegate methods. These methods unconditionally return `True`, so we can simplify the code by removing it.
The same delegate callback is used for notifications and reading characteristics. This rearranges the logic so that if there is a read request pending, it will complete the read, otherwise it will trigger a notification callback. Previously, reads would also trigger notification callbacks.
CoreBluetooth callback fixes and cleanups
This changes the WinRT backend to use the GATT session status instead of the actual device connection status. Windows doesn't actually allow explicitly connecting and disconnecting devices. This is handled automatically in the background. So instead, we use the GATT session to act as the connection status. This could potentially fix some issues where devices disconnect briefly after initial connection and before enumerating services.
winrt: use GATT session status
Fixes the following exception: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/Users/david/work/bleak/bleak/backends/corebluetooth/CentralManagerDelegate.py", line 358, in did_disconnect_peripheral callback() File "/Users/david/work/bleak/bleak/backends/corebluetooth/client.py", line 105, in disconnect_callback for future in self._delegate.futures(): File "/Users/david/work/bleak/bleak/backends/corebluetooth/PeripheralDelegate.py", line 77, in futures if self._services_discovered_future AttributeError: 'PeripheralDelegate' object has no attribute '_services_discovered_future' Problem was introduced by commit ad59f6e.
corebluetooth: fix crash on disconnect
macOS has a bug (feature?) where advertising data is no longer received unless one or more service UUIDs are given in scanForPeripheralsWithServices:options:. This implements a new kwarg on `BleakScanner` to allow users to provide such a list of UUIDs. This commit only implements it in the CoreBluetooth backend with other backends to follow. Issue #635.
This implements the service_uuids kwarg in BleakScanner in the BlueZ backend.
This changes set_scanning_filter in the Android backend to raise NotImplementedError since it is not implemented. Also remove async specifier since this is not supposed to be an async function.
This implements the BleakScanner service_uuids kwarg in the Android backend.
This changes how advertising data is cached and combined. Previously, we just cached scan response data to get the local name later. Separate callbacks were called for advertising data and scan response data which makes more work for users who are interested in filtering on data that is split between the two packets. Now, the advertising data and scan response data are both cached together as a single object and this object is used to create the Bleak advertising data structure so that the advertising data seen by Bleak users now contains the information from both advertising data type combined.
This provides an implementation for the BleakScanner service_uuids kwarg in the WinRT backend. As explained in the code comment, it is not possible to use the OS-provided filter mechanism for technical reasons. Fixes #230
corebluetooth: work around macOS 12 scanner bug
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 #635 Signed-off-by: Marc Koderer <[email protected]>
Use predefined service uuids
LEGO has Powered Up Smart Hubs that communicate with BLE. This adds the UUIDs for the official LEGO firmware and 3rd-party Pybricks firmware.
This removes the explicit apartment initialization that breaks apps that have already initialized a single threaded apartment. Fixes: #698
The Android build is failing and I don't have time to fix it. This converts it to a manual trigger so that it doesn't cause pull requests to go red but keeps the job so we can fix it later.
Apparently there are some security concerns about pytest-runner. We weren't using it anyway, so we can remove it.
drop pytest-runner
github: convert android build to manual trigger
requirements: bump bleak-winrt to v1.1.0
uuids: add LEGO UUIDs
Adding 100s of UUIDs to the scan filter on BlueZ causes BlueZ to fail with: Traceback (most recent call last): File "examples/detection_callback.py", line 53, in <module> asyncio.run(main(service_uuids)) File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "examples/detection_callback.py", line 42, in main await scanner.start() File "/home/david/work/pybricks/bleak/bleak/backends/bluezdbus/scanner.py", line 169, in start assert_reply(reply) File "/home/david/work/pybricks/bleak/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply raise BleakDBusError(reply.error_name, reply.body) bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] Operation already in progress `bluetoothd` has to be restarted to clear the error. So don't allow this option on OS other than Mac. Also drop the "all" option and enable it by default based on the macOS version. Fixes: #716
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.
PyPI rejects this classifier.
Using the published trigger is more robust than the created trigger. It allows triggering the workflow from a draft (helpful when a release upload fails and you have to do it over again).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added
service_uuids
kwarg toBleakScanner
. This can be used to work around issue of scanning not working on macOS 12. Fixes Scan peripherals and filter by service UUID #230. Works around No results when scanning on MacOS 12 #635.Changed
bleak-winrt
dependency to v1.1.0. Fixes BleakScannerWinRT import fails in Jupyter Notebook - [WinError -2147417850] Cannot change thread mode after it is set #698.Fixed
InvalidStateError
in CoreBluetooth backend when read and notification of the same characteristic are used. Fixes InvalidStateError after callback #675.