HTTP connection

This connector allows data to be transferred from/to Everynet Network Server to specific HTTP server hosted by the user.

In order to enable HTTP adapter you should create new Connection at Everynet Management API or Network Server Interface, select 'HTTP / HTTP Adapter' and use the following arguments:

Argument Required Description
description no Description of connection
filter yes Network Server Filter ID
url yes URL of your server, more description below
authorization no Authorization header value, more description below
URL

Example:

https://login:password@example.com:1234/messages/{type}/{device}

Fields substitution only applied for parts, after the port field (path, params, query, hash)

If the field is not present, it will be left as is, eg /messages/{type}/{device}

List of fields that could be substituted:

device The device EUI (dev_eui by LoraWAN specification)
device_addr The device address (dev_addr by LoraWAN specification)
application The application EUI (app_eui by LoraWAN specification)
gateway The gateway mac address
network The network of gateways identifier
type The type of message (uplink / join / error / e.t.c.)
Authorization

You can specify an Authorization header value.

This field is mandatory if you are going to send requests TO the Network Server.

This value is used for both sides of request.

  • The connector will send requests to your application with that header.
  • The connector expects this header to be same value, if you send request.

Example:

If you specify the field like

"authorization": "Token 123"

The requests will contain the header, and expect the same from your application, if it makes requests

Headers:
...
Authorization: Token 123
...
Send messages to the Network Server

You can send JSON message in two ways

  • As a response of the request to your application from the connector. (No special authorization required)
  • Initiating a request to the connector (Required an Authorization header to be set)
Requests from the application

The url for the requests

https://adapters.ns.< your_region >.everynet.io/http2/cb/< your_connection_id >

You can send the requests to the Network Server with HTTP requests to that URL.

All rules applied to this request are similar to the response of your application, but you MUST specify the Authrorization header (please refer to it's section).

You can specify an Authorization header value.

Connection checking

In order to check if your server is available or not, the connector will make a check.

Periodically it will send the OPTIONS request to your application, which you must reply with some proper HTTP response.

Example:

OPTIONS /lora/%7Bdevice%7D/%7Btype%7D HTTP/1.1
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: */*
Host: example.com
Content-Length: 0



HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Allow: POST, OPTIONS
Content-Length: 0
Date: Mon, 16 Jul 2018 10:38:10 GMT

Working cycle

If the connection is established, the connector starts to send you messages from the Network Server.

You may reply with a JSON message in response, every other format is silently discarded.

If the application responded with 4xx-5xx codes, it will shut down the connection until valid connection check is done.

Example of usage

What this example is about:

  • You have HTTP server with the following URL: http://example.com
  • You will receive uplink messages to the server endpoint http://example.com/uplink and downlink_request messages to http://yourserver.com/downlink_request.

What you should do:

  1. Create a filter in the NS for the data you want to receive. Select uplink and downlink_response types.
  2. Create HTTP connection with the following URL: http://example.com/{type} and Filter ID of the filter you have just created.
  3. After that, server will send you connection-check request to your application
OPTIONS /example HTTP/1.1
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: everynet-http
Host: example.com
Authorization: b24023b99492fc94
Content-Length: 0



HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Allow: POST, OPTIONS
Content-Length: 0
Date: Fri, 20 Jul 2018 06:53:53 GMT

If your application responded to that, the connector starts to send messages to your application.

Example of uplink message:

POST /uplink HTTP/1.1
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: everynet-http
Host: example.com 
Content-Length: 543
Content-Type: application/json

{"params": {"payload": "MzQ3NjcwNjFiNDc3NGU2ZmFiZjBhNmY4YTJjYmI0Y2M=", "port": 7, "duplicate": false, "counter_up": 3, "rx_time": 1532073817.157281, "encrypted_payload": "pLgR8Tzh3JptkhtozJ5OlFuS3zQCygWD5hmx9zMjLnU="}, "meta": {"network": "e23d2f31af81b25ef50375b5b7810c52", "packet_hash": "73465c1ed0cae413816d0f78baf3dcc2", "application": "1293e9e373666fd5", "device_addr": "d242b7a6", "time": 1532073817.175208, "device": "b2b48f713c2f973d", "packet_id": "f577207419bb4701ff9f7874c2e2808e", "gateway": "92a199d4e41ab64b"}, "type": "uplink"}

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Date: Fri, 20 Jul 2018 08:03:37 GMT

Example of downlink_request message and downlink_response message reply back

POST /downlink_request HTTP/1.1
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: everynet-http
Host: example.com
Content-Length: 412
Content-Type: application/json

{"params": {"counter_down": 3, "max_size": 51, "tx_time": 1532075747.295559}, "meta": {"network": "12b5d8a8df8d9255c65d6d565d836a9d", "packet_hash": "cf59f7bf410a9eb23383f41342c3c7fe", "application": "6264dd6a1b4e9ca1", "device_addr": "f22eef89", "time": 1532075746.335046, "device": "c20ba71a9affafc6", "packet_id": "a8b464039cca609bed00f8ec58f494fe", "gateway": "524d07d7ef40dea3"}, "type": "downlink_request"}


HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 476
Date: Fri, 20 Jul 2018 08:35:46 GMT

{
  "meta": {
    "application": "6264dd6a1b4e9ca1", 
    "device": "c20ba71a9affafc6", 
    "device_addr": "f22eef89", 
    "gateway": "524d07d7ef40dea3", 
    "network": "12b5d8a8df8d9255c65d6d565d836a9d", 
    "packet_hash": "cf59f7bf410a9eb23383f41342c3c7fe", 
    "packet_id": "a8b464039cca609bed00f8ec58f494fe", 
    "time": 1532075746.335046
  }, 
  "params": {
    "counter_down": 3, 
    "payload": "220de733f4", 
    "port": 50
  }, 
  "type": "downlink_response"
}

Class C downlink_claim

You can also send this type of message as a response to your application.

1-3. Repeat the same steps for Simple flow example

  1. If you want to send downlink_claim message, you have to set the authorization parameter in the connection. It will be used to check requests from your application to the connector for security verification.

For example

  • Authorization = Token 1234567890 (The same as an authorization field in the connection you have set)
  • Connection ID = 5b51a9a8e15b770005c928c9
POST /http2/cb/5b51a9a8e15b770005c928c9 HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Authorization: Token 1234567890
Connection: keep-alive
Content-Length: 142
Content-Type: application/json
Host: adapters.ns.eu.everynet.io
User-Agent: HTTPie/1.0.0-dev

{
    "meta": {
        "device": "d2953b67bca671a6", 
        "network": "12024f9efc46a98120a6fac272a9c3a4"
    }, 
    "type": "downlink_claim"
}

HTTP/1.1 202 Accepted
Connection: keep-alive
Content-Length: 0
Content-Type: text/html; charset=utf-8
Date: Fri, 20 Jul 2018 09:47:30 GMT

results matching ""

    No results matching ""