Add failed callback

This commit is contained in:
Jesse Hills 2022-09-28 12:06:20 +13:00
parent 86512bc607
commit 0c5d109951
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A

View File

@ -447,6 +447,7 @@ class APIClient:
self, self,
address: int, address: int,
on_bluetooth_connection_state: Callable[[bool, int], None], on_bluetooth_connection_state: Callable[[bool, int], None],
on_bluetooth_connection_failed: Callable[[], None],
timeout: float = 10.0, timeout: float = 10.0,
) -> Callable[[], None]: ) -> Callable[[], None]:
self._check_authenticated() self._check_authenticated()
@ -458,6 +459,8 @@ class APIClient:
resp = BluetoothDeviceConnection.from_pb(msg) resp = BluetoothDeviceConnection.from_pb(msg)
if address == resp.address: if address == resp.address:
on_bluetooth_connection_state(resp.connected, resp.mtu) on_bluetooth_connection_state(resp.connected, resp.mtu)
if resp.failed:
on_bluetooth_connection_failed()
assert self._connection is not None assert self._connection is not None
await self._connection.send_message_callback_response( await self._connection.send_message_callback_response(