diff --git a/api/ble.py b/api/ble.py index 6234407..40b5778 100644 --- a/api/ble.py +++ b/api/ble.py @@ -18,6 +18,7 @@ provided for convenience. """ import asyncio +import subprocess import warnings, logging warnings.filterwarnings("ignore") logging.getLogger('apscheduler').setLevel(logging.ERROR) @@ -191,9 +192,14 @@ def read_data_sync(mac: str) -> Optional[SensorReading]: # --------------------------------------------------------------------------- # -# Original helper functions +# Other helper functions # --------------------------------------------------------------------------- # +def reset_adapter(): + subprocess.run(["sudo", "rfkill", "block", "bluetooth"], check=True) + subprocess.run(["sudo", "rfkill", "unblock", "bluetooth"], check=True) + def sensor_data_query(mac_list: List[str]) -> List[dict]: + reset_adapter() result = [] for mac in mac_list: try: