Preserve RRD preview frames and clarify onboard K1 status
This commit is contained in:
@@ -838,6 +838,18 @@ async def _retrieve_bluez_device(address: str, details: object = None) -> BLEDev
|
||||
return None
|
||||
|
||||
|
||||
async def status_read_device_is_current(device: BLEDevice) -> bool:
|
||||
"""Check a BlueZ handle before the one explicit status-read connection.
|
||||
|
||||
BlueZ may remove an unpaired object after a completed scan session. This
|
||||
cache check neither scans nor connects and never changes macOS selection.
|
||||
"""
|
||||
details = getattr(device, "details", None)
|
||||
if not sys.platform.startswith("linux") or not isinstance(details, dict):
|
||||
return True
|
||||
return await _retrieve_bluez_device(device.address, details) is not None
|
||||
|
||||
|
||||
async def _retrieve_corebluetooth_device(
|
||||
captured: CapturedDiscoveredDevice,
|
||||
) -> BLEDevice | None:
|
||||
|
||||
@@ -26,6 +26,7 @@ from k1link.device_plugins.xgrids_k1.ble.scanner import (
|
||||
mark_captured_device_gatt_validated,
|
||||
retrieve_connected_device_capture,
|
||||
retrieve_known_device_capture_for_status_read,
|
||||
status_read_device_is_current,
|
||||
)
|
||||
|
||||
PROFILE_ID = "xgrids-k1-fw3-wifi-v1"
|
||||
@@ -390,6 +391,18 @@ async def _read_wifi_status_impl(
|
||||
"Exact BLE device is unavailable; run an explicit recovery or scan.",
|
||||
)
|
||||
|
||||
if not await status_read_device_is_current(device):
|
||||
# One explicit read may refresh the exact vanished BlueZ object
|
||||
# before GATT. No failed connect/write is retried; public discovery
|
||||
# generations, the pinned target and macOS behavior are unchanged.
|
||||
progress.operation_stage = "exact-uuid-scan"
|
||||
active_captured_device = await discover_known_device_capture_for_status_read(
|
||||
device_macos_uuid, timeout_seconds=min(timeout_seconds, 8.0),
|
||||
)
|
||||
device = (captured_device_handle(active_captured_device)
|
||||
if active_captured_device is not None else None)
|
||||
if device is None:
|
||||
raise BleakDeviceNotFoundError(device_macos_uuid, "Exact BLE device unavailable")
|
||||
progress.operation_stage = "connect"
|
||||
async with BleakClient(device, timeout=timeout_seconds, pair=False) as client:
|
||||
progress.operation_stage = "gatt-contract"
|
||||
|
||||
Reference in New Issue
Block a user