2016-10-06 13:21:30 +02:00
|
|
|
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Notes about WiFi Programming
|
|
|
|
|
*
|
|
|
|
|
* The esp32 WiFi programming model can be depicted as following picture:
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* default handler user handler
|
|
|
|
|
* ------------- --------------- ---------------
|
|
|
|
|
* | | event | | callback or | |
|
|
|
|
|
* | tcpip | ---------> | event | ----------> | application |
|
|
|
|
|
* | stack | | task | event | task |
|
|
|
|
|
* |-----------| |-------------| |-------------|
|
|
|
|
|
* /|\ |
|
|
|
|
|
* | |
|
|
|
|
|
* event | |
|
|
|
|
|
* | |
|
|
|
|
|
* | |
|
|
|
|
|
* --------------- |
|
|
|
|
|
* | | |
|
|
|
|
|
* | WiFi Driver |/__________________|
|
|
|
|
|
* | |\ API call
|
|
|
|
|
* | |
|
|
|
|
|
* |-------------|
|
|
|
|
|
*
|
|
|
|
|
* 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().
|
|
|
|
|
*
|
|
|
|
|
* 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,
|
|
|
|
|
* on receiving event SYSTEM_EVENT_STA_CONNECTED, it will call tcpip_adapter_start() to start the DHCP
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* The application task (code) generally mixes all these thing together, it calls APIs to init the system/WiFi and
|
|
|
|
|
* handle the events when necessary.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __ESP_WIFI_H__
|
|
|
|
|
#define __ESP_WIFI_H__
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
|
#include "freertos/queue.h"
|
|
|
|
|
#include "rom/queue.h"
|
2017-01-16 15:03:13 +01:00
|
|
|
|
#include "sdkconfig.h"
|
2016-10-06 13:21:30 +02:00
|
|
|
|
#include "esp_err.h"
|
|
|
|
|
#include "esp_wifi_types.h"
|
2017-08-18 10:12:58 +02:00
|
|
|
|
#include "esp_wifi_crypto_types.h"
|
2016-10-06 13:21:30 +02:00
|
|
|
|
#include "esp_event.h"
|
2018-06-27 09:01:06 +02:00
|
|
|
|
#include "esp_wifi_os_adapter.h"
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-01-16 15:03:13 +01: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 */
|
2017-05-06 19:29:12 +02:00
|
|
|
|
#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 */
|
2017-11-23 23:26:53 +01:00
|
|
|
|
#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-13 16:23:44 +01:00
|
|
|
|
|
2016-11-18 17:32:28 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief WiFi stack configuration parameters passed to esp_wifi_init call.
|
|
|
|
|
*/
|
2016-10-06 13:21:30 +02:00
|
|
|
|
typedef struct {
|
2017-03-10 14:40:14 +01:00
|
|
|
|
system_event_handler_t event_handler; /**< WiFi event handler */
|
2018-06-27 09:01:06 +02:00
|
|
|
|
wifi_osi_funcs_t* osi_funcs; /**< WiFi OS functions */
|
2017-08-18 10:12:58 +02:00
|
|
|
|
wpa_crypto_funcs_t wpa_crypto_funcs; /**< WiFi station crypto functions when connect */
|
2017-03-10 14:40:14 +01:00
|
|
|
|
int static_rx_buf_num; /**< WiFi static RX buffer number */
|
|
|
|
|
int dynamic_rx_buf_num; /**< WiFi dynamic RX buffer number */
|
2017-04-04 00:26:23 +02:00
|
|
|
|
int tx_buf_type; /**< WiFi TX buffer type */
|
|
|
|
|
int static_tx_buf_num; /**< WiFi static TX buffer number */
|
2017-03-10 14:40:14 +01:00
|
|
|
|
int dynamic_tx_buf_num; /**< WiFi dynamic TX buffer number */
|
2018-06-27 09:01:06 +02:00
|
|
|
|
int csi_enable; /**< WiFi channel state information enable flag */
|
2017-11-23 23:26:53 +01:00
|
|
|
|
int ampdu_rx_enable; /**< WiFi AMPDU RX feature enable flag */
|
|
|
|
|
int ampdu_tx_enable; /**< WiFi AMPDU TX feature enable flag */
|
2017-03-10 14:40:14 +01:00
|
|
|
|
int nvs_enable; /**< WiFi NVS flash enable flag */
|
|
|
|
|
int nano_enable; /**< Nano option for printf/scan family enable flag */
|
2017-08-01 07:51:04 +02:00
|
|
|
|
int tx_ba_win; /**< WiFi Block Ack TX window size */
|
|
|
|
|
int rx_ba_win; /**< WiFi Block Ack RX window size */
|
2018-06-27 09:01:06 +02:00
|
|
|
|
int wifi_task_core_id; /**< WiFi Task Core ID */
|
2018-11-26 23:22:11 +01:00
|
|
|
|
int beacon_max_len; /**< WiFi softAP maximum length of the beacon */
|
2019-05-12 17:52:23 +02:00
|
|
|
|
int mgmt_sbuf_num; /**< WiFi management short buffer number, the minimum value is 6, the maximum value is 32 */
|
2017-03-10 14:40:14 +01:00
|
|
|
|
int magic; /**< WiFi init magic number, it should be the last field */
|
2016-10-06 13:21:30 +02:00
|
|
|
|
} wifi_init_config_t;
|
|
|
|
|
|
2017-04-04 00:26:23 +02:00
|
|
|
|
#ifdef CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM
|
|
|
|
|
#define WIFI_STATIC_TX_BUFFER_NUM CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM
|
|
|
|
|
#else
|
|
|
|
|
#define WIFI_STATIC_TX_BUFFER_NUM 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM
|
|
|
|
|
#define WIFI_DYNAMIC_TX_BUFFER_NUM CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM
|
|
|
|
|
#else
|
|
|
|
|
#define WIFI_DYNAMIC_TX_BUFFER_NUM 0
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-06-27 09:01:06 +02:00
|
|
|
|
#if CONFIG_ESP32_WIFI_CSI_ENABLED
|
|
|
|
|
#define WIFI_CSI_ENABLED 1
|
|
|
|
|
#else
|
|
|
|
|
#define WIFI_CSI_ENABLED 0
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-11-23 23:26:53 +01:00
|
|
|
|
#if CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED
|
|
|
|
|
#define WIFI_AMPDU_RX_ENABLED 1
|
2017-03-10 14:40:14 +01:00
|
|
|
|
#else
|
2017-11-23 23:26:53 +01:00
|
|
|
|
#define WIFI_AMPDU_RX_ENABLED 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED
|
|
|
|
|
#define WIFI_AMPDU_TX_ENABLED 1
|
|
|
|
|
#else
|
|
|
|
|
#define WIFI_AMPDU_TX_ENABLED 0
|
2017-03-10 14:40:14 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if CONFIG_ESP32_WIFI_NVS_ENABLED
|
|
|
|
|
#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-18 10:12:58 +02:00
|
|
|
|
|
|
|
|
|
extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
|
|
|
|
|
|
2017-03-10 14:40:14 +01:00
|
|
|
|
#define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F
|
2017-09-12 08:40:52 +02:00
|
|
|
|
|
2017-11-23 23:26:53 +01:00
|
|
|
|
#ifdef CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED
|
2017-09-12 08:40:52 +02:00
|
|
|
|
#define WIFI_DEFAULT_TX_BA_WIN CONFIG_ESP32_WIFI_TX_BA_WIN
|
2017-11-23 23:26:53 +01:00
|
|
|
|
#else
|
|
|
|
|
#define WIFI_DEFAULT_TX_BA_WIN 0 /* unused if ampdu_tx_enable == false */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED
|
2017-09-12 08:40:52 +02:00
|
|
|
|
#define WIFI_DEFAULT_RX_BA_WIN CONFIG_ESP32_WIFI_RX_BA_WIN
|
|
|
|
|
#else
|
2017-11-23 23:26:53 +01:00
|
|
|
|
#define WIFI_DEFAULT_RX_BA_WIN 0 /* unused if ampdu_rx_enable == false */
|
2017-09-12 08:40:52 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2018-06-27 09:01:06 +02:00
|
|
|
|
#if CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1
|
|
|
|
|
#define WIFI_TASK_CORE_ID 1
|
|
|
|
|
#else
|
|
|
|
|
#define WIFI_TASK_CORE_ID 0
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-11-26 23:22:11 +01:00
|
|
|
|
#ifdef CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN
|
|
|
|
|
#define WIFI_SOFTAP_BEACON_MAX_LEN CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN
|
|
|
|
|
#else
|
|
|
|
|
#define WIFI_SOFTAP_BEACON_MAX_LEN 752
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-05-12 17:52:23 +02:00
|
|
|
|
#ifdef CONFIG_ESP32_WIFI_MGMT_SBUF_NUM
|
|
|
|
|
#define WIFI_MGMT_SBUF_NUM CONFIG_ESP32_WIFI_MGMT_SBUF_NUM
|
|
|
|
|
#else
|
|
|
|
|
#define WIFI_MGMT_SBUF_NUM 32
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
|
#define WIFI_INIT_CONFIG_DEFAULT() { \
|
|
|
|
|
.event_handler = &esp_event_send, \
|
2018-06-27 09:01:06 +02:00
|
|
|
|
.osi_funcs = &g_wifi_osi_funcs, \
|
2017-08-18 10:12:58 +02:00
|
|
|
|
.wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \
|
2017-03-10 14:40:14 +01:00
|
|
|
|
.static_rx_buf_num = CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM,\
|
|
|
|
|
.dynamic_rx_buf_num = CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM,\
|
2017-04-04 00:26:23 +02:00
|
|
|
|
.tx_buf_type = CONFIG_ESP32_WIFI_TX_BUFFER_TYPE,\
|
|
|
|
|
.static_tx_buf_num = WIFI_STATIC_TX_BUFFER_NUM,\
|
|
|
|
|
.dynamic_tx_buf_num = WIFI_DYNAMIC_TX_BUFFER_NUM,\
|
2018-06-27 09:01:06 +02:00
|
|
|
|
.csi_enable = WIFI_CSI_ENABLED,\
|
2017-11-23 23:26:53 +01:00
|
|
|
|
.ampdu_rx_enable = WIFI_AMPDU_RX_ENABLED,\
|
|
|
|
|
.ampdu_tx_enable = WIFI_AMPDU_TX_ENABLED,\
|
2017-03-10 14:40:14 +01:00
|
|
|
|
.nvs_enable = WIFI_NVS_ENABLED,\
|
|
|
|
|
.nano_enable = WIFI_NANO_FORMAT_ENABLED,\
|
2017-09-12 08:40:52 +02:00
|
|
|
|
.tx_ba_win = WIFI_DEFAULT_TX_BA_WIN,\
|
|
|
|
|
.rx_ba_win = WIFI_DEFAULT_RX_BA_WIN,\
|
2018-06-27 09:01:06 +02:00
|
|
|
|
.wifi_task_core_id = WIFI_TASK_CORE_ID,\
|
2018-11-26 23:22:11 +01:00
|
|
|
|
.beacon_max_len = WIFI_SOFTAP_BEACON_MAX_LEN, \
|
2019-05-12 17:52:23 +02:00
|
|
|
|
.mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM, \
|
2017-03-10 14:40:14 +01:00
|
|
|
|
.magic = WIFI_INIT_CONFIG_MAGIC\
|
2016-10-06 13:21:30 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Init WiFi
|
|
|
|
|
* Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
|
|
|
|
|
* WiFi NVS structure etc, this WiFi also start WiFi task
|
|
|
|
|
*
|
|
|
|
|
* @attention 1. This API must be called before all other WiFi API can be called
|
2017-03-10 14:40:14 +01:00
|
|
|
|
* @attention 2. Always use WIFI_INIT_CONFIG_DEFAULT macro to init the config to default values, this can
|
|
|
|
|
* guarantee all the fields got correct value when more fields are added into wifi_init_config_t
|
|
|
|
|
* in future release. If you want to set your owner initial values, overwrite the default values
|
|
|
|
|
* which are set by WIFI_INIT_CONFIG_DEFAULT, please be notified that the field 'magic' of
|
|
|
|
|
* wifi_init_config_t should always be WIFI_INIT_CONFIG_MAGIC!
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2017-10-16 20:25:41 +02:00
|
|
|
|
* @param config pointer to WiFi init configuration structure; can point to a temporary variable.
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_NO_MEM: out of memory
|
2016-12-30 01:44:45 +01:00
|
|
|
|
* - others: refer to error code esp_err.h
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2017-10-16 20:25:41 +02:00
|
|
|
|
esp_err_t esp_wifi_init(const wifi_init_config_t *config);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Deinit WiFi
|
|
|
|
|
* Free all resource allocated in esp_wifi_init and stop WiFi task
|
|
|
|
|
*
|
|
|
|
|
* @attention 1. This API should be called if you want to remove WiFi driver from the system
|
|
|
|
|
*
|
2018-09-21 08:39:36 +02:00
|
|
|
|
* @return
|
|
|
|
|
* - ESP_OK: succeed
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_deinit(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set the WiFi operating mode
|
|
|
|
|
*
|
|
|
|
|
* Set the WiFi operating mode as station, soft-AP or station+soft-AP,
|
|
|
|
|
* The default mode is soft-AP mode.
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param mode WiFi operating mode
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - others: refer to error code in esp_err.h
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_mode(wifi_mode_t mode);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get current operating mode of WiFi
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param[out] mode store current WiFi mode
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_mode(wifi_mode_t *mode);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Start WiFi according to current configuration
|
|
|
|
|
* If mode is WIFI_MODE_STA, it create station control block and start station
|
|
|
|
|
* If mode is WIFI_MODE_AP, it create soft-AP control block and start soft-AP
|
|
|
|
|
* If mode is WIFI_MODE_APSTA, it create soft-AP and station control block and start soft-AP and station
|
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
|
|
|
|
* - ESP_ERR_NO_MEM: out of memory
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_FAIL: other WiFi internal errors
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_start(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Stop WiFi
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* If mode is WIFI_MODE_STA, it stop station and free station control block
|
2016-10-06 13:21:30 +02:00
|
|
|
|
* If mode is WIFI_MODE_AP, it stop soft-AP and free soft-AP control block
|
|
|
|
|
* If mode is WIFI_MODE_APSTA, it stop station/soft-AP and free station/soft-AP control block
|
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_stop(void);
|
|
|
|
|
|
2016-11-28 00:11:36 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief Restore WiFi stack persistent settings to default values
|
|
|
|
|
*
|
|
|
|
|
* This function will reset settings made using the following APIs:
|
|
|
|
|
* - esp_wifi_get_auto_connect,
|
|
|
|
|
* - esp_wifi_set_protocol,
|
|
|
|
|
* - esp_wifi_set_config related
|
|
|
|
|
* - esp_wifi_set_mode
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-11-28 00:11:36 +01:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_restore(void);
|
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief Connect the ESP32 WiFi station to the AP.
|
|
|
|
|
*
|
|
|
|
|
* @attention 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode
|
|
|
|
|
* @attention 2. If the ESP32 is connected to an AP, call esp_wifi_disconnect to disconnect.
|
2018-09-21 08:39:36 +02:00
|
|
|
|
* @attention 3. The scanning triggered by esp_wifi_start_scan() will not be effective until connection between ESP32 and the AP is established.
|
|
|
|
|
* If ESP32 is scanning and connecting at the same time, ESP32 will abort scanning and return a warning message and error
|
|
|
|
|
* number ESP_ERR_WIFI_STATE.
|
|
|
|
|
* If you want to do reconnection after ESP32 received disconnect event, remember to add the maximum retry time, otherwise the called
|
|
|
|
|
* scan will not work. This is especially true when the AP doesn't exist, and you still try reconnection after ESP32 received disconnect
|
|
|
|
|
* event with the reason code WIFI_REASON_NO_AP_FOUND.
|
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - 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
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_connect(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Disconnect the ESP32 WiFi station from the AP.
|
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi was not initialized by esp_wifi_init
|
2017-01-16 15:03:13 +01:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_FAIL: other WiFi internal errors
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_disconnect(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Currently this API is just an stub API
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
|
|
|
|
* - others: fail
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_clear_fast_connect(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2016-10-28 00:53:02 +02:00
|
|
|
|
* @brief deauthenticate all stations or associated id equals to aid
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param aid when aid is 0, deauthenticate all stations, otherwise deauthenticate station whose associated id is aid
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2017-01-16 15:03:13 +01:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_MODE: WiFi mode is wrong
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2016-10-28 00:53:02 +02:00
|
|
|
|
esp_err_t esp_wifi_deauth_sta(uint16_t aid);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Scan all available APs.
|
|
|
|
|
*
|
|
|
|
|
* @attention If this API is called, the found APs are stored in WiFi driver dynamic allocated memory and the
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* will be freed in esp_wifi_scan_get_ap_records, so generally, call esp_wifi_scan_get_ap_records to cause
|
2016-10-06 13:21:30 +02:00
|
|
|
|
* the memory to be freed once the scan is done
|
2017-04-04 00:26:23 +02:00
|
|
|
|
* @attention The values of maximum active scan time and passive scan time per channel are limited to 1500 milliseconds.
|
|
|
|
|
* Values above 1500ms may cause station to disconnect from AP and are not recommended.
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param config configuration of scanning
|
|
|
|
|
* @param block if block is true, this API will block the caller until the scan is done, otherwise
|
2016-10-06 13:21:30 +02:00
|
|
|
|
* it will return immediately
|
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2017-01-16 15:03:13 +01:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_TIMEOUT: blocking scan is timeout
|
2018-09-21 08:39:36 +02:00
|
|
|
|
* - ESP_ERR_WIFI_STATE: wifi still connecting when invoke esp_wifi_scan_start
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - others: refer to error code in esp_err.h
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2017-10-16 20:25:41 +02:00
|
|
|
|
esp_err_t esp_wifi_scan_start(const wifi_scan_config_t *config, bool block);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Stop the scan in process
|
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2017-01-16 15:03:13 +01:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_scan_stop(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get number of APs found in last scan
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param[out] number store number of APIs found in last scan
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @attention This API can only be called when the scan is completed, otherwise it may get wrong value.
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2017-01-16 15:03:13 +01:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2016-10-28 00:53:02 +02:00
|
|
|
|
esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get AP list found in last scan
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param[inout] number As input param, it stores max AP number ap_records can hold.
|
|
|
|
|
* 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-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2017-01-16 15:03:13 +01:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
|
|
|
|
* - ESP_ERR_NO_MEM: out of memory
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2016-10-28 00:53:02 +02:00
|
|
|
|
esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @brief Get information of AP which the ESP32 station is associated with
|
2016-10-28 00:53:02 +02:00
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param ap_info the wifi_ap_record_t to hold AP information
|
2018-06-27 09:01:06 +02: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.11b mode
|
2016-10-28 00:53:02 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-11-23 23:26:53 +01:00
|
|
|
|
* - ESP_ERR_WIFI_CONN: The station interface don't initialized
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
|
2016-10-28 00:53:02 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2018-06-27 09:01:06 +02:00
|
|
|
|
* @brief Set current WiFi power save type
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2018-06-27 09:01:06 +02:00
|
|
|
|
* @attention Default power save type is WIFI_PS_MIN_MODEM.
|
2016-12-02 13:50:43 +01:00
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param type power save type
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2018-06-27 09:01:06 +02:00
|
|
|
|
* @return ESP_OK: succeed
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_ps(wifi_ps_type_t type);
|
|
|
|
|
|
|
|
|
|
/**
|
2018-06-27 09:01:06 +02:00
|
|
|
|
* @brief Get current WiFi power save type
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2018-06-27 09:01:06 +02:00
|
|
|
|
* @attention Default power save type is WIFI_PS_MIN_MODEM.
|
2016-12-02 13:50:43 +01:00
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param[out] type: store current power save type
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2018-06-27 09:01:06 +02:00
|
|
|
|
* @return ESP_OK: succeed
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set protocol type of specified interface
|
|
|
|
|
* The default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N)
|
|
|
|
|
*
|
|
|
|
|
* @attention Currently we only support 802.11b or 802.11bg or 802.11bgn mode
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param ifx interfaces
|
|
|
|
|
* @param protocol_bitmap WiFi protocol bitmap
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_IF: invalid interface
|
|
|
|
|
* - others: refer to error codes in esp_err.h
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap);
|
|
|
|
|
|
|
|
|
|
/**
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @brief Get the current protocol bitmap of the specified interface
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param ifx interface
|
|
|
|
|
* @param[out] protocol_bitmap store current WiFi protocol bitmap of interface ifx
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_IF: invalid interface
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - others: refer to error codes in esp_err.h
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set the bandwidth of ESP32 specified interface
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @attention 1. API return false if try to configure an interface that is not enabled
|
2016-10-06 13:21:30 +02:00
|
|
|
|
* @attention 2. WIFI_BW_HT40 is supported only when the interface support 11N
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param ifx interface to be configured
|
|
|
|
|
* @param bw bandwidth
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_IF: invalid interface
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - others: refer to error codes in esp_err.h
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the bandwidth of ESP32 specified interface
|
|
|
|
|
*
|
|
|
|
|
* @attention 1. API return false if try to get a interface that is not enable
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param ifx interface to be configured
|
|
|
|
|
* @param[out] bw store bandwidth of interface ifx
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_IF: invalid interface
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw);
|
|
|
|
|
|
|
|
|
|
/**
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @brief Set primary/secondary channel of ESP32
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
|
|
|
|
* @attention 1. This is a special API for sniffer
|
2017-03-10 14:40:14 +01:00
|
|
|
|
* @attention 2. This API should be called after esp_wifi_start() or esp_wifi_set_promiscuous()
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-18 17:32:28 +01: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-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_IF: invalid interface
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second);
|
|
|
|
|
|
|
|
|
|
/**
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @brief Get the primary/secondary channel of ESP32
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
|
|
|
|
* @attention 1. API return false if try to get a interface that is not enable
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param primary store current primary channel
|
|
|
|
|
* @param[out] second store current second channel
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
|
|
|
|
|
|
|
|
|
|
/**
|
2017-10-13 21:07:41 +02:00
|
|
|
|
* @brief configure country info
|
|
|
|
|
*
|
|
|
|
|
* @attention 1. The default country is {.cc="CN", .schan=1, .nchan=13, policy=WIFI_COUNTRY_POLICY_AUTO}
|
2017-11-23 23:26:53 +01:00
|
|
|
|
* @attention 2. 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="USA", .schan=1, .nchan=11}
|
|
|
|
|
* 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
|
|
|
|
|
* from the AP the country info is set back back to the country info of the station automatically,
|
|
|
|
|
* {.cc="USA", .schan=1, .nchan=11} in the example.
|
2017-10-13 21:07:41 +02:00
|
|
|
|
* @attention 3. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, always use the configured country info.
|
|
|
|
|
* @attention 4. 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 changed also.
|
|
|
|
|
* @attention 5. The country configuration is not stored into flash
|
|
|
|
|
* @attention 6. This API doesn't validate the per-country rules, it's up to the user to fill in all fields according to
|
|
|
|
|
* local regulations.
|
|
|
|
|
*
|
|
|
|
|
* @param country the configured country info
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2017-10-16 20:25:41 +02:00
|
|
|
|
esp_err_t esp_wifi_set_country(const wifi_country_t *country);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2017-10-13 21:07:41 +02:00
|
|
|
|
* @brief get the current country info
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2017-10-13 21:07:41 +02:00
|
|
|
|
* @param country country info
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_country(wifi_country_t *country);
|
|
|
|
|
|
2017-10-13 21:07:41 +02:00
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief Set MAC address of the ESP32 WiFi station or the soft-AP interface.
|
|
|
|
|
*
|
|
|
|
|
* @attention 1. This API can only be called when the interface is disabled
|
|
|
|
|
* @attention 2. ESP32 soft-AP and station have different MAC addresses, do not set them to be the same.
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @attention 3. The bit 0 of the first byte of ESP32 MAC address can not be 1. For example, the MAC address
|
2016-10-06 13:21:30 +02:00
|
|
|
|
* can set to be "1a:XX:XX:XX:XX:XX", but can not be "15:XX:XX:XX:XX:XX".
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param ifx interface
|
|
|
|
|
* @param mac the MAC address
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-11-18 17:32:28 +01: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-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2017-10-16 20:25:41 +02:00
|
|
|
|
esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get mac of specified interface
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param ifx interface
|
|
|
|
|
* @param[out] mac store mac of the interface ifx
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_IF: invalid interface
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]);
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-30 00:28:30 +01:00
|
|
|
|
* @brief The RX callback function in the promiscuous mode.
|
|
|
|
|
* Each time a packet is received, the callback function will be called.
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-12-30 00:28:30 +01: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-10-06 13:21:30 +02:00
|
|
|
|
*
|
|
|
|
|
*/
|
2016-12-30 00:28:30 +01:00
|
|
|
|
typedef void (* wifi_promiscuous_cb_t)(void *buf, wifi_promiscuous_pkt_type_t type);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Register the RX callback function in the promiscuous mode.
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* Each time a packet is received, the registered callback function will be called.
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param cb callback
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Enable the promiscuous mode.
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param en false - disable, true - enable
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_promiscuous(bool en);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the promiscuous mode.
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param[out] en store the current status of promiscuous mode
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_promiscuous(bool *en);
|
|
|
|
|
|
2017-08-01 07:51:04 +02:00
|
|
|
|
/**
|
2017-11-23 23:26:53 +01:00
|
|
|
|
* @brief Enable the promiscuous mode packet type filter.
|
2017-08-01 07:51:04 +02:00
|
|
|
|
*
|
2017-11-23 23:26:53 +01:00
|
|
|
|
* @note The default filter is to filter all packets except WIFI_PKT_MISC
|
2017-08-01 07:51:04 +02:00
|
|
|
|
*
|
2017-11-23 23:26:53 +01:00
|
|
|
|
* @param filter the packet type filtered in promiscuous mode.
|
2017-08-01 07:51:04 +02:00
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
* - ESP_OK: succeed
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2017-08-01 07:51:04 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_promiscuous_filter(wifi_promiscuous_filter_t *filter);
|
|
|
|
|
|
2018-06-27 09:01:06 +02: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
|
|
|
|
|
* - ESP_ERR_WIFI_ARG: invalid argument
|
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter);
|
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief Set the configuration of the ESP32 STA or AP
|
|
|
|
|
*
|
|
|
|
|
* @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.
|
|
|
|
|
* @attention 3. ESP32 is 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 ESP32 station.
|
|
|
|
|
*
|
2017-11-23 23:26:53 +01:00
|
|
|
|
* @param interface interface
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param conf station or soft-AP configuration
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-11-18 17:32:28 +01: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
|
|
|
|
|
* - others: refer to the erro code in esp_err.h
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2017-11-23 23:26:53 +01:00
|
|
|
|
esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get configuration of specified interface
|
|
|
|
|
*
|
2017-11-23 23:26:53 +01:00
|
|
|
|
* @param interface interface
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param[out] conf station or soft-AP configuration
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_IF: invalid interface
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2017-11-23 23:26:53 +01:00
|
|
|
|
esp_err_t esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get STAs associated with soft-AP
|
|
|
|
|
*
|
|
|
|
|
* @attention SSC only API
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param[out] sta station list
|
2018-06-27 09:01:06 +02: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.11b mode
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-11-18 17:32:28 +01: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-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2016-10-28 00:53:02 +02:00
|
|
|
|
esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set the WiFi API configuration storage type
|
|
|
|
|
*
|
|
|
|
|
* @attention 1. The default value is WIFI_STORAGE_FLASH
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param storage : storage type
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_storage(wifi_storage_t storage);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set auto connect
|
|
|
|
|
* The default value is true
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param en : true - enable auto connect / false - disable auto connect
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_ERR_WIFI_MODE: WiFi internal error, the station/soft-AP control block is invalid
|
|
|
|
|
* - others: refer to error code in esp_err.h
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2018-06-27 09:01:06 +02:00
|
|
|
|
esp_err_t esp_wifi_set_auto_connect(bool en) __attribute__ ((deprecated));
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the auto connect flag
|
|
|
|
|
*
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* @param[out] en store current auto connect configuration
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2018-06-27 09:01:06 +02:00
|
|
|
|
esp_err_t esp_wifi_get_auto_connect(bool *en) __attribute__ ((deprecated));
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* @brief Set 802.11 Vendor-Specific Information Element
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2017-08-01 07:51:04 +02: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-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init()
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: Invalid argument, including if first byte of vnd_ie is not WIFI_VENDOR_IE_ELEMENT_ID (0xDD)
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* or second byte is an invalid length.
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_NO_MEM: Out of memory
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2017-08-01 07:51:04 +02: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-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2017-08-01 07:51:04 +02: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.
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
2017-08-01 07:51:04 +02:00
|
|
|
|
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-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* @brief Register Vendor-Specific Information Element monitoring callback.
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* @param cb Callback function
|
|
|
|
|
* @param ctx Context argument, passed to callback function.
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*
|
2016-11-13 16:23:44 +01:00
|
|
|
|
* @return
|
2016-11-18 17:32:28 +01:00
|
|
|
|
* - ESP_OK: succeed
|
2017-08-01 07:51:04 +02:00
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
2016-10-06 13:21:30 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx);
|
|
|
|
|
|
2017-08-01 07:51:04 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief Set maximum WiFi transmiting power
|
|
|
|
|
*
|
|
|
|
|
* @attention WiFi transmiting power is divided to six levels in phy init data.
|
|
|
|
|
* Level0 represents highest transmiting power and level5 represents lowest
|
|
|
|
|
* transmiting power. Packets of different rates are transmitted in
|
|
|
|
|
* different powers according to the configuration in phy init data.
|
|
|
|
|
* This API only sets maximum WiFi transmiting power. If this API is called,
|
|
|
|
|
* the transmiting power of every packet will be less than or equal to the
|
|
|
|
|
* value set by this API. If this API is not called, the value of maximum
|
|
|
|
|
* transmitting power set in phy_init_data.bin or menuconfig (depend on
|
|
|
|
|
* whether to use phy init data in partition or not) will be used. Default
|
|
|
|
|
* value is level0. Values passed in power are mapped to transmit power
|
|
|
|
|
* levels as follows:
|
|
|
|
|
* - [78, 127]: level0
|
|
|
|
|
* - [76, 77]: level1
|
|
|
|
|
* - [74, 75]: level2
|
|
|
|
|
* - [68, 73]: level3
|
|
|
|
|
* - [60, 67]: level4
|
|
|
|
|
* - [52, 59]: level5
|
|
|
|
|
* - [44, 51]: level5 - 2dBm
|
|
|
|
|
* - [34, 43]: level5 - 4.5dBm
|
|
|
|
|
* - [28, 33]: level5 - 6dBm
|
|
|
|
|
* - [20, 27]: level5 - 8dBm
|
|
|
|
|
* - [8, 19]: level5 - 11dBm
|
|
|
|
|
* - [-128, 7]: level5 - 14dBm
|
|
|
|
|
*
|
|
|
|
|
* @param power Maximum WiFi transmiting power.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
* - ESP_OK: succeed
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start
|
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_max_tx_power(int8_t power);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get maximum WiFi transmiting power
|
|
|
|
|
*
|
|
|
|
|
* @attention This API gets maximum WiFi transmiting power. Values got
|
|
|
|
|
* from power are mapped to transmit power levels as follows:
|
|
|
|
|
* - 78: 19.5dBm
|
|
|
|
|
* - 76: 19dBm
|
|
|
|
|
* - 74: 18.5dBm
|
|
|
|
|
* - 68: 17dBm
|
|
|
|
|
* - 60: 15dBm
|
|
|
|
|
* - 52: 13dBm
|
|
|
|
|
* - 44: 11dBm
|
|
|
|
|
* - 34: 8.5dBm
|
|
|
|
|
* - 28: 7dBm
|
|
|
|
|
* - 20: 5dBm
|
|
|
|
|
* - 8: 2dBm
|
|
|
|
|
* - -4: -1dBm
|
|
|
|
|
*
|
|
|
|
|
* @param power Maximum WiFi transmiting power.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
* - ESP_OK: succeed
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start
|
2018-04-07 08:45:18 +02:00
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
2017-08-01 07:51:04 +02:00
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_max_tx_power(int8_t *power);
|
|
|
|
|
|
2018-06-27 09:01:06 +02: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
|
|
|
|
|
* - ESP_ERR_WIFI_ARG: invalid argument
|
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_event_mask(uint32_t *mask);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Send raw ieee80211 data
|
|
|
|
|
*
|
|
|
|
|
* @attention Currently only support for sending beacon/probe request/probe response/action and non-QoS
|
|
|
|
|
* data frame
|
|
|
|
|
*
|
|
|
|
|
* @param ifx interface if the Wi-Fi mode is Station, the ifx should be WIFI_IF_STA. If the Wi-Fi
|
|
|
|
|
* mode is SoftAP, the ifx should be WIFI_IF_AP. If the Wi-Fi mode is Station+SoftAP, the
|
|
|
|
|
* 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
|
|
|
|
|
* @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
|
|
|
|
|
* 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
|
|
|
|
|
* connection has been set up, en_sys_seq must be true, otherwise ESP_ERR_WIFI_ARG is returned.
|
|
|
|
|
*
|
|
|
|
|
* @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);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief The RX callback function of Channel State Information(CSI) data.
|
|
|
|
|
*
|
|
|
|
|
* Each time a CSI data is received, the callback function will be called.
|
|
|
|
|
*
|
|
|
|
|
* @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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
*
|
|
|
|
|
* return
|
|
|
|
|
* - ESP_OK: succeed
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled
|
|
|
|
|
* - 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
|
|
|
|
|
* - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled
|
|
|
|
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_set_csi(bool en);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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
|
|
|
|
|
* - ESP_ERR_WIFI_ARG: Invalid argument, e.g. parameter is NULL, invalid GPIO number etc
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
* - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is NULL
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
* - ESP_ERR_WIFI_ARG: Invalid argument, e.g. parameter is NULL, invalid antenna mode or invalid GPIO number
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
* - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is NULL
|
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_get_ant(wifi_ant_config_t *config);
|
|
|
|
|
|
2019-05-12 17:52:23 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief A general API to set/get WiFi internal configuration, it's for debug only
|
|
|
|
|
*
|
|
|
|
|
* @param cmd : ioctl command type
|
|
|
|
|
* @param cfg : configuration for the command
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
* - ESP_OK: succeed
|
|
|
|
|
* - others: failed
|
|
|
|
|
*/
|
|
|
|
|
esp_err_t esp_wifi_internal_ioctl(int cmd, wifi_ioctl_config_t *cfg);
|
|
|
|
|
|
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* __ESP_WIFI_H__ */
|