Retry BLE with fresh LE scan on br-connection-not-supported (0.1.15)
This commit is contained in:
@@ -450,6 +450,7 @@ async def connect(
|
||||
)
|
||||
|
||||
last_exc: Exception | None = None
|
||||
forced_rescan_done = False
|
||||
for attempt in range(1, BLE_CONNECT_RETRIES + 1):
|
||||
try:
|
||||
async with BleakClient(target) as client:
|
||||
@@ -466,8 +467,15 @@ async def connect(
|
||||
except BleakDBusError as exc:
|
||||
msg = str(exc).lower()
|
||||
if "br-connection-not-supported" in msg:
|
||||
last_exc = exc
|
||||
if not forced_rescan_done:
|
||||
forced_rescan_done = True
|
||||
target = await resolve_ble_target(None)
|
||||
if attempt < BLE_CONNECT_RETRIES:
|
||||
await asyncio.sleep(BLE_CONNECT_BACKOFF * attempt)
|
||||
continue
|
||||
raise PrinterError(
|
||||
"BLE connection failed (br-connection-not-supported). "
|
||||
"BLE connection failed (br-connection-not-supported) after LE rescan. "
|
||||
"Try Classic Bluetooth with classic=true and channel=1."
|
||||
) from exc
|
||||
last_exc = exc
|
||||
|
||||
Reference in New Issue
Block a user