Allow specifying a timeout for bluetooth_gatt_start_notify (#770)

This commit is contained in:
J. Nick Koston 2023-11-28 08:07:33 -06:00 committed by GitHub
parent 844326a3a2
commit 15e6279246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -830,7 +830,7 @@ class APIClient:
handle, handle,
req, req,
BluetoothGATTWriteResponse, BluetoothGATTWriteResponse,
timeout=timeout, timeout,
) )
async def bluetooth_gatt_read_descriptor( async def bluetooth_gatt_read_descriptor(
@ -862,7 +862,7 @@ class APIClient:
handle, handle,
req, req,
BluetoothGATTReadResponse, BluetoothGATTReadResponse,
timeout=timeout, timeout,
) )
if TYPE_CHECKING: if TYPE_CHECKING:
assert isinstance(resp, BluetoothGATTReadResponse) assert isinstance(resp, BluetoothGATTReadResponse)
@ -889,7 +889,7 @@ class APIClient:
handle, handle,
req, req,
BluetoothGATTWriteResponse, BluetoothGATTWriteResponse,
timeout=timeout, timeout,
) )
async def bluetooth_gatt_start_notify( async def bluetooth_gatt_start_notify(
@ -897,6 +897,7 @@ class APIClient:
address: int, address: int,
handle: int, handle: int,
on_bluetooth_gatt_notify: Callable[[int, bytearray], None], on_bluetooth_gatt_notify: Callable[[int, bytearray], None],
timeout: float = 10.0,
) -> tuple[Callable[[], Coroutine[Any, Any, None]], Callable[[], None]]: ) -> tuple[Callable[[], Coroutine[Any, Any, None]], Callable[[], None]]:
"""Start a notify session for a GATT characteristic. """Start a notify session for a GATT characteristic.
@ -924,6 +925,7 @@ class APIClient:
handle, handle,
BluetoothGATTNotifyRequest(address=address, handle=handle, enable=True), BluetoothGATTNotifyRequest(address=address, handle=handle, enable=True),
BluetoothGATTNotifyResponse, BluetoothGATTNotifyResponse,
timeout,
) )
except Exception: except Exception:
remove_callback() remove_callback()