Skip to content

Commit

Permalink
Merge pull request #1118 from hbldh/release/0.19.3
Browse files Browse the repository at this point in the history
Release/0.19.3
  • Loading branch information
dlech authored Nov 7, 2022
2 parents f3a66f8 + 2c7b058 commit c7101de
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.

`Unreleased`_
=============

`0.19.3`_ (2022-11-06)
======================

Fixed
-----
* Fixed ``TimeoutError`` when connecting to certain devices with WinRT backend. Fixes #604.


`0.19.2`_ (2022-11-06)
======================
Expand Down Expand Up @@ -859,7 +865,8 @@ Fixed
* Bleak created.


.. _Unreleased: https://github.com/hbldh/bleak/compare/v0.19.2...develop
.. _Unreleased: https://github.com/hbldh/bleak/compare/v0.19.3...develop
.. _0.19.3: https://github.com/hbldh/bleak/compare/v0.19.2...v0.19.3
.. _0.19.2: https://github.com/hbldh/bleak/compare/v0.19.1...v0.19.2
.. _0.19.1: https://github.com/hbldh/bleak/compare/v0.19.0...v0.19.1
.. _0.19.0: https://github.com/hbldh/bleak/compare/v0.18.1...v0.19.0
Expand Down
26 changes: 18 additions & 8 deletions bleak/backends/winrt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,30 @@ def max_pdu_size_changed_handler(sender: GattSession, args):
self._session.maintain_connection = True
# This keeps the device connected until we set maintain_connection = False.

# wait for the session to become active
async with async_timeout.timeout(timeout):
await event.wait()
wait_connect_task = asyncio.create_task(event.wait())

try:
# a connection may not be made until we request info from the
# device, so we have to get services before the GATT session
# is set to active
wait_get_services_task = asyncio.create_task(self.get_services())

try:
# wait for the session to become active
async with async_timeout(timeout):
await asyncio.gather(wait_connect_task, wait_get_services_task)

finally:
wait_get_services_task.cancel()
finally:
wait_connect_task.cancel()

except BaseException:
handle_disconnect()
raise
finally:
self._session_active_events.remove(event)

# Obtain services, which also leads to connection being established.
await self.get_services()

return True

async def disconnect(self) -> bool:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bleak"
version = "0.19.2"
version = "0.19.3"
description = "Bluetooth Low Energy platform Agnostic Klient"
authors = ["Henrik Blidh <henrik.blidh@nedomkull.com>"]
license = "MIT"
Expand Down

0 comments on commit c7101de

Please sign in to comment.