How to decode payload?

I recently purchased an AWS qualified gateway, and I am now sending the device messages directly to my AWS IOT core account.

Unlike the TTN, I have not found a place to input a decoder function. ***Can someone help me out on how to decode the payload data in received messages? Or how to read the received payload data? ***

The mqtt message I am receiving looks like this:

{
"WirelessDeviceId": "xxxx",
"PayloadData": "EQE5JBkA",
"WirelessMetadata": {
"LoRaWAN": {
  "DataRate": "5",
  "DevEui": "xxxx",
  "FPort": 104,
  "Frequency": "867500000",
  "Gateways": [
    {
      "GatewayEui": "xxxx",
      "Rssi": -62,
      "Snr": 7.25
    }
  ],
  "Timestamp": "2021-03-03T13:31:59Z"
}
}
}

The decoder function I was using in TTN was

function Decoder (bytes,port) {

var params = {};

// Status measurement
params.darker = ((bytes[0] & 0x1) !== 0) ? true : false;
params.lighter = ((bytes[0] & 0x2) !== 0) ? true : false;
params.keep_alive = ((bytes[0] & 0x20) !== 0) ? true : false;
   
// Lux
params.lux = ((bytes[5] << 16) | (bytes[4] << 8) | bytes[3])/100;



// Board temp measurement
temp_board = bytes[2] & 0x7f;
temp_board = temp_board - 32;



// Battery measurements
batt = bytes[1] & 0x0f;
batt = (25 + batt) / 10;
params.temp_board = temp_board;
params.batt = batt;

return params;
}

Side question: does anyone know how to decode the payload coming through in AWS?

Thanks in advance to anyone who can help :slight_smile:

And you are asking this on the TTN forum because??

BTW, please take a moment to format your message for readability.

Hey @kersing

thanks for your comment, and I have updated both my question and formatting. I am asking in this forum because the underlying question is how to read the received payload as I am unable to wrap my head around it. The decoder function I was using was given to me by the vendor who sold the sensor to me so I don’t really know what/how it is decoding.

Thanks in advance

So you are asking us rather than the vendor of the sensor for a decoder to run on a platform that is nothing to do with TTN?

The hint from Jac was we are the forum for TTN only.

To give you a hint, payload_data in the mqtt message is base64 encoded, once decoded it will be the data array fed to the decoder. The port can be found in the mqtt message as well.
As we’re about TTN, not AWS I don’t have a clue whether you can enter a decoder function anywhere or just do it yourself once you get the mqtt message.

Thanks. I will run with this hint :slight_smile: