Стабилизация подключения K1 после сна и ожидания Bluetooth

This commit is contained in:
DCCONSTRUCTIONS
2026-08-23 16:24:05 +03:00
parent 5ebc9fc27c
commit c041a569f6
9 changed files with 393 additions and 29 deletions
+69 -3
View File
@@ -15417,6 +15417,56 @@ def test_control_first_loss_freezes_topology_before_ephemeral_retirement(
assert service._physical_command_coordinator.snapshot() is physical # noqa: SLF001
def test_post_start_refresh_timeout_wakes_existing_read_only_recovery(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
service, runtime = service_with_fake_runtime(tmp_path)
control, physical = _install_composite_active_recovery_fixture(
service,
runtime,
monkeypatch,
runtime_phase="live",
camera_phase="streaming",
)
with service._lock: # noqa: SLF001
acquisition = service._acquisition # noqa: SLF001
assert acquisition is not None
acquisition.state = "awaiting_external_start"
acquisition.message_code = "acquisition.start.device_initializing"
acquisition.state_revision += 1
control.state = "failed"
control.outcome_unknown = True
control.failure = {
"reason_code": "mqtt_response_timeout",
"failed_phase": "initializing",
"dialogue_stage": "start-active-observed",
"modeling_command_attempted": True,
"stop_command_attempted": False,
"safe_to_retry": False,
}
start_projects_before = list(control.start_projects)
stop_calls_before = control.stop_calls
state = service.state()
assert runtime.recovery_requests == [
("mqtt_response_timeout", runtime.producer_generation),
]
assert state["phase"] == "reconnecting"
assert state["connection_recovery"]["automatic_read_only_rebind"] is True
assert state["acquisition"]["state"] == "awaiting_external_start"
assert state["acquisition"]["cleanup_pending"] is False
assert state["acquisition"]["result"] is None
assert state["last_operation"]["status"] == "running"
assert state["selected_device_id"] == "test-ble-transport"
assert state["source_mode"] == "live"
assert runtime.stop_calls == 0
assert control.start_projects == start_projects_before
assert control.stop_calls == stop_calls_before
assert service._physical_command_coordinator.snapshot() is physical # noqa: SLF001
def test_incident_host_route_streak_wakes_recovery_before_binding_retirement(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
@@ -20311,7 +20361,7 @@ def test_quick_connect_activates_the_device_ap_then_associates_the_host(
lambda _target: True,
)
_set_scanned_devices(service, [{"device_id": "k1-a", "name": "XGR-TEST-A"}])
activation_calls: list[tuple[str, str]] = []
activation_calls: list[tuple[str, str, float, float]] = []
association_calls: list[tuple[Path, str, str]] = []
ble_session_open = False
@@ -20331,12 +20381,21 @@ def test_quick_connect_activates_the_device_ap_then_associates_the_host(
async def fake_activation_session(
device_id: str,
*,
timeout_seconds: float,
connect_timeout_seconds: float,
write_mode: str,
on_write_dispatch: Callable[[dict[str, Any], str], None] | None = None,
**_: object,
) -> AsyncIterator[dict[str, Any]]:
nonlocal ble_session_open
activation_calls.append((device_id, write_mode))
activation_calls.append(
(
device_id,
write_mode,
timeout_seconds,
connect_timeout_seconds,
)
)
_dispatch_test_network_write(on_write_dispatch)
ble_session_open = True
try:
@@ -20396,7 +20455,14 @@ def test_quick_connect_activates_the_device_ap_then_associates_the_host(
)
)
assert activation_calls == [("k1-a", "with_response")]
assert activation_calls == [
(
"k1-a",
"with_response",
15.0,
facade_module.QUICK_CONNECT_BLE_CONNECT_TIMEOUT_SECONDS,
)
]
assert not ble_session_open
assert len(association_calls) == 1
assert association_calls[0][0].name == "associate_wifi.swift"