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
+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