Need Help?
TTNv3 uplink via https POST integration
This help article serves as a comprehensive guide to connect The Things Network (TTN) v3 platform with the AlphaX Cloud platform using the HTTPS POST protocol. By establishing this integration, you will be able to seamlessly upload data from TTNv3 to AlphaX Cloud, enabling efficient data management, analysis, and visualization. Follow the step-by-step instructions provided in this article to establish a secure and reliable connection between TTNv3 and AlphaX Cloud, ensuring a smooth flow of data for your IoT applications.
About the The things Network (TTN)
The Things Network provides a set of open tools and a global, open network to build your next IoT application at low cost, featuring maximum security and ready to scale.
The Things Stack is the LoRaWAN Network Server used by the Things network and is the critical component for their LoRaWAN solution. It is Used by thousands of companies and developers around the world, to securely manage applications, end devices and gateways and is built by The Things Industries.
Assumptions
- Devices are connected and communicating via the TTN network*
- You have access to an application and integrations in the TTN Console*
- You are using TTNv3
- You have enabled https integrations within AlphaX Cloud and generated a conduit token
For assistance with the The Things Network please use the community support to help troubleshoot.
For help generating an AlphaX Conduit token see this help article.
Getting Started
For this help guide we will be using an Application called “Dingtek DC500 People Counter”. Yours may be named differently.
- Log-in to your TTN Console using your username and password. Please see The Things Network community for help loging in.
- When you have gained access to the platform, navigate to the paplication you would like to integrate with AlphaX. you will be redirected to a page that looks similar to the one below.
- Click on the Integrations Tab on the left menu bar and it will open for you.
- Navigate to the “Webhooks” section to start creating your integration.
Creating a Webhook
- When you arrive at the “Webhooks” page you will be given the option to “Add Webhook”. Click this button to get to the next screen.
- Click Add Webhook Button. this will navigate to a second screen
- Click the Custom Webhook option. You may have many options on your screen so be sure to select the right one.
- A form will be displayed for you to complete as shown below. Complete the form with the following information.
– Enter an ID for your integration. This ID required
– Select the JSON webhook format.
– Enter the Base URL. This must be “https://conduit.alphax.cloud/post/ttnv3” for the integration to work correctly.
– Click the + Add header entry button and add an entry for token and enter your security token from AlphaX. - Go to the Enabled event types section and click Uplink message. In the selection box enter /uplink
- Leave the rest of the fields with the default content. i.e. Blank in most cases.
To get your AlphaX token please refer to this help article: How to Activate Conduit
Configuring Data
The next step is to configure your data to be in the correct format. The integration will take care of the rest of the formatting automatically however, your data must be aligned to the correct channelId to be successfully imported into AlphaX.
NOTE: The unique identifier for registration into AlphaX is the Device EUI
There are two mandatory fields that are required for the integration into AlphaX to work:
- channelId: integer Formated
- value: Number Formatted (16 character maximum length)
Note: As seen above your sensor will require a different parser depending on make and model. Please refer to the manufacturer for information regarding packet format.
To create an uplink payload formatter:
- Navigate to the payload formatter on the left hand side menu bar.
- Click payload formatters and click on the Uplink option. On the next screen you will be given an option to select the type of uplink payload formatter you want.
- Select Custom Javascript Format as the formatter type.
- Enter your code into the formatter code section.
Several example formatters have been provided below, or feel free to search our knowledge base for more.
Example Parser: Variable Length Payload for AlphaX X1 Series.
function decodeUplink(input) { dynamic = []; dynamic.push({ channelId: 255, value: (input.bytes[0] | input.bytes[1] << 8)/100 }); dynamic.push({ channelId: 252, value: (input.bytes[6] | input.bytes[7] << 8)/100 }); if(input.bytes.length-8 > 1){ var i; for (i=0; i < (input.bytes.length-8)/4; i++){ ch = Number(i+1); var val; val = (input.bytes[8+(i*4)] | input.bytes[9+(i*4)] << 8 | input.bytes[10+(i*4)] << 16 | input.bytes[11+(i*4)] << 24)/1000; dynamic.push({channelId:ch, value:val}); } } return { data: dynamic, warnings: [], errors: [] } }
Example Parser: Fixed Length Payload for Dingtek DC500
function decodeUplink(input) { if (input.bytes[3]==2){ return { data: [ { channelId: 1, value: (input.bytes[6] | input.bytes[5] << 8)}, { channelId: 255, value: (input.bytes[10] | input.bytes[9] << 8)/100 }, ], warnings: [], errors: [] } } }