maybe I fixed it
This commit is contained in:
97
startup.lua
97
startup.lua
@ -697,98 +697,67 @@ local function handleOutgoingDial()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if remote iris is closed using transceiver
|
|
||||||
local remoteIrisState = nil
|
|
||||||
if transceiver then
|
|
||||||
remoteIrisState = transceiver.checkConnectedShielding()
|
|
||||||
end
|
|
||||||
|
|
||||||
local connectionSafe = false
|
local connectionSafe = false
|
||||||
|
|
||||||
if remoteIrisState and remoteIrisState > 0 then
|
-- If remote computer requested a password, show the prompt
|
||||||
-- Remote iris is closed (partially or fully) - UNSAFE
|
if state.remotePasswordRequired then
|
||||||
|
utils.log("Password required by remote gate")
|
||||||
|
|
||||||
-- Close local iris to protect travelers
|
-- Close local iris to protect travelers
|
||||||
if config.irisEnabled then
|
if config.irisEnabled then
|
||||||
utils.closeIris()
|
utils.closeIris()
|
||||||
end
|
end
|
||||||
|
|
||||||
if remoteIrisState == 100 then
|
local result = HandlePasswordEntry()
|
||||||
utils.log("WARNING: Remote iris is fully closed!")
|
|
||||||
else
|
|
||||||
utils.log("WARNING: Remote iris is " .. remoteIrisState .. "% closed!")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If password is required and remote has computer, show prompt now
|
-- Check if iris opened during password entry (via GDO)
|
||||||
if state.remotePasswordRequired and remoteIrisState == 100 then
|
if result == "IRIS_OPENED" then
|
||||||
utils.log("Showing password prompt for remote gate")
|
connectionSafe = true
|
||||||
|
display.showPasswordResult(true)
|
||||||
|
sleep(1)
|
||||||
|
elseif result then
|
||||||
|
-- Password was entered, send it
|
||||||
|
utils.debug("Sent: IRIS_PASSWORD:" .. result)
|
||||||
|
|
||||||
local result = HandlePasswordEntry()
|
-- Wait for response
|
||||||
|
local function WaitForResponse()
|
||||||
-- Check if iris opened during password entry (via GDO)
|
sleep(3)
|
||||||
if result == "IRIS_OPENED" then
|
return nil
|
||||||
connectionSafe = true
|
|
||||||
-- Show success message briefly
|
|
||||||
display.showPasswordResult(true)
|
|
||||||
sleep(1)
|
|
||||||
elseif result then
|
|
||||||
-- Password was entered, send it
|
|
||||||
utils.debug("Sent: IRIS_PASSWORD:" .. result)
|
|
||||||
|
|
||||||
-- Wait for response
|
|
||||||
local function WaitForResponse()
|
|
||||||
sleep(3) -- Wait up to 3 seconds for response
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local waitResult = parallel.waitForAny(GetMessage, WaitForResponse)
|
|
||||||
if waitResult == 1 then
|
|
||||||
local response = state.lastReceivedMessage
|
|
||||||
state.lastReceivedMessage = nil
|
|
||||||
if response == "IRIS_OPEN" or response == "GDO_IRIS_OPEN" then
|
|
||||||
display.showPasswordResult(true)
|
|
||||||
utils.log("Password accepted - iris opened")
|
|
||||||
sleep(1)
|
|
||||||
connectionSafe = true
|
|
||||||
elseif response == "IRIS_DENIED" then
|
|
||||||
display.showPasswordResult(false)
|
|
||||||
utils.log("Password rejected")
|
|
||||||
sleep(2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Re-check iris state after password/GDO attempt
|
local waitResult = parallel.waitForAny(GetMessage, WaitForResponse)
|
||||||
if transceiver then
|
if waitResult == 1 then
|
||||||
remoteIrisState = transceiver.checkConnectedShielding()
|
local response = state.lastReceivedMessage
|
||||||
if not remoteIrisState or remoteIrisState == 0 then
|
state.lastReceivedMessage = nil
|
||||||
|
if response == "IRIS_OPEN" or response == "GDO_IRIS_OPEN" then
|
||||||
|
display.showPasswordResult(true)
|
||||||
|
utils.log("Password accepted - iris opened")
|
||||||
|
sleep(1)
|
||||||
connectionSafe = true
|
connectionSafe = true
|
||||||
|
elseif response == "IRIS_DENIED" then
|
||||||
|
display.showPasswordResult(false)
|
||||||
|
utils.log("Password rejected")
|
||||||
|
sleep(2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Show warning screen if iris still closed
|
-- If still not safe, show warning
|
||||||
if not connectionSafe and remoteIrisState and remoteIrisState > 0 then
|
if not connectionSafe 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)
|
||||||
mon.setCursorPos(6, 5)
|
mon.setCursorPos(6, 5)
|
||||||
mon.write("REMOTE IRIS")
|
mon.write("REMOTE IRIS")
|
||||||
mon.setCursorPos(8, 7)
|
mon.setCursorPos(8, 7)
|
||||||
if remoteIrisState == 100 then
|
mon.write("CLOSED!")
|
||||||
mon.write("CLOSED!")
|
|
||||||
else
|
|
||||||
mon.write(remoteIrisState .. "% CLOSED")
|
|
||||||
end
|
|
||||||
mon.setCursorPos(3, 10)
|
mon.setCursorPos(3, 10)
|
||||||
mon.write("Connection unsafe")
|
mon.write("Connection unsafe")
|
||||||
display.drawIrisStatus()
|
display.drawIrisStatus()
|
||||||
display.drawDisconnectButton()
|
display.drawDisconnectButton()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Remote iris is open or no iris present
|
-- No password required - connection is safe
|
||||||
utils.log("DEBUG: Remote iris is open or no iris present")
|
|
||||||
connectionSafe = true
|
connectionSafe = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user