MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 25 of 36
This document contains information that is proprietary to MediaTek Inc. (“MediaTek”) and/or its licensor(s).
Any unauthorized use, reproduction or disclosure of this document in whole or in part is strictly prohibited.
Note 1. The scan table
g_ap_list
is a user-defined array initialized
in
wifi_connection_scan_init()
. It’s required to call
wifi_connection_scan_deinit()
after
the scan process is complete. Otherwise, calling the function
wifi_connection_scan_init()
again
will fail.
Note 2. The information of the scanned APs is stored in the scan table in descending order of the RSSI.
Note 3. It is recommended to call
wifi_connection_scan_deinit()
first to release the scan table
from the scan process, to give the ownership of the scan table back to the user. Then the user can safely
access the information stored in the scan table, erase the table or free the memory allocated to the
table.
Note 4. Call the function
wifi_connection_scan_deinit()
after the scan completes or after the
scan has stopped by
wifi_connect_stop_scan()
.
2.4.1.2.
Using a callback to parse the Wi-Fi beacon and probe-response raw packet
1)
Register the event handler
WIFI_EVENT_IOT_REPORT_BEACON_PROBE_RESPONSE
. The beacon and
probe-response raw packet in the air can be received and uploaded to the handler.
uint8_t status = 0;
int event_handler_sample(wifi_event_t event_id, unsigned char *payload,
unsigned int len)
{
int handled = 0;
if (event_id == WIFI_EVENT_IOT_REPORT_BEACON_PROBE_RESPONSE){
handled = 1;
if (len != 0) {
wifi_scan_list_item_t ap_data;
os_memset(&ap_data, 0, sizeof(wifi_scan_list_item_t));
if (wifi_connection_parse_beacon(payload, len, &ap_data) >= 0) {
printf("\n%-4s%-33s%-20s%-8s%-8s%-8s%-8s\n", "Ch", "SSID",
"BSSID", "Auth",
"Cipher", "RSSI", "WPS");
printf("%-4d", ap_data.channel);
printf("%-33s", ap_data.ssid);
printf("%02x:%02x:%02x:%02x:%02x:%02x ",
ap_data.bssid[0],
ap_data.bssid[1],
ap_data.bssid[2],
ap_data.bssid[3],
ap_data.bssid[4],
ap_data.bssid[5]);
printf("%-8d", ap_data.auth_mode);
printf("%-8d", ap_data.encrypt_mode);
printf("%-8d", ap_data.rssi);
printf("%-8d", ap_data.wps);
printf("\n");
}
}
return handled;
}
status=wifi_connection_register_event_handler(WIFI_EVENT_IOT_REPORT_BEACON
_PROBE_RESPONSE, (wifi_event_handler_t) event_handler_sample);