aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorSmoke <[email protected]>2024-01-19 10:51:52 -1000
committerSmoke <[email protected]>2024-01-19 10:51:52 -1000
commit70bb2c77356d349165ba46ea98f8346284c2e44e (patch)
tree7a1f858ca12386f7bd9478550e29bf3c1af109b5 /util.go
parent320bb2e1e7dfe5092ea1f6b65a9c6e53e58ce387 (diff)
updates
Diffstat (limited to 'util.go')
-rw-r--r--util.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..0de4297
--- /dev/null
+++ b/util.go
@@ -0,0 +1,46 @@
+package meshtastic
+
+import (
+ pbuf "buf.build/gen/go/meshtastic/protobufs/protocolbuffers/go/meshtastic"
+ "encoding/binary"
+ "fmt"
+)
+
+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
+}
+
+type Node struct {
+ LongName string
+ ShortName string
+ ID uint32
+ HardwareModel pbuf.HardwareModel
+}
+
+// Not actually in use yet 😅
+func (n *Node) EncryptPacket(pkt *pbuf.MeshPacket, channelName string, key []byte) *pbuf.MeshPacket {
+ payload := pkt.GetPayloadVariant()
+ _ = payload
+ switch p := payload.(type) {
+ case *pbuf.MeshPacket_Decoded:
+ _ = p
+ encrypted := pbuf.MeshPacket_Encrypted{
+ Encrypted: nil,
+ }
+ _ = encrypted
+ }
+ return nil
+}