2.2 Firmware Setup
In the LoRaWAN connection type, calculate all the measurements with the LoRaWAN Mote Application (demo) in Advanced Software Framework (ASF) 3.50.0.
In the LoRa connection type, calculate all the measurements with the Radio utility firmware available in the WLR089U0 (SAMR34 Module) Reference Design Package.
The following are the steps for the LoRaWAN connection type code modification from default:
- Configure the Activation mode to Over the Air
Activation (OTAA) by enabling the
DEMO_APP_ACTIVATION_TYPE
macro and disabling (comment out the line) the same macro defined for Activation by Personalization (ABP) mode in theconf_app.h
file.#define DEMO_APP_ACTIVATION_TYPE OVER_THE_AIR_ACTIVATION //#define DEMO_APP_ACTIVATION_TYPE ACTIVATION_BY_PERSONALIZATION
- Configure the data transmission type to confirmed
type or unconfirmed type based on the scenario in the
conf_app.h
file. The macroDEMO_APP_TRANSMISSION_TYPE
is defined for both unconfirmed and confirmed types and can be configured by commenting out the unused macro.#define DEMO_APP_TRANSMISSION_TYPE UNCONFIRMED //#define DEMO_APP_TRANSMISSION_TYPE CONFIRMED
- Configure the device class to Class A in the
conf_app.h
file. The macroDEMO_APP_ENDDEVICE_CLASS
sets the device class and can be configured by commenting out the unused macro.#define DEMO_APP_ENDDEVICE_CLASS CLASS_A //#define DEMO_APP_ENDDEVICE_CLASS CLASS_C
- Configure the join parameters for the OTAA join
procedure according to the network server, which is in the
conf_app.h
file.#define DEMO_DEVICE_EUI {0xde, 0xaf, 0xfa, 0xce, 0xde, 0xaf, 0xfa, 0xce} #define DEMO_JOIN_EUI {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12} #define DEMO_APPLICATION_KEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12}
- Configure the TX data rate based on the scenario
in the
conf_regparams.h
file.#define MAC_DEF_TX_CURRENT_DATARATE_EU (DR0 or DR5)
Note: In this application note, consider the Industrial Scientific and Medical (ISM) Europe (EU) band to capture the current measurements in various scenarios under the LoRaWAN connection type.
- For profiling the maximum payload size transmit
scenario, modify some part of the code in the
sendData()
, add a buffer to store and transmit the maximum application payload in theenddevice_demo.c
file.#define EU_MAX_PAYLOAD_SIZE_DR5 234 #define EU_MAX_PAYLOAD_SIZE_DR0 43 uint8_t eu_max_payload_buffer_DR5[EU_MAX_PAYLOAD_SIZE_DR5] = { 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA}
uint8_t eu_max_payload_buffer_DR0[EU_MAX_PAYLOAD_SIZE_DR0] = {0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA};
//get_resource_data(TEMP_SENSOR,(uint8_t *)&cel_val); //fahren_val = convert_celsius_to_fahrenheit(cel_val); //printf("\nTemperature:"); //snprintf(temp_sen_str,sizeof(temp_sen_str),"%.1fC/%.1fF\n", cel_val,fahren_val); //printf("%.1f\xf8 C/%.1f\xf8 F\n\r",cel_val, fahren_val); //data_len = strlen(temp_sen_str); // lorawanSendReq.buffer = &temp_sen_str;
- Add the following code for profiling the max
payload scenario in DR5:
data_len = EU_MAX_PAYLOAD_SIZE_DR5; lorawanSendReq.buffer = &eu_max_payload_buffer_DR5; lorawanSendReq.bufferLength = data_len; //lorawanSendReq.bufferLength = data_len - 1; lorawanSendReq.confirmed = DEMO_APP_TRANSMISSION_TYPE; lorawanSendReq.port = DEMO_APP_FPORT;
- Add the following code for profiling the max
payload scenario in DR0:
data_len = EU_MAX_PAYLOAD_SIZE_DR0; lorawanSendReq.buffer = &eu_max_payload_buffer_DR0; lorawanSendReq.bufferLength = data_len; //lorawanSendReq.bufferLength = data_len - 1; lorawanSendReq.confirmed = DEMO_APP_TRANSMISSION_TYPE; lorawanSendReq.port = DEMO_APP_FPORT;
Note: Using the default configuration available in the LoRaWAN Mote Application (demo) is recommended for profiling the minimum payload size scenarios in DR0 and DR5, which transmits the temperature sensor data.
- Configure the number of retransmissions of the
confirmed uplink to 2 to emulate the retransmission scenario that is similar to this
profile. The
MAC_CONFIRMABLE_UPLINK_REPETITIONS_MAX
macro holds the configuration of the number of retransmissions applicable for the confirmed uplink scenario in thelorawan_defs.h
file.#define MAC_CONFIRMABLE_UPLINK_REPITITIONS_MAX (2)