diff --git a/CMakeLists.txt b/CMakeLists.txt index 49fb43f..919af98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,15 @@ list(APPEND srcs "src/utils/src/espnow_mem.c" "src/utils/src/espnow_utils.c") list(APPEND include_dirs "src/utils/include") -list(APPEND requires "spi_flash" "nvs_flash" "esp_timer" "esp_wifi" "driver") +list(APPEND requires "spi_flash" "nvs_flash" "esp_timer" "esp_wifi") +# only need to append these if ESP-IDF is >= 5.4 +idf_build_get_property(IDF_VERSION_MAJOR IDF_VERSION_MAJOR) +idf_build_get_property(IDF_VERSION_MINOR IDF_VERSION_MINOR) +if(IDF_VERSION_MAJOR GREATER 5 OR (IDF_VERSION_MAJOR EQUAL 5 AND IDF_VERSION_MINOR GREATER_EQUAL 4)) + list(APPEND requires "esp_driver_gpio" "esp_driver_uart" "esp_driver_usb_serial_jtag") +else() + list(APPEND requires "driver") +endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" diff --git a/src/espnow/src/espnow.c b/src/espnow/src/espnow.c index f4f3902..42f3f37 100644 --- a/src/espnow/src/espnow.c +++ b/src/espnow/src/espnow.c @@ -401,16 +401,27 @@ void espnow_recv_cb(const uint8_t *addr, const uint8_t *data, int size) } /**< callback function of sending ESPNOW data */ +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 1) +void espnow_send_cb(const esp_now_send_info_t *tx_info, esp_now_send_status_t status) +#else void espnow_send_cb(const uint8_t *addr, esp_now_send_status_t status) +#endif { if (g_buffered_num) { g_buffered_num --; } +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 1) + if (!tx_info || !g_event_group) { + ESP_LOGW(TAG, "Send cb args error, tx_info is NULL"); + return ; + } +#else if (!addr || !g_event_group) { ESP_LOGW(TAG, "Send cb args error, addr is NULL"); return ; } +#endif if (status == ESP_NOW_SEND_SUCCESS) { xEventGroupSetBits(g_event_group, SEND_CB_OK);