Microchip® Advanced Software Framework

api_parser.c File Reference

RF4CE API parser.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include "compiler.h"
#include "nwk_msg_code.h"
#include "app_config.h"
#include "conf_sio2ncp.h"
#include "sio2ncp.h"
#include "api_parser.h"
#include "rf4ce.h"
#include "pb_pairing.h"
#include "zrc.h"
#include "vendor_data.h"
#include "nwk_config.h"
#define SOT   (1)
 The start of transmission delimiter. More...
 
#define EOT   (4)
 The end of transmission delimiter. More...
 
#define UART_RX_STATE_SOT   (1)
 A UART state that expects a SOT to be received as the next character. More...
 
#define UART_RX_STATE_LENGTH   (2)
 A UART state that expects the length to be received as the next character. More...
 
#define UART_RX_PROTOCOL_ID   (3)
 A UART state that expects the length to be received as the next character. More...
 
#define UART_RX_STATE_DATA   (4)
 A UART state that expects the next data character to be received. More...
 
#define UART_RX_STATE_EOT   (5)
 A UART state that expects a EOT to be received as the next character. More...
 
#define SIO_BUF_COUNT   (2)
 
#define SIO_RX2NCP_BUF_SIZE   (200)
 
#define SIO_TX_BUF_SIZE   SIO_RX2NCP_BUF_SIZE
 
#define GET_NIB_ATTR_SIZE(x)
 Gets attribute size by reading from a table stored in flash. More...
 
static uint8_t sio_rx_buf [SIO_RX2NCP_BUF_SIZE]
 This is the receive buffer of the UART. More...
 
static uint8_t sio_tx_buf [SIO_BUF_COUNT][SIO_TX_BUF_SIZE]
 This is the transmit buffer of the UART. More...
 
static uint8_t * sio_rx_ptr
 This pointer points to the next free element inside the receive buffer of the UART. More...
 
static volatile uint8_t sio_rx_state
 This is the receiver state of the UART. More...
 
static uint8_t sio_rx_length
 This is the length of the message should be received. More...
 
static uint8_t data [20]
 This is the length of the message should be transmitted. More...
 
static uint8_t data_length
 
static uint8_t rx_index
 
static uint8_t head
 
static uint8_t buf_count
 
static uint8_t protocol_id
 
static zrc_indication_callback_t zrc_ind_cb
 
static nwk_indication_callback_t nwk_ind_callback
 
nlme_start_confirm_cb_t nlme_start_confirm_cb
 
nlme_reset_confirm_cb_t nlme_reset_confirm_cb
 
nlme_rx_enable_confirm_cb_t nlme_rx_enable_confirm_cb
 
nlde_data_confirm_cb_t nlde_data_confirm_cb
 
nlme_auto_discovery_confirm_cb_t nlme_auto_discovery_confirm_cb
 
nlme_update_key_confirm_cb_t nlme_update_key_confirm_cb
 
nwk_ch_agility_confirm_cb_t nwk_ch_agility_confirm_cb
 
pbp_org_pair_confirm_cb_t pbp_org_pair_confirm_cb
 
pbp_rec_pair_confirm_cb_t pbp_rec_pair_confirm_cb
 
zrc_cmd_disc_confirm_cb_t zrc_cmd_disc_confirm_cb
 
static void process_incoming_data (void)
 
static uint8_t * get_next_tx_buffer (void)
 
static void handle_incoming_msg (void)
 
void serial_api_init (void)
 This function does the initialization of the SIO or UART. More...
 
nwk_enum_t nwk_init (void)
 Initialization of RF4CE network layer. More...
 
bool nwk_task (void)
 Function to handle the state machine serial data exchange. More...
 
bool nlme_reset_request (bool SetDefaultNIB, FUNC_PTR confirm_cb)
 NLME-RESET.request primitive API. More...
 
bool nlde_data_request (uint8_t PairingRef, profile_id_t ProfileId, uint16_t VendorId, uint8_t nsduLength, uint8_t *nsdu, uint8_t TxOptions, uint8_t Handle, FUNC_PTR confirm_cb)
 NLDE-DATA.request primitive API. More...
 
bool nlme_auto_discovery_request (uint8_t RecAppCapabilities, dev_type_t RecDevTypeList[DEVICE_TYPE_LIST_SIZE], profile_id_t RecProfileIdList[PROFILE_ID_LIST_SIZE], uint32_t AutoDiscDuration, FUNC_PTR confirm_cb)
 
bool nlme_discovery_request (uint16_t DstPANId, uint16_t DstNwkAddr, uint8_t OrgAppCapabilities, dev_type_t OrgDevTypeList[3], profile_id_t OrgProfileIdList[7], dev_type_t SearchDevType, uint8_t DiscProfileIdListSize, profile_id_t DiscProfileIdList[7], uint32_t DiscDuration, FUNC_PTR confirm_cb)
 NLME-DISCOVERY.request primitive API. More...
 
bool nlme_discovery_response (nwk_enum_t Status, uint64_t DstIEEEAddr, uint8_t RecAppCapabilities, dev_type_t RecDevTypeList[3], profile_id_t RecProfileIdList[7], uint8_t DiscReqLQI)
 NLME-DISCOVERY.response primitive API. More...
 
bool nlme_pair_request (uint8_t LogicalChannel, uint16_t DstPANId, uint64_t DstIEEEAddr, uint8_t OrgAppCapabilities, dev_type_t OrgDevTypeList[DEVICE_TYPE_LIST_SIZE], profile_id_t OrgProfileIdList[PROFILE_ID_LIST_SIZE], uint8_t KeyExTransferCount, FUNC_PTR confirm_cb)
 
bool nlme_pair_response (nwk_enum_t Status, uint16_t DstPANId, uint64_t DstIEEEAddr, uint8_t RecAppCapabilities, dev_type_t RecDevTypeList[3], profile_id_t RecProfileIdList[7], uint8_t ProvPairingRef)
 NLME-PAIR.response primitive API. More...
 
bool nlme_get_request (nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex, FUNC_PTR confirm_cb)
 NLME-GET.request primitive API. More...
 
bool nlme_rx_enable_request (uint32_t RxOnDuration, FUNC_PTR confirm_cb)
 NLME-RX-ENABLE.request primitive API. More...
 
bool nlme_set_request (nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex, uint8_t *NIBAttributeValue, FUNC_PTR confirm_cb)
 NLME-SET.request primitive API. More...
 
bool nlme_start_request (FUNC_PTR confirm_cb)
 NLME-START.request primitive API. More...
 
bool nlme_unpair_request (uint8_t PairingRef, FUNC_PTR confirm_cb)
 NLME-UNPAIR.request primitive API. More...
 
bool nlme_unpair_response (uint8_t PairingRef)
 NLME-UNPAIR.response primitive API. More...
 
bool nlme_update_key_request (uint8_t PairingRef, uint8_t NewLinkKey[16], FUNC_PTR confirm_cb)
 NLME-UPDATE-KEY.request primitive API. More...
 
bool nwk_ch_agility_request (nwk_agility_mode_t AgilityMode, FUNC_PTR confirm_cb)
 Sets channel agility mode. More...
 
bool pbp_org_pair_request (uint8_t OrgAppCapabilities, dev_type_t OrgDevTypeList[DEVICE_TYPE_LIST_SIZE], profile_id_t OrgProfileIdList[PROFILE_ID_LIST_SIZE], dev_type_t SearchDevType, uint8_t DiscProfileIdListSize, profile_id_t DiscProfileIdList[PROFILE_ID_LIST_SIZE], FUNC_PTR confirm_cb)
 
bool pbp_rec_pair_request (uint8_t RecAppCapabilities, dev_type_t RecDevTypeList[3], profile_id_t RecProfileIdList[7], FUNC_PTR confirm_cb)
 Recipient pair request; target use. More...
 
bool zrc_cmd_request (uint8_t PairingRef, uint16_t VendorId, zrc_cmd_code_t CmdCode, uint8_t CmdLength, uint8_t *Cmd, uint8_t TxOptions, FUNC_PTR confirm_cb)
 Handles the key press from the application. More...
 
bool zrc_cmd_disc_request (uint8_t PairingRef, FUNC_PTR confirm_cb)
 Handles the cmd discovery request. More...
 
bool zrc_cmd_disc_response (uint8_t PairingRef, uint8_t *SupportedCmd)
 Send out the cmd discovery response. More...
 
void register_nwk_indication_callback (nwk_indication_callback_t *nwk_ind_cb)
 Registering network indication callback. More...
 
void register_zrc_indication_callback (zrc_indication_callback_t *zrc_ind_callback)
 Registering zrc indication callback. More...
 
uint8_t nwk_get_nib_attribute_size (uint8_t nib_attribute_id)
 Gets the NIB attribute value size. More...