fix(websocket): include SNR, hops, route and analyzer URL in channel message events

The SocketIO new_message emit for channel messages was missing snr,
path_len, pkt_payload and analyzer_url fields, causing messages received
via WebSocket to render without metadata until a full page refresh.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-15 12:12:41 +01:00
parent 9a0d05ae93
commit e817181261
2 changed files with 23 additions and 1 deletions
+22
View File
@@ -7,12 +7,16 @@ Event handlers capture incoming data and write to Database + emit SocketIO.
"""
import asyncio
import hashlib
import json
import logging
import threading
import time
from typing import Optional, Any, Dict, List
ANALYZER_BASE_URL = 'https://analyzer.letsmesh.net/packets?packet_hash='
GRP_TXT_TYPE_BYTE = 0x05
logger = logging.getLogger(__name__)
@@ -380,6 +384,20 @@ class DeviceManager:
return
if self.socketio:
snr = data.get('SNR', data.get('snr'))
path_len = data.get('path_len')
pkt_payload = data.get('pkt_payload')
# Compute analyzer URL from pkt_payload
analyzer_url = None
if pkt_payload:
try:
raw = bytes([GRP_TXT_TYPE_BYTE]) + bytes.fromhex(pkt_payload)
packet_hash = hashlib.sha256(raw).hexdigest()[:16].upper()
analyzer_url = f"{ANALYZER_BASE_URL}{packet_hash}"
except (ValueError, TypeError):
pass
self.socketio.emit('new_message', {
'type': 'channel',
'channel_idx': channel_idx,
@@ -387,6 +405,10 @@ class DeviceManager:
'content': content,
'timestamp': ts,
'id': msg_id,
'snr': snr,
'path_len': path_len,
'pkt_payload': pkt_payload,
'analyzer_url': analyzer_url,
}, namespace='/chat')
logger.debug(f"SocketIO emitted new_message for ch{channel_idx} msg #{msg_id}")
+1 -1
View File
@@ -908,7 +908,7 @@ function appendMessageFromSocket(data) {
path_len: data.path_len || null,
echo_paths: [],
echo_snrs: [],
analyzer_url: null,
analyzer_url: data.analyzer_url || null,
pkt_payload: data.pkt_payload || null,
txt_type: data.txt_type || 0,
};