Microchip® Advanced Software Framework

mac_scan.c File Reference
#include <compiler.h>
#include <string.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "return_val.h"
#include "pal.h"
#include "bmm.h"
#include "qmm.h"
#include "tal.h"
#include "ieee_const.h"
#include "mac_msg_const.h"
#include "mac_api.h"
#include "mac_msg_types.h"
#include "mac_data_structures.h"
#include "stack_config.h"
#include "mac_internal.h"
#include "mac.h"
#include "mac_config.h"
#include "mac_build_config.h"

Macros

#define BEAC_REQ_ORPH_NOT_PAYLOAD_LEN   (1)
 
#define BEACON_NETWORK_MAX_BO   (14)
 
#define MAC_CALCULATE_SYMBOL_TIME_SCANDURATION(SD)   (aBaseSuperframeDuration * ((1UL << (SD)) + 1))
 Scan duration formula: \(aBaseSuperframeDuration (2^SD + 1)\) where \(0 <= SD <= 14\). More...
 

Functions

static void mac_awake_scan (buffer_t *buff_ptr)
 
void mac_process_orphan_realign (buffer_t *buf_ptr)
 Processing a coordinator realignment command frame during Orphan scan. More...
 
void mac_scan_send_complete (retval_t status)
 Continue scanning after the completion of frame transmission. More...
 
static void mac_t_scan_duration_cb (void *callback_parameter)
 
void mlme_scan_request (uint8_t *m)
 The MLME-SCAN.request primitive makes a request for a node to start a scan procedure. More...
 
static void scan_clean_up (buffer_t *buf)
 
static void scan_proceed (uint8_t scanning_type, buffer_t *buf)
 
static void scan_set_complete (retval_t set_status)
 Continue scanning after setting of PIB attributes. More...
 
static bool send_scan_cmd (bool beacon_req)
 Send a beacon request or orphan notification command frame. More...
 
void tal_ed_end_cb (uint8_t energy_level)
 ED scan callback function. More...
 

Variables

static uint32_t scan_channels
 
static uint8_t scan_curr_channel
 
static uint8_t scan_curr_page
 
static uint8_t scan_duration
 
static uint8_t scan_type
 

#define BEAC_REQ_ORPH_NOT_PAYLOAD_LEN   (1)

Referenced by send_scan_cmd().

#define BEACON_NETWORK_MAX_BO   (14)

Referenced by mlme_scan_request().

#define MAC_CALCULATE_SYMBOL_TIME_SCANDURATION (   SD)    (aBaseSuperframeDuration * ((1UL << (SD)) + 1))

Scan duration formula: \(aBaseSuperframeDuration (2^SD + 1)\) where \(0 <= SD <= 14\).

Referenced by mac_scan_send_complete(), and scan_set_complete().

void scan_set_complete ( retval_t  set_status)
static

Continue scanning after setting of PIB attributes.

This functions continues scanning once the corresponding PIB attribute change has been completed depending on the status.

Parameters
set_statusStatus of the Request to change the PIB attribute

References Assert, FUNC_PTR, MAC_CALCULATE_SYMBOL_TIME_SCANDURATION, mac_conf_buf_ptr, MAC_SCAN_ACTIVE, MAC_SCAN_ED, MAC_SCAN_ORPHAN, MAC_SCAN_PASSIVE, mac_scan_state, MAC_SUCCESS, mac_t_scan_duration_cb(), MAKE_MAC_BUSY, MLME_SCAN_TYPE_PASSIVE, pal_timer_start(), PHY_RX_ON, scan_curr_channel, scan_duration, scan_proceed(), send_scan_cmd(), T_Scan_Duration, TAL_CONVERT_SYMBOLS_TO_US, tal_ed_start(), tal_rx_enable(), and TIMEOUT_RELATIVE.

Referenced by mac_process_orphan_realign(), and scan_proceed().

static bool send_scan_cmd ( bool  beacon_req)
static

Send a beacon request or orphan notification command frame.

This function sends a beacon request or orphan notification command frame. An MPDU containing either a beacon request or an orphan notification command frame is constructed and sent.

Parameters
beacon_reqTrue if a beacon request command frame shall be sent, otherwise (false) an orphan notification command frame will be sent.
Returns
True if the frame transmission has been initiated, false otherwise.

References BEAC_REQ_ORPH_NOT_PAYLOAD_LEN, BEACONREQUEST, BMM_BUFFER_POINTER, BROADCAST, frame_info_tag::buffer_header, convert_16_bit_to_byte_array(), convert_64_bit_to_byte_array(), convert_spec_16_bit_to_byte_array(), CSMA_UNSLOTTED, FCF_FRAMETYPE_MAC_CMD, FCF_LONG_ADDR, FCF_NO_ADDR, FCF_PAN_ID_COMPRESSION, FCF_SET_DEST_ADDR_MODE, FCF_SET_FRAMETYPE, FCF_SET_SOURCE_ADDR_MODE, FCF_SHORT_ADDR, LARGE_BUFFER_SIZE, mac_pib_tag::mac_DSN, mac_pib, mac_scan_cmd_buf_ptr, MAC_SUCCESS, MAKE_MAC_BUSY, frame_info_tag::mpdu, frame_info_tag::msg_type, NO_CSMA_NO_IFS, ORPHANNOTIFICATION, tal_pib, and tal_tx_frame().

Referenced by scan_set_complete().

void tal_ed_end_cb ( uint8_t  energy_level)

ED scan callback function.

User call back function for finished ED Scan.

This function is a callback function from the TAL after ED scan is performed on a specified channel.

Parameters
energy_levelMaximum energy on the channel

References BMM_BUFFER_POINTER, scan_result_list_t::ed_value, mac_conf_buf_ptr, MAKE_MAC_NOT_BUSY, MLME_SCAN_TYPE_ED, mlme_scan_conf_tag::ResultListSize, scan_curr_channel, scan_proceed(), mlme_scan_conf_tag::scan_result_list, and mlme_scan_conf_tag::UnscannedChannels.

Referenced by ed_scan_done().

uint32_t scan_channels
static
uint8_t scan_curr_page
static
uint8_t scan_duration
static