Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PRIME Serial MAC

This module provides configuration and utils for the serialization of the MAC layer in PRIME.

Macros

#define NOTVALID   0
 
#define VALID   1
 

Functions

static int8_t _serial_if_mac_pack_data_conf (uint16_t us_con_handle, const uint8_t *puc_data, uint8_t uc_result, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Data.Confirm. More...
 
static int8_t _serial_if_mac_pack_data_ind (uint16_t us_con_handle, const uint8_t *puc_data, uint16_t us_data_len, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Data.Indication. More...
 
static int8_t _serial_if_mac_pack_establish_conf (uint16_t us_con_handle, uint8_t uc_reason, const uint8_t *puc_eui48_addr, uint8_t uc_type, const uint8_t *puc_data, uint16_t us_data_len, uint8_t uc_error_type)
 This function packs the MAC callback primitive Establish.Confirm. More...
 
static int8_t _serial_if_mac_pack_establish_ind (uint16_t us_con_handle, const uint8_t *puc_eui48_addr, uint8_t uc_type, const uint8_t *puc_data, uint16_t us_data_len, uint16_t us_cf_bytes, uint8_t uc_error_type)
 This function packs the MAC callback primitive Establish.Indication. More...
 
static int8_t _serial_if_mac_pack_join_conf (uint16_t us_con_handle, uint8_t uc_result, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Join.Confirm. More...
 
static int8_t _serial_if_mac_pack_join_ind_base (uint16_t us_con_handle, const uint8_t *puc_eui48_addr, uint8_t uc_type, const uint8_t *puc_data, uint16_t us_data_len, uint8_t uc_error_type)
 This function packs the MAC callback primitive Join.Indication.Base. More...
 
static int8_t _serial_if_mac_pack_join_ind_service (uint16_t us_con_handle, const uint8_t *puc_data, uint16_t us_data_len, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Join.Indication.Service. More...
 
static int8_t _serial_if_mac_pack_leave_conf (uint16_t us_con_handle, uint8_t uc_result, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Leave.Confirm. More...
 
static int8_t _serial_if_mac_pack_leave_ind_base (uint16_t us_con_handle, const uint8_t *puc_eui48_addr, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Leave.Indication.Base. More...
 
static int8_t _serial_if_mac_pack_leave_ind_service (uint16_t us_con_handle, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Leave.Indication.Service. More...
 
static int8_t _serial_if_mac_pack_release_conf (uint16_t us_con_handle, uint8_t uc_result, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Release.Confirm. More...
 
static int8_t _serial_if_mac_pack_release_ind (uint16_t us_con_handle, uint8_t uc_reason, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Release.Indication. More...
 
static int _serial_if_mac_unpack_data_req (void)
 This function extracts the MAC SAP Data.Request. More...
 
static int _serial_if_mac_unpack_establish_req (void)
 This function extracts the MAC SAP Establish.Request. More...
 
static int _serial_if_mac_unpack_establish_resp (void)
 This function extracts the MAC SAP Establish.Response. More...
 
static int _serial_if_mac_unpack_join_req_base (void)
 This function extracts the MAC SAP Join.Request.Base. More...
 
static int _serial_if_mac_unpack_join_req_service (void)
 This function extracts the MAC SAP Join.Request.Service. More...
 
static int _serial_if_mac_unpack_join_resp_base (void)
 This function extracts the MAC SAP Join.Response.Base. More...
 
static int _serial_if_mac_unpack_join_resp_service (void)
 This function extracts the MAC SAP Join.Response.Service. More...
 
static int _serial_if_mac_unpack_leave_req_base (void)
 This function extracts the MAC SAP Leave.Request.Base. More...
 
static int _serial_if_mac_unpack_leave_req_service (void)
 This function extracts the MAC SAP Leave.Request.Service. More...
 
static int _serial_if_mac_unpack_redirect_resp (void)
 This function extracts the MAC SAP Redirect.Response. More...
 
static int _serial_if_mac_unpack_release_req (void)
 This function extracts the MAC SAP Release.Request. More...
 
static int _serial_if_mac_unpack_release_resp (void)
 This function extracts the MAC SAP Release.Response. More...
 
uint8_t serial_if_mac_api_parser (uint8_t *puc_rx_msg, uint16_t us_len)
 Received message. More...
 
int8_t serial_if_mac_process (void)
 Function to encapsulate MAC Tx Control Process. More...
 

Variables

static MacSapCallBack cmd
 
static uint8_t commandMacToPack [PRIME_MACSAP_DATA_SIZE]
 
static MacSapCallBacknewMacCallBackCmd = &cmd
 
static uint8_t * puc_rx
 
static uint16_t us_rx_len
 
static uint16_t us_tx_len
 

static int8_t _serial_if_mac_pack_data_conf ( uint16_t  us_con_handle,
const uint8_t *  puc_data,
uint8_t  uc_result,
uint8_t  uc_type,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Data.Confirm.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
puc_dataPointer to the data attached to the connection request
uc_resultResult of the transmission
uc_typeType of convergence sublayer for the connection
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References MAX_PDU_SIZE, and PRIME_MACSAP_DATA_CONFIRM.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_data_ind ( uint16_t  us_con_handle,
const uint8_t *  puc_data,
uint16_t  us_data_len,
uint8_t  uc_type,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Data.Indication.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
puc_dataPointer to the data attached to the connection request
us_data_lenData length of the data attached to the request
uc_typeType of convergence sublayer for the connection
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References PRIME_MACSAP_DATA_INDICATION.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_establish_conf ( uint16_t  us_con_handle,
uint8_t  uc_reason,
const uint8_t *  puc_eui48_addr,
uint8_t  uc_type,
const uint8_t *  puc_data,
uint16_t  us_data_len,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Establish.Confirm.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
uc_reasonReason for the connection indication
puc_eui48_addrPointer to node's MAC address to set the connection
uc_typeType of convergence sublayer for the connection
puc_dataPointer to the data attached to the connection request
us_data_lenData length of the data attached to the request
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References NOTVALID, NULL, PRIME_MAC_LENGTH, PRIME_MACSAP_ESTABLISH_CONFIRM, and VALID.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_establish_ind ( uint16_t  us_con_handle,
const uint8_t *  puc_eui48_addr,
uint8_t  uc_type,
const uint8_t *  puc_data,
uint16_t  us_data_len,
uint16_t  us_cf_bytes,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Establish.Indication.

Note
Copies puc_buf[] into puc_dst[], re-ordering the bytes to adapt to the serial communication. After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
puc_eui48_addrPointer to node's MAC address to set the connection
uc_typeType of convergence sublayer for the connection
puc_dataPointer to the data attached to the connection request
us_data_lenData length of the data attached to the request
us_cf_bytesNumber of CFP Bytes to be allocated for the conecction
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References NOTVALID, NULL, PRIME_MAC_LENGTH, PRIME_MACSAP_ESTABLISH_INDICATION, and VALID.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_join_conf ( uint16_t  us_con_handle,
uint8_t  uc_result,
uint8_t  uc_type,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Join.Confirm.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
uc_resultResult to the join indication
uc_typeType of convergence sublayer for the connection
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References PRIME_MACSAP_JOIN_CONFIRM.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_join_ind_base ( uint16_t  us_con_handle,
const uint8_t *  puc_eui48_addr,
uint8_t  uc_type,
const uint8_t *  puc_data,
uint16_t  us_data_len,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Join.Indication.Base.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
puc_eui48_addrPointer to node's MAC address to set the connection
uc_typeType of convergence sublayer for the connection
puc_dataPointer to the data attached to the connection request
us_data_lenData length of the data attached to the request
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References NOTVALID, NULL, PRIME_MAC_LENGTH, PRIME_MACSAP_JOIN_INDICATION_BASE, and VALID.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_join_ind_service ( uint16_t  us_con_handle,
const uint8_t *  puc_data,
uint16_t  us_data_len,
uint8_t  uc_type,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Join.Indication.Service.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
puc_dataPointer to the data attached to the connection request
us_data_lenData length of the data attached to the request
uc_typeType of convergence sublayer for the connection
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References PRIME_MACSAP_JOIN_INDICATION_SERVICE.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_leave_conf ( uint16_t  us_con_handle,
uint8_t  uc_result,
uint8_t  uc_type,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Leave.Confirm.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
uc_resultResult for the leave indication
uc_typeType of convergence sublayer for the connection
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References PRIME_MACSAP_LEAVE_CONFIRM.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_leave_ind_base ( uint16_t  us_con_handle,
const uint8_t *  puc_eui48_addr,
uint8_t  uc_type,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Leave.Indication.Base.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
puc_eui48_addrPointer to node's MAC address to set the connection
uc_typeType of convergence sublayer for the connection
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References NOTVALID, NULL, PRIME_MAC_LENGTH, PRIME_MACSAP_LEAVE_INDICATION_BASE, and VALID.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_leave_ind_service ( uint16_t  us_con_handle,
uint8_t  uc_type,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Leave.Indication.Service.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
uc_typeType of convergence sublayer for the connection
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References PRIME_MACSAP_LEAVE_INDICATION_SERVICE.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_release_conf ( uint16_t  us_con_handle,
uint8_t  uc_result,
uint8_t  uc_type,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Release.Confirm.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
uc_resultResult of the release
uc_typeType of convergence sublayer for the connection
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References PRIME_MACSAP_RELEASE_CONFIRM.

Referenced by serial_if_mac_process().

static int8_t _serial_if_mac_pack_release_ind ( uint16_t  us_con_handle,
uint8_t  uc_reason,
uint8_t  uc_type,
uint8_t  uc_error_type 
)
static

This function packs the MAC callback primitive Release.Indication.

Note
After packing, it requests the sending to the CS layer.
Parameters
us_con_handleConnection handler
uc_reasonReason for the release
uc_typeType of convergence sublayer for the connection
uc_error_typeError type
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References PRIME_MACSAP_RELEASE_INDICATION.

Referenced by serial_if_mac_process().

static int _serial_if_mac_unpack_data_req ( void  )
static

This function extracts the MAC SAP Data.Request.

Note
This function extracts the MAC SAP Data.Request from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::buf, MacSapCallBack::bufLength, MacSapCallBack::handler, prime_MAC_DATA_request(), MacSapCallBack::priority, and puc_rx.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_establish_req ( void  )
static

This function extracts the MAC SAP Establish.Request.

Note
This function extracts the MAC SAP Establish.Request from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::arq, MacSapCallBack::buf, MacSapCallBack::bufLength, MacSapCallBack::cfpBytes, MacSapCallBack::macAddr, prime_MAC_ESTABLISH_request(), PRIME_MAC_LENGTH, puc_rx, MacSapCallBack::type, and VALID.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_establish_resp ( void  )
static

This function extracts the MAC SAP Establish.Response.

Note
This function extracts the MAC SAP Establish.Response from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::answer, MacSapCallBack::buf, MacSapCallBack::bufLength, MacSapCallBack::handler, prime_MAC_ESTABLISH_response(), and puc_rx.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_join_req_base ( void  )
static

This function extracts the MAC SAP Join.Request.Base.

Note
This function extracts the MAC SAP Join.Request.Base from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::broadcast, MacSapCallBack::buf, MacSapCallBack::bufLength, MacSapCallBack::handler, MacSapCallBack::macAddr, prime_MAC_JOIN_request_base(), PRIME_MAC_LENGTH, puc_rx, and MacSapCallBack::type.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_join_req_service ( void  )
static

This function extracts the MAC SAP Join.Request.Service.

Note
This function extracts the MAC SAP Join.Request.Service from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::broadcast, MacSapCallBack::buf, MacSapCallBack::bufLength, prime_MAC_JOIN_request_service(), puc_rx, and MacSapCallBack::type.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_join_resp_base ( void  )
static

This function extracts the MAC SAP Join.Response.Base.

Note
This function extracts the MAC SAP Join.Response.Base from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::answer, MacSapCallBack::handler, MacSapCallBack::macAddr, prime_MAC_JOIN_response_base(), PRIME_MAC_LENGTH, and puc_rx.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_join_resp_service ( void  )
static

This function extracts the MAC SAP Join.Response.Service.

Note
This function extracts the MAC SAP Join.Response.Service from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::answer, MacSapCallBack::handler, prime_MAC_JOIN_response_service(), and puc_rx.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_leave_req_base ( void  )
static

This function extracts the MAC SAP Leave.Request.Base.

Note
This function extracts the MAC SAP Leave.Request.Base from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::handler, MacSapCallBack::macAddr, prime_MAC_LEAVE_request_base(), PRIME_MAC_LENGTH, and puc_rx.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_leave_req_service ( void  )
static

This function extracts the MAC SAP Leave.Request.Service.

Note
This function extracts the MAC SAP Leave.Request.Service from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::handler, prime_MAC_LEAVE_request_service(), and puc_rx.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_redirect_resp ( void  )
static

This function extracts the MAC SAP Redirect.Response.

Note
This function extracts the MAC SAP Redirect.Response from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::buf, MacSapCallBack::bufLength, MacSapCallBack::handler, MacSapCallBack::macAddr, PRIME_MAC_LENGTH, prime_MAC_REDIRECT_response(), and puc_rx.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_release_req ( void  )
static

This function extracts the MAC SAP Release.Request.

Note
This function extracts the MAC SAP Release.Request from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::handler, prime_MAC_RELEASE_request(), and puc_rx.

Referenced by serial_if_mac_api_parser().

static int _serial_if_mac_unpack_release_resp ( void  )
static

This function extracts the MAC SAP Release.Response.

Note
This function extracts the MAC SAP Release.Response from the received packet and stores the data in the circular buffer if possible.
Return values
0primitive stored
-1primitive could not be stored

References MacSapCallBack::answer, MacSapCallBack::handler, prime_MAC_RELEASE_response(), and puc_rx.

Referenced by serial_if_mac_api_parser().

int8_t serial_if_mac_process ( void  )

Function to encapsulate MAC Tx Control Process.

Note
This function will be called using a pointer.
Return values
0if the request has been made to the CS layer
-1if it was unable to pass the request to the CS layer

References _serial_if_mac_pack_data_conf(), _serial_if_mac_pack_data_ind(), _serial_if_mac_pack_establish_conf(), _serial_if_mac_pack_establish_ind(), _serial_if_mac_pack_join_conf(), _serial_if_mac_pack_join_ind_base(), _serial_if_mac_pack_join_ind_service(), _serial_if_mac_pack_leave_conf(), _serial_if_mac_pack_leave_ind_base(), _serial_if_mac_pack_leave_ind_service(), _serial_if_mac_pack_release_conf(), _serial_if_mac_pack_release_ind(), MacSapCallBack::answer, MacSapCallBack::buf, MacSapCallBack::bufLength, MacSapCallBack::cfpBytes, MacSapCallBack::command, MacSapCallBack::errorType, GENERIC_CALLBACK_HANDLER, GENERIC_CALLBACK_TYPE, MacSapCallBack::handler, MacSapCallBack::macAddr, NULL, prime_MAC_callback(), PRIME_MACSAP_DATA_CONFIRM, PRIME_MACSAP_DATA_INDICATION, PRIME_MACSAP_ESTABLISH_CONFIRM, PRIME_MACSAP_ESTABLISH_INDICATION, PRIME_MACSAP_JOIN_CONFIRM, PRIME_MACSAP_JOIN_INDICATION_BASE, PRIME_MACSAP_JOIN_INDICATION_SERVICE, PRIME_MACSAP_LEAVE_CONFIRM, PRIME_MACSAP_LEAVE_INDICATION_BASE, PRIME_MACSAP_LEAVE_INDICATION_SERVICE, PRIME_MACSAP_RELEASE_CONFIRM, PRIME_MACSAP_RELEASE_INDICATION, PROTOCOL_MAC_PRIME, x_usi_serial_cmd_params_t::ptr_buf, MacSapCallBack::type, x_usi_serial_cmd_params_t::uc_protocol_type, x_usi_serial_cmd_params_t::us_len, us_tx_len, and usi_send_cmd().

uint8_t commandMacToPack[PRIME_MACSAP_DATA_SIZE]
static
MacSapCallBack* newMacCallBackCmd = &cmd
static
uint16_t us_rx_len
static
uint16_t us_tx_len
static

Referenced by serial_if_mac_process().