int tx_buf_type; /**< WiFi TX buffer type */
int static_tx_buf_num; /**< WiFi static TX buffer number */
int dynamic_tx_buf_num; /**< WiFi dynamic TX buffer number */
+ int csi_enable; /**< WiFi channel state information enable flag */
int ampdu_rx_enable; /**< WiFi AMPDU RX feature enable flag */
int ampdu_tx_enable; /**< WiFi AMPDU TX feature enable flag */
int nvs_enable; /**< WiFi NVS flash enable flag */
#define WIFI_DYNAMIC_TX_BUFFER_NUM 0
#endif
+#if CONFIG_ESP32_WIFI_CSI_ENABLED
+#define WIFI_CSI_ENABLED 1
+#else
+#define WIFI_CSI_ENABLED 0
+#endif
+
#if CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED
#define WIFI_AMPDU_RX_ENABLED 1
#else
.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,\
+ .csi_enable = WIFI_CSI_ENABLED,\
.ampdu_rx_enable = WIFI_AMPDU_RX_ENABLED,\
.ampdu_tx_enable = WIFI_AMPDU_TX_ENABLED,\
.nvs_enable = WIFI_NVS_ENABLED,\
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.
+ *
+ */
+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);
+
#ifdef __cplusplus
}
#endif
unsigned stbc:2; /**< STBC */
unsigned fec_coding:1; /**< Flag is set for 11n packets which are LDPC */
unsigned sgi:1; /**< SGI */
- unsigned noise_floor:8; /**< noise floor */
+ signed noise_floor:8; /**< noise floor */
unsigned ampdu_cnt:8; /**< ampdu cnt */
- unsigned channel:4; /**< which channel this packet in */
- unsigned :12; /**< reserve */
- unsigned timestamp:32; /**< timestamp */
- unsigned :32; /**< reserve */
+ unsigned channel:4; /**< which primary channel this packet in */
+ unsigned second_channel:4;/**< which second channel this packet in */
+ unsigned :8; /**< reserve */
+ unsigned timestamp:32; /**< timestamp, unit: microsecond */
unsigned :32; /**< reserve */
+ unsigned :31; /**< reserve */
+ unsigned ant:1; /**< antenna number from which this packet is received */
unsigned sig_len:12; /**< length of packet */
unsigned :12; /**< reserve */
unsigned rx_state:8; /**< rx state */
#define WIFI_EVENT_MASK_NONE (0) /**< mask none of the WiFi events */
#define WIFI_EVENT_MASK_AP_PROBEREQRECVED (BIT(0)) /**< mask SYSTEM_EVENT_AP_PROBEREQRECVED event */
+/**
+ * @brief Channel state information(CSI) configuration type
+ *
+ */
+typedef struct {
+ bool lltf_en; /**< enable to receive legacy long training field(lltf) data */
+ bool htltf_en; /**< enable to receive HT long training field(htltf) data */
+ bool stbcltf2_en; /**< enable to receive space time block code long training field(stbcltf2) data */
+ bool manu_scale; /**< manually scale the CSI data by left shifting or automatically scale the CSI data. If set true, please set the shift bits. false: automatically. true: manually */
+ uint8_t shift; /**< manually left shift bits of the scale of the CSI data. The range of the left shift bits is 0~15 */
+} wifi_csi_config_t;
+
+/**
+ * @brief CSI data type
+ *
+ */
+typedef struct {
+ wifi_pkt_rx_ctrl_t rx_ctrl;/**< received packet radio metadata header of the CSI data */
+ uint8_t mac[6]; /**< source MAC address of the CSI data */
+ bool last_word_invalid; /**< last four bytes of the CSI data is invalid or not */
+ uint8_t *buf; /**< buffer of CSI data */
+ uint16_t len; /**< length of CSI data */
+} wifi_csi_info_t;
+
#ifdef __cplusplus
}
#endif