diff --git a/gate.lua b/gate.lua index 2032595..bbee6ea 100644 --- a/gate.lua +++ b/gate.lua @@ -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 diff --git a/server/services/data.js b/server/services/data.js index a405ba3..3b3dbf8 100644 --- a/server/services/data.js +++ b/server/services/data.js @@ -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) { diff --git a/ticketmachine.lua b/ticketmachine.lua index d90469c..410f57d 100644 --- a/ticketmachine.lua +++ b/ticketmachine.lua @@ -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