|
@@ -16,6 +16,7 @@
|
|
|
#define __ESP_WPS_H__
|
|
#define __ESP_WPS_H__
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
#include <stdbool.h>
|
|
|
|
|
+#include "esp_err.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
#ifdef __cplusplus
|
|
|
extern "C" {
|
|
extern "C" {
|
|
@@ -40,43 +41,43 @@ extern "C" {
|
|
|
* @{
|
|
* @{
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
+#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 */
|
|
|
|
|
+
|
|
|
typedef enum wps_type {
|
|
typedef enum wps_type {
|
|
|
WPS_TYPE_DISABLE = 0,
|
|
WPS_TYPE_DISABLE = 0,
|
|
|
WPS_TYPE_PBC,
|
|
WPS_TYPE_PBC,
|
|
|
WPS_TYPE_PIN,
|
|
WPS_TYPE_PIN,
|
|
|
- WPS_TYPE_DISPLAY,
|
|
|
|
|
WPS_TYPE_MAX,
|
|
WPS_TYPE_MAX,
|
|
|
-} WPS_TYPE_t;
|
|
|
|
|
-
|
|
|
|
|
-enum wps_cb_status {
|
|
|
|
|
- WPS_CB_ST_SUCCESS = 0, /**< WPS succeed */
|
|
|
|
|
- WPS_CB_ST_FAILED, /**< WPS fail */
|
|
|
|
|
- WPS_CB_ST_TIMEOUT, /**< WPS timeout, fail */
|
|
|
|
|
- WPS_CB_ST_WEP, /**< WPS failed because that WEP is not supported */
|
|
|
|
|
- WPS_CB_ST_SCAN_ERR, /**< can not find the target WPS AP */
|
|
|
|
|
-};
|
|
|
|
|
|
|
+} wps_type_t;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @brief Enable Wi-Fi WPS function.
|
|
* @brief Enable Wi-Fi WPS function.
|
|
|
*
|
|
*
|
|
|
* @attention WPS can only be used when ESP32 station is enabled.
|
|
* @attention WPS can only be used when ESP32 station is enabled.
|
|
|
*
|
|
*
|
|
|
- * @param WPS_TYPE_t wps_type : WPS type, so far only WPS_TYPE_PBC and WPS_TYPE_PIN is supported
|
|
|
|
|
|
|
+ * @param wps_type_t wps_type : WPS type, so far only WPS_TYPE_PBC and WPS_TYPE_PIN is supported
|
|
|
*
|
|
*
|
|
|
- * @return true : succeed
|
|
|
|
|
- * @return false : fail
|
|
|
|
|
|
|
+ * @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_ERR_WIFI_FAIL : wps initialization fails
|
|
|
*/
|
|
*/
|
|
|
-bool esp_wifi_wps_enable(WPS_TYPE_t wps_type);
|
|
|
|
|
|
|
+esp_err_t esp_wifi_wps_enable(wps_type_t wps_type);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @brief Disable Wi-Fi WPS function and release resource it taken.
|
|
* @brief Disable Wi-Fi WPS function and release resource it taken.
|
|
|
*
|
|
*
|
|
|
* @param null
|
|
* @param null
|
|
|
*
|
|
*
|
|
|
- * @return true : succeed
|
|
|
|
|
- * @return false : fail
|
|
|
|
|
|
|
+ * @return
|
|
|
|
|
+ * - ESP_OK : succeed
|
|
|
|
|
+ * - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
|
|
*/
|
|
*/
|
|
|
-bool esp_wifi_wps_disable(void);
|
|
|
|
|
|
|
+esp_err_t esp_wifi_wps_disable(void);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @brief WPS starts to work.
|
|
* @brief WPS starts to work.
|
|
@@ -85,36 +86,14 @@ bool esp_wifi_wps_disable(void);
|
|
|
*
|
|
*
|
|
|
* @param null
|
|
* @param null
|
|
|
*
|
|
*
|
|
|
- * @return true : WPS starts to work successfully, but does not mean WPS succeed.
|
|
|
|
|
- * @return false : fail
|
|
|
|
|
- */
|
|
|
|
|
-bool esp_wifi_wps_start(void);
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * @brief WPS callback.
|
|
|
|
|
- *
|
|
|
|
|
- * @param int status : status of WPS, enum wps_cb_status.
|
|
|
|
|
- * - If parameter status == WPS_CB_ST_SUCCESS in WPS callback, it means WPS got AP's
|
|
|
|
|
- * information, user can call wifi_wps_disable to disable WPS and release resource,
|
|
|
|
|
- * then call wifi_station_connect to connect to target AP.
|
|
|
|
|
- * - Otherwise, it means that WPS fail, user can create a timer to retry WPS by
|
|
|
|
|
- * wifi_wps_start after a while, or call wifi_wps_disable to disable WPS and release resource.
|
|
|
|
|
- *
|
|
|
|
|
- * @return null
|
|
|
|
|
- */
|
|
|
|
|
-typedef void (*wps_st_cb_t)(int status);
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * @brief Set WPS callback.
|
|
|
|
|
- *
|
|
|
|
|
- * @attention WPS can only be used when ESP32 station is enabled.
|
|
|
|
|
- *
|
|
|
|
|
- * @param wps_st_cb_t cb : callback.
|
|
|
|
|
- *
|
|
|
|
|
- * @return true : WPS starts to work successfully, but does not mean WPS succeed.
|
|
|
|
|
- * @return false : fail
|
|
|
|
|
|
|
+ * @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_ERR_WIFI_FAIL : wps initialization fails
|
|
|
*/
|
|
*/
|
|
|
-bool esp_wifi_set_wps_cb(wps_st_cb_t cb);
|
|
|
|
|
|
|
+esp_err_t esp_wifi_wps_start(void);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @}
|
|
* @}
|