Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added retain flag for publishing #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shmuelzon
Copy link

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.

@isolution-de
Copy link

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!

@mmaret-geny
Copy link

Successfully tested on Wemos Mini (esp8266)

@TRIROG
Copy link

TRIROG commented Mar 28, 2017

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

@shmuelzon
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants