logging on disconnect
rgb/pipeline/head This commit looks good Details

pull/3/head
Nathan 2 years ago
parent ba17eb4a4c
commit 05907d4745

@ -105,6 +105,9 @@ func animator(tk *rgbmatrix.ToolKit, mqMessages chan mqtt.Message) {
tk.PlayAnimation(NewAnimation(image.Point{64, 32}, mqMessages)) tk.PlayAnimation(NewAnimation(image.Point{64, 32}, mqMessages))
} }
func onConnectionLostHandler(c MQTT.Client, reason error) {
log.Fatalf(reason.Error())
}
func setupMQTT() *mqtt.ClientOptions { func setupMQTT() *mqtt.ClientOptions {
opts := MQTT.NewClientOptions() opts := MQTT.NewClientOptions()
opts.AddBroker(fmt.Sprintf("tcp://%s:%s", os.Getenv("MQTTBROKER"), os.Getenv("MQTTPORT"))) opts.AddBroker(fmt.Sprintf("tcp://%s:%s", os.Getenv("MQTTBROKER"), os.Getenv("MQTTPORT")))
@ -112,6 +115,7 @@ func setupMQTT() *mqtt.ClientOptions {
opts.SetPassword(os.Getenv("MQTTPASSWORD")) opts.SetPassword(os.Getenv("MQTTPASSWORD"))
opts.SetClientID("rgbboard") opts.SetClientID("rgbboard")
opts.SetAutoReconnect(true) opts.SetAutoReconnect(true)
opts.SetConnectionLostHandler(onConnectionLostHandler)
return opts return opts
} }

Loading…
Cancel
Save