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:
@@ -7,13 +7,15 @@
|
|||||||
# already exist (see PLAN.md Phase 6). The optional "phone-hotspot" profile is
|
# already exist (see PLAN.md Phase 6). The optional "phone-hotspot" profile is
|
||||||
# created through the Settings page.
|
# created through the Settings page.
|
||||||
#
|
#
|
||||||
# Since Phase 23+: all WiFi traffic (hotspot AP, phone client, home client)
|
# Since 2026-08-12: the fast TP-Link T3U (wlan1) hosts the in-car AP
|
||||||
# runs on wlan1 (TP-Link T3U dongle). wlan0 (onboard) is disabled.
|
# ("Hotspot-local"), while the onboard BCM43438 (wlan0) carries the internet
|
||||||
|
# uplink (home-wifi / phone-hotspot).
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
WLAN=wlan1 # T3U dongle — change to wlan0 if reverting to onboard
|
WLAN=wlan0 # onboard — internet uplink
|
||||||
WLAN_FB=wlan0 # onboard fallback
|
WLAN_FB=wlan1 # T3U — uplink fallback
|
||||||
|
AP_IFACE=wlan1 # T3U — hosts the in-car AP
|
||||||
|
|
||||||
sudo systemctl stop yaris-uplink-wait.service 2>/dev/null || true
|
sudo systemctl stop yaris-uplink-wait.service 2>/dev/null || true
|
||||||
sudo systemctl stop yaris-netwatch.timer yaris-netwatch.service 2>/dev/null || true
|
sudo systemctl stop yaris-netwatch.timer yaris-netwatch.service 2>/dev/null || true
|
||||||
@@ -26,10 +28,11 @@ sudo install -m 644 "$REPO_DIR/deploy/yaris-hotspot-dns.conf" \
|
|||||||
sudo install -m 755 "$REPO_DIR/deploy/90-yaris-uplink" \
|
sudo install -m 755 "$REPO_DIR/deploy/90-yaris-uplink" \
|
||||||
/etc/NetworkManager/dispatcher.d/90-yaris-uplink
|
/etc/NetworkManager/dispatcher.d/90-yaris-uplink
|
||||||
|
|
||||||
# Bind all connections to the T3U dongle (wlan1)
|
# Bind the internet uplink to the onboard radio (wlan0)
|
||||||
sudo nmcli connection modify home-wifi connection.interface-name "$WLAN"
|
sudo nmcli connection modify home-wifi connection.interface-name "$WLAN"
|
||||||
sudo nmcli connection modify Hotspot \
|
# The in-car AP lives on the fast T3U (wlan1)
|
||||||
connection.interface-name "$WLAN" \
|
sudo nmcli connection modify Hotspot-local \
|
||||||
|
connection.interface-name "$AP_IFACE" \
|
||||||
ipv4.method shared \
|
ipv4.method shared \
|
||||||
ipv4.addresses 10.42.0.1/24
|
ipv4.addresses 10.42.0.1/24
|
||||||
if nmcli connection show phone-hotspot >/dev/null 2>&1; then
|
if nmcli connection show phone-hotspot >/dev/null 2>&1; then
|
||||||
@@ -40,8 +43,8 @@ if nmcli connection show phone-hotspot >/dev/null 2>&1; then
|
|||||||
802-11-wireless.mtu 1400
|
802-11-wireless.mtu 1400
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create wlan0 fallback profiles (lower autoconnect-priority so wlan1 wins)
|
# Create wlan1 fallback profile (lower autoconnect-priority so wlan0 wins)
|
||||||
# home-wifi-fb: same SSID as home-wifi but on wlan0
|
# home-wifi-fb: same SSID as home-wifi but on wlan1 (T3U)
|
||||||
HOME_SSID=$(nmcli -g 802-11-wireless.ssid connection show home-wifi 2>/dev/null || true)
|
HOME_SSID=$(nmcli -g 802-11-wireless.ssid connection show home-wifi 2>/dev/null || true)
|
||||||
HOME_PSK=$(sudo nmcli -g 802-11-wireless-security.psk connection show --show-secrets home-wifi 2>/dev/null || true)
|
HOME_PSK=$(sudo nmcli -g 802-11-wireless-security.psk connection show --show-secrets home-wifi 2>/dev/null || true)
|
||||||
if [ -n "$HOME_SSID" ] && [ -n "$HOME_PSK" ]; then
|
if [ -n "$HOME_SSID" ] && [ -n "$HOME_PSK" ]; then
|
||||||
|
|||||||
+13
-9
@@ -11,9 +11,13 @@ import uuid
|
|||||||
|
|
||||||
PHONE_CONNECTION = "phone-hotspot"
|
PHONE_CONNECTION = "phone-hotspot"
|
||||||
HOME_CONNECTION = "home-wifi"
|
HOME_CONNECTION = "home-wifi"
|
||||||
AP_CONNECTION = "Hotspot"
|
AP_CONNECTION = "Hotspot-local"
|
||||||
PRIMARY_INTERFACE = "wlan1" # TP-Link T3U dongle — preferred
|
# 2026-08-12 swap: the fast TP-Link T3U (wlan1) hosts the in-car AP so phones
|
||||||
FALLBACK_INTERFACE = "wlan0" # onboard — used if T3U is absent
|
# 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"
|
STATUS_PATH = "/var/lib/yaris-obd/uplink-status.json"
|
||||||
PHONE_KEYFILE = (
|
PHONE_KEYFILE = (
|
||||||
"/etc/NetworkManager/system-connections/"
|
"/etc/NetworkManager/system-connections/"
|
||||||
@@ -199,7 +203,7 @@ def write_status(action, error=None):
|
|||||||
|
|
||||||
|
|
||||||
def restore_fallback():
|
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):
|
if activate(HOME_CONNECTION):
|
||||||
write_status("connected_home")
|
write_status("connected_home")
|
||||||
return True
|
return True
|
||||||
@@ -208,10 +212,10 @@ def restore_fallback():
|
|||||||
|
|
||||||
|
|
||||||
def _ap_client_count():
|
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:
|
try:
|
||||||
proc = subprocess.run(
|
proc = subprocess.run(
|
||||||
["iw", "dev", "wlan0", "station", "dump"],
|
["iw", "dev", AP_INTERFACE, "station", "dump"],
|
||||||
capture_output=True, text=True, timeout=5,
|
capture_output=True, text=True, timeout=5,
|
||||||
)
|
)
|
||||||
return proc.stdout.count("Station ")
|
return proc.stdout.count("Station ")
|
||||||
@@ -220,7 +224,7 @@ def _ap_client_count():
|
|||||||
|
|
||||||
|
|
||||||
def check_uplink():
|
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()
|
current = active_connection()
|
||||||
phone_configured = connection_exists(PHONE_CONNECTION)
|
phone_configured = connection_exists(PHONE_CONNECTION)
|
||||||
|
|
||||||
@@ -240,7 +244,7 @@ def check_uplink():
|
|||||||
return _connect_home_or_idle()
|
return _connect_home_or_idle()
|
||||||
|
|
||||||
if phone_configured:
|
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
|
was_phone = current == PHONE_CONNECTION
|
||||||
if was_phone:
|
if was_phone:
|
||||||
run_nmcli("connection", "down", PHONE_CONNECTION, check=False)
|
run_nmcli("connection", "down", PHONE_CONNECTION, check=False)
|
||||||
@@ -281,7 +285,7 @@ def check_uplink():
|
|||||||
|
|
||||||
|
|
||||||
def _connect_home_or_idle():
|
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):
|
if activate(HOME_CONNECTION):
|
||||||
write_status("connected_home")
|
write_status("connected_home")
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user