diff options
| author | Noah Stride <[email protected]> | 2024-02-02 19:51:25 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-02-02 09:51:25 -1000 |
| commit | ffcb5db042e1f74b93020a9e840704eb9984913c (patch) | |
| tree | 2ee157217aa958ff6195a6aaa3e4ec968e8c62d9 /emulated | |
| parent | 463760ccf1cb99f387f5bf99ed83e31772744671 (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 'emulated')
| -rw-r--r-- | emulated/emulated.go | 6 | ||||
| -rw-r--r-- | emulated/example/main.go | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/emulated/emulated.go b/emulated/emulated.go index 7077ee4..2001276 100644 --- a/emulated/emulated.go +++ b/emulated/emulated.go @@ -55,12 +55,10 @@ func (c *Config) validate() error { return fmt.Errorf("NodeID is required") } if c.LongName == "" { - // TODO: Generate from NodeID - return fmt.Errorf("LongName is required") + c.LongName = c.NodeID.DefaultLongName() } if c.ShortName == "" { - // TODO: Generate from NodeID - return fmt.Errorf("ShortName is required") + c.ShortName = c.NodeID.DefaultShortName() } if c.Channels == nil { //lint:ignore ST1005 we're referencing an actual field here. diff --git a/emulated/example/main.go b/emulated/example/main.go index d0a16e7..1e9b82b 100644 --- a/emulated/example/main.go +++ b/emulated/example/main.go @@ -18,11 +18,14 @@ func main() { ctx := context.Background() log.SetLevel(log.DebugLevel) - myNodeID := meshtastic.NodeID(3735928559) + nodeID, err := meshtastic.RandomNodeID() + if err != nil { + panic(err) + } r, err := emulated.NewRadio(emulated.Config{ LongName: "EXAMPLE", ShortName: "EMPL", - NodeID: myNodeID, + NodeID: nodeID, MQTTClient: &mqtt.DefaultClient, Channels: &pb.ChannelSet{ Settings: []*pb.ChannelSettings{ @@ -65,7 +68,7 @@ func main() { err := r.ToRadio(egCtx, &pb.ToRadio{ PayloadVariant: &pb.ToRadio_Packet{ Packet: &pb.MeshPacket{ - From: myNodeID.Uint32(), + From: nodeID.Uint32(), // This is hard coded to Noah's node ID To: 2437877602, PayloadVariant: &pb.MeshPacket_Decoded{ |
