diff --git a/AUTHORS.rst b/AUTHORS.rst index b6eca00d..6bff3be3 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -24,6 +24,7 @@ Contributors * David Johansen * JP Hutchins * Bram Duvigneau +* Peter-Newman Messan Sponsors -------- diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9c360d48..fa6ebbe8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,7 @@ Changed * Don't change ctypes' global state ``bleak.backends.winrt.util``. * Improved performance of BlueZ backend when there are many adapters. * Added support for Python 3.13. +* Fixed uninitialized bus connection when pairing before connection on BlueZ backend. `0.22.2`_ (2024-06-01) ====================== diff --git a/bleak/backends/bluezdbus/client.py b/bleak/backends/bluezdbus/client.py index ec225584..54c7f1f5 100644 --- a/bleak/backends/bluezdbus/client.py +++ b/bleak/backends/bluezdbus/client.py @@ -436,6 +436,11 @@ async def pair(self, *args, **kwargs) -> bool: Boolean regarding success of pairing. """ + if self._bus is None: + self._bus = await MessageBus( + bus_type=BusType.SYSTEM, negotiate_unix_fd=True + ).connect() + # See if it is already paired. reply = await self._bus.call( Message(