diff --git a/api/ble.py b/api/ble.py index 4f6c0f1..d1b4d1a 100644 --- a/api/ble.py +++ b/api/ble.py @@ -78,6 +78,8 @@ async def _discover_device(mac: str) -> Optional[str]: log.warning("Device %s not found in scan", mac) except asyncio.TimeoutError: log.warning("Discover call timed out after %.1fs for %s", SCAN_TIMEOUT + 2.0, mac) + except Exception as e: + log.error(f"Dicvoere call failed - {e}") return None def _parse_sensor_data(raw: bytes) -> (float, int): @@ -223,6 +225,7 @@ def read_data_sync(mac: str) -> Optional[SensorReading]: def reset_adapter(): log.info("Restting BT Adapter...") log.info(subprocess.run(["sudo", "rfkill", "block", "bluetooth"], capture_output=True, text=True, check=True).stdout) + time.sleep(2) log.info(subprocess.run(["sudo", "rfkill", "unblock", "bluetooth"], capture_output=True, text=True, check=True).stdout) time.sleep(5) log.info("Reset complete. ")