From 049a712780a750c63443e8ccb6f862b7f0958ea0 Mon Sep 17 00:00:00 2001 From: Moonlit Productions Date: Fri, 2 Jan 2026 01:04:30 -0500 Subject: [PATCH] maybe I fixed it --- startup.lua | 121 +++++++--------------------------------------------- 1 file changed, 16 insertions(+), 105 deletions(-) diff --git a/startup.lua b/startup.lua index 4b791c2..f8bc329 100644 --- a/startup.lua +++ b/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,108 +286,29 @@ 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 - mon.setBackgroundColor(colors.red) - mon.clear() - mon.setTextScale(1) - mon.setCursorPos(6, 5) - mon.write("REMOTE IRIS") - mon.setCursorPos(8, 7) - if remoteIrisState == 100 then - mon.write("CLOSED!") - else - mon.write(remoteIrisState .. "% CLOSED") - end - mon.setCursorPos(3, 10) - mon.write("Connection unsafe") - display.drawIrisStatus() - display.drawDisconnectButton() + -- Show warning screen + mon.setBackgroundColor(colors.red) + mon.clear() + mon.setTextScale(1) + mon.setCursorPos(6, 5) + mon.write("REMOTE IRIS") + mon.setCursorPos(8, 7) + if remoteIrisState == 100 then + mon.write("CLOSED!") else - display.showConnected(state.destAddressname, state.destAddress) + mon.write(remoteIrisState .. "% CLOSED") end + mon.setCursorPos(3, 10) + mon.write("Connection unsafe") + display.drawIrisStatus() + display.drawDisconnectButton() 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)