common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MagicStart1      = byte(0x94)
	MagicStart2      = byte(0xc3)
	MaxPayloadLength = 512
)

Variables

View Source
var (
	ErrUplinkConnectorAlreadyRunning = errors.New("uplink connector is already running")
	ErrUplinkIsAlreadyRunning        = errors.New("uplink is already running")
	ErrDownlinkIsAlreadyRunning      = errors.New("downlink is already running")
)

Functions

This section is empty.

Types

type DownlinkAudience

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

type DownlinkBaseConfig

type DownlinkBaseConfig struct {
	Uplink           string `toml:"uplink"`
	MeshPacketBuffer int    `toml:"mesh_packet_buffer"`
	MeshPacketDedupe bool   `toml:"mesh_packet_dedupe"`
}

func (*DownlinkBaseConfig) GetDownlinkBaseConfig

func (c *DownlinkBaseConfig) GetDownlinkBaseConfig() *DownlinkBaseConfig

func (*DownlinkBaseConfig) Prepare

func (c *DownlinkBaseConfig) Prepare() error

type Frame

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

func NewFrame

func NewFrame(header [4]byte, data []byte) *Frame

func NewPBOnlyFrame

func NewPBOnlyFrame(data []byte) *Frame

func (*Frame) ParseFromRadio

func (f *Frame) ParseFromRadio() (*protobuf.FromRadio, error)

func (*Frame) WriteTo

func (f *Frame) WriteTo(w io.Writer) (n int64, err error)

func (*Frame) WriteToNoHeader

func (f *Frame) WriteToNoHeader(w io.Writer) (n int64, err error)

type FrameCollector

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

FrameCollector searches for frames in a byte stream and collects them. It accepts data chunks that may contain zero, one, or multiple frames, and handles cases where frames are split across multiple chunks.

func NewFrameCollector

func NewFrameCollector(logger *slog.Logger) *FrameCollector

func (*FrameCollector) Collect

func (c *FrameCollector) Collect(data []byte) []*Frame

func (*FrameCollector) Reset

func (c *FrameCollector) Reset()

type RingBuffer

type RingBuffer[T any] struct {
	// contains filtered or unexported fields
}

func NewRingBuffer

func NewRingBuffer[T any](capacity int) *RingBuffer[T]

func (*RingBuffer[T]) Add

func (rb *RingBuffer[T]) Add(item T)

func (*RingBuffer[T]) GetAll

func (rb *RingBuffer[T]) GetAll() []T

func (*RingBuffer[T]) GetLastN

func (rb *RingBuffer[T]) GetLastN(n int) []T

func (*RingBuffer[T]) Reset

func (rb *RingBuffer[T]) Reset()
type Uplink struct {
	// contains filtered or unexported fields
}
func NewUplink(logger *slog.Logger, config UplinkBaseConfig, connector UplinkConnector) *Uplink

func (*Uplink) AttachClient

func (u *Uplink) AttachClient(
	downlinkLogger *slog.Logger,
	in chan *Frame,
	sendBufferedPackets int,
	lastSentFrame *Frame,
) (out chan *Frame, ok bool)

func (*Uplink) GetNodeInfo

func (u *Uplink) GetNodeInfo() *protobuf.MyNodeInfo

func (*Uplink) Run

func (u *Uplink) Run(ctx context.Context) error

type UplinkBaseConfig

type UplinkBaseConfig struct {
	ID                string         `toml:"id"`
	ReconnectInterval *time.Duration `toml:"reconnect_interval"`
	RequestConfig     bool           `toml:"request_config"`

	MeshPacketBuffer int `toml:"-"` // maximum MeshPacketBuffer value across all downlinks using this uplink
}

func (*UplinkBaseConfig) GetUplinkBaseConfig

func (c *UplinkBaseConfig) GetUplinkBaseConfig() *UplinkBaseConfig

func (*UplinkBaseConfig) Prepare

func (c *UplinkBaseConfig) Prepare() error

type UplinkConnector

type UplinkConnector interface {
	Open(ctx context.Context, in chan *Frame) (out chan *Frame, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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