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

Release/0.21.0 #1410

Merged
merged 36 commits into from
Sep 2, 2023
Merged

Release/0.21.0 #1410

merged 36 commits into from
Sep 2, 2023

Conversation

dlech
Copy link
Collaborator

@dlech dlech commented Sep 2, 2023

Added

  • Added bleak.uuids.normalize_uuid_16() function.
  • Added bleak.uuids.normalize_uuid_32() function.
  • Added advertisement_data() async iterator method to BleakScanner. Merged BleakScanner: Add async iterator scanning capability #1361.
  • Added type hints for kwargs on BleakScanner class methods.
  • Added support for Python 3.12.

Changed

Fixed

dlech and others added 30 commits April 19, 2023 17:06
The error messages were reporting something like:

    <_bleak_winrt_Windows_Devices_Bluetooth_GenericAttributeProfile.GattDeviceService object at 0x00000206F9189750>

This is the repr of the service object which isn't very useful. Change
the error message to include some useful identification properties
instead.
We had a hard-coded list of services know to return an access denied
error when attempting to enumerate characteristics. However, since
we don't know Windows internals, the list was not exhaustive and it
could also change in the future.

Instead, we can just check for the access denied error and skip any
service that returns that error which should also handle additional
services we don't know about yet.

Fixes: #1291
Bumps [requests](https://github.com/psf/requests) from 2.28.1 to 2.31.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](psf/requests@v2.28.1...v2.31.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Also fix missing `:` and don't create unnecessary instance of BleakScanner.

Fixes: #1334
Function `register_detection_callback()` of `BaseBleakScanner` ensures
that `_callback` is a synchronous function, so change its typing
accordingly.

Additionally, passing `Awaitable` to `asyncio.create_task()` results in
warning:
  Unexpected type(s): (Awaitable[None] | None)
  Possible type(s): (Generator[Any, None, Any] | Coroutine)
Every coroutine is an awaitable, but not every awaitable is a coroutine,
so change the `AdvertisementDataFilter` type accordingly.
This fixes a possible race condition where `_stopped_handler()` is scheduled via `call_soon_threadsafe()`, then `self.watcher` is set to none before the callback is actually run.

Fixes: #1330
Bumps [pygments](https://github.com/pygments/pygments) from 2.13.0 to 2.15.0.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](pygments/pygments@2.13.0...2.15.0)

---
updated-dependencies:
- dependency-name: pygments
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
We are considering adding an async iterator that can be used to handle
advertisement data as it is received. It will be trivial for users to
create multiple parallel iterators, so instead of disallowing it, this
prepares the way to allow multiple simultaneous subscribers.
It has been noted that IntEnum.__str__() has changed in Python 3.11 and
now only prints integers instead of the name of the enum. This changes
all logging messages that use enums in the WinRT backend to use %r for
repr() so that we get both the name and the value.

Fixes: #1284

Also changes uses of str.format() to f-strings and remove uses of
format string from loggers while we are touching this.
This fixes several issues with the implementation. Notably, on Linux
trying to scan and connect to two devices at the same time results in:

    bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] Operation already in progress

This is worked around by using an asyncio.Lock to ensure only one scan
and connect is called at a time.

Fixes: #1036

Also fixes error due to main() not being a coroutine:

    ValueError: a coroutine was expected, got <_GatheringFuture pending>

Fixes: #1288

Finally, command line args are added to make it easy to run the example
without modifying the code.
This adds additional utility functions for converting 16-bit and 32-bit
int values to Bleak's normalized UUID str format.

Issue: #1342
This simplifies some uses of UUIDs by taking advantage of the short
string form or utility functions.
Use `*` instead of `-` to be consistent.
Previously, some backends would select the "best" response type based
on the reported characteristics while some did not. For the ones that
didn't, it was a commonly reported issue for the write to not work.

This adds a recommendation to the docs to always be explicit about
the requested response type and moves the common logic for picking
the "best" type in the default case to the BleakClient class to avoid
duplicated code.

The logic is simplified to prefer a write with response if available
and no longer reports a warning for devices that don't properly specify
properties (since it would create much noise with many writes).

Fixes: #909
Add `advertisement_data()` async iterator method to the `BleakScanner`
which yields results of the ongoing scan.
- Switch usage of f-strings for log message formatting
- Guard expensive loggers with isEnableFor
This makes sure all methods of the BlueZManager are checking
that the adapter or device exists in BlueZ before continuing with
the method.

Documentation is updated to indicate which functions have this check
and which do not.
…es_discovery()

This adds a 3rd race condition to _wait_for_services_discovery() to
handle the case where an interface is removed from BlueZ without
changing the "Connected" property. This can happen, e.g. when we
hit "retry due to le-connection-abort-by-local".
This adds a device path key to the condition callbacks. This will avoid
calling callbacks for other devices that are not the subject of the
current "PropertiesChanged" signal.
* Android : updated requirements, permissions and archs in buildozer.spec
* Fixed bleak recipe for android

The current develop branch of p4a uses the setup.py to install the recipe and doesn't seem compliant with PEP517 yet.

The temporary fix is to provide a setup.py during the build stage for android.

Also, the recipe is now more generic, so it can easily be used in your own projects.
This makes it easy to get up and running with vscode.
It appears that GattDeviceService.Close() can hang forever under
certain circumstances.  This change adds a 0.1 second delay before
closing services to see if that helps.

Fixes: #1359
WinError does the same thing and is a bit more straight forward.
Python 3.12 introduces a new type to indicate the C buffer protocol.
We can use this to more correctly indicate allowable types.
dlech and others added 6 commits September 2, 2023 13:05
Python 3.7 has reached end of life.
This ensures we get support for Python 3.12.
Most of the class methods for BleakScanner allow passing **kwargs to
the BleakScanner() constructor. PEP 692 now gives us a way to have
proper type hints for this.
The winrt packages are now being distributed as individual namespace
packages, so we can take advantage of that instead of having to
provide our own bleak_winrt package.

The new packages haven't been tested much yet, so just enabling on
Python 3.12 for now.
@dlech dlech merged commit e23914e into master Sep 2, 2023
@dlech dlech deleted the release/0.21.0 branch September 2, 2023 19:26
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.

6 participants