Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type HandlerFunc
- type HandlerRegistry
- type MessageHandler
- type State
- func (s *State) AddChannel(channel *meshtastic.Channel)
- func (s *State) AddConfig(config *meshtastic.Config)
- func (s *State) AddModule(module *meshtastic.ModuleConfig)
- func (s *State) AddNode(node *meshtastic.NodeInfo)
- func (s *State) Channels() []*meshtastic.Channel
- func (s *State) Complete() bool
- func (s *State) ConfigID() uint32
- func (s *State) Configs() []*meshtastic.Config
- func (s *State) DeviceMetadata() *meshtastic.DeviceMetadata
- func (s *State) Modules() []*meshtastic.ModuleConfig
- func (s *State) NodeInfo() *meshtastic.MyNodeInfo
- func (s *State) Nodes() []*meshtastic.NodeInfo
- func (s *State) SetComplete(complete bool)
- func (s *State) SetConfigID(configID uint32)
- func (s *State) SetDeviceMetadata(deviceMetadata *meshtastic.DeviceMetadata)
- func (s *State) SetNodeInfo(nodeInfo *meshtastic.MyNodeInfo)
- type StreamConn
Constants ¶
const ( // WaitAfterWake is the amount of time to wait after sending the wake message before sending the first message. WaitAfterWake = 100 * time.Millisecond // Start1 is a magic byte used in the meshtastic stream protocol. // Start1 is sent at the beginning of a message to indicate the start of a new message. Start1 = 0x94 // Start2 is a magic byte used in the meshtastic stream protocol. // It is sent after Start1 to indicate the start of a new message. Start2 = 0xc3 // PacketMTU is the maximum size of the protobuf message which can be sent within the header. PacketMTU = 512 )
Variables ¶
var (
ErrTimeout = errors.New("timeout connecting to radio")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { State State // contains filtered or unexported fields }
func NewClient ¶
func NewClient(sc *StreamConn, errorOnNoHandler bool) *Client
func (*Client) SendToRadio ¶
func (c *Client) SendToRadio(msg *meshtastic.ToRadio) error
type HandlerFunc ¶
type HandlerRegistry ¶
type HandlerRegistry struct {
// contains filtered or unexported fields
}
HandlerRegistry holds registered handlers for protobuf messages.
func NewHandlerRegistry ¶
func NewHandlerRegistry(errorOnNoHandler bool) *HandlerRegistry
New creates a new instance of HandlerRegistry. Set errorOnNoHandler to true if you want HandleMessage to return an error if there are no handlers registered for a given msg when HandleMessage is called.
func (*HandlerRegistry) HandleMessage ¶
func (r *HandlerRegistry) HandleMessage(msg proto.Message) error
HandleMessage invokes all registered handlers for the provided protobuf message, in the order they were registered.
func (*HandlerRegistry) RegisterHandler ¶
func (r *HandlerRegistry) RegisterHandler(msg proto.Message, handler MessageHandler)
RegisterHandler registers a handler for a specific protobuf message type.
type MessageHandler ¶
MessageHandler defines the function signature for a handler that processes a protobuf message.
type State ¶
func (*State) AddChannel ¶
func (s *State) AddChannel(channel *meshtastic.Channel)
func (*State) AddConfig ¶
func (s *State) AddConfig(config *meshtastic.Config)
func (*State) AddModule ¶
func (s *State) AddModule(module *meshtastic.ModuleConfig)
func (*State) AddNode ¶
func (s *State) AddNode(node *meshtastic.NodeInfo)
func (*State) Channels ¶
func (s *State) Channels() []*meshtastic.Channel
func (*State) Configs ¶
func (s *State) Configs() []*meshtastic.Config
func (*State) DeviceMetadata ¶
func (s *State) DeviceMetadata() *meshtastic.DeviceMetadata
func (*State) Modules ¶
func (s *State) Modules() []*meshtastic.ModuleConfig
func (*State) NodeInfo ¶
func (s *State) NodeInfo() *meshtastic.MyNodeInfo
func (*State) Nodes ¶
func (s *State) Nodes() []*meshtastic.NodeInfo
func (*State) SetComplete ¶
func (*State) SetConfigID ¶
func (*State) SetDeviceMetadata ¶
func (s *State) SetDeviceMetadata(deviceMetadata *meshtastic.DeviceMetadata)
func (*State) SetNodeInfo ¶
func (s *State) SetNodeInfo(nodeInfo *meshtastic.MyNodeInfo)
type StreamConn ¶
type StreamConn struct { // DebugWriter is an optional writer that is used when a non-protobuf message is sent over the connection. DebugWriter io.Writer // contains filtered or unexported fields }
StreamConn implements the meshtastic client API stream protocol. This protocol is used to send and receive protobuf messages over a serial or TCP connection. See https://meshtastic.org/docs/development/device/client-api#streaming-version for additional information.
func NewClientStreamConn ¶
func NewClientStreamConn(conn io.ReadWriteCloser) (*StreamConn, error)
NewClientStreamConn creates a new StreamConn with the provided io.ReadWriteCloser. Once an io.ReadWriteCloser is provided, the StreamConn should be used read, write and close operations.
func NewRadioStreamConn ¶
func NewRadioStreamConn(conn io.ReadWriteCloser) *StreamConn
NewRadioStreamConn creates a new StreamConn with the provided io.ReadWriteCloser. Once an io.ReadWriteCloser is provided, the StreamConn should be used read, write and close operations.
func (*StreamConn) Read ¶
func (c *StreamConn) Read(out proto.Message) error
Read reads a protobuf message from the connection.
func (*StreamConn) ReadBytes ¶
func (c *StreamConn) ReadBytes() ([]byte, error)
ReadBytes reads a byte message from the connection. Prefer using Read if you have a protobuf message.
func (*StreamConn) Write ¶
func (c *StreamConn) Write(in proto.Message) error
Write writes a protobuf message to the connection.
func (*StreamConn) WriteBytes ¶
func (c *StreamConn) WriteBytes(data []byte) error
WriteBytes writes a byte slice to the connection. Prefer using Write if you have a protobuf message.