aboutsummaryrefslogtreecommitdiff
path: root/examples/mqtt/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'examples/mqtt/main.go')
-rw-r--r--examples/mqtt/main.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/mqtt/main.go b/examples/mqtt/main.go
index 0ad9c5f..742c396 100644
--- a/examples/mqtt/main.go
+++ b/examples/mqtt/main.go
@@ -3,7 +3,6 @@ package main
import (
"encoding/base64"
"encoding/hex"
- "fmt"
"github.com/charmbracelet/log"
pb "github.com/meshnet-gophers/meshtastic-go/meshtastic"
"github.com/meshnet-gophers/meshtastic-go/mqtt"
@@ -43,12 +42,15 @@ func channelHandler(channel string) mqtt.HandlerFunc {
}
var message pb.Data
err = proto.Unmarshal(decodedMessage, &message)
+ if err != nil {
+ log.Error(err)
+ }
- log.Info(processMessage(message), "topic", m.Topic, "channel", channel, "portnum", message.Portnum.String())
+ log.Info(processMessage(&message), "topic", m.Topic, "channel", channel, "portnum", message.Portnum.String())
}
}
-func processMessage(message pb.Data) string {
+func processMessage(message *pb.Data) string {
if message.Portnum == pb.PortNum_NODEINFO_APP {
var user = pb.User{}
proto.Unmarshal(message.Payload, &user)
@@ -75,7 +77,7 @@ func processMessage(message pb.Data) string {
return s.String()
}
- return fmt.Sprintf("unknown message type")
+ return "unknown message type"
}
func generateKey(key string) ([]byte, error) {