Adafruit_MQTT_Library icon indicating copy to clipboard operation
Adafruit_MQTT_Library copied to clipboard

Added retain flag for publishing

Open shmuelzon opened this issue 8 years ago • 4 comments

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.

shmuelzon avatar Jan 02 '17 07:01 shmuelzon

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!

isolution-de avatar Jan 27 '17 00:01 isolution-de

Successfully tested on Wemos Mini (esp8266)

mmaret-geny avatar Mar 06 '17 22:03 mmaret-geny

can you please provide an example on how to use this?

TRIROG avatar Mar 28 '17 07:03 TRIROG

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.

shmuelzon avatar Mar 28 '17 07:03 shmuelzon