MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 4 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.
2.
Using the Module
The Wi-Fi module can only be applied once the settings are configured at system reboot. Apply your settings in the
wifi_init()
API to initialize the driver in STA or AP mode. To configure the board as a repeater, see section 2.2,
“Using the Wi-Fi module in AP mode”.
Starting from the SDK v4, initialize the Wi-Fi settings by calling the
wifi_init()
function. The legacy Wi-Fi profile
API is disabled by default. To enable the legacy Wi-Fi profile API, define compile option
MTK_WIFI_PROFILE_ENABLE
.
Most of the Wi-Fi APIs in
wifi_api.h
require FreeRTOS up and running. These APIs should be invoked in a task
triggered by
vTaskStartScheduler()
. The APIs in Table 3 are invoked in the
main()
function as an exception.
Table 3. Configuration functions
API
API
wifi_init()
wifi_connection_register_event_handler()
wifi_config_get_mac_address ()
wifi_connection_unregister_event_handler ()
You can register an event handler to complete the initialization and call the Wi-Fi APIs, as shown in the example
code below.
/* Register wifi initialization event handler in main() function */
wifi_connection_register_event_handler(WIFI_EVENT_IOT_INIT_COMPLETE,
user_wifi_init_callback);
/* User-defined wifi initialization callback function */
bool g_wifi_init_ready = false;
void user_wifi_init_callback() { g_wifi_init_ready = true; }
void user_wifi_init_qurey_status(){
while(g_wifi_init_ready == false) {
vTaskDelay(20);
}
}
/* User-defined task */
user_task()
{
user_wifi_init_query_status();
/* Call APIs to connect only after Wi-Fi is initialized. */
wifi_config_set_ssid(WIFI_PORT_STA, "REMOTE_AP", sizeof("REMOTE_AP"));
wifi_config_set_wpa_psk_key(WIFI_PORT_STA, "12345678",
sizeof("12345678"));
wifi_config_reload_setting();
}
2.1.
Using the Wi-Fi module in STA mode
In most cases, the configuration to initialize the Wi-Fi in STA mode takes effect immediately. However, some
settings can only take effect by calling the
wifi_config_reload_setting()
after calling the following APIs:
•
wifi_config_set_pmk()
•
wifi_config_set_security_mode()