ble - testing without discovery
This commit is contained in:
1 parent
38ee150ea3
commit
0480a76c71
1 file changed
+12
-11
+12
-11
@@ -182,17 +182,17 @@ def _is_match(mac: str, name: str) -> bool:
|
||||
####################################################
|
||||
async def read_data(mac: str) -> Optional[SensorReading]:
|
||||
|
||||
try:
|
||||
address = await asyncio.wait_for(
|
||||
_discover_device(mac),
|
||||
timeout=DISCOVER_TIMEOUT,
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
log.warning("Device discovery timed out for %s after %.1fs", mac, DISCOVER_TIMEOUT)
|
||||
return None
|
||||
|
||||
if not address:
|
||||
return None
|
||||
# try:
|
||||
# address = await asyncio.wait_for(
|
||||
# _discover_device(mac),
|
||||
# timeout=DISCOVER_TIMEOUT,
|
||||
# )
|
||||
# except asyncio.TimeoutError:
|
||||
# log.warning("Device discovery timed out for %s after %.1fs", mac, DISCOVER_TIMEOUT)
|
||||
# return None
|
||||
#
|
||||
# if not address:
|
||||
# return None
|
||||
|
||||
try:
|
||||
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())
|
||||
time.sleep(2)
|
||||
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
|
||||
def get_usb_id():
|
||||
|
||||
Reference in new issue
Block a user