diff --git a/config.toml.example b/config.toml.example index 5dfb0bb..4b64a5d 100644 --- a/config.toml.example +++ b/config.toml.example @@ -1,5 +1,6 @@ [mqtt] Host = "192.168.0.123" +Port = 1883 [[targets]] Host = "192.168.0.222" diff --git a/main.go b/main.go index 6273184..a7663f7 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,7 @@ type targetConfig struct { type config struct { MQTT struct { Host string + Port uint16 } Targets []targetConfig } @@ -206,7 +207,9 @@ func main() { conf, err := parseConfig(*configpath) check(err) - mqttOpts := mqtt.NewClientOptions().AddBroker(fmt.Sprintf("tcp://%s:1883", conf.MQTT.Host)).SetClientID("apc2mqtt") + mqttOpts := mqtt.NewClientOptions().AddBroker( + fmt.Sprintf("tcp://%s:%d", conf.MQTT.Host, conf.MQTT.Port), + ).SetClientID("apc2mqtt") mqttClient := mqtt.NewClient(mqttOpts) if token := mqttClient.Connect(); token.Wait() && token.Error() != nil { panic(token.Error())