feat: Enhance debugging output; log open channels and modem messages in the main event loop

This commit is contained in:
MayaTheShy
2026-02-20 01:00:01 -05:00
parent 86250deba3
commit 5a4fd000fe

View File

@@ -296,6 +296,14 @@ end
addLog("Listening on channels " .. STATUS_CHANNEL .. ", " .. CHANNEL_RECEIVE .. ", " .. POCKET_CHANNEL, colors.lightBlue)
-- Debug: Print what channels are actually open
print("Opened channels:")
for i = 0, 65535 do
if modem.isOpen(i) then
print(" Channel " .. i .. " is OPEN")
end
end
-- Start polling timer
local POLL_INTERVAL = 2 -- Poll every 2 seconds (reduced frequency for better reliability)
os.startTimer(POLL_INTERVAL)
@@ -305,9 +313,18 @@ local recentCommandSends = {}
-- Main loop
local lastRefresh = os.epoch("utc")
print("🎧 Starting main event loop...")
while true do
local event, side, channel, replyChannel, message, distance = os.pullEvent()
-- Log ALL modem messages for debugging
if event == "modem_message" then
print("🔔 MODEM MESSAGE RECEIVED!")
print(" Event: " .. event)
print(" Channel: " .. channel)
print(" Expected channels: " .. STATUS_CHANNEL .. " (status), " .. CHANNEL_RECEIVE .. " (receive), " .. POCKET_CHANNEL .. " (pocket)")
end
if event == "timer" then
-- Poll for commands for all known turtles
for turtleID, turtleData in pairs(turtles) do