net: swap WiFi roles — fast T3U (wlan1) hosts AP, onboard (wlan0) carries uplink
- yaris_uplink.py: PRIMARY_INTERFACE=wlan0, AP_INTERFACE=wlan1, AP_CONNECTION=Hotspot-local - install_netwatch.sh: WLAN=wlan0, WLAN_FB=wlan1, AP on wlan1 - _ap_client_count() reads the AP interface instead of hardcoded wlan0
This commit is contained in:
+13
-9
@@ -11,9 +11,13 @@ import uuid
|
||||
|
||||
PHONE_CONNECTION = "phone-hotspot"
|
||||
HOME_CONNECTION = "home-wifi"
|
||||
AP_CONNECTION = "Hotspot"
|
||||
PRIMARY_INTERFACE = "wlan1" # TP-Link T3U dongle — preferred
|
||||
FALLBACK_INTERFACE = "wlan0" # onboard — used if T3U is absent
|
||||
AP_CONNECTION = "Hotspot-local"
|
||||
# 2026-08-12 swap: the fast TP-Link T3U (wlan1) hosts the in-car AP so phones
|
||||
# get 5GHz AC throughput; the weak onboard BCM43438 (wlan0) carries the
|
||||
# internet uplink (home-wifi / phone-hotspot), which is background traffic.
|
||||
AP_INTERFACE = "wlan1"
|
||||
PRIMARY_INTERFACE = "wlan0" # onboard — internet uplink
|
||||
FALLBACK_INTERFACE = "wlan1" # T3U — uplink fallback if onboard is absent
|
||||
STATUS_PATH = "/var/lib/yaris-obd/uplink-status.json"
|
||||
PHONE_KEYFILE = (
|
||||
"/etc/NetworkManager/system-connections/"
|
||||
@@ -199,7 +203,7 @@ def write_status(action, error=None):
|
||||
|
||||
|
||||
def restore_fallback():
|
||||
"""Try home-wifi on wlan1. wlan0 AP is permanent and never touched."""
|
||||
"""Try home-wifi on the uplink interface. The AP on wlan1 is never touched."""
|
||||
if activate(HOME_CONNECTION):
|
||||
write_status("connected_home")
|
||||
return True
|
||||
@@ -208,10 +212,10 @@ def restore_fallback():
|
||||
|
||||
|
||||
def _ap_client_count():
|
||||
"""Return number of stations connected to the AP on wlan0."""
|
||||
"""Return number of stations connected to the AP on wlan1 (T3U)."""
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
["iw", "dev", "wlan0", "station", "dump"],
|
||||
["iw", "dev", AP_INTERFACE, "station", "dump"],
|
||||
capture_output=True, text=True, timeout=5,
|
||||
)
|
||||
return proc.stdout.count("Station ")
|
||||
@@ -220,7 +224,7 @@ def _ap_client_count():
|
||||
|
||||
|
||||
def check_uplink():
|
||||
"""Manage internet uplink on wlan1 only. wlan0 is a permanent AP, never touched."""
|
||||
"""Manage internet uplink on wlan0 only. wlan1 AP is never touched."""
|
||||
current = active_connection()
|
||||
phone_configured = connection_exists(PHONE_CONNECTION)
|
||||
|
||||
@@ -240,7 +244,7 @@ def check_uplink():
|
||||
return _connect_home_or_idle()
|
||||
|
||||
if phone_configured:
|
||||
# Only take down the phone hotspot if it's up — never touch the AP on wlan0
|
||||
# Only take down the phone hotspot if it's up — never touch the AP on wlan1
|
||||
was_phone = current == PHONE_CONNECTION
|
||||
if was_phone:
|
||||
run_nmcli("connection", "down", PHONE_CONNECTION, check=False)
|
||||
@@ -281,7 +285,7 @@ def check_uplink():
|
||||
|
||||
|
||||
def _connect_home_or_idle():
|
||||
"""Try home-wifi on wlan1. wlan0 AP is never touched."""
|
||||
"""Try home-wifi on the uplink interface. The AP on wlan1 is never touched."""
|
||||
if activate(HOME_CONNECTION):
|
||||
write_status("connected_home")
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user