Skip to content

Commit 290746f

Browse files
authored
Merge pull request #1823 from hbldh/release/v1.1.1
Release/v1.1.1
2 parents 1e6dd6f + 2564f91 commit 290746f

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

CHANGELOG.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
1010
`Unreleased`_
1111
=============
1212

13+
`1.1.1`_ (2025-09-07)
14+
=====================
15+
16+
Fixed
17+
-----
18+
- Fixed D-Bus connection leak on connection failure in BlueZ backend.
19+
- Fixed characteristic's max write without response size using wrong characteristic's value. Fixes #1820.
20+
- Fixed ``AttributeError`` in Python4Android backend when accessing ``is_connected`` before connecting. Fixes #1791.
21+
1322
`1.1.0`_ (2025-08-10)
1423
=====================
1524

@@ -1111,7 +1120,8 @@ Fixed
11111120
* Bleak created.
11121121

11131122

1114-
.. _Unreleased: https://github.com/hbldh/bleak/compare/v1.1.0...develop
1123+
.. _Unreleased: https://github.com/hbldh/bleak/compare/v1.1.1...develop
1124+
.. _1.1.1: https://github.com/hbldh/bleak/compare/v1.1.0...v1.1.1
11151125
.. _1.1.0: https://github.com/hbldh/bleak/compare/v1.0.1...v1.1.0
11161126
.. _1.0.1: https://github.com/hbldh/bleak/compare/v1.0.0...v1.0.1
11171127
.. _1.0.0: https://github.com/hbldh/bleak/compare/v0.22.3...v1.0.0

bleak/backends/bluezdbus/defs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class GattCharacteristic1(TypedDict):
123123
NotifyAcquired: bool
124124
Notifying: bool
125125
Flags: list[CharacteristicPropertyName]
126+
# "MTU" property was added in BlueZ 5.62.
127+
# It may missing when operating with an older stack.
126128
MTU: int
127129
# Handle is server-only and not available in Bleak
128130

bleak/backends/bluezdbus/manager.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import os
2020
from collections import defaultdict
2121
from collections.abc import Callable, Coroutine, MutableMapping
22+
from functools import partial
2223
from typing import Any, NamedTuple, Optional, cast
2324
from weakref import WeakKeyDictionary
2425

@@ -154,6 +155,12 @@ class DeviceWatcher(NamedTuple):
154155
}
155156

156157

158+
def get_max_write_without_response_size(char_props: GattCharacteristic1) -> int:
159+
# "MTU" property was added in BlueZ 5.62, otherwise fall
160+
# back to minimum MTU according to Bluetooth spec.
161+
return char_props.get("MTU", 23) - 3
162+
163+
157164
class BlueZManager:
158165
"""
159166
BlueZ D-Bus object manager.
@@ -244,9 +251,12 @@ async def async_init(self) -> None:
244251
# dbus-next will destroy the underlying file descriptors
245252
# when the previous one is closed in its finalizer.
246253
bus = MessageBus(bus_type=BusType.SYSTEM, auth=get_dbus_authenticator())
247-
await bus.connect()
248254

249255
try:
256+
# We need to call bus.disconnect() even when bus.connect() fails in
257+
# order to release the file handles created in the constructor.
258+
await bus.connect()
259+
250260
# Add signal listeners
251261

252262
bus.add_message_handler(self._parse_msg)
@@ -709,9 +719,11 @@ async def get_services(
709719
extract_service_handle_from_path(char_path),
710720
char_props["UUID"],
711721
char_props["Flags"],
712-
# "MTU" property was added in BlueZ 5.62, otherwise fall
713-
# back to minimum MTU according to Bluetooth spec.
714-
lambda: char_props.get("MTU", 23) - 3,
722+
# Because `char_props` is a loop varialbe, we cannot
723+
# directly bind a closure (i.e. lambda) to it;
724+
# instead, we let `functools.partial` create a new
725+
# function frame to close over at each iteration.
726+
partial(get_max_write_without_response_size, char_props),
715727
service,
716728
)
717729

bleak/backends/p4android/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def __init__(
6161
self.__gatt = None
6262
self.__mtu = 23
6363

64+
self.__callbacks = None
65+
6466
# Connectivity methods
6567

6668
@override

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "bleak"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
description = "Bluetooth Low Energy platform Agnostic Klient"
55
authors = [{ name = "Henrik Blidh", email = "[email protected]" }]
66
license = "MIT"

0 commit comments

Comments
 (0)