Skip to content

Commit b25a003

Browse files
committed
Merge branch 'feature/refactor_wps_api' into 'master'
feat(lib): refactor wps api See merge request sdk/ESP8266_RTOS_SDK!471
2 parents ae6680b + 4484d80 commit b25a003

File tree

6 files changed

+143
-3
lines changed

6 files changed

+143
-3
lines changed

components/esp8266/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ register_component()
1212
target_link_libraries(${COMPONENT_NAME} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib")
1313
if(NOT CONFIG_NO_BLOBS)
1414
target_link_libraries(${COMPONENT_NAME} gcc hal core
15-
net80211 phy pp smartconfig ssc wpa espnow)
15+
net80211 phy pp smartconfig ssc wpa espnow wps)
1616
endif()
1717

1818
target_link_libraries(${COMPONENT_NAME} "-u call_user_start")

components/esp8266/component.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ COMPONENT_SRCDIRS := driver source
1212
LIBS ?=
1313
ifndef CONFIG_NO_BLOBS
1414
LIBS += gcc hal core net80211 \
15-
phy pp smartconfig ssc wpa espnow
15+
phy pp smartconfig ssc wpa espnow wps
1616
endif
1717

1818
#Linker scripts used to link the final application.

components/esp8266/include/esp_wps.h

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef __ESP_WPS_H__
16+
#define __ESP_WPS_H__
17+
18+
#include <stdint.h>
19+
#include <stdbool.h>
20+
#include "esp_err.h"
21+
22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
26+
/** \defgroup WiFi_APIs WiFi Related APIs
27+
* @brief WiFi APIs
28+
*/
29+
30+
/** @addtogroup WiFi_APIs
31+
* @{
32+
*/
33+
34+
/** \defgroup WPS_APIs WPS APIs
35+
* @brief ESP8266 WPS APIs
36+
*
37+
* WPS can only be used when ESP8266 station is enabled.
38+
*
39+
*/
40+
41+
/** @addtogroup WPS_APIs
42+
* @{
43+
*/
44+
45+
#define ESP_ERR_WIFI_REGISTRAR (ESP_ERR_WIFI_BASE + 51) /*!< WPS registrar is not supported */
46+
#define ESP_ERR_WIFI_WPS_TYPE (ESP_ERR_WIFI_BASE + 52) /*!< WPS type error */
47+
#define ESP_ERR_WIFI_WPS_SM (ESP_ERR_WIFI_BASE + 53) /*!< WPS state machine is not initialized */
48+
49+
typedef enum wps_type {
50+
WPS_TYPE_DISABLE = 0,
51+
WPS_TYPE_PBC,
52+
WPS_TYPE_PIN,
53+
WPS_TYPE_MAX,
54+
} wps_type_t;
55+
56+
#define WPS_MAX_MANUFACTURER_LEN 65
57+
#define WPS_MAX_MODEL_NUMBER_LEN 33
58+
#define WPS_MAX_MODEL_NAME_LEN 33
59+
#define WPS_MAX_DEVICE_NAME_LEN 33
60+
61+
typedef struct {
62+
char manufacturer[WPS_MAX_MANUFACTURER_LEN]; /*!< Manufacturer, null-terminated string. The default manufcturer is used if the string is empty */
63+
char model_number[WPS_MAX_MODEL_NUMBER_LEN]; /*!< Model number, null-terminated string. The default model number is used if the string is empty */
64+
char model_name[WPS_MAX_MODEL_NAME_LEN]; /*!< Model name, null-terminated string. The default model name is used if the string is empty */
65+
char device_name[WPS_MAX_DEVICE_NAME_LEN]; /*!< Device name, null-terminated string. The default device name is used if the string is empty */
66+
} wps_factory_information_t;
67+
68+
typedef struct {
69+
wps_type_t wps_type;
70+
wps_factory_information_t factory_info;
71+
} esp_wps_config_t;
72+
73+
#define WPS_CONFIG_INIT_DEFAULT(type) { \
74+
.wps_type = type, \
75+
.factory_info = { \
76+
.manufacturer = "ESPRESSIF", \
77+
.model_number = "ESP8266", \
78+
.model_name = "ESPRESSIF IOT", \
79+
.device_name = "ESP STATION", \
80+
} \
81+
}
82+
83+
/**
84+
* @brief Enable Wi-Fi WPS function.
85+
*
86+
* @attention WPS can only be used when ESP8266 station is enabled.
87+
*
88+
* @param wps_type_t wps_type : WPS type, so far only WPS_TYPE_PBC and WPS_TYPE_PIN is supported
89+
*
90+
* @return
91+
* - ESP_OK : succeed
92+
* - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
93+
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
94+
* - ESP_FAIL : wps initialization fails
95+
*/
96+
esp_err_t esp_wifi_wps_enable(const esp_wps_config_t *config);
97+
98+
/**
99+
* @brief Disable Wi-Fi WPS function and release resource it taken.
100+
*
101+
* @param null
102+
*
103+
* @return
104+
* - ESP_OK : succeed
105+
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
106+
*/
107+
esp_err_t esp_wifi_wps_disable(void);
108+
109+
/**
110+
* @brief WPS starts to work.
111+
*
112+
* @attention WPS can only be used when ESP8266 station is enabled.
113+
*
114+
* @param timeout_ms : maximum blocking time before API return.
115+
* - 0 : non-blocking
116+
* - 1~120000 : blocking time (not supported in IDF v1.0)
117+
*
118+
* @return
119+
* - ESP_OK : succeed
120+
* - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
121+
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
122+
* - ESP_ERR_WIFI_WPS_SM : wps state machine is not initialized
123+
* - ESP_FAIL : wps initialization fails
124+
*/
125+
esp_err_t esp_wifi_wps_start(int timeout_ms);
126+
127+
/**
128+
* @}
129+
*/
130+
131+
/**
132+
* @}
133+
*/
134+
135+
#ifdef __cplusplus
136+
}
137+
#endif
138+
139+
#endif /* __ESP_WPS_H__ */

components/esp8266/lib/VERSION

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
gwen:
22
core: b9f2d3e
3-
net80211: b9f2d3e
3+
net80211: 48cd36b
44
pp: 82269d9
55
smartconfig:eca7811
66
wpa: b9f2d3e
77
espnow: 95a55d0
8+
wps: 48cd36b
89
phy: 1055_8

components/esp8266/lib/libnet80211.a

4 Bytes
Binary file not shown.

components/esp8266/lib/libwps.a

266 KB
Binary file not shown.

0 commit comments

Comments
 (0)