Skip to content

Commit 16435e7

Browse files
committed
build(esp/espnow): add support for IDF 5.5
ESP-IDF v5.5 introduced a change to the ESP-NOW send callback signature causing a build failure. This patch introduces a fix to this problem. Backwards compatibility is preserved.
1 parent 9e3ae65 commit 16435e7

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/espidf/espnow_adapter.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <thread>
1111

12+
#include "esp_idf_version.h"
1213
#include "esp_now.h"
1314

1415
#include "spsp/espnow_adapter.hpp"
@@ -46,16 +47,27 @@ namespace SPSP::LocalLayers::ESPNOW
4647
}
4748

4849
// Wrapper for C send callback
49-
void _sendCallback(const uint8_t *dst, esp_now_send_status_t status)
50+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
51+
void _sendCallback(const esp_now_send_info_t *tx_info, esp_now_send_status_t status)
5052
{
5153
auto cb = _adapterInstance->getSendCb();
54+
if (cb == nullptr) {
55+
return;
56+
}
5257

58+
cb(tx_info->des_addr, status == ESP_NOW_SEND_SUCCESS);
59+
}
60+
#else
61+
void _sendCallback(const uint8_t *dst, esp_now_send_status_t status)
62+
{
63+
auto cb = _adapterInstance->getSendCb();
5364
if (cb == nullptr) {
5465
return;
5566
}
5667

5768
cb(dst, status == ESP_NOW_SEND_SUCCESS);
5869
}
70+
#endif
5971

6072
Adapter::Adapter()
6173
{

0 commit comments

Comments
 (0)