![Mediatek Labs LinkIt Developer'S Manual Download Page 13](http://html1.mh-extra.com/html/mediatek-labs/linkit/linkit_developers-manual_1760805013.webp)
MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 9 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.
a)
Initialize the
wifi_config_ext_t
structure, as shown below. Set
config_ext.sta_auto_connect_present
to 1 to enable the presence of
config_ext.sta_auto_connect.
wifi_config_ext_t config_ext;
config_ext.sta_auto_connect_present = 1;
config_ext.sta_auto_connect =
1; // Enable the auto connect.
b)
Call the
wifi_init()
function to initialize the Wi-Fi driver, see section 2.1, “Using the Wi-Fi module
wifi_init(&config, &config_ext); // Assuming the config is already
initialized.
2)
Disable the auto connect option.
a)
Initialize the
wifi_config_ext_t
structure.
wifi_config_ext_t config_ext;
config_ext.sta_auto_connect_present = 1;
config_ext.sta_auto_connect = 0; // Disable the auto connect.
b)
Call the
wifi_init()
function to initialize the Wi-Fi driver, see section 2.1, “Using the Wi-Fi module
wifi_init(&config, &config_ext); // Assuming the config is already
initialized
Note, if the mode is changed to STA mode by calling
wifi_config_set_opmode()
, the Wi-Fi driver will not
connect to the AP router using auto connect. And after calling
wifi_config_reload_setting()
, it will start
try to connect to AP.
2.1.6.
Wi-Fi connection support
The connection APIs are used to manage the link status, such as, disconnect from the AP, disconnect the station,
get the link status, get the station list, start/stop the scan and register an event handler for scan, connect, or
disconnect events. The connection APIs use an in-band mechanism and must be called after the OS task scheduler
has started, to ensure the in-band task is running.
In the STA mode, the device can disconnect from the AP, get the link status, start or stop the scan and register an
event handler for scan, connect or disconnect events.
1)
Get the link status.
Call the function
wifi_connection_get_link_status()
to get the link status in STA mode, as shown below.
2)
Disconnect the AP.
Call the function
wifi_connection_disconnect_ap()
to disconnect the station from the AP router, as shown
below.
uint8_t status = 0;
uint8_t link = 0;
status = wifi_connection_get_link_status(&link);
if (link == 1){
printf("link=%d, the station is connecting to an AP router.\n", link);
}else if (link == 0) {
printf("link=%d, the station doesn’t connect to an AP router.\n",
link);
}