refactor: replace hardcoded channel IDs with dynamic channel retrieval from platform.channels
This commit is contained in:
@@ -2,10 +2,12 @@
|
|||||||
-- Combines turtle control, GPS tracking, server management, and webbridge control
|
-- Combines turtle control, GPS tracking, server management, and webbridge control
|
||||||
-- Communicates wirelessly with webbridge - NO direct HTTP calls
|
-- Communicates wirelessly with webbridge - NO direct HTTP calls
|
||||||
|
|
||||||
local CHANNEL_SEND = 100
|
local Channels = require('platform.channels')
|
||||||
local CHANNEL_RECEIVE = 101
|
|
||||||
local STATUS_CHANNEL = 102
|
local CHANNEL_SEND = Channels.get('remoteturtle.command')
|
||||||
local POCKET_CHANNEL = 103 -- Pocket <-> Webbridge communication
|
local CHANNEL_RECEIVE = Channels.get('remoteturtle.response')
|
||||||
|
local STATUS_CHANNEL = Channels.get('remoteturtle.status')
|
||||||
|
local POCKET_CHANNEL = Channels.get('remoteturtle.pocket')
|
||||||
|
|
||||||
-- Find modem
|
-- Find modem
|
||||||
local modem = peripheral.find("modem")
|
local modem = peripheral.find("modem")
|
||||||
@@ -19,9 +21,12 @@ if pocket then
|
|||||||
modem = peripheral.find("modem")
|
modem = peripheral.find("modem")
|
||||||
end
|
end
|
||||||
|
|
||||||
modem.open(CHANNEL_RECEIVE)
|
local WebBridge = require('platform.webbridge')
|
||||||
modem.open(STATUS_CHANNEL)
|
WebBridge.openChannels(modem, {
|
||||||
modem.open(POCKET_CHANNEL)
|
'remoteturtle.response',
|
||||||
|
'remoteturtle.status',
|
||||||
|
'remoteturtle.pocket',
|
||||||
|
})
|
||||||
|
|
||||||
local w, h = term.getSize()
|
local w, h = term.getSize()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user