![Mediatek Labs LinkIt Скачать руководство пользователя страница 39](http://html1.mh-extra.com/html/mediatek-labs/linkit/linkit_developers-manual_1760805039.webp)
MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 35 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.7.2.2.
WPS PIN method
There are three cases when using the WPS PIN method to connect to the Wi-Fi network:
•
The access point as a Registrar.
•
The access point as an Enrollee.
•
The STA as an Enrollee.
Call the function
wifi_wps_connection_by_pin()
to apply the API directly.
1)
AP as a Registrar
When the device is AP, assign the parameter
WIFI_PORT_AP
to the "port" parameter of this API, and then the AP
will operate as a Registrar. The STA will operate as an Enrollee.
First of all, AP needs to know the STA’s PIN code and we manually give STA’s PIN to AP.
Before the AP calls the
wifi_wps_connection_by_pin()
API, the Enrollee, such as a smart phone, needs to
push the WPS PIN virtual button to get a PIN code and trigger the Enrollee process. Then input this PIN code to AP
and call the
wifi_wps_connection_by_pin()
API using Enrollee’s PIN to trigger AP’s Registrar process. During
120 seconds (based on the official WPS specification), the Enrollee will connect with the AP and get an IP, or
prompt fail.
An example implementation is shown below.
2)
AP as an Enrollee
When the device is AP as an Enrollee, the process is passive and there is no command or API to control it. The
process will be auto triggered by a Registrar.
AP needs to give its PIN code to the Registrar when it acts as an Enrollee. AP can get the PIN code by calling the API
described in section 2.7.2.3, "WPS get the PIN code".
3)
STA as an Enrollee
When the device is STA, assign the parameter
WIFI_PORT_STA
to the "port" parameter of this API, to set the STA
as an Enrollee. The AP will act as Registrar.
Once the STA calls this API, the Enrollee process will be triggered. Then the Registrar, such as an AP, needs to input
the STA’s PIN code and trigger the Registrar process. During 120 seconds, the Enrollee will connect with the AP and
get an IP address, or prompt fail.
If the STA’s "
pin
" parameter is NULL, a pin code will be auto-generated and displayed through UART, such as "
WPS
PIN: 00309448
".
An example implementation is shown below.
int32_t wps_ap_pin_example()
{
uint8_t *bssid = "00:11:22:33:44:55";
uint8_t *sta_pin = "00309448";
return wifi_wps_connection_by_pin(WIFI_PORT_AP, bssid, sta_pin);
}
int32_t wps_sta_pin_example()
{
uint8_t *bssid = "00:11:22:33:44:55";
uint8_t *pin = NULL;