Clean Python Flask replacement for odc-api (434k lines Node.js → ~350 lines Python)
- GET /api/1/landmarks/last/{N} - last N detections from SQLite
- POST /api/1/landmarks - ingest detections + forward to AdaMaps
- GET /api/1/gnssConcise/latestValid - GPS fix from Redis
- GET /api/1/status - device status
- GET /api/1/deviceinfo - device identity
- GET /api/1/recording/frames/latest - latest frame path
No /api/1/cmd - that's the CVE, it's gone.
Includes:
- SQLite for local storage + offline queue
- Background thread for AdaMaps retry
- systemd service unit
- install.sh for device deployment
28 lines
801 B
Python
28 lines
801 B
Python
"""Device status and info endpoints."""
|
|
import time
|
|
from flask import Blueprint, jsonify
|
|
from .. import config, redis_client
|
|
|
|
bp = Blueprint("status", __name__, url_prefix="/api/1")
|
|
|
|
_start_time = time.time()
|
|
|
|
|
|
@bp.route("/status", methods=["GET"])
|
|
def status():
|
|
"""Device status: firmware, uptime, GPS lock, camera status."""
|
|
return jsonify({
|
|
"firmware_version": config.FIRMWARE_VERSION,
|
|
"uptime_seconds": int(time.time() - _start_time),
|
|
"gps_lock": redis_client.has_gps_lock(),
|
|
"camera_status": "active", # TODO: check camera pipeline
|
|
})
|
|
|
|
|
|
@bp.route("/deviceinfo", methods=["GET"])
|
|
def deviceinfo():
|
|
"""Device identity."""
|
|
return jsonify({
|
|
"device_id": config.get("device_id"),
|
|
"firmware_version": config.FIRMWARE_VERSION,
|
|
})
|