meshtastic

package module
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

README

Under heavy development. Consider these contracts written with a half-eaten crayon; they will change.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	LongName      string
	ShortName     string
	ID            uint32
	HardwareModel pbuf.HardwareModel
}

func (*Node) EncryptPacket

func (n *Node) EncryptPacket(pkt *pbuf.MeshPacket, channelName string, key []byte) *pbuf.MeshPacket

Not actually in use yet 😅

type NodeID

type NodeID uint32

NodeID holds the node identifier. This is a uint32 value which uniquely identifies a node within a mesh.

const (
	// BroadcastNodeID is the special NodeID used when broadcasting a packet to a channel.
	BroadcastNodeID NodeID = math.MaxUint32
)

func RandomNodeID added in v0.1.5

func RandomNodeID() (NodeID, error)

RandomNodeID returns a randomised NodeID. It's recommended to call this the first time a node is started and persist the result.

Hardware meshtastic nodes first try a NodeID of the last four bytes of the BLE MAC address. If that ID is already in use or invalid, a random NodeID is generated. Source: https://github.com/meshtastic/firmware/blob/d1ea58975755e146457a8345065e4ca357555275/src/mesh/NodeDB.cpp#L466

func (NodeID) Bytes

func (n NodeID) Bytes() []byte

Bytes converts the NodeID to a byte slice

func (NodeID) DefaultLongName added in v0.1.5

func (n NodeID) DefaultLongName() string

DefaultLongName returns the default long node name based on the NodeID. Source: https://github.com/meshtastic/firmware/blob/d1ea58975755e146457a8345065e4ca357555275/src/mesh/NodeDB.cpp#L382

func (NodeID) DefaultShortName added in v0.1.5

func (n NodeID) DefaultShortName() string

DefaultShortName returns the default short node name based on the NodeID. Last two bytes of the NodeID represented in hex. Source: https://github.com/meshtastic/firmware/blob/d1ea58975755e146457a8345065e4ca357555275/src/mesh/NodeDB.cpp#L382

func (NodeID) String

func (n NodeID) String() string

String converts the NodeID to a hex formatted string. This is typically how NodeIDs are displayed in Meshtastic UIs.

func (NodeID) Uint32

func (n NodeID) Uint32() uint32

Uint32 returns the underlying uint32 value of the NodeID.

type PacketDeduplicator added in v0.1.5

type PacketDeduplicator struct {
	sync.RWMutex // RWMutex is used to protect the seen map from concurrent access.
	// contains filtered or unexported fields
}

PacketDeduplicator is a structure that prevents processing of duplicate packets. It keeps a record of seen packets and the time they were last seen.

func NewDeduplicator added in v0.1.5

func NewDeduplicator(hasher hash.Hash, expiresAfter time.Duration) *PacketDeduplicator

NewDeduplicator creates a new PacketDeduplicator with a given hasher and expiration duration for packet records. It starts a background goroutine to periodically clean up expired packet records.

func (*PacketDeduplicator) Seen added in v0.1.5

func (p *PacketDeduplicator) Seen(sender, packetID uint32) bool

Seen checks whether a packet with the given sender and packetID has been seen before. If not, it records the packet as seen and returns false. Otherwise, it returns true.

func (*PacketDeduplicator) SeenData added in v0.1.5

func (p *PacketDeduplicator) SeenData(data []byte) bool

SeenData checks whether the data has been seen before based on its hashed value. If not, it records the data as seen and returns false. Otherwise, it returns true.

Directories

Path Synopsis
Package lora provides utilities to assess the signal quality of LoRa (Long Range) communication based on RSSI (Received Signal Strength Indicator) and SNR (Signal-to-Noise Ratio) values.
Package lora provides utilities to assess the signal quality of LoRa (Long Range) communication based on RSSI (Received Signal Strength Indicator) and SNR (Signal-to-Noise Ratio) values.

Jump to

Keyboard shortcuts

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