Skip to content

Commit

Permalink
Merge pull request #976 from hbldh/bluez-battery-fixes
Browse files Browse the repository at this point in the history
BlueZ battery fixes
  • Loading branch information
dlech authored Sep 5, 2022
2 parents 9529686 + 44dd2c8 commit faee54b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ Changed
-------
* ``BleakClient`` methods now raise ``BleakError`` if called when not connected in WinRT backend.
* Extended disconnect timeout to 120 seconds in WinRT backend. Fixes #807.
* Changed version check for BlueZ battery workaround to exclude versions >= 5.55. Merged #976.

Fixed
-----
* Fixed wrong error message for BlueZ "Operation failed with ATT error". Merged #975.
* Fixed possible ``AttributeError`` when enabling notifications for battery service in BlueZ backend. Merged #976.

`0.16.0`_ (2022-08-31)
======================
Expand Down
2 changes: 1 addition & 1 deletion bleak/backends/bluezdbus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def bleak_callback(s, d):
# provide this functionality...
# See https://kernel.googlesource.com/pub/scm/bluetooth/bluez/+/refs/tags/5.48/doc/battery-api.txt
if str(char_specifier) == "00002a19-0000-1000-8000-00805f9b34fb" and (
self._hides_battery_characteristic
BlueZFeatures.hides_battery_characteristic
):
raise BleakError(
"Notifications on Battery Level Char ({0}) is not "
Expand Down
2 changes: 1 addition & 1 deletion bleak/backends/bluezdbus/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def check_bluez_version(cls) -> None:
cls.write_without_response_workaround_needed = not (
major == 5 and minor >= 51
)
cls.hides_battery_characteristic = major == 5 and minor >= 48
cls.hides_battery_characteristic = major == 5 and minor >= 48 and minor < 55
cls.hides_device_name_characteristic = major == 5 and minor >= 48
else:
# Its possible they may be running inside a container where
Expand Down
4 changes: 2 additions & 2 deletions tests/bleak/backends/bluezdbus/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
(b"bluetoothctl: 5.46", True, False, False, False),
(b"bluetoothctl: 5.48", True, False, True, True),
(b"bluetoothctl: 5.51", True, True, True, True),
(b"bluetoothctl: 5.63", True, True, True, True),
(b"", True, True, True, True),
(b"bluetoothctl: 5.63", True, True, False, True),
(b"", True, True, False, True),
],
)
async def test_bluez_version(
Expand Down

0 comments on commit faee54b

Please sign in to comment.