kopia lustrzana https://github.com/espressif/esp-idf
1. Add wps event processing.
2. Change wps API return type and value.pull/97/merge
rodzic
bdd7fb7a13
commit
3b96f68afd
|
@ -67,6 +67,10 @@ static system_event_handle_t g_system_event_handle_table[] = {
|
|||
{SYSTEM_EVENT_STA_DISCONNECTED, system_event_sta_disconnected_handle_default},
|
||||
{SYSTEM_EVENT_STA_AUTHMODE_CHANGE, NULL},
|
||||
{SYSTEM_EVENT_STA_GOT_IP, system_event_sta_got_ip_default},
|
||||
{SYSTEM_EVENT_STA_WPS_ER_SUCCESS, NULL},
|
||||
{SYSTEM_EVENT_STA_WPS_ER_FAILED, NULL},
|
||||
{SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, NULL},
|
||||
{SYSTEM_EVENT_STA_WPS_ER_PIN, NULL},
|
||||
{SYSTEM_EVENT_AP_START, system_event_ap_start_handle_default},
|
||||
{SYSTEM_EVENT_AP_STOP, system_event_ap_stop_handle_default},
|
||||
{SYSTEM_EVENT_AP_STACONNECTED, NULL},
|
||||
|
@ -221,6 +225,22 @@ static esp_err_t esp_system_event_debug(system_event_t *event)
|
|||
IP2STR(&got_ip->ip_info.gw));
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS: {
|
||||
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_WPS_ER_SUCCESS");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_WPS_ER_FAILED: {
|
||||
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_WPS_ER_FAILED");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT: {
|
||||
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_WPS_ER_TIMEOUT");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_WPS_ER_PIN: {
|
||||
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_WPS_ER_PIN");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_AP_START: {
|
||||
ESP_LOGD(TAG, "SYSTEM_EVENT_AP_START");
|
||||
break;
|
||||
|
|
|
@ -35,6 +35,10 @@ typedef enum {
|
|||
SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected from AP */
|
||||
SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */
|
||||
SYSTEM_EVENT_STA_GOT_IP, /**< ESP32 station got IP from connected AP */
|
||||
SYSTEM_EVENT_STA_WPS_ER_SUCCESS, /**< ESP32 station wps succeeds in enrollee mode */
|
||||
SYSTEM_EVENT_STA_WPS_ER_FAILED, /**< ESP32 station wps fails in enrollee mode */
|
||||
SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /**< ESP32 station wps timeout in enrollee mode */
|
||||
SYSTEM_EVENT_STA_WPS_ER_PIN, /**< ESP32 station wps pin code in enrollee mode */
|
||||
SYSTEM_EVENT_AP_START, /**< ESP32 soft-AP start */
|
||||
SYSTEM_EVENT_AP_STOP, /**< ESP32 soft-AP stop */
|
||||
SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
|
||||
|
@ -73,6 +77,10 @@ typedef struct {
|
|||
tcpip_adapter_ip_info_t ip_info;
|
||||
} system_event_sta_got_ip_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t pin_code; /**< PIN code of station in enrollee mode */
|
||||
}system_event_sta_wps_er_pin_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t mac[6]; /**< MAC address of the station connected to ESP32 soft-AP */
|
||||
uint8_t aid; /**< the aid that ESP32 soft-AP gives to the station connected to */
|
||||
|
@ -94,6 +102,7 @@ typedef union {
|
|||
system_event_sta_scan_done_t scan_done; /**< ESP32 station scan (APs) done */
|
||||
system_event_sta_authmode_change_t auth_change; /**< the auth mode of AP ESP32 station connected to changed */
|
||||
system_event_sta_got_ip_t got_ip; /**< ESP32 station got IP */
|
||||
system_event_sta_wps_er_pin_t sta_er_pin;
|
||||
system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP32 soft-AP */
|
||||
system_event_ap_stadisconnected_t sta_disconnected; /**< a station disconnected to ESP32 soft-AP */
|
||||
system_event_ap_probe_req_rx_t ap_probereqrecved; /**< ESP32 soft-AP receive probe request packet */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define __ESP_WPS_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
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 {
|
||||
WPS_TYPE_DISABLE = 0,
|
||||
WPS_TYPE_PBC,
|
||||
WPS_TYPE_PIN,
|
||||
WPS_TYPE_DISPLAY,
|
||||
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.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @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.
|
||||
|
@ -85,36 +86,14 @@ bool esp_wifi_wps_disable(void);
|
|||
*
|
||||
* @param null
|
||||
*
|
||||
* @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_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
|
||||
*/
|
||||
bool esp_wifi_set_wps_cb(wps_st_cb_t cb);
|
||||
esp_err_t esp_wifi_wps_start(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
Ładowanie…
Reference in New Issue