COAP response changing HEX buffer

Hi All, I'm tying to respond to a COAP request with a buffer of:

[64,219,228,137,163,6]
String: 4090e589a306

The COAP response is coming out as:

[64,239,191,189,229,137,163,6]
String: 40efbfbde589a306

I've tried different encoding formats and using the buffer maker but can't seem to figure out why it's changing.

Some more info:
If I set the response payload to 12345678
the request response comes out as 3132333435363738
or buffer

[49,50,51,52,53,54,55,56]

2023-05-15_12-51-31

I ended up finding an issue in node-red-contrib-coap where the content format is being set to one of three options and none of them allow just an unchanged payload to pass through.
My quick and dirty fix was to set text/plain to msg.payload

if (_checkContentFormat(contentFormat, "text/plain")) {
            return msg.payload.toString();
        } else if (_checkContentFormat(contentFormat, "json")) {
            return JSON.stringify(msg.payload);
        } else if (_checkContentFormat(contentFormat, "cbor")) {
            return cbor.encode(msg.payload);
        } else {
            return msg.payload.toString();
        }
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.