You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
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.The text was updated successfully, but these errors were encountered: