Skip to content
Snippets Groups Projects
Commit ed1bf62d authored by Dennis Eisold's avatar Dennis Eisold
Browse files

Set frontendId as ClientId for MQTT

parent 163d871f
No related branches found
No related tags found
1 merge request!24Set frontendId as ClientId for MQTT
...@@ -76,26 +76,19 @@ namespace Wetterstation ...@@ -76,26 +76,19 @@ namespace Wetterstation
lbDatum.Text = DateTime.Now.ToShortDateString(); lbDatum.Text = DateTime.Now.ToShortDateString();
} }
//MQTT connect //MQTT connect
public void mqttStart() public void mqttStart()
{ {
String topic_publish = "/wetterstation/backend/" + WeatherstationSettings.frontendId + "/"; String topic_publish = "/wetterstation/backend/" + WeatherstationSettings.frontendId + "/";
String topic_subscribe = "/wetterstation/frontend/" + WeatherstationSettings.frontendId + "/#"; String topic_subscribe = "/wetterstation/frontend/" + WeatherstationSettings.frontendId + "/#";
System.Console.WriteLine("Hello, World!");
// Create Client instance // Create Client instance
this.myClient = new MqttClient("mqtt.itstall.de"); this.myClient = new MqttClient("mqtt.itstall.de");
// Register to message received // Register to message received
myClient.MqttMsgPublishReceived += client_recievedMessage; myClient.MqttMsgPublishReceived += client_recievedMessage;
string clientId = Guid.NewGuid().ToString(); this.myClient.Connect(WeatherstationSettings.frontendId, "wetterstation", "wetterstation");
this.myClient.Connect("", "wetterstation", "wetterstation");
// Subscribe to topic // Subscribe to topic
this.myClient.Subscribe(new String[] { topic_subscribe }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }); this.myClient.Subscribe(new String[] { topic_subscribe }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment