How to set MQTT retain flag?

I’ve been using MQTT in my code for a while now, however wanted to clean up a few things and experiment with the retain flag, however after reading Particle MQTT and googling can’t find any examples of people using the flag :frowning:

I can see mention of “retain” in the MQTT.h and cpp files and assume I need to add something to the client.publish line, taking a guess after looking at the .h file, is this correct or do i need to add something else?

client.publish("outTopic/message","hello world", true);        // <- does adding true here set the retain flag?

yes, that's correct :+1:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.