I’m sending binary data without any encoding from my board(cellular) to Tago using MQTT.
I think I’m seeing different bytes arriving at the Payload Parser from what I actually send.
For example, I send this array as a payload:
{ 0x6D,0x00, 0x74, 0x89, 0xC6, 0x5E, 0xCF, 0x02, 0x34, 0x0B, 0x4A, 0x16, 0x00, 0x00, 0x3B }
Live inspector shows me this:
The code I’m using is:
const ignore_vars = [];
payload = payload.filter(x => !ignore_vars.includes(x.variable));
// Payload is an environment variable. Is where what is being inserted to your device comes in.
// Payload always is an array of objects. [ { variable, value…}, {variable, value…} …]
const payload_raw = payload.find(x => x.variable === ‘payload_raw’ || x.variable === ‘payload’ || x.variable === ‘data’);
if (payload_raw) {
// Get a unique serie for the incoming data.
const { value, serie, time } = payload_raw;
// Parse the payload_raw to JSON format (it comes in a String format)
if (value) {
console.log(value);
const buf = Buffer.from(value,‘latin1’);
console.log(buf.toString(‘hex’));
//payload = payload.concat(parsePayload(value).map(x => ({ …x, serie, time: x.time || time })));
}
}
In this particular example, it seems that the bytes 0x89, 0xC6, 0xCF are substituted by 0xFD bytes. I’ve tried other encodings(even with no encoding) on the Buffer.from(), but the result is worst.
Am I missing something?
Thank you.