Files
pmaports-rtwo/device/testing/device-motorola-rtwo/rtwo-wifi-5ghz-scan.sh
T
snlavaiseandClaude Opus 5.5 98b3104e94 device-motorola-rtwo: package the dashboard and the 5 GHz WiFi workaround
Both lived only in the rootfs (/usr/local, /etc). Move them into the
device package:

- rtwo-dashboard: sway always runs with the system dashboard on the panel
  (DSI-1); the launcher follows the DP-1 HPD and opens a login console on
  the external monitor while one is connected. The console runs login as
  a session leader (setsid -c) and reopens the tty on every loop, since
  login's vhangup() otherwise leaves the loop with dead fds. Files go to
  /usr/libexec and /usr/share/rtwo-dashboard.
- rtwo-wifi-5ghz-scan: unsticks wpa_supplicant after boot (ath12k). The
  network now comes from NetworkManager (first WiFi connection) or from
  /etc/default/rtwo-wifi-5ghz-scan instead of a hardcoded SSID.

Both services are enabled through multi-user.target.wants, like
rtwo-panel-revive. New dependencies: sway, foot, seatd-launch, python3,
font-jetbrains-mono-nerd, font-noto-emoji, iw, networkmanager-cli.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnHwDU5yL8L6qgPEN5CV5m
2026-09-26 20:36:18 -03:00

67 lines
2.3 KiB
Bash

#!/bin/sh
# rtwo (ath12k / WCN7850), 2026-09-25. Tras el arranque, wpa_supplicant queda
# con un escaneo trabado ("Reject scan trigger since one is already pending")
# y su interfaz no sale de 'disconnected': NetworkManager no intenta conectar
# nunca. Ademas, los escaneos normales no recorren los canales de 5 GHz, y la red
# (en 5 GHz) no aparece.
# Hasta que wlan0 conecte: escaneo dirigido a 5 GHz (con 'scan abort' si da
# EBUSY), conexion explicita con nmcli si la red aparece, y reinicio de
# wpa_supplicant (NetworkManager se reengancha solo) si sigue sin conectar.
FREQS="5180 5200 5220 5240 5260 5280 5300 5320 5500 5520 5540 5560 5580 5600 5620 5640 5660 5680 5700 5720 5745 5765 5785 5805 5825"
# Red a destrabar: la primera conexion WiFi de NetworkManager, o la que se fije
# en /etc/default/rtwo-wifi-5ghz-scan (CON=<nombre de la conexion>).
[ -r /etc/default/rtwo-wifi-5ghz-scan ] && . /etc/default/rtwo-wifi-5ghz-scan
: "${CON:=$(nmcli -t -f NAME,TYPE connection show | awk -F: '$2 == "802-11-wireless" { print $1; exit }')}"
[ -n "$CON" ] || { echo "sin conexion WiFi en NetworkManager"; exit 0; }
: "${SSID:=$(nmcli -g 802-11-wireless.ssid connection show "$CON")}"
connected() {
nmcli -t -f DEVICE,STATE device | grep -q '^wlan0:connected$'
}
scan() {
iw dev wlan0 scan freq $FREQS ssid "$SSID" 2>&1
}
i=0
while [ ! -e /sys/class/net/wlan0 ] && [ $i -lt 60 ]; do
sleep 1; i=$((i + 1))
done
[ -e /sys/class/net/wlan0 ] || { echo "wlan0 no aparecio"; exit 1; }
sleep 10
n=0
while [ $n -lt 30 ]; do
if connected; then
echo "wlan0 conectado tras $n intentos"
exit 0
fi
n=$((n + 1))
if [ $n -eq 2 ] || [ $((n % 5)) -eq 0 ]; then
echo "#$n: reiniciando wpa_supplicant (escaneo trabado)"
systemctl restart wpa_supplicant
sleep 5
connected && continue
fi
out=$(scan)
if echo "$out" | grep -q 'Resource busy'; then
echo "#$n: EBUSY, scan abort y reintento"
iw dev wlan0 scan abort >/dev/null 2>&1
sleep 1
out=$(scan)
fi
if echo "$out" | grep -q "SSID: $SSID\$"; then
echo "#$n: $SSID encontrada, conectando con nmcli"
nmcli --wait 30 connection up "$CON" 2>&1 | sed 's/^/ nmcli: /'
else
nbss=$(echo "$out" | grep -c '^BSS ')
err=$(echo "$out" | grep -m1 'command failed')
echo "#$n: $SSID NO encontrada ($nbss BSS en 5 GHz) $err"
fi
sleep 10
done
echo "wlan0 sigue sin conectar tras $n intentos"
exit 1