feat: Auto-detect device name from meshcli prompt

Bridge now detects device name from meshcli prompt ("DeviceName|*")
and exposes it via /health endpoint. mc-webui fetches this at startup
and uses RuntimeConfig for dynamic device name throughout the app.

Fallback chain: prompt detection → .infos command → MC_DEVICE_NAME env var

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-01-15 07:48:10 +01:00
parent 6000750e6c
commit c7163aa035
8 changed files with 178 additions and 24 deletions
+10 -1
View File
@@ -5,13 +5,15 @@ mc-webui - Flask application entry point
import logging
import re
import shlex
import threading
import requests
from flask import Flask, request as flask_request
from flask_socketio import SocketIO, emit
from app.config import config
from app.config import config, runtime_config
from app.routes.views import views_bp
from app.routes.api import api_bp
from app.archiver.manager import schedule_daily_archiving
from app.meshcore.cli import fetch_device_name_from_bridge
# Commands that require longer timeout (in seconds)
SLOW_COMMANDS = {
@@ -57,6 +59,13 @@ def create_app():
else:
logger.info("Archive scheduler disabled")
# Fetch device name from bridge in background thread
def init_device_name():
device_name, source = fetch_device_name_from_bridge()
runtime_config.set_device_name(device_name, source)
threading.Thread(target=init_device_name, daemon=True).start()
logger.info(f"mc-webui started - device: {config.MC_DEVICE_NAME}")
logger.info(f"Messages file: {config.msgs_file_path}")
logger.info(f"Serial port: {config.MC_SERIAL_PORT}")