mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-27 17:37:39 +01:00
Adjust ble timeouts to be longer than bleak timeouts (#287)
This commit is contained in:
parent
021e2563a3
commit
745e0b688e
@ -153,6 +153,8 @@ from .model import (
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
DEFAULT_BLE_TIMEOUT = 30.0
|
||||||
|
|
||||||
ExecuteServiceDataType = Dict[
|
ExecuteServiceDataType = Dict[
|
||||||
str, Union[bool, int, float, str, List[bool], List[int], List[float], List[str]]
|
str, Union[bool, int, float, str, List[bool], List[int], List[float], List[str]]
|
||||||
]
|
]
|
||||||
@ -451,7 +453,7 @@ class APIClient:
|
|||||||
self,
|
self,
|
||||||
address: int,
|
address: int,
|
||||||
on_bluetooth_connection_state: Callable[[bool, int, int], None],
|
on_bluetooth_connection_state: Callable[[bool, int, int], None],
|
||||||
timeout: float = 10.0,
|
timeout: float = DEFAULT_BLE_TIMEOUT,
|
||||||
) -> Callable[[], None]:
|
) -> Callable[[], None]:
|
||||||
self._check_authenticated()
|
self._check_authenticated()
|
||||||
|
|
||||||
@ -510,7 +512,10 @@ class APIClient:
|
|||||||
|
|
||||||
assert self._connection is not None
|
assert self._connection is not None
|
||||||
resp = await self._connection.send_message_await_response_complex(
|
resp = await self._connection.send_message_await_response_complex(
|
||||||
BluetoothGATTGetServicesRequest(address=address), do_append, do_stop
|
BluetoothGATTGetServicesRequest(address=address),
|
||||||
|
do_append,
|
||||||
|
do_stop,
|
||||||
|
timeout=DEFAULT_BLE_TIMEOUT,
|
||||||
)
|
)
|
||||||
services = []
|
services = []
|
||||||
for msg in resp:
|
for msg in resp:
|
||||||
@ -518,7 +523,10 @@ class APIClient:
|
|||||||
return ESPHomeBluetoothGATTServices(address=address, services=services)
|
return ESPHomeBluetoothGATTServices(address=address, services=services)
|
||||||
|
|
||||||
async def bluetooth_gatt_read(
|
async def bluetooth_gatt_read(
|
||||||
self, address: int, characteristic_handle: int, timeout: float = 10.0
|
self,
|
||||||
|
address: int,
|
||||||
|
characteristic_handle: int,
|
||||||
|
timeout: float = DEFAULT_BLE_TIMEOUT,
|
||||||
) -> bytearray:
|
) -> bytearray:
|
||||||
self._check_authenticated()
|
self._check_authenticated()
|
||||||
|
|
||||||
@ -568,7 +576,7 @@ class APIClient:
|
|||||||
self,
|
self,
|
||||||
address: int,
|
address: int,
|
||||||
handle: int,
|
handle: int,
|
||||||
timeout: float = 10.0,
|
timeout: float = DEFAULT_BLE_TIMEOUT,
|
||||||
) -> bytearray:
|
) -> bytearray:
|
||||||
self._check_authenticated()
|
self._check_authenticated()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user