# TASK_SCANU
[SCANU]

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

Collaboration diagram for TASK_SCANU:

## Data Structures
struct | scanu_start_req
| Structure containing the parameters of the SCANU_START_REQ message. More...
struct | scanu_start_cfm
| Structure containing the parameters of the SCANU_START_CFM message. More...
struct | scanu_get_scan_result_req
| Structure containing the parameters of the SCANU_GET_SCAN_RESULT_REQ message. More...
struct | scanu_get_scan_result_cfm
| Structure containing the parameters of the SCANU_GET_SCAN_RESULT_CFM message. More...
## Defines
#define | SCANU_IDX_MAX 1
| Task max index number.
## Enumerations
enum | { SCANU_IDLE, SCANU_SCANNING, SCANU_STATE_MAX }
| Possible states of the task. More...
enum | { SCANU_START_REQ = KE_FIRST_MSG(TASK_SCANU), SCANU_START_CFM, SCANU_JOIN_REQ, SCANU_JOIN_CFM, SCANU_RESULT_IND, SCANU_GET_SCAN_RESULT_REQ, SCANU_GET_SCAN_RESULT_CFM }
| Messages that are logically related to the task. More...
## Functions
static int | scanu_start_req_handler (ke_msg_id_t const msgid, struct scanu_start_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| SCAN module message handler.
static int | scanu_join_req_handler (ke_msg_id_t const msgid, struct scanu_start_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| SCAN module message handler.
static int | scanu_get_scan_result_req_handler (ke_msg_id_t const msgid, struct scanu_get_scan_result_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| SCAN module message handler.
static int | scan_start_cfm_handler (ke_msg_id_t const msgid, struct scan_start_cfm const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| SCAN module message handler.
static int | scan_done_ind_handler (ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| SCAN module message handler.
static int | rxu_mgt_ind_handler (ke_msg_id_t const msgid, struct rxu_mgt_ind const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| SCAN module message handler.
## Variables
struct ke_msg_handler | scanu_idle []
| Specifies the messages handled in idle state.
struct ke_msg_handler | scanu_scanning []
| Specifies the messages handled in scanning state.
struct ke_msg_handler | scanu_default_state []
| DEFAULT handler definition.
struct ke_state_handler | scanu_state_handler [SCANU_STATE_MAX]
| Specifies the message handler structure for every input state.
struct ke_state_handler | scanu_default_handler
| Specifies the message handlers that are common to all states.
ke_state_t | scanu_state [SCANU_IDX_MAX]
| Defines the place holder for the states of all the task instances.
struct ke_state_handler | scanu_state_handler [SCANU_STATE_MAX]
| Specifies the message handler structure for every input state.
struct ke_state_handler | scanu_default_handler
| Specifies the message handlers that are common to all states.
ke_state_t | scanu_state [SCANU_IDX_MAX]
| Defines the place holder for the states of all the task instances.

## Detailed Description

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

## Enumeration Type Documentation

anonymous enum

Possible states of the task.

Enumerator:

  SCANU_IDLE | Idle State.
  SCANU_SCANNING | SCANNING State.
  SCANU_STATE_MAX | Max number of states.

Definition at line 33 of file scanu_task.h.

anonymous enum

Messages that are logically related to the task.

Enumerator:

  SCANU_START_REQ | Scan request from host.
  SCANU_START_CFM | Scanning start Confirmation.
  SCANU_JOIN_REQ | Join request.
  SCANU_JOIN_CFM | Join confirmation.
  SCANU_RESULT_IND | Scan result indication.
  SCANU_GET_SCAN_RESULT_REQ | Get Scan result request.
  SCANU_GET_SCAN_RESULT_CFM | Scan result confirmation.

Definition at line 44 of file scanu_task.h.

## Function Documentation

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

SCAN module message handler.

This function handles the reception of a BEACON and PROBE Response It extracts all required information from them.

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 231 of file scanu_task.c.

References scanu_frame_handler().

static int scan_done_ind_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]`

SCAN module message handler.

This function handles the scan confirmation message from LMAC. This message confirms a scan request command after LMAC is finished with scan procedure

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 203 of file scanu_task.c.

References scanu_env_tag::band, KE_MSG_CONSUMED, scanu_env, and scanu_scan_next().

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

SCAN module message handler.

This function handles the scan confirmation message from LMAC. This message confirms a scan request command after LMAC is finished with scan procedure

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 177 of file scanu_task.c.

References CO_OK, KE_MSG_CONSUMED, scanu_confirm(), and scan_start_cfm::status.

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

SCAN module message handler.

This function handles the request to obtain the scan results. The request should be made after finishing the scan process (i.e after reception of scan confirmation message from SCANU) to ensure that the scan results are valid.

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 141 of file scanu_task.c.

References scanu_get_scan_result_req::idx, KE_MSG_ALLOC, KE_MSG_CONSUMED, ke_msg_send(), scanu_env_tag::result_cnt, scanu_env_tag::scan_result, scanu_get_scan_result_cfm::scan_result, scanu_env, SCANU_GET_SCAN_RESULT_CFM, TASK_SCANU, and mac_scan_result::valid_flag.

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

SCAN module message handler.

This function handles the scan request message from any module. This message Requests the STA to perform active or passive scan. If a scan is requested within two seconds of the last scan, no scan is performed and the last scan results are sent to the requester. The time at which the last scan was performed is stored in the time_stamp element in me_scan_context. If a scan should be performed, the following is done:

- Store the important parameters in the SCAN context.
- Decrease the number of channels to be scanned.
- Send a scan request to the LMAC.
- Move to the state SCANNING to wait the CFM and send the next request.
  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 92 of file scanu_task.c.

References ASSERT_ERR, scanu_env_tag::band, BSS_CAPA_RESET, vif_info_tag::bss_info, mac_scan_result::bssid, scanu_start_req::bssid, scanu_env_tag::bssid, scanu_env_tag::join_status, scanu_env_tag::joining, KE_MSG_NO_FREE, MAC_ADDR_GROUP, mac_ref_bssid_get(), mac_scan_result::max_bssid_indicator, mac_scan_result::multi_bssid_index, scanu_env_tag::param, PHY_BAND_2G4, scanu_env_tag::ref_bssid, scanu_env, scanu_find_result(), scanu_start(), scanu_env_tag::src_id, scanu_start_req::vif_idx, and vif_info_tab.

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

SCAN module message handler.

This function handles the scan request message from any module. This message Requests the STA to perform active or passive scan. If a scan is requested within two seconds of the last scan, no scan is performed and the last scan results are sent to the requester. The time at which the last scan was performed is stored in the time_stamp element in me_scan_context. If a scan should be performed, the following is done:

- Store the important parameters in the SCAN context.
- Decrease the number of channels to be scanned.
- Send a scan request to the LMAC.
- Move to the state SCANNING to wait the CFM and send the next request.
  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 49 of file scanu_task.c.

References scanu_env_tag::band, scanu_start_req::bssid, scanu_env_tag::bssid, scanu_env_tag::joining, KE_MSG_NO_FREE, ke_msg_send_basic(), MM_ANT_DIV_STOP_REQ, scanu_env_tag::param, PHY_BAND_2G4, scanu_env, scanu_start(), scanu_env_tag::src_id, TASK_MM, and TASK_SCANU.

## Variable Documentation

struct ke_state_handler scanu_default_handler

Initial value:

        KE_STATE_HANDLER(scanu_default_state)

Specifies the message handlers that are common to all states.

Definition at line 283 of file scanu_task.c.

struct ke_msg_handler scanu_default_state[]

Initial value:

    {

        {SCANU_START_REQ, ke_msg_save},
        {SCANU_JOIN_REQ, ke_msg_save},
        {SCANU_GET_SCAN_RESULT_REQ, ke_msg_save},

        {RXU_MGT_IND, ke_msg_discard},
    }

DEFAULT handler definition.

Definition at line 261 of file scanu_task.c.

struct ke_msg_handler scanu_idle[]

Initial value:

    {
        {SCANU_START_REQ, (ke_msg_func_t)scanu_start_req_handler},
        {SCANU_JOIN_REQ, (ke_msg_func_t)scanu_join_req_handler},
        {SCANU_GET_SCAN_RESULT_REQ, (ke_msg_func_t)scanu_get_scan_result_req_handler},
    }

Specifies the messages handled in idle state.

Definition at line 245 of file scanu_task.c.

struct ke_msg_handler scanu_scanning[]

Initial value:

    {
        {SCAN_START_CFM, (ke_msg_func_t)scan_start_cfm_handler},
        {SCAN_DONE_IND, (ke_msg_func_t)scan_done_ind_handler},
        {RXU_MGT_IND, (ke_msg_func_t)rxu_mgt_ind_handler},
    }

Specifies the messages handled in scanning state.

Definition at line 253 of file scanu_task.c.

struct ke_state_handler scanu_state_handler[SCANU_STATE_MAX]

Initial value:

    {

        [SCANU_IDLE] = KE_STATE_HANDLER(scanu_idle),

        [SCANU_SCANNING] = KE_STATE_HANDLER(scanu_scanning),
    }

Specifies the message handler structure for every input state.

Definition at line 273 of file scanu_task.c.