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