@radiobridge/packet-decoder
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

RadioBridge Decoder

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.

Installation

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

Usage

You can use the decoder package using NPM or use the minified JS version to decode the data in browsers.

Node.js

const decoder = require('@radiobridge/packet-decoder')

console.log(decoder.decodePayload('1901030126000000000000'))

JavaScript - Browser compatible

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>

Additional Helper functions

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==');

Output Format

decodePayload function accepts a Hexadecimal payload and returns the decoded values as an JSON Object.

Example Output

// 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
  }
}

Sensor Decode Examples

Please refer to the GitHub README to view the sensors output in detail.

Package Sidebar

Install

npm i @radiobridge/packet-decoder

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

9.52 MB

Total Files

85

Last publish

Collaborators

  • radiobridge