![Mediatek Labs LinkIt Developer'S Manual Download Page 20](http://html1.mh-extra.com/html/mediatek-labs/linkit/linkit_developers-manual_1760805020.webp)
MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 16 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.
c)
Call the function
wifi_config_set_channel(port, channel)
to setup the channel on a given
port, as shown below.
wifi_config_set_channel(WIFI_PORT_AP, 6);
Apply the configuration by calling the function
wifi_config_reload_setting()
, as shown below.
wifi_config_reload_setting();
2.2.2.
Use the device in AP mode with WPA2PSK method
1)
In this example, the device is in AP mode and operates on channel 6, the authentication mode is
WPA2PSK (
WIFI_AUTH_MODE_WPA2_PSK
) with AES encryption type
(
WIFI_ENCRYPT_TYPE_AES_ENABLED
), the password is "
12345678"
and the SSID is "
MTK_SOFT_AP
".
Initialize the module in AP mode, as shown below.
a)
Define the operation mode (
config.opmode
), SSID (
config.ap_config.ssid
), channel
(
config.ap_config.channel
), authentication mode (
config.ap_config.auth_mode
),
encryption type (
config.ap_config.encrypt_type
) and password
(
config.ap_config.password
) in the
wifi_config_t
structure, as shown below.
wifi_config_t config = {0};
config.opmode = WIFI_MODE_AP_ONLY;
strcpy((char *)config.ap_config.ssid, "MTK_SOFT_AP");
config.ap_config.ssid_length = strlen("MTK_SOFT_AP");
config.ap_config.auth_mode = WIFI_AUTH_MODE_WPA2_PSK;
config.ap_config.encrypt_type = WIFI_ENCRYPT_TYPE_AES_ENABLED;
strcpy((char *)config.ap_config.password, "12345678");
config.ap_config.password_length = strlen("12345678");
config.ap_config.channel = 6;
b)
Call the
wifi_init()
function to initialize the Wi-Fi driver.
wifi_init(&config, NULL);
The device in AP mode supports various types of security modes, as shown in Table 4. More information about the
authentication mode and encryption group types can be found in
wifi_auth_mode_t
and
wifi_encrypt_type_t
types in the Wi-Fi API Reference Manual.
2)
Use configuration APIs to set the device in AP mode that operates in WPA2PSK mode with a given port,
channel, password and SSID.
a)
Call the function
wifi_config_set_opmode(opmode)
to set the opmode to
WIFI_MODE_AP_ONLY
, as shown below.
wifi_config_set_opmode(WIFI_MODE_AP_ONLY);
Call the function
wifi_config_set_ssid(port, ssid_name, strlen(ssid_name))
to set the SSID
("
MTK_SOFT_AP
") of a given port (
WIFI_PORT_AP
), as shown below.
wifi_config_set_ssid(WIFI_PORT_AP, "MTK_SOFT_AP", strlen("MTK_SOFT_AP"));
b)
Call the function
wifi_config_set_security_mode(port, auth, encrypt)
to set the
security mode of the AP router, as shown below.
wifi_config_set_security_mode(WIFI_PORT_AP, WIFI_AUTH_MODE_WPA2_PSK,
WIFI_ENCRYPT_TYPE_AES_KEY_ENABLED);
c)
Call the function
wifi_config_set_wpa_psk_key(port, password,
strlen(password))
to set the WPA2PSK key, as shown below.
wifi_config_set_wpa_psk_key(WIFI_PORT_AP, "12345678", strlen("12345678"));
d)
Call the function
wifi_config_set_channel(port, channel)
to setup the channel on a
given port, as shown below.