diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index f3e2a88145..7425f9d52d 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 d76df1104c..4d32995e8f 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 2fae5b1324..86c783a904 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 7031a35021..38bbecacf8 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");