more G-Labs products

Author Topic: MqttClientHelper Publish  (Read 941 times)

August 20, 2015, 08:36:54 PM
Read 941 times

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I think I may have found a problem with the Publish method in MqttClientHelper.cs, in this forum message is a description of the problem.

Basically the Payload/Message looks like it's adding a string terminator to the beginning of the string, which doesn't play well with the MySensor nodes.

I downloaded the HomeGenie source and added an extra overload for MqttClientHelper Publish in
HomeGenie/Automation/Scripting/MqttClientHelper.cs.

Code: [Select]
/// <summary>
/// Publish a message to the specified topic.
/// </summary>
/// <param name="topic">Topic name.</param>
/// <param name="message">Message text as byte array.</param>
public MqttClientHelper Publish(string topic, byte[] message)
{
lock (mqttSyncLock)
{
mqttClient.PublishMessage(topic, message);
}
return this;
}

Calling it from HomeGenie with the following code works :) and the Payload is arriving at the MySensor node.

Code: [Select]
MqttClient.Publish("MyMQTT/21/1/V_LIGHT", Encoding.ASCII.GetBytes("1"));
Would it be possible to add this overload to MqttClientHelper? I'm not sure how to go about it in GitHub.
« Last Edit: August 20, 2015, 08:39:25 PM by mvdarend »

August 21, 2015, 02:42:54 AM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
login to github and click the following link:

https://github.com/genielabs/HomeGenie/edit/master/HomeGenie/Automation/Scripting/MqttClientHelper.cs

there you can edit and publish the modified file. I'm just telling for future reference. If it's too much bother to create an account on github, I will do it for you.

g.

August 21, 2015, 06:18:58 AM
Reply #2

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Thanks Gene, I was playing around with GitHub a while back as I'd like to help more, so I already had an account.

I'll give the GitHub documents a better readthrough today, as I still don't completely understand all the terms used (forking, pull request etc.)