LogoLogo
Website
  • Overview
  • Getting started
  • Integrations
    • MQTT Integration
    • HTTPS Integration
    • LORIOT Integration
    • Swisscom LPN Integration
    • TheThingsNetwork Integration
    • TheThingsIndustries Integration
    • Sigfox Integration
    • AWS IoT Integration
    • AWS Kinesis Integration
    • Azure Event Hub Integration
    • Azure IoT Hub Integration
    • Helium Network Integration
  • Key concept
    • Entities and relations
    • Entity Groups
    • Attributes
    • Device Profiles
    • Telemetry data
    • Device alarms
    • Version control
  • Dashboards
    • Dashboards
      • Dashboard Templates
      • IAQ Template
      • Aliases
    • Widget library
      • Energy management widgets
        • Summarized annual consumption
        • Daily profile
        • XY chart
  • Rule Engine
    • Rule Engine
      • Rule Engine Templates
        • General data proccessing concept
        • Weather data feed
      • Test Javascript function
      • Predefined Message Types
      • Filter rule nodes
        • check alarm status
        • check existence fields
        • check relation
        • gps geofencing filter
        • message type filter
        • message type switch
        • originator type filter
        • originator type switch
        • script filter
        • switch script node
      • Enrichment rule nodes
        • calculate delta
        • customer attributes
        • customer details
        • originator attributes
        • originator fields
        • originator telemetry
        • related attributes
        • related Device attributes
        • tenant attributes
        • tenant details
      • Transformation rule nodes
        • change originator
        • duplicate to group
        • duplicate to related
        • script transformation
        • to email transformation
        • M-Bus decoder
      • Action rule nodes
        • Add to group
        • Remove from group
        • Generate report
        • Integration Downlink
        • REST Call Reply
        • Change owner
        • Create alarm
        • Clear alarm
        • Delay messages
        • Generator
        • Log
        • RPC Call Reply
        • RPC Call Request
        • GPS geofencing events
        • Save attributes
        • Math Function
        • Asset Profiles Feature
        • fetch device credentials
        • delete attributes
        • split array msg
        • json path
        • delete keys
        • rename keys
        • copy keys
        • Save to Custom
        • Assign To Customer
        • Unassign From Customer
        • Create Relation
        • Delete Relation
        • Push to cloud
        • Pus to edge
        • Save timeseries
      • Analytics rule nodes
        • Aggregate Latest
        • Aggregate Stream
        • Alarms Count
      • Output connectors
        • AWS SNS
        • AWS SQS
        • MQTT
        • RabbitMQ
        • Kafka
        • Azure IoT Hub
        • Rest API
        • Priva
          • Realtime Telemetry API
          • Realtime Setpoint API
          • Data Insight Metadata API
          • Data Insight History API
          • Alarm Data Api
        • SOAP API
        • send email
        • send SMS
        • send Twilio SMS
      • Flow
        • Acknowledge
        • Checkpoint
        • Rule Chain
        • Output
  • Device Type Library
    • telemetry data keys
    • attribute data keys
      • Assets
        • Property
          • Building
          • Floor
          • Room
        • Facility
          • Component
        • City Zone
      • Devices
    • relation Type keys
  • API documentation
    • Admin Controller
  • CLI Tool
    • How to install the tool
    • Dataimport
  • Dynamic QR Codes
    • Dynamic QR Code App
Powered by GitBook
On this page
  • Overview
  • Create Uplink Converter
  • Create integration
  • Send uplink message
  • Downlink Converter

Was this helpful?

  1. Integrations

Helium Network Integration

PreviousAzure IoT Hub IntegrationNextEntities and relations

Last updated 2 years ago

Was this helpful?

Overview

Helium Integration allows converting existing protocols and payload formats to Tesenso IoT Cloud message format and is useful in several deployment scenarios:

  • stream device and/or asset data from external system, IoT platform or connectivity provider back-end.

  • stream device and/or asset data from your custom application running in the cloud.

  • connect the existing device with custom Helium based protocol to Tesenso IoT Cloud.

Create Uplink Converter

Before creating the integration, you need to create an Uplink converter in Data converters. Uplink is necessary in order to convert the incoming data from the device into the required format for displaying them in Tesenso IoT Cloud. Click on the “plus” and on “Create new converter”. To view the events, enable Debug. In the function decoder field, specify a script to parse and transform data.

Example for the Uplink converter:

// V0.1, 23.06.2021, DS

/** Decoder **/

// decode payload to string and json and parse it to data
var payloadJson = decodeToJson(payload);
var dataJson = decodeDataKLAX(payloadJson);

var deviceName = payloadJson.dev_eui; 

// Result object with device/asset attributes/telemetry data
var result = {
    // Use deviceName and deviceType or assetName and assetType, but not both.
    deviceName: deviceName,
    //deviceType: deviceType,
    // assetName: assetName,
    // assetType: assetType,
    //   customerName: customerName,
    //   groupName: groupName,
    attributes: dataJson.attributes,
    telemetry: dataJson.telemetry
};


function decodeDataKLAX(payloadJson) {
    // TODO: Make this work for all LPN
    if (payloadJson.type == 'uplink') {
        var decoded = {
            'telemetry':{},
            'attributes':{}
        }
        decoded.telemetry.ts = payloadJson.ts;
        //decoded.telemetry.rssi = payloadJson.rssi;
        //decoded.telemetry.snr = payloadJson.snr;
        //decoded.telemetry.toa = payloadJson.toa;
        //decoded.telemetry.frequency = payloadJson.freq;
        //decoded.telemetry.dr = payloadJson.dr;
        decoded.telemetry.data = base64ToHex(payloadJson.payload);
        decoded.telemetry.port = payloadJson.port;
        decoded.telemetry.bat = payloadJson.bat;
        return decoded;
    } else {
        return {};
    }
}

function decodeToString(payload) {
    return String.fromCharCode.apply(String, payload);
}

function decodeToJson(payload) {
    // covert payload to string.
    var str = decodeToString(payload);
    // parse string to JSON
    var data = JSON.parse(str);
    return data;
}
function base64ToHex(str) {
  var raw = atob(str);
  var result = '';
  for (var i = 0; i < raw.length; i++) {
    var hex = raw.charCodeAt(i).toString(16);
    result += (hex.length === 2 ? hex : '0' + hex);
  }
  return result.toUpperCase();
}


function decodeToString(payload) {
   return String.fromCharCode.apply(String, payload);
}

function decodeToJson(payload) {
   // covert payload to string.
   var str = decodeToString(payload);

   // parse string to JSON
   var data = JSON.parse(str);
   return data;
}

return result;

// console.log(result);
return result;

Base64 string to hex string converter

function base64ToHex(str) {
  var raw = atob(str);
  var result = '';
  for (var i = 0; i < raw.length; i++) {
    var hex = raw.charCodeAt(i).toString(16);
    result += (hex.length === 2 ? hex : '0' + hex);
  }
  return result.toUpperCase();
}

You can change the decoder function while creating the converter or after creating it. If the converter has already been created, then click on the “pencil” icon to edit it. Copy the configuration example for the converter (or your own configuration) and insert it into the decoder function. Save changes by clicking on the “checkmark” icon

NOTE While Debug mode is very useful for development and troubleshooting, leaving it enabled in production mode can significantly increase the disk space used by the database since all the debug data is stored there. It is highly recommended turning the Debug mode off after debugging is complete.

Create integration

Now that the Uplink converter has been created, it is possible to create an integration

Enable security option

If necessary, you can specify additional parameters, without which the data will not be included in the integration. To do this, check the Enable security checkbox and click on the Headers filter. Specify an arbitrary value and save the changes

Once the Headers filter has been configured, it will also need to be specified in the uplink message as follows.

-H "test-header:secret

Send uplink message

To send an uplink message, you need a Helium endpoint URL from the integration. Let`s go to the Integrations tab in Tesenso IoT Cloud. Find your Helium integration and click on it. There you can find the Helium endpoint URL. Click on the icon to copy the url

Use this command to send the message. Replace $DEVICEname, $DEVICEtype and $YOUR_HTTPS_ENDPOINT_URL with corresponding values.

curl -v -X POST -d "{\"deviceName\":\"$DEVICEname\",\"deviceType\":\"$DEVICEtype\",\"temperature\":33,\"model\":\"test\"}" $YOUR_HTTP_ENDPOINT_URL -H "Content-Type:application/json"

Use this command to send the message. Replace $DEVICEname, $DEVICEtype, $YOUR_HTTPS_ENDPOINT_URL and $VALUE with corresponding values.

curl -v -X POST -d "{\"deviceName\":\"$DEVICEname\",\"deviceType\":\"$DEVICEtype\",\"temperature\":33,\"model\":\"test\"}" $YOUR_HTTPS_ENDPOINT_URL -H "Content-Type:application/json" -H "$VALUE"

The created device with data can be seen in the section Device groups -> All

Received data can be viewed in the Uplink converter. In the “In” and “Out” blocks of the Events tab

Use the Dashboards to work with data. Dashboards are a modern format for collecting and visualizing data sets. Visibility of data presentation is achieved through a variety of widgets.

Downlink Converter

Create Downlink in Data converters. To see events enable Debug

Add a converter to the integration. You can customize a downlink according to your configuration. Let’s consider an example where we send an attribute update message. So we should change code in the downlink encoder function under line //downlink data input:

data: JSON.stringify(msg)

where msg is the message that we receive and send back to the device

An example of downlink converter:

// Encode downlink data from incoming Rule Engine message

// msg - JSON message payload downlink message json
// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.
// metadata - list of key-value pairs with additional data about the message
// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter

var result = {

    // downlink data content type: JSON, TEXT or BINARY (base64 format)
    contentType: "JSON",

    // downlink data
    data: JSON.stringify(msg),

    // Optional metadata object presented in key/value format
    metadata: {
    }
};

return result;

How to work with dashboards read .

here
Page cover image