arduino-mqtt icon indicating copy to clipboard operation
arduino-mqtt copied to clipboard

Document binary payloads

Open sheffieldnikki opened this issue 3 years ago • 1 comments

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);

sheffieldnikki avatar Oct 19 '21 18:10 sheffieldnikki

Look at MQTTClient.cpp:146

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

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

windoze avatar Nov 27 '21 07:11 windoze

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

256dpi avatar Feb 04 '23 10:02 256dpi

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.

sheffieldnikki avatar Feb 04 '23 12:02 sheffieldnikki

You're correct. Reopening.

256dpi avatar Feb 04 '23 13:02 256dpi

I updated the Readme accordingly.

256dpi avatar Feb 05 '23 14:02 256dpi