Skip to content

mqttPublishBinaryMsg() function is not able to send binary data containing null characters #55

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

Open
Kazhuu opened this issue Jan 29, 2025 · 1 comment

Comments

@Kazhuu
Copy link

Kazhuu commented Jan 29, 2025

When sending MQTT binary messages with function mqttPublishBinaryMsg, which is taking the binary message buffer to be sent and it's size. There is a problem however with this function. When function internally calls sendCommand with the binary message, it does not pass the length of the buffer and the sendCommand function assumes it to be a null terminated string. This seems to be because it will call hwPrint, which in turn also uses print() function of the serial, which for the binary data should be write() instead with the buffer and it's size given to it.

With this problem I'm not able to send raw binary data over MQTT that has 0x00 values in it. When fixing the code and using the Serial.write(buf, length) instead. I'm able to send raw MQTT binary message.

@Kazhuu Kazhuu changed the title mqttPublishBinaryMsg function is not able to send null characters mqttPublishBinaryMsg() function is not able to send binary data containing null characters Jan 29, 2025
@PaulZC
Copy link
Collaborator

PaulZC commented Jan 29, 2025

Hi Mauri (@Kazhuu ),

Thank you for reporting this. We will update the code as soon as we can.

Best wishes,
Paul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants