Skip to content

Commit

Permalink
add mqtt port parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
zivillian committed Nov 1, 2023
1 parent 437e248 commit 9dd969d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ism7mqtt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static async Task Main(string[] args)
bool showHelp = false;
bool enableDebug = GetEnvBool("ISM7_DEBUG");
string mqttHost = GetEnvString("ISM7_MQTTHOST");
int mqttPort = GetEnvInt32("ISM7_MQTTPORT", 1883);
string ip = GetEnvString("ISM7_IP");
string password = GetEnvString("ISM7_PASSWORD");
string parameter = "parameter.json";
Expand All @@ -47,6 +48,7 @@ static async Task Main(string[] args)
{"mqttuser=", "MQTT username", x => mqttUsername = x},
{"mqttpass=", "MQTT password", x => mqttPassword = x},
{"mqttqos=", "MQTT QoS", (int x) => _qos = (MqttQualityOfServiceLevel)x},
{"mqttport=", "MQTT port (defaults to 1883)", (int x) => mqttPort = x},
{"s|separate", "send values to separate mqtt topics - also disables json payload", x=> _useSeparateTopics = x != null},
{"retain", "retain mqtt messages", x=> _retain = x != null},
{"interval=", "push interval in seconds (defaults to 60)", (int x) => interval = x},
Expand Down Expand Up @@ -97,7 +99,7 @@ static async Task Main(string[] args)
using (var mqttClient = new MqttFactory().CreateMqttClient())
{
var mqttOptionBuilder = new MqttClientOptionsBuilder()
.WithTcpServer(mqttHost)
.WithTcpServer(mqttHost, mqttPort)
.WithClientId($"Wolf_{ip.Replace(".", String.Empty)}");
if (!String.IsNullOrEmpty(mqttUsername) || !String.IsNullOrEmpty(mqttPassword))
{
Expand Down

0 comments on commit 9dd969d

Please sign in to comment.