Tie points to locator serial numbers and store receiver telemetry
Field setups often relay through a phone/gateway that owns the MQTT connection, so the publishing credential and the instrument are now separate concepts: - Points messages carry a "serial" identifying the locator receiver; unknown serials are auto-registered as devices in the publisher's org (name "Locator <serial>"). Device.mqttUsername is now optional and serialNumber is unique per org. - LocatePoint gains standard receiver telemetry: frequencyHz, currentMa, signalDb, gainDb, locateMode (PEAK/NULL/BROAD_PEAK/SONDE), phaseDeg, compassDeg, distortionPct, plus GPS quality columns vAccuracy, satellites, hdop. All optional; raw payload still kept. - Migration hand-edited to preserve the generated geom column and its GIST index (Prisma diff wanted to drop both). - REST create/point DTOs, map tooltips, job-detail latest-point readout, devices settings form, seed, and the sample publisher all carry the new fields. - Added .dockerignore for backend/web: COPY . . was clobbering the image's freshly generated Prisma client with the host's stale node_modules, breaking image builds after schema changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,11 +3,16 @@
|
||||
The backend subscribes to devices/# and expects points at
|
||||
devices/{mqttUsername}/points with a JSON body:
|
||||
|
||||
{"ticket": "TKT-...", "points": [{"lat": .., "lng": .., "ts": "ISO8601", ...}]}
|
||||
{"serial": "...", "ticket": "TKT-...",
|
||||
"points": [{"lat": .., "lng": .., "ts": "ISO8601", ...}]}
|
||||
|
||||
Points for an unknown ticket auto-create a stub job (source=DEVICE).
|
||||
The MQTT username identifies the publisher (app/gateway) and its org; "serial"
|
||||
names the locator receiver the readings came from (auto-registered on first
|
||||
sight). Points for an unknown ticket auto-create a stub job (source=DEVICE).
|
||||
"""
|
||||
|
||||
import random
|
||||
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
@@ -19,6 +24,7 @@ BROKER_HOST = os.getenv("MQTT_HOST", "127.0.0.1")
|
||||
BROKER_PORT = int(os.getenv("MQTT_PORT", "1883"))
|
||||
USERNAME = os.getenv("MQTT_USERNAME", "testuser")
|
||||
PASSWORD = os.getenv("MQTT_PASSWORD", "testpass")
|
||||
SERIAL = os.getenv("SERIAL", "DEMO-0001")
|
||||
TICKET = os.getenv("TICKET", "TKT-2026-0001")
|
||||
INTERVAL = float(os.getenv("MQTT_INTERVAL", "2"))
|
||||
|
||||
@@ -37,6 +43,7 @@ try:
|
||||
seq = 0
|
||||
while True:
|
||||
payload = {
|
||||
"serial": SERIAL,
|
||||
"ticket": TICKET,
|
||||
"points": [
|
||||
{
|
||||
@@ -45,7 +52,17 @@ try:
|
||||
"alt": 187.4 + seq * 0.02,
|
||||
"fix": "FIXED_RTK",
|
||||
"hAcc": 0.014,
|
||||
"depth": 1.2,
|
||||
"vAcc": 0.021,
|
||||
"sats": random.randint(18, 26),
|
||||
"hdop": 0.7,
|
||||
"depth": round(1.1 + random.uniform(0, 0.3), 2),
|
||||
"freqHz": 33000,
|
||||
"currentMa": round(50 - seq * 0.4 + random.uniform(-1, 1), 1),
|
||||
"signalDb": round(62 - seq * 0.2 + random.uniform(-0.5, 0.5), 1),
|
||||
"gainDb": 40,
|
||||
"mode": "PEAK",
|
||||
"compassDeg": round(17.5 + random.uniform(-3, 3), 1),
|
||||
"distortionPct": round(random.uniform(2, 8), 1),
|
||||
"utility": "GAS",
|
||||
"seq": seq + 1,
|
||||
"ts": datetime.now(timezone.utc).isoformat(),
|
||||
|
||||
Reference in New Issue
Block a user