fix(telemetry): allineamento stati hangtime e risoluzione falsi positivi sui beacon

- Backend (mqtt_service.py): Aggiunta logica per intercettare i pacchetti beacon in assenza di traffico voce. Il sistema ora pulisce la memoria dei modi alternativi (es. D-Star/YSF) se il beacon è DMR, prevenendo il blocco dell'interfaccia su un vecchio protocollo.
- Frontend (app.js): La memorizzazione del colore e del modo per la gestione dell'hangtime (Hold) ora scatta con la condizione `!isIdle` anziché solo con il PTT voce (`isTx`).
- I badge della dashboard Home ora mostrano coerentemente il protocollo corretto per tutta la durata dell'hangtime, sia dopo un passaggio voce che dopo un beacon di rete.
This commit is contained in:
2026-11-01 09:31:40 +01:00
parent bf4a669446
commit 9b7c76c801
2 changed files with 18 additions and 38 deletions
+14 -34
View File
@@ -1,6 +1,5 @@
import json
import re
import datetime
from paho.mqtt import client as mqtt_client
from core.config import config, logger
from core.database import save_to_sqlite
@@ -19,7 +18,7 @@ def on_connect(client, userdata, flags, reason_code, properties=None):
default_topics = [
"servizi/+/stat", "dmr-gateway/+/json", "devices/+/services",
"nxdn-gateway/+/json", "ysf-gateway/+/json", "p25-gateway/+/json",
"dstar-gateway/+/json", "mmdvm/+/json", "data/#", "aprs-gateway/aprs"
"dstar-gateway/+/json", "mmdvm/+/json", "data/#"
]
topics_list = config.get('mqtt', {}).get('topics', default_topics)
@@ -43,35 +42,6 @@ def on_message(client, userdata, msg):
try:
topic = msg.topic
payload = msg.payload.decode('utf-8', errors='replace').strip()
# NUOVO BLOCCO APRS
if topic == "aprs-gateway/aprs":
try:
raw_aprs = payload
# Formato atteso: SOURCE>DEST,PATH:PAYLOAD
if ">" in raw_aprs and ":" in raw_aprs:
header, aprs_payload = raw_aprs.split(":", 1)
source, rest = header.split(">", 1)
if "," in rest:
dest, path = rest.split(",", 1)
else:
dest = rest
path = ""
aprs_data = {
"time": datetime.datetime.now().strftime("%H:%M:%S"),
"source": source.strip(),
"dest": dest.strip(),
"path": path.strip(),
"payload": aprs_payload.strip()
}
state.socketio.emit('aprs_msg', aprs_data)
except Exception as e:
logger.error(f"Errore decodifica APRS: {e}")
return # Esci per non processare il resto della logica su questo topic
parts = topic.split('/')
if len(parts) < 2:
return
@@ -334,12 +304,12 @@ def on_message(client, userdata, msg):
if m and "running" not in m.lower():
save_to_sqlite(cid, {'src_id': f"🌐 {m}", 'dst_id': 'NET'}, protocol=proto)
# --- LETTURA STATO MODI DA TOPIC data/+/MMDVM ---
# --- MODI OPERATIVI MMDVM ---
elif len(parts) == 3 and p0 == 'data' and p2 == 'mmdvm':
try:
cid = parts[1].lower()
data = json.loads(payload)
state.operating_modes[cid] = data
state.operating_modes[cid] = json.loads(payload)
state.notify_update()
except Exception as e:
logger.error(f"Errore parsing MMDVM modes per {cid}: {e}")
@@ -359,6 +329,16 @@ def on_message(client, userdata, msg):
state.client_telemetry[cid]["idle"] = False
# --- ALLINEAMENTO MODI PER BEACON ---
curr_mode = data.get('MMDVM', {}).get('mode', '')
if curr_mode:
if curr_mode.upper() == 'DMR':
state.client_telemetry[cid]["alt"] = ""
else:
old_alt = state.client_telemetry[cid].get("alt", "")
if not any(i in old_alt for i in ['🟢','🟣','🔵','🟠']):
state.client_telemetry[cid]["alt"] = f"📡 {curr_mode.upper()} BEACON"
if 'DMR' in data:
d = data['DMR']
act = d.get('action')
+2 -2
View File
@@ -892,8 +892,8 @@ async function refreshStates() {
}
// --- NESSUN TIMER LOCALE: COMANDA MQTT ---
// Memorizza l'ultimo modo in trasmissione per usarlo durante l'Hangtime
if (isTx && isOnline) {
// Memorizza l'ultimo modo dedotto per usarlo durante l'Hangtime o i Beacon
if (!isIdle && isOnline) {
cardDiv.dataset.lastMode = txModeStr.replace("TX ", "").trim();
cardDiv.dataset.lastColor = activeModeColor;
}