StarPort: Keep A Home Wi-Fi Join That Already Connected

- When the car's acks stall right after the comma's own Wi-Fi changes, stop the join only if it has not connected yet.
- A join that already connected (only its address left) is kept and logged as other_wifi_join_kept; the 8 s grace still reconnects the car if acks never return.
- 2026-11-16: stopping a connected iPhone hotspot join lost the hotspot and still dropped the car, while a joined hotspot streamed alongside the car for minutes.
This commit is contained in:
dirwin31
2026-11-16 07:02:09 -08:00
committed by Danny
parent 3d6c33e720
commit 7c0b4bf06b
2 changed files with 19 additions and 1 deletions
@@ -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()
@@ -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: