Skip to content

Commit d196147

Browse files
feat(wifi): Added tx callback function for 80211 tx
Closes #13319
1 parent 3e6c4da commit d196147

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

components/esp_wifi/include/esp_wifi.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,27 @@ esp_err_t esp_wifi_get_event_mask(uint32_t *mask);
11981198

11991199
esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
12001200

1201+
/**
1202+
* @brief Callback function of 80211 tx data
1203+
*
1204+
* @param tx_info TX information of 80211 tx. The information can only be used in the callback context.
1205+
*/
1206+
typedef void (*esp_wifi_80211_tx_done_cb_t)(const esp_80211_tx_info_t *tx_info);
1207+
1208+
/**
1209+
* @brief Register the TX callback function of 80211 tx data.
1210+
*
1211+
* @attention This callback will be executed in WiFi task, so avoid doing any time consuming activity in the callback.
1212+
* Doing heavy work here can affect the WiFi performance.
1213+
*
1214+
* @param cb callback function. If the cb is NULL, then unregister the tx cb.
1215+
*
1216+
* @return
1217+
* - ESP_OK: succeed
1218+
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
1219+
*/
1220+
esp_err_t esp_wifi_register_80211_tx_cb(esp_wifi_80211_tx_done_cb_t cb);
1221+
12011222
/**
12021223
* @brief The RX callback function of Channel State Information(CSI) data.
12031224
*

components/esp_wifi/include/esp_wifi_types_generic.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,29 @@ typedef struct {
14861486
uint8_t regulatory_type; /**< regulatory type of country */
14871487
} wifi_regdomain_t;
14881488

1489+
/**
1490+
* @brief Status of wifi sending data
1491+
*/
1492+
typedef enum {
1493+
WIFI_SEND_SUCCESS = 0, /**< Sending Wi-Fi data successfully */
1494+
WIFI_SEND_FAIL, /**< Sending Wi-Fi data fail */
1495+
} wifi_tx_status_t;
1496+
1497+
/**
1498+
* @brief Information of wifi sending data
1499+
*/
1500+
typedef struct {
1501+
uint8_t *des_addr; /**< The address of the receive device */
1502+
uint8_t *src_addr; /**< The address of the sending device */
1503+
wifi_interface_t ifidx; /**< Interface of sending 80211 tx data */
1504+
uint8_t *data; /**< The data for 80211 tx, start from the MAC header */
1505+
uint8_t data_len; /**< The frame body length for 80211 tx, excluding the MAC header */
1506+
wifi_phy_rate_t rate; /**< Data rate */
1507+
wifi_tx_status_t tx_status; /**< Status of sending 80211 tx data */
1508+
} wifi_tx_info_t;
1509+
1510+
typedef wifi_tx_info_t esp_80211_tx_info_t;
1511+
14891512
#ifdef __cplusplus
14901513
}
14911514
#endif

0 commit comments

Comments
 (0)