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

using set with retained messages #281

Open
Tieske opened this issue Nov 5, 2023 · 1 comment
Open

using set with retained messages #281

Tieske opened this issue Nov 5, 2023 · 1 comment

Comments

@Tieske
Copy link
Contributor

Tieske commented Nov 5, 2023

For battery driven devices, it makes sense that set topics are retained. So instead of reinventing the loop of checking availability and only sending if awake in the Homie controller, we can actually use the logic that MQTT already provides.

Maybe, if the device is sleeping, then the retain flag is allowed? or would this lead to race-conditions due to MQTT timing?

Also does a later non-retained message delete it again to ensure we cleanup after it? if not how to clean?

Requires devices to not reconnect using a "clean" session, otherwise they would get the same command over and over again every time they go online.

Seems like a device must specify this in its description. Probably an additional property is required.

We can do this past 5.0

@Thalhammer
Copy link
Member

Maybe, if the device is sleeping, then the retain flag is allowed?

You shouldn't need that. If you send the set message with a qos of 1 or 2 it will get queued by the broker until the device reconnects.

Also does a later non-retained message delete it again to ensure we cleanup after it?

No. As stated by MQTT-3.3.1-12 If the RETAIN flag is 0, in a PUBLISH Packet sent by a Client to a Server, the Server MUST NOT store the message and MUST NOT remove or replace any existing retained message. I.e. the retained message would stay and get delivered anyway.

Requires devices to not reconnect using a "clean" session

Which is likely what would be a recommended behavior anyway, cause it avoids having to subscribe after every connect and therefore improves latency, bandwidth usage and (potentially) reduces cost (e.g. GSM networks). The client can use the session present bit of the connect reply to check if it needs to subscribe without having to keep local state. The only special case you need is if a firmware upgrade / configuration change adds new subscriptions.

Seems like a device must specify this in its description.

I don't think so. IMHO all thats needed is allowing QOS1/2 publish for the set topic.

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

No branches or pull requests

2 participants