0.1.29
This commit is contained in:
@@ -487,8 +487,25 @@ async def connect(
|
||||
if "br-connection-not-supported" in msg:
|
||||
last_exc = exc
|
||||
if not forced_rescan_done:
|
||||
print(
|
||||
"BLE connection failed with 'br-connection-not-supported'. "
|
||||
"Attempting to clear device cache with 'bluetoothctl remove' and rescan."
|
||||
)
|
||||
# Aggressive recovery: try to remove the device from bluez's cache
|
||||
if address:
|
||||
try:
|
||||
remove_cmd = f'echo -e "remove {address}\\nquit" | bluetoothctl'
|
||||
proc = await asyncio.create_subprocess_shell(
|
||||
remove_cmd,
|
||||
stdout=asyncio.subprocess.DEVNULL,
|
||||
stderr=asyncio.subprocess.DEVNULL,
|
||||
)
|
||||
await asyncio.wait_for(proc.communicate(), timeout=10.0)
|
||||
except Exception as remove_exc:
|
||||
print(f" Failed to run 'bluetoothctl remove': {remove_exc}")
|
||||
|
||||
forced_rescan_done = True
|
||||
target = await resolve_ble_target(None)
|
||||
target = await resolve_ble_target(address)
|
||||
if attempt < BLE_CONNECT_RETRIES:
|
||||
await asyncio.sleep(BLE_CONNECT_BACKOFF * attempt)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user