# Payload Parser problem

**URL:** https://community.tago.io/t/payload-parser-problem/644
**Category:** Devices and Connectors
**Created:** [January 22, 2022, 4:59am UTC](https://community.tago.io/t/payload-parser-problem/644 "2022-01-22T04:59:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex034/user_avatar/community.tago.io/system/32/24_2.png) [@system](https://community.tago.io/u/system)
#### Post date: [January 22, 2022, 4:59am UTC](https://community.tago.io/t/payload-parser-problem/644/1 "2022-01-22T04:59:16Z")

</div>

@Bruno Almeida

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.

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex034/user_avatar/community.tago.io/system/32/24_2.png) [@system](https://community.tago.io/u/system)
#### Post date: [January 22, 2022, 4:59am UTC](https://community.tago.io/t/payload-parser-problem/644/2 "2022-01-22T04:59:17Z")

</div>

@Felipe Lima

hi @bruno, every request is transform to json object, so binary type is not a primary type of json (it’s a type on node.js), the server is setted to utf-8 encoded, you can tried convert from utf-8 string to buffer, or change your payload to hex in string, to be easily to convert it.

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex034/user_avatar/community.tago.io/system/32/24_2.png) [@system](https://community.tago.io/u/system)
#### Post date: [January 22, 2022, 4:59am UTC](https://community.tago.io/t/payload-parser-problem/644/3 "2022-01-22T04:59:17Z")

</div>

@Bruno Almeida

Hi Felipe,

Thank you for your answer.

When you say to convert from UTF-8 to Buffer, you mean `const buf = Buffer.from(value,'utf8');` ? If yes, I’ve already did this, but the converted buffer comes with a lot of ‘wrong’ bytes.

No chance on converting the data to a human-readable format. The same devices can be configured for send the data through satellite(Iridium) as well, so every bit counts.

Last year I worked with Tago and a device that send data in pretty much the same binary format, and everything worked well. The only difference is that this application didn’t use MQTT, but some type of custom connector (I think) made by Vitor (don’t know if he still works at Tago).

I think sending binary data in constrained devices is vital, are you sure that Tago only expects human-readable packets?

thank you!

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex034/user_avatar/community.tago.io/system/32/24_2.png) [@system](https://community.tago.io/u/system)
#### Post date: [January 22, 2022, 4:59am UTC](https://community.tago.io/t/payload-parser-problem/644/4 "2022-01-22T04:59:18Z")

</div>

@Felipe Lima

hi @bruno I will take a look on our end, and come back to you soon. thanks.

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex034/user_avatar/community.tago.io/system/32/24_2.png) [@system](https://community.tago.io/u/system)
#### Post date: [January 22, 2022, 4:59am UTC](https://community.tago.io/t/payload-parser-problem/644/5 "2022-01-22T04:59:19Z")

</div>

@Bruno Almeida

Hi Felipe!

If you need something or some specific test, please let me know.

Thank you!

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex034/user_avatar/community.tago.io/system/32/24_2.png) [@system](https://community.tago.io/u/system)
#### Post date: [January 22, 2022, 4:59am UTC](https://community.tago.io/t/payload-parser-problem/644/6 "2022-01-22T04:59:20Z")

</div>

@Felipe Lima

Hi @bruno,

We deploy a new version of MQTT Connector with payload option, now you can choose to use payload with HEX format, you should create a new device, and select HEX in payload type. if you publish a message back to your device, it should be in hex format on string type (the same way you received). We’re still working on documentation, but you can start using it right now.

 ![image](https://canada1.discourse-cdn.com/flex034/uploads/tagoio1/original/1X/2fde72ab1cfb92f8a567efc075651231e61fe7cf.png)

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex034/user_avatar/community.tago.io/system/32/24_2.png) [@system](https://community.tago.io/u/system)
#### Post date: [January 22, 2022, 4:59am UTC](https://community.tago.io/t/payload-parser-problem/644/7 "2022-01-22T04:59:20Z")

</div>

@Bruno Almeida

Hi Felipe,

Working perfectly now, thank you very much for the effort!

BTW, the interface is way more faster than when I worked with Tago last year, congratulations!

Best Regards,

---

<div class="post-metadata">

### Author: ![bill.bianeck](https://avatars.discourse-cdn.com/v4/letter/b/2bfe46/32.png) [@bill.bianeck](https://community.tago.io/u/bill.bianeck)
#### Post date: [April 7, 2022, 4:57pm UTC](https://community.tago.io/t/payload-parser-problem/644/8 "2022-04-07T16:57:01Z")

</div>

That’s the idea, to improve our product significantly more each year, we are glad you liked @Felipe Lima solution about this.

Feel free to navigate and engage with our topics within the community!
