From af76d3172f05b5b9ad73006e18abe333898097a6 Mon Sep 17 00:00:00 2001 From: Alexey Zholtikov Date: Sat, 14 Jun 2025 07:27:44 +0300 Subject: [PATCH] feat: esp-idf v5.5 support --- README.md | 2 +- version.txt | 2 +- zh_espnow.c | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b218e0..ef2f2aa 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Tested on 1. [ESP8266 RTOS_SDK v3.4](https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/index.html#) -2. [ESP32 ESP-IDF v5.4](https://docs.espressif.com/projects/esp-idf/en/release-v5.4/esp32/index.html) +2. [ESP32 ESP-IDF v5.5](https://docs.espressif.com/projects/esp-idf/en/release-v5.5/esp32/index.html) ## Features diff --git a/version.txt b/version.txt index afa2b35..abb1658 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.8.0 \ No newline at end of file +1.9.0 \ No newline at end of file diff --git a/zh_espnow.c b/zh_espnow.c index 6caa041..6e4d2df 100755 --- a/zh_espnow.c +++ b/zh_espnow.c @@ -48,7 +48,12 @@ static esp_err_t _zh_espnow_init_resources(const zh_espnow_init_config_t *config static esp_err_t _zh_espnow_validate_config(const zh_espnow_init_config_t *config); static esp_err_t _zh_espnow_register_callbacks(bool battery_mode); static esp_err_t _zh_espnow_create_task(const zh_espnow_init_config_t *config); + +#if ESP_IDF_VERSION_MAJOR >= 5 && ESP_IDF_VERSION_MINOR >= 5 +static void _zh_espnow_send_cb(const esp_now_send_info_t *esp_now_info, esp_now_send_status_t status); +#else static void _zh_espnow_send_cb(const uint8_t *mac_addr, esp_now_send_status_t status); +#endif #if defined CONFIG_IDF_TARGET_ESP8266 || ESP_IDF_VERSION_MAJOR == 4 static void _zh_espnow_recv_cb(const uint8_t *mac_addr, const uint8_t *data, int data_len); #else @@ -277,6 +282,23 @@ static esp_err_t _zh_espnow_register_callbacks(bool battery_mode) return ESP_OK; } +#if ESP_IDF_VERSION_MAJOR >= 5 && ESP_IDF_VERSION_MINOR >= 5 +static void IRAM_ATTR _zh_espnow_send_cb(const esp_now_send_info_t *esp_now_info, esp_now_send_status_t status) +{ + if (esp_now_info == NULL) + { + ZH_ESPNOW_LOGE("Send callback received NULL MAC address."); + return; + } + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + ZH_ESPNOW_LOGI("ESP-NOW send callback: %s for MAC %02X:%02X:%02X:%02X:%02X:%02X.", (status == ESP_NOW_SEND_SUCCESS) ? "SUCCESS" : "FAIL", MAC2STR(esp_now_info->des_addr)); + xEventGroupSetBitsFromISR(_event_group_handle, (status == ESP_NOW_SEND_SUCCESS) ? DATA_SEND_SUCCESS : DATA_SEND_FAIL, &xHigherPriorityTaskWoken); + if (xHigherPriorityTaskWoken == pdTRUE) + { + portYIELD_FROM_ISR(); + }; +} +#else static void IRAM_ATTR _zh_espnow_send_cb(const uint8_t *mac_addr, esp_now_send_status_t status) { if (mac_addr == NULL) @@ -292,6 +314,7 @@ static void IRAM_ATTR _zh_espnow_send_cb(const uint8_t *mac_addr, esp_now_send_s portYIELD_FROM_ISR(); }; } +#endif #if defined CONFIG_IDF_TARGET_ESP8266 || ESP_IDF_VERSION_MAJOR == 4 static void IRAM_ATTR _zh_espnow_recv_cb(const uint8_t *mac_addr, const uint8_t *data, int data_len)