This library helps de-coding the Radio Bridge sensor payload as a JSON Object, that can be used in various applications to display the proper sensor states.
This library can be installed using any compatible package manager.
npm install @radiobridge/packet-decoder --save
# For Yarn, use the command below.
yarn add @radiobridge/packet-decoder
You can use the decoder package using NPM or use the minified JS version to decode the data in browsers.
const decoder = require('@radiobridge/packet-decoder')
console.log(decoder.decodePayload('1901030126000000000000'))
Download the JS file from here
<script type="text/javascript" src="radiobridge-decoder.min.js"></script>
<script type="text/javascript">
console.log(radiobridgeDecoder.decodePayload('1901030126000000000000'))
</script>
Following functions are also available to decode the raw payloads received through different LNS networks, You can pass the raw data to the appropriate function to decode the payload.
let result = decodeTtnPayload('GAYDAQ==');
let result = decodeChirpstackPayload('FwYDAA==');
let result = decodeAwsIotPayload('FwYDAA==');
let result = decodeKerlinkPayload('FwYDAA==');
decodePayload function accepts a Hexadecimal payload and returns the decoded values as an JSON Object.
// Input: 1901030126000000000000
// Output:
{
"protocol": "1",
"counter": 25,
"type": "SUPERVISOR",
"SUPERVISOR": {
"BatteryLow": true,
"ErrorWithLastDownlink": true,
"TamperState": false,
"TamperSinceLastReset": false,
"threshold": "X-axis over threshold",
"battery": "2.6V",
"accumulationCount": 0
}
}
Please refer to the GitHub README to view the sensors output in detail.