From 5d2397db7c2680d667ce31f88bf6cf2add12a182 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Fri, 31 Jul 2026 23:30:41 +0800 Subject: [PATCH] feat(station): add visible build version reporting Add a station build version counter, show it on the monitor and terminal header, log it at startup, and report it to the server during register and heartbeat so deployed client versions are visible during troubleshooting. --- CloudServer/server.js | 11 +++++++---- station_broadcast.lua | 14 ++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CloudServer/server.js b/CloudServer/server.js index 2935089..652638c 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -1448,19 +1448,21 @@ function handleHeartbeat(ws, data) { name: cleanName, code: data.stationCode || '', platform: data.stationPlatform || getPlatformNumberFromName(cleanName), + version: data.stationVersion || '', lastSeen: Date.now(), ws: ws }; normalizeStationRecord(stations[cleanName]); - log('INFO', `Station auto-registered via heartbeat: "${cleanName}"`); + log('INFO', `Station auto-registered via heartbeat: "${cleanName}"${data.stationVersion ? ` ${data.stationVersion}` : ''}`); broadcastUpdate(); } else { stations[cleanName].lastSeen = Date.now(); if (data.stationCode) stations[cleanName].code = data.stationCode; if (data.stationPlatform) stations[cleanName].platform = data.stationPlatform; + if (data.stationVersion) stations[cleanName].version = data.stationVersion; if (stations[cleanName].ws !== ws) { stations[cleanName].ws = ws; // Update WS in case of reconnect - log('INFO', `Station WebSocket updated via heartbeat: "${cleanName}"`); + log('INFO', `Station WebSocket updated via heartbeat: "${cleanName}"${data.stationVersion ? ` ${data.stationVersion}` : ''}`); broadcastUpdate(); } normalizeStationRecord(stations[cleanName]); @@ -1469,19 +1471,20 @@ function handleHeartbeat(ws, data) { } function handleStationRegister(ws, data) { - const { stationName, stationCode, stationPlatform } = data; + const { stationName, stationCode, stationPlatform, stationVersion } = data; const cleanName = stationName.trim(); stations[cleanName] = { name: cleanName, code: stationCode, platform: stationPlatform || getPlatformNumberFromName(cleanName), + version: stationVersion || '', lastSeen: Date.now(), ws: ws // Keep reference if we need to send back }; normalizeStationRecord(stations[cleanName]); - log('SUCCESS', `Station registered: "${cleanName}" (${stationCode})`); + log('SUCCESS', `Station registered: "${cleanName}" (${stationCode})${stationVersion ? ` ${stationVersion}` : ''}`); // Send ack ws.send(JSON.stringify({ diff --git a/station_broadcast.lua b/station_broadcast.lua index afe3278..e9ba5ee 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -2,6 +2,9 @@ -- ============================================================================ -- 1. Configuration & Constants -- ============================================================================ +local APP_VERSION = 1 +local APP_VERSION_TEXT = "v" .. tostring(APP_VERSION) + local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group", API_URL = "http://stabadmin.fse-media.group", @@ -1108,7 +1111,8 @@ function Network.register() type = "station_register", stationName = State.stationName, stationCode = State.stationCode, - stationPlatform = State.stationPlatform + stationPlatform = State.stationPlatform, + stationVersion = APP_VERSION_TEXT }) end @@ -1291,7 +1295,8 @@ function Network.heartbeat() type = "heartbeat", stationName = State.stationName, stationCode = State.stationCode, - stationPlatform = State.stationPlatform + stationPlatform = State.stationPlatform, + stationVersion = APP_VERSION_TEXT }) end os.sleep(10) @@ -1309,7 +1314,7 @@ function Display.render() mon.clear() mon.setCursorPos(1,1) mon.setTextColor(COLORS.INFO) - mon.write("STATION: " .. State.stationName) + mon.write("STATION: " .. State.stationName .. " " .. APP_VERSION_TEXT) mon.setCursorPos(1,2) mon.write("TIME: " .. os.date("%H:%M:%S")) @@ -1397,7 +1402,7 @@ function Display.renderTerminal() term.setBackgroundColor(colors.gray) term.setTextColor(colors.white) term.clearLine() - local title = " Station Broadcast Console (" .. State.stationName .. ") " + local title = " Station Broadcast Console (" .. State.stationName .. " / " .. APP_VERSION_TEXT .. ") " term.setCursorPos(math.floor((w - #title)/2) + 1, 1) term.write(title) term.setBackgroundColor(colors.black) @@ -1542,6 +1547,7 @@ end -- ============================================================================ Peripherals.init() Audio.loadStationList() +Utils.log("INFO", "StationBroadcast version " .. APP_VERSION_TEXT) parallel.waitForAny( function()