aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorNoah Stride <[email protected]>2024-02-02 19:51:25 +0000
committerGitHub <[email protected]>2024-02-02 09:51:25 -1000
commitffcb5db042e1f74b93020a9e840704eb9984913c (patch)
tree2ee157217aa958ff6195a6aaa3e4ec968e8c62d9 /util.go
parent463760ccf1cb99f387f5bf99ed83e31772744671 (diff)
Support for generating random NodeIDs and deriving Short/Long names (#2)
* Super rough initial subscription to channels and sending node info * Very ugly hacky FromRadio subscription * Add more TODOs :weary: * Add log message before we try to broadcast NodeInfo * Add basic positioning broadcasting * demo sending message from consumer * Use const for BroadcastNodeID * Config validation and defaults * Tidy up examples/TODOs * Tidy up example * Handle position and devicetelemetry updates * Fix dodgy merge * Allow configuring interval for nodeinfo/position seperately * Make broadcasted position configurable * Add MQTTProtoTopic constant rather than modifying topic root * Add Long/Short generation from NodeID * Mimic Meshtastic source more closely * Use generated Long/Short when not specified * Add TestRandomNodeID * Generate NodeID above the threshold
Diffstat (limited to 'util.go')
-rw-r--r--util.go23
1 files changed, 0 insertions, 23 deletions
diff --git a/util.go b/util.go
index ef2c61f..f96ca57 100644
--- a/util.go
+++ b/util.go
@@ -2,31 +2,8 @@ package meshtastic
import (
pbuf "buf.build/gen/go/meshtastic/protobufs/protocolbuffers/go/meshtastic"
- "encoding/binary"
- "fmt"
- "math"
)
-type NodeID uint32
-
-func (n NodeID) Uint32() uint32 {
- return uint32(n)
-}
-
-func (n NodeID) String() string {
- return fmt.Sprintf("!%08x", uint32(n))
-}
-
-// Bytes converts the NodeID to a byte slice
-func (n NodeID) Bytes() []byte {
- bytes := make([]byte, 4) // uint32 is 4 bytes
- binary.BigEndian.PutUint32(bytes, n.Uint32())
- return bytes
-}
-
-// BroadcastNodeID is the special NodeID used when broadcasting a packet to a channel.
-const BroadcastNodeID NodeID = math.MaxUint32
-
type Node struct {
LongName string
ShortName string