MQTT RETAIN messages work a little strangely
-
MQTT RETAIN messages work a little strangely. The first ones always come and are recorded by the mosquito server, but all subsequent messages do not reach and are not recorded by the server .. The RETAIN flag is naturally set.
-
Yes, I am using the mosquitto MQTT broker, but the problem is most likely with the mysensors MQTT gateway. On Mosquito, I am able to write a packet with the retained flag from the console, and it works.
@Clone-Tv Could you post your sketch, gateway log and which hardware you're using?
E.g. the default MQTT gateways don't set MY_MQTT_CLIENT_PUBLISH_RETAIN, so the stack behaves differently when set (https://github.com/mysensors/MySensors/blob/6c4b8055f729d1582b52068e3e858b77803a18b3/core/MyGatewayTransportMQTTClient.cpp#L129)
-
I do not use signed messages, so I used the Signed flag in the MySensors packet header to implement selective MQTT
retainstate.Gateway is ESP2866 - no specific code.
Code send from client:template<typename T> void reportMsg(const uint8_t & id, const mysensors_data_t & tag, const T & val, const bool retain) { MyMessage msg(id, tag); msg.setSigned(retain); send(msg.set(val), true); }Lite patch
MyGatewayTransportMQTTClient.cpp:bool gatewayTransportSend(MyMessage &message) { ... bool retain = message.getSigned(); message.setSigned(false); ....
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login