meshtastic

package
v0.0.0-...-b5ab26a Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SeenByLimit   = 10
	NeighborLimit = 100
)

Variables

View Source
var DefaultKey = []byte{
	0xd4, 0xf1, 0xbb, 0x3a,
	0x20, 0x29, 0x07, 0x59,
	0xf0, 0xbc, 0xff, 0xab,
	0xcf, 0x4e, 0x69, 0x01,
}

Functions

func NewBlockCipher

func NewBlockCipher(key []byte) cipher.Block

Types

type MQTTClient

type MQTTClient struct {
	TopicRegex     *regexp.Regexp
	BlockCipher    cipher.Block
	MessageHandler func(from uint32, topic string, portNum generated.PortNum, payload []byte)

	mqtt.Client
	// contains filtered or unexported fields
}

func (*MQTTClient) Connect

func (c *MQTTClient) Connect() error

func (*MQTTClient) Disconnect

func (c *MQTTClient) Disconnect()

type NeighborInfo

type NeighborInfo struct {
	Snr     float32 `json:"snr,omitempty"`
	Updated int64   `json:"updated"`
}

type Node

type Node struct {
	// User
	LongName  string `json:"longName"`
	ShortName string `json:"shortName"`
	HwModel   string `json:"hwModel"`
	Role      string `json:"role"`
	// MapReport
	FwVersion        string `json:"fwVersion,omitempty"`
	Region           string `json:"region,omitempty"`
	ModemPreset      string `json:"modemPreset,omitempty"`
	HasDefaultCh     bool   `json:"hasDefaultCh,omitempty"`
	OnlineLocalNodes uint32 `json:"onlineLocalNodes,omitempty"`
	LastMapReport    int64  `json:"lastMapReport,omitempty"`
	// Position
	Latitude  int32  `json:"latitude"`
	Longitude int32  `json:"longitude"`
	Altitude  int32  `json:"altitude,omitempty"`
	Precision uint32 `json:"precision,omitempty"`
	// DeviceMetrics
	BatteryLevel      uint32  `json:"batteryLevel,omitempty"`
	Voltage           float32 `json:"voltage,omitempty"`
	ChUtil            float32 `json:"chUtil,omitempty"`
	AirUtilTx         float32 `json:"airUtilTx,omitempty"`
	Uptime            uint32  `json:"uptime,omitempty"`
	LastDeviceMetrics int64   `json:"lastDeviceMetrics,omitempty"`
	// NeighborInfo
	Neighbors map[uint32]*NeighborInfo `json:"neighbors,omitempty"`
	// key=mqtt topic, value=first seen/last position update
	SeenBy map[string]int64 `json:"seenBy"`
}

func NewNode

func NewNode(topic string) *Node

func (*Node) ClearDeviceMetrics

func (node *Node) ClearDeviceMetrics()

func (*Node) ClearMapReportData

func (node *Node) ClearMapReportData()

func (*Node) IsValid

func (node *Node) IsValid() bool

func (*Node) Prune

func (node *Node) Prune(seenByTtl, neighborTtl, deviceMetricsTtl, mapReportTtl int64)

func (*Node) UpdateDeviceMetrics

func (node *Node) UpdateDeviceMetrics(batteryLevel uint32, voltage, chUtil, airUtilTx float32, uptime uint32)

func (*Node) UpdateMapReport

func (node *Node) UpdateMapReport(fwVersion, region, modemPreset string, hasDefaultCh bool, onlineLocalNodes uint32)

func (*Node) UpdateNeighborInfo

func (node *Node) UpdateNeighborInfo(neighborNum uint32, snr float32)

func (*Node) UpdatePosition

func (node *Node) UpdatePosition(latitude, longitude, altitude int32, precision uint32)

func (*Node) UpdateSeenBy

func (node *Node) UpdateSeenBy(topic string)

func (*Node) UpdateUser

func (node *Node) UpdateUser(longName, shortName, hwModel, role string)

type NodeDB

type NodeDB map[uint32]*Node

func (NodeDB) GetValid

func (db NodeDB) GetValid() NodeDB

func (*NodeDB) LoadFile

func (db *NodeDB) LoadFile(path string) error

func (NodeDB) Prune

func (db NodeDB) Prune(seenByTtl, neighborTtl, deviceMetricsTtl, mapReportTtl int64)

func (NodeDB) WriteFile

func (db NodeDB) WriteFile(path string) error

Jump to

Keyboard shortcuts

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