Adafruit_MQTT_Library
Adafruit_MQTT_Library copied to clipboard
Added retain flag for publishing
Added a 'retain' flag for the Adafruit_MQTT_Publish
class. When set, published topics will be saved on the broker so later subscriptions will receive the message as well.
In order to remove this topic from the broker, one must publish a message with no (i.e. zero-length) content.
By default, this flag is unset to keep the current behavior.
Why is Adafruit not accepting this pull request? Wanted to modify the library by myself, but then I found your fork. I would have made the same changes as you did. Good work!
Successfully tested on Wemos Mini (esp8266)
can you please provide an example on how to use this?
Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/photocell", 0, 1);
The last value is the retained flag. Setting it to zero will not publish the topic as retained. Setting it to anything else will.