From 986c718f5c4eb84571bf9068f36c87044ba34c27 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sun, 6 Nov 2022 22:55:09 -0600 Subject: [PATCH] winrt/client: fix TimeoutError for certain devices Some devices will get a TimeoutError when trying to connect because setting `self._session.maintain_connection = True` is not enough to trigger a connection to the device. We also have to start an interaction with the device. This can be done by calling `self.get_services()` which we need to do here anyway. This also make `get_services()` be included in the timeout, which is probably a good thing. Fixes: #604 --- CHANGELOG.rst | 4 ++++ bleak/backends/winrt/client.py | 26 ++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 74d402ff..31197209 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,10 @@ and this project adheres to `Semantic Versioning bool: @@ -540,8 +552,6 @@ async def get_services(self, **kwargs) -> BleakGATTServiceCollection: A :py:class:`bleak.backends.service.BleakGATTServiceCollection` with this device's services tree. """ - if not self.is_connected: - raise BleakError("Not connected") # Return the Service Collection. if self._services_resolved: