[Feature] Protobuf Encoding / Decoding per Subscription
Motivation
As mentioned in #555 protobuf encoding is now supported in MQTTX, which is great, but sadly one can only configure one message type for all subscriptions. Often it is necessary to subscribe to multiple topics, which all use a different protobuf message to en-/decode.
Detailed design
I would like to be able to set up a mapping from either subscription or topic to protobuf (or other schema) message both for sending as well as receiving. This means that the "Run Script" should either be available by subscription, or that a certain mapping from (wildcarded) topics to encodings is possible. The best case would be if it were possible to take different messages from different encoding files.
Alternatives
I have considered writing a script that would do this en-/decoding dynamically based on the topic, however, since the functions are not yet properly documented I was not able to easily do this. I furthermore think, that this would be an important feature to have, as writing a custom script is a lot more effort / higher barrier to entry for something that could be quite common to need (imo).
Hi @Neverbolt 👋
Thank you very much for your suggestions and feedback. We are currently planning improvements in the scripting use, and your suggestions are of great help to us. We plan to implement and optimize the script functionality for topics in the future. At the same time, we apologize for not being able to fully meet your requirements.
If possible, you could consider using MQTTX CLI as an alternative. It also supports protobuf, and you can use multiple commands to use different proto files for different topics. For example:
mqttx sub -t 'testtopic/1' -h broker.emqx.io -Pp ./TestPerson.proto -Pmn Person
mqttx sub -t 'testtopic/2' -h broker.emqx.io -Pp ./Message.proto -Pmn Message
We will continue to strive to enhance the functionality and user experience of MQTTX. Thanks again for your valuable suggestions.