![Mediatek Labs LinkIt Скачать руководство пользователя страница 21](http://html1.mh-extra.com/html/mediatek-labs/linkit/linkit_developers-manual_1760805021.webp)
MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 17 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_channel(WIFI_PORT_AP, 6);
Apply the configuration by calling the function
wifi_config_reload_setting()
, as shown below.
wifi_config_reload_setting();
The authentication and encryption method combinations are also available (see Table 4).
2.2.3.
Use the device in AP mode with open WEP method
1)
In this example, the device is in AP mode and operates on channel 6, the security mode is in open WEP
mode with the key index is set to 0, the password is "
1234567890
" 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 and define the key index in the
wifi_config_ext_t
(
config_ext.ap_wep_key_index
) structure, as shown below. Set
config_ext.sta_wep_key_index_present
to 1 to enable the presence of
config_ext.sta_wep_key_index.
wifi_config_t config = {0};
wifi_config_ext_t config_ext = {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_OPEN;
config.ap_config.encrypt_type = WIFI_ENCRYPT_TYPE_WEP_ENABLED;
strcpy((char *)config.ap_config.password, "1234567890");
config.ap_config.password_length = strlen("1234567890");
config.ap_config.channel = 6;
config_ext.ap_wep_key_index_present = 1;
config_ext.ap_wep_key_index = 0;
b)
Call the
wifi_init()
function to initialize the Wi-Fi driver.
wifi_init(&config, &config_ext);
2)
Use configuration APIs to set the device in AP mode that operates in WEP mode with the SSID of
"
MTK_SOFT_AP
".
a)
Determine if the given WEP key (
key_string
) has a proper length, 5 or 13 ASCII characters (8 bits),
10 or 26 HEX characters (4 bits).
wifi_wep_key_t keys = {{{0}}};
uint8_t key_id = 0; //0~3
char *key_string = "1234567890";
uint8_t length = strlen(key_string);
if (key_id < 4) {
keys.wep_key_length[key_id] = length;
os_memcpy(&keys.wep_key[key_id], key_string, length);
}
b)
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);