Respond to iris opening quicker
This commit is contained in:
@ -49,9 +49,6 @@ config.chatboxDebugPlayer = "MoonlitJolty"
|
|||||||
-- MESSAGING
|
-- MESSAGING
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
|
||||||
-- Program version (sent to remote gates when connection established)
|
|
||||||
config.programVersion = "1.0"
|
|
||||||
|
|
||||||
-- Enable computer-to-computer messaging through stargate
|
-- Enable computer-to-computer messaging through stargate
|
||||||
config.enableMessaging = true
|
config.enableMessaging = true
|
||||||
|
|
||||||
|
|||||||
19
handlers.lua
19
handlers.lua
@ -64,7 +64,7 @@ function handlers.handlePasswordInput()
|
|||||||
local remoteIrisState = transceiver.checkConnectedShielding()
|
local remoteIrisState = transceiver.checkConnectedShielding()
|
||||||
if not remoteIrisState or remoteIrisState == 0 then
|
if not remoteIrisState or remoteIrisState == 0 then
|
||||||
-- Iris opened! Exit password prompt
|
-- Iris opened! Exit password prompt
|
||||||
utils.log("Remote iris opened, canceling password prompt")
|
utils.log("Remote iris opened via transceiver check, canceling password prompt")
|
||||||
state.enteringPassword = false
|
state.enteringPassword = false
|
||||||
return "IRIS_OPENED"
|
return "IRIS_OPENED"
|
||||||
end
|
end
|
||||||
@ -74,18 +74,24 @@ function handlers.handlePasswordInput()
|
|||||||
local event = { os.pullEvent() }
|
local event = { os.pullEvent() }
|
||||||
local eventType = event[1]
|
local eventType = event[1]
|
||||||
|
|
||||||
|
utils.log("DEBUG: Password handler received event: " .. tostring(eventType))
|
||||||
|
|
||||||
-- Handle GDO events
|
-- Handle GDO events
|
||||||
if eventType == "transceiver_transmission_received" then
|
if eventType == "transceiver_transmission_received" then
|
||||||
-- Pass to GDO handler
|
-- Pass to GDO handler
|
||||||
|
utils.log("DEBUG: Processing GDO transmission in password handler")
|
||||||
handlers.handleGDOTransmission(table.unpack(event))
|
handlers.handleGDOTransmission(table.unpack(event))
|
||||||
-- Continue loop to check iris state
|
-- Continue loop to check iris state
|
||||||
elseif eventType == "stargate_message_received" then
|
elseif eventType == "stargate_message_received" then
|
||||||
-- Pass to message handler
|
-- Pass to message handler
|
||||||
handlers.handleMessage(table.unpack(event))
|
handlers.handleMessage(table.unpack(event))
|
||||||
-- Check if iris opened
|
utils.log("DEBUG: Message in password handler: " .. tostring(state.lastReceivedMessage))
|
||||||
if state.lastReceivedMessage == "IRIS_OPEN" then
|
-- Check if iris opened (via password or GDO)
|
||||||
|
if state.lastReceivedMessage == "IRIS_OPEN" or state.lastReceivedMessage == "GDO_IRIS_OPEN" then
|
||||||
|
utils.log("Received iris open confirmation: " .. state.lastReceivedMessage)
|
||||||
state.lastReceivedMessage = nil
|
state.lastReceivedMessage = nil
|
||||||
state.enteringPassword = false
|
state.enteringPassword = false
|
||||||
|
utils.log("DEBUG: About to return IRIS_OPENED from password handler")
|
||||||
return "IRIS_OPENED"
|
return "IRIS_OPENED"
|
||||||
end
|
end
|
||||||
elseif eventType == "monitor_touch" then
|
elseif eventType == "monitor_touch" then
|
||||||
@ -258,6 +264,13 @@ function handlers.handleGDOTransmission(eventType, side, frequency, idc, matches
|
|||||||
utils.log("Valid GDO code received - opening iris")
|
utils.log("Valid GDO code received - opening iris")
|
||||||
utils.debug("Valid GDO - opening iris")
|
utils.debug("Valid GDO - opening iris")
|
||||||
utils.openIris()
|
utils.openIris()
|
||||||
|
|
||||||
|
-- Send message to remote gate that iris opened via GDO
|
||||||
|
if config.enableMessaging then
|
||||||
|
gate.sendStargateMessage("GDO_IRIS_OPEN")
|
||||||
|
utils.log("Sent GDO iris open notification to remote gate")
|
||||||
|
utils.debug("Sent: GDO_IRIS_OPEN")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return "gdo_received"
|
return "gdo_received"
|
||||||
|
|||||||
38
startup.lua
38
startup.lua
@ -11,6 +11,12 @@
|
|||||||
- Whitelist/blacklist security
|
- Whitelist/blacklist security
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
---------------------------------------------
|
||||||
|
-- PROGRAM VERSION
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
local PROGRAM_VERSION = "2.0"
|
||||||
|
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
-- LOAD MODULES
|
-- LOAD MODULES
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
@ -461,8 +467,8 @@ local function handleIncomingWormhole()
|
|||||||
|
|
||||||
-- Send version message to remote gate
|
-- Send version message to remote gate
|
||||||
sleep(0.5) -- Brief delay to ensure connection is stable
|
sleep(0.5) -- Brief delay to ensure connection is stable
|
||||||
utils.sendVersionMessage()
|
utils.sendVersionMessage(PROGRAM_VERSION)
|
||||||
utils.debug("Sent: SGCS_V" .. config.programVersion)
|
utils.debug("Sent: SGCS_V" .. PROGRAM_VERSION)
|
||||||
|
|
||||||
-- Handle iris
|
-- Handle iris
|
||||||
if config.autoCloseIrisOnIncoming then
|
if config.autoCloseIrisOnIncoming then
|
||||||
@ -753,6 +759,11 @@ local function handleOutgoingDial()
|
|||||||
utils.log("Remote gate requires password for entry")
|
utils.log("Remote gate requires password for entry")
|
||||||
lastMessageTime = os.clock()
|
lastMessageTime = os.clock()
|
||||||
break -- Got password request, that's all we need
|
break -- Got password request, that's all we need
|
||||||
|
elseif message == "GDO_IRIS_OPEN" then
|
||||||
|
utils.log("Remote iris opened via GDO")
|
||||||
|
state.remotePasswordRequired = false
|
||||||
|
lastMessageTime = os.clock()
|
||||||
|
break -- Iris opened, no password needed
|
||||||
end
|
end
|
||||||
elseif result == 2 then
|
elseif result == 2 then
|
||||||
-- GDO transmission received (handled by event system)
|
-- GDO transmission received (handled by event system)
|
||||||
@ -800,10 +811,15 @@ local function handleOutgoingDial()
|
|||||||
|
|
||||||
local result = HandlePasswordEntry()
|
local result = HandlePasswordEntry()
|
||||||
|
|
||||||
|
utils.log("DEBUG: HandlePasswordEntry returned: " .. tostring(result))
|
||||||
|
|
||||||
-- Check if iris opened during password entry (via GDO)
|
-- Check if iris opened during password entry (via GDO)
|
||||||
if result == "IRIS_OPENED" then
|
if result == "IRIS_OPENED" then
|
||||||
utils.log("Iris opened during password entry")
|
utils.log("Iris opened during password entry (via GDO or message)")
|
||||||
connectionSafe = true
|
connectionSafe = true
|
||||||
|
-- Show success message briefly
|
||||||
|
display.showPasswordResult(true)
|
||||||
|
sleep(1)
|
||||||
elseif result then
|
elseif result then
|
||||||
-- Password was entered, send it
|
-- Password was entered, send it
|
||||||
utils.debug("Sent: IRIS_PASSWORD:" .. result)
|
utils.debug("Sent: IRIS_PASSWORD:" .. result)
|
||||||
@ -818,7 +834,7 @@ local function handleOutgoingDial()
|
|||||||
if waitResult == 1 then
|
if waitResult == 1 then
|
||||||
local response = state.lastReceivedMessage
|
local response = state.lastReceivedMessage
|
||||||
state.lastReceivedMessage = nil
|
state.lastReceivedMessage = nil
|
||||||
if response == "IRIS_OPEN" then
|
if response == "IRIS_OPEN" or response == "GDO_IRIS_OPEN" then
|
||||||
display.showPasswordResult(true)
|
display.showPasswordResult(true)
|
||||||
utils.log("Password accepted - iris opened")
|
utils.log("Password accepted - iris opened")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
@ -831,17 +847,21 @@ local function handleOutgoingDial()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Re-check iris state
|
-- Re-check iris state after password/GDO attempt
|
||||||
if transceiver then
|
if transceiver then
|
||||||
remoteIrisState = transceiver.checkConnectedShielding()
|
remoteIrisState = transceiver.checkConnectedShielding()
|
||||||
|
utils.log("Re-checked remote iris state: " .. tostring(remoteIrisState))
|
||||||
if not remoteIrisState or remoteIrisState == 0 then
|
if not remoteIrisState or remoteIrisState == 0 then
|
||||||
connectionSafe = true
|
connectionSafe = true
|
||||||
|
utils.log("Remote iris confirmed open")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Show warning screen if iris still closed
|
-- Show warning screen if iris still closed
|
||||||
if not connectionSafe and remoteIrisState and remoteIrisState > 0 then
|
if not connectionSafe and remoteIrisState and remoteIrisState > 0 then
|
||||||
|
utils.log("DEBUG: connectionSafe=" ..
|
||||||
|
tostring(connectionSafe) .. ", remoteIrisState=" .. tostring(remoteIrisState))
|
||||||
mon.setBackgroundColor(colors.red)
|
mon.setBackgroundColor(colors.red)
|
||||||
mon.clear()
|
mon.clear()
|
||||||
mon.setTextScale(1)
|
mon.setTextScale(1)
|
||||||
@ -860,17 +880,25 @@ local function handleOutgoingDial()
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Remote iris is open or no iris present
|
-- Remote iris is open or no iris present
|
||||||
|
utils.log("DEBUG: Remote iris is open or no iris present")
|
||||||
connectionSafe = true
|
connectionSafe = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
utils.log("DEBUG: Before iris opening check - connectionSafe=" ..
|
||||||
|
tostring(connectionSafe) .. ", config.irisEnabled=" .. tostring(config.irisEnabled))
|
||||||
|
|
||||||
-- Only open local iris if connection is safe
|
-- Only open local iris if connection is safe
|
||||||
if connectionSafe and config.irisEnabled then
|
if connectionSafe and config.irisEnabled then
|
||||||
|
utils.log("Connection safe - opening local iris")
|
||||||
-- Wait 2 seconds to avoid voiding the iris
|
-- Wait 2 seconds to avoid voiding the iris
|
||||||
sleep(2)
|
sleep(2)
|
||||||
utils.openIris()
|
utils.openIris()
|
||||||
display.showConnected(state.destAddressname, state.destAddress)
|
display.showConnected(state.destAddressname, state.destAddress)
|
||||||
elseif connectionSafe then
|
elseif connectionSafe then
|
||||||
|
utils.log("Connection safe - no iris to open")
|
||||||
display.showConnected(state.destAddressname, state.destAddress)
|
display.showConnected(state.destAddressname, state.destAddress)
|
||||||
|
else
|
||||||
|
utils.log("Connection NOT safe - iris remains closed")
|
||||||
end
|
end
|
||||||
|
|
||||||
if (gate.isStargateConnected() == true) then
|
if (gate.isStargateConnected() == true) then
|
||||||
|
|||||||
@ -163,9 +163,9 @@ end
|
|||||||
-- MESSAGING
|
-- MESSAGING
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
|
||||||
function utils.sendVersionMessage()
|
function utils.sendVersionMessage(version)
|
||||||
if config.enableMessaging then
|
if config.enableMessaging then
|
||||||
local message = "SGCS_V" .. config.programVersion
|
local message = "SGCS_V" .. version
|
||||||
gate.sendStargateMessage(message)
|
gate.sendStargateMessage(message)
|
||||||
utils.log("Sent version message: " .. message)
|
utils.log("Sent version message: " .. message)
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user