User Tools

Site Tools


wiki:interfaces:rhttp

Remote HTTP

Introduction

A HTTP client is running on the gateway. It can be used to forward end-devices Rx data to HTTP server in real-time (Rx data are forwarded as soon as they are received).

Its configuration is available in Configuration ⇒ Interfaces ⇒ Remote HTTP menu.

Remote HTTP

It is possible to configure:

  • Host: IP address or hostname
  • Port: port
  • Path: destination directory

rx_data suffix is no more added automatically in URL since SPN version 2.1. You must add it in path if used in your HTTP server configuration.

All data transmitted between client and server are encoded in JSON format.

If transmission fails, frames not sent are stored to be sent later on. The 10000 most recent frames are saved in RAM, the other ones are discarded. Frames are deleted from the RAM once successfully transmitted.

The examples featured in this guide use the program ncat to simulate an HTTP server.
For testing purposes, you could also use mockable.io.

Receive data

The gateway will send a POST requests when it receives frames from an end-device. The body of this request will contain the data of the received frames as a JSON string.

The HTTP headers indicate:

  • The Content-Type is set to application/json, meaning that the body of the HTTP POST contains a JSON string.
  • The Accept is also set to application/json, meaning that the server can reply with a JSON string.

The HTTP body contains an rx_data JSON object.

Rx packets structure

Here is the structure of an RX packet sent over HTTP:

  • rx_data_id: integer. RX data unique identifier
  • end_device_id: string. The Device EUI or DevAddr depending on the activation procedure
  • received_time: integer. Unix timestamp
  • sequence_number: integer. Sequence number sent by the end-device
  • port: integer. LoRaWAN port to be used
  • radio_id: integer. Radio identifier (range [0;1])
  • channel: integer. Channel identifier (range [0;9])
  • rssi_dbm: integer. RSSI in dBm
  • snr_db: float. LoRa SNR ratio in dB
  • frequency_hz: integer. TX central frequency in Hz
  • modulation_type: string. Modulation type, either LoRa or FSK
  • data_rate: string. Data rate.
    → if the modulation is LoRa, datr is SFxBWy where x represents the spreading. factor (range 7-12 inclusive), and y is the bandwidth in kHz
    → if the modulation is FSK, datr is the FSK bit rate in bps
  • coding_rate: string. ECC coding rate. Example: 4/5
  • adr: boolean. Adaptative Data rate enable
  • payload: string. Base64-encoded payload data

Example

Here is an example of one RX packet sent by the Wanesy SPN gateway.ncat, awk and jq are used to illustrate this example:

ncat -lp 12345 | awk '/^\r$/ { body=NR } body && NR > body { print $0 }' | jq -r .
  • Launches ncat to listen on the TCP port 12345.
  • The awk script discards the HTTP headers and prints the HTTP body.
  • jq will prettyprint the JSON string on the console.

Output:

$ ncat -lp 8000 | awk '/^\r$/ { body=NR } body && NR > body { print $0 }' | jq -r .
{
  "rx_data": {
    "rxdata_id": 77,
    "end_device_id": "0018B20000000BAA",
    "received_time": 1510669226,
    "sequence_number": 1,
    "port": 1,
    "radio_id": 0,
    "channel": 1,
    "rssi_dbm": -45,
    "snr_db": 9.2,
    "frequency_hz": 868300000,
    "modulation_type": "LORA",
    "data_rate": "SF12BW125",
    "coding_rate": "4/5",
    "adr": 1,
    "payload": "nhxICQcQABNRUSYAAA53"
  }
}

Help

Inline help is available in web user interface in Configuration ⇒ Interfaces ⇒ Remote HTTP ⇒ Help

An extract of this help is available below:

Click to display ⇲

Click to hide ⇱

Click to hide ⇱

Common parameters

This service is used to push Rx data to a HTTP server via REST API.

The common URI is:

http(s)://path.to.host:port/path
  • path.to.host: host name or IP address.
  • port: server port.
  • path: path, starts with /.

Flow syntax

Rx data flow

Rx data are pushed to:

http(s)://path.to.host:port/path
wiki/interfaces/rhttp.txt · Last modified: 2020/04/10 17:32 by mgr