Reputation: 1
this is my first post, as after long hours of search i didn't find any satisfying answer for my problem...
I can retrieve data in real time from a mqtt broker using a command like this :
.\mosquitto_sub -h XX.XX.XX -t XX/XX/XX -p XXXX --psk-identity XXX --psk XXXXXXXXXXXXXXX
But i have two issues :
The data displayed in the shell seems encoded with unreadable characters by the shell (like this:
ÿC% <C(0§└
). As i understand it's protobuf encoding but so far all my attempts to decode it failed miserably.
Even if i find a way to decode it, as the data is displayed directly in the shell in real time, I've no idea how to save it in real time into a database.
Ideally, it would exist a platform/language which could read mqtt messages, could decode them and then insert them into a database as they arrive.
Any help/insight would be greatly appreciated. Thanks.
Upvotes: 0
Views: 1167
Reputation: 59608
Simple, don't use mosquitto_sub
(but look at the -F
option and the Output Format section in the man page in the mean time)
Ideally, it would exist a platform/language which could read mqtt messages, could decode them and then insert them into a database as they arrive.
There are many, you just need to pick one and have a go. The right way to approach this is to use one of the many MQTT client libraries and a matching protobuf library for what ever language you choose and write your own client that has the right protobuf schema to decode the data directly from the byte array/buffer that the MQTT client library will present to you for each subscribed message that arrives.
(And no we can not recommend a MQTT/Protobuf library as we have no idea what languages you are familiar with or what other constraints your project may have and asking for such recommendations is explicitly off topic for Stack Overflow. But you might want to have a look at a Low Code platform like Node-RED if you are not proficient/confident with any of scripting or compiled languages ).
Upvotes: 2