Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
883 views
in Technique[技术] by (71.8m points)

iot - How to manipulate/modify MQTT msgs?

MQTT is a very well known standard protocol, however there is no standard for the payload structure of the msgs.

I have a MQTT broker works with payload in a format like that: {"value": "ON"} The Device works with payload in a different format like that {"ON"}

I need a way to add the "value:" on the msgs coming from the device. I need a way to remove the "value:" on the msgs coming from the broker.

How could I manipulate or edit the msgs from the device to make them understandable by the broker? I would need an "intermediary broker" doing this manipulation I imagine

Which options would you recommend? Thanks.

question from:https://stackoverflow.com/questions/65860686/how-to-manipulate-modify-mqtt-msgs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is no standard mechanism to do this.

The normal way would be to subscribe to the original messages topic with a client which does the transformation then re-published it on a new topic that the end device is subscribed to.

There are libraries that let you implement your own broker that include hooks that should allow you to manipulate messages on the fly if needed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...