decoding/splitting mqtt data received
Unsolved
Mobile and Embedded
-
I am using mqtt_bridge on remote machine which is converting ros data into mqtt and sending to qt appliction where qtmqtt library is used to read those topic data.
Currently i'm reading odom topic of nav_msgs/Odometry type but i'm getting somethign like:��header��seq�A��stamp��secs�/�nsecs�+6�@�frame_id�odom�child_frame_id�base_footprint�pose��pose��position��x˿���#��y˿����3���z˿P�V��@Ыorientation��x˾���6���y�?Zwڪ �z�?P��
This is the function where i'm trying to decode this json msg to appropriate data.
void QmlMqttSubscription::handleMessage(const QMqttMessage &qmsg) { auto items = qmsg.payload(); qDebug() << items; emit messageReceived(qmsg.payload()); }
I'm using quicksubscription example code from mqtt package. Can anyone tell me how do i split this data properly and save in some variable?
-
Hi,
@Dinesh-Lama said in decoding/splitting mqtt data received:
This is the function where i'm trying to decode this json msg to appropriate data.
Since it's json, you can use QJsonDocument::fromJson and then go from there to extract the information you want.