Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
m2m_wifi_req_scan_result

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

Functions

NMI_API sint8 m2m_wifi_req_scan_result (uint8 index)
 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. More...
 

NMI_API sint8 m2m_wifi_req_scan_result ( uint8  index)

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.

Asynchronous API to request the information of an access point discovered via scanning.

Synchronous call to read the AP information from the SCAN Result list.

Parameters
[in]indexIndex 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]indexIndex 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.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
Parameters
[in]indexIndex 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_SUCCESS 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
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 @ref M2M_WIFI_RESP_SCAN_RESULT or
@ref 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 
@ref tstrM2mWifiscanResult structure.
Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
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 scan information.
Warning
  • Function used in STA mode only. the scan results are updated only if the scan request is called.
  • Calling this function only without a scan request will lead to firmware errors.
  • Application code should refrain from introducing a large delay between the scan request and the scan result request, to prevent errors occurring.

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"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
Parameters
[in]indexIndex 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_SUCCESS 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
This function allows the information of any discovered access point to be retrieved. When a
scan is completed, the application is informed of the number of networks (access points)
discovered. Calling this function with an index, N, will return the information for the Nth
access point. The information will be returned to the application via a
@ref M2M_WIFI_RESP_SCAN_RESULT event, and the response data may be obtained through casting
the pointer (pvMsg) to @ref tstrM2mWifiscanResult.
Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tstrM2mWifiscanResult m2m_wifi_get_num_ap_found m2m_wifi_request_scan
Precondition
  • m2m_wifi_request_scan must be called first to ensure up to date results are available.
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered in order to receive scan data after calling this function. Registration of the callback is done via the m2m_wifi_init function.
  • The event M2M_WIFI_RESP_SCAN_RESULT must be handled in the callback to receive the requested scan information.
Warning
  • This API is valid only for STA mode, it may be called regardless of the connection state (connected or disconnected).
  • Calling this function without first issuing a scan request may lead to stale data being recovered.
  • Application code should refrain from introducing significant delays between issuing the scan request and scan result requests.

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 the response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}