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:
Mathieu Moran
2026-08-08 18:01:35 -04:00
co-authored by Copilot
parent f91a3d479d
commit 261ef3f4db
46 changed files with 2150 additions and 255 deletions
+14 -7
View File
File diff suppressed because one or more lines are too long
+65
View File
@@ -0,0 +1,65 @@
// Dashcam page: scan for a USB dashcam, then trigger importing its videos.
// Uses plain fetch() (not socket.io / yaris.js) since this is a one-shot
// request/response flow, not a live data stream, and yaris.js assumes DOM
// elements (#map, #speedGraph) that don't exist on this page.
const deviceStatus = document.getElementById('dash-device-status');
const importStatus = document.getElementById('dash-import-status');
const scanBtn = document.getElementById('dash-scan-btn');
const importBtn = document.getElementById('dash-import-btn');
function describeDevice(device) {
const label = device.label ? ` "${device.label}"` : '';
return `${device.path}${label} (${device.size}, ${device.fstype || 'unknown fs'})`;
}
function scanForDashcam() {
deviceStatus.textContent = 'Scanning...';
importBtn.disabled = true;
fetch('/api/dash/devices')
.then(response => response.json())
.then(data => {
const devices = data.devices || [];
if (devices.length === 0) {
deviceStatus.textContent = 'No USB dashcam/storage device detected. Plug it in and scan again.';
return;
}
deviceStatus.textContent = 'Detected: ' + devices.map(describeDevice).join(', ');
importBtn.disabled = false;
})
.catch(err => {
deviceStatus.textContent = 'Error while scanning: ' + err;
});
}
function importDashcam() {
importStatus.textContent = 'Importing... this can take a while for large videos.';
importBtn.disabled = true;
fetch('/api/dash/import', { method: 'POST' })
.then(response => response.json())
.then(summary => {
if (summary.status !== 'ok') {
importStatus.textContent = summary.message || ('Import failed: ' + summary.status);
return;
}
let text = `Found ${summary.found} video(s), copied ${summary.copied}, skipped ${summary.skipped} (already imported).`;
if (summary.errors && summary.errors.length > 0) {
text += ` Errors: ${summary.errors.join('; ')}`;
}
importStatus.textContent = text;
})
.catch(err => {
importStatus.textContent = 'Error while importing: ' + err;
})
.finally(() => {
importBtn.disabled = false;
});
}
scanBtn.addEventListener('click', scanForDashcam);
importBtn.addEventListener('click', importDashcam);
// Auto-scan once when the page loads.
scanForDashcam();
+24 -7
View File
@@ -1,13 +1,19 @@
const socket = io();
// map
var map = L.map('map').setView([48.505, -0.09], 13);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
// Offline tiles pre-downloaded via scripts/download_map_tiles.py (see PLAN.md
// Phase 3). Only zoom 8-15 is cached by default - matches DEFAULT_MIN_ZOOM/
// DEFAULT_MAX_ZOOM in that script.
// Generic placeholder center (not a real location) - re-centers automatically
// to the real live GPS fix once one comes in (see gps_location handler below).
var map = L.map('map', { minZoom: 8, maxZoom: 15 }).setView([48.505, -0.09], 12);
L.tileLayer('/static/vendor/tiles/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.maptiler.com/copyright/" target="_blank">MapTiler</a> &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
minZoom: 8,
maxZoom: 15
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('your car... soon(tm)')
.openPopup();
var carMarker = L.marker(map.getCenter()).addTo(map)
.bindPopup('your car... soon(tm)');
// charts
@@ -95,6 +101,8 @@ socket.on('rpi_uptime', function(data) {
status.innerHTML = data;
});
let mapCentered = false;
socket.on('gps_location', function(data) {
console.log("location received")
const LocationX = document.getElementById('gpsLocationX');
@@ -102,4 +110,13 @@ socket.on('gps_location', function(data) {
LocationX.innerHTML = data[0];
LocationY.innerHTML = data[1];
});
const lat = data[0];
const lon = data[1];
if (lat != null && lon != null) {
carMarker.setLatLng([lat, lon]);
if (!mapCentered) {
map.setView([lat, lon], 15);
mapCentered = true;
}
}
});