Help Needed: Handling Serialized Data with Escaped Characters in Paho MQTT/Packet Library

I need a little help. @Middleware & OS I'm using the library called paho mqtt/packet. The example provided with it performs serialization of the data that needs to be sent and then sends it over TCP just like that. I have written the code for the ESP, and it works fine without any issues. However, when I serialize the data, it looks like this (as seen in the debugger):
\020\016\0\004MQTT\004\002\0\024\0\002me
\020\016\0\004MQTT\004\002\0\024\0\002me
The driver I wrote treats these escapes as the end of the string, so it doesn't see anything and doesn't send anything. Is this format normal? I mean, is the packet supposed to look like this? And if this is the normal format, how can I deal with these escapes? Here's the code and the shape of the array before sending:
attachment 0
attachment 1
Solution:
you are right, I hadn't initialized it. I have added memset(buf, 0, 200); to my code, but I'm still facing the same issue with the serialized data being interpreted incorrectly ...
Jump to solution
3 Replies
youcef_ali
youcef_ali5mo ago
There is no initialisation of your buf variable try memset( buf, 0, 200 );
Great~~~
Great~~~5mo ago
👍
Solution
wafa_ath
wafa_ath5mo ago
you are right, I hadn't initialized it. I have added memset(buf, 0, 200); to my code, but I'm still facing the same issue with the serialized data being interpreted incorrectly ...
Want results from more Discord servers?
Add your server