====== End-device configuration ======
The way to configure an end-device is unique to each kind of end-device. Therefore, this part of the wiki is generic. Refer to the datasheet of your end-device to configure it.
===== Configuration parameters =====
==== Pairing IDs ====
To use an end-device with Wanesy SPN, the end-device and the gateway need to be paired. To achieve this, two mechanisms are available: ABP or OTAA.
Each mechanism uses specific parameters. They need to be the same in both the end-device and the gateway.
=== If the end-device uses OTAA (Over The Air Activation) ===
* Device EUI (''dev_eui'')
* Application EUI (''app_eui'')
* Application key (''app_key'')
=== If the end-device uses ABP (Activation By Personalisation) ===
* Device Address (''dev_addr'')
* Network Session Key (''nwk_skey'')
* Application Session Key (''app_skey'')
==== Tx frequencies and response window frequency ====
End-devices send packets to the gateway using different frequencies. These frequencies must be configured and need to respect the regional parameters of the LoRaWAN specification.
To receive packets from the gateway, the end-devices open two receive windows after sending a packet. The first window uses the same frequency and radio settings as the one used to send the packet. The second window uses static parameters which need to be defined.
==== End-device's specific parameters ====
Most of the end-devices contain more than these parameters, however, they are specific to each type of end-device. Here are a few examples of parameters:
* Region of the end-device
* LoRa device class
* Tx power
* Datarate
* Receive and join accept delay
* etc.
These parameters can or cannot be mandatory. Refer to the constructor datasheet for proper tuning.
===== Join procedure =====
When using OTAA mechanism, to pair an end-device with the gateway, a **join request** needs to be initiated by the end-device. Depending on the used end-device, it can either be done automatically or manually. Check whether you need to trigger it yourself or not.
===== End-device parameters =====
Every end-device needs to be configured/registered. This configuration is done via the ''Fleet => End-device => Manage end-devices'' menu. End-devices can be added one by one manually in the end-device fleet or with a CSV file.
The configuration of an end-device cannot be edited. To change the configuration, this end-device needs to be deleted and re-created. This will **delete all received data** from this end-device.
It is also possible to download the current fleet to make a backup.
==== Class ====
Wanesy SPN handles two kinds of LoRa class functionality: class A and class C.
The main difference between classes A and C is that a class C device can receive data from the gateway at almost any time whereas the class A device can only receive data for a short duration after it emitted a packet. For more information about LoRa classes, refer to the [[https://www.lora-alliance.org/|LoRaWan specification]].
==== Activation parameters ====
To communicate, an end-device needs to be activated on the gateway. There are two types of activation: OTAA (Over-The-Air Activation) and ABP (Activation by Personalization).
=== If the end-device uses OTAA ===
For over-the-air activation, end-devices must follow a join procedure prior to participating in data exchanges with the network server. An end-device has to go through a new join procedure every time it has lost the session context information. The join procedure requires the end-device to be personalized with the following information before it starts the join procedure:
* A globally unique end-device identifier: ''DevEUI''.
* The application identifier: ''AppEUI''.
* An AES-128 key: ''AppKey''.
This information is used at each join procedure to derive unique session keys (''NwkSKey'', ''AppSKey''). These keys are then used to exchanged data between the end-device and the gateway.
{{.:..:add_otaa_end_device.png?600|Add OTAA end-device}}
=== If the end-device uses ABP ===
Activating an end-device by personalization means that the ''DevAddr'' and the two session keys (''NwkSKey'' and ''AppSKey'') are directly stored into the end-device instead of the DevEUI, AppEUI and the AppKey. The end-device is equipped with the required information for participating in a specific LoRa network when started.
{{.:..:add_abp_end_device.png?600|Add ABP end-device}}
==== LoRa RF parameters ====
When a packet is sent by an end-device, the end-device opens two reception windows. The first window uses the same channel as the one used to send the frame. The second window uses a predefined frequency. During these windows, a frame sends by the gateway can be received.
By default, Wanesy SPN automatically chooses which window is used. When the second window is used, by default, the packet is sent at the frequency ''869,525MHz'' with the datarate ''0'' for EU868 region.
If this configuration is not desired, it can be overridden using the ''Override default Rx parameters'' checkbox.
{{.:..:add_end_device_lora_rf_parameters.png?600|Change default LoRa RF end-device parameters}}
==== Import a fleet with a CSV file ====
=== File format ===
__Fleet_import_template:__
Depending on the version of the firmware, the template to use changes. Templates can be downloaded from the [[.:..:..:releases:2.1:templates|templates]] page.
__Input fields description:__
{{.:..:import_end_device_fleet.png?350|Import end-device fleet}}
* ''activation_type'': ''OTAA'' or ''ABP''
* ''class'': Class of the end-device, ''A'' or ''C''
* ''dev_eui'': Device EUI
* Only for OTAA end-devices. Leave empty if the activation type is ABP
* ''app_eui'': Application EUI
* Only for OTAA end-devices. Leave empty if the activation type is ABP
* ''app_key'': Application key (only for OTAA device)
* Only for OTAA end-devices. Leave empty if the activation type is ABP
* ''dev_addr'': Device address
* Only for ABP end-devices. Leave empty if the activation type is OTAA
* ''nwks_key'': Network Session Key
* Only for ABP end-devices. Leave empty if the activation type is OTAA
* ''apps_key'': Application Session Key
* Only for ABP end-devices. Leave empty if the activation type is OTAA
* ''rx_window'':
* Window 1: ''0''
* Window 2: ''1''
* Automatic window: ''255''
* ''rx_frequency'': Frequency value in Hz (example 869525000)
* ''rx_datarate'': Integer value of the datarate
=== Example ===
activation_type (IN),class (IN),dev_eui (IN),app_eui (IN),app_key (IN),dev_addr (IN),nwks_key (IN),apps_key (IN),rx_window (IN),rx_frequency (IN),rx_datarate (IN),status (OUT)
OTAA,A,0018B20000000BAA,0018B20041524632,0018B244415246320018B20000000BAA,,,,255,869525000,0,UNKNOWN
ABP,C,,,,00001233,98765432109876543210987654321098,98765432109876543210987654321098,1,869525000,3,UNKNOWN
==== Delete your end-devices ====
=== One by one ===
It is possible to delete end-devices one by one. Select your end-device in the list under the ''Fleet => End-devices => OTAA'' or ''Fleet => End-devices => ABP'' menu and click on the bin icon.
{{.:..:bin.png?30|delete}}
=== All the fleet ===
To remove all the fleet click on ''DELETE ALL END-DEVICES'' button in ''Fleet => End-devices => Manage end-devices => Delete end-devices'' menu. \\
{{.:..:delete_all_end_devices.png?400|Delete all end-devices}}
==== Edit end-device configuration ====
It is possible to edit end-device configuration from ''Fleet => End-devices => OTAA'' or ''Fleet => End-devices => ABP'' menu then pencil icon.{{.:..:pencil.png?30|edit}}
Editing an end-device does not remove the data it has received and sent.