/**
* \file  enddevice_demo.h
*
* \brief Serial Provisioning of LoRaWAN Demo Application
*
* Copyright (c) 2021 Europalab Devices ApS
*
* \asf_license_start
*
* \page License
*
* This file is part of Sendcomm.
*
* Sendcomm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sendcomm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Sendcomm. If not, see <https://www.gnu.org/licenses/>.
*
* \asf_license_stop
*
*/

#ifndef DEMO_APP_H_
#define DEMO_APP_H_

/*********************************************************************//**
 \brief      Macro to check the LoRaWAN stack status attribute
             network joined bit
*************************************************************************/
#define LORAWAN_NW_JOINED	0x01
//#define EDBG_EUI_READ 1
typedef enum _AppTaskIds_t
{
	DISPLAY_TASK_HANDLER,
	PROCESS_TASK_HANDLER,
	APP_TASKS_COUNT
}AppTaskIds_t;

typedef enum _AppTaskState_t
{
	RESTORE_BAND_STATE,
	DEMO_APP_CONFIG,
	DEMO_CERT_APP_STATE,
	DEMO_APP_STATE,
	JOIN_SEND_STATE
}AppTaskState_t;

/*********************************************************************//**
 \brief      Function to Initialize the Demo application
*************************************************************************/
void mote_demo_init(void);

/*********************************************************************//*
 \brief      Set join parameters function
 \param[in]  activation type - notifies the activation type (OTAA/ABP)
 \return     LORAWAN_SUCCESS, if successfully set the join parameters
             LORAWAN_INVALID_PARAMETER, otherwise
 ************************************************************************/
StackRetStatus_t set_join_parameters(ActivationType_t activation_type);

/*********************************************************************//*
 \brief      Function to Initialize the device type
 \param[in]  ed_class - notifies the device class (CLASS_A/CLASS_C)
 \return     LORAWAN_SUCCESS, if successfully set the device class
             LORAWAN_INVALID_PARAMETER, otherwise
 ************************************************************************/
StackRetStatus_t set_device_type(EdClass_t ed_class);

/***********************************************************************
 \brief      Function to Initialize set default parameters
 \param[in]  void
 \return     LORAWAN_SUCCESS, if successfully set all the parameters
             LORAWAN_INVALID_PARAMETER, otherwise
 ************************************************************************/
StackRetStatus_t mote_set_parameters(IsmBand_t ismBand, const uint16_t index);

/*********************************************************************//*
 \brief      Function to Initialize the Multicast parameters
 ************************************************************************/
void set_multicast_params (void);

/*********************************************************************//**
 \brief      Callback function for the ending of Bidirectional communication of
       Application data
 *************************************************************************/
void demo_appdata_callback(void *appHandle, appCbParams_t *data);

/*********************************************************************//*
 \brief      Callback function for the ending of Activation procedure
 ************************************************************************/
void demo_joindata_callback(StackRetStatus_t status);

/*********************************************************************//*
 \brief      Function to Print stack default parameters
 ************************************************************************/
void print_default_parameters(void);

/*********************************************************************//*
 \brief      Function to Print application configuration
 ************************************************************************/
void  print_application_config (void);

/*********************************************************************//*
 \brief      Function to Print array of characters
 \param[in]  *array  - Pointer of the array to be printed
 \param[in]   length - Length of the array
 ************************************************************************/
void print_array (uint8_t *data, uint8_t length);

/*********************************************************************//*
 \brief      Function to Print stack return status
 \param[in]  status - Status from the stack
 ************************************************************************/
void print_stack_status(StackRetStatus_t status);

/*********************************************************************//*
 \brief      Function to Check stack return status
 \param[in]  Void
 ************************************************************************/
void check_stack_status(void);

/*********************************************************************//**
\brief    Pulls the data from UART when activated
*************************************************************************/
void serial_data_handler(void);

/*********************************************************************//**
\brief    Pulls data from UART and concatenates to appropriate EUI/Key
*************************************************************************/
void serial_read_appConfig(uint8_t *buffer, uint8_t noOfBytes);

/*********************************************************************//**
\brief    ASCII input to Decimal Converter. Range of ascii handled (0,F/f)
*************************************************************************/
uint8_t asciiToDecConverter(uint8_t input);

#endif /* DEMO_APP_H_ */
