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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
92b20d9
version bump for develop
dlech Jul 29, 2022
22d008f
docs/troubleshooting: fix windows BTP link
dlech Aug 1, 2022
3d67036
Merge pull request #914 from hbldh/win-btp-link
dlech Aug 1, 2022
8cc2222
Make callback logging lazy
bdraco Aug 1, 2022
742b63d
Merge pull request #912 from bdraco/lazy_logger
dlech Aug 1, 2022
6b70d94
Fix disconnect in the global BlueZ manager
bdraco Aug 2, 2022
dfae35b
Switch to using async_timeout for timeouts
bdraco Aug 2, 2022
7e334f6
Handle the race in the BlueZ D-Bus backend where the device disconnec…
bdraco Aug 2, 2022
c581d5e
Avoid reusing the MessageBus in the manager
bdraco Aug 2, 2022
90aed10
Merge pull request #916 from bdraco/async_timeout
dlech Aug 3, 2022
6395e7e
Merge pull request #918 from bdraco/disconnect_not_coro
dlech Aug 3, 2022
b358549
Merge branch 'develop' into fix_disconnect_race
dlech Aug 3, 2022
10358b3
Merge pull request #919 from bdraco/fix_disconnect_race
dlech Aug 3, 2022
e7db0a1
Merge branch 'develop' into no_reuse_dbus_socket_manager
dlech Aug 3, 2022
90ead61
Merge pull request #920 from bdraco/no_reuse_dbus_socket_manager
dlech Aug 3, 2022
88c7e6b
Merge remote-tracking branch 'origin/master' into develop
dlech Aug 3, 2022
9363607
remove explicit inheritance from object
dlech Aug 3, 2022
9a1f31d
Adjust default timeout for ``read_gatt_char()`` with CoreBluetooth to…
bdraco Aug 8, 2022
8f7e43e
Merge pull request #928 from bdraco/read_gatt_char_corebluetooth_stil…
dlech Aug 26, 2022
8515d22
Merge pull request #922 from hbldh/explicit-object-inheritance
dlech Aug 26, 2022
579d0cf
bluezdbus: move dbus interface dict types to defs
dlech Aug 26, 2022
529583f
backends/characteristic: add max_write_without_response_size property
dlech Aug 26, 2022
78f15ee
remove top-level Makefile
dlech Aug 26, 2022
f727f4f
backends/bluezdbus/manager: fix typo
dlech Aug 26, 2022
41f28f9
backends/bluezdbus: remove first seen filter in scanner
dlech Aug 26, 2022
c1f1bb9
bluezdbus: move dbus interface dict types to defs
dlech Aug 26, 2022
3b320f0
backends/bluezdbus/manager: add object lookup maps
dlech Aug 26, 2022
f343136
Merge pull request #966 from hbldh/bluez-get-services-performance
dlech Aug 29, 2022
775d426
Merge pull request #964 from hbldh/bluez-no-ignore-rssi-change
dlech Aug 29, 2022
dbb716f
Merge pull request #963 from hbldh/remove-makefile
dlech Aug 29, 2022
03370c0
Merge branch 'develop' into max-write-without-response-size
dlech Aug 29, 2022
6901c63
Merge pull request #962 from hbldh/max-write-without-response-size
dlech Aug 29, 2022
b93082a
backends/bluezdbus/client: fix not disconnecting if get_services() th…
dlech Aug 29, 2022
aa27f4c
backends/bluezdbus/scanner: fix removed devices included in discovere…
dlech Aug 29, 2022
bdfaea1
Merge pull request #967 from hbldh/bluez-fix-device-removed-while-sca…
dlech Aug 30, 2022
7999b2c
Merge branch 'develop' into bluez-fix-bad-connect-state
dlech Aug 30, 2022
77d74ed
Merge pull request #968 from hbldh/bluez-fix-bad-connect-state
dlech Aug 30, 2022
357e501
release v0.16.0
dlech Aug 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
`Unreleased`_
=============

`0.16.0`_ (2022-08-31)
======================

Added
-----
* Added ``BleakGattCharacteristic.max_write_without_response_size`` property. Fixes #738.

Fixed
-----
* Fixed regression in v0.15 where devices removed from BlueZ while scanning
were still listed in ``BleakScanner.discovered_devices``. Fixes #942.
* Fixed possible bad connection state in BlueZ backend. Fixes #951.

Changed
-------
* Made BlueZ D-Bus signal callback logging lazy to improve performance. Merged #912.
* Switch to using async_timeout instead of asyncio.wait_for for performance. Merged #916.
* Improved performance of ``BlueZManager.get_services()``. Fixes #927.

Removed
-------
* Removed explicit inheritance from object in class declarations. Merged #922.
* Removed first seen filter in ``BleakScanner`` detection callbacks on BlueZ backend. Merged #964.

`0.15.1`_ (2022-08-03)
======================

Expand All @@ -19,6 +43,7 @@ Fixed
* Handle the race in the BlueZ D-Bus backend where the device disconnects during
the connection process which presented as ``Failed to cancel connection``. Merged #919.
* Ensure the BlueZ D-Bus scanner can reconnect after DBus disconnection. Merged #920.
* Adjust default timeout for ``read_gatt_char()`` with CoreBluetooth to 20s. Fixes #926.


`0.15.0`_ (2022-07-29)
Expand Down Expand Up @@ -722,7 +747,8 @@ Fixed
* Bleak created.


.. _Unreleased: https://github.com/hbldh/bleak/compare/v0.15.1...develop
.. _Unreleased: https://github.com/hbldh/bleak/compare/v0.16.0...develop
.. _0.16.0: https://github.com/hbldh/bleak/compare/v0.15.1...v0.16.0
.. _0.15.1: https://github.com/hbldh/bleak/compare/v0.15.0...v0.15.1
.. _0.15.0: https://github.com/hbldh/bleak/compare/v0.14.3...v0.15.0
.. _0.14.3: https://github.com/hbldh/bleak/compare/v0.14.2...v0.14.3
Expand Down
87 changes: 0 additions & 87 deletions Makefile

This file was deleted.

1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
async_timeout = ">=4.0.1"
typing-extensions = ">=4.2.0"
dbus-next = {version = ">=0.2.2", sys_platform = "== 'linux'"}
pyobjc-core = {version = ">=7.0.1", sys_platform = "== 'darwin'"}
Expand Down
2 changes: 1 addition & 1 deletion bleak/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

__version__ = "0.15.1"
__version__ = "0.16.0"
21 changes: 14 additions & 7 deletions bleak/backends/bluezdbus/characteristic.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import List, Union
from uuid import UUID
from typing import Union, List

from bleak.backends.bluezdbus.utils import extract_service_handle_from_path
from bleak.backends.characteristic import BleakGATTCharacteristic
from bleak.backends.descriptor import BleakGATTDescriptor

from ..characteristic import BleakGATTCharacteristic
from ..descriptor import BleakGATTDescriptor
from .defs import GattCharacteristic1
from .utils import extract_service_handle_from_path

_GattCharacteristicsFlagsEnum = {
0x0001: "broadcast",
Expand All @@ -31,9 +31,16 @@ class BleakGATTCharacteristicBlueZDBus(BleakGATTCharacteristic):
"""GATT Characteristic implementation for the BlueZ DBus backend"""

def __init__(
self, obj: dict, object_path: str, service_uuid: str, service_handle: int
self,
obj: GattCharacteristic1,
object_path: str,
service_uuid: str,
service_handle: int,
max_write_without_response_size: int,
):
super(BleakGATTCharacteristicBlueZDBus, self).__init__(obj)
super(BleakGATTCharacteristicBlueZDBus, self).__init__(
obj, max_write_without_response_size
)
self.__descriptors = []
self.__path = object_path
self.__service_uuid = service_uuid
Expand Down
38 changes: 21 additions & 17 deletions bleak/backends/bluezdbus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from typing import Callable, Optional, Union
from uuid import UUID

import async_timeout

from dbus_next.aio import MessageBus
from dbus_next.constants import BusType, ErrorType
from dbus_next.message import Message
Expand Down Expand Up @@ -153,22 +155,31 @@ def on_value_changed(char_path: str, value: bytes) -> None:

try:
try:
reply = await asyncio.wait_for(
self._bus.call(
async with async_timeout.timeout(timeout):
reply = await self._bus.call(
Message(
destination=defs.BLUEZ_SERVICE,
interface=defs.DEVICE_INTERFACE,
path=self._device_path,
member="Connect",
)
),
timeout,
)
)
assert_reply(reply)

self._is_connected = True

# Create a task that runs until the device is disconnected.
self._disconnect_monitor_event = asyncio.Event()
asyncio.ensure_future(self._disconnect_monitor())

await self.get_services()

return True
except BaseException:
# calling Disconnect cancels any pending connect request
# Calling Disconnect cancels any pending connect request. Also,
# if connection was successful but get_services() raises (e.g.
# because task was cancelled), the we still need to disconnect
# before passing on the exception.
if self._bus:
# If disconnected callback already fired, this will be a no-op
# since self._bus will be None and the _cleanup_all call will
Expand Down Expand Up @@ -196,15 +207,6 @@ def on_value_changed(char_path: str, value: bytes) -> None:
)

raise

# Create a task that runs until the device is disconnected.
self._disconnect_monitor_event = asyncio.Event()
asyncio.ensure_future(self._disconnect_monitor())

# Get all services. This means making the actual connection.
await self.get_services()

return True
except BaseException:
self._cleanup_all()
raise
Expand Down Expand Up @@ -294,7 +296,8 @@ async def disconnect(self) -> bool:
if self._disconnecting_event:
# another call to disconnect() is already in progress
logger.debug(f"already in progress ({self._device_path})")
await asyncio.wait_for(self._disconnecting_event.wait(), timeout=10)
async with async_timeout.timeout(10):
await self._disconnecting_event.wait()
elif self.is_connected:
self._disconnecting_event = asyncio.Event()
try:
Expand All @@ -308,7 +311,8 @@ async def disconnect(self) -> bool:
)
)
assert_reply(reply)
await asyncio.wait_for(self._disconnecting_event.wait(), timeout=10)
async with async_timeout.timeout(10):
await self._disconnecting_event.wait()
finally:
self._disconnecting_event = None

Expand Down
Loading