local constants = require("core.constants") local protocol = require("core.protocol") local M = {} function M.open() for _, name in ipairs(peripheral.getNames()) do if peripheral.hasType(name, "modem") then rednet.open(name) end end return rednet.isOpen() end function M.broadcast(message) rednet.broadcast(message, constants.PROTOCOL) end function M.send(id, message) return rednet.send(id, message, constants.PROTOCOL) end function M.receive(timeout) local sender, message = rednet.receive(constants.PROTOCOL, timeout) if sender and protocol.valid(message) then return sender, message end return nil, nil end return M