update fork - #1
Closed
vChavezB wants to merge 121 commits into
Closed
Conversation
Ignore Flake E231. It disagrees with Black formatting.
Also fix the type hints while we are touching it (hbldh#1730). Co-authored-by: David Lechner <david@pybricks.com>
Update poetry to v2
Log to stderr instead of stdout by default
Unless there is a know breaking change that actually affects us, having upper bounds on dependencies in libraries can actually be problematic for people using the library who may need newer versions to satisfy other dependencies.
There are known bugs in older versions of the winrt libraries. Drop bleak_winrt and use winrt >= 3.1 on all Python versions now. There were some major breaking API name changes, so there is quite a bit of churn in the code as well as some improvements to type hints.
Fix a leak where service interfaces were not being removed from the service map in the BlueZ manager. This could cause a KeyError on later connections when calling get_services(). Fixes: hbldh#1435
The try/except blocks in the `BluezDBusClient` connect menthod were cleaning up a few things on failure, but not everything. So we need one more level of cleanup that calls _cleanup_all(). Since this is getting too indented, switch to using an AsyncExitStack to handle the cleanup.
It is convenient to create a separate virtual environment for the docs. However, docs builds can fail because it would otherwise recurse into this directory.
This was missed in 808cdf3.
Also reformat to return early on already paired devices for less indentation.
Avoid a deadlock when event doesn't come by allowing it to timeout.
choose all characters up to the last 21. This is needed, since the hci device can have an index >= 10 and hence the number of characters of the prefix is not fixed. Instead, the suffix length is fixed as it comes from https://github.com/bluez/bluez/blob/313de9af36cbbd02d69ba12b8819e28f6a89bbd5/src/gatt-client.c#L2011 https://github.com/bluez/bluez/blob/313de9af36cbbd02d69ba12b8819e28f6a89bbd5/src/gatt-client.c#L1835
Add a new callback that can help discriminate between characteristic value changes due to a notification and ones due to a read response. CoreBluetooth uses the same delegate callback for both and doesn't have any info available in the parameters to know what is the difference between the two. To work around this allow the user to provide a discriminator function that can inspect the value to determine if it was from a notification. This way, if a notification happens while we are waiting for a read response, we don't accidentally send the notification value as the read response value.
Some device need to pair _before_ connecting, otherwise getting services doesn't work correctly. This adds a `pair` parameter to the BleakClient constructor that allows this to happen during the connection process.
This is handled in the pyproject.toml file now.
bleak/backends/bluezdbus/manager.py:713: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance bleak/backends/bluezdbus/manager.py:713: note: Consider using "Sequence" instead, which is covariant
We want to deprecate this, so it shouldn't be part of the public API. It still works thanks to kwargs.
Apparently, can_pair is False if a device is already paired, so we need to reverse the order of the checks in order to avoid raising an exception when trying to pair a device that is already paired.
Recent versions of Python only print the int value of IntEnum. Printing the name is more user-friendly.
Seems to be a bug in the WinRT API where the value returned by the pairing status result is not updated unless we request a device info update first.
This should remove the need for the protection_level kwarg. Not sure if the retry is actually needed since on the device used for testing, it connects at the ENCRYPTION level on the first try.
Now that the default behavior is to try to use the highest protection level, there should no longer be a need to manually set the protection level.
Currently, the bot only adds labels. We want it to also comment so that notifications are sent to issue subscribers.
Bumps [requests](https://github.com/psf/requests) from 2.32.0 to 2.32.4. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](psf/requests@v2.32.0...v2.32.4) --- updated-dependencies: - dependency-name: requests dependency-version: 2.32.4 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
Enable extended advertising scanning by default by setting the `AllowExtendedAdvertisements` property, which defaults to false. https://learn.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.advertisement.bluetoothleadvertisementwatcher.allowextendedadvertisements Signed-off-by: Jordan Yates <jordan@embeint.com>
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.19 to 2.5.0. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](urllib3/urllib3@1.26.19...2.5.0) --- updated-dependencies: - dependency-name: urllib3 dependency-version: 2.5.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
Add some docs and update the sample code to advise users to use a longer timeout when pairing during connect for devices that require user interaction.
Devices with resolvable private addresses will change their address after pairing. So for the address property to return the "correct" value, we need to update the device's address after pairing. Fixes: hbldh#1737
Replace use of address with backend-specific key for the seen_devices dictionary. As we found out, in the BlueZ backend, the address may not match the D-Bus path in the case of private resolvable addresses. So to avoid problems with converting the address to a D-Bus path, we need to use the D-Bus path as the key in the seen_devices dictionary. For good measure, we also use the macOS UUID for the device even when using the use_bdaddr hack to get the actual address. Other backends continue to use the address as the key, as there doesn't appear to be any better alternative.
Release/v1.0.0
Use tomllib instead of tomli when building the docs since they require Python 3.11 to build already. This required some trickery to make isort happy since the docs have a different minimum Python version than the rest of the code.
- unnecessary cast - accessing attributes of None
The BLEDevice() constructor technically isn't considered part of the public API, so a breaking change was made removing `rssi` and `**kwargs`. However, there are users that implement their own backends, so effectively this should be considered public and the breaking change reverted. It looks like all users are passing `rssi` as a keyword argument, so just restoring `**kwargs` should be sufficient. Signed-off-by: David Lechner <david@pybricks.com>
There were some imports that were moved to `bleak.args.bluez` in v1.0 without a proper deprecation period. Restore these imports and add the proper deprecation warnings.
This will let us see which tests are actually being run, which is useful since some tests are skipped on some platforms.
When reading characteristics and descriptors, we can pass the objects directly instead of their handles. This is more efficient because it saves a dictionary lookup to get the object from the handle. No point in doing that lookup if we already have the object.
This file contains hidden or 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
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.
Pull Request Guidelines for Bleak
Before you submit a pull request, check that it meets these guidelines:
CHANGELOG.rst, describing your changes as is specified by theguidelines in that document.
different problems and you are committing them in the same PR. In that case,
consider making several PRs instead.
AUTHORS.rstfile!