Skip to content
Manuel Bleichenbacher edited this page Jul 28, 2018 · 5 revisions

With the member function TheThingsNetwork::startProvisioningTask(), a provisioning background task can be started that handles AT commands entered via one of the UARTs. The AT commands are used to provision the device EUI, application EUI and application key.

By using the provisioning task, the same software can be flashed to multiple device and each device can then be provisioned with unique EUIs and keys. Furthermore, the sensitive key is less likely to leak via the source code repository.

Commands

If the provisioning background process is running, it will echo all input on the selected UART. Line editing is not supported.

Successfully executed commands will output OK on a separate line. Invalid commands (command does not exist or invalid parameters were provided) will output ERROR on a separate line.

AT

Returns OK to indicate that the background process is listeting for AT commands

AT
OK

AT+PROV?

Displays the device EUI and application EUI that are currently being used. The format is DDDDDDDDDDDDDD-AAAAAAAAAAAAAAAA-00000000000000000000000000000000 where DD...DD is the device EUI and AA...AA is the application EUI – both in 16 characters long in hexadecimal format. The 00...00 at the end is a placeholder for the appication key. It cannot be queried.

AT+PROV?
0123456789ABCDEF-0123456789ABCDEF-00000000000000000000000000000000
OK

AT+PROV=<keys>

Set the device EUI, application EUI and application key and stores them in non-volatile storage. The format is DDDDDDDDDDDDDD-AAAAAAAAAAAAAAAA-KKKKKKKKKKKKKKKKKKKKKKKK where DD...DD is the device EUI, AA...AA is the application EUI and KK...KK is the application key. The EUIs are 16 characters of hexadecimal data, the application keys i32 characters of hexadecimal data.

The data is provided in MSB (most signification bit first) format, i.e. in the format it can be copied from the TTN console by clicking on the Copy icon.

AT+PROV=0123456789ABCDEF-0123456789ABCDEF-00000000000000000000000000000000
OK

AT+PROVQ

Quits the background process.

AT+PROVQ
OK

UART Configuration

The provisioning task listens and answers on a UART. It can be configured via make menuconfig. Usually, one of the UARTs is made available via the USB connector and used for sending the log output. It is possible to use the same UART for the provisioning task without adversely affecting the log output.

Basic configuration

With the UART for provisioning option, the basic configuration can be selected:

  • Default: UART0 with the GPIO1 and GPIO3 pins (for TX and RX) is used. This UART is usually also used for log output and for the USB connector.
  • Custom: Custom settings can configured. To that end, additional configuration options will appear.
  • None: The provisioning task is disabled.

UART peripheral

Select the UART:

  • UART0
  • UART1

Configure UART settings

  • No: The baud rate, the RX and the TX pins will not be configured. This is the preferred option if the UART is shared with other features (e.g. the log output). They will be responsible for configuring the UART.
  • Yes: The baud rate, the RX and the TX pins can be configured with configuration options that will additionally appear.

UART TX on GPIO#

Configure the GPIO number for the UART TX signal.

UART RX on GPIO#

Configure the GPIO number for the UART RX signal.

UART baud rate

Configure the UART baud rate

Clone this wiki locally