Qubitro Documentation
SupportLog inSign Up
  • Documentation
  • Guides
  • Developers
  • Welcome
  • Data Sources
    • No-Code Integrations
      • Onomondo
      • Notehub
      • The Things Stack
      • Soracom
      • Loriot
      • 1NCE
      • Golioth
      • AWS IoT Core LoRaWAN
      • Actility ThingPark
      • Chirpstack
      • Particle
    • MQTT
    • HTTP
  • Platform
    • Project
      • Settings
      • Access Management
      • Roles & Permissions
    • Device
      • Settings
    • Storage
      • Time Series Storage
    • Functions
      • Decoder Function
        • LoRaWAN Device Template Decoder
        • LoRaWAN Custom Decoder
        • Hex Payload Decoder
      • Transformation Function
      • Rule Function
        • Send Email
        • Webhooks
        • Slack
        • Twilio
        • Mailgun
        • SendGrid
      • Storage Function
        • AWS Redshift
        • Google BigQuery
        • MQTT Publish
        • MongoDB Time Series
      • Scheduled Function
        • HTTP
      • Function Settings
      • Function Templates
        • Settings
    • Monitoring
      • Dashboards
        • Setup & Configuration
        • Widgets
          • Chart
          • State Timeline
          • Gauge
          • Stat
          • Headline
          • Aggregated Chart
          • Map
          • Battery
          • Image
          • Image Map
          • Table
          • Storage Table
          • Iframe
          • Blob Storage
        • Settings
        • Access Management
        • Roles & Permission
      • Blueprints
        • Setup & Configuration
        • Settings
    • Credentials
      • API Keys
      • External Credentials
        • Slack
        • Mailgun
        • SendGrid
        • Twilio
        • AWS Redshift
        • MQTT
        • MongoDB
        • The Things Stack
      • Webhook Signing Key
  • Add-Ons
    • Storage Views
    • Aggregated View
    • Archived Views
    • Blob Storage
    • Managed Email
    • Audit Log
    • MCP Server
  • Organizations
    • Overview
    • General
    • Groups
    • Members & Roles
      • Read Only
      • Read/Write
      • Admin
    • Custom Roles
    • Add-Ons
    • Billing
    • Invoices
    • White-Label
  • Account Management
    • Personal Accounts
Powered by GitBook
On this page
  • Overview
  • How It Works
  • Tips
  • Required Input Format
  • Function Schema
  • Example
  • Creating a Custom Decoder Function
Export as PDF
  1. Platform
  2. Functions
  3. Decoder Function

Hex Payload Decoder

The Hex Payload Decoder allows you to convert incoming hex string payloads into valid JSON data

PreviousLoRaWAN Custom DecoderNextTransformation Function

Last updated 3 months ago

Overview

The Hex Payload Decoder allows you to convert incoming hex string payloads into valid JSON data for non-LoRaWAN data sources.

The Hex Payload Decoder is only applicable for non-LoRaWAN data sources, such as , , or . LoRaWAN devices use or for decoding.

How It Works

If a is enabled, data will be processed before storage. The decoder applies first, and then any defined transformation function modifies the data before it is stored in Qubitro.

Tips

  • Avoid unnecessary logic or external dependencies that could slow down execution.

  • Use arithmetic operations and bit shifts to convert hex values into readable fields.

  • Keep payload formatters simple and lightweight.

Need help reviewing your custom formatter? Our team can assist in checking your code for compatibility. Reach out via the .

Required Input Format

Data must be published as JSON with the following structure:

{ "payload_hex": "hex_value" }

The key must be "payload_hex" in the incoming JSON payload. Any other key name will not be recognized by the system.

Function Schema

A decoder function processes incoming hex payloads and returns a structured JSON object.

Function Parameters

The decoder function receives a single parameter: input, which contains:

  • bytes → A byte array representing the raw payload received.

function decoder(input) {
  // Your decoding logic here
}

Return Values

To ensure compatibility with Qubitro’s no-code suite, the output should be a key-value JSON object.

Example

1

Incoming payload

{ "payload_hex": "7B2274656D7065726174757265223A32352C2268756D6964697479223A36302C227072657373757265223A313031332C2262617474657279223A39307D" }
2

Formatter code

function decoder(input) {
    
    // Extract values from the input bytes array

    // First byte represents temperature
    let temperature = input.bytes[0];  

    // Second byte represents humidity
    let humidity = input.bytes[1];     

    // Third & Fourth bytes represent pressure (16-bit value)
    let pressure = (input.bytes[2] << 8) | input.bytes[3]; 

    // Fifth byte represents battery level
    let battery = input.bytes[4];      

    // Return an object containing the decoded values
    return { temperature, humidity, pressure, battery };
}
3

Decoded payload

{
  "temperature": 123,
  "humidity": 34,
  "pressure": 29797,
  "battery": 109
}

Creating a Custom Decoder Function

1

Select the Function Type

  1. Open the device details page in the Qubitro Portal.

  2. Click the Functions tab.

  3. Click Create Function and select Decoder Function.

  4. Choose Hex Payload Decoder as the formatter type.

2

Write the Decoder Code

  1. Enter your custom decoder function in the editor.

  2. Adjust the function to match your device’s payload format.

3

Save and Apply the Function

  1. Click Save to apply the decoder function.

Once saved, Qubitro will automatically apply the decoder to all incoming data for the assigned device.

MQTT
HTTP
Onomondo
Device Templates
Custom Decoder
Transformation Function
Support Page