Initial commit: adacam-api v1.0.0
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
This commit is contained in:
parent
5dd91b0b15
commit
7acc5ab088
17 changed files with 507 additions and 1 deletions
52
adacam_api/config.py
Normal file
52
adacam_api/config.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
"""Config management for adacam-api."""
|
||||
import json
|
||||
import os
|
||||
import uuid
|
||||
|
||||
CONFIG_PATH = "/data/adacam/config.json"
|
||||
FIRMWARE_VERSION = "adacam-1.0.0"
|
||||
|
||||
_defaults = {
|
||||
"device_id": None,
|
||||
"adamaps_key": "***REMOVED***",
|
||||
"adamaps_api": "https://api.adamaps.org",
|
||||
"ap_interface": "wlp1s0f0",
|
||||
"tunnel_host": "",
|
||||
"tunnel_user": "",
|
||||
"tunnel_port": 2222,
|
||||
}
|
||||
|
||||
_config = None
|
||||
|
||||
|
||||
def load():
|
||||
"""Load config from disk, creating defaults if needed."""
|
||||
global _config
|
||||
os.makedirs(os.path.dirname(CONFIG_PATH), exist_ok=True)
|
||||
|
||||
if os.path.exists(CONFIG_PATH):
|
||||
with open(CONFIG_PATH) as f:
|
||||
_config = {**_defaults, **json.load(f)}
|
||||
else:
|
||||
_config = _defaults.copy()
|
||||
|
||||
# Generate device_id on first run
|
||||
if not _config.get("device_id"):
|
||||
_config["device_id"] = str(uuid.uuid4())
|
||||
save()
|
||||
|
||||
return _config
|
||||
|
||||
|
||||
def save():
|
||||
"""Persist config to disk."""
|
||||
os.makedirs(os.path.dirname(CONFIG_PATH), exist_ok=True)
|
||||
with open(CONFIG_PATH, "w") as f:
|
||||
json.dump(_config, f, indent=2)
|
||||
|
||||
|
||||
def get(key, default=None):
|
||||
"""Get a config value."""
|
||||
if _config is None:
|
||||
load()
|
||||
return _config.get(key, default)
|
||||
Loading…
Add table
Add a link
Reference in a new issue