Synchronous function to retrieve the number of AP's found in the last scan request, The function read the number of AP's from global variable which updated in the wi-fi callback fucntion through the M2M_WIFI_RESP_SCAN_DONE event. Function used only in STA mode only.
◆ m2m_wifi_get_num_ap_found()
- See also
- m2m_wifi_request_scan M2M_WIFI_RESP_SCAN_DONE M2M_WIFI_RESP_SCAN_RESULT
- Precondition
- m2m_wifi_request_scan need to be called first
- A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at intialization. Registering the callback is done through passing it to the m2m_wifi_init.
- Warning
- This function must be called only in the wi-fi callback function when the events M2M_WIFI_RESP_SCAN_DONE or M2M_WIFI_RESP_SCAN_RESULT are received. Calling this function in any other place will result in undefined/outdated numbers.
- Returns
- Return the number of AP's found in the last Scan Request.
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.
#include "m2m_wifi.h"
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;
}
}
int main()
{
{
while(1)
{
}
}
}