Skip to content

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

Open
@Kazhuu

Description

@Kazhuu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions