-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Espressif_MQTT_Client.h parsing problem in ESP-IDF #237
Comments
The output is only weird, because you print out non-terminated strings like it is a null-terminated string. If you measure the characters you can see that Which version of the library are you using, because a similair issue has been fixed previously and additionally can you enable |
I use this versions:
Using example named "0017-espressif_esp32_process_shared_attribute_update", which is available on ESP Component Registry under Examples, I can't get my shared attributes when I update them on thingsboard. I have THINGSBOARD_ENABLE_DEBUG enabled on top of my main.cpp and I can see in debug log that attributes are received on MQTT socket using this example script, but my callback function is never called so I didn't receive any parameters in my main code. After code change specified in my first comment everything worked. |
The issue is exactly the case you mentioned debugged it further and confirmed it. It occurs because the EspressifMQTTClient received a non null-terminated string and therefore latter I implemented my own fix that reduces the required steps because the topic size can simply be read from the topic_len and therefore also simply used as the size of the new topic. char topic[event->topic_len + 1] = {};
strncpy(topic, event->topic, event->topic_len); Has been commited into the pull request, as soon as it has been merged and released the issue will be fixed. For now simply apply the patch locally. |
Thank you for very quick response and fix! |
I wasn't receiving shared attribute updates at all using demo code (with server, device key and variable names changed).
When I turned on THINGSBOARD_ENABLE_DEBUG I saw weird lines in the log:
This is mqtt_event_handler from Espressif_MQTT_Client.h before:
The text was updated successfully, but these errors were encountered: