Skip to content

Commit

Permalink
Set a default client ID for MQTT
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrin committed Jan 6, 2022
1 parent b05b2b0 commit 20a2869
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sender/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ func SetupMQTT(conf config.MQTT) {
"topic_prefix": conf.TopicPrefix,
}).Info("Starting MQTT")

clientID := conf.ClientID
if clientID == "" {
clientID = "ruuvi-go-gateway"
}
opts := mqtt.NewClientOptions()
opts.SetCleanSession(false)
opts.AddBroker(server)
opts.SetClientID(conf.ClientID)
opts.SetClientID(clientID)
opts.SetUsername(conf.Username)
opts.SetPassword(conf.Password)
opts.SetKeepAlive(10 * time.Second)
Expand Down

0 comments on commit 20a2869

Please sign in to comment.