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.16.0 #969

Merged
merged 38 commits into from
Aug 31, 2022
Merged

release v0.16.0 #969

merged 38 commits into from
Aug 31, 2022

Conversation

dlech
Copy link
Collaborator

@dlech dlech commented Aug 31, 2022

Added

Fixed

Changed

Removed

dlech and others added 30 commits July 29, 2022 12:04
old link was getting 404 error
docs/troubleshooting: fix windows BTP link
Fixes logging-format-interpolation (W1202)
```
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 344, in async_init
    await self._bus.disconnect()
TypeError: object NoneType can't be used in 'await' expression

```
When the dbus socket gets disconnected from dbus, we cannot
reuse the connection because dbus-next finalize will remove
the underlying fds

Fixes
```
2022-08-02 09:29:00.722 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Bluetooth for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 290, in async_init
    await self._bus.connect()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 149, in connect
    await self._authenticate()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 380, in _authenticate
    await self._loop.sock_sendall(self._sock, b0)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 441, in sock_sendall
    n = sock.send(data)
BrokenPipeError: [Errno 32] Broken pipe
```
Switch to using async_timeout for timeouts
Fix disconnect in the global BlueZ manager
Handle the race in the BlueZ D-Bus backend where the device disconnects during the connection process
Avoid reusing the MessageBus in the manager
In Python 3, we don't need to explicitly inherit from object.
…l_timeout

Adjust default timeout for ``read_gatt_char()`` with CoreBluetooth to 20s
remove explicit inheritance from object
This moves the D-Bus interface property dict types to the defs module.
This will help avoid circular imports of the manager module.
This adds a new max_write_without_response_size property to
BleakGattClient that can be used to ensure data will be able to be used
in a characteristic write without response command without causing
an OS error.

The NUS example is updated to show how to make use of this property.
This is not used, so can be removed.
This filter was originally added to get the same behavior as macOS.
However macOS has changed so we receive duplicate events even when
filter duplicates is enabled.

This allows us to get RSSI change events to allow making proper user
interfaces that show changing RSSI while scanning devices.
This moves the D-Bus interface property dict types to the defs module.
This will help avoid circular imports of the manager module.
This adds maps to improve performance when calling get_services().

Previously we had to enumerate all BlueZ D-Bus objects for each service,
characteristic and descriptor. When there were many devices, this was
a performance bottleneck.

Instead, we can create a map of the D-Bus object tree as new interfaces
appear, then use this map as an efficient way to find the child D-Bus
object paths in the GATT tree.

Fixes #927.
Bluez: improve get services performance
BlueZ: don't ignore RSSI change in detection callbacks
…rows

It is possible for get_services() to raise an exception, e.g. if
external code cancels the task. If this happens, we need to be sure
that the device disconnects so the BlueZClient is in a consistent
state (if the connect() method raises and exception, is is expected
that the device will not be connected).

To fix this, we can just move the call to get_services() inside of the
existing try block that will disconnect on any exception, then reraise
the exception.

Fixes #951.
…d_devices

This fixes a regression introduced in v0.15 where device removed from
BlueZ while scanning were no longer removed from this list of discovered
devices. This caused the `discovered_devices` property to return
devices that could no longer be connected to by BlueZ since they were
removed.

Fixes #942.
…nning

BlueZ: fix removed devices included in discovered_devices
BlueZ: fix not disconnecting if get_services() throws during connect
@dlech dlech changed the base branch from develop to master August 31, 2022 21:21
@dlech dlech merged commit aa24332 into master Aug 31, 2022
@dlech dlech deleted the release/0.16.0 branch August 31, 2022 21:30
@dlech
Copy link
Collaborator Author

dlech commented Aug 31, 2022

cc @bdraco

@bdraco
Copy link
Contributor

bdraco commented Aug 31, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment