HTTP integration fails, wrong raw data

See also Advantage of Base64 encoding in MQTT?

Just a minor note: if one is really only using the Decoder to get a hexadecimal text representation of the binary payload, then note that even that will take a bit of time. That’s probably not a problem, unless, e.g., one schedules a downlink using the HTTP Integration, where timing is really tight. See My application's downlink is always queued for next uplink (though not using a Decoder may not fix that).

I’d convert the Base64 representation in my application instead, if only to keep all code in one place.

And another aside:

In the Decoder, the values in the bytes array will never exceed 0xFF. So, byte.toString(16) would suffice. And in case one wants to avoid the loop and mutable variables, Array.reduce is your friend:

function Decoder(bytes, port) {
  return {
    hex_payload: bytes.reduce(function(acc, byte) {
      return acc + ('0' + byte.toString(16)).slice(-2);
    }, '')
  };
}

Enjoy. :wink: