1
0
Fork 0
mirror of https://github.com/Luzifer/culmqtt.git synced 2024-11-09 22:40:07 +00:00
culmqtt/mqtt.go

18 lines
413 B
Go
Raw Normal View History

2018-07-06 18:57:55 +00:00
package main
import mqtt "github.com/eclipse/paho.mqtt.golang"
var brokerClient mqtt.Client
func init() {
opts := mqtt.NewClientOptions().AddBroker(cfg.MQTTHost)
if cfg.MQTTUser != "" || cfg.MQTTPass != "" {
opts.SetUsername(cfg.MQTTUser).SetPassword(cfg.MQTTPass)
}
brokerClient = mqtt.NewClient(opts)
brokerClient.Connect().Wait()
brokerClient.Subscribe("culmqtt/+/send", 0x01, publishFS20ToCUL)
}