feat: Enhance debugging output; log open channels and modem messages in the main event loop
This commit is contained in:
@@ -296,6 +296,14 @@ end
|
|||||||
|
|
||||||
addLog("Listening on channels " .. STATUS_CHANNEL .. ", " .. CHANNEL_RECEIVE .. ", " .. POCKET_CHANNEL, colors.lightBlue)
|
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
|
-- Start polling timer
|
||||||
local POLL_INTERVAL = 2 -- Poll every 2 seconds (reduced frequency for better reliability)
|
local POLL_INTERVAL = 2 -- Poll every 2 seconds (reduced frequency for better reliability)
|
||||||
os.startTimer(POLL_INTERVAL)
|
os.startTimer(POLL_INTERVAL)
|
||||||
@@ -305,9 +313,18 @@ local recentCommandSends = {}
|
|||||||
|
|
||||||
-- Main loop
|
-- Main loop
|
||||||
local lastRefresh = os.epoch("utc")
|
local lastRefresh = os.epoch("utc")
|
||||||
|
print("🎧 Starting main event loop...")
|
||||||
while true do
|
while true do
|
||||||
local event, side, channel, replyChannel, message, distance = os.pullEvent()
|
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
|
if event == "timer" then
|
||||||
-- Poll for commands for all known turtles
|
-- Poll for commands for all known turtles
|
||||||
for turtleID, turtleData in pairs(turtles) do
|
for turtleID, turtleData in pairs(turtles) do
|
||||||
|
|||||||
Reference in New Issue
Block a user