Mqtt client example for br plc, link to sample

Hi Wenjie Cui!
I want to implement communication between B&R PLC (client) and MQTT broker, but the library paho.mqtt.c-ar you mentioned is not available. Could you please share an example program to send messages to MQTT broker using this library?

The library is available in the archive:

Please see this post for more info:

Thank you so much!
This is exactly what I was looking for! Very useful!

Dear All,
As I have tried to used this library in my project but not able to connect with my cloud. It is showing an error of -10005.
So anybody can help how to resolve this issue.

Thanks In Advance.
Shrenik

Hi,

i’ve no experience with that library, but having a look into the constants definition I see that error -10005 means “connection failed”.
So I would recommend to check your PLCs IP settings, if the broker is reachable.
Especially check, if DNS is activated (if using a hostname), if the default gateway settings are correct (if the broker isn’t on the same subnet as the PLC), and so on.
Additionally, please check the PLC loggers for information (I’m not sure, but I could imagine that this library creates some logger entries / an own logger module).

The’re some hints / informations about the network settings in the github documentation:

Best regards!

Please note that if you are using the certificate store you could hit a bug in the AS6/AR6 of the library. AS6/AR6: Own Certificates aren’t loading when placed in the certificates store · Issue #41 · br-automation-community/paho.mqtt.c-ar. You can use the workaround of placing the certificates in the USER filedevice.