diff --git a/scripts/diagnose.sh b/scripts/diagnose.sh index 24c2020..0bf300f 100755 --- a/scripts/diagnose.sh +++ b/scripts/diagnose.sh @@ -7,6 +7,15 @@ # Without --fix : read-only health check, prints a report, exits 0 if healthy. # With --fix : attempts to auto-fix every issue it finds. Safe to run while # the service is running — restarts are done with systemctl. +# +# Current project layout (2026-08): +# Pi (Raspberry Pi 3) — Flask web UI + SQLite + OBD/GPS/dashcam, hosted as a +# 5GHz AP on wlan1 (T3U #1, 10.42.0.1); internet uplink on wlan2 (T3U #2, +# home WiFi "BuzzBis" or phone hotspot); onboard wlan0 retired to fallback. +# Android companion app — connects to http://10.42.0.1 over the hotspot for +# the live dashboard + dashcam downloads, uploads to the remote server +# (https://yaris.ceaf.dev) over the phone's own cellular link. +# Remote server — self-hosted Flask+Postgres stack (unraid, yaris.ceaf.dev). # ============================================================================= set -euo pipefail @@ -129,17 +138,48 @@ fi # ── 3. Network ──────────────────────────────────────────────────────────────── section "3. Network & Hotspot" -# Hotspot (wlan0 or wlan1) -HOTSPOT_IFACE=$(ip -o link show | awk '/wlan/{print $2}' | tr -d ':' | head -1) -if [ -n "$HOTSPOT_IFACE" ]; then - HOTSPOT_IP=$(ip -4 addr show "$HOTSPOT_IFACE" 2>/dev/null | awk '/inet /{print $2}' | head -1) - if [ -n "$HOTSPOT_IP" ]; then - pass "WiFi interface $HOTSPOT_IFACE has IP $HOTSPOT_IP" +# In-car AP lives on wlan1 (T3U #1, 5GHz @ 10.42.0.1). The Android app and the +# phone browser connect to this for the live dashboard + dashcam downloads. +AP_IFACE="wlan1" +if ip -o link show | grep -q "^[0-9]*: $AP_IFACE:"; then + AP_IP=$(ip -4 addr show "$AP_IFACE" 2>/dev/null | awk '/inet /{print $2}' | head -1) + if [ -n "$AP_IP" ]; then + pass "In-car AP up on $AP_IFACE ($AP_IP)" + if echo "$AP_IP" | grep -q "10.42.0.1/"; then + pass " AP is on the expected 10.42.0.1/24 subnet" + else + warn " AP IP is $AP_IP — expected 10.42.0.1/24" + fi else - warn "WiFi interface $HOTSPOT_IFACE has no IP address" + fail "In-car AP interface $AP_IFACE has no IP — hotspot down?" + fix_action "bring up the AP profile" "sudo nmcli con up Hotspot-local" fi else - warn "No WiFi interface detected" + fail "AP interface $AP_IFACE missing — is T3U #1 plugged in?" +fi + +# Internet uplink lives on wlan2 (T3U #2) — home WiFi "BuzzBis" or phone hotspot. +UL_IFACE="wlan2" +if ip -o link show | grep -q "^[0-9]*: $UL_IFACE:"; then + UL_IP=$(ip -4 addr show "$UL_IFACE" 2>/dev/null | awk '/inet /{print $2}' | head -1) + UL_SSID=$(nmcli -t -f GENERAL.CONNECTION device show "$UL_IFACE" 2>/dev/null | sed 's/GENERAL.CONNECTION://' || true) + if [ -n "$UL_IP" ]; then + pass "Uplink up on $UL_IFACE ($UL_IP${UL_SSID:+ via $UL_SSID})" + else + warn "Uplink interface $UL_IFACE has no IP (normal when out of WiFi/phone range)" + fi +else + warn "Uplink interface $UL_IFACE missing — second T3U not plugged in?" +fi + +# Onboard BCM43438 (wlan0) is retired to a weak fallback — informational only. +if ip -o link show | grep -q "^[0-9]*: wlan0:"; then + W0_IP=$(ip -4 addr show wlan0 2>/dev/null | awk '/inet /{print $2}' | head -1) + if [ -n "$W0_IP" ]; then + info "Onboard wlan0 active ($W0_IP) — normally retired to fallback" + else + info "Onboard wlan0 present but inactive (retired fallback)" + fi fi # Is the web UI reachable locally? @@ -353,6 +393,10 @@ section "8. Manual Recovery Commands" info "Restart service: sudo systemctl restart $SERVICE" info "View live logs: tail -f $LOG_FILE" info "Journalctl logs: sudo journalctl -u $SERVICE -f" +info "Bring up AP (wlan1): sudo nmcli con up Hotspot-local" +info "Bring up uplink (wlan2): sudo nmcli con up home-wifi" +info "Phone app URL: http://10.42.0.1/ (hotspot) — Android app in ./android" +info "Remote server: https://yaris.ceaf.dev" info "Force OBD_PROTOCOL=6: sudo systemctl edit $SERVICE" info " (add: Environment=OBD_PROTOCOL=6 then restart)" info "Skip voltage check: sudo systemctl edit $SERVICE"