From 4e63941c92c68e87c71c785a60eb4872045443ef Mon Sep 17 00:00:00 2001 From: mikecarper Date: Thu, 25 Jun 2026 01:07:32 -0700 Subject: [PATCH] Fix repeater build compile errors --- src/Dispatcher.h | 2 +- src/helpers/bridges/ESPNowBridge.cpp | 13 +++++++++++-- src/helpers/bridges/ESPNowBridge.h | 9 +++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Dispatcher.h b/src/Dispatcher.h index cb86bb4b..e6bf9ebd 100644 --- a/src/Dispatcher.h +++ b/src/Dispatcher.h @@ -189,6 +189,7 @@ protected: virtual unsigned long getDutyCycleWindowMs() const { return 3600000; } const Packet* getOutboundInFlight() const { return outbound; } bool queueOutboundPacket(Packet* packet, uint8_t priority, uint32_t delay_millis); + bool tryParsePacket(Packet* pkt, const uint8_t* raw, int len); public: void begin(); @@ -215,7 +216,6 @@ public: unsigned long futureMillis(int millis_from_now) const; private: - bool tryParsePacket(Packet* pkt, const uint8_t* raw, int len); void checkRecv(); void checkSend(); }; diff --git a/src/helpers/bridges/ESPNowBridge.cpp b/src/helpers/bridges/ESPNowBridge.cpp index b9eb1c10..ac72284c 100644 --- a/src/helpers/bridges/ESPNowBridge.cpp +++ b/src/helpers/bridges/ESPNowBridge.cpp @@ -9,11 +9,20 @@ ESPNowBridge *ESPNowBridge::_instance = nullptr; // Static callback wrappers -void ESPNowBridge::recv_cb(const uint8_t *mac, const uint8_t *data, int32_t len) { +#if ESP_IDF_VERSION_MAJOR >= 5 +void ESPNowBridge::recv_cb(const esp_now_recv_info_t *info, const uint8_t *data, int len) { + const uint8_t *mac = info != nullptr ? info->src_addr : nullptr; if (_instance) { _instance->onDataRecv(mac, data, len); } } +#else +void ESPNowBridge::recv_cb(const uint8_t *mac, const uint8_t *data, int len) { + if (_instance) { + _instance->onDataRecv(mac, data, len); + } +} +#endif void ESPNowBridge::send_cb(const uint8_t *mac, esp_now_send_status_t status) { if (_instance) { @@ -100,7 +109,7 @@ void ESPNowBridge::xorCrypt(uint8_t *data, size_t len) { } } -void ESPNowBridge::onDataRecv(const uint8_t *mac, const uint8_t *data, int32_t len) { +void ESPNowBridge::onDataRecv(const uint8_t *mac, const uint8_t *data, int len) { // Ignore packets that are too small to contain header + checksum if (len < (BRIDGE_MAGIC_SIZE + BRIDGE_CHECKSUM_SIZE)) { BRIDGE_DEBUG_PRINTLN("RX packet too small, len=%d\n", len); diff --git a/src/helpers/bridges/ESPNowBridge.h b/src/helpers/bridges/ESPNowBridge.h index 431a036b..95658875 100644 --- a/src/helpers/bridges/ESPNowBridge.h +++ b/src/helpers/bridges/ESPNowBridge.h @@ -2,6 +2,7 @@ #include "MeshCore.h" #include "esp_now.h" +#include "esp_idf_version.h" #include "helpers/bridges/BridgeBase.h" #ifdef WITH_ESPNOW_BRIDGE @@ -42,7 +43,11 @@ class ESPNowBridge : public BridgeBase { private: static ESPNowBridge *_instance; - static void recv_cb(const uint8_t *mac, const uint8_t *data, int32_t len); +#if ESP_IDF_VERSION_MAJOR >= 5 + static void recv_cb(const esp_now_recv_info_t *info, const uint8_t *data, int len); +#else + static void recv_cb(const uint8_t *mac, const uint8_t *data, int len); +#endif static void send_cb(const uint8_t *mac, esp_now_send_status_t status); /** @@ -90,7 +95,7 @@ private: * @param data Received data * @param len Length of received data */ - void onDataRecv(const uint8_t *mac, const uint8_t *data, int32_t len); + void onDataRecv(const uint8_t *mac, const uint8_t *data, int len); /** * ESP-NOW send callback