Encoding and decoding payload data

Scripts

One script is associated with a Manufacturer and Model for encoding and decoding the uplink/downlink messages respectively, in the transformation gateway script engine. These scripts are stored in the database.

Script is written in JavaScript (ECMAScript 2020 edition). The script has two functions, encode() and decode(). The script function encode(), returns a raw data specific to the device. While the function decode(), returns a decoded data in JSON format.

Any utility functions can be defined in a separate util.js file.

Note: Scripts contain two sections; the main codec script and a utility script. The utility script is optional. When an upload operation is to be performed, the main script must have a file name as, codec.js or encode.js. Whereas, the utility script must have a file name as, util.js or utility.js.
Adding scripts to IMPACT
Scripts can be added using either of the following ways:
  • Scripts can be added or updated directly from IMPACT Console or using REST APIs.
  • Scripts can be uploaded as a zip file in IMPACT Console or using REST APIs.
    Note: The main script and the utility script must be zipped together and uploaded but not as a folder.

Supported data formats

The following device data formats are supported in IMPACT.
  • Hexa decimal (HEX)
  • Binary (B64)
  • JSON
Note: The script can handle the mixed payload and parse the preceding data formats.

Subsequent sections provide more details on each of these data formats.