Synchronous call to read the AP information from the SCAN Result list with the given index.
This function is expected to be called when the response events M2M_WIFI_RESP_SCAN_RESULT or M2M_WIFI_RESP_SCAN_DONE are received in the wi-fi callback function. The response information received can be obtained through the casting to the tstrM2mWifiscanResult structure
Reads the AP information from the Scan Result list with the given index, the response received in wifi_cb M2M_WIFI_RESP_SCAN_RESULT, the response pointer should be casted with tstrM2mWifiscanResult structure.
- Parameters
-
[in] | index | Index for the requested result, the index range start from 0 till number of AP's found |
- See Also
- tstrM2mWifiscanResult,m2m_wifi_get_num_ap_found,m2m_wifi_request_scan
- Returns
- The function shall return M2M_SUCCESE for success and a negative value otherwise
- Precondition
- m2m_wifi_request_scan need to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found
- Warning
- Function used only in STA mode only. the scan result updated only if scan request called, else it will be cashed in firmware for the host scan request result, which mean if large delay occur between the scan request and the scan result request, the result will not be up-to-date
- Parameters
-
[in] | index | Index for the requested result, the index range start from 0 till number of AP's found |
- See Also
- tstrM2mWifiscanResult m2m_wifi_get_num_ap_found m2m_wifi_request_scan
- Precondition
- m2m_wifi_request_scan needs to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found
- A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the m2m_wifi_init function.
- The event M2M_WIFI_RESP_SCAN_RESULT must be handled in the callback to receive the requested connection information.
- Warning
- Tthe scan results are updated only if the scan request is called. Calling this function only without a scan request will lead to firmware errors. Refrain from introducing a large delay between the scan request and the scan result request.
- Returns
- The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Example
The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.
void wifi_event_cb(
uint8 u8WiFiEvent,
void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
printf(
"Num of AP found %d\n",pstrInfo->
u8NumofCh);
{
u8ScanResultIdx = 0;
{
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf(
"(ERR) Scan fail with error <%d>\n",pstrInfo->
s8ScanState);
}
}
break;
{
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
if(u8ScanResultIdx < u8NumFoundAPs)
{
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
{
{
while(1)
{
}
}
}
References hif_send(), M2M_REQ_GRP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SCAN_RESULT, NULL, and tstrM2mReqScanResult::u8Index.
Referenced by os_m2m_wifi_req_scan_result(), and wifi_cb().