Skip to content

Commit

Permalink
Stop scan loop and show error message on BleakError (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
koenvervloesem authored Dec 8, 2023
1 parent 2b08151 commit 2fc1d04
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions TheengsGateway/ble_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,13 @@ async def ble_scan_loop(self) -> None:
while not self.stopped:
if self.client.is_connected():
self.published_messages = 0
await scanner.start()
await asyncio.sleep(self.configuration["ble_scan_time"])
await scanner.stop()
try:
await scanner.start()
await asyncio.sleep(self.configuration["ble_scan_time"])
await scanner.stop()
except BleakError as error:
logger.exception(error) # noqa: TRY401
self.stopped = True
logger.info(
"Sent %s messages to MQTT",
self.published_messages,
Expand Down

0 comments on commit 2fc1d04

Please sign in to comment.