Skip to content

GW-AN09 connect TTN by basicstation

1. Overview

TTN supports basicstation-lns and basicstation-cups protocols, and this article describes how to connect TTN through these two protocols. The following is a link to TTN's instructions on basicstation for reference:

LoRa Basics™ Station

2.basicstation-lns protocol connection TTN

the following is TTN's explanation link about LNS for reference:

LoRaWAN Network Server (LNS)

2.1 Add Gateway

2.2 Create APIkey

APIkey requires enabling permissions:

  • Link as Gateway to a Gateway Server for traffic exchange, I .e. write uplink and read downlink

copy the created APIkey and format the APIkey according to TTN's instructions to generate a key.

Format: Add "Authorization: Bear" before APIkey"

for example, APIkey is:

plain
#APIkey
NNSXS.VMNPB62XJRNKSRST6FXBKYWA4IJWH5EJP6ZIQTA.FMYP5EVTIEAIGMGL4TERH2JPAFIIECZ6223H3HCABIN77YH662HQ
#格式化后
Authorization: Bearer NNSXS.VMNPB62XJRNKSRST6FXBKYWA4IJWH5EJP6ZIQTA.FMYP5EVTIEAIGMGL4TERH2JPAFIIECZ6223H3HCABIN77YH662HQ

can be formatted via command line

plain
LNS_KEY="your-lns-api-key"
echo "Authorization: Bearer $LNS_KEY" | perl -p -e 's/\r\n|\n|\r/\r\n/g'  > lns.key
plain
set LNS_KEY=your-lns-api-key
echo Authorization: Bearer %LNS_KEY% > lns.key

the following figure shows how to use command line formatting in linux environment in practice:

2.3 to obtain CA certificate

tttn provides a CA certificate approved by TTN. Please refer to the following link for the acquisition method:

Root Certificates

according to the link provided by TTN, this practice downloadedLet's Encrypt ISRG Root X1 Trust. Download Link:

CA证书下载链接

2.4 Gateway Configuration

log in to the webConfigure interface of the Gateway, open Gateway configuration->LoRaWANserver, and set nsProtocol to basicstation-lns.

2.4.1 Fill in the server address

the server address format is "wss:// <server-address>: 8887, for example, wss:// au1.cloud.thethings.net work:8887, enter the server address in the uri field.

2.4.2 Fill in the CA certificate

fill in the trust field with the CA certificate downloaded from the 2.3

2.4.3 Fill in key

fill in the key field with the formatted APIkey in the 2.2 and click submit to save the settings.

Note: The cert field is not required.

3.basicstation-cups protocol connection TTN

the following link is TTN's configuration description of the CUPS protocol for reference:

Configuration and Update Server (CUPS)

3.1 Create APIkey

the CUPS server automatically retrieves the LNS credential and sends it to the gateway. Therefore, to use the CUPS protocol, you need to create two apikeys. One is the CUPS APIkey and the other is the LNS APIkey.

3.1.1 Create CUPS_APIkey

CUPS_APIkey requires the enable permission:

  • View gateway information
  • Edit basic gateway settings
  • Retrieve secrets associated with a gateway

after creation, copy the created APIkey and format it in the same way as section 2.2 of this article.

3.1.2 Create LNS_APIkey

LNS_APIkey requires the enable permission:

  • Link as Gateway to a Gateway Server for traffic exchange, I .e. write uplink and read downlink

copy the created APIkey.

Paste the copied LNS_APIkey into the General Settings->LoRa Basics Station LNS Authentication Key as shown

save the settings.

3.2 to obtain CA certificate

same as Section 2.3 of this article

3.3 Gateway Configuration

log in to the webConfigure interface of the Gateway, open Gateway configuration->LoRaWANserver, and set nsProtocol to basicstation-cups.

3.3.1 Fill in the server address

the server address format is "https:// <server-address>: 443 ", for example" https://au1.cloud.thethings.network:443 ", enter the server address into the uri field.

3.3.2 Fill in the CA certificate

fill in the trust field with the CA certificate downloaded in section 2.3 of this article

3.3.3 Fill in key

fill in the key field with the formatted CUPS_APIkey in section 3.1 of this article, and click submit to save the settings.

Note: The cert field is not required.