2021-12-17 03:50:51 -05:00
/*
2023-09-12 04:46:44 -04:00
* SPDX - FileCopyrightText : 2019 - 2023 Espressif Systems ( Shanghai ) CO LTD
2021-12-17 03:50:51 -05:00
*
* SPDX - License - Identifier : Apache - 2.0
*/
2016-11-07 01:59:35 -05:00
# 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"
2020-02-06 06:28:56 -05:00
# include "esp_compiler.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
* @ {
*/
/** @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 */
2023-09-12 04:46:44 -04:00
/**
* @ brief Enumeration of WPS ( Wi - Fi Protected Setup ) types .
*/
2016-11-07 01:59:35 -05:00
typedef enum wps_type {
2023-09-12 04:46:44 -04:00
WPS_TYPE_DISABLE = 0 , /**< WPS is disabled */
WPS_TYPE_PBC , /**< WPS Push Button Configuration method */
WPS_TYPE_PIN , /**< WPS PIN (Personal Identification Number) method */
WPS_TYPE_MAX /**< Maximum value for WPS type enumeration */
2016-11-09 04:27:12 -05:00
} wps_type_t ;
2016-11-07 01:59:35 -05:00
2023-09-12 04:46:44 -04:00
# define WPS_MAX_MANUFACTURER_LEN 65 /**< Maximum length of the manufacturer name in WPS information */
# define WPS_MAX_MODEL_NUMBER_LEN 33 /**< Maximum length of the model number in WPS information */
# define WPS_MAX_MODEL_NAME_LEN 33 /**< Maximum length of the model name in WPS information */
# define WPS_MAX_DEVICE_NAME_LEN 33 /**< Maximum length of the device name in WPS information */
2018-05-13 22:58:19 -04:00
2023-09-12 04:46:44 -04:00
/**
* @ brief Structure representing WPS factory information for ESP device .
*
* This structure holds various strings representing factory information for a device , such as the manufacturer ,
* model number , model name , and device name . Each string is a null - terminated character array . If any of the
* strings are empty , the default values are used .
*/
2018-05-13 22:58:19 -04:00
typedef struct {
2023-09-12 04:46:44 -04:00
char manufacturer [ WPS_MAX_MANUFACTURER_LEN ] ; /*!< Manufacturer of the device. If empty, the default manufacturer is used. */
char model_number [ WPS_MAX_MODEL_NUMBER_LEN ] ; /*!< Model number of the device. If empty, the default model number is used. */
char model_name [ WPS_MAX_MODEL_NAME_LEN ] ; /*!< Model name of the device. If empty, the default model name is used. */
char device_name [ WPS_MAX_DEVICE_NAME_LEN ] ; /*!< Device name. If empty, the default device name is used. */
2018-05-13 22:58:19 -04:00
} wps_factory_information_t ;
2023-09-12 04:46:44 -04:00
# define PIN_LEN 9 /*!< The length of the WPS PIN (Personal Identification Number). */
/**
* @ brief Structure representing configuration settings for WPS ( Wi - Fi Protected Setup ) .
*
* This structure encapsulates various configuration settings for WPS , including the WPS type ( PBC or PIN ) ,
* factory information that will be shown in the WPS Information Element ( IE ) , and a PIN if the WPS type is
* set to PIN .
*/
2017-08-01 10:29:16 -04:00
typedef struct {
2023-09-12 04:46:44 -04:00
wps_type_t wps_type ; /*!< The type of WPS to be used (PBC or PIN). */
wps_factory_information_t factory_info ; /*!< Factory information to be shown in the WPS Information Element (IE). Vendor can choose to display their own information. */
char pin [ PIN_LEN ] ; /*!< WPS PIN (Personal Identification Number) used when wps_type is set to WPS_TYPE_PIN. */
2018-05-13 22:58:19 -04:00
} esp_wps_config_t ;
2017-08-01 10:29:16 -04:00
2023-09-12 04:46:44 -04:00
/**
* @ def WPS_CONFIG_INIT_DEFAULT ( type )
* @ brief Initialize a default WPS configuration structure with specified WPS type .
*
* This macro initializes a ` esp_wps_config_t ` structure with default values for the specified WPS type .
* It sets the WPS type , factory information ( including default manufacturer , model number , model name , and device name ) ,
* and a default PIN value if applicable .
*
* @ param type The WPS type to be used ( PBC or PIN ) .
* @ return An initialized ` esp_wps_config_t ` structure with the specified WPS type and default values .
*/
2017-08-01 10:29:16 -04:00
# define WPS_CONFIG_INIT_DEFAULT(type) { \
. wps_type = type , \
2018-05-13 22:58:19 -04:00
. factory_info = { \
2020-02-06 06:28:56 -05:00
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR ( manufacturer , " ESPRESSIF " ) \
2022-06-06 01:31:02 -04:00
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR ( model_number , CONFIG_IDF_TARGET ) \
2020-02-06 06:28:56 -05:00
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR ( model_name , " ESPRESSIF IOT " ) \
2022-05-13 04:02:24 -04:00
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR ( device_name , " ESP DEVICE " ) \
} , \
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR ( pin , " 00000000 " ) \
2017-08-01 10:29:16 -04:00
}
2016-11-07 01:59:35 -05:00
/**
* @ brief Enable Wi - Fi WPS function .
*
2023-09-12 04:46:44 -04:00
* @ param config : WPS config to be used in connection
2016-11-07 01:59:35 -05:00
*
2020-11-10 02:40:01 -05:00
* @ return
2016-11-09 04:27:12 -05:00
* - 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 .
*
2020-11-10 02:40:01 -05:00
* @ return
2016-11-09 04:27:12 -05:00
* - 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
/**
2023-09-12 04:46:44 -04:00
* @ brief Start WPS session .
2016-11-07 01:59:35 -05:00
*
2023-09-12 04:46:44 -04:00
* @ attention WPS can only be used when station is enabled . WPS needs to be enabled first for using this API .
2016-11-07 01:59:35 -05:00
*
2022-12-20 02:06:07 -05:00
* @ param timeout_ms : deprecated : This argument ' s value will have not effect in functionality of API .
* The argument will be removed in future .
* The app should start WPS and register for WIFI events to get the status .
* WPS status is updated through WPS events . See wifi_event_t enum for more info .
2016-11-07 01:59:35 -05:00
*
2020-11-10 02:40:01 -05:00
* @ return
2016-11-09 04:27:12 -05:00
* - 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
2022-05-13 04:02:24 -04:00
/**
* @ brief Enable Wi - Fi AP WPS function .
*
* @ attention WPS can only be used when softAP is enabled .
*
2023-09-12 04:46:44 -04:00
* @ param config : wps configuration to be used .
2022-05-13 04:02:24 -04: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_FAIL : wps initialization fails
*/
esp_err_t esp_wifi_ap_wps_enable ( const esp_wps_config_t * config ) ;
/**
* @ brief Disable Wi - Fi SoftAP WPS function and release resource it taken .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
*/
esp_err_t esp_wifi_ap_wps_disable ( void ) ;
/**
* @ brief WPS starts to work .
*
* @ attention WPS can only be used when softAP is enabled .
*
2022-06-08 04:23:59 -04:00
* @ param pin : Pin to be used in case of WPS mode is pin .
* If Pin is not provided , device will use the pin generated / provided
* during esp_wifi_ap_wps_enable ( ) and reported in WIFI_EVENT_AP_WPS_RG_PIN
*
2022-05-13 04:02:24 -04: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
* - ESP_FAIL : wps initialization fails
*/
esp_err_t esp_wifi_ap_wps_start ( const unsigned char * pin ) ;
2016-11-07 01:59:35 -05:00
/**
* @ }
*/
/**
* @ }
*/
# ifdef __cplusplus
}
# endif
# endif /* __ESP_WPS_H__ */