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/v0.17.0 #1006

Merged
merged 45 commits into from
Sep 12, 2022
Merged

Release/v0.17.0 #1006

merged 45 commits into from
Sep 12, 2022

Conversation

dlech
Copy link
Collaborator

@dlech dlech commented Sep 12, 2022

Added

Changed

Fixed

Removed

dlech and others added 30 commits August 31, 2022 16:31
This changes the disconnect timeout on the WinRT backend to 120s.

Sometimes it can take up to a minute for Windows to actually close
the GATT session/disconnect the device. This behavior is also seen
in other apps, like WebBluetooth in Chrome. Furthermore, the device
remains connected even after the app is closed, so clearly this is
an issue with the Windows Bluetooth stack and not something that
can be fixed in userspace code.

Fixes #807.
We are decoding the ATT error message number to a string. This was
using the wrong lookup table for the messages.

`PROTOCOL_ERROR_CODES` matches `BT_ATT_ERROR_*` in the BlueZ source.
This changes the battery workaround version check to exclude BlueZ
versions >=5.55 since the battery service was re-exposed in [1].

[1]: bluez/bluez@713f6f0
Essentially, the BLEDeviceCoreBluetooth class was being using to pass
the last-seen RSSI value for an advertisement for each device. So we
can simplify things by dropping the class and only keep track of the
last RSSI value.
This changes the build system from setuptools to poetry. This allows
us to avoid duplicating the package dependencies 3 times and also
include a lock file so that devs are working from the same package
versions.
Several dependencies were not added. This is evident when trying to
build the docs without installing main dependencies.

Also simplify and move after imports while we are touching this.
The TypedDict type breaks autodoc mocks in sphinx, so we can avoid the
problem by ensuing that sphinx uses python >=3.8 and only use the
typing-extensions package for python 3.7.
This adds a connection check to all methods that require a connection in the WinRT backend similar to what is already done in the BlueZ backend.

This fixes an issue where we would get an AttribueError in the connect method while getting services caused by the device disconnecting after connecting but before getting the services. Now a more informative exception is raised instead.
backends/winrt/client: extend disconnect timeout
exc: fix BlueZ ATT error messages
use poetry for build and deps
This fixes build docs on Python >=3.10.

Also update readthedocs.yml with new requirements.txt to fix failing builds.
docs: update sphinx to latest version
This fixes all instances of flake8 E402 and enables CI to fail on future instances of this error.
flake8: fix E402 and enable in CI
This updates the docs for recent changes in dependency management.
docs: update for recent changes
…n requested (#923)

If the device was previously connected and we have the
the service collection already built, it can
be reused for the next connection if the device has not
since been removed from the bus when the dangerous_use_bleak_cache
flag is passed.

For devices that connect and disconnect frequently this
can make operations up to an magnitude faster once
the first connection has been made and the device
has not been removed from the bus since the last
connection.
…m-for-unpair-in-winrt-client

Fixed use of wrong enum in unpair function of WinRT backend
Poetry seems to be picking up the wrong Python version when creating
the virtual environment, so specify it explicitly using:

    poetry env use pythonX.Y
dlech and others added 15 commits September 9, 2022 18:52
github: fix virtual env python version
* Switch from dbus_next to dbus_fast

* remove workaround since its fixed in dbus-fast
…994)



Co-authored-by: David Lechner <david@lechnology.com>
The `properties` and `descriptors` properties had inconsistent return
types between backends. This makes them consistent in all backends.
It is possible that self._session is set to None when
max_pdu_size_changed_handler is called. So we can use the sender arg
instead to avoid a possible AttributeError.

Fixes #998.
If the device disconnects right away for any reason, the
on_connected_changed callback fires and clears the
disconnect_monitor_event which results in the following
exception:

```
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 182, in connect
    asyncio.ensure_future(self._disconnect_monitor())
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 615, in ensure_future
    return _ensure_future(coro_or_future, loop=loop)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 636, in _ensure_future
    return loop.create_task(coro_or_future)
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 240, in _disconnect_monitor
    await self._disconnect_monitor_event.wait()
AttributeError: NoneType object has no attribute wait
```
The `# noqa: F401` directives were on the wrong line and not picked up
by flake8. This moves them to correct line and also allows us to use
the main flake8 config in CI since all errors are now fixed.
The discover() function was removed from the docs and was supposed to
be deprecated some time ago, but it didn't get a proper warning and
was still used in some examples.

This removes it from the examples and adds a warning so that it can
eventually be removed.
If specific adapter is not provided as a parameter, default adapter is
selected automatically as a first adapter out of all powered adapter in
the system, instead of using hardcoded "hci0".

Additional logic to only choose powered adapters is added for two
convenience reasons:
- If adapter is powered down but selected for operation, Bleak will not
  power it on. Consequently, `org.bluez.Error.NotReady` error will occur
  anyway when trying to use such adapter.
- If user has multiple adapters present on the system but currently uses
  only some while others are powered off, it most probably wants to use
  one of the active adapters.

Signed-off-by: Bojan Potočnik <info@bojanpotocnik.com>
Co-authored-by: David Lechner <david@pybricks.com>
PyPI rejected the upload because of the inclusion of the prefix.
@dlech dlech merged commit 6e89f05 into master Sep 12, 2022
@dlech dlech deleted the release/v0.17.0 branch September 12, 2022 20:28
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.

None yet

6 participants