Gateway API

Gateways are associated with collections and can be accessed via the /span/collections/${collectionId}/gateways resource.

Note that the built-in gateways in Span (the cellular IoT and internet gateways) will always be visible in the gateway resource but they won’t be possible to edit or remove.

A very simple gateway configuration might look like this:

 {
      "gatewayId": "17dh0cf43jfgna",
      "name": "The LoRa Gateway",
      "type": "Lora",
      "config": {
        "cust": {
          "params": {
            "appEui": "f0-ab-19-29-b7-a7-df-77"
          }
        }
      },
      "status": "Offline"
    }

The configuration for the gateway is stored in the cust object. This is a simple string-of-strings map with configuration values. These configuration values are passed on to your gateway service when the gateway is updated.

Your custom gateway will require a client certificate. The recommended way to create a certificate is to use a certificate signing request. You can let Span create the certificate but your private key will briefly be available (in-memory) inside the Span service and will be transmitted across the Internet.

The Span CLI CSR command shows how to create a certificate signing request.

Device configuration and metadata

The configuration block on the device in Span doubles as both a configuration block and a metadata block. The gateway may provide updated configuration settings for devices when a message is transmitted (like RSSI, SNR and frequencies):

{
    "deviceId": "17dh0cf43jfgnk",
    "collectionId": "17dh0cf43jfh0g",
    "tags": {
        "name": "My First LoRa Device"
    },
    "config": {
        "gateway": {
            "17dh0cf43jfgna": {
                "gatewayId": "17dh0cf43jfgna",
                "params": {
                    "appEui": "f0-ab-19-29-b7-a7-df-77",
                    "appKey": "f03fa9b9bc70f4ed567f99fd58534dab",
                    "appSKey": "2076dc6adc5af051c455b4ae3a9bfcbb",
                    "devAddr": "d18237",
                    "devEui": "11-22-33-44-aa-bb-cc-dd",
                    "fCntDn": "0",
                    "fCntUp": "0",
                    "nwkSKey": "9af1ca00ba716ea7f97cf0ff3570141a",
                    "relaxedCounter": "true",
                    "state": "otaa"
                }
            }
        }
    },
}