-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Hello Stefan,
thank you for your work on the library!
I have been able to publish to my Mosquitto-Broker on my PC,
but I can not figure out how to properly subscribe to a channel or capture the messages correctly.
I think I am getting something mixxed up, because I am using an old Version (3.5.11 is the only Version I was able to get running on the old Codesys version supported by my PLC..).
This is how I can publish, it all works fine:

I have tried different ways of subscribing, this is what I am currently left with, from the example project, but I see no changes what so ever when I break at the receiver:

In the main task I simply call the sub and publish functions and the MQTT handler:

It would be very nice if you could give me a hint what I am missing or point me towards the right example version.
(The date on my files is the 8.4.2019, if that helps.)
Edit: I changed the topic to '#', but still cant see anything. "Recived Publishs" in the MQTTSubscribe instance stays at 0 aswell. So I guess the subscriber does not get any of the messages (I can see them in Mosquitto though).
I get a connection at the broker with the correct topic subscription.
In the MQTTHandle instance I can see the "CounterOutputPublishCalled" increase with the messages I publish from my PC and "RevicedBytes" also increases whenever I publish a message to the broker (from my PC).
When I added a breakpoint in the maintask to stop at every cycle, "CountReceivedPublishs" also increased, otherwise it did not.
I also noticed that the first Entry of the InData Array in MQTT_Handle changes when a message is inbound.
Edit 2: I can see my reciveString object (showing the correct topic '#') in the SubscribeCalbacks array of MQTT_handle in my main Task. The MQTT_handles object shows some reaction to inbound messages, but it doesnt seem to be passed on to the next publishReceived Method.
Edit 3: I created my own subscription FB implementing the MessageRecived interface to see if the "MessageRecived" function gets called for a incoming message, which was very easy to do thanks to your great implementation. The call is executed as expected and I was also able to read the data, so there must be something I have done incorrectly when using the ReciveString.
One thing I noticed is that for all messages "PayloadIsString" seems to be True and it doesnt matter if I put a string (with "quotes") or a number as the message in mosquitto.
I believe I can make my project work with my makeshift solution. However if anyone has an idea as to where I made a mistake and what I need to change, I would be thankfull for any hints.
Beste Grüße,
Max