diff --git a/openpilot/starpilot/system/starport/supervisor.py b/openpilot/starpilot/system/starport/supervisor.py index f021334669..f0b042b569 100644 --- a/openpilot/starpilot/system/starport/supervisor.py +++ b/openpilot/starpilot/system/starport/supervisor.py @@ -289,7 +289,7 @@ class SharedRadioWatch: self.counter = counter or Path(f"/sys/class/net/{interface}/carrier_changes") self.carrier = carrier or Path(f"/sys/class/net/{interface}/carrier") self.on_down = on_down # the other network was lost, not just roamed - self.on_stall = on_stall # the car's acks stopped after a change + self.on_stall = on_stall # the car's acks stopped after a change that has not connected yet self.changed_at: float | None = None self._stop = threading.Event() self._thread = threading.Thread(target=self._run, name="aa_radio_watch", daemon=True) @@ -329,6 +329,11 @@ class SharedRadioWatch: self.log("other_wifi_hold_failed", error=str(error) or type(error).__name__) def stalled(self) -> None: + # A join that already connected has only its address left. Stopping it there lost the hotspot and still + # dropped the car on 2026-11-16, while a joined hotspot then streamed alongside the car for minutes. + if self._carrier(): + self.log("other_wifi_join_kept", interface=self.interface) + return if self.on_stall is not None: self.on_stall() diff --git a/openpilot/starpilot/system/starport/tests/test_shared_radio_grace.py b/openpilot/starpilot/system/starport/tests/test_shared_radio_grace.py index fab1f2c971..3b06e72bdc 100644 --- a/openpilot/starpilot/system/starport/tests/test_shared_radio_grace.py +++ b/openpilot/starpilot/system/starport/tests/test_shared_radio_grace.py @@ -135,6 +135,19 @@ def test_watch_holds_home_wifi_only_when_it_was_lost(tmp_path, carrier, held): watch.stop() +@pytest.mark.parametrize("carrier, stopped", [("1\n", False), ("0\n", True), (None, True)]) +def test_stall_keeps_a_join_that_already_connected(tmp_path, carrier, stopped): + carrier_path = tmp_path / "carrier" + if carrier is not None: + carrier_path.write_text(carrier) + stops, logged = [], [] + watch = SharedRadioWatch(lambda name, **fields: logged.append(name), counter=tmp_path / "carrier_changes", + carrier=carrier_path, on_stall=lambda: stops.append(True)) + watch.stalled() + assert stops == ([True] if stopped else []) + assert logged == ([] if stopped else ["other_wifi_join_kept"]) + + def test_watch_without_the_counter_never_reports(tmp_path): watch = SharedRadioWatch(lambda *a, **k: None, interval=0.01, counter=tmp_path / "missing").start() try: