feat(fleet): integrate independent trackers, VPS pairing and recoverable commands

This commit is contained in:
DCCONSTRUCTIONS
2026-09-28 18:44:12 +03:00
parent d684eb7e05
commit f3a7592d90
45 changed files with 10006 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
"""Admit the owner VPS before touching the tracker's initial USB channels."""
import time
from .independent_equipment import EquipmentError
def apply(hosts, identifier, revision):
equipment = hosts.equipment
with hosts.lock:
row = next((r for r in equipment.listing() if r["id"] == identifier), None)
if row is None or row["revision"] != revision:
raise EquipmentError("Настройки изменились. Откройте устройство заново.")
equipment.require_idle(row)
endpoint = row["settings"].get("endpoint")
if not endpoint or endpoint["slot"] != 1:
raise EquipmentError("Выберите ваш VPS как сервер 1 для первоначальной настройки.")
host = next(
(
h
for h in hosts.rows()
if h["state"] == "paired"
and row["vehicle_id"] in h["vehicle_ids"]
and h.get("status", {}).get("tracker") == {k: endpoint[k] for k in ("host", "port")}
),
None,
)
if not host:
raise EquipmentError("Сначала подключите выбранный VPS к этому аппарату.")
hosts.sync(host) # durably admit this device before its first cellular connection
if (
host.get("status", {}).get("version")
not in (
"0.1.15",
"0.1.16",
"0.1.17",
"0.1.18",
"0.1.19",
"0.1.20",
"0.1.21",
"0.1.22",
"0.1.23",
"0.1.24",
"0.1.25",
"0.1.26",
"0.1.27",
"0.1.28",
"0.1.29",
"0.1.30",
"0.1.31",
"0.1.32",
"0.1.33",
"0.1.34",
"0.1.35",
"0.1.36",
"0.1.37",
"0.1.38",
"0.1.39",
"0.1.40",
"0.1.41",
)
or time.time() - host["last_sync_at"] > 30
):
raise EquipmentError("Установите актуальный VPS Host и проверьте связь с ним.")
return equipment.apply(identifier, revision)