256dpi / arduino-mqtt

MQTT library for Arduino
MIT License
1.01k stars 232 forks source link

Document binary payloads #268

Closed sheffieldnikki closed 1 year ago

sheffieldnikki commented 2 years ago

I think this library allows for binary payloads, but it isn't clear from the documentation.

How about updating the README.md and the function prototypes to make it more obvious that fixed-length binary as well as null-terminated char strings are supported? eg,

Publishes a message to the broker with an optional payload, which can be a string or binary:

...
bool publish(const char topic[], const uint8_t payload[], int length);
bool publish(const char topic[], const uint8_t payload[], int length, bool retained, int qos);
windoze commented 2 years ago

Look at MQTTClient.cpp:146

    str_payload = String((const char *)message.payload);

It doesn't look like that the library supports receiving binary.

256dpi commented 1 year ago

The library supports registering an advanced callback using onMessageAdvanced that will receive the full buffers. Check the readme to find more information.

sheffieldnikki commented 1 year ago

The library supports registering an advanced callback using onMessageAdvanced that will receive the full buffers. Check the readme to find more information.

That doesn't address this issue, which is the documentation needs improving to mention fixed-length binary payloads, and how to use them in the library, onMessageAdvanced doesn't currently mention binary payloads, or why you'd want to use it.

256dpi commented 1 year ago

You're correct. Reopening.

256dpi commented 1 year ago

I updated the Readme accordingly.