Software
The Waspmote device communicates with the LoRaWAN module via UART. So different commands are sent from the microcontroller unit to the module so as to perform different tasks.

Waspmote libraries

Waspmote LoRaWAN files

The files related to the LoRaWAN libraries for these modules are:
  • WaspLoRaWAN.h
  • WaspLoRaWAN.cpp
It is mandatory to include the LoRaWAN library when using these modules. So the following line must be added at the beginning of the code:
#include <WaspLoRaWAN.h>

Class constructor

To start using the Waspmote LoRaWAN library, an object from the WaspLoRaWAN class must be created. This object, called LoRaWAN, is already created by default inside Waspmote LoRaWAN library. It will be usedthrough this guide to show how Waspmote works.
When using the class constructor, all variables are initialized to a default value.

API constants

The API constants used in functions are:
Constant
Description
LORAWAN_ANSWER_OK
Successful response to a function
LORAWAN_ANSWER_ERROR
Erratic response to a function
LORAWAN_NO_ANSWER
No response to a function
LORAWAN_INIT_ERROR
Required keys to join to a network were not initialized
LORAWAN_LENGTH_ERROR
Data to be sent length limit exceeded
LORAWAN_SENDING_ERROR
Server did not response
LORAWAN_NOT_JOINED
Module has not joined a network
LORAWAN_INPUT_ERROR
Invalid input parameter
LORAWAN_VERSION_ERROR
The module does not support this function
RN2483_MODULE
LoRaWAN module plugged is LoRaWAN EU
RN2903_MODULE
LoRaWAN module plugged is LoRaWAN US
RN2903_IN_MODULE
LoRaWAN module plugged is LoRaWAN IN
RN2903_AS_MODULE
LoRaWAN module plugged is LoRaWAN ASIA-PAC / LATAM
ABZ_MODULE
LoRaWAN module plugged is LoRaWAN JP / KR
BAND_JP923
LoRaWAN module is using the AS923 band
BAND_KR920
LoRaWAN module is using the KR920-923 band

API variables

The variables used inside functions and Waspmote codes are:
Variable
Description
_buffer
The buffer of memory used for storing the responses from the module
_length
The useful length of the buffer
_def_delay
The time to wait after sending every command until listen for a response
_baudrate
The baudrate to be used when the module is switched on
_uart
The selected UART (regarding the socket used: SOCKET0 or SOCKET1)
_adr
The adaptive data rate state (on or off)
_ar
The automatic reply state (on or off)
_eui
The buffer used for storing the preprogrammed globally unique identifier from the module's hardware
_devEUI
The buffer used for storing the globally unique identifier for the module (software programmable)
_appEUI
The buffer used for storing the application identifier for the module
_nwkSKey
The buffer used for storing the network session key for the module
_appSKey
The buffer used for storing the application session key for the module
_appKey
The buffer used for storing the application key for the module
_devAddr
The buffer used for storing network device address for module
_band
The buffer used for storing the frequency band
_margin
The demodulation margin received in the last Link Check Answer frame
_gwNumber
The number of gateways successfully received the last Link Check Answer frame
_freq
The buffer used for storing the operating frequency for every channel
_radioFreq
The transceiver operating frequency
_radioFreqDev
The transceiver frequency deviation
_preambleLength
The preamble length for transceiver
_dCycle
The buffer used for storing the operating duty cycle for every channel
_drrMin
The minimum operating data rate range for every channel
_drrMax
The maximum operating data rate range for every channel
_dCyclePS
The duty cycle prescaler (which can only be configured by the server)
_crcStatus
The CRC status to determine if it is to be included during operation
_powerIndex
The output power to be used on LoRaWAN transmissions
_dataRate
The data rate to be used on LoRaWAN transmissions
_retries
The number of retransmissions for an uplink
_upCounter
The value of the uplink frame counter
_downCounter
The value of the downlink frame counter
_radioPower
The output power level used by the transceiver
_radioSF
The spreading factor to be used by the transceiver
_radioRxBW
The receiving bandwidth used by the transceiver
_radioCR
The coding rate used by the transceiver
_radioWDT
The time to be used by the transceiver watchdog timer
_radioBW
The value used for the transceiver bandwidth
_radioSNR
The SNR value for the last received packet by the transceiver
_radioMode
The buffer to save the operative radio mode
_radioBitRate
The operative radio bit rate
_supplyPower
The voltage level read by the module
_rx2DataRate
The second receiving window data rate
_rx2Frequency
The second receiving window frequency
_rx1Delay
The first receiving window delay
_macStatus
The MAC status register from the module
_status
The status of every LoRaWAN channel
_data
The buffer of memory used for storing data received from the back-end
_port
The port where data was received
_dataReceived
The flag used to inform if any data was received
_version
The version of the module plugged into Waspmote
_bandABZ
Band used for the LoRaWAN JP / KR type module

API functions

Through this guide there are lots of examples of using functions. In these examples, API functions are called to execute the commands, storing in their related variables the parameter value in each case. The functions are called using the predefined object LoRaWAN.
All public functions return one of these possible values:
  • LORAWAN_ANSWER_OK = 0
  • LORAWAN_ANSWER_ERROR = 1
  • LORAWAN_NO_ANSWER = 2
  • LORAWAN_INIT_ERROR = 3
  • LORAWAN_LENGTH_ERROR = 4
  • LORAWAN_SENDING_ERROR = 5
  • LORAWAN_NOT_JOINED = 6
  • LORAWAN_INPUT_ERROR = 7
  • LORAWAN_VERSION_ERROR = 8

Module system management features

Switch on

The ON() function allows to switch on the LoRaWAN module, it opens the MCU UART for communicating with the module and it automatically enters into command mode.
In addition, when the module has been powered and communication is opened, this function checks whethera module is plugged to the socket and which type of module has been plugged. This check is done within every function that reboots the module such as “ON”, “reset” or “factoryReset”.
After this step the module will be able to receive commands to configure it or send packets. It is necessary toindicate the socket that it is being used: SOCKET0 or SOCKET1.
Example of use for SOCKET0:
1
{
2
LoRaWAN.ON(SOCKET0);
3
}
Copied!
Related variable:
LoRaWAN._version → Stores the module's version
Figure: LoRaWAN module in SOCKET0

Switch off

The OFF() function allows the user to switch off the LoRaWAN module and close the UART. This function must be called in order to keep battery level when the module is not going to be managed. It is necessary to indicate the socket that it is being used: SOCKET0 or SOCKET1.
Example of use for SOCKET0:
1
{
2
LoRaWAN.OFF(SOCKET0);
3
}
Copied!

Module software reset

The reset() function allows the user to reset and restart the LoRaWAN module. The stored internal configurations will be loaded automatically upon reboot.
Example of use:
1
{
2
LoRaWAN.reset();
3
}
Copied!
Related variable:
LoRaWAN._version → Stores the module's version

Module factory reset

The factoryReset() function allows the user to reset the module's configuration data and user EEPROM to factory default values and restart the module.
Example of use:
1
{
2
LoRaWAN.factoryReset();
3
}
Copied!
Related variable:
LoRaWAN._version → Stores the module's version

Preprogrammed unique identifier (EUI)

The getEUI() function allows the user to query the preprogrammed EUI node address from the module. The preprogrammed EUI node address is a read-only value and cannot be changed or erased. It is a global unique 64-bit identifier.
Example of use:
1
{
2
LoRaWAN.getEUI();
3
}
Copied!
Related variable:
LoRaWAN._eui → Stores the module's EUI

LoRaWAN parameters

Device EUI

The setDeviceEUI() function allows the user to set the 64-bit hexadecimal number representing the device EUI. There are two function prototypes which are explained below:
  • No input device EUI is specified, then the preprogrammed EUI is used as the device EUI.
  • A user-provided device EUI is specified as input.
The getDeviceEUI() function allows the user to query the device EUI which was previously set by the user. The attribute _devEUI permits to access to the settings of the module. The default value is 0000000000000000.
Depending on the network to join, it is needed to configure a random device EUI or a fixed device EUI provided by the back-end. This matter relies on the registering process for new devices in each back-end. For further information please go to “LoRaWAN back-ends” chapter.
Example for preprogrammed EUI:
1
{
2
LoRaWAN.setDeviceEUI();
3
LoRaWAN.getDeviceEUI();
4
}
Copied!
Example for user-provided device EUI:
1
{
2
LoRaWAN.setDeviceEUI(0102030405060708);
3
LoRaWAN.getDeviceEUI();
4
}
Copied!
Related variable:
LoRaWAN._devEUI → Stores the previously set device EUI

Device address

The setDeviceAddr() function allows the user to set the 32-bit hexadecimal number representing the device address. This address must be unique to the current network. There are two function prototypes which are explained below:
  • No input device address is specified, then the last 4 bytes of the preprogrammed EUI are set as device address.
  • A user-provided device address is specified as input.
The getDeviceAddr() function allows the user to query the device address which was previously set by the user. The attribute _devAddr permits to access to the settings of the module. The range goes from 00000000 to FFFFFFFF. The default value is 00000000.
Depending on the network to join, it is possible configure a random device address or a fixed device address.This matter depends on the back-end and the registering process for new devices. For further information please go to “LoRaWAN back-ends” chapter.
Example for using the preprogrammed EUI:
1
{
2
LoRaWAN.setDeviceAddr();
3
LoRaWAN.getDeviceAddr();
4
}
Copied!
Example for user-provided device address:
1
{
2
LoRaWAN.setDeviceAddr(01020304);
3
LoRaWAN.getDeviceAddr();
4
}
Copied!
Related variable:
LoRaWAN._devAddr → Stores the previously set device address

Application Session Key

The setAppSessionKey() function allows the user to set the 128-bit hexadecimal number representing the application session key.
All payloads are encrypted using an AES algorithm with a 128-bit secret key, the Application Session Key. Each end-device has its own unique Application Session Key only known by the end-device and the application server.
Figure: Use of application session key
The attribute _appSKeystores the application session key previously set by the user. The range goes from 00000000000000000000000000000000 to FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.
Example of use:
1
{
2
LoRaWAN.setAppSessionKey(00102030405060708090A0B0C0D0E0F”);
3
}
Copied!
Related variable:
LoRaWAN._appSKey → Stores the previously set application session key

Network session key

The setNwkSessionKey() function allows the user to set the 128-bit hexadecimal number representing the network session key.
All frames contain a 32-bit cryptographic Message Integrity Check (MIC) signature computed using the AES algorithm with a 128-bit secret key, the Network Session Key. Each end-device has its own Network Session Key only known by the end-device and the network server.
Figure: Use of network session key
The attribute _nwkSKey stores the network session key previously set by the user. The range goes from 00000000000000000000000000000000 to FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.
Example of use:
1
{
2
LoRaWAN.setNwkSessionKey(00102030405060708090A0B0C0D0E0F”);
3
}
Copied!
Related variable:
LoRaWAN._nwkSKey → Stores the previously set network session key

Application EUI

The setAppEUI() function allows the user to set the 64-bit hexadecimal number representing the application identifier. This parameters is a global application identifier that uniquely identifies the application provider (i.e., owner) of the module.
Example of use:
1
{
2
LoRaWAN.setAppEUI(1112131415161718);
3
}
Copied!
Related variable:
LoRaWAN._appEUI → Stores the previously set application EUI

Application key

The setAppKey() function allows the user to set the 128-bit hexadecimal number representing the application key. Whenever an end-device joins a network via OTAA, the Application Key is used to derive thesession keys, Network Session Key and Application Session Key, which are specific for that end-device to encrypt and verify network communication and application data.
The attribute _appKeystores the application session key previously set by the user. The range goes from 00000000000000000000000000000000 to FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.
Example of use:
1
{
2
LoRaWAN.setAppKey(00102030405060708090A0B0C0D0E0F”);
3
}
Copied!
Related variable:
LoRaWAN._appKey → Stores the previously set application key

LoRaWAN module activation

To participate in a LoRaWAN network, each module has to be personalized and activated.
Activation of a module can be achieved in two ways, either via Over-The-Air Activation (OTAA) when an end-device is deployed or reset, or via Activation By Personalization (ABP) in which the two steps of end-device personalization and activation are done as one step.

Over-The-Air Activation (OTAA)

For OTAA, modules must follow a join procedure prior to participating in data exchanges with the network server. A module has to go through a new join procedure every time it has lost the session context information.
The OTAA join procedure requires the module to be personalized with the following information before its starts the join procedure:
  • Device EUI (64-bit)
  • Application EUI (64-bit)
  • Application Key (128-bit)
After joining through OTAA, the module and the network exchanged the Network Session Key and the Application Session Key which are needed to perform communications.

Activation By Personalization (ABP)

Activating a module by ABP means that the device address and the two session keys are directly stored into the module instead of the Device EUI, Application EUI and the Application Key. The module is equipped with the required information for participating in a specific LoRa network when started.
Each module should have a unique set of Network Session Key and Application Session Key. Compromising the keys of one module shouldn‘t compromise the security of the communications of other devices. The process to build those keys should be such that the keys cannot be derived in any way from publicly available information.
The ABP join procedure requires the module to be personalized with the following information before its starts the join procedure:
  • Device address (32-bit)
  • Network Session Key (128-bit key) ensures security on network level
  • Application Session Key (128-bit key) ensures end-to-end security on application level

Join a network

Before sending packets to a gateway, the node must join a network first. The joinABP() function allows theuser to attempt joining the network using the Activation By Personalization mode (ABP). The joinOTAA()function allows the user to attempt joining the network using the Over the Air Activation mode (OTAA). Beforejoining the network, the specific parameters for activation should be configured depending on the joining procedure.
  • Join ABP
Before joining the network, the specific parameters for activation should be configured: device EUI, device address, network session key and application session key.
Example of use:
1
{
2
LoRaWAN.joinABP();
3
}
Copied!
  • Join OTAA
Before joining the network, the specific parameters for activation should be configured: device EUI, application EUI and application key.
Example of use:
1
{
2
LoRaWAN.joinOTAA();
3
}
Copied!
After joining via OTAA successfully, the module will be able to join the network in ABP mode in future joining procedures. The session keys are stored in module's memory, so it is possible to power down the module and restart it using ABP for joining the network with the previously stored keys.

LoRaWAN mode features

Operational ISM bands

The resetMacConfig() function allows the user to reset the software LoRaWAN stack and initialize it with the parameters for the selected band: 433 MHz, 868 MHz or 900 MHz.
The getBand() function allows the user to query the current frequency band of operation. This function is not available for the LoRaWAN US and AU modules since they can only work in the 902-928 MHz ISM band for the US version and 915-928 MHz ISM band for the AU version. The attribute _band permits to access to the settings of the module. The default value is 868. This value can be saved into the module's memory with the saveConfig() function due to keep the band configuration after a reboot. Value can be either 433 or 868.
Example of use:
1
{
2
LoRaWAN.resetMacConfig(433);
3
LoRaWAN.getBand();
4
}
Copied!
Related variable:
LoRaWAN._band → Stores the current frequency band of operation

Send data to a LoRaWAN gateway

  • Sending unconfirmed packets
The sendUnconfirmed() function allows the user to transmit data on a specified port number. This function will not expect any acknowledgement back from the server. It is necessary to indicate the port to use. The range is from 1 to 223. The second input of the sending function is the payload of the packet to send. The payload must be specified in hexadecimal format as a string.
Example of use:
1
{
2
uint8_t port = 1;
3
char data[] =010203040506070809;
4
LoRaWAN.sendUnconfirmed( port, data);
5
}
Copied!
There is a second sendUnconfirmed() function prototype which permits to send a packet defined as an array of bytes. So the function expects three inputs: port, pointer to the data and length of the data.
Example of use:
1
{
2
uint8_t port = 1;
3
uint8_t data[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
4
LoRaWAN.sendUnconfirmed( port, data, 6);
5
}
Copied!
The length of the payload capable of being transmitted is dependent upon the set data rate. Please refer to the “Data rate” section for the payload length values.
Figure: Sending confirmed packets with ACK
The sendConfirmed() function allows the user to transmit data on a specified port number. This function will expect an acknowledgement from the server. If no ACK is received, the message will be retransmitted automatically up to a maximum of times specified by the setRetries() function. It is necessary to indicate the port to use. The range is from 1 to 223. The second input of the sending function is the payload of the packet to send. The payload must be specified in hexadecimal format as a string.
Example of use:
1
{
2
uint8_t port = 1;
3
char data[] =010203040506070809;
4
LoRaWAN.sendConfirmed( port, data);
5
}
Copied!
The length of the payload capable of being transmitted is dependent upon the set data rate. Please refer to the “Data rate” section for the payload length values.

Receiving data from a LoRaWAN gateway

Note that not every back-end is able to send data to end devices. The back-ends which are able to perform data downlink use the ACK process to send a special ACK frame containing data. So once the user programs a downlink process, this downlink data will be received by the target module the next time it performs a transmission.
There is no specific function to receive data from back-ends in this library. The sendUnconfirmed() and the sendConfirmed() functions check if any special ACK is received and store data if any has been received. In case data has been received, _dataReceived flag will be set to true.
Related variables:
LoRaWAN._port → Stores the port used by the back-ends to send data LoRaWAN._data → Stores the received data LoRaWAN._dataReceived → Data received flag

Save configuration

The saveConfig() function allows the user to save LoRaWAN Class A protocol configuration parameters to the module’s non-volatile memory. This function must be issued after the configuration parameters have been appropriately set.
The LoRaWAN Class A protocol configuration savable parameters are:
  • Band
  • Uplink Frame Counter
  • Downlink Frame Counter
  • Data Rate
  • Adaptive Data Rate state
  • Device EUI
  • Application EUI
  • Application Key
  • Network Session Key
  • Application Session Key
  • Device Address
  • Second receiving window parameters
  • All Channel Parameter
    • Frequency
    • Duty Cycle
    • Data Rate Range
    • Status
There are some exceptions for the LoRaWAN US module, it does not save:
  • Band, since it does not use this parameter
  • Data rate
  • Channel frequency, preset according to specification
  • Duty cycle, since it does not use this parameter
Example of use:
1
{
2
LoRaWAN.saveConfig();
3
}
Copied!
The macResume() function allows the user to enable LoRaWAN mode. After switching on the module it is not mandatory to call this function because the default mode upon reboot is LoRaWAN mode. However, if P2P mode was previously set and the user needs to switch back to LoRaWAN mode, then this function must be called. This function is not available for the LoRaWAN JP / KR module.
Example of use:
1
{
2
LoRaWAN.macResume();
3
}
Copied!

Power level

The setPower() function allows the user to set the output power to be used on the next transmissions.
The getPower() function allows the user to query the device power index which was previously set by the user. The attribute _powerIndex permits to access to the settings of the module. The range goes from 0 to 5 for the 433 MHz frequency band and from 1 to 5 for the 868 MHz frequency band. LoRaWAN US and LoRaWAN AU power index values can be: 5, 7, 8, 9 or 10. LoRaWAN IN power index values go from 0 to 5. LoRaWAN ASIA-PAC / LATAM power index values go from 0 to 5. LoRaWAN JP / KR power index values go from 0 to 7.
Power Index
Power level(868 MHz)
Power level(433 MHz)
0
N / A
10 dBm
1
14 dBm
7 dBm
2
11 dBm
4 dBm
3
8 dBm
1 dBm
4
5 dBm
-2 dBm
5
2 dBm
-5 dBm
Table: Power levels table (LoRaWAN EU /433 module)
Power Index
Power level (900 MHz)
5
20 dBm
7
16 dBm
8
14 dBm
9
12 dBm
10
10 dBm
Table: Power levels table (LoRaWAN US and LoRaWAN AU modules)
Power Index
Power level (865-867 MHz)
0
MaxEIRP = 18.5 dBm
1
MaxEIRP – 2 dB
2
MaxEIRP – 4 dB
3
MaxEIRP – 6 dB
4
MaxEIRP – 8 dB
5
MaxEIRP – 10 dB
Table: Power levels table (LoRaWAN IN module MaxEIRP is 18.5 dBm)
Power Index
Power level (923 MHz)
0
MaxEIRP = 18.5 dBm
1
MaxEIRP – 2 dB
2
MaxEIRP – 4 dB
3
MaxEIRP – 6 dB
4
MaxEIRP – 8 dB
5
MaxEIRP – 10 dB
Table: Power levels table (LoRaWAN ASIA-PAC / LATAM module MaxEIRP is 18.5 dBm)
Power Index
Power level (923 MHz Japan)
0
MaxEIRP = 16 dBm
1
MaxEIRP – 2 dB
2
MaxEIRP – 4 dB
3
MaxEIRP – 6 dB
4
MaxEIRP – 8 dB
5
MaxEIRP – 10 dB
6
MaxEIRP – 14 dB
7
MaxEIRP – 14 dB
Table: Power levels table (LoRaWAN JP / KR (band AS923MHZ Japan) module MaxEIRP is 16 dBm)
Power Index
Power level (920 MHz Korea)
0
MaxEIRP = 14 dBm
1
MaxEIRP – 2 dB
2
MaxEIRP – 4 dB
3
MaxEIRP – 6 dB
4
MaxEIRP – 8 dB
5
MaxEIRP – 10 dB
6
MaxEIRP – 12 dB
7
MaxEIRP – 14 dB
Table: Power levels table (LoRaWAN JP / KR (band KR920-923MHz) module MaxEIRP is 14 dBm)
Example of use:
1
{
2
LoRaWAN.setPower(1);
3
LoRaWAN.getPower();
4
}
Copied!
Related variable:
LoRaWAN._powerIndex → Stores the previously set power

Adaptive data rate (ADR)

The setADR() function allows the user to enable or disable the adaptive data rate (ADR). The server is informed about the status of the module's ADR. In every uplink frame it receives from ADR field in uplink datapacket. If ADR is enabled, the server will optimize the data rate and the transmission power based on the information collected from the network: the RSSI / SNR of the last received packets.
The getADR() function allows the user to query the device adaptive data rate status. The attribute _adrpermits to access to the settings of the module. This attribute is set to 'true' if ADR is enabled or 'false' if ADRis disabled.
Example of use:
1
{
2
LoRaWAN.setADR(“on”);
3
LoRaWAN.setADR(“off”);
4
LoRaWAN.getADR();
5
}
Copied!
Related variable:
LoRaWAN._adr → Stores the previously set ADR status
Example of setting adaptive data rate: https://development.libelium.com/lorawan-05-adaptive-data-rate/

Data rate

The setDataRate() function allows the user to set the data rate to be used for the next transmission. The following encoding is used for Data Rate (DR):
Data Rate
Configuration
Indicative physicalbit rate [bits/s]
Maximum payload[bytes]
0
LoRa: SF12 / 125 kHz
250
51
1
LoRa: SF11 / 125 kHz
980
51
2
LoRa: SF10 / 125 kHz
980
51
3
LoRa: SF9 / 125 kHz
1760
115
4
LoRa: SF8 / 125 kHz
5470
222
5
LoRa: SF7 / 125 kHz
5470
222
Table: Data rates table for the LoRaWAN EU, IN, ASIA-PAC / LATAM and JP / KR modules
Data Rate
Configuration
Indicative physicalbit rate [bits/s]
Maximum payload[bytes]
0
LoRa: SF10 / 125 kHz
980
11
1
LoRa: SF9 / 125 kHz
1760
53
2
LoRa: SF8 / 125 kHz
3125
129
3
LoRa: SF7 / 125 kHz
5470
242
4
LoRa: SF8 / 500 kHz
12500
242
Table: Data rates table for the LoRaWAN US and LoRaWAN AU modules
The getDataRate() function allows the user to query the device data rate. The attribute _dataRatepermits to access to the settings of the module.
Example of use:
1
{
2
LoRaWAN.setDatarate(0);
3
LoRaWAN.getDataRate();
4
}
Copied!
Related variable:
LoRaWAN._dataRate → Stores the previously set data rate

Transmission retries

The setRetries() function allows the user to set the number of retransmissions to be used for an uplink confirmed packet, if no downlink acknowledgment is received from the server.
The getRetries() function allows the user to query the number of retransmissions which was previously set by the user. The attribute _retriespermits to access to the settings of the module. The attribute range is from 0 to 255.
Example of use:
1
{
2
LoRaWAN.setRetries (3);
3
LoRaWAN.getRetries ();
4
}
Copied!
Related variable:
LoRaWAN._retries → Stores the previously set number of retransmissions

Receiving windows

As it has been described in the section “Receiving data from a LoRaWAN gateway”, there is no specific function to receive data. The module is only capable of receiving gateway messages after a transmission hasbeen done from the module during shorts periods of time named receiving windows.
The first receiving window has a fixed data rate and frequency that matches with those used in the last transmission. The setRX1Delay() function allows the user to set the delay between the transmission and the first reception window.
The getRX1Delay() function allows the user to query the delay between the transmission and the first reception window. The attribute _rx1Delaypermits to access to the settings of the module. The attribute range is from 0 to 65535.
The second receiving delay is set internally by the module calculated with the first window delay plus 1000 ms. The setRX2Parameters() function allows the user to set the data rate and frequency that will be usedby the second reception window. The getRX2Delay() function allows the user to query the delay between the transmission and the second reception window.
The attribute _rx2Delaypermits to access to the settings of the module. The attribute range is from 0 to 65535. The getRX2Parameters() function allows the user to query the data rate and frequency used in the second reception window. This function expects a parameter that indicates the band ofthe parameters that are queried: 868 and 433 for the LoRaWAN EU module and 900 fo the LoRaWAN US and LoRaWAN AU modules. The attribute _rx2DataRatepermits to access to the settings of the module. The attribute range is from 0 to 7 for the LoRaWAN EU, LoRaWAN IN and LoRaWAN ASIA-PAC / LATAM modules and 8 to 13 for the LoRaWAN US and LoRaWAN AU modules. The attribute _rx2Frequencypermits to access to the settings of the module. The attribute range is from 863000000 to 870000000 for the 868 band and from 433050000 to 434790000 for the 433 band, in Hz for the LoRaWAN EU and IN modules and from 923300000 to 927500000, for the 900 band, in Hz for the LoRaWAN US, AU and ASIA-PAC / LATAM modules. The attribute range is from 920600000 to 928000000 for the AS923MHz Japan band and from 920900000 to 923300000 for the KR920-923MHz band, in Hz for the LoRaWAN JP / KR module.
Example of use:
1
{
2
LoRaWAN.setRX1Delay(1000); // set a 1000 ms delay
3
LoRaWAN.getRX1Delay();
4
LoRaWAN.getRX2Delay();
5
LoRaWAN.setRX2Parameters(0,864500000); // set DR0 and 864.5 MHz
6
LoRaWAN.getRX2Delay(868);
7
}
Copied!
Related variable:
LoRaWAN. rx1Delay → Stores the RX1 delay LoRaWAN. rx2Delay → Stores the RX2 delay LoRaWAN. rx2DataRate → Stores the RX2 data rate LoRaWAN. rx2Frequency → Stores the RX2 frequency

Automatic reply (AR)

The setAR() function allows the user to enable or disable the module's automatic reply. By enabling the automatic reply, the module will transmit a packet without a payload immediately after a confirmed downlink is received, or when the Frame Pending bit has been set by the server. If set to OFF, no automatic reply will be transmitted.
The getAR() function allows the user to query the automatic reply status to the module. The attribute _arpermits to access to the settings of the module. This attribute is set to 'true' if AR is enabled or 'false' if AR is disabled.
This parameter cannot be stored in the module's EEPROM using the saveConfig() function. To get to know the previous state of this parameter user can use the attribute _ar.
Example of use:
1
{
2
LoRaWAN.setAR(“on”);
3
LoRaWAN.setAR(“off”);
4
LoRaWAN.getAR();
5
}
Copied!
Related variable:
LoRaWAN._ar → Stores the previously set ADR status
The setUpCounter() function allows the user to set the uplink frame counter that will be used for the next uplink transmission.
The getUpCounter() function allows the user to query the uplink frame counter that will be used for thenext uplink transmission. The attribute _upCounter permits to access the settings of the module. The attribute range is from 0 to 4294967295.
If the back-end's sequence number check is set to strict, this uplink counter must be synchronized with the back-end uplink counter. The _upCounter is saved into the module's memory after every transmission.
Example of use:
1
{
2
LoRaWAN.setUpCounter(10);
3
LoRaWAN.getUpCounter();
4
}
Copied!
Related variable:
LoRaWAN._upCounter → Stores the previously set uplink frame sequence number
The setDownCounter() function allows the user to set the downlink frame counter that will be used for the next downlink reception.
The getDownCounter() function allows the user to query the downlink frame counter that will be used for the next downlink reception. The attribute _downCounter permits to access the settings of the module. The attribute range is from 0 to 4294967295.
If the back-end check sequence number function is set to strict, this downlink counter must be synchronized with the back-end downlink counter. The _downCounter is saved into the module's memory after every reception.
Example of use:
1
{
2
LoRaWAN.setDownCounter(10);
3
LoRaWAN.getDownCounter();
4
}
Copied!
Related variable:
LoRaWAN._downCounter → Stores the previously set downlink frame sequence number

Channel parameters

The LoRaWAN EU module has 16 channels available to be configured. The channel parameters are:
  • Frequency
  • Duty cycle
  • Data rate range
  • Status
Channel Number
Parameters
Frequency band 868
Frequency band 433
Channel 0
Frequency (Hz)
868100000
433175000
Channel 0
Duty cycle
302
302
Channel 0
Data rate range
0-5
0-5
Channel 0
Status
On
On
Channel 1
Frequency (Hz)
868300000
433375000
Channel 1
Duty cycle
302
302
Channel 1
Data rate range
0-5
0-5
Channel 1
Status
On
On
Channel 2
Frequency (Hz)
868300000
433375000
Channel 2
Duty cycle
302
302
Channel 2
Data rate range
0-5
0-5
Channel 2
Status
On
On
Channel 3 - 15
Frequency (Hz)
0 (to be configured by theuser)
0 (to be configured by theuser)
Channel 3 - 15
Duty cycle
65535
15 -15
Channel 3 - 15
Data rate range
15 -15
15 -15
Channel 3 - 15
Status
Off
Off
Table: Channel parameters table for LoRaWAN EU
The LoRaWAN US module has 72 channels with a preset fixed frequency for every channel. Data rate rangeand channel status are the only settable parameters.
Channel number
Default Values
Default Values
Channel 0 - 63
Frequency (Hz)
902300000 + 200000 * channel Index
Channel 0 - 63
Data rate range (min - max)
0 - 4
Channel 0 - 63
Status
On
Channel 64 - 71
Frequency (Hz)
903000000 + 1600000 * (channel Index- 64)
Channel 64 - 71
Data rate range (min - max)
4 - 4
Channel 64 - 71
Status
On
Table: Channel parameters table for LoRaWAN US
The LoRaWAN AU module has 72 channels with a preset fixed frequency for every channel (like the US model). Data rate range and channel status are the only settable parameters.
Channel number
Parameters
Default Values
Channel 0 - 63
Frequency (Hz)
915200000 + 200000 * channel Index
Channel 0 - 63
Data rate range (min - max)
0 - 4
Channel 0 - 63
Status
On
Channel 64 - 71
Frequency (Hz)
915900000 + 1600000 * (channel Index- 64)
Channel 64 - 71
Data rate range (min - max)
4 - 4
Channel 64 - 71
Status
On
Table: Channel parameters table for LoRaWAN AU
The LoRaWAN IN module has 16 channels available to be configured. The channel parameters are:
  • Frequency
  • Duty cycle
  • Data rate range
  • Status
Channel Number
Parameters
Default Values
Channel 0
Frequency (Hz)
865062500
Channel 0
Duty cycle
302
Channel 0
Data rate range
0-0
Channel 0
Status
On
Channel 1
Frequency (Hz)
865062500
Channel 1
Duty cycle
302
Channel 1
Data rate range
0-0
Channel 1
Status
On
Channel 2
Frequency (Hz)
865062500
Channel 2
Duty cycle
302
Channel 2
Data rate range
0-0
Channel 2
Status
On
Channel 3 - 15
Frequency (Hz)
0 (to be configured by the user)
Channel 3 - 15
Duty cycle
65535
Channel 3 - 15
Data rate range
15 -15
Channel 3 - 15
Status
Off
Table: Channel parameters table for LoRaWAN IN
The LoRaWAN ASIA-PAC / LATAM module has 16 channels available to be configured. The channel parameters are:
  • Frequency
  • Duty cycle
  • Data rate range
  • Status
Channel Number
Parameters
Default Values
Channel 0
Frequency (Hz)
923200000
Channel 0
Duty cycle
302
Channel 0
Data rate range
0-5
Channel 0
Status
On
Channel 1
Frequency (Hz)
923400000
Channel 1
Duty cycle
302
Channel 1
Data rate range
0-5
Channel 1
Status
On
Channel 2 - 15
Frequency (Hz)
0 (to be configured by the user)
Channel 2 - 15
Duty cycle
15 -15
Channel 2 - 15
Data rate range
15 -15
Channel 2 - 15
Status
Off
Table: Channel parameters table for LoRaWAN ASIA-PAC / LATAM
The LoRaWAN JP / KR module configured in the AS923 MHz Japan band has 16 channels available to be configured. The channel parameters are:
  • Frequency
  • Data rate range
  • Status
Channel Number
Parameters
Default Values
Channel 0
Frequency (Hz)
923400000
Channel 0
Data rate range
0-5
Channel 0
Status
On
Channel 1
Frequency (Hz)
923400000
Channel 1
Data rate range
0-5
Channel 1
Status
On
Channel 2 - 15
Frequency (Hz)
0 (to be configured by the user)
Channel 2 - 15
Data rate range
0 -5
Channel 2 - 15
Status
Off
Table: Channel parameters table for LoRaWAN JP / KR (band AS923MHz Japan)
The LoRaWAN JP / KR module configured in the KR920-923 MHz band 16 channels available to be configured. The channel parameters are:
  • Frequency
  • Data rate range
  • Status
Channel Number
Parameters
Default Values
Channel 0
Frequency (Hz)
922100000
Channel 0
Data rate range
0-5
Channel 0
Status
On
Channel 1
Frequency (Hz)
922300000
Channel 1
Data rate range
0-5
Channel 1
Status
On
Channel 2
Frequency (Hz)
922500000
Channel 2
Data rate range
0-5
Channel 2
Status
On
Channel 3 - 15
Frequency (Hz)
0 (to be configured by the user)
Channel 3 - 15
Data rate range
0-5
Channel 3 - 15
Status
Off
Table: Channel parameters table for LoRaWAN JP / KR (band KR902-923MHz)
Below you can see how the parameters can be configured.
  • Channel frequency
The first 3 channels have a fixed frequency value fot the LoRaWAN EU module. The rest of them can be configured in the following ranges: from 863250000 to 869750000 Hz for the 868 MHz band, and from 433050000 to 434790000 Hz for the 433 MHz band. Though frequency is not a settable parameter in LoRaWAN US and LoRaWAN AU modules frequency can be queried with ranges from 902300000 to 914900000 Hz and from 915200000 to 927800000 for each module. Like in the LoRaWAN EU module, the first 3 channels are preconfigured by default for the LoRaWAN JP / KR configured in the KR920-923 MHz band. In the LoRaWAN IN, LoRaWAN ASIA-PAC / LATAM and LoRaWAN JP / KR configured in the AS923 MHz Japan band, only the first 2 channels are preconfigured by default.
The setChannelFreq() function allows the user to set the operational frequency on the given channel number (from 3 to 15). The default channels (0-2) cannot be modified in terms of frequency. This function is not available for LoRaWAN US or LoRaWAN AU modules because channels have a fixed frequency.
The getChannelFreq() function allows the user to query the channel frequency which was previously set by the user. This function can query channels from 0 to 15 when using LoRaWAN EU module and channels from 0 to 71 when using LoRaWAN US or LoRaWAN AU module. The attribute _freqpermits to access to the settings of the module.
Example of use:
1
{
2
LoRaWAN.setChannelFreq(3,868000000);
3
LoRaWAN.getChannelFreq(3);
4
}
Copied!
Related variable:
LoRaWAN._freq[n] → Stores the previously set frequency for channel 'n'
  • Channel duty cycle
The setChannelDutyCycle() function allows the user to set the operational duty cycle on the given channel number (from 0 to 15). The duty cycle value that needs to be used as input argument can be obtained from the wanted duty cycle X (in percentage) using the following formula: duty cycle = (100/X) – 1. The default settings consider only the three default channels (0-2), and their default duty cycle is 0.33%. If a new channel is created either by the server or by the user, all the channels (including the default ones) must be updated by the user in terms of duty cycle to comply with the applicable regulations in the country. This function is not available for LoRaWAN US, LoRaWAN AU and LoRaWAN JP / KR modules.
The getChannelDutyCycle() function allows the user to query the channel duty cycle which was previously set by the user. The attribute _dCyclepermits to access to the settings of the module. The attribute range goes from 0 to 65535. The _dCycle value that needs to be configured can be obtained from the actual duty cycle X (in percentage) using the following formula: X = 100/(_dCycle+ 1). This function is not available for LoRaWAN US and LoRaWAN AU modules.
Example of use:
1
{
2
LoRaWAN.setChannelDutyCycle(3,9);
3
LoRaWAN.getChannelDutyCycle(3);
4
}
Copied!
Related variable:
LoRaWAN._dCycle[n] → Stores the previously set duty cycle for channel 'n'
  • Channel data rate range (DRR)
The setChannelDRRange() function allows the user to set the operational data rate range, from minimum to maximum values, for the given channel number.
The LoRaWAN EU, LoRaWAN IN, LoRaWAN ASIA-PAC / LATAM and LoRaWAN JP / KR modules support data rate ranges from 0 to 5 on channels 0 to 15.
The LoRaWAN US and the LoRAWAN AU modules support data rate ranges from 0 to 3 on channels 0 to 63.Channels from 64 to 71 have a fixed data rate range.
The getChannelDRRange() function allows the user to query the data rate range which was previously setby the user. The attributes to store the maximum and minimum data rates are _drrMax and _drrMinrespectively.