extern "C" {
#endif
+#define ESP_ERR_WIFI_OK ESP_OK /*!< No error */
+#define ESP_ERR_WIFI_FAIL ESP_FAIL /*!< General fail code */
+#define ESP_ERR_WIFI_NO_MEM ESP_ERR_NO_MEM /*!< Out of memory */
+#define ESP_ERR_WIFI_ARG ESP_ERR_INVALID_ARG /*!< Invalid argument */
+#define ESP_ERR_WIFI_NOT_INIT (ESP_ERR_WIFI_BASE + 1) /*!< WiFi driver is not installed by esp_wifi_init */
+#define ESP_ERR_WIFI_NOT_START (ESP_ERR_WIFI_BASE + 2) /*!< WiFi driver is not started by esp_wifi_start */
+#define ESP_ERR_WIFI_NOT_SUPPORT (ESP_ERR_WIFI_BASE + 3) /*!< WiFi API doesn't support */
+#define ESP_ERR_WIFI_IF (ESP_ERR_WIFI_BASE + 4) /*!< WiFi interface error */
+#define ESP_ERR_WIFI_MODE (ESP_ERR_WIFI_BASE + 5) /*!< WiFi mode error */
+#define ESP_ERR_WIFI_STATE (ESP_ERR_WIFI_BASE + 6) /*!< WiFi internal state error */
+#define ESP_ERR_WIFI_CONN (ESP_ERR_WIFI_BASE + 7) /*!< WiFi internal control block of station or soft-AP error */
+#define ESP_ERR_WIFI_NVS (ESP_ERR_WIFI_BASE + 8) /*!< WiFi internal NVS module error */
+#define ESP_ERR_WIFI_MAC (ESP_ERR_WIFI_BASE + 9) /*!< MAC address is invalid */
+#define ESP_ERR_WIFI_SSID (ESP_ERR_WIFI_BASE + 10) /*!< SSID is invalid */
+#define ESP_ERR_WIFI_PASSWORD (ESP_ERR_WIFI_BASE + 11) /*!< Passord is invalid */
+#define ESP_ERR_WIFI_TIMEOUT (ESP_ERR_WIFI_BASE + 12) /*!< Timeout error */
+
typedef struct {
system_event_handler_t event_handler; /**< WiFi event handler */
} wifi_init_config_t;
*
* @param wifi_init_config_t *config : provide WiFi init configuration
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NO_MEM : out of memory
+ * - others : refer to error code esp_err.h
*/
esp_err_t esp_wifi_init(wifi_init_config_t *config);
* @attention 1. This API should be called if you want to remove WiFi driver from the system
*
* @return ESP_OK : succeed
- * @return others : fail
*/
esp_err_t esp_wifi_deinit(void);
*
* @param wifi_mode_t mode : WiFi operating modes:
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - others : refer to error code in esp_err.h
*/
esp_err_t esp_wifi_set_mode(wifi_mode_t mode);
*
* @param wifi_mode_t *mode : store current WiFi mode
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
*/
esp_err_t esp_wifi_get_mode(wifi_mode_t *mode);
*
* @param null
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - ESP_ERR_WIFI_NO_MEM : out of memory
+ * - ESP_ERR_WIFI_CONN : WiFi internal error, station or soft-AP control block wrong
+ * - ESP_ERR_WIFI_FAIL : other WiFi internal errors
*/
esp_err_t esp_wifi_start(void);
*
* @param null
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
*/
esp_err_t esp_wifi_stop(void);
*
* @param null
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
+ * - ESP_ERR_WIFI_CONN : WiFi internal error, station or soft-AP control block wrong
+ * - ESP_ERR_WIFI_SSID : SSID of AP which station connects is invalid
*/
esp_err_t esp_wifi_connect(void);
*
* @param null
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
+ * - ESP_ERR_WIFI_FAIL : other WiFi internal errors
*/
esp_err_t esp_wifi_disconnect(void);
*
* @param null
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - others : fail
*/
esp_err_t esp_wifi_clear_fast_connect(void);
*
* @param uint16_t aid : when aid is 0, deauthenticate all stations, otherwise deauthenticate station whose associated id is aid
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - ESP_ERR_WIFI_MODE : WiFi mode is wrong
*/
esp_err_t esp_wifi_deauth_sta(uint16_t aid);
* @param bool block : if block is true, this API will block the caller until the scan is done, otherwise
* it will return immediately
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
+ * - ESP_ERR_WIFI_TIMEOUT : blocking scan is timeout
+ * - others : refer to error code in esp_err.h
*/
esp_err_t esp_wifi_scan_start(wifi_scan_config_t *conf, bool block);
* @brief Stop the scan in process
*
* @param null
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
*/
esp_err_t esp_wifi_scan_stop(void);
*
* @attention This API can only be called when the scan is completed, otherwise it may get wrong value
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
+ * - ESP_ERR_WIFI_ARG : invalid argument
*/
esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number);
the actual AP number this API returns
* @param wifi_ap_record_t *ap_records: wifi_ap_record_t array to hold the found APs
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_NOT_START : WiFi is not started by esp_wifi_start
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - ESP_ERR_WIFI_NO_MEM : out of memory
*/
esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records);
*
* @param wifi_ap_record_t *ap_info: the wifi_ap_record_t to hold station assocated AP
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - others : fail
*/
esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info);
*
* @param wifi_ps_type_t type : power save type
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return ESP_ERR_WIFI_NOT_SUPPORT : not support yet
*/
esp_err_t esp_wifi_set_ps(wifi_ps_type_t type);
*
* @param wifi_ps_type_t *type : store current power save type
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return ESP_ERR_WIFI_NOT_SUPPORT : not support yet
*/
esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type);
* @param wifi_interface_t ifx : interfaces
* @param uint8_t protocol : WiFi protocol bitmap
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_IF : invalid interface
+ * - others : refer to erro code in esp_err.h
*/
esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap);
* @param wifi_interface_t ifx : interfaces
* @param uint8_t protocol : store current WiFi protocol bitmap of interface ifx
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_IF : invalid interface
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - others : refer to error code in esp_err.h
*/
esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap);
* @param wifi_interface_t ifx : interface to be configured
* @param wifi_bandwidth_t bw : bandwidth
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_IF : invalid interface
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - others : refer to error code in esp_err.h
*/
esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw);
* @param wifi_interface_t ifx : interface to be configured
* @param wifi_bandwidth_t *bw : store bandwidth of interface ifx
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_IF : invalid interface
+ * - ESP_ERR_WIFI_ARG : invalid argument
*/
esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw);
* @param uint8_t primary : for HT20, primary is the channel number, for HT40, primary is the primary channel
* @param wifi_second_chan_t second : for HT20, second is ignored, for HT40, second is the second channel
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_IF : invalid interface
+ * - ESP_ERR_WIFI_ARG : invalid argument
*/
esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second);
* @param uint8_t *primary : store current primary channel
* @param wifi_second_chan_t *second : store current second channel
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
*/
esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
*
* @param wifi_country_t country : country type
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - others : refer to error code in esp_err.h
*/
esp_err_t esp_wifi_set_country(wifi_country_t country);
*
* @param wifi_country_t country : store current country
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
*/
esp_err_t esp_wifi_get_country(wifi_country_t *country);
* @param wifi_interface_t ifx : interface
* @param uint8 mac[6]: the MAC address.
*
- * @return true : succeed
- * @return false : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - ESP_ERR_WIFI_IF : invalid interface
+ * - ESP_ERR_WIFI_MAC : invalid mac address
+ * - ESP_ERR_WIFI_MODE : WiFi mode is wrong
+ * - others : refer to error code in esp_err.h
*/
esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, uint8_t mac[6]);
*
* @param uint8_t mac[6] : store mac of this interface ifx
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - ESP_ERR_WIFI_IF : invalid interface
*/
esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]);
* @param void *buf : the data received
* @param uint16_t len : data length
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return none
*/
typedef void (* wifi_promiscuous_cb_t)(void *buf, uint16_t len);
*
* @param wifi_promiscuous_cb_t cb : callback
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
*/
esp_err_t esp_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
*
* @param bool promiscuous : false - disable / true - enable
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
*/
esp_err_t esp_wifi_set_promiscuous(bool en);
*
* @param bool *enable : store the current status of promiscuous mode
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
*/
esp_err_t esp_wifi_get_promiscuous(bool *en);
* @param wifi_interface_t ifx : interface
* @param wifi_config_t *conf : station or soft-AP configuration
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - ESP_ERR_WIFI_IF : invalid interface
+ * - ESP_ERR_WIFI_MODE : invalid mode
+ * - ESP_ERR_WIFI_PASSWORD : invalid password
+ * - ESP_ERR_WIFI_NVS : WiFi internal NVS error
+ * - others : refer to the erro code in esp_err.h
*/
esp_err_t esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf);
* @param wifi_interface_t ifx : interface
* @param wifi_config_t *conf : station or soft-AP configuration
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - ESP_ERR_WIFI_IF : invalid interface
*/
esp_err_t esp_wifi_get_config(wifi_interface_t ifx, wifi_config_t *conf);
*
* @param wifi_sta_list_t *sta: station list
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - ESP_ERR_WIFI_MODE : WiFi mode is wrong
+ * - ESP_ERR_WIFI_CONN : WiFi internal error, the station/soft-AP control block is invalid
*/
esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta);
*
* @param wifi_storage_t storage : storage type
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
*/
esp_err_t esp_wifi_set_storage(wifi_storage_t storage);
-/**
- * @brief The WiFi RX callback function
- *
- * Each time the WiFi need to forward the packets to high layer, the callback function will be called
- *
- */
-typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void *eb);
-
-/**
- * @brief Set the WiFi RX callback
- *
- * @attention 1. Currently we support only one RX callback for each interface
- *
- * @param wifi_interface_t ifx : interface
- * @param wifi_rxcb_t fn : WiFi RX callback
- *
- * @return ESP_OK : succeed
- * @return others : fail
- */
-esp_err_t esp_wifi_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn);
-
/**
* @brief Set auto connect
* The default value is true
*
- * @attention 1.
- *
* @param bool en : true - enable auto connect / false - disable auto connect
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_MODE : WiFi internal error, the station/soft-AP control block is invalid
+ * - others : refer to error code in esp_err.h
*/
esp_err_t esp_wifi_set_auto_connect(bool en);
*
* @param bool *en : store current auto connect configuration
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
*/
esp_err_t esp_wifi_get_auto_connect(bool *en);
1 - WIFI_VND_IE_ID_1
* @param uint8_t *vnd_ie : pointer to a vendor specific element
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
+ * - ESP_ERR_WIFI_ARG : invalid argument
+ * - ESP_ERR_WIFI_NO_MEM : out of memory
*/
esp_err_t esp_wifi_set_vendor_ie(bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, uint8_t *vnd_ie);
* @param esp_vendor_ie_cb_t cb : callback function
* @param void *ctx : reserved
*
- * @return ESP_OK : succeed
- * @return others : fail
+ * @return
+ * - ESP_OK : succeed
+ * - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by eps_wifi_init
*/
esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx);