![Mediatek Labs LinkIt Developer'S Manual Download Page 9](http://html1.mh-extra.com/html/mediatek-labs/linkit/linkit_developers-manual_1760805009.webp)
MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 5 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.
•
wifi_config_set_ssid()
•
wifi_config_set_wep_key()
•
wifi_config_set_wpa_psk_key()
The configuration APIs use in-band mechanism for Wi-Fi driver and Wi-Fi firmware communication, thus these APIs
must be called after the OS task scheduler has started, to make sure an in-band task is running. The function
wifi_config_register_rx_handler()
registers
wifi_rx_handler()
to manage the raw packets. There is
a limitation on calling this handler as it's using an in-band mechanism. It's restricted to call any in-band functions
like Wi-Fi configuration APIs or Wi-Fi connection APIs inside
wifi_rx_handler().
Note 1. There is no need to configure the security mode in STA mode, as the security mode of the STA
can automatically match to the security mode of the AP.
Note 2. If AP’s security mode is unknown, call the
wifi_config_set_wpa_psk_key()
and
wifi_config_set_wep_key()
APIs to set the password.
To use the module in a STA mode, apply any of the examples described below.
2.1.1.
The AP router operates in open mode
1)
In this example, the AP router operates in open mode with an SSID of "
REMOTE_AP
". Initialize the module
in STA mode, as shown below.
a)
Define the operation mode (
config.opmode
) and the SSID (
config.sta_config.ssid
) in the
wifi_config_t
structure.
wifi_config_t config = {0};
config.opmode = WIFI_MODE_STA_ONLY;
strcpy((char *)config.sta_config.ssid, "
REMOTE
_AP");
config.sta_config.ssid_length = strlen((char *)config.sta_config.ssid);
b)
Call the
wifi_init()
function to initialize the Wi-Fi driver.
wifi_init(&config, NULL);
You’ve now successfully initialized the Wi-Fi module in STA mode.
2)
To use configuration APIs in STA mode to connect to the AP router:
a)
Call the
wifi_config_set_opmode()
function to set the opmode to WIFI_MODE_STA_ONLY.
wifi_config_set_opmode(WIFI_MODE_STA_ONLY);
b)
Call the
wifi_config_set_ssid()
function to set the port to WIFI_PORT_STA and the SSID to
"
REMOTE_AP
"
.
wifi_config_set_ssid(WIFI_PORT_STA, "
REMOTE_AP"
, strlen("
REMOTE_AP
"));
c)
Apply the parameters by calling the
wifi_config_reload_setting()
function.
wifi_config_reload_setting();
You’ve successfully configured the Wi-Fi settings.