From 05cf7e98d9e368b69a45f5727658e7ea25d612ae Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Thu, 26 Mar 2026 15:22:23 -0400 Subject: [PATCH] refactor: replace hardcoded channel IDs with dynamic channel retrieval from platform.channels --- pocketcontrol.lua | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pocketcontrol.lua b/pocketcontrol.lua index 9766538..edb9fe8 100644 --- a/pocketcontrol.lua +++ b/pocketcontrol.lua @@ -2,10 +2,12 @@ -- Combines turtle control, GPS tracking, server management, and webbridge control -- Communicates wirelessly with webbridge - NO direct HTTP calls -local CHANNEL_SEND = 100 -local CHANNEL_RECEIVE = 101 -local STATUS_CHANNEL = 102 -local POCKET_CHANNEL = 103 -- Pocket <-> Webbridge communication +local Channels = require('platform.channels') + +local CHANNEL_SEND = Channels.get('remoteturtle.command') +local CHANNEL_RECEIVE = Channels.get('remoteturtle.response') +local STATUS_CHANNEL = Channels.get('remoteturtle.status') +local POCKET_CHANNEL = Channels.get('remoteturtle.pocket') -- Find modem local modem = peripheral.find("modem") @@ -19,9 +21,12 @@ if pocket then modem = peripheral.find("modem") end -modem.open(CHANNEL_RECEIVE) -modem.open(STATUS_CHANNEL) -modem.open(POCKET_CHANNEL) +local WebBridge = require('platform.webbridge') +WebBridge.openChannels(modem, { + 'remoteturtle.response', + 'remoteturtle.status', + 'remoteturtle.pocket', +}) local w, h = term.getSize()