iotagent-ul
iotagent-ul copied to clipboard
MQTTBinding: Add configuration for publishing retained messages.
At
https://github.com/telefonicaid/iotagent-ul/blob/master/lib/bindings/MQTTBinding.js#L257
could there be a configuration flag for retained messages. It may be useful for low-consumption devices that are not listening at the moment of updates (many devices may only power on themselves once or twice a day).
It may be useful, indeed. We are currently implementing polling commands for the HTTP binding, precisely for the same reason (this issue was an old one). It seems to me retained messages will have a similar effect for MQTT.
I've seen this may get in conflict with how commands are designed:
If a low-consumption device is not listening at a time, and any component in this time sends two or more different cmds in this time, only last one will reach the device.
For example, if you want to play one sound then shutdown alarm:
topic message
/myRealm/alarm1/cmd emitsound@time=20|sound=1
/myRealm/alarm1/cmd shutdown@time=5
Lets think that alarm check status every 5 seconds to save battery. If those two MQTT messages gets to the server between those 5 seconds, the first one will be lost. The alarm will be shutdown without playing any sound.
A solution with different design for MQTT binding may be:
topic message
/myRealm/alarm1/cmd/emitsound time=20|sound=1
/myRealm/alarm1/cmd/shutdown time=5
Or:
topic message
/myRealm/alarm1/cmd/emitsound <timestamp>@time=20|sound=1
/myRealm/alarm1/cmd/shutdown <timestamp>@time=5
By looking at timestamp this hypothetical device could check which command got first, in case of order being important.