fix: 即使无法获取GPS信号也上报机器在线状态,并升级版本至v1.5.18
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
local DEFAULT_SERVER_BASE = "http://ticket.fse-media.group"
|
local DEFAULT_SERVER_BASE = "http://ticket.fse-media.group"
|
||||||
local DEFAULT_SERVER_PATH = "/api/tickets/check"
|
local DEFAULT_SERVER_PATH = "/api/tickets/check"
|
||||||
local GATE_OPEN_SECONDS = 2
|
local GATE_OPEN_SECONDS = 2
|
||||||
local VERSION = "v1.5.17"
|
local VERSION = "v1.5.18"
|
||||||
local VERSION_CHECK_INTERVAL = 5
|
local VERSION_CHECK_INTERVAL = 5
|
||||||
|
|
||||||
local CONFIG_PATH = "gate_config.json"
|
local CONFIG_PATH = "gate_config.json"
|
||||||
@@ -192,6 +192,7 @@ local function checkAndApplyUpdate()
|
|||||||
print("OTA Update Error: " .. tostring(res))
|
print("OTA Update Error: " .. tostring(res))
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
end
|
end
|
||||||
|
sleep(3)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lastUpdateError = "loadfile failed: " .. tostring(err)
|
lastUpdateError = "loadfile failed: " .. tostring(err)
|
||||||
@@ -200,6 +201,7 @@ local function checkAndApplyUpdate()
|
|||||||
print("OTA Update Error: " .. tostring(err))
|
print("OTA Update Error: " .. tostring(err))
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
end
|
end
|
||||||
|
sleep(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
isUpdating = false
|
isUpdating = false
|
||||||
@@ -1521,24 +1523,23 @@ end
|
|||||||
|
|
||||||
local function backgroundLocationSyncTask()
|
local function backgroundLocationSyncTask()
|
||||||
sleep(5)
|
sleep(5)
|
||||||
|
local x, y, z
|
||||||
if gps and type(gps.locate) == "function" then
|
if gps and type(gps.locate) == "function" then
|
||||||
local x, y, z = gps.locate(2)
|
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
|
|
||||||
end
|
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
|
while true do
|
||||||
sleep(86400)
|
sleep(86400)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ const pool = mysql.createPool({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const DEFAULT_LUA_VERSIONS = {
|
const DEFAULT_LUA_VERSIONS = {
|
||||||
ticketmachine: 'v1.5.16',
|
ticketmachine: 'v1.5.18',
|
||||||
gate: 'v1.5.16'
|
gate: 'v1.5.18'
|
||||||
};
|
};
|
||||||
|
|
||||||
function normalizeLuaVersions(input) {
|
function normalizeLuaVersions(input) {
|
||||||
|
|||||||
+15
-14
@@ -1,6 +1,6 @@
|
|||||||
local CURRENT_STATION_CODE = 'Ticket-Machine'
|
local CURRENT_STATION_CODE = 'Ticket-Machine'
|
||||||
local API_BASE = 'http://ticket.fse-media.group/api'
|
local API_BASE = 'http://ticket.fse-media.group/api'
|
||||||
local VERSION = 'v1.5.17'
|
local VERSION = 'v1.5.18'
|
||||||
local UPDATE_CHECK_INTERVAL = 5
|
local UPDATE_CHECK_INTERVAL = 5
|
||||||
|
|
||||||
-- ###########################
|
-- ###########################
|
||||||
@@ -722,6 +722,7 @@ local function checkAndApplyUpdate()
|
|||||||
print("OTA Update Error: " .. tostring(res))
|
print("OTA Update Error: " .. tostring(res))
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
end
|
end
|
||||||
|
sleep(3)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lastUpdateError = "loadfile failed: " .. tostring(err)
|
lastUpdateError = "loadfile failed: " .. tostring(err)
|
||||||
@@ -730,6 +731,7 @@ local function checkAndApplyUpdate()
|
|||||||
print("OTA Update Error: " .. tostring(err))
|
print("OTA Update Error: " .. tostring(err))
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
end
|
end
|
||||||
|
sleep(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
isUpdating = false
|
isUpdating = false
|
||||||
@@ -777,21 +779,20 @@ end
|
|||||||
|
|
||||||
local function backgroundLocationSyncTask()
|
local function backgroundLocationSyncTask()
|
||||||
sleep(5)
|
sleep(5)
|
||||||
|
local x, y, z
|
||||||
if gps and type(gps.locate) == "function" then
|
if gps and type(gps.locate) == "function" then
|
||||||
local x, y, z = gps.locate(2)
|
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
|
|
||||||
end
|
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
|
while true do
|
||||||
sleep(86400)
|
sleep(86400)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user