Microchip® Advanced Software Framework

enddevice_demo.c File Reference

LORAWAN Demo Application.

Copyright (c) 2019-2020 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include "lorawan.h"
#include "system_task_manager.h"
#include "enddevice_demo.h"
#include "conf_app.h"
#include "sio2host.h"
#include "resources.h"
#include "delay.h"
#include "sw_timer.h"
#include "LED.h"
#include "pmm.h"
#include "radio_driver_hal.h"
#include "conf_pmm.h"
#include "conf_sio2host.h"
#include "pds_interface.h"
#include "conf_certification.h"
#include "enddevice_cert.h"
#include "atomic.h"
#include <stdint.h>

Macros

#define MAX_NA_CHANNELS   72
 
#define MAX_SUBBAND_CHANNELS   8
 

Functions

static void app_resources_uninit (void)
 
SYSTEM_TaskStatus_t APP_TaskHandler (void)
 This function is called to process APP task. SHOULD be defined in APP. More...
 
static void appPostTask (AppTaskIds_t id)
 
static void appWakeup (uint32_t sleptDuration)
 
static float convert_celsius_to_fahrenheit (float cel_val)
 
void demo_appdata_callback (void *appHandle, appCbParams_t *appdata)
 Callback function for the ending of Bidirectional communication of Application data. More...
 
static void demo_handle_evt_rx_data (void *appHandle, appCbParams_t *appdata)
 
void demo_joindata_callback (StackRetStatus_t status)
 
static void demoTimerCb (void *cnt)
 
void dev_eui_read (void)
 Reads the MAC EUI from the EDBG Controller of the XPro Board. More...
 
static void displayJoinAndSend (void)
 Displays and activates LED's for joining to a network and sending data to a network. More...
 
static void displayRunDemoApp (void)
 Displays and activates LED's for selecting Demo application. More...
 
static void displayRunDemoCertApp (void)
 Displays and activates LED's to choose between Demo and Certification application. More...
 
static void displayRunRestoreBand (void)
 Activates LED's to indicate restoring of band. More...
 
static SYSTEM_TaskStatus_t displayTask (void)
 Calls appropriate functions based on state variables. More...
 
static void lTimerCb (void *data)
 
void mote_demo_init (void)
 Initialization the Demo application. More...
 
StackRetStatus_t mote_set_parameters (IsmBand_t ismBand, const uint16_t index)
 
void print_application_config (void)
 
void print_array (uint8_t *array, uint8_t length)
 
void print_stack_status (StackRetStatus_t status)
 
static void processJoinAndSend (void)
 Sends Join request or Data to the network. More...
 
static void processRunDemoApp (void)
 Runs the Demo application. More...
 
static void processRunDemoCertApp (void)
 Activates demo application or certification application. More...
 
static void processRunRestoreBand (void)
 Restores the previous band and runs. More...
 
static SYSTEM_TaskStatus_t processTask (void)
 Calls appropriate functions based on state variables. More...
 
static void runCertApp (void)
 
static void sendData (void)
 
void serial_data_handler (void)
 Pulls the data from UART when activated. More...
 
StackRetStatus_t set_device_type (EdClass_t ed_class)
 
StackRetStatus_t set_join_parameters (ActivationType_t activation_type)
 
void set_multicast_params (void)
 

Variables

static volatile uint8_t appTaskFlags = 0x00u
 
static SYSTEM_TaskStatus_t(* appTaskHandlers [])(void)
 
static AppTaskState_t appTaskState
 
bool bandSelected
 
static const char * bandStrings []
 
uint8_t bandTable []
 
static float cel_val
 
bool certAppEnabled = false
 
static volatile uint8_t count = 5
 
static uint8_t data_len = 0
 
static uint8_t demoAppKey [16] = DEMO_APPLICATION_KEY
 
static uint8_t demoAppsKey [16] = DEMO_APPLICATION_SESSION_KEY
 
static uint32_t demoDevAddr = DEMO_DEVICE_ADDRESS
 
static uint8_t demoDevEui [8] = DEMO_DEVICE_EUI
 
static uint8_t demoJoinEui [8] = DEMO_JOIN_EUI
 
static uint8_t demoMcastAppsKey [16] = DEMO_APP_MCAST_APP_SESSION_KEY
 
static uint32_t demoMcastDevAddr = DEMO_APP_MCAST_GROUP_ADDRESS
 
static bool demoMcastEnable = DEMO_APP_MCAST_ENABLE
 
static uint8_t demoMcastGroupId = DEMO_APP_MCAST_GROUPID
 
static uint8_t demoMcastNwksKey [16] = DEMO_APP_MCAST_NWK_SESSION_KEY
 
static uint8_t demoNwksKey [16] = DEMO_NETWORK_SESSION_KEY
 
uint8_t demoTimerId
 
bool factory_reset
 
static float fahren_val
 
static bool joined = false
 
uint32_t longPress
 
static LorawanSendReq_t lorawanSendReq
 
uint8_t lTimerId
 
static uint8_t off = LOFF
 
static uint8_t on = LON
 
static uint8_t rxchar [11]
 
static char serialBuffer
 
static bool startReceiving = false
 
static char temp_sen_str [25]
 
static uint8_t toggle = LTOGGLE
 
PRINT EVENTS
bool button_pressed
 Determine if button is pressed. More...
 

#define MAX_NA_CHANNELS   72

Referenced by mote_set_parameters().

#define MAX_SUBBAND_CHANNELS   8

Referenced by mote_set_parameters().

static void app_resources_uninit ( void  )
static
SYSTEM_TaskStatus_t APP_TaskHandler ( void  )

This function is called to process APP task. SHOULD be defined in APP.

References APP_TASK_ID, APP_TASKS_COUNT, appTaskFlags, appTaskHandlers, ATOMIC_SECTION_ENTER, ATOMIC_SECTION_EXIT, SYSTEM_PostTask(), and SYSTEM_TASK_SUCCESS.

Referenced by main(), and wsndemo_task().

static void appWakeup ( uint32_t  sleptDuration)
static
static float convert_celsius_to_fahrenheit ( float  cel_val)
static
static void demo_handle_evt_rx_data ( void *  appHandle,
appCbParams_t appdata 
)
static
void dev_eui_read ( void  )

Reads the MAC EUI from the EDBG Controller of the XPro Board.

References demoDevEui, edbg_eui_read_eui64(), i, and j.

static void displayJoinAndSend ( void  )
static

Displays and activates LED's for joining to a network and sending data to a network.

References LED_AMBER, LED_GREEN, off, set_LED_data(), and startReceiving.

Referenced by displayTask().

static void displayRunDemoApp ( void  )
static

Displays and activates LED's for selecting Demo application.

References bandStrings, bandTable, i, LED_AMBER, LED_GREEN, off, set_LED_data(), and startReceiving.

Referenced by displayTask().

static void displayRunDemoCertApp ( void  )
static

Displays and activates LED's to choose between Demo and Certification application.

References LED_AMBER, LED_GREEN, off, set_LED_data(), and startReceiving.

Referenced by displayTask().

static void displayRunRestoreBand ( void  )
static

Activates LED's to indicate restoring of band.

References appPostTask(), LED_AMBER, LED_GREEN, off, PROCESS_TASK_HANDLER, and set_LED_data().

Referenced by displayTask().

void lTimerCb ( void *  data)
static
static void print_array ( uint8_t *  array,
uint8_t  length 
)
static void processRunDemoApp ( void  )
static
static void processRunDemoCertApp ( void  )
static

Activates demo application or certification application.

References appPostTask(), appTaskState, DEMO_APP_STATE, DEMO_CERT_APP_STATE, DISPLAY_TASK_HANDLER, runCertApp(), and serialBuffer.

Referenced by processTask().

static void runCertApp ( void  )
static

References cert_app_init(), and certAppEnabled.

Referenced by processRunDemoCertApp().

static void sendData ( void  )
static

volatile uint8_t appTaskFlags = 0x00u
static

Referenced by APP_TaskHandler(), and appPostTask().

SYSTEM_TaskStatus_t(* appTaskHandlers[APP_TASKS_COUNT])(void)
static
Initial value:
= {
}
static SYSTEM_TaskStatus_t processTask(void)
Calls appropriate functions based on state variables.
Definition: enddevice_demo.c:279
static SYSTEM_TaskStatus_t displayTask(void)
Calls appropriate functions based on state variables.
Definition: enddevice_demo.c:228

Referenced by APP_TaskHandler().

bool bandSelected
const char* bandStrings[]
static
Initial value:
=
{
"FactoryDefaultReset",
"EU868",
"NA915",
"AU915",
"AS923",
"JPN923",
"KR920",
"IND865",
"Clear PDS",
"Reset Board"
}

Referenced by displayRunDemoApp(), mote_demo_init(), mote_set_parameters(), and processRunRestoreBand().

uint8_t bandTable[]
Initial value:
=
{
0xFF,
0xFF,
0xFF
}
Definition: stack_common.h:150
Definition: stack_common.h:169
Definition: stack_common.h:142
Definition: stack_common.h:152
Definition: stack_common.h:148
Definition: stack_common.h:173
Definition: stack_common.h:146

Referenced by cert_select_band(), cert_set_join_parameters(), displayRunDemoApp(), enddevice_cpc_fresh_join(), mote_demo_init(), mote_set_parameters(), processRunDemoApp(), and processRunRestoreBand().

float cel_val
static
bool certAppEnabled = false

Referenced by runCertApp().

uint8_t demoAppKey[16] = DEMO_APPLICATION_KEY
static

Referenced by set_join_parameters().

uint8_t demoAppsKey[16] = DEMO_APPLICATION_SESSION_KEY
static

Referenced by set_join_parameters().

uint32_t demoDevAddr = DEMO_DEVICE_ADDRESS
static

Referenced by set_join_parameters().

uint8_t demoDevEui[8] = DEMO_DEVICE_EUI
static
uint8_t demoJoinEui[8] = DEMO_JOIN_EUI
static

Referenced by set_join_parameters().

uint8_t demoMcastAppsKey[16] = DEMO_APP_MCAST_APP_SESSION_KEY
static

Referenced by set_multicast_params().

uint32_t demoMcastDevAddr = DEMO_APP_MCAST_GROUP_ADDRESS
static

Referenced by set_multicast_params().

bool demoMcastEnable = DEMO_APP_MCAST_ENABLE
static

Referenced by set_multicast_params().

uint8_t demoMcastGroupId = DEMO_APP_MCAST_GROUPID
static

Referenced by set_multicast_params().

uint8_t demoMcastNwksKey[16] = DEMO_APP_MCAST_NWK_SESSION_KEY
static

Referenced by set_multicast_params().

uint8_t demoNwksKey[16] = DEMO_NETWORK_SESSION_KEY
static

Referenced by set_join_parameters().

uint8_t demoTimerId

Referenced by demoTimerCb(), and mote_demo_init().

bool factory_reset
float fahren_val
static
uint32_t longPress
LorawanSendReq_t lorawanSendReq
static
uint8_t lTimerId

Referenced by demo_appdata_callback(), and lTimerCb().

uint8_t rxchar[11]
static

Referenced by demoTimerCb(), and mote_demo_init().

char temp_sen_str[25]
static
uint8_t toggle = LTOGGLE
static

Referenced by lTimerCb().