# TASK_APM
[APM]

Declaration of all structures and functions used by the APM module. More...

Collaboration diagram for TASK_APM:

## Data Structures
struct | apm_start_req
| Structure containing the parameters of the APM_START_REQ message. More...
struct | apm_start_cfm
| Structure containing the parameters of the APM_START_CFM message. More...
struct | apm_stop_req
| Structure containing the parameters of the APM_STOP_REQ message. More...
struct | apm_start_cac_req
| Structure containing the parameters of the APM_START_CAC_REQ message. More...
struct | apm_start_cac_cfm
| Structure containing the parameters of the APM_START_CAC_CFM message. More...
struct | apm_stop_cac_req
| Structure containing the parameters of the APM_STOP_CAC_REQ message. More...
## Defines
#define | APM_IDX_MAX 1
| Task max index number.
## Enumerations
enum | apm_state_tag { APM_IDLE, APM_BSS_PARAM_SETTING, APM_BCN_SETTING, APM_STOPPING, APM_STATE_MAX }
| Possible states of the task. More...
enum | apm_msg_tag { APM_START_REQ = KE_FIRST_MSG(TASK_APM), APM_START_CFM, APM_STOP_REQ, APM_STOP_CFM, APM_START_CAC_REQ, APM_START_CAC_CFM, APM_STOP_CAC_REQ, APM_STOP_CAC_CFM }
| Messages that are logically related to the task. More...
## Functions
static int | apm_start_req_handler (ke_msg_id_t const msgid, struct apm_start_req *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| APM module message handler.
static int | me_set_ps_disable_cfm_handler (ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| APM module message handler.
static int | mm_bss_param_setting_handler (ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| APM module message handler.
static int | me_set_active_cfm_handler (ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| APM module message handler.
static int | mm_bcn_change_cfm_handler (ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| APM module message handler.
static int | mm_chan_ctxt_unlink_cfm_handler (ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| MM_CHAN_CTXT_UNLINK_CFM message handler.
static int | mm_set_vif_state_cfm_handler (ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| MM_SET_VIF_STATE_CFM message handler.
static int | apm_stop_req_handler (ke_msg_id_t const msgid, struct apm_stop_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| APM module message handler.
static int | apm_start_cac_req_handler (ke_msg_id_t const msgid, struct apm_start_cac_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| APM module message handler.
static int | apm_stop_cac_req_handler (ke_msg_id_t const msgid, struct apm_stop_cac_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| APM module message handler.
## Variables
struct ke_msg_handler | apm_default_state []
| DEFAULT handler definition.
struct ke_state_handler | apm_default_handler
| Specifies the message handlers that are common to all states.
ke_state_t | apm_state [APM_IDX_MAX]
| Defines the placeholder for the states of all the task instances.
struct ke_state_handler | apm_default_handler
| Specifies the message handlers that are common to all states.
ke_state_t | apm_state [APM_IDX_MAX]
| Defines the placeholder for the states of all the task instances.

## Detailed Description

Declaration of all structures and functions used by the APM module.

## Enumeration Type Documentation

enum apm_msg_tag

Messages that are logically related to the task.

Enumerator:

  APM_START_REQ | Request to start the AP.
  APM_START_CFM | Confirmation of the AP start.
  APM_STOP_REQ | Request to stop the AP.
  APM_STOP_CFM | Confirmation of the AP stop.
  APM_START_CAC_REQ | Request to start CAC.
  APM_START_CAC_CFM | Confirmation of the CAC start.
  APM_STOP_CAC_REQ | Request to stop CAC.
  APM_STOP_CAC_CFM | Confirmation of the CAC stop.

Definition at line 55 of file apm_task.h.

enum apm_state_tag

Possible states of the task.

Enumerator:

  APM_IDLE | IDLE State.
  APM_BSS_PARAM_SETTING | Waiting for BSS parameter setting.
  APM_BCN_SETTING | Waiting for the beacon to be set to LMAC.
  APM_STOPPING | Waiting for the AP to be stopped.
  APM_STATE_MAX | Number of states.

Definition at line 40 of file apm_task.h.

## Function Documentation

static int apm_start_cac_req_handler | ( | ke_msg_id_t const | msgid,
|  | struct apm_start_cac_req const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

APM module message handler.

This function handles the message APM_AP_START_CAC_REQ from SME. This message requests the UMAC to start listening on the specified channel until APM_AP_STOP_CAC_REQ is received. CAC (Channel Availability Check) is done to check for radar before starting an AP on a DFS channel

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 399 of file apm_task.c.

References vif_info_tag::active, APM_IDLE, APM_START_CAC_CFM, apm_start_cac_cfm::ch_idx, apm_start_cac_req::chan, chan_ctxt_add(), chan_ctxt_link(), CO_BAD_PARAM, CO_BUSY, CO_FAIL, CO_OK, GLOBAL_INT_DISABLE, GLOBAL_INT_RESTORE, KE_MSG_ALLOC, KE_MSG_CONSUMED, ke_msg_send(), ke_state_get(), ps_env_tag::prevent_sleep, PS_CAC_STARTED, ps_env, apm_start_cac_cfm::status, TASK_APM, vif_info_tag::type, VIF_AP, apm_start_cac_req::vif_idx, and vif_info_tab.

static int apm_start_req_handler | ( | ke_msg_id_t const | msgid,
|  | struct apm_start_req * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

APM module message handler.

This function handles the message APM_AP_START_REQ from host. This message requests the UMAC to start an AP in a BSS network.

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 46 of file apm_task.c.

References vif_info_tag::active, apm_env, APM_IDLE, apm_set_bss_param(), APM_START_CFM, ASSERT_ERR, mac_chan_op::band, vif_info_tag::bss_info, me_bss_info::chan, apm_start_req::chan, vif_info_tag::chan_ctxt, chan_ctxt_add(), chan_ctxt_link(), CO_BAD_PARAM, CO_BUSY, co_clz(), CO_FAIL, CO_OK, CO_OP_IN_PROGRESS, me_bss_info::high_11b_rate, HW_RATE_2MBPS, KE_MSG_ALLOC, KE_MSG_CONSUMED, KE_MSG_NO_FREE, ke_msg_send(), ke_state_get(), me_legacy_rate_bitfield_build(), apm::param, PHY_BAND_2G4, me_bss_info::power_constraint, me_bss_info::rate_set, apm_start_cfm::status, TASK_APM, tpc_update_vif_tx_power(), vif_info_tag::type, VIF_AP, apm_start_cfm::vif_idx, apm_start_req::vif_idx, and vif_info_tab.

static int apm_stop_cac_req_handler | ( | ke_msg_id_t const | msgid,
|  | struct apm_stop_cac_req const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

APM module message handler.

This function handles the message APM_AP_STOP_CAC_REQ from SME. This message requests the UMAC to stop listening of the specified channel. CAC (Channel Availability Check) ends if a radar is detected or after a defined period

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 475 of file apm_task.c.

References vif_info_tag::active, APM_IDLE, APM_STOP_CAC_CFM, chan_ctxt_unlink(), GLOBAL_INT_DISABLE, GLOBAL_INT_RESTORE, KE_MSG_CONSUMED, ke_msg_send_basic(), ke_state_get(), ps_env_tag::prevent_sleep, PS_CAC_STARTED, ps_env, TASK_APM, vif_info_tag::type, VIF_AP, apm_stop_cac_req::vif_idx, and vif_info_tab.

static int apm_stop_req_handler | ( | ke_msg_id_t const | msgid,
|  | struct apm_stop_req const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

APM module message handler.

This function handles the message APM_AP_STOP_REQ from host. This message requests the UMAC to stop the AP.

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 358 of file apm_task.c.

References vif_info_tag::active, APM_IDLE, apm_stop(), APM_STOP_CFM, KE_MSG_CONSUMED, KE_MSG_SAVED, ke_msg_send_basic(), ke_state_get(), TASK_APM, vif_info_tag::type, VIF_AP, apm_stop_req::vif_idx, and vif_info_tab.

static int me_set_active_cfm_handler | ( | ke_msg_id_t const | msgid,
|  | void const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

APM module message handler.

This function handles the message ME_SET_ACTIVE_CFM. It is sent by ME Task once requested state is reached. Vif is activated when the AP is started and deactivated when the AP is stopped.

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 223 of file apm_task.c.

References apm_bcn_set(), APM_BSS_PARAM_SETTING, apm_env, APM_IDLE, APM_STOP_CFM, APM_STOPPING, ASSERT_ERR, apm::bss_config, co_list_is_empty(), KE_MSG_CONSUMED, ke_msg_send_basic(), ke_state_get(), ke_state_set(), and TASK_APM.

static int me_set_ps_disable_cfm_handler | ( | ke_msg_id_t const | msgid,
|  | void const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

APM module message handler.

This function handles the message ME_SET_PS_DISABLE_CFM. It is sent by ME Task once request Power Save mode has been configured. Power Save mode is disabled when an AP is started and re-enabled when it is stopped.

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 156 of file apm_task.c.

References apm_bss_config_send(), APM_BSS_PARAM_SETTING, APM_IDLE, APM_STOPPING, ASSERT_ERR, KE_MSG_CONSUMED, ke_state_get(), and TASK_APM.

static int mm_bcn_change_cfm_handler | ( | ke_msg_id_t const | msgid,
|  | void const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

APM module message handler.

This function handles the message MM_BCN_CHANGE_CFM. It is sent by MM layer once the beacon has been configured. Beacon is only configured once when the AP is started. It is the last step in the start of the AP.

Note:
  If Beacon need to be modified while AP is running, the modification is directly sent to MM task.

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 270 of file apm_task.c.

References APM_BCN_SETTING, apm_start_cfm(), ASSERT_ERR, CO_OK, KE_MSG_CONSUMED, ke_state_get(), and TASK_APM.

static int mm_bss_param_setting_handler | ( | ke_msg_id_t const | msgid,
|  | void const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

APM module message handler.

This function handles the messages MM_SET_BSSID_CFM and MM_SET_BEACON_INT_CFM. They are sent by MM task once requested configuration has been completed. Configuration is done only when the AP is started.

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 193 of file apm_task.c.

References apm_bss_config_send(), APM_BSS_PARAM_SETTING, ASSERT_ERR, KE_MSG_CONSUMED, ke_state_get(), and TASK_APM.

static int mm_chan_ctxt_unlink_cfm_handler | ( | ke_msg_id_t const | msgid,
|  | void const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

MM_CHAN_CTXT_UNLINK_CFM message handler.

This function is called once the channel context associated to a VIF has been unlinked.

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 297 of file apm_task.c.

References apm_bss_config_send(), APM_STOPPING, ASSERT_ERR, KE_MSG_CONSUMED, ke_state_get(), and TASK_APM.

static int mm_set_vif_state_cfm_handler | ( | ke_msg_id_t const | msgid,
|  | void const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

MM_SET_VIF_STATE_CFM message handler.

This function is called once the VIF has been put to active state at the end of the AP creation, or to inactive state upon AP deletion.

Parameters:

  `[in]` | msgid | Id of the message received (probably unused)
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 324 of file apm_task.c.

References apm_bss_config_send(), APM_IDLE, APM_STOPPING, ASSERT_ERR, KE_MSG_CONSUMED, ke_state_get(), and TASK_APM.

## Variable Documentation

struct ke_state_handler apm_default_handler

Initial value:

        KE_STATE_HANDLER(apm_default_state)

Specifies the message handlers that are common to all states.

Definition at line 535 of file apm_task.c.

struct ke_msg_handler apm_default_state[]

Initial value:

    {
        {APM_START_REQ, (ke_msg_func_t)apm_start_req_handler},
        {APM_STOP_REQ, (ke_msg_func_t)apm_stop_req_handler},
        {ME_SET_ACTIVE_CFM, (ke_msg_func_t)me_set_active_cfm_handler},
        {MM_BCN_CHANGE_CFM, (ke_msg_func_t)mm_bcn_change_cfm_handler},
        {MM_SET_BSSID_CFM, mm_bss_param_setting_handler},
        {MM_SET_BASIC_RATES_CFM, mm_bss_param_setting_handler},
        {MM_SET_BEACON_INT_CFM, mm_bss_param_setting_handler},
        {ME_SET_PS_DISABLE_CFM, (ke_msg_func_t)me_set_ps_disable_cfm_handler},
        {MM_SET_VIF_STATE_CFM, (ke_msg_func_t)mm_set_vif_state_cfm_handler},
        {MM_CHAN_CTXT_UNLINK_CFM, (ke_msg_func_t)mm_chan_ctxt_unlink_cfm_handler},
        {APM_START_CAC_REQ, (ke_msg_func_t)apm_start_cac_req_handler},
        {APM_STOP_CAC_REQ, (ke_msg_func_t)apm_stop_cac_req_handler},
    }

DEFAULT handler definition.

Definition at line 518 of file apm_task.c.