ble - testing without discovery

This commit is contained in:
matt committed 2026-10-21 20:23:30 -07:00
1 parent 38ee150ea3
commit 0480a76c71
1 file changed
+12 -11
+12 -11
View File
@@ -182,17 +182,17 @@ def _is_match(mac: str, name: str) -> bool:
#################################################### ####################################################
async def read_data(mac: str) -> Optional[SensorReading]: async def read_data(mac: str) -> Optional[SensorReading]:
try: # try:
address = await asyncio.wait_for( # address = await asyncio.wait_for(
_discover_device(mac), # _discover_device(mac),
timeout=DISCOVER_TIMEOUT, # timeout=DISCOVER_TIMEOUT,
) # )
except asyncio.TimeoutError: # except asyncio.TimeoutError:
log.warning("Device discovery timed out for %s after %.1fs", mac, DISCOVER_TIMEOUT) # log.warning("Device discovery timed out for %s after %.1fs", mac, DISCOVER_TIMEOUT)
return None # return None
#
if not address: # if not address:
return None # return None
try: try:
async with BleakClient(address, timeout=CONNECT_TIMEOUT) as client: async with BleakClient(address, timeout=CONNECT_TIMEOUT) as client:
@@ -376,6 +376,7 @@ def restart_bt_service():
log.info(subprocess.run(["systemctl", "stop", "bluetooth.service"], capture_output=True, text=True, check=True).stdout.strip()) log.info(subprocess.run(["systemctl", "stop", "bluetooth.service"], capture_output=True, text=True, check=True).stdout.strip())
time.sleep(2) time.sleep(2)
log.info(subprocess.run(["systemctl", "start", "bluetooth.service"], capture_output=True, text=True, check=True).stdout.strip()) log.info(subprocess.run(["systemctl", "start", "bluetooth.service"], capture_output=True, text=True, check=True).stdout.strip())
time.sleep(2)
# this will return the USB ID based on systems scans # this will return the USB ID based on systems scans
def get_usb_id(): def get_usb_id():