fix(phase26): skip netwatch AP scan when clients connected (BUG-01)
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user