From 45ead31bd57058f4b225397caa4b624d68c0eeb9 Mon Sep 17 00:00:00 2001 From: Jessy Chen Date: Thu, 26 May 2022 03:04:33 -0400 Subject: [PATCH] esp_wifi: upload more wifi pkt info in rx callback for espnow & csi --- components/esp_wifi/include/esp_now.h | 14 ++++++++++++-- components/esp_wifi/include/esp_wifi_types.h | 1 + components/esp_wifi/lib | 2 +- examples/wifi/espnow/main/espnow_example_main.c | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index f3e2a88145e..7425f9d52d8 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -80,13 +80,23 @@ typedef struct esp_now_peer_num { int encrypt_num; /**< Number of encrypted ESPNOW peers, maximum value is ESP_NOW_MAX_ENCRYPT_PEER_NUM */ } esp_now_peer_num_t; +/** + * @brief ESPNOW packet information + */ +typedef struct esp_now_recv_info { + uint8_t * src_addr; /**< Source address of ESPNOW packet */ + uint8_t * des_addr; /**< Destination address of ESPNOW packet */ + wifi_pkt_rx_ctrl_t * rx_ctrl; /**< Rx control info of ESPNOW packet */ +} esp_now_recv_info_t; + /** * @brief Callback function of receiving ESPNOW data - * @param mac_addr peer MAC address + * @param esp_now_info received ESPNOW packet information * @param data received data * @param data_len length of received data + * @attention esp_now_info is a local variable,it can only be used in the callback. */ -typedef void (*esp_now_recv_cb_t)(const uint8_t *mac_addr, const uint8_t *data, int data_len); +typedef void (*esp_now_recv_cb_t)(const esp_now_recv_info_t * esp_now_info, const uint8_t *data, int data_len); /** * @brief Callback function of sending ESPNOW data diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index d76df1104ca..4d32995e8f8 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -489,6 +489,7 @@ typedef struct { 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 */ + uint8_t dmac[6]; /**< destination MAC address of the CSI data */ bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not */ int8_t *buf; /**< buffer of CSI data */ uint16_t len; /**< length of CSI data */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 2fae5b13243..86c783a9047 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 2fae5b132437907691d51ac4b3c31227b7b7ab33 +Subproject commit 86c783a90479aa6f7b602775ba7fe9c3d97438ee diff --git a/examples/wifi/espnow/main/espnow_example_main.c b/examples/wifi/espnow/main/espnow_example_main.c index 7031a350218..38bbecacf83 100644 --- a/examples/wifi/espnow/main/espnow_example_main.c +++ b/examples/wifi/espnow/main/espnow_example_main.c @@ -79,10 +79,11 @@ static void example_espnow_send_cb(const uint8_t *mac_addr, esp_now_send_status_ } } -static void example_espnow_recv_cb(const uint8_t *mac_addr, const uint8_t *data, int len) +static void example_espnow_recv_cb(const esp_now_recv_info_t *recv_info, const uint8_t *data, int len) { example_espnow_event_t evt; example_espnow_event_recv_cb_t *recv_cb = &evt.info.recv_cb; + uint8_t * mac_addr = recv_info->src_addr; if (mac_addr == NULL || data == NULL || len <= 0) { ESP_LOGE(TAG, "Receive cb arg error");