Skip to content

Parser API Description

This page lists the parser entry points that ship with the currently supported device bundles. Every function follows the LoRaWAN® Payload Codec API Specification TS013-1.0.0 where possible and returns an object with data, optional warnings, and optional errors.

Supported Devices and Versions

Parser generationVersionDevices
Modern modular4.x.xPEW, NETRIS1, TRW
Transitional TypeScript3.x.xNETRIS2
Legacy JavaScript2.x.xA2G, F98W6, GD20W, PGW23, NETRIS3 family (FLRU, PEU, PGU, TGU, TRU)

Version 4.x.x

The parser is built on the codec abstraction layer and can host multiple codecs at once. Each codec ships with sensible default measuring ranges, but you should always tune them for the concrete probe you deploy.

  • decodeUplink(input: { bytes: number[], fPort: number, recvTime?: string }):
    Validates bytes, fPort, and optional recvTime before selecting the matching codec and decoding measurements or status messages. Returns a typed data payload for the chosen codec or an errors array when decoding fails.
  • decodeHexUplink(input: { bytes: string; fPort: number; recvTime?: string }):
    Accepts hexadecimal payloads, converts them to integer arrays, and delegates to decodeUplink. Useful when integrations provide the payload as hex rather than raw byte arrays.
  • encodeDownlink(input: { codec: string; input: unknown }):
    Looks up the requested codec and runs its encoder. On success it returns the downlink frame as an array of 8-bit integers. If the codec is missing or encoding is unsupported an exception is thrown.
  • adjustMeasuringRange(channelName: string, range: { start: number; end: number }):
    Updates the measuring range for the named channel across every registered codec, enabling runtime calibration without rebuilding the bundle. Use this right after instantiating the parser to align the default ranges with your sensor’s data sheet. If the channel is unknown, an error is thrown.
  • adjustRoundingDecimals(decimals: number):
    Normalizes the requested precision, then applies it to all codecs so numeric outputs round consistently.

Version 3.x.x

Only the NETRIS2 device uses this format. The parser is written in TypeScript and ships as a function that returns the helpers below.

  • decodeUplink(input: { bytes: number[], fPort: number, recvTime?: string }):
    Performs schema validation on the uplink structure, inspects the message type byte, and decodes measurements, process alarms, technical alarms, configuration status, identification, or keep-alive frames.
  • decodeHexUplink(input: { bytes: string; fPort: number; recvTime?: string }):
    Ensures the bytes field is a valid hexadecimal string, converts it to an integer array, and forwards the request to decodeUplink.
  • encodeDownlink(input: DownlinkInput): number[]:
    Accepts one of the typed NETRIS2 actions (factory reset, battery reset, channel disable, main configuration update, process alarm configuration, measurement offset, or start-up time). Returns the downlink frame as an array of 8-bit integers on success or throws an exception when validation fails. Input varies based on the device.
  • adjustRoundingDecimals(decimals: number):
    Overrides the default rounding precision used when presenting channel values.

Version 2.x.x

The parser is delivered as a single JavaScript file that manipulates global measurement ranges. Before the decoding helpers can be used you must edit the top-level variables (for example FORCE_RANGE_START, FORCE_RANGE_END, DEVICE_TEMPERATURE_RANGE_START, DEVICE_TEMPERATURE_RANGE_END) so they reflect the sensor-specific measuring span published in the device documentation.

  • decodeUplink(input: { bytes: number[]; fPort: number; recvTime?: Date }):
    Decodes strain, device temperature, and battery voltage readings when the measurement ranges are defined. Populates the data object with the scaled values or records parsing errors in errors.
  • decodeHexString(fPort: number, hexEncodedString: string):
    Converts a hex string to bytes and then runs decodeUplink.
  • decodeBase64String(fPort: number, base64EncodedString: string):
    Converts a Base64 string to bytes before delegating to decodeUplink.

All APIs above emit their results as plain JavaScript objects that can be consumed directly by gateways, network servers, or custom applications.