fix: 即使无法获取GPS信号也上报机器在线状态,并升级版本至v1.5.18

This commit is contained in:
2026-07-11 15:58:50 +08:00
parent f0b62eca49
commit de187db646
3 changed files with 35 additions and 33 deletions
+18 -17
View File
@@ -1,7 +1,7 @@
local DEFAULT_SERVER_BASE = "http://ticket.fse-media.group"
local DEFAULT_SERVER_PATH = "/api/tickets/check"
local GATE_OPEN_SECONDS = 2
local VERSION = "v1.5.17"
local VERSION = "v1.5.18"
local VERSION_CHECK_INTERVAL = 5
local CONFIG_PATH = "gate_config.json"
@@ -192,6 +192,7 @@ local function checkAndApplyUpdate()
print("OTA Update Error: " .. tostring(res))
term.setTextColor(colors.white)
end
sleep(3)
end
else
lastUpdateError = "loadfile failed: " .. tostring(err)
@@ -200,6 +201,7 @@ local function checkAndApplyUpdate()
print("OTA Update Error: " .. tostring(err))
term.setTextColor(colors.white)
end
sleep(3)
end
isUpdating = false
@@ -1521,24 +1523,23 @@ end
local function backgroundLocationSyncTask()
sleep(5)
local x, y, z
if gps and type(gps.locate) == "function" then
local x, y, z = gps.locate(2)
if x and y and z then
local label = os.getComputerLabel()
if not label or label == "" then label = "#" .. tostring(os.getComputerID()) end
local payload = {
device_id = label,
type = "Gate",
gate_mode = modeBySide and "bidirectional" or mode,
station_code = stationCodeForSide(nil) or "",
x = x,
y = y,
z = z
}
local serverBase = guessBaseFromStatusURL(serverURL)
pcall(postCheck, serverBase .. '/api/machine-location', payload)
end
x, y, z = gps.locate(2)
end
local label = os.getComputerLabel()
if not label or label == "" then label = "#" .. tostring(os.getComputerID()) end
local payload = {
device_id = label,
type = "Gate",
gate_mode = modeBySide and "bidirectional" or mode,
station_code = stationCodeForSide(nil) or "",
x = x,
y = y,
z = z
}
local serverBase = guessBaseFromStatusURL(serverURL)
pcall(postCheck, serverBase .. '/api/machine-location', payload)
while true do
sleep(86400)
end
+2 -2
View File
@@ -22,8 +22,8 @@ const pool = mysql.createPool({
});
const DEFAULT_LUA_VERSIONS = {
ticketmachine: 'v1.5.16',
gate: 'v1.5.16'
ticketmachine: 'v1.5.18',
gate: 'v1.5.18'
};
function normalizeLuaVersions(input) {
+15 -14
View File
@@ -1,6 +1,6 @@
local CURRENT_STATION_CODE = 'Ticket-Machine'
local API_BASE = 'http://ticket.fse-media.group/api'
local VERSION = 'v1.5.17'
local VERSION = 'v1.5.18'
local UPDATE_CHECK_INTERVAL = 5
-- ###########################
@@ -722,6 +722,7 @@ local function checkAndApplyUpdate()
print("OTA Update Error: " .. tostring(res))
term.setTextColor(colors.white)
end
sleep(3)
end
else
lastUpdateError = "loadfile failed: " .. tostring(err)
@@ -730,6 +731,7 @@ local function checkAndApplyUpdate()
print("OTA Update Error: " .. tostring(err))
term.setTextColor(colors.white)
end
sleep(3)
end
isUpdating = false
@@ -777,21 +779,20 @@ end
local function backgroundLocationSyncTask()
sleep(5)
local x, y, z
if gps and type(gps.locate) == "function" then
local x, y, z = gps.locate(2)
if x and y and z then
local payload = {
device_id = currentDeviceId(),
type = "TicketMachine",
station = (CFG.current_station and (CFG.current_station.en_name or CFG.current_station.name)) or state.stationName,
station_code = state.stationCode or CURRENT_STATION_CODE,
x = x,
y = y,
z = z
}
postJSONResult(API_BASE .. '/machine-location', payload)
end
x, y, z = gps.locate(2)
end
local payload = {
device_id = currentDeviceId(),
type = "TicketMachine",
station = (CFG.current_station and (CFG.current_station.en_name or CFG.current_station.name)) or state.stationName,
station_code = state.stationCode or CURRENT_STATION_CODE,
x = x,
y = y,
z = z
}
postJSONResult(API_BASE .. '/machine-location', payload)
while true do
sleep(86400)
end