forked from platypush/platypush
Scan always at least for 10 seconds before failing on get_device
.
This commit is contained in:
parent
6267943786
commit
43289a3b55
1 changed files with 10 additions and 1 deletions
|
@ -42,6 +42,12 @@ class BLEManager(BaseBluetoothManager):
|
||||||
RSSI update, in seconds.
|
RSSI update, in seconds.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_min_get_device_scan_duration: Final[int] = 10
|
||||||
|
"""
|
||||||
|
Wait at least this many seconds for a device to be discovered when calling
|
||||||
|
get_device().
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -74,7 +80,10 @@ class BLEManager(BaseBluetoothManager):
|
||||||
dev = self._device_cache.get(device)
|
dev = self._device_cache.get(device)
|
||||||
if not dev:
|
if not dev:
|
||||||
self.logger.info('Scanning for unknown device "%s"', device)
|
self.logger.info('Scanning for unknown device "%s"', device)
|
||||||
await self._scan()
|
await self._scan(
|
||||||
|
duration=max(self._min_get_device_scan_duration, self.poll_interval)
|
||||||
|
)
|
||||||
|
|
||||||
dev = self._device_cache.get(device)
|
dev = self._device_cache.get(device)
|
||||||
|
|
||||||
assert dev, f'Unknown device: "{device}"'
|
assert dev, f'Unknown device: "{device}"'
|
||||||
|
|
Loading…
Reference in a new issue