![Mediatek Labs LinkIt Скачать руководство пользователя страница 11](http://html1.mh-extra.com/html/mediatek-labs/linkit/linkit_developers-manual_1760805011.webp)
MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 7 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_reload_setting();
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 Manual.
2.1.3.
The AP router operates in open WEP mode
1)
In this example, the AP router operates in open WEP mode with the key index set to 0, the password set
to "
1234567890
" and the SSID of the router is "
REMOTE_AP
". Initialize the module in STA mode, as
shown below.
a)
Define the operation mode (
config.opmode
), the SSID (
config.sta_config.ssid
), password
(
config.sta_config.password
) and key index (
config_ext.sta_wep_key_index
) in the
wifi_config_t
and
wifi_config_ext_t
data structures. 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_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, "1234567890");
config.sta_config.password_length = strlen((char
*)config.sta_config.password);
config_ext.sta_wep_key_index_present = 1;
config_ext.sta_wep_key_index = 0;
b)
Call the
wifi_init()
function to initialize the Wi-Fi driver.
wifi_init(&config, &config_ext);
Note, the open WEP mode is configured slightly different from the other two examples described in this section. It
requires both
wifi_config_t
and
wifi_config_ext_t
parameters.
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 WEP key by calling the
wifi_config_set_wep_key()
function.
wifi_wep_key_t wep_key = {{{0}}};
wep_key.wep_tx_key_index = 0;
wep_key.wep_key[0] = "1234567890";
wep_key.wep_key_length[0] = strlen("1234567890");
wifi_config_set_wep_key(WIFI_PORT_STA, &wep_key);
d)
Apply the settings by calling
wifi_config_reload_setting()
function.
wifi_config_reload_setting();