maybe I fixed it
This commit is contained in:
95
startup.lua
95
startup.lua
@ -253,9 +253,7 @@ local function GetGDOTransmission()
|
||||
end
|
||||
|
||||
local function HandlePasswordEntry()
|
||||
utils.debug("HandlePasswordEntry: Calling handlers.handlePasswordInput()")
|
||||
local result = handlers.handlePasswordInput()
|
||||
utils.debug("HandlePasswordEntry: handlers.handlePasswordInput() returned: " .. tostring(result))
|
||||
return result
|
||||
end
|
||||
|
||||
@ -265,18 +263,17 @@ local function HandleIncomingPasswordRequest(password)
|
||||
utils.log("Correct password received, opening iris")
|
||||
utils.openIris()
|
||||
utils.sendPasswordResponse(true)
|
||||
utils.debug("Sent: IRIS_OPEN")
|
||||
return true
|
||||
else
|
||||
utils.log("Incorrect password received")
|
||||
utils.sendPasswordResponse(false)
|
||||
utils.debug("Sent: IRIS_DENIED")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function MonitorRemoteIris()
|
||||
-- Continuously monitor remote iris state while connected
|
||||
-- Password handling is done during initial connection only
|
||||
local lastIrisState = nil
|
||||
local state = getState()
|
||||
|
||||
@ -289,90 +286,14 @@ local function MonitorRemoteIris()
|
||||
-- Only update display if state changed
|
||||
if remoteIrisState ~= lastIrisState then
|
||||
if remoteIrisState and remoteIrisState > 0 then
|
||||
-- Remote iris closed or closing
|
||||
-- Remote iris closed or closing during active connection
|
||||
if remoteIrisState == 100 then
|
||||
utils.log("ALERT: Remote iris fully closed during connection!")
|
||||
else
|
||||
utils.log("ALERT: Remote iris moving: " .. remoteIrisState .. "%")
|
||||
end
|
||||
|
||||
-- If remote has computer and iris just became fully closed, check for password request
|
||||
if state.remoteHasComputer and remoteIrisState == 100 and (not lastIrisState or lastIrisState < 100) then
|
||||
utils.log("Remote iris closed and computer detected - checking for password request")
|
||||
|
||||
-- Check if password was already requested during initial connection
|
||||
if state.remotePasswordRequired then
|
||||
utils.log("Password already requested - showing password prompt")
|
||||
|
||||
local password = HandlePasswordEntry()
|
||||
|
||||
-- Wait for response
|
||||
local function WaitForResponse()
|
||||
sleep(3) -- Wait up to 3 seconds for response
|
||||
return nil
|
||||
end
|
||||
|
||||
local result = parallel.waitForAny(GetMessage, WaitForResponse)
|
||||
if result == 1 then
|
||||
local response = state.lastReceivedMessage
|
||||
state.lastReceivedMessage = nil
|
||||
if response == "IRIS_OPEN" then
|
||||
display.showPasswordResult(true)
|
||||
utils.log("Password accepted - iris opened")
|
||||
-- Continue monitoring, iris state will update
|
||||
elseif response == "IRIS_DENIED" then
|
||||
display.showPasswordResult(false)
|
||||
utils.log("Password rejected")
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Wait briefly for password request message if not already received
|
||||
utils.log("Waiting for password request message")
|
||||
local function WaitForPasswordRequest()
|
||||
sleep(2) -- Wait up to 2 seconds for password request
|
||||
return nil
|
||||
end
|
||||
|
||||
local result = parallel.waitForAny(GetMessage, WaitForPasswordRequest)
|
||||
if result == 1 then
|
||||
local message = state.lastReceivedMessage
|
||||
state.lastReceivedMessage = nil
|
||||
|
||||
-- Only show password panel if explicitly requested
|
||||
if message == "IRIS_PASSWORD_REQUIRED" then
|
||||
utils.log("Password requested by remote gate - showing password prompt")
|
||||
|
||||
local password = HandlePasswordEntry()
|
||||
|
||||
-- Wait for response
|
||||
local function WaitForResponse()
|
||||
sleep(3) -- Wait up to 3 seconds for response
|
||||
return nil
|
||||
end
|
||||
|
||||
result = parallel.waitForAny(GetMessage, WaitForResponse)
|
||||
if result == 1 then
|
||||
local response = state.lastReceivedMessage
|
||||
state.lastReceivedMessage = nil
|
||||
if response == "IRIS_OPEN" then
|
||||
display.showPasswordResult(true)
|
||||
utils.log("Password accepted - iris opened")
|
||||
-- Continue monitoring, iris state will update
|
||||
elseif response == "IRIS_DENIED" then
|
||||
display.showPasswordResult(false)
|
||||
utils.log("Password rejected")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Re-check iris state after password attempt
|
||||
remoteIrisState = transceiver.checkConnectedShielding()
|
||||
end
|
||||
|
||||
-- Show warning screen if iris still closed
|
||||
if remoteIrisState and remoteIrisState > 0 then
|
||||
-- Show warning screen
|
||||
mon.setBackgroundColor(colors.red)
|
||||
mon.clear()
|
||||
mon.setTextScale(1)
|
||||
@ -388,9 +309,6 @@ local function MonitorRemoteIris()
|
||||
mon.write("Connection unsafe")
|
||||
display.drawIrisStatus()
|
||||
display.drawDisconnectButton()
|
||||
else
|
||||
display.showConnected(state.destAddressname, state.destAddress)
|
||||
end
|
||||
else
|
||||
-- Remote iris is open (0 or nil)
|
||||
if lastIrisState and lastIrisState > 0 then
|
||||
@ -806,19 +724,12 @@ local function handleOutgoingDial()
|
||||
|
||||
local result = HandlePasswordEntry()
|
||||
|
||||
utils.debug("HandlePasswordEntry returned: " .. tostring(result))
|
||||
utils.debug("Type of result: " .. type(result))
|
||||
utils.debug("result == 'IRIS_OPENED': " .. tostring(result == "IRIS_OPENED"))
|
||||
|
||||
-- Check if iris opened during password entry (via GDO)
|
||||
if result == "IRIS_OPENED" then
|
||||
utils.debug("Setting connectionSafe=true after IRIS_OPENED")
|
||||
utils.log("Iris opened during password entry (via GDO or message)")
|
||||
connectionSafe = true
|
||||
-- Show success message briefly
|
||||
display.showPasswordResult(true)
|
||||
sleep(1)
|
||||
utils.debug("After success display, connectionSafe=" .. tostring(connectionSafe))
|
||||
elseif result then
|
||||
-- Password was entered, send it
|
||||
utils.debug("Sent: IRIS_PASSWORD:" .. result)
|
||||
|
||||
Reference in New Issue
Block a user