TTN Provisioning - hardwario/lora-modem GitHub Wiki
Although The Things Network (TTN) supports LoRaWAN 1.1, the implementation in TTN network server v.3.18.2 is not compatible with the firmware. For the time being, you may need to configure your device as LoRaWAN 1.0.4.
When adding our device through TTN Console, select "LoRaWAN Specification 1.0.4" as your LoRaWAN version and "RP002 Regional Parameters 1.0.1" as your Regional Parameters version. Set both AppKey and NwkKey to the key configured using the AT command AT+APPKEY
.
You can also use ttn-lw-cli
to provision your device from the command line.
Generate a new random AppKey:
APP_KEY=$(openssl enc -aes-128-cbc -k secret -P -md sha1 2>/dev/null | grep ^key= | cut -d = -f 2)
Then provision your device for over the air activation (OTAA) as follows:
ttn-lw-cli end-devices create <your-app-id> <your-device-name> \
--lorawan-version MAC_V1_0_4 \
--join-eui 0101010101010101 \
--dev-eui <DevEUI> \
--root-keys.app-key.key $APP_KEY \
--root-keys.nwk-key.key $APP_KEY \
--frequency-plan-id US_902_928_FSB_2 \
--lorawan-phy-version RP002_V1_0_1
In the device's AT command interface run:
AT+MODE=1
AT+APPKEY=$APP_KEY
AT+JOIN
Generate new random DevAddr, NwkSKey, and AppSKey:
DEV_ADDR=$(openssl enc -aes-128-cbc -k secret -P -md sha1 2>/dev/null | grep ^key= | cut -d = -f 2 | head -c 8)
NWK_S_KEY=$(openssl enc -aes-128-cbc -k secret -P -md sha1 2>/dev/null | grep ^key= | cut -d = -f 2)
APP_S_KEY=$(openssl enc -aes-128-cbc -k secret -P -md sha1 2>/dev/null | grep ^key= | cut -d = -f 2)
Then provision the device for ABP as follows:
ttn-lw-cli end-devices create <your-app-id> <your-device-name> \
--abp \
--lorawan-version MAC_V1_0_4 \
--session.dev_addr $DEV_ADDR \
--session.keys.app-s-key.key $APP_S_KEY \
--session.keys.f_nwk_s_int_key.key $NWK_S_KEY \
--dev-eui <DevEUI> \
--frequency-plan-id US_902_928_FSB_2 \
--lorawan-phy-version RP002_V1_0_1
# Optionally disable ADR in ABP mode
#ttn-lw-cli end-devices set <your-app-id> <your-device-name> --mac-settings.use-adr=false
In the device's AT command interface run:
AT+MODE=0
AT+DEVADDR=$DEV_ADDR
AT+NWKSKEY=$NWK_S_KEY
AT+APPSKEY=$APP_S_KEY