2021-04-07 03:04:51 -04:00
/*
2023-07-06 02:35:56 -04:00
* SPDX - FileCopyrightText : 2015 - 2023 Espressif Systems ( Shanghai ) CO LTD
2021-04-07 03:04:51 -04:00
*
* SPDX - License - Identifier : Apache - 2.0
*/
2016-08-17 11:08:22 -04:00
2016-09-07 08:33:13 -04:00
/* Notes about WiFi Programming
*
2023-02-10 18:38:45 -05:00
* WiFi programming model can be depicted as following picture :
2016-09-07 08:33:13 -04:00
*
*
* default handler user handler
2016-09-12 04:43:32 -04:00
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* | | event | | callback or | |
* | tcpip | - - - - - - - - - > | event | - - - - - - - - - - > | application |
2016-09-07 08:33:13 -04:00
* | stack | | task | event | task |
* | - - - - - - - - - - - | | - - - - - - - - - - - - - | | - - - - - - - - - - - - - |
* / | \ |
* | |
* event | |
* | |
* | |
* - - - - - - - - - - - - - - - |
* | | |
* | WiFi Driver | / __________________ |
* | | \ API call
* | |
* | - - - - - - - - - - - - - |
2016-09-12 04:43:32 -04:00
*
* The WiFi driver can be consider as black box , it knows nothing about the high layer code , such as
* TCPIP stack , application task , event task etc , all it can do is to receive API call from high layer
* or post event queue to a specified Queue , which is initialized by API esp_wifi_init ( ) .
2016-09-07 08:33:13 -04:00
*
* The event task is a daemon task , which receives events from WiFi driver or from other subsystem , such
* as TCPIP stack , event task will call the default callback function on receiving the event . For example ,
2021-12-02 05:19:28 -05:00
* on receiving event WIFI_EVENT_STA_CONNECTED , it will call esp_netif API to start the DHCP
2016-09-12 04:43:32 -04:00
* client in it ' s default handler .
*
* Application can register it ' s own event callback function by API esp_event_init , then the application callback
* function will be called after the default callback . Also , if application doesn ' t want to execute the callback
* in the event task , what it needs to do is to post the related event to application task in the application callback function .
2016-09-07 08:33:13 -04:00
*
2016-09-12 04:43:32 -04:00
* The application task ( code ) generally mixes all these thing together , it calls APIs to init the system / WiFi and
2016-09-07 08:33:13 -04:00
* handle the events when necessary .
2016-09-12 04:43:32 -04:00
*
2016-09-07 08:33:13 -04:00
*/
2016-08-17 11:08:22 -04:00
# ifndef __ESP_WIFI_H__
# define __ESP_WIFI_H__
# include <stdint.h>
# include <stdbool.h>
2016-09-26 23:33:19 -04:00
# include "esp_err.h"
2016-09-26 23:47:47 -04:00
# include "esp_wifi_types.h"
2016-09-26 23:33:19 -04:00
# include "esp_event.h"
2019-07-07 23:26:18 -04:00
# include "esp_private/esp_wifi_private.h"
2019-11-04 02:02:19 -05:00
# include "esp_wifi_default.h"
2016-08-17 11:08:22 -04:00
# ifdef __cplusplus
extern " C " {
# endif
2023-05-26 03:11:47 -04:00
# define ESP_ERR_WIFI_NOT_INIT (ESP_ERR_WIFI_BASE + 1) /*!< WiFi driver was not installed by esp_wifi_init */
# define ESP_ERR_WIFI_NOT_STARTED (ESP_ERR_WIFI_BASE + 2) /*!< WiFi driver was not started by esp_wifi_start */
# define ESP_ERR_WIFI_NOT_STOPPED (ESP_ERR_WIFI_BASE + 3) /*!< WiFi driver was not stopped by esp_wifi_stop */
# 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) /*!< Password is invalid */
# define ESP_ERR_WIFI_TIMEOUT (ESP_ERR_WIFI_BASE + 12) /*!< Timeout error */
# define ESP_ERR_WIFI_WAKE_FAIL (ESP_ERR_WIFI_BASE + 13) /*!< WiFi is in sleep state(RF closed) and wakeup fail */
# define ESP_ERR_WIFI_WOULD_BLOCK (ESP_ERR_WIFI_BASE + 14) /*!< The caller would block */
# define ESP_ERR_WIFI_NOT_CONNECT (ESP_ERR_WIFI_BASE + 15) /*!< Station still in disconnect status */
2016-11-08 04:34:46 -05:00
2023-05-26 03:11:47 -04:00
# define ESP_ERR_WIFI_POST (ESP_ERR_WIFI_BASE + 18) /*!< Failed to post the event to WiFi task */
# define ESP_ERR_WIFI_INIT_STATE (ESP_ERR_WIFI_BASE + 19) /*!< Invalid WiFi state when init/deinit is called */
# define ESP_ERR_WIFI_STOP_STATE (ESP_ERR_WIFI_BASE + 20) /*!< Returned when WiFi is stopping */
# define ESP_ERR_WIFI_NOT_ASSOC (ESP_ERR_WIFI_BASE + 21) /*!< The WiFi connection is not associated */
# define ESP_ERR_WIFI_TX_DISALLOW (ESP_ERR_WIFI_BASE + 22) /*!< The WiFi TX is disallowed */
2019-07-07 23:26:18 -04:00
2023-05-26 03:11:47 -04:00
# define ESP_ERR_WIFI_TWT_FULL (ESP_ERR_WIFI_BASE + 23) /*!< no available flow id */
# define ESP_ERR_WIFI_TWT_SETUP_TIMEOUT (ESP_ERR_WIFI_BASE + 24) /*!< Timeout of receiving twt setup response frame, timeout times can be set during twt setup */
2023-06-05 08:06:52 -04:00
# define ESP_ERR_WIFI_TWT_SETUP_TXFAIL (ESP_ERR_WIFI_BASE + 25) /*!< TWT setup frame tx failed */
# define ESP_ERR_WIFI_TWT_SETUP_REJECT (ESP_ERR_WIFI_BASE + 26) /*!< The twt setup request was rejected by the AP */
2023-07-17 08:23:45 -04:00
# define ESP_ERR_WIFI_DISCARD (ESP_ERR_WIFI_BASE + 27) /*!< Discard frame */
2023-11-08 04:13:04 -05:00
# define ESP_ERR_WIFI_ROC_IN_PROGRESS (ESP_ERR_WIFI_BASE + 28) /*!< ROC op is in progress */
2022-12-20 09:07:09 -05:00
2016-11-15 12:35:09 -05:00
/**
* @ brief WiFi stack configuration parameters passed to esp_wifi_init call .
*/
2016-08-17 11:08:22 -04:00
typedef struct {
2017-10-19 05:42:55 -04:00
wifi_osi_funcs_t * osi_funcs ; /**< WiFi OS functions */
2017-08-01 10:29:16 -04:00
wpa_crypto_funcs_t wpa_crypto_funcs ; /**< WiFi station crypto functions when connect */
2017-02-21 01:52:25 -05:00
int static_rx_buf_num ; /**< WiFi static RX buffer number */
int dynamic_rx_buf_num ; /**< WiFi dynamic RX buffer number */
2017-03-14 09:03:41 -04:00
int tx_buf_type ; /**< WiFi TX buffer type */
int static_tx_buf_num ; /**< WiFi static TX buffer number */
2017-02-21 01:52:25 -05:00
int dynamic_tx_buf_num ; /**< WiFi dynamic TX buffer number */
2023-07-25 23:47:33 -04:00
int rx_mgmt_buf_type ; /**< WiFi RX MGMT buffer type */
int rx_mgmt_buf_num ; /**< WiFi RX MGMT buffer number */
2020-02-13 01:26:48 -05:00
int cache_tx_buf_num ; /**< WiFi TX cache buffer number */
2018-05-09 04:44:06 -04:00
int csi_enable ; /**< WiFi channel state information enable flag */
2017-11-17 02:47:22 -05:00
int ampdu_rx_enable ; /**< WiFi AMPDU RX feature enable flag */
int ampdu_tx_enable ; /**< WiFi AMPDU TX feature enable flag */
2021-01-15 04:00:15 -05:00
int amsdu_tx_enable ; /**< WiFi AMSDU TX feature enable flag */
2017-02-21 01:52:25 -05:00
int nvs_enable ; /**< WiFi NVS flash enable flag */
int nano_enable ; /**< Nano option for printf/scan family enable flag */
2017-06-23 10:46:10 -04:00
int rx_ba_win ; /**< WiFi Block Ack RX window size */
2018-05-03 05:02:44 -04:00
int wifi_task_core_id ; /**< WiFi Task Core ID */
2018-09-23 09:09:59 -04:00
int beacon_max_len ; /**< WiFi softAP maximum length of the beacon */
2019-02-13 04:37:53 -05:00
int mgmt_sbuf_num ; /**< WiFi management short buffer number, the minimum value is 6, the maximum value is 32 */
2019-11-11 06:22:07 -05:00
uint64_t feature_caps ; /**< Enables additional WiFi features and capabilities */
2021-03-11 05:09:58 -05:00
bool sta_disconnected_pm ; /**< WiFi Power Management for station at disconnected status */
2022-08-03 05:26:33 -04:00
int espnow_max_encrypt_num ; /**< Maximum encrypt number of peers supported by espnow */
2017-02-21 01:52:25 -05:00
int magic ; /**< WiFi init magic number, it should be the last field */
2016-08-17 11:08:22 -04:00
} wifi_init_config_t ;
2023-02-10 18:38:45 -05:00
# ifdef CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM
# define WIFI_STATIC_TX_BUFFER_NUM CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM
2017-03-14 09:03:41 -04:00
# else
# define WIFI_STATIC_TX_BUFFER_NUM 0
# endif
2022-10-31 11:40:12 -04:00
# if CONFIG_SPIRAM
2023-02-10 18:38:45 -05:00
# define WIFI_CACHE_TX_BUFFER_NUM CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM
2020-02-13 01:26:48 -05:00
# else
# define WIFI_CACHE_TX_BUFFER_NUM 0
# endif
2023-02-10 18:38:45 -05:00
# ifdef CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM
# define WIFI_DYNAMIC_TX_BUFFER_NUM CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM
2017-03-14 09:03:41 -04:00
# else
# define WIFI_DYNAMIC_TX_BUFFER_NUM 0
# endif
2023-07-25 23:47:33 -04:00
# ifdef CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF
# define WIFI_RX_MGMT_BUF_NUM_DEF CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF
# else
# define WIFI_RX_MGMT_BUF_NUM_DEF 0
# endif
2023-02-10 18:38:45 -05:00
# if CONFIG_ESP_WIFI_CSI_ENABLED
2018-05-09 04:44:06 -04:00
# define WIFI_CSI_ENABLED 1
# else
# define WIFI_CSI_ENABLED 0
# endif
2023-02-10 18:38:45 -05:00
# if CONFIG_ESP_WIFI_AMPDU_RX_ENABLED
2017-11-17 02:47:22 -05:00
# define WIFI_AMPDU_RX_ENABLED 1
2017-02-21 01:52:25 -05:00
# else
2017-11-17 02:47:22 -05:00
# define WIFI_AMPDU_RX_ENABLED 0
# endif
2023-02-10 18:38:45 -05:00
# if CONFIG_ESP_WIFI_AMPDU_TX_ENABLED
2017-11-17 02:47:22 -05:00
# define WIFI_AMPDU_TX_ENABLED 1
# else
# define WIFI_AMPDU_TX_ENABLED 0
2017-02-21 01:52:25 -05:00
# endif
2023-02-10 18:38:45 -05:00
# if CONFIG_ESP_WIFI_AMSDU_TX_ENABLED
2021-01-15 04:00:15 -05:00
# define WIFI_AMSDU_TX_ENABLED 1
# else
# define WIFI_AMSDU_TX_ENABLED 0
# endif
2023-02-10 18:38:45 -05:00
# if CONFIG_ESP_WIFI_NVS_ENABLED
2017-02-21 01:52:25 -05:00
# define WIFI_NVS_ENABLED 1
# else
# define WIFI_NVS_ENABLED 0
# endif
# if CONFIG_NEWLIB_NANO_FORMAT
# define WIFI_NANO_FORMAT_ENABLED 1
# else
# define WIFI_NANO_FORMAT_ENABLED 0
# endif
2017-08-01 10:29:16 -04:00
extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs ;
2017-02-21 01:52:25 -05:00
# define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F
2017-08-08 00:53:52 -04:00
2023-02-10 18:38:45 -05:00
# ifdef CONFIG_ESP_WIFI_AMPDU_RX_ENABLED
# define WIFI_DEFAULT_RX_BA_WIN CONFIG_ESP_WIFI_RX_BA_WIN
2017-08-21 00:41:31 -04:00
# else
2017-11-17 02:47:22 -05:00
# define WIFI_DEFAULT_RX_BA_WIN 0 /* unused if ampdu_rx_enable == false */
2017-08-21 00:41:31 -04:00
# endif
2023-02-10 18:38:45 -05:00
# if CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_1
2018-05-03 05:02:44 -04:00
# define WIFI_TASK_CORE_ID 1
# else
# define WIFI_TASK_CORE_ID 0
# endif
2023-02-10 18:38:45 -05:00
# ifdef CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN
# define WIFI_SOFTAP_BEACON_MAX_LEN CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN
2018-09-23 09:09:59 -04:00
# else
# define WIFI_SOFTAP_BEACON_MAX_LEN 752
# endif
2023-02-10 18:38:45 -05:00
# ifdef CONFIG_ESP_WIFI_MGMT_SBUF_NUM
# define WIFI_MGMT_SBUF_NUM CONFIG_ESP_WIFI_MGMT_SBUF_NUM
2019-02-13 04:37:53 -05:00
# else
# define WIFI_MGMT_SBUF_NUM 32
# endif
2021-03-11 05:09:58 -05:00
# if CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE
# define WIFI_STA_DISCONNECTED_PM_ENABLED true
# else
# define WIFI_STA_DISCONNECTED_PM_ENABLED false
# endif
2023-11-16 08:43:36 -05:00
# if CONFIG_ESP_WIFI_ENABLE_WPA3_SAE
# define WIFI_ENABLE_WPA3_SAE (1<<0)
# else
# define WIFI_ENABLE_WPA3_SAE 0
# endif
# if CONFIG_SPIRAM
# define WIFI_ENABLE_SPIRAM (1<<1)
# else
# define WIFI_ENABLE_SPIRAM 0
# endif
# if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT
# define WIFI_FTM_INITIATOR (1<<2)
# else
# define WIFI_FTM_INITIATOR 0
# endif
# if CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT
# define WIFI_FTM_RESPONDER (1<<3)
# else
# define WIFI_FTM_RESPONDER 0
# endif
# define CONFIG_FEATURE_WPA3_SAE_BIT (1<<0)
2020-02-13 01:26:48 -05:00
# define CONFIG_FEATURE_CACHE_TX_BUF_BIT (1<<1)
2021-01-21 09:25:39 -05:00
# define CONFIG_FEATURE_FTM_INITIATOR_BIT (1<<2)
# define CONFIG_FEATURE_FTM_RESPONDER_BIT (1<<3)
2019-11-11 06:22:07 -05:00
2023-11-16 08:43:36 -05:00
/* Set additional WiFi features and capabilities */
# define WIFI_FEATURE_CAPS (WIFI_ENABLE_WPA3_SAE | \
WIFI_ENABLE_SPIRAM | \
WIFI_FTM_INITIATOR | \
WIFI_FTM_RESPONDER )
2016-09-26 23:33:19 -04:00
# define WIFI_INIT_CONFIG_DEFAULT() { \
2017-10-19 05:42:55 -04:00
. osi_funcs = & g_wifi_osi_funcs , \
2017-08-01 10:29:16 -04:00
. wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs , \
2023-02-10 18:38:45 -05:00
. static_rx_buf_num = CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM , \
. dynamic_rx_buf_num = CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM , \
. tx_buf_type = CONFIG_ESP_WIFI_TX_BUFFER_TYPE , \
2017-03-14 09:03:41 -04:00
. static_tx_buf_num = WIFI_STATIC_TX_BUFFER_NUM , \
. dynamic_tx_buf_num = WIFI_DYNAMIC_TX_BUFFER_NUM , \
2023-07-25 23:47:33 -04:00
. rx_mgmt_buf_type = CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF , \
. rx_mgmt_buf_num = WIFI_RX_MGMT_BUF_NUM_DEF , \
2020-02-13 01:26:48 -05:00
. cache_tx_buf_num = WIFI_CACHE_TX_BUFFER_NUM , \
2018-05-09 04:44:06 -04:00
. csi_enable = WIFI_CSI_ENABLED , \
2017-11-17 02:47:22 -05:00
. ampdu_rx_enable = WIFI_AMPDU_RX_ENABLED , \
. ampdu_tx_enable = WIFI_AMPDU_TX_ENABLED , \
2021-01-15 04:00:15 -05:00
. amsdu_tx_enable = WIFI_AMSDU_TX_ENABLED , \
2017-02-21 01:52:25 -05:00
. nvs_enable = WIFI_NVS_ENABLED , \
. nano_enable = WIFI_NANO_FORMAT_ENABLED , \
2017-08-21 00:41:31 -04:00
. rx_ba_win = WIFI_DEFAULT_RX_BA_WIN , \
2018-05-03 05:02:44 -04:00
. wifi_task_core_id = WIFI_TASK_CORE_ID , \
2018-09-23 09:09:59 -04:00
. beacon_max_len = WIFI_SOFTAP_BEACON_MAX_LEN , \
2019-02-13 04:37:53 -05:00
. mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM , \
2023-11-16 08:43:36 -05:00
. feature_caps = WIFI_FEATURE_CAPS , \
2021-03-11 05:09:58 -05:00
. sta_disconnected_pm = WIFI_STA_DISCONNECTED_PM_ENABLED , \
2022-08-03 05:26:33 -04:00
. espnow_max_encrypt_num = CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM , \
2017-02-21 01:52:25 -05:00
. magic = WIFI_INIT_CONFIG_MAGIC \
2021-02-16 12:07:46 -05:00
}
2016-09-26 08:15:16 -04:00
2016-09-07 05:29:08 -04:00
/**
2021-11-26 06:11:09 -05:00
* @ brief Initialize WiFi
* Allocate resource for WiFi driver , such as WiFi control structure , RX / TX buffer ,
* WiFi NVS structure etc . This WiFi also starts WiFi task
2016-09-07 05:29:08 -04:00
*
2016-09-12 04:43:32 -04:00
* @ attention 1. This API must be called before all other WiFi API can be called
2021-11-26 06:11:09 -05:00
* @ attention 2. Always use WIFI_INIT_CONFIG_DEFAULT macro to initialize the configuration to default values , this can
* guarantee all the fields get correct value when more fields are added into wifi_init_config_t
* in future release . If you want to set your own initial values , overwrite the default values
* which are set by WIFI_INIT_CONFIG_DEFAULT . Please be notified that the field ' magic ' of
2017-02-21 01:52:25 -05:00
* wifi_init_config_t should always be WIFI_INIT_CONFIG_MAGIC !
2016-09-12 04:43:32 -04:00
*
2021-11-26 06:11:09 -05:00
* @ param config pointer to WiFi initialized configuration structure ; can point to a temporary variable .
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2018-02-09 08:43:11 -05:00
* - ESP_ERR_NO_MEM : out of memory
2016-12-21 20:37:03 -05:00
* - others : refer to error code esp_err . h
2016-09-07 05:29:08 -04:00
*/
2017-10-12 21:47:19 -04:00
esp_err_t esp_wifi_init ( const wifi_init_config_t * config ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
2016-09-12 04:43:32 -04:00
* @ brief Deinit WiFi
* Free all resource allocated in esp_wifi_init and stop WiFi task
2016-09-07 05:29:08 -04:00
*
2016-09-12 04:43:32 -04:00
* @ attention 1. This API should be called if you want to remove WiFi driver from the system
2016-09-07 05:29:08 -04:00
*
2020-11-12 03:18:24 -05:00
* @ return
2018-08-28 08:16:17 -04:00
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_deinit ( void ) ;
2016-09-07 05:29:08 -04:00
/**
* @ brief Set the WiFi operating mode
*
2023-02-13 23:36:40 -05:00
* Set the WiFi operating mode as station , soft - AP , station + soft - AP or NAN .
2021-04-07 03:04:51 -04:00
* The default mode is station mode .
2016-09-07 05:29:08 -04:00
*
2016-11-15 12:35:09 -05:00
* @ param mode WiFi operating mode
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-11-15 12:35:09 -05:00
* - others : refer to error code in esp_err . h
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_set_mode ( wifi_mode_t mode ) ;
2016-09-07 05:29:08 -04:00
/**
* @ brief Get current operating mode of WiFi
*
2016-11-15 12:35:09 -05:00
* @ param [ out ] mode store current WiFi mode
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_get_mode ( wifi_mode_t * mode ) ;
2016-09-07 05:29:08 -04:00
/**
2016-09-12 04:43:32 -04:00
* @ brief Start WiFi according to current configuration
2023-02-13 23:36:40 -05:00
* If mode is WIFI_MODE_STA , it creates station control block and starts station
* If mode is WIFI_MODE_AP , it creates soft - AP control block and starts soft - AP
* If mode is WIFI_MODE_APSTA , it creates soft - AP and station control block and starts soft - AP and station
* If mode is WIFI_MODE_NAN , it creates NAN control block and starts NAN
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
* - ESP_ERR_NO_MEM : out of memory
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_CONN : WiFi internal error , station or soft - AP control block wrong
2018-02-09 08:43:11 -05:00
* - ESP_FAIL : other WiFi internal errors
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_start ( void ) ;
2016-09-07 05:29:08 -04:00
/**
2016-09-12 04:43:32 -04:00
* @ brief Stop WiFi
2023-02-13 23:36:40 -05:00
* If mode is WIFI_MODE_STA , it stops station and frees station control block
* If mode is WIFI_MODE_AP , it stops soft - AP and frees soft - AP control block
* If mode is WIFI_MODE_APSTA , it stops station / soft - AP and frees station / soft - AP control block
* If mode is WIFI_MODE_NAN , it stops NAN and frees NAN control block
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_stop ( void ) ;
2016-11-21 04:15:37 -05:00
/**
* @ brief Restore WiFi stack persistent settings to default values
*
* This function will reset settings made using the following APIs :
2020-10-26 08:27:44 -04:00
* - esp_wifi_set_bandwidth ,
2016-11-21 04:15:37 -05:00
* - esp_wifi_set_protocol ,
* - esp_wifi_set_config related
* - esp_wifi_set_mode
*
* @ return
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-11-21 04:15:37 -05:00
*/
esp_err_t esp_wifi_restore ( void ) ;
2016-09-07 05:29:08 -04:00
/**
2023-02-10 18:38:45 -05:00
* @ brief Connect WiFi station to the AP .
2016-09-07 05:29:08 -04:00
*
* @ attention 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode
2023-02-10 18:38:45 -05:00
* @ attention 2. If station interface is connected to an AP , call esp_wifi_disconnect to disconnect .
* @ attention 3. The scanning triggered by esp_wifi_scan_start ( ) will not be effective until connection between device and the AP is established .
* If device is scanning and connecting at the same time , it will abort scanning and return a warning message and error
2018-08-26 00:38:06 -04:00
* number ESP_ERR_WIFI_STATE .
2023-08-18 02:16:34 -04:00
* @ attention 4. This API attempts to connect to an Access Point ( AP ) only once . To enable reconnection in case of a connection failure , please use
* the ' failure_retry_cnt ' feature in the ' wifi_sta_config_t ' . Users are suggested to implement reconnection logic in their application
* for scenarios where the specified AP does not exist , or reconnection is desired after the device has received a disconnect event .
2020-11-12 03:18:24 -05:00
*
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2019-10-07 10:48:32 -04:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
2016-11-15 12:35:09 -05:00
* - 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
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_connect ( void ) ;
2016-09-07 05:29:08 -04:00
/**
2023-02-10 18:38:45 -05:00
* @ brief Disconnect WiFi station from the AP .
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi was not initialized by esp_wifi_init
2017-01-02 00:51:48 -05:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi was not started by esp_wifi_start
2018-02-09 08:43:11 -05:00
* - ESP_FAIL : other WiFi internal errors
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_disconnect ( void ) ;
2016-09-07 05:29:08 -04:00
/**
* @ brief Currently this API is just an stub API
*
2016-11-15 12:35:09 -05:00
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
* - others : fail
2016-09-07 05:29:08 -04:00
*/
2016-08-30 06:09:48 -04:00
esp_err_t esp_wifi_clear_fast_connect ( void ) ;
2016-09-07 05:29:08 -04:00
/**
2016-10-26 09:50:15 -04:00
* @ brief deauthenticate all stations or associated id equals to aid
2016-09-07 05:29:08 -04:00
*
2016-11-15 12:35:09 -05:00
* @ param aid when aid is 0 , deauthenticate all stations , otherwise deauthenticate station whose associated id is aid
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2017-01-02 00:51:48 -05:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi was not started by esp_wifi_start
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_MODE : WiFi mode is wrong
2016-09-07 05:29:08 -04:00
*/
2016-10-26 09:50:15 -04:00
esp_err_t esp_wifi_deauth_sta ( uint16_t aid ) ;
2016-08-30 06:09:48 -04:00
2016-09-07 05:29:08 -04:00
/**
* @ brief Scan all available APs .
*
2023-11-03 04:17:24 -04:00
* @ attention If this API is called , the found APs are stored in WiFi driver dynamic allocated memory . And then
* can be freed in esp_wifi_scan_get_ap_records ( ) , esp_wifi_scan_get_ap_record ( ) or esp_wifi_clear_ap_list ( ) ,
* so call any one to free the memory once the scan is done .
2017-03-16 04:20:19 -04:00
* @ attention The values of maximum active scan time and passive scan time per channel are limited to 1500 milliseconds .
* Values above 1500 ms may cause station to disconnect from AP and are not recommended .
2016-09-07 05:29:08 -04:00
*
2023-08-18 02:16:34 -04:00
* @ param config configuration settings for scanning , if set to NULL default settings will be used
* of which default values are show_hidden : false , scan_type : active , scan_time . active . min : 0 ,
* scan_time . active . max : 120 miliseconds , scan_time . passive : 360 miliseconds
*
2016-11-15 12:35:09 -05:00
* @ param block if block is true , this API will block the caller until the scan is done , otherwise
2016-09-12 04:43:32 -04:00
* it will return immediately
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2017-01-02 00:51:48 -05:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi was not started by esp_wifi_start
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_TIMEOUT : blocking scan is timeout
2018-08-26 00:38:06 -04:00
* - ESP_ERR_WIFI_STATE : wifi still connecting when invoke esp_wifi_scan_start
2016-11-15 12:35:09 -05:00
* - others : refer to error code in esp_err . h
2016-09-07 05:29:08 -04:00
*/
2017-10-12 21:47:19 -04:00
esp_err_t esp_wifi_scan_start ( const wifi_scan_config_t * config , bool block ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
* @ brief Stop the scan in process
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2017-01-02 00:51:48 -05:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_scan_stop ( void ) ;
2016-09-07 05:29:08 -04:00
/**
* @ brief Get number of APs found in last scan
*
2023-10-04 05:49:52 -04:00
* @ param [ out ] number store number of APs found in last scan
2016-09-07 05:29:08 -04:00
*
2016-11-15 12:35:09 -05:00
* @ attention This API can only be called when the scan is completed , otherwise it may get wrong value .
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2017-01-02 00:51:48 -05:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-09-07 05:29:08 -04:00
*/
2016-10-26 08:02:39 -04:00
esp_err_t esp_wifi_scan_get_ap_num ( uint16_t * number ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
2023-11-03 04:17:24 -04:00
* @ brief Get AP list found in last scan .
*
* @ attention This API will free all memory occupied by scanned AP list .
2016-09-07 05:29:08 -04:00
*
2020-11-12 03:18:24 -05:00
* @ param [ inout ] number As input param , it stores max AP number ap_records can hold .
2016-11-15 12:35:09 -05:00
* As output param , it receives the actual AP number this API returns .
* @ param ap_records wifi_ap_record_t array to hold the found APs
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2017-01-02 00:51:48 -05:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
* - ESP_ERR_NO_MEM : out of memory
2016-09-07 05:29:08 -04:00
*/
2016-10-26 08:02:39 -04:00
esp_err_t esp_wifi_scan_get_ap_records ( uint16_t * number , wifi_ap_record_t * ap_records ) ;
2016-08-17 11:08:22 -04:00
2023-11-03 04:17:24 -04:00
/**
* @ brief Get one AP record from the scanned AP list .
*
* @ attention Different from esp_wifi_scan_get_ap_records ( ) , this API only gets one AP record
* from the scanned AP list each time . This API will free the memory of one AP record ,
* if the user doesn ' t get all records in the scannned AP list , then needs to call esp_wifi_clear_ap_list ( )
* to free the remaining memory .
*
* @ param [ out ] ap_record pointer to one AP record
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
* - ESP_ERR_INVALID_ARG : invalid argument
* - ESP_FAIL : scan APs is NULL , means all AP records fetched or no AP found
*/
esp_err_t esp_wifi_scan_get_ap_record ( wifi_ap_record_t * ap_record ) ;
2016-10-26 22:42:01 -04:00
2022-08-08 02:28:07 -04:00
/**
* @ brief Clear AP list found in last scan
*
2023-11-03 04:17:24 -04:00
* @ attention This API will free all memory occupied by scanned AP list .
* When the obtained AP list fails , AP records must be cleared , otherwise it may cause memory leakage .
2022-08-08 02:28:07 -04:00
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_MODE : WiFi mode is wrong
* - ESP_ERR_INVALID_ARG : invalid argument
*/
esp_err_t esp_wifi_clear_ap_list ( void ) ;
2016-10-26 22:42:01 -04:00
/**
2023-02-10 18:38:45 -05:00
* @ brief Get information of AP to which the device is associated with
2016-10-26 22:42:01 -04:00
*
2020-12-21 02:44:00 -05:00
* @ attention When the obtained country information is empty , it means that the AP does not carry country information
*
2016-11-15 12:35:09 -05:00
* @ param ap_info the wifi_ap_record_t to hold AP information
2018-04-24 04:22:33 -04:00
* sta can get the connected ap ' s phy mode info through the struct member
* phy_11b , phy_11g , phy_11n , phy_lr in the wifi_ap_record_t struct .
* For example , phy_11b = 1 imply that ap support 802.11 b mode
2016-10-26 22:42:01 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-10-30 09:29:32 -04:00
* - ESP_ERR_WIFI_CONN : The station interface don ' t initialized
2020-11-12 03:18:24 -05:00
* - ESP_ERR_WIFI_NOT_CONNECT : The station is in disconnect status
2016-10-26 22:42:01 -04:00
*/
esp_err_t esp_wifi_sta_get_ap_info ( wifi_ap_record_t * ap_info ) ;
2016-09-07 05:29:08 -04:00
/**
2018-06-13 03:44:59 -04:00
* @ brief Set current WiFi power save type
2016-09-07 05:29:08 -04:00
*
2018-06-13 03:44:59 -04:00
* @ attention Default power save type is WIFI_PS_MIN_MODEM .
2016-11-30 23:08:11 -05:00
*
2016-11-15 12:35:09 -05:00
* @ param type power save type
2016-09-07 05:29:08 -04:00
*
2018-06-13 03:44:59 -04:00
* @ return ESP_OK : succeed
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_set_ps ( wifi_ps_type_t type ) ;
2016-09-07 05:29:08 -04:00
/**
2018-06-13 03:44:59 -04:00
* @ brief Get current WiFi power save type
2016-09-07 05:29:08 -04:00
*
2018-06-13 03:44:59 -04:00
* @ attention Default power save type is WIFI_PS_MIN_MODEM .
2016-11-30 23:08:11 -05:00
*
2016-11-15 12:35:09 -05:00
* @ param [ out ] type : store current power save type
2016-09-07 05:29:08 -04:00
*
2018-06-13 03:44:59 -04:00
* @ return ESP_OK : succeed
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_get_ps ( wifi_ps_type_t * type ) ;
2016-09-07 05:29:08 -04:00
/**
* @ brief Set protocol type of specified interface
2022-12-20 09:07:09 -05:00
* The default protocol is ( WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N ) .
* if CONFIG_SOC_WIFI_HE_SUPPORT , the default protocol is ( WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_11AX ) .
2016-09-07 05:29:08 -04:00
*
2022-12-20 09:07:09 -05:00
* @ attention Support 802.11 b or 802.11 bg or 802.11 bgn or 802.11 bgnax or LR mode
2016-09-12 04:43:32 -04:00
*
2016-11-15 12:35:09 -05:00
* @ param ifx interfaces
* @ param protocol_bitmap WiFi protocol bitmap
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_IF : invalid interface
* - others : refer to error codes in esp_err . h
2016-09-07 05:29:08 -04:00
*/
esp_err_t esp_wifi_set_protocol ( wifi_interface_t ifx , uint8_t protocol_bitmap ) ;
/**
2016-11-15 12:35:09 -05:00
* @ brief Get the current protocol bitmap of the specified interface
2016-09-07 05:29:08 -04:00
*
2016-11-15 12:35:09 -05:00
* @ param ifx interface
* @ param [ out ] protocol_bitmap store current WiFi protocol bitmap of interface ifx
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_IF : invalid interface
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-11-15 12:35:09 -05:00
* - others : refer to error codes in esp_err . h
2016-09-07 05:29:08 -04:00
*/
esp_err_t esp_wifi_get_protocol ( wifi_interface_t ifx , uint8_t * protocol_bitmap ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
2023-02-10 18:38:45 -05:00
* @ brief Set the bandwidth of specified interface
2016-09-07 05:29:08 -04:00
*
2016-11-15 12:35:09 -05:00
* @ attention 1. API return false if try to configure an interface that is not enabled
2016-09-07 05:29:08 -04:00
* @ attention 2. WIFI_BW_HT40 is supported only when the interface support 11 N
*
2016-11-15 12:35:09 -05:00
* @ param ifx interface to be configured
* @ param bw bandwidth
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_IF : invalid interface
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-11-15 12:35:09 -05:00
* - others : refer to error codes in esp_err . h
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_set_bandwidth ( wifi_interface_t ifx , wifi_bandwidth_t bw ) ;
2016-09-07 05:29:08 -04:00
/**
2023-02-10 18:38:45 -05:00
* @ brief Get the bandwidth of specified interface
2016-09-07 05:29:08 -04:00
*
* @ attention 1. API return false if try to get a interface that is not enable
*
2016-11-15 12:35:09 -05:00
* @ param ifx interface to be configured
* @ param [ out ] bw store bandwidth of interface ifx
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_IF : invalid interface
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_get_bandwidth ( wifi_interface_t ifx , wifi_bandwidth_t * bw ) ;
2016-09-07 05:29:08 -04:00
/**
2023-02-10 18:38:45 -05:00
* @ brief Set primary / secondary channel of device
2016-09-07 05:29:08 -04:00
*
2023-06-27 09:34:53 -04:00
* @ attention 1. This API should be called after esp_wifi_start ( ) and before esp_wifi_stop ( )
2023-02-10 18:38:45 -05:00
* @ attention 2. When device is in STA mode , this API should not be called when STA is scanning or connecting to an external AP
* @ attention 3. When device is in softAP mode , this API should not be called when softAP has connected to external STAs
* @ attention 4. When device is in STA + softAP mode , this API should not be called when in the scenarios described above
2022-07-20 05:45:10 -04:00
* @ attention 5. The channel info set by this API will not be stored in NVS . So If you want to remeber the channel used before wifi stop ,
* you need to call this API again after wifi start , or you can call ` esp_wifi_set_config ( ) ` to store the channel info in NVS .
2016-09-07 05:29:08 -04:00
*
2016-11-15 12:35:09 -05:00
* @ param primary for HT20 , primary is the channel number , for HT40 , primary is the primary channel
* @ param second for HT20 , second is ignored , for HT40 , second is the second channel
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_IF : invalid interface
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2023-06-27 09:34:53 -04:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_set_channel ( uint8_t primary , wifi_second_chan_t second ) ;
2016-09-07 05:29:08 -04:00
/**
2023-02-10 18:38:45 -05:00
* @ brief Get the primary / secondary channel of device
2016-09-07 05:29:08 -04:00
*
* @ attention 1. API return false if try to get a interface that is not enable
*
2016-11-15 12:35:09 -05:00
* @ param primary store current primary channel
* @ param [ out ] second store current second channel
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_get_channel ( uint8_t * primary , wifi_second_chan_t * second ) ;
2016-09-07 05:29:08 -04:00
/**
2017-09-19 08:59:48 -04:00
* @ brief configure country info
*
2021-05-20 01:44:26 -04:00
* @ attention 1. It is discouraged to call this API since this doesn ' t validate the per - country rules ,
* it ' s up to the user to fill in all fields according to local regulations .
* Please use esp_wifi_set_country_code instead .
2022-08-17 09:53:23 -04:00
* @ attention 2. The default country is " 01 " ( world safe mode ) { . cc = " 01 " , . schan = 1 , . nchan = 11 , . policy = WIFI_COUNTRY_POLICY_AUTO } .
2022-09-05 17:08:14 -04:00
* @ attention 3. The third octet of country code string is one of the following : ' ' , ' O ' , ' I ' , ' X ' , otherwise it is considered as ' ' .
2022-08-17 09:53:23 -04:00
* @ attention 4. When the country policy is WIFI_COUNTRY_POLICY_AUTO , the country info of the AP to which
* the station is connected is used . E . g . if the configured country info is { . cc = " US " , . schan = 1 , . nchan = 11 }
2017-10-31 14:26:17 -04:00
* and the country info of the AP to which the station is connected is { . cc = " JP " , . schan = 1 , . nchan = 14 }
* then the country info that will be used is { . cc = " JP " , . schan = 1 , . nchan = 14 } . If the station disconnected
2021-05-20 01:44:26 -04:00
* from the AP the country info is set back to the country info of the station automatically ,
2019-06-24 09:13:39 -04:00
* { . cc = " US " , . schan = 1 , . nchan = 11 } in the example .
2022-08-17 09:53:23 -04:00
* @ attention 5. When the country policy is WIFI_COUNTRY_POLICY_MANUAL , then the configured country info is used always .
* @ attention 6. When the country info is changed because of configuration or because the station connects to a different
2021-05-20 01:44:26 -04:00
* external AP , the country IE in probe response / beacon of the soft - AP is also changed .
2022-08-17 09:53:23 -04:00
* @ attention 7. The country configuration is stored into flash .
* @ attention 8. When this API is called , the PHY init data will switch to the PHY init data type corresponding to the
2019-10-15 23:22:50 -04:00
* country info .
2017-09-19 08:59:48 -04:00
*
* @ param country the configured country info
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-09-07 05:29:08 -04:00
*/
2017-10-12 21:47:19 -04:00
esp_err_t esp_wifi_set_country ( const wifi_country_t * country ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
2017-09-19 08:59:48 -04:00
* @ brief get the current country info
2016-09-07 05:29:08 -04:00
*
2017-09-19 08:59:48 -04:00
* @ param country country info
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_get_country ( wifi_country_t * country ) ;
2017-09-19 08:59:48 -04:00
2016-09-07 05:29:08 -04:00
/**
2023-03-23 05:47:18 -04:00
* @ brief Set MAC address of WiFi station , soft - AP or NAN interface .
2016-09-07 05:29:08 -04:00
*
* @ attention 1. This API can only be called when the interface is disabled
2023-03-23 05:47:18 -04:00
* @ attention 2. Above mentioned interfaces have different MAC addresses , do not set them to be the same .
2023-02-10 18:38:45 -05:00
* @ attention 3. The bit 0 of the first byte of MAC address can not be 1. For example , the MAC address
2016-09-07 05:29:08 -04:00
* can set to be " 1a:XX:XX:XX:XX:XX " , but can not be " 15:XX:XX:XX:XX:XX " .
*
2016-11-15 12:35:09 -05:00
* @ param ifx interface
* @ param mac the MAC address
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-11-15 12:35:09 -05:00
* - 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 codes in esp_err . h
2016-09-07 05:29:08 -04:00
*/
2017-10-12 21:47:19 -04:00
esp_err_t esp_wifi_set_mac ( wifi_interface_t ifx , const uint8_t mac [ 6 ] ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
* @ brief Get mac of specified interface
*
2016-11-15 12:35:09 -05:00
* @ param ifx interface
* @ param [ out ] mac store mac of the interface ifx
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_IF : invalid interface
2016-09-07 05:29:08 -04:00
*/
2016-08-17 11:08:22 -04:00
esp_err_t esp_wifi_get_mac ( wifi_interface_t ifx , uint8_t mac [ 6 ] ) ;
2016-09-07 05:29:08 -04:00
/**
2020-11-12 03:18:24 -05:00
* @ brief The RX callback function in the promiscuous mode .
2016-12-11 21:00:24 -05:00
* Each time a packet is received , the callback function will be called .
2016-09-07 05:29:08 -04:00
*
2016-12-11 21:00:24 -05:00
* @ param buf Data received . Type of data in buffer ( wifi_promiscuous_pkt_t or wifi_pkt_rx_ctrl_t ) indicated by ' type ' parameter .
* @ param type promiscuous packet type .
2016-09-07 05:29:08 -04:00
*
*/
2016-12-11 21:00:24 -05:00
typedef void ( * wifi_promiscuous_cb_t ) ( void * buf , wifi_promiscuous_pkt_type_t type ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
* @ brief Register the RX callback function in the promiscuous mode .
*
2016-11-15 12:35:09 -05:00
* Each time a packet is received , the registered callback function will be called .
2016-09-07 05:29:08 -04:00
*
2016-11-15 12:35:09 -05:00
* @ param cb callback
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-09-07 05:29:08 -04:00
*/
2016-08-27 06:10:01 -04:00
esp_err_t esp_wifi_set_promiscuous_rx_cb ( wifi_promiscuous_cb_t cb ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
* @ brief Enable the promiscuous mode .
*
2016-11-15 12:35:09 -05:00
* @ param en false - disable , true - enable
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-09-07 05:29:08 -04:00
*/
2016-09-26 08:15:16 -04:00
esp_err_t esp_wifi_set_promiscuous ( bool en ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
* @ brief Get the promiscuous mode .
*
2016-11-15 12:35:09 -05:00
* @ param [ out ] en store the current status of promiscuous mode
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-09-07 05:29:08 -04:00
*/
2016-09-26 08:15:16 -04:00
esp_err_t esp_wifi_get_promiscuous ( bool * en ) ;
2016-08-17 11:08:22 -04:00
2017-05-26 02:11:16 -04:00
/**
2017-09-26 21:09:21 -04:00
* @ brief Enable the promiscuous mode packet type filter .
2017-05-26 02:11:16 -04:00
*
2017-09-26 21:09:21 -04:00
* @ note The default filter is to filter all packets except WIFI_PKT_MISC
2017-05-26 02:11:16 -04:00
*
2017-09-26 21:09:21 -04:00
* @ param filter the packet type filtered in promiscuous mode .
2017-05-26 02:11:16 -04:00
*
* @ return
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2017-05-26 02:11:16 -04:00
*/
esp_err_t esp_wifi_set_promiscuous_filter ( const wifi_promiscuous_filter_t * filter ) ;
/**
* @ brief Get the promiscuous filter .
*
* @ param [ out ] filter store the current status of promiscuous filter
*
* @ return
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2017-05-26 02:11:16 -04:00
*/
esp_err_t esp_wifi_get_promiscuous_filter ( wifi_promiscuous_filter_t * filter ) ;
2018-02-04 22:52:56 -05:00
/**
* @ brief Enable subtype filter of the control packet in promiscuous mode .
*
* @ note The default filter is to filter none control packet .
*
* @ param filter the subtype of the control packet filtered in promiscuous mode .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
*/
esp_err_t esp_wifi_set_promiscuous_ctrl_filter ( const wifi_promiscuous_filter_t * filter ) ;
/**
* @ brief Get the subtype filter of the control packet in promiscuous mode .
*
* @ param [ out ] filter store the current status of subtype filter of the control packet in promiscuous mode
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument
2018-02-04 22:52:56 -05:00
*/
esp_err_t esp_wifi_get_promiscuous_ctrl_filter ( wifi_promiscuous_filter_t * filter ) ;
2016-09-07 05:29:08 -04:00
/**
2023-02-13 23:36:40 -05:00
* @ brief Set the configuration of the STA , AP or NAN
2016-09-07 05:29:08 -04:00
*
2016-09-12 04:43:32 -04:00
* @ attention 1. This API can be called only when specified interface is enabled , otherwise , API fail
* @ attention 2. For station configuration , bssid_set needs to be 0 ; and it needs to be 1 only when users need to check the MAC address of the AP .
2023-02-10 18:38:45 -05:00
* @ attention 3. ESP devices are limited to only one channel , so when in the soft - AP + station mode , the soft - AP will adjust its channel automatically to be the same as
* the channel of the station .
2023-02-13 23:36:40 -05:00
* @ attention 4. The configuration will be stored in NVS for station and soft - AP
2016-09-07 05:29:08 -04:00
*
2017-09-26 21:09:21 -04:00
* @ param interface interface
2023-02-13 23:36:40 -05:00
* @ param conf station , soft - AP or NAN configuration
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-11-15 12:35:09 -05:00
* - 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
2023-09-29 10:05:18 -04:00
* - others : refer to the error code in esp_err . h
2016-09-07 05:29:08 -04:00
*/
2017-09-26 21:09:21 -04:00
esp_err_t esp_wifi_set_config ( wifi_interface_t interface , wifi_config_t * conf ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
* @ brief Get configuration of specified interface
*
2017-09-26 21:09:21 -04:00
* @ param interface interface
2016-11-15 12:35:09 -05:00
* @ param [ out ] conf station or soft - AP configuration
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_IF : invalid interface
2016-09-07 05:29:08 -04:00
*/
2017-09-26 21:09:21 -04:00
esp_err_t esp_wifi_get_config ( wifi_interface_t interface , wifi_config_t * conf ) ;
2016-08-17 11:08:22 -04:00
2016-09-07 05:29:08 -04:00
/**
2016-09-12 04:43:32 -04:00
* @ brief Get STAs associated with soft - AP
2016-09-07 05:29:08 -04:00
*
* @ attention SSC only API
*
2016-11-15 12:35:09 -05:00
* @ param [ out ] sta station list
2018-04-24 04:22:33 -04:00
* ap can get the connected sta ' s phy mode info through the struct member
* phy_11b , phy_11g , phy_11n , phy_lr in the wifi_sta_info_t struct .
* For example , phy_11b = 1 imply that sta support 802.11 b mode
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-11-15 12:35:09 -05:00
* - ESP_ERR_WIFI_MODE : WiFi mode is wrong
* - ESP_ERR_WIFI_CONN : WiFi internal error , the station / soft - AP control block is invalid
2016-09-07 05:29:08 -04:00
*/
2016-10-26 06:16:40 -04:00
esp_err_t esp_wifi_ap_get_sta_list ( wifi_sta_list_t * sta ) ;
2016-08-22 23:22:58 -04:00
2020-04-15 08:20:16 -04:00
/**
* @ brief Get AID of STA connected with soft - AP
*
* @ param mac STA ' s mac address
* @ param [ out ] aid Store the AID corresponding to STA mac
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
* - ESP_ERR_INVALID_ARG : invalid argument
* - ESP_ERR_NOT_FOUND : Requested resource not found
* - 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_aid ( const uint8_t mac [ 6 ] , uint16_t * aid ) ;
2016-08-22 23:22:58 -04:00
2016-09-07 05:29:08 -04:00
/**
2016-09-12 04:43:32 -04:00
* @ brief Set the WiFi API configuration storage type
2016-09-07 05:29:08 -04:00
*
* @ attention 1. The default value is WIFI_STORAGE_FLASH
*
2016-11-15 12:35:09 -05:00
* @ param storage : storage type
2016-09-07 05:29:08 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : invalid argument
2016-09-07 05:29:08 -04:00
*/
2016-09-01 03:09:00 -04:00
esp_err_t esp_wifi_set_storage ( wifi_storage_t storage ) ;
2016-08-30 06:09:48 -04:00
2019-07-07 23:26:18 -04:00
/**
* @ brief Function signature for received Vendor - Specific Information Element callback .
* @ param ctx Context argument , as passed to esp_wifi_set_vendor_ie_cb ( ) when registering callback .
* @ param type Information element type , based on frame type received .
* @ param sa Source 802.11 address .
* @ param vnd_ie Pointer to the vendor specific element data received .
* @ param rssi Received signal strength indication .
*/
typedef void ( * esp_vendor_ie_cb_t ) ( void * ctx , wifi_vendor_ie_type_t type , const uint8_t sa [ 6 ] , const vendor_ie_data_t * vnd_ie , int rssi ) ;
2016-09-13 05:11:53 -04:00
/**
2017-06-29 03:20:45 -04:00
* @ brief Set 802.11 Vendor - Specific Information Element
2016-09-13 05:11:53 -04:00
*
2017-06-29 03:20:45 -04:00
* @ param enable If true , specified IE is enabled . If false , specified IE is removed .
* @ param type Information Element type . Determines the frame type to associate with the IE .
* @ param idx Index to set or clear . Each IE type can be associated with up to two elements ( indices 0 & 1 ) .
* @ param vnd_ie Pointer to vendor specific element data . First 6 bytes should be a header with fields matching vendor_ie_data_t .
* If enable is false , this argument is ignored and can be NULL . Data does not need to remain valid after the function returns .
2016-09-13 05:11:53 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init ( )
2018-02-09 08:43:11 -05:00
* - ESP_ERR_INVALID_ARG : Invalid argument , including if first byte of vnd_ie is not WIFI_VENDOR_IE_ELEMENT_ID ( 0xDD )
2017-06-29 03:20:45 -04:00
* or second byte is an invalid length .
2018-02-09 08:43:11 -05:00
* - ESP_ERR_NO_MEM : Out of memory
2016-09-13 05:11:53 -04:00
*/
2017-06-29 03:20:45 -04:00
esp_err_t esp_wifi_set_vendor_ie ( bool enable , wifi_vendor_ie_type_t type , wifi_vendor_ie_id_t idx , const void * vnd_ie ) ;
2016-09-13 05:11:53 -04:00
/**
2017-06-29 03:20:45 -04:00
* @ brief Register Vendor - Specific Information Element monitoring callback .
2016-09-13 05:11:53 -04:00
*
2017-06-29 03:20:45 -04:00
* @ param cb Callback function
* @ param ctx Context argument , passed to callback function .
2016-09-13 05:11:53 -04:00
*
2016-11-08 04:34:46 -05:00
* @ return
2016-11-15 12:35:09 -05:00
* - ESP_OK : succeed
2017-06-29 03:19:17 -04:00
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2016-09-13 05:11:53 -04:00
*/
esp_err_t esp_wifi_set_vendor_ie_cb ( esp_vendor_ie_cb_t cb , void * ctx ) ;
2017-07-25 03:22:18 -04:00
/**
2020-05-19 03:27:51 -04:00
* @ brief Set maximum transmitting power after WiFi start .
*
* @ attention 1. Maximum power before wifi startup is limited by PHY init data bin .
* @ attention 2. The value set by this API will be mapped to the max_tx_power of the structure wifi_country_t variable .
* @ attention 3. Mapping Table { Power , max_tx_power } = { { 8 , 2 } , { 20 , 5 } , { 28 , 7 } , { 34 , 8 } , { 44 , 11 } ,
2020-12-21 02:44:00 -05:00
* { 52 , 13 } , { 56 , 14 } , { 60 , 15 } , { 66 , 16 } , { 72 , 18 } , { 80 , 20 } } .
* @ attention 4. Param power unit is 0.25 dBm , range is [ 8 , 84 ] corresponding to 2 dBm - 20 dBm .
* @ attention 5. Relationship between set value and actual value . As follows : { set value range , actual value } = { { [ 8 , 19 ] , 8 } , { [ 20 , 27 ] , 20 } , { [ 28 , 33 ] , 28 } , { [ 34 , 43 ] , 34 } , { [ 44 , 51 ] , 44 } , { [ 52 , 55 ] , 52 } , { [ 56 , 59 ] , 56 } , { [ 60 , 65 ] , 60 } , { [ 66 , 71 ] , 66 } , { [ 72 , 79 ] , 72 } , { [ 80 , 84 ] , 80 } } .
2020-10-26 08:27:44 -04:00
*
2020-05-19 03:27:51 -04:00
* @ param power Maximum WiFi transmitting power .
2017-07-25 03:22:18 -04:00
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2022-07-24 07:46:29 -04:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument , e . g . parameter is out of range
2017-07-25 03:22:18 -04:00
*/
esp_err_t esp_wifi_set_max_tx_power ( int8_t power ) ;
/**
2020-05-19 03:27:51 -04:00
* @ brief Get maximum transmiting power after WiFi start
2017-07-25 03:22:18 -04:00
*
2020-05-19 03:27:51 -04:00
* @ param power Maximum WiFi transmitting power , unit is 0.25 dBm .
2017-07-25 03:22:18 -04:00
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2022-07-24 07:46:29 -04:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument
2017-07-25 03:22:18 -04:00
*/
esp_err_t esp_wifi_get_max_tx_power ( int8_t * power ) ;
2018-03-15 23:43:21 -04:00
/**
* @ brief Set mask to enable or disable some WiFi events
*
* @ attention 1. Mask can be created by logical OR of various WIFI_EVENT_MASK_ constants .
* Events which have corresponding bit set in the mask will not be delivered to the system event handler .
* @ attention 2. Default WiFi event mask is WIFI_EVENT_MASK_AP_PROBEREQRECVED .
* @ attention 3. There may be lots of stations sending probe request data around .
* Don ' t unmask this event unless you need to receive probe request data .
*
* @ param mask WiFi event mask .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
*/
esp_err_t esp_wifi_set_event_mask ( uint32_t mask ) ;
/**
* @ brief Get mask of WiFi events
*
* @ param mask WiFi event mask .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument
2018-03-15 23:43:21 -04:00
*/
esp_err_t esp_wifi_get_event_mask ( uint32_t * mask ) ;
2018-02-26 00:29:52 -05:00
/**
* @ brief Send raw ieee80211 data
*
* @ attention Currently only support for sending beacon / probe request / probe response / action and non - QoS
* data frame
2020-11-12 03:18:24 -05:00
*
2018-02-26 00:29:52 -05:00
* @ param ifx interface if the Wi - Fi mode is Station , the ifx should be WIFI_IF_STA . If the Wi - Fi
2020-11-12 03:18:24 -05:00
* mode is SoftAP , the ifx should be WIFI_IF_AP . If the Wi - Fi mode is Station + SoftAP , the
2018-02-26 00:29:52 -05:00
* ifx should be WIFI_IF_STA or WIFI_IF_AP . If the ifx is wrong , the API returns ESP_ERR_WIFI_IF .
* @ param buffer raw ieee80211 buffer
* @ param len the length of raw buffer , the len must be < = 1500 Bytes and > = 24 Bytes
2020-11-12 03:18:24 -05:00
* @ param en_sys_seq indicate whether use the internal sequence number . If en_sys_seq is false , the
* sequence in raw buffer is unchanged , otherwise it will be overwritten by WiFi driver with
2018-02-26 00:29:52 -05:00
* the system sequence number .
* Generally , if esp_wifi_80211_tx is called before the Wi - Fi connection has been set up , both
* en_sys_seq = = true and en_sys_seq = = false are fine . However , if the API is called after the Wi - Fi
2023-08-18 02:16:34 -04:00
* connection has been set up , en_sys_seq must be true , otherwise ESP_ERR_INVALID_ARG is returned .
2018-02-26 00:29:52 -05:00
*
* @ return
* - ESP_OK : success
* - ESP_ERR_WIFI_IF : Invalid interface
* - ESP_ERR_INVALID_ARG : Invalid parameter
* - ESP_ERR_WIFI_NO_MEM : out of memory
*/
esp_err_t esp_wifi_80211_tx ( wifi_interface_t ifx , const void * buffer , int len , bool en_sys_seq ) ;
2018-03-15 23:43:21 -04:00
2018-05-09 04:44:06 -04:00
/**
2020-11-12 03:18:24 -05:00
* @ brief The RX callback function of Channel State Information ( CSI ) data .
2018-05-09 04:44:06 -04:00
*
* Each time a CSI data is received , the callback function will be called .
*
2020-11-12 03:18:24 -05:00
* @ param ctx context argument , passed to esp_wifi_set_csi_rx_cb ( ) when registering callback function .
* @ param data CSI data received . The memory that it points to will be deallocated after callback function returns .
2018-05-09 04:44:06 -04:00
*
*/
typedef void ( * wifi_csi_cb_t ) ( void * ctx , wifi_csi_info_t * data ) ;
/**
* @ brief Register the RX callback function of CSI data .
*
* Each time a CSI data is received , the callback function will be called .
*
* @ param cb callback
* @ param ctx context argument , passed to callback function
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
*/
esp_err_t esp_wifi_set_csi_rx_cb ( wifi_csi_cb_t cb , void * ctx ) ;
/**
* @ brief Set CSI data configuration
*
* @ param config configuration
2020-11-12 03:18:24 -05:00
*
2018-05-09 04:44:06 -04:00
* return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2022-07-24 07:46:29 -04:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start or promiscuous mode is not enabled
2018-05-09 04:44:06 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument
*/
esp_err_t esp_wifi_set_csi_config ( const wifi_csi_config_t * config ) ;
/**
* @ brief Enable or disable CSI
*
* @ param en true - enable , false - disable
*
* return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2022-07-24 07:46:29 -04:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start or promiscuous mode is not enabled
2018-05-09 04:44:06 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument
*/
esp_err_t esp_wifi_set_csi ( bool en ) ;
2018-05-14 23:59:32 -04:00
/**
* @ brief Set antenna GPIO configuration
*
* @ param config Antenna GPIO configuration .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : Invalid argument , e . g . parameter is NULL , invalid GPIO number etc
2018-05-14 23:59:32 -04:00
*/
esp_err_t esp_wifi_set_ant_gpio ( const wifi_ant_gpio_config_t * config ) ;
/**
* @ brief Get current antenna GPIO configuration
*
* @ param config Antenna GPIO configuration .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument , e . g . parameter is NULL
2018-05-14 23:59:32 -04:00
*/
esp_err_t esp_wifi_get_ant_gpio ( wifi_ant_gpio_config_t * config ) ;
/**
* @ brief Set antenna configuration
*
* @ param config Antenna configuration .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : Invalid argument , e . g . parameter is NULL , invalid antenna mode or invalid GPIO number
2018-05-14 23:59:32 -04:00
*/
esp_err_t esp_wifi_set_ant ( const wifi_ant_config_t * config ) ;
/**
* @ brief Get current antenna configuration
*
* @ param config Antenna configuration .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument , e . g . parameter is NULL
2018-05-14 23:59:32 -04:00
*/
esp_err_t esp_wifi_get_ant ( wifi_ant_config_t * config ) ;
2020-07-10 10:09:23 -04:00
/**
* @ brief Get the TSF time
* In Station mode or SoftAP + Station mode if station is not connected or station doesn ' t receive at least
* one beacon after connected , will return 0
*
* @ attention Enabling power save may cause the return value inaccurate , except WiFi modem sleep
*
* @ param interface The interface whose tsf_time is to be retrieved .
*
* @ return 0 or the TSF time
*/
int64_t esp_wifi_get_tsf_time ( wifi_interface_t interface ) ;
2020-07-14 03:15:00 -04:00
/**
2023-02-10 18:38:45 -05:00
* @ brief Set the inactive time of the STA or AP
2020-07-14 03:15:00 -04:00
*
* @ attention 1. For Station , If the station does not receive a beacon frame from the connected SoftAP during the inactive time ,
* disconnect from SoftAP . Default 6 s .
* @ attention 2. For SoftAP , If the softAP doesn ' t receive any data from the connected STA during inactive time ,
* the softAP will force deauth the STA . Default is 300 s .
* @ attention 3. The inactive time configuration is not stored into flash
*
* @ param ifx interface to be configured .
* @ param sec Inactive time . Unit seconds .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument , For Station , if sec is less than 3. For SoftAP , if sec is less than 10.
2020-07-14 03:15:00 -04:00
*/
esp_err_t esp_wifi_set_inactive_time ( wifi_interface_t ifx , uint16_t sec ) ;
/**
* @ brief Get inactive time of specified interface
*
* @ param ifx Interface to be configured .
* @ param sec Inactive time . Unit seconds .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2023-03-30 23:39:50 -04:00
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument
2020-07-14 03:15:00 -04:00
*/
esp_err_t esp_wifi_get_inactive_time ( wifi_interface_t ifx , uint16_t * sec ) ;
2020-08-14 11:42:57 -04:00
/**
* @ brief Dump WiFi statistics
*
* @ param modules statistic modules to be dumped
*
* @ return
* - ESP_OK : succeed
* - others : failed
*/
esp_err_t esp_wifi_statis_dump ( uint32_t modules ) ;
2020-11-12 03:18:24 -05:00
/**
2023-08-18 02:16:34 -04:00
* @ brief Set RSSI threshold , if average rssi gets lower than threshold , WiFi task will post event WIFI_EVENT_STA_BSS_RSSI_LOW .
2020-11-12 03:18:24 -05:00
*
2023-08-18 02:16:34 -04:00
* @ attention If the user wants to receive another WIFI_EVENT_STA_BSS_RSSI_LOW event after receiving one , this API needs to be
* called again with an updated / same RSSI threshold .
2020-11-12 03:18:24 -05:00
*
2023-10-26 23:59:58 -04:00
* @ param rssi threshold value in dbm between - 100 to 10
* Note that in some rare cases where signal strength is very strong , rssi values can be slightly positive .
2020-11-12 03:18:24 -05:00
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
2023-08-18 02:16:34 -04:00
* - ESP_ERR_INVALID_ARG : invalid argument
2020-11-12 03:18:24 -05:00
*/
esp_err_t esp_wifi_set_rssi_threshold ( int32_t rssi ) ;
2021-01-21 09:25:39 -05:00
/**
2021-01-26 02:19:18 -05:00
* @ brief Start an FTM Initiator session by sending FTM request
* If successful , event WIFI_EVENT_FTM_REPORT is generated with the result of the FTM procedure
2021-01-21 09:25:39 -05:00
*
2022-12-07 08:07:10 -05:00
* @ attention 1. Use this API only in Station mode .
* @ attention 2. If FTM is initiated on a different channel than Station is connected in or internal SoftAP is started in ,
* FTM defaults to a single burst in ASAP mode .
2021-01-26 02:19:18 -05:00
*
* @ param cfg FTM Initiator session configuration
2021-01-21 09:25:39 -05:00
*
* @ return
* - ESP_OK : succeed
* - others : failed
*/
2021-01-26 02:19:18 -05:00
esp_err_t esp_wifi_ftm_initiate_session ( wifi_ftm_initiator_cfg_t * cfg ) ;
2021-01-21 09:25:39 -05:00
2021-04-01 09:22:17 -04:00
/**
* @ brief End the ongoing FTM Initiator session
*
* @ attention This API works only on FTM Initiator
*
* @ return
* - ESP_OK : succeed
* - others : failed
*/
esp_err_t esp_wifi_ftm_end_session ( void ) ;
/**
* @ brief Set offset in cm for FTM Responder . An equivalent offset is calculated in picoseconds
* and added in TOD of FTM Measurement frame ( T1 ) .
*
* @ attention Use this API only in AP mode before performing FTM as responder
*
* @ param offset_cm T1 Offset to be added in centimeters
*
* @ return
* - ESP_OK : succeed
* - others : failed
*/
esp_err_t esp_wifi_ftm_resp_set_offset ( int16_t offset_cm ) ;
2021-01-29 03:33:12 -05:00
/**
* @ brief Enable or disable 11 b rate of specified interface
*
* @ attention 1. This API should be called after esp_wifi_init ( ) and before esp_wifi_start ( ) .
* @ attention 2. Only when really need to disable 11 b rate call this API otherwise don ' t call this .
*
* @ param ifx Interface to be configured .
* @ param disable true means disable 11 b rate while false means enable 11 b rate .
*
* @ return
* - ESP_OK : succeed
* - others : failed
*/
esp_err_t esp_wifi_config_11b_rate ( wifi_interface_t ifx , bool disable ) ;
2022-10-09 04:55:15 -04:00
# define ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE 0
2021-03-11 05:09:58 -05:00
/**
2022-03-15 05:08:12 -04:00
* @ brief Set wake interval for connectionless modules to wake up periodically .
2021-03-11 05:09:58 -05:00
*
2022-03-15 05:08:12 -04:00
* @ attention 1. Only one wake interval for all connectionless modules .
* @ attention 2. This configuration could work at connected status .
* When ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled , this configuration could work at disconnected status .
* @ attention 3. Event WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START would be posted each time wake interval starts .
* @ attention 4. Recommend to configure interval in multiples of hundred . ( e . g . 100 ms )
2022-10-09 04:55:15 -04:00
* @ attention 5. Recommend to configure interval to ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE to get stable performance at coexistence mode .
2021-03-11 05:09:58 -05:00
*
2022-03-15 05:08:12 -04:00
* @ param wake_interval Milliseconds after would the chip wake up , from 1 to 65535.
2021-03-11 05:09:58 -05:00
*/
2022-03-15 05:08:12 -04:00
esp_err_t esp_wifi_connectionless_module_set_wake_interval ( uint16_t wake_interval ) ;
2021-03-11 05:09:58 -05:00
2023-08-07 02:40:29 -04:00
/**
* @ brief Request extra reference of Wi - Fi radio .
* Wi - Fi keep active state ( RF opened ) to be able to receive packets .
*
* @ attention Please pair the use of ` esp_wifi_force_wakeup_acquire ` with ` esp_wifi_force_wakeup_release ` .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
*/
esp_err_t esp_wifi_force_wakeup_acquire ( void ) ;
/**
* @ brief Release extra reference of Wi - Fi radio .
* Wi - Fi go to sleep state ( RF closed ) if no more use of radio .
*
* @ attention Please pair the use of ` esp_wifi_force_wakeup_acquire ` with ` esp_wifi_force_wakeup_release ` .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started by esp_wifi_start
*/
esp_err_t esp_wifi_force_wakeup_release ( void ) ;
2021-05-20 01:44:26 -04:00
/**
* @ brief configure country
*
* @ attention 1. When ieee80211d_enabled , the country info of the AP to which
* the station is connected is used . E . g . if the configured country is US
* and the country info of the AP to which the station is connected is JP
* then the country info that will be used is JP . If the station disconnected
* from the AP the country info is set back to the country info of the station automatically ,
* US in the example .
* @ attention 2. When ieee80211d_enabled is disabled , then the configured country info is used always .
* @ attention 3. When the country info is changed because of configuration or because the station connects to a different
* external AP , the country IE in probe response / beacon of the soft - AP is also changed .
* @ attention 4. The country configuration is stored into flash .
* @ attention 5. When this API is called , the PHY init data will switch to the PHY init data type corresponding to the
* country info .
* @ attention 6. Supported country codes are " 01 " ( world safe mode ) " AT " , " AU " , " BE " , " BG " , " BR " ,
* " CA " , " CH " , " CN " , " CY " , " CZ " , " DE " , " DK " , " EE " , " ES " , " FI " , " FR " , " GB " , " GR " , " HK " , " HR " , " HU " ,
* " IE " , " IN " , " IS " , " IT " , " JP " , " KR " , " LI " , " LT " , " LU " , " LV " , " MT " , " MX " , " NL " , " NO " , " NZ " , " PL " , " PT " ,
* " RO " , " SE " , " SI " , " SK " , " TW " , " US "
*
* @ attention 7. When country code " 01 " ( world safe mode ) is set , SoftAP mode won ' t contain country IE .
2022-03-04 06:34:46 -05:00
* @ attention 8. The default country is " 01 " ( world safe mode ) and ieee80211d_enabled is TRUE .
2022-09-05 17:08:14 -04:00
* @ attention 9. The third octet of country code string is one of the following : ' ' , ' O ' , ' I ' , ' X ' , otherwise it is considered as ' ' .
2021-05-20 01:44:26 -04:00
*
* @ param country the configured country ISO code
* @ param ieee80211d_enabled 802.11 d is enabled or not
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
* - ESP_ERR_INVALID_ARG : invalid argument
*/
esp_err_t esp_wifi_set_country_code ( const char * country , bool ieee80211d_enabled ) ;
/**
* @ brief get the current country code
*
* @ param country country code
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_WIFI_NOT_INIT : WiFi is not initialized by esp_wifi_init
* - ESP_ERR_INVALID_ARG : invalid argument
*/
esp_err_t esp_wifi_get_country_code ( char * country ) ;
2021-07-13 03:33:20 -04:00
/**
* @ brief Config 80211 tx rate of specified interface
*
* @ attention 1. This API should be called after esp_wifi_init ( ) and before esp_wifi_start ( ) .
*
* @ param ifx Interface to be configured .
* @ param rate Phy rate to be configured .
*
* @ return
* - ESP_OK : succeed
* - others : failed
*/
esp_err_t esp_wifi_config_80211_tx_rate ( wifi_interface_t ifx , wifi_phy_rate_t rate ) ;
2022-04-05 08:14:42 -04:00
/**
* @ brief Disable PMF configuration for specified interface
*
* @ attention This API should be called after esp_wifi_set_config ( ) and before esp_wifi_start ( ) .
*
* @ param ifx Interface to be configured .
*
* @ return
* - ESP_OK : succeed
* - others : failed
*/
esp_err_t esp_wifi_disable_pmf_config ( wifi_interface_t ifx ) ;
2023-02-16 00:59:36 -05:00
/**
* @ brief Get the Association id assigned to STA by AP
*
* @ param [ out ] aid store the aid
*
* @ attention aid = 0 if station is not connected to AP .
*
* @ return
* - ESP_OK : succeed
*/
esp_err_t esp_wifi_sta_get_aid ( uint16_t * aid ) ;
/**
* @ brief Get the negotiated phymode after connection .
*
* @ param [ out ] phymode store the negotiated phymode .
*
* @ return
* - ESP_OK : succeed
*/
esp_err_t esp_wifi_sta_get_negotiated_phymode ( wifi_phy_mode_t * phymode ) ;
2023-02-13 23:36:40 -05:00
2023-01-05 03:29:16 -05:00
/**
* @ brief Config dynamic carrier sense
*
* @ attention This API should be called after esp_wifi_start ( ) .
*
* @ param enabled Dynamic carrier sense is enabled or not .
*
* @ return
* - ESP_OK : succeed
* - others : failed
*/
esp_err_t esp_wifi_set_dynamic_cs ( bool enabled ) ;
2023-07-06 02:35:56 -04:00
/**
* @ brief Get the rssi info after station connected to AP
*
* @ attention This API should be called after station connected to AP .
*
* @ param rssi store the rssi info received from last beacon .
*
* @ return
* - ESP_OK : succeed
* - ESP_ERR_INVALID_ARG : invalid argument
* - ESP_FAIL : failed
*/
esp_err_t esp_wifi_sta_get_rssi ( int * rssi ) ;
2016-08-17 11:08:22 -04:00
# ifdef __cplusplus
}
# endif
# endif /* __ESP_WIFI_H__ */