From 0dc1a669807218f079753803f2eb00c7a6bdea6f Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 15 Oct 2026 20:20:37 -0700 Subject: [PATCH] add exception handler for scan_macs --- api/ble.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/ble.py b/api/ble.py index 8d56311..df6a541 100644 --- a/api/ble.py +++ b/api/ble.py @@ -105,7 +105,13 @@ async def _scan_once() -> List[str]: A list of MAC addresses (upper-case as returned by Bleak). """ log.debug("Starting one-shot BLE scan (timeout = %.1fs)", SCAN_TIMEOUT) - devices = await BleakScanner.discover(timeout=SCAN_TIMEOUT) + try: + devices = await BleakScanner.discover(timeout=SCAN_TIMEOUT) + except Exception as e: + print(f"Error reading BLE data - {e}") + this_result = None + if "org.freedesktop.DBus.Error.AccessDenied" in e: + return [] return [dev.address for dev in devices if _is_match(dev.address, dev.name)]