transport

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.1.5

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v0.1.5

func NewClient(sc *StreamConn, errorOnNoHandler bool) *Client

func (*Client) Connect added in v0.1.5

func (c *Client) Connect() error

func (*Client) Handle added in v0.1.5

func (c *Client) Handle(kind proto.Message, handler MessageHandler)

func (*Client) SendToRadio added in v0.1.5

func (c *Client) SendToRadio(msg *meshtastic.ToRadio) error

type HandlerFunc added in v0.1.5

type HandlerFunc func(message proto.Message)

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

type MessageHandler func(msg proto.Message)

MessageHandler defines the function signature for a handler that processes a protobuf message.

type StreamConn added in v0.1.5

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 added in v0.1.5

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 added in v0.1.5

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) Close added in v0.1.5

func (c *StreamConn) Close() (err error)

Close closes the connection.

func (*StreamConn) Read added in v0.1.5

func (c *StreamConn) Read(out proto.Message) error

Read reads a protobuf message from the connection.

func (*StreamConn) ReadBytes added in v0.1.5

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 added in v0.1.5

func (c *StreamConn) Write(in proto.Message) error

Write writes a protobuf message to the connection.

func (*StreamConn) WriteBytes added in v0.1.5

func (c *StreamConn) WriteBytes(data []byte) error

WriteBytes writes a byte slice to the connection. Prefer using Write if you have a protobuf message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL