Microchip® Advanced Software Framework

mac_internal.h File Reference

Declares MAC internal functions, globals, and macros.

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

#include "pal.h"
#include "tal.h"
#include "ieee_const.h"
#include "mac_data_structures.h"
#include "return_val.h"

Data Structures

struct  mac_pib_tag
 

Macros

#define BO_USED_FOR_MAC_PERS_TIME   (0)
 
#define FINAL_CAP_SLOT_DEFAULT   (0x0F)
 
#define macAckWaitDuration_def   (54)
 Default value for MIB macAckWaitDuration. More...
 
#define macMaxFrameTotalWaitTime_def   (1986)
 
#define MAKE_MAC_BUSY()
 This macro sets the MAC to busy. More...
 
#define MAKE_MAC_NOT_BUSY()
 This macro sets the MAC to not busy. More...
 

Typedefs

typedef void(* handler_t )(uint8_t *)
 
typedef struct mac_pib_tag mac_pib_t
 
typedef enum mac_poll_state_tag mac_poll_state_t
 MAC poll states. More...
 
typedef enum
mac_radio_sleep_state_tag 
mac_radio_sleep_state_t
 MAC sleep state type. More...
 
typedef enum mac_scan_state_tag mac_scan_state_t
 Device or coordinator scan states. More...
 
typedef __PACK__DATA__ enum
mac_state_tag 
mac_state_t
 MAC state type. More...
 
typedef enum
mac_superframe_state_tag 
mac_superframe_state_t
 MAC state type. More...
 
typedef enum mac_sync_state_tag mac_sync_state_t
 Device or coordinator sync states. More...
 

Enumerations

enum  mac_poll_state_tag {
  MAC_POLL_IDLE = 0,
  MAC_AWAIT_ASSOC_RESPONSE,
  MAC_POLL_EXPLICIT,
  MAC_POLL_IMPLICIT
}
 MAC poll states. More...
 
enum  mac_radio_sleep_state_tag {
  RADIO_AWAKE = 0,
  RADIO_SLEEPING
}
 MAC sleep state type. More...
 
enum  mac_scan_state_tag {
  MAC_SCAN_IDLE = 0,
  MAC_SCAN_ED,
  MAC_SCAN_ACTIVE,
  MAC_SCAN_ORPHAN,
  MAC_SCAN_PASSIVE
}
 Device or coordinator scan states. More...
 
enum  mac_state_tag {
  MAC_IDLE = 0,
  MAC_ASSOCIATED = 1,
  MAC_COORDINATOR = 2,
  MAC_PAN_COORD_STARTED = 3
}
 MAC state type. More...
 
enum  mac_superframe_state_tag {
  MAC_ACTIVE_CAP = 0,
  MAC_INACTIVE,
  MAC_NOBEACON
}
 MAC state type. More...
 
enum  mac_sync_state_tag {
  MAC_SYNC_NEVER = 0,
  MAC_SYNC_ONCE,
  MAC_SYNC_TRACKING_BEACON,
  MAC_SYNC_BEFORE_ASSOC
}
 Device or coordinator sync states. More...
 

Functions

void dispatch_event (uint8_t *event)
 Obtains the message type from the buffer and calls the respective handler. More...
 
void mac_build_and_tx_beacon (bool beacon_enabled, buffer_t *beacon_buffer_header)
 Builds and transmits the beacon frame. More...
 
bool mac_build_and_tx_data_req (bool expl_poll, bool force_own_long_addr, uint8_t expl_dest_addr_mode, address_field_t *expl_dest_addr, uint16_t expl_dest_pan_id)
 Build and transmits data request command frame. More...
 
static void mac_check_persistence_timer (void)
 
void mac_coord_realignment_command_tx_success (uint8_t tx_status, buffer_t *buf_ptr)
 Continues handling of MLME_START.request (Coordinator realignment) command. More...
 
void mac_gen_mcps_data_conf (buffer_t *buf_ptr, uint8_t status, uint8_t handle, uint32_t timestamp)
 
void mac_gen_mlme_associate_conf (buffer_t *buf_ptr, uint8_t status, uint16_t assoc_short_addr)
 
void mac_handle_tx_null_data_frame (void)
 
void mac_idle_trans (void)
 Resets the MAC helper variables and transition to idle state. More...
 
void mac_mlme_comm_status (uint8_t status, buffer_t *buf_ptr)
 Creates a Communication Status Indication message to the upper layer. More...
 
void mac_prep_disassoc_conf (buffer_t *buf_ptr, uint8_t status)
 Prepares a disassociation confirm message with device address information. More...
 
void mac_process_associate_request (buffer_t *buf_ptr)
 Processes a received association request command frame. More...
 
void mac_process_associate_response (buffer_t *buf_ptr)
 Processing of an associaton reponse command frame. More...
 
void mac_process_beacon_frame (buffer_t *msg)
 Processes received beacon frame. More...
 
void mac_process_beacon_request (buffer_t *buf_ptr)
 Processes a beacon request. More...
 
void mac_process_coord_realign (buffer_t *buf_ptr)
 Processing a coordinator realignment command frame. More...
 
void mac_process_data_frame (buffer_t *buf_ptr)
 Processes data frames. More...
 
void mac_process_data_request (buffer_t *buf_ptr)
 Processes a received data request command frame. More...
 
void mac_process_data_response (void)
 Processes a data response to an MLME-POLL.request. More...
 
void mac_process_disassociate_notification (buffer_t *buf_ptr)
 Process a disassociation notification command. More...
 
void mac_process_orphan_notification (buffer_t *buf_ptr)
 Handles an orphan notification. More...
 
void mac_process_orphan_realign (buffer_t *buf_ptr)
 Processing a coordinator realignment command frame during Orphan scan. More...
 
void mac_process_tal_data_ind (uint8_t *msg)
 Depending on received frame the appropriate function is called. More...
 
void mac_scan_send_complete (retval_t status)
 Continue scanning after the completion of frame transmission. More...
 
void mac_sleep_trans (void)
 Puts the radio to sleep if this is allowed. More...
 
void mac_start_persistence_timer (void)
 
void mac_sync_loss (uint8_t loss_reason)
 Function to initiate MLME-SYNC-LOSS.indication to NHLE. More...
 
void mac_t_assocresponsetime_cb (void *callback_parameter)
 
void mac_t_poll_wait_time_cb (void *callback_parameter)
 T_Poll_Wait_Time timer callback. More...
 
void mac_t_response_wait_cb (void *callback_parameter)
 Handle T_Poll_Wait_Time timer after successful transmission of an association request frame and before sending out the subsequent data request frame. More...
 
void mac_trx_init_sleep (void)
 MAC function to put the radio to sleep mode. More...
 
void mac_trx_wakeup (void)
 MAC function to wake-up the radio from sleep state. More...
 
bool mac_tx_coord_realignment_command (frame_msgtype_t cmd_type, buffer_t *buf_ptr, uint16_t new_panid, uint8_t new_channel, uint8_t new_page)
 Sends a coordinator realignment command frame. More...
 
retval_t set_tal_pib_internal (uint8_t attribute, pib_value_t *attribute_value)
 Wakes-up the radio and sets the corresponding TAL PIB attribute. More...
 

Variables

queue_t indirect_data_q
 Queue used by MAC layer to put in indirect data. More...
 
uint8_t mac_beacon_payload []
 Holds the contents of the beacon payload. More...
 
bool mac_busy
 MAC busy state, indicates whether MAC can process any request from NHLE. More...
 
__PACK__RST_DATA__ uint8_t * mac_conf_buf_ptr
 Holds the mlme request buffer pointer, used to give the respective confirmation in scan, poll and association. More...
 
uint8_t mac_last_dsn
 
uint64_t mac_last_src_addr
 
parse_t mac_parse_data
 Global parse data. More...
 
mac_pib_t mac_pib
 
mac_poll_state_t mac_poll_state
 Current state of MAC poll state machine, e.g. More...
 
mac_radio_sleep_state_t mac_radio_sleep_state
 Radio sleep state. More...
 
bool mac_rx_enabled
 
uint8_t * mac_scan_cmd_buf_ptr
 Holds the buffer pointer which is used to send scan command. More...
 
uint8_t mac_scan_orig_channel
 Stores the original channel before start of scanning. More...
 
uint8_t mac_scan_orig_page
 Stores the original channel page before start of scanning. More...
 
uint16_t mac_scan_orig_panid
 Stores the original PAN-Id before start of scanning. More...
 
mac_scan_state_t mac_scan_state
 Current state of scanning process. More...
 
mac_state_t mac_state
 Current state of the MAC state machine. More...
 
mac_sync_state_t mac_sync_state
 Current state of syncronization with parent (either coordinator or PAN coordinator). More...
 
queue_t tal_mac_q
 Queue used by MAC for its internal operation. More...