Revive yaris-obd: USB OBD adapter, real GPS/GNSS, offline map, hotspot, SQLite logging, dashcam retrieval
Squashed rewrite of the project revival work (replaces prior history on this branch to remove personal data that had been accidentally committed - real LAN IP, GPS coordinates, home WiFi SSID, and phone model). See PLAN.md for full phase-by-phase details. Summary: - Phase 2: adapt app_obd.py for a USB OBD-II adapter (was Bluetooth-only), auto-detect /dev/ttyUSB*, fix several pre-existing crash bugs. - Phase 3/4: make the web UI work fully offline (vendored Socket.IO/Leaflet/ Chart.js/FontAwesome, offline map tile downloader script, live GPS marker tracking fix). - Phase 5: systemd deployment/autostart on the Pi. - Phase 6: WiFi hotspot mode via NetworkManager (auto-switch between home WiFi and a local AP for in-car web UI access), mDNS hostname + port 80 redirect so the UI is reachable at a plain hostname with no port number. - Phase 7: fix app_db.py/app_sql.py bugs, wire up local SQLite trip logging. - Phase 8: brand-agnostic USB dashcam file retrieval (lsblk transport-based detection, works with any dashcam brand/folder layout). - Rewritten readme.md with a proper project overview. Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# yaris-netwatch.sh
|
||||
#
|
||||
# Runs periodically via yaris-netwatch.timer. If wlan0 is currently in
|
||||
# AP/hotspot mode, briefly attempts to reconnect to the known home WiFi.
|
||||
# If that succeeds, we're back on home WiFi (used for syncing itinerary/
|
||||
# dashcam data to the remote server). If it fails (still out of range),
|
||||
# reactivates the hotspot so the web UI stays reachable locally in the car.
|
||||
#
|
||||
# The Pi's onboard WiFi radio (BCM43438) cannot act as an AP and scan for
|
||||
# client networks at the same time, so this brief switch-and-check is the
|
||||
# only way to detect "home WiFi is back in range" while sitting in AP mode.
|
||||
# The reverse direction (home WiFi -> hotspot, i.e. leaving range) is handled
|
||||
# automatically by NetworkManager's own autoconnect-priority mechanism and
|
||||
# needs no watcher: the "home-wifi" profile has a higher
|
||||
# connection.autoconnect-priority than Hotspot, so NM tries it first whenever
|
||||
# the device needs to reconnect, and falls through to Hotspot on its own once
|
||||
# home WiFi drops out of range.
|
||||
|
||||
set -u
|
||||
|
||||
LOG_TAG="yaris-netwatch"
|
||||
HOME_CON="home-wifi"
|
||||
AP_CON="Hotspot"
|
||||
IFACE="wlan0"
|
||||
LAST_LOG="/tmp/yaris-netwatch-last.log"
|
||||
|
||||
active_con() {
|
||||
nmcli -t -f DEVICE,CONNECTION device status | awk -F: -v d="$IFACE" '$1==d {print $2}'
|
||||
}
|
||||
|
||||
current="$(active_con)"
|
||||
|
||||
if [ "$current" != "$AP_CON" ]; then
|
||||
# Already on home WiFi (or something else) - nothing to do.
|
||||
logger -t "$LOG_TAG" "wlan0 is on '$current', no action needed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
logger -t "$LOG_TAG" "wlan0 is on hotspot, checking for home WiFi ($HOME_CON)..."
|
||||
|
||||
if nmcli --wait 20 con up "$HOME_CON" >"$LAST_LOG" 2>&1; then
|
||||
logger -t "$LOG_TAG" "home WiFi found, switched to '$HOME_CON'"
|
||||
else
|
||||
logger -t "$LOG_TAG" "home WiFi not found, restoring hotspot"
|
||||
nmcli con up "$AP_CON" >>"$LAST_LOG" 2>&1
|
||||
fi
|
||||
Reference in New Issue
Block a user