-
Notifications
You must be signed in to change notification settings - Fork 63
AT Commands
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.
See the provision example for a code example.
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.
Returns OK
to indicate that the background process is listeting for AT commands
AT
OK
Displays the device's hardware EUI. The hardware EUI is a EUI that is generated from the device's MAC address by inserting FF FE
into the middle of the MAC address. So the hardware EUI for a device with the MAC address A0:B1:C2:01:02:03
would be A0 B1 C2 FF FE 01 02 03
.
The hardware EUI can be used as the device EUI (see TheThingsNetwork::provisionWithMAC
and the AT command AT+PROVQ=
.
The hardware EUI is displayed as hexadecimal data with the byte ordering the TTN console calls MSB. So it can simply be copied into the Device EUI entry field when registering or modifying a TTN device.
AT+HWEUI?
D8A01DFFFE27E23B
OK
Displays the device's ethernet MAC address (of the Wifi module).
AT+MAC?
D8:A0:1D:27:E2:3B
OK
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 application key. It cannot be queried.
AT+PROV?
0123456789ABCDEF-0123456789ABCDEF-00000000000000000000000000000000
OK
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 is 32 characters of hexadecimal data.
The data is provided in the same byte ordering the TTN console uses by default and calls MSB. So it can simply be copied by clicking on the Copy icon.
AT+PROV=0123456789ABCDEF-0123456789ABCDEF-0123456789ABCDEF0123456789ABCDEF
OK
Setting the EUIs and keys to all zeroes will reset the device to an unprovisioned state:
AT+PROV=0000000000000000-0000000000000000-00000000000000000000000000000000
OK
Set the device EUI, application EUI and application key and stores them in non-volatile storage. The format is AAAAAAAAAAAAAAAA-KKKKKKKKKKKKKKKKKKKKKKKK
where AA...AA
is the application EUI and KK...KK
is the application key. The EUI is 16 characters of hexadecimal data, the application keys is 32 characters of hexadecimal data. The device EUI is generated from the device's MAC address (by inserted FF FE into the middle of the MAC address, e.g. the MAC address A0:B1:C2:01:02:03
becomes the device EUI A0 B1 C2 FF FE 01 02 03
).
The data is provided in the same byte ordering the TTN console uses by default and calls MSB. So it can simply be copied by clicking on the Copy icon.
AT+PROVM=0123456789ABCDEF-0123456789ABCDEF0123456789ABCDEF
OK
Quits the background process.
AT+PROVQ
OK
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.
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.
Select the UART:
- UART0
- UART1
- 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.
Configure the GPIO number for the UART TX signal.
Configure the GPIO number for the UART RX signal.
Configure the UART baud rate