![Mediatek Labs LinkIt Developer'S Manual Download Page 10](http://html1.mh-extra.com/html/mediatek-labs/linkit/linkit_developers-manual_1760805010.webp)
MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 6 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.1.2.
The AP router operates in WPA2PSK authentication mode
1)
In this example, the AP router operates in WPA2PSK authentication mode with AES encryption type, the
password is "
12345678
" and the SSID of the AP router is "
REMOTE_AP
". Initialize the module in STA mode,
as shown below.
a)
Define the operation mode (
config.opmode
), password (
config.sta_config.password
) 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);
strcpy((char *)config.sta_config.password, "12345678");
config.sta_config.password_length = strlen((char
*)config.sta_config.password);
b)
Call the
wifi_init()
function to initialize the Wi-Fi driver.
wifi_init(&config, NULL);
The STA mode supports various types of security modes, as shown in Table 4. For more information about the
authentication mode and encryption group types, refer to
wifi_auth_mode_t
and
wifi_encrypt_type_t
types in the Wi-Fi API reference guide.
Table 4. The supported security modes
Authentication mode
Encryption type
WIFI_AUTH_MODE_OPEN
WIFI_ENCRYPT_TYPE_WEP_ENABLED
WIFI_AUTH_MODE_WPA_PSK
WIFI_ENCRYPT_TYPE_TKIP_ENABLED
WIFI_AUTH_MODE_WPA_PSK
WIFI_ENCRYPT_TYPE_AES_ENABLED
WIFI_AUTH_MODE_WPA_PSK
WIFI_ENCRYPT_TYPE_TKIP_AES_MIX
WIFI_AUTH_MODE_WPA2_PSK
WIFI_ENCRYPT_TYPE_TKIP_ENABLED
WIFI_AUTH_MODE_WPA2_PSK
WIFI_ENCRYPT_TYPE_AES_ENABLED
WIFI_AUTH_MODE_WPA2_PSK
WIFI_ENCRYPT_TYPE_TKIP_AES_MIX
WIFI_AUTH_MODE_WPA_PSK_WPA2_PSK
WIFI_ENCRYPT_TYPE_TKIP_ENABLED
WIFI_AUTH_MODE_WPA_PSK_WPA2_PSK
WIFI_ENCRYPT_TYPE_AES_ENABLED
WIFI_AUTH_MODE_WPA_PSK_WPA2_PSK
WIFI_ENCRYPT_TYPE_TKIP_AES_MIX
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)
Set the password to "12345678" by calling the
wifi_config_set_wpa_psk_key()
function.
wifi_config_set_wpa_psk_key(WIFI_PORT_STA, "12345678",
strlen("12345678"));
d)
Apply the parameters by calling the
wifi_config_reload_setting()
function.