Documentation
¶
Index ¶
- Variables
- type NodeID
- func (n NodeID) Bytes() []byte
- func (n NodeID) DefaultLongName() string
- func (n NodeID) DefaultShortName() string
- func (n NodeID) IsBroadcast() bool
- func (n NodeID) IsReservedID() bool
- func (n NodeID) MarshalText() ([]byte, error)
- func (n NodeID) String() string
- func (n NodeID) ToMacAddress() string
- func (n NodeID) Uint32() uint32
- func (n *NodeID) UnmarshalText(text []byte) error
- type Packet
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPacket signals the source buffer does not contain a valid packet. ErrInvalidPacket = errors.New("meshtastic: invalid packet") )
Functions ¶
This section is empty.
Types ¶
type NodeID ¶
type NodeID uint32
const ( // BroadcastNodeID is the special NodeID used when broadcasting a packet to a channel. BroadcastNodeID NodeID = math.MaxUint32 // BroadcastNodeIDNoLora is a special broadcast address that excludes LoRa transmission. // Used for MQTT-only broadcasts. This is ^all with the NO_LORA flag (0x40) cleared. BroadcastNodeIDNoLora NodeID = math.MaxUint32 ^ 0x40 )
func ParseNodeID ¶
ParseNodeID parses a NodeID from various string formats:
- "!abcd1234" (Meshtastic format with ! prefix)
- "0xabcd1234" (hex with 0x prefix)
- "abcd1234" (plain hex)
- "12345678" (decimal)
func RandomNodeID ¶
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) DefaultLongName ¶
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 ¶
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) IsBroadcast ¶
IsBroadcast returns true if this is any form of broadcast address.
func (NodeID) IsReservedID ¶
IsReservedID returns true if this is a reserved or broadcast NodeID.
func (NodeID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (NodeID) String ¶
String converts the NodeID to a hex formatted string. This is typically how NodeIDs are displayed in Meshtastic UIs.
func (NodeID) ToMacAddress ¶
ToMacAddress returns a MAC address string derived from the NodeID. This creates a locally administered unicast MAC address.
func (*NodeID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler for use with config parsers like Viper.
type Packet ¶
type Packet struct {
Destination NodeID `json:"destination"`
Source NodeID `json:"source"`
ID uint32 `json:"id"`
Flags uint8 `json:"flags"`
ChannelHash uint8 `json:"channelHash"`
NextHop uint8 `json:"nextHop"`
RelayNode uint8 `json:"relayNode"`
PayloadLength int `json:"-"`
Payload [maxPayloadSize]byte `json:"-"`
Data *meshtasticpb.Data `json:"data,omitempty"`
DecodedPayload proto.Message `json:"decodedPayload,omitempty"`
TextPayload string `json:"textPayload,omitempty"`
}
func (*Packet) MarshalJSON ¶
MarshalJSON implements custom JSON marshaling for Packet.