fix(phase26): skip netwatch AP scan when clients connected (BUG-01)

This commit is contained in:
Mathieu Moran
2026-08-11 03:11:13 -04:00
parent f9d967e71c
commit 89bbc4fdb8
3 changed files with 71 additions and 0 deletions
+19
View File
@@ -220,9 +220,28 @@ def restore_fallback():
return False
def _ap_client_count():
"""Return number of stations connected to the AP on INTERFACE."""
try:
proc = subprocess.run(
["iw", "dev", INTERFACE, "station", "dump"],
capture_output=True, text=True, timeout=5,
)
return proc.stdout.count("Station ")
except (OSError, subprocess.SubprocessError):
return 0
def check_uplink():
current = active_connection()
phone_configured = connection_exists(PHONE_CONNECTION)
# Never tear down the AP if a client is connected — the user is actively
# using the hotspot (e.g. phone browsing the web UI while driving).
# Skip this netwatch cycle and let the next one try again.
if current == AP_CONNECTION and _ap_client_count() > 0:
write_status("ap_has_clients_skipped_check")
return True
if current == PHONE_CONNECTION:
if internet_reachable():
write_status("phone_connected")