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>
or
#include <WaspLoRaWAN_Global.h>
The include above will depend on the LoRaWAN module in use.
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 (common)
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
API constants LoRaWAN
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
API constants LoRaWAN Global
AS923
LoRaWAN module is configured for AS923
AU915
LoRaWAN module is configured for AU915
EU868
LoRaWAN module is configured for EU868
KR920
LoRaWAN module is configured for KR920
IN865
LoRaWAN module is configured for IN865
US915
LoRaWAN module is configured for US915
SUB_BAND_0 to SUB_BAND_7
LoRaWAN subband for AU915 and US915 modules configuration
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
= 0LORAWAN_ANSWER_ERROR
= 1LORAWAN_NO_ANSWER
= 2LORAWAN_INIT_ERROR
= 3LORAWAN_LENGTH_ERROR
= 4LORAWAN_SENDING_ERROR
= 5LORAWAN_NOT_JOINED
= 6LORAWAN_INPUT_ERROR
= 7LORAWAN_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:
Related variable:
LoRaWAN._version
→ Stores the module's version
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:
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:
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:
Related variable:
LoRaWAN._version
→ Stores the module's version
Examples of LoRaWAN configuration: https://development.libelium.com/lorawan-01a-configure-module-eu-in-asia-pac-latam/ https://development.libelium.com/lorawan-01b-configure-module-us-or-au/ https://development.libelium.com/lorawan-global-01-region-configuration/
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:
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:
Example for user-provided device EUI:
Related variable:
LoRaWAN._devEUI
→ Stores the previously set device EUI
Examples of LoRaWAN configuration: https://development.libelium.com/lorawan-01a-configure-module-eu-in-asia-pac-latam/ https://development.libelium.com/lorawan-01b-configure-module-us-or-au/ https://development.libelium.com/lorawan-global-01-region-configuration/
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:
Example for user-provided device address:
Related variable:
LoRaWAN._devAddr
→ Stores the previously set device address
Examples of LoRaWAN configuration: https://development.libelium.com/lorawan-01a-configure-module-eu-in-asia-pac-latam/ https://development.libelium.com/lorawan-01b-configure-module-us-or-au/ https://development.libelium.com/lorawan-global-01-region-configuration/
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.
The attribute _appSKeystores
the application session key previously set by the user. The range goes from 00000000000000000000000000000000 to FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.
Example of use:
Related variable:
LoRaWAN._appSKey
→ Stores the previously set application session key
Examples of LoRaWAN configuration: https://development.libelium.com/lorawan-01a-configure-module-eu-in-asia-pac-latam/ https://development.libelium.com/lorawan-01b-configure-module-us-or-au/ https://development.libelium.com/lorawan-global-01-region-configuration/
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.
The attribute _nwkSKey
stores the network session key previously set by the user. The range goes from 00000000000000000000000000000000 to FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.
Example of use:
Related variable:
LoRaWAN._nwkSKey
→ Stores the previously set network session key
Examples of LoRaWAN configuration: https://development.libelium.com/lorawan-01a-configure-module-eu-in-asia-pac-latam/ https://development.libelium.com/lorawan-01b-configure-module-us-or-au/ https://development.libelium.com/lorawan-global-01-region-configuration/
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:
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:
Related variable:
LoRaWAN._appKey
→ Stores the previously set application key
Examples of LoRaWAN configuration: https://development.libelium.com/lorawan-01a-configure-module-eu-in-asia-pac-latam/ https://development.libelium.com/lorawan-01b-configure-module-us-or-au/ https://development.libelium.com/lorawan-global-01-region-configuration/
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 thNon-Globalon 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:
Join OTAA
Before joining the network, the specific parameters for activation should be configured: device EUI, application EUI and application key.
Example of use:
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
Non Global modules
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:
Related variable:
LoRaWAN._band
→ Stores the current frequency band of operation
LoRaWAN Global module
The setBand()
function allows the user to configure the module for the selected band: AS923, AU915, EU868, KR920, IN865 or US915.
The getBand()
function allows the user to query the current frequency band of operation. The attribute _band
permits to access to the settings of the module. The default value is EU868.
Example of use:
Related variable:
LoRaWAN._band
→ Stores the current frequency band of operation
The setChannelMask()
function allows the user to configure the sub-band in certain regions, such as AU915 and US915.
Example of use:
The showChannelConfig()
function allows the user to query the current channel frequency configuration. The channel configuration is printed through the serial port and it is available for all the band configurations.
Example of use:
Example of region configuration: https://development.libelium.com/lorawan-global-01-region-configuration/
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:
Example of sending a packet without ACK: https://development.libelium.com/lorawan-06-join-abp-send-unconfirmed/ https://development.libelium.com/lorawan-09-join-otaa-send-unconfirmed/ https://development.libelium.com/lorawan-global-04-join-abp-send-unconfirmed/ https://development.libelium.com/lorawan-global-07-join-otaa-send-unconfirmed/
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:
Examples of sending a packet using the alternative prototype: https://development.libelium.com/lorawan-08-join-abp-send-frame/ https://development.libelium.com/lorawan-11-join-otaa-send-frame/ https://development.libelium.com/lorawan-global-09-join-otaa-send-frame/ https://development.libelium.com/lorawan-global-11-join-otaa-send-tiny-frame/
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.
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:
Example of sending a packet with ACK: https://development.libelium.com/lorawan-08-join-abp-send-frame/ https://development.libelium.com/lorawan-11-join-otaa-send-frame/ https://development.libelium.com/lorawan-global-05-join-abp-send-confirmed/ https://development.libelium.com/lorawan-global-08-join-otaa-send-confirmed/
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:
Examples of LoRaWAN configuration: https://development.libelium.com/lorawan-01a-configure-module-eu-in-asia-pac-latam/ https://development.libelium.com/lorawan-01b-configure-module-us-or-au/
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:
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:
Related variable:
LoRaWAN._powerIndex
→ Stores the previously set power
Example of setting power level: https://development.libelium.com/lorawan-03-power-level/ https://development.libelium.com/lorawan-global-02-power-lever/
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:
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/ https://development.libelium.com/lorawan-global-03-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:
Related variable:
LoRaWAN._dataRate
→ Stores the previously set data rate
Example of setting data rate: https://development.libelium.com/lorawan-04-data-rate/ https://development.libelium.com/lorawan-global-03-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:
Related variable:
LoRaWAN._retries
→ Stores the previously set number of retransmissions
Examples of LoRaWAN configuration: https://development.libelium.com/lorawan-01a-configure-module-eu-in-asia-pac-latam/ https://development.libelium.com/lorawan-01b-configure-module-us-or-au/
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 _rx1Delay
permits 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 _rx2Delay
permits 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 _rx2DataRate
permits 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 _rx2Frequency
permits 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:
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 _ar
permits 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:
Related variable:
LoRaWAN._ar
→ Stores the previously set ADR status
Examples of LoRaWAN configuration: https://development.libelium.com/lorawan-01a-configure-module-eu-in-asia-pac-latam/ https://development.libelium.com/lorawan-01b-configure-module-us-or-au/
Uplink counter
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:
Related variable:
LoRaWAN._upCounter
→ Stores the previously set uplink frame sequence number
Downlink counter
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:
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 _freq
permits to access to the settings of the module.
Example of use:
Related variable:
LoRaWAN._freq[n]
→ Stores the previously set frequency for channel 'n'
Example of channel settings configuration: https://development.libelium.com/lorawan-02a-channels-eu-or-in-or-asia-pac-latam/ https://development.libelium.com/lorawan-02b-channels-us-or-au/ https://development.libelium.com/lorawan-global-01-region-configuration/
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 _dCycle
permits 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:
Related variable:
LoRaWAN._dCycle[n]
→ Stores the previously set duty cycle for channel 'n'
Example of channel settings configuration: https://development.libelium.com/lorawan-02a-channels-eu-or-in-or-asia-pac-latam/ https://development.libelium.com/lorawan-02b-channels-us-or-au/
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
.
Example of use:
Related variable:
LoRaWAN._drrMax[n]
→ Stores the previously set maximum data rate for channel 'n'
LoRaWAN._drrMin[n]
→ Stores the previously set minimum data rate for channel 'n'
Example of channel settings configuration: https://development.libelium.com/lorawan-02a-channels-eu-or-in-or-asia-pac-latam/ https://development.libelium.com/lorawan-02b-channels-us-or-au/ https://development.libelium.com/lorawan-global-01-region-configuration/
Channel status
The setChannelStatus()
function allows the user to set the operation of the given channel, either ”on”
or ”off”
. This function is not available for the LoRaWAN JP / KR.
LoRaWAN EU, LoRaWAN IN and LoRaWAN ASIA-PAC / LATAM allows to configure the channel status on channels from 0 to 15.
LoRaWAN US and LoRaWAN AU allow to configure the channel status on channels from 0 to 71.
The getChannelStatus()
function allows the user to query the operation channel status. The attribute _statuspermits to access to the settings of the module.
Example of use:
Related variable:
LoRaWAN._status[n]
→ Stores the previously set status for channel 'n'
Example of channel settings configuration: https://development.libelium.com/lorawan-02a-channels-eu-or-in-or-asia-pac-latam/ https://development.libelium.com/lorawan-02b-channels-us-or-au/ https://development.libelium.com/lorawan-global-01-region-configuration/
Duty cycle prescaler
The getDutyCyclePrescaler()
function allows the user to query the duty cycle prescaler. The value of the prescaler can be configured only by the server through use of the Duty Cycle Request frame. Upon reception of this command from the server, the duty cycle prescaler is changed for all enabled channels. Theattribute _dCyclePS
permits to access to the settings of the module.
Example of use:
Related variable:
LoRaWAN._dCyclePS
→ Stores the duty cycle prescaler established by the server
Margin
The getMargin()
function allows the user to query the demodulation margin as received in the last Link Check Answer frame. The attribute _margin
permits to access to the settings of the module.
Example of use:
Related variable:
LoRaWAN._margin
→ Stores the margin received in the last Link Check Answer frame
Gateway number
The getGatewayNumber()
function allows the user to query the number of gateways that successfully received the last Link Check Request frame command, as received in the last Link Check Answer. The attribute _gwNumber
permits to access to the settings of the module.
Example of use:
Related variable:
LoRaWAN._gwNumber
→ Stores the number of gateways that received the last Link Check Request frame
P2P mode – Direct communication between nodes
This feature is only available for the LoRaWAN module, the LoRaWAN Global module can only communicate with LoRaWAN gateways using the LoRaWAN communication protocol.
Enable P2P mode
The macPause()
function allows the user to disable LoRaWAN mode and enable P2P mode. After power reboot, the module's default mode is LoRaWAN. So, it is mandatory to call this function in order to work with the P2P mode. After calling this function, all P2P functions explained in this section will be able to be run.
Example of use:
Send data
The sendRadio()
function allows the user to transmit data using the radio transceiver. This function will notexpect any acknowledgement back from the receiver. The maximum length of the frame is 255 bytes (510 ASCII digits).
Example of use:
Receive data
The receiveRadio()
function allows the user to receive data using the radio transceiver. This function needs a timeout parameter to keep the module listening for any data. The range for this timeout input parameter is from 0 ms to 4294967295 ms. If any data frame is received, it is stored in _buffer
. The length of the buffer is specified in _length
. The user must keep in mind that this buffer structure is used for all functions in the API. So, the packet contents should be stored in a program buffer for being used after reception.
Example of use:
Related variable:
LoRaWAN._buffer
→ Stores data received through radio transceiver
LoRaWAN._length
→ Stores length of the data stored in _buffer
Power level
The setRadioPower()
function allows the user to set the operating output power in P2P mode.
The getRadioPower()
function allows the user to query the operating output power level in P2P mode which was previously set by the user. The attribute _radioPowerpermits
to access to the settings of the module.
The range of this attribute goes from -3 to 15 for the LoRaWAN EU module.
The range of this attribute goes from 2 to 20 for the LoRaWAN US and LoRaWAN AU modules.
The output power level in dBm can be consulted in the radio transceiver module datasheet:
RN2483 to see about LoRaWAN EU
RN2903 to see about LoRaWAN US, LoRaWAN AU, LoRaWAN IN and LoRaWAN ASIA-PAC / LATAM
CMWX1ZZABZ to see about LoRaWAN JP / KR
Example of use:
Related variable:
LoRaWAN._radioPower
→ Stores the previously set output power level
Spreading Factor
The setRadioSF()
function allows the user to set the operating spreading factor (SF) in P2P mode.
The getRadioSF()
function allows the user to query the operating Spreading Factor (SF) in P2P mode which was previously set by the user. The attribute _radioSF
permits to access to the settings of the module. The spreading factor can take the following values: “sf7”, “sf8”, “sf9”, “sf10”, “sf11” and “sf12”.
Example of use:
Related variable:
LoRaWAN._radioSF
→ Stores the previously set Spreading Factor
Frequency deviation
The setRadioFreqDeviation()
function allows the user to set the frequency deviation during operation in P2P mode.
The getRadioFreqDeviation()
function allows the user to query the operating frequency deviation which was previously set by the user. The attribute _radioFreqDevpermits
to access to the settings of the module. The frequency deviation range goes from 0 to 200000.
Example of use:
Related variable:
LoRaWAN._radioFreqDev
→ Stores the previously set frequency deviation
Preamble length
The setRadioPreamble()
function allows the user to set the preamble length for transmit/receive in P2P mode.
The getRadioPreamble()
function allows the user to query the preamble length which was previously set by the user. The attribute _preambleLengthpermits
to access to the settings of the module. The preamble length range goes from 0 to 65535.
Example of use:
Related variable:
LoRaWAN._preambleLength
→ Stores the previously set preamble length
CRC header
The setRadioCRC()
function allows the user to set the Cyclic Redundancy Check (CRC) header status for transmit/receive in P2P mode.
The getRadioCRC()
function allows the user to query the CRC status which was previously set by the user. The attribute _crcStatus
permits to access to the settings of the module. This attribute is set to ”on” ifCRC is enabled or ”off” if CRC is disabled.
Example of use:
Related variable:
LoRaWAN._crcStatus
→ Stores the previously set CRC status
Coding Rate
The setRadioCR()
function allows the user to set the Coding Rate (CR) for communications in P2P mode.
The getRadioCR()
function allows the user to query the CR which was previously set by the user. The attribute _radioCR
permits to access to the settings of the module. The CR can take the following values: “4/5”, “4/6”, “4/7” and “4/8”.
Example of use:
Related variable:
LoRaWAN._radioCR
→ Stores the previously set coding rate
Bandwidth
The setRadioBandwidth()
function allows the user to set the operating radio bandwidth (BW) for LoRa operation.
The getRadioBandwidth()
function allows the user to query radio bandwidth which was previously set bythe user. The attribute _radioBW
permits to access to the settings of the module. The radio bandwidth can take the following values: 125 kHz, 250 kHz and 500 kHz.
Example of use:
Related variable:
LoRaWAN._radioBW
→ Stores the previously set radio bandwidth
Frequency
The setRadioFrequency()
function allows the user to set the communication frequency of the radio transceiver.
The getRadioFrequency()
function allows the user to query radio frequency which was previously set by the user. The attribute _radioFreq
permits to access to the settings of the module.
When using the LoRaWAN EU or the LoRaWAN IN module, the operation frequency can take values from 433250000 to 434550000 or from 863250000 to 869750000, for the 433 and 868 MHz bands.
When using the LoRaWAN US or the LoRaWAN AU module, the operation frequency can take values from 902000000 to 928000000.
When using the LoRaWAN ASIA-PAC / LATAM module, the operation frequency can take values from 919000000 to 928000000.
Example of use:
Related variable:
LoRaWAN._radioFreq
→ Stores the previously set communication frequency
Signal to noise ratio (SNR)
The getRadioSNR()
function allows the user to query the Signal to Noise Ratio (SNR) for the last received packet. The attribute _radioSNR
permits to access to the settings of the module. The SNR can take values from -127 to 128.
Example of use:
Related variable:
LoRaWAN._radioSNR
→ Stores the previously set communication frequency
Hybrid LoRaWAN / P2P mode
It is possible to set up hybrid networks using both Radio and LoRaWAN protocols. Therefore, several nodes can use a P2P star topology to reach a central node which will access to the LoRaWAN network to route the information. The basis of this operation is that the central node listens to P2P packets and sends them to the LoRaWAN infrastructure. See the following diagram to understand this hybrid network:
The user must keep in mind that there is a mismatch between the maximum payload in P2P networks (255 bytes) and LoRaWAN networks (242 bytes). Therefore, the central node will be able to resend all received frames from the other P2P nodes. The following example shows how to operate as a central node sending data of the incoming P2P packets to the LoRaWAN network: https://development.libelium.com/lorawan-p2p-04-hybrid-p2p-lorawan/
Last updated