Hey,
I was wondering what is exactly the added advantage of encoding data through Base64 on the MQTT connection?
When the node sends binary data (rather than plain text), which is certainly best practice, then one needs to make sure that the binary data is encoded in a way that does not break the JSON text message format. Base64 only uses printable characters, so ensures the JSON is fine, even if the payload contains bytes that are not printable, or would have a special meaning if interpreted as ASCII.
One could use hexadecimal codes, but then one would only use the characters 0-9, A-F and would need 2 characters to encode each byte. Base64 uses many more characters in the encoding, so needs fewer characters for each byte.
By the way: note the lovely TTN payload functions if you want a readable self-documenting MQTT message.
1 Like