2016-11-07 01:59:35 -05:00
|
|
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#ifndef __ESP_WPS_H__
|
|
|
|
#define __ESP_WPS_H__
|
|
|
|
|
2017-08-01 10:29:16 -04:00
|
|
|
#include <stdint.h>
|
2016-11-07 01:59:35 -05:00
|
|
|
#include <stdbool.h>
|
2016-11-09 04:27:12 -05:00
|
|
|
#include "esp_err.h"
|
2017-08-01 10:29:16 -04:00
|
|
|
#include "esp_wifi_crypto_types.h"
|
2016-11-07 01:59:35 -05:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** \defgroup WiFi_APIs WiFi Related APIs
|
|
|
|
* @brief WiFi APIs
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @addtogroup WiFi_APIs
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \defgroup WPS_APIs WPS APIs
|
|
|
|
* @brief ESP32 WPS APIs
|
|
|
|
*
|
|
|
|
* WPS can only be used when ESP32 station is enabled.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @addtogroup WPS_APIs
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2016-11-09 04:27:12 -05:00
|
|
|
#define ESP_ERR_WIFI_REGISTRAR (ESP_ERR_WIFI_BASE + 51) /*!< WPS registrar is not supported */
|
|
|
|
#define ESP_ERR_WIFI_WPS_TYPE (ESP_ERR_WIFI_BASE + 52) /*!< WPS type error */
|
|
|
|
#define ESP_ERR_WIFI_WPS_SM (ESP_ERR_WIFI_BASE + 53) /*!< WPS state machine is not initialized */
|
|
|
|
|
2016-11-07 01:59:35 -05:00
|
|
|
typedef enum wps_type {
|
|
|
|
WPS_TYPE_DISABLE = 0,
|
|
|
|
WPS_TYPE_PBC,
|
|
|
|
WPS_TYPE_PIN,
|
|
|
|
WPS_TYPE_MAX,
|
2016-11-09 04:27:12 -05:00
|
|
|
} wps_type_t;
|
2016-11-07 01:59:35 -05:00
|
|
|
|
2017-08-01 10:29:16 -04:00
|
|
|
extern const wps_crypto_funcs_t g_wifi_default_wps_crypto_funcs;
|
|
|
|
|
2018-05-13 22:58:19 -04:00
|
|
|
#define WPS_MAX_MANUFACTURER_LEN 65
|
|
|
|
#define WPS_MAX_MODEL_NUMBER_LEN 33
|
|
|
|
#define WPS_MAX_MODEL_NAME_LEN 33
|
|
|
|
#define WPS_MAX_DEVICE_NAME_LEN 33
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char manufacturer[WPS_MAX_MANUFACTURER_LEN]; /*!< Manufacturer, null-terminated string. The default manufcturer is used if the string is empty */
|
|
|
|
char model_number[WPS_MAX_MODEL_NUMBER_LEN]; /*!< Model number, null-terminated string. The default model number is used if the string is empty */
|
|
|
|
char model_name[WPS_MAX_MODEL_NAME_LEN]; /*!< Model name, null-terminated string. The default model name is used if the string is empty */
|
|
|
|
char device_name[WPS_MAX_DEVICE_NAME_LEN]; /*!< Device name, null-terminated string. The default device name is used if the string is empty */
|
|
|
|
} wps_factory_information_t;
|
|
|
|
|
2017-08-01 10:29:16 -04:00
|
|
|
typedef struct {
|
|
|
|
wps_type_t wps_type;
|
|
|
|
const wps_crypto_funcs_t *crypto_funcs;
|
2018-05-13 22:58:19 -04:00
|
|
|
wps_factory_information_t factory_info;
|
|
|
|
} esp_wps_config_t;
|
2017-08-01 10:29:16 -04:00
|
|
|
|
2020-01-14 09:10:28 -05:00
|
|
|
/* C & C++ compilers have different rules about C99-style named initializers */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define WPS_AGG(X) { X }
|
|
|
|
#else
|
|
|
|
#define WPS_AGG(X) X
|
|
|
|
#endif
|
|
|
|
|
2017-08-01 10:29:16 -04:00
|
|
|
#define WPS_CONFIG_INIT_DEFAULT(type) { \
|
|
|
|
.wps_type = type, \
|
|
|
|
.crypto_funcs = &g_wifi_default_wps_crypto_funcs, \
|
2018-05-13 22:58:19 -04:00
|
|
|
.factory_info = { \
|
2020-01-14 09:10:28 -05:00
|
|
|
WPS_AGG( .manufacturer = "ESPRESSIF" ), \
|
|
|
|
WPS_AGG( .model_number = "ESP32" ), \
|
|
|
|
WPS_AGG( .model_name = "ESPRESSIF IOT" ), \
|
|
|
|
WPS_AGG( .device_name = "ESP STATION" ), \
|
2018-05-13 22:58:19 -04:00
|
|
|
} \
|
2017-08-01 10:29:16 -04:00
|
|
|
}
|
|
|
|
|
2016-11-07 01:59:35 -05:00
|
|
|
/**
|
|
|
|
* @brief Enable Wi-Fi WPS function.
|
|
|
|
*
|
|
|
|
* @attention WPS can only be used when ESP32 station is enabled.
|
|
|
|
*
|
2016-11-09 04:27:12 -05:00
|
|
|
* @param wps_type_t wps_type : WPS type, so far only WPS_TYPE_PBC and WPS_TYPE_PIN is supported
|
2016-11-07 01:59:35 -05:00
|
|
|
*
|
2016-11-09 04:27:12 -05:00
|
|
|
* @return
|
|
|
|
* - ESP_OK : succeed
|
|
|
|
* - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
|
|
|
|
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
2018-02-09 08:43:11 -05:00
|
|
|
* - ESP_FAIL : wps initialization fails
|
2016-11-07 01:59:35 -05:00
|
|
|
*/
|
2017-08-01 10:29:16 -04:00
|
|
|
esp_err_t esp_wifi_wps_enable(const esp_wps_config_t *config);
|
2016-11-07 01:59:35 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable Wi-Fi WPS function and release resource it taken.
|
|
|
|
*
|
|
|
|
* @param null
|
|
|
|
*
|
2016-11-09 04:27:12 -05:00
|
|
|
* @return
|
|
|
|
* - ESP_OK : succeed
|
|
|
|
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
2016-11-07 01:59:35 -05:00
|
|
|
*/
|
2016-11-09 04:27:12 -05:00
|
|
|
esp_err_t esp_wifi_wps_disable(void);
|
2016-11-07 01:59:35 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief WPS starts to work.
|
|
|
|
*
|
|
|
|
* @attention WPS can only be used when ESP32 station is enabled.
|
|
|
|
*
|
2016-11-10 21:51:33 -05:00
|
|
|
* @param timeout_ms : maximum blocking time before API return.
|
|
|
|
* - 0 : non-blocking
|
|
|
|
* - 1~120000 : blocking time (not supported in IDF v1.0)
|
2016-11-07 01:59:35 -05:00
|
|
|
*
|
2016-11-09 04:27:12 -05:00
|
|
|
* @return
|
|
|
|
* - ESP_OK : succeed
|
|
|
|
* - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
|
|
|
|
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
|
|
|
* - ESP_ERR_WIFI_WPS_SM : wps state machine is not initialized
|
2018-02-09 08:43:11 -05:00
|
|
|
* - ESP_FAIL : wps initialization fails
|
2016-11-07 01:59:35 -05:00
|
|
|
*/
|
2016-11-10 21:51:33 -05:00
|
|
|
esp_err_t esp_wifi_wps_start(int timeout_ms);
|
2016-11-07 01:59:35 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __ESP_WPS_H__ */
|