diff --git a/aioesphomeapi/api.proto b/aioesphomeapi/api.proto index 40aa3e4..30d6935 100644 --- a/aioesphomeapi/api.proto +++ b/aioesphomeapi/api.proto @@ -1187,7 +1187,7 @@ message BluetoothDeviceConnectionResponse { uint64 address = 1; bool connected = 2; uint32 mtu = 3; - bool failed = 4; + int error = 4; } message BluetoothGATTGetServicesRequest { diff --git a/aioesphomeapi/client.py b/aioesphomeapi/client.py index f7d28e5..2816d64 100644 --- a/aioesphomeapi/client.py +++ b/aioesphomeapi/client.py @@ -446,8 +446,7 @@ class APIClient: async def bluetooth_device_connect( self, address: int, - on_bluetooth_connection_state: Callable[[bool, int], None], - on_bluetooth_connection_failed: Callable[[], None], + on_bluetooth_connection_state: Callable[[bool, int, int], None], timeout: float = 10.0, ) -> Callable[[], None]: self._check_authenticated() @@ -458,9 +457,7 @@ class APIClient: if isinstance(msg, BluetoothDeviceConnectionResponse): resp = BluetoothDeviceConnection.from_pb(msg) if address == resp.address: - on_bluetooth_connection_state(resp.connected, resp.mtu) - if resp.failed: - on_bluetooth_connection_failed() + on_bluetooth_connection_state(resp.connected, resp.mtu, resp.error) assert self._connection is not None await self._connection.send_message_callback_response( diff --git a/aioesphomeapi/model.py b/aioesphomeapi/model.py index 1c20cb1..0d7286c 100644 --- a/aioesphomeapi/model.py +++ b/aioesphomeapi/model.py @@ -804,7 +804,7 @@ class BluetoothDeviceConnection(APIModelBase): address: int = 0 connected: bool = False mtu: int = 0 - failed: bool = False + error: int = 0 @dataclass(frozen=True)