From 86cacd6e2ad7cc2b8c177a9eabc4fede52f834ec Mon Sep 17 00:00:00 2001 From: Timm Bogner <64260873+timmbogner@users.noreply.github.com> Date: Sun, 2 Jun 2024 22:29:49 -0500 Subject: [PATCH] Patch for ESP-NOW API change Co-Authored-By: Heinz Haeberle <281508+kheinz57@users.noreply.github.com> #209 --- src/fdrs_gateway_espnow.h | 11 ++++++----- src/fdrs_node_espnow.h | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/fdrs_gateway_espnow.h b/src/fdrs_gateway_espnow.h index cf1513c..72feddb 100644 --- a/src/fdrs_gateway_espnow.h +++ b/src/fdrs_gateway_espnow.h @@ -32,19 +32,20 @@ bool pingFlagEspNow = false; #if defined(ESP8266) void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) { -esp_now_sent_flag = true; + esp_now_sent_flag = true; } void OnDataRecv(uint8_t *mac, uint8_t *incomingData, uint8_t len) { + memcpy(&incMAC, mac, sizeof(incMAC)); #elif defined(ESP32) void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { -esp_now_sent_flag = true; + esp_now_sent_flag = true; } -void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len) +void OnDataRecv(const esp_now_recv_info *pkt_info, const uint8_t *incomingData, int len) { -#endif - memcpy(&incMAC, mac, sizeof(incMAC)); + memcpy(&incMAC, pkt_info->src_addr, sizeof(incMAC)); + #endif if (len < sizeof(DataReading)) { DBG1("Incoming ESP-NOW System Packet from 0x" + String(incMAC[5], HEX)); diff --git a/src/fdrs_node_espnow.h b/src/fdrs_node_espnow.h index 64b6a3f..2f39a5b 100644 --- a/src/fdrs_node_espnow.h +++ b/src/fdrs_node_espnow.h @@ -68,6 +68,7 @@ void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) } void OnDataRecv(uint8_t *mac, uint8_t *incomingData, uint8_t len) { +memcpy(&incMAC, mac, sizeof(incMAC)); #elif defined(ESP32) void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { @@ -80,10 +81,10 @@ void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) esp_now_ack_flag = CRC_BAD; } } -void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len) +void OnDataRecv(const esp_now_recv_info *pkt_info, const uint8_t *incomingData, int len) { + memcpy(&incMAC, pkt_info->src_addr, sizeof(incMAC)); #endif - memcpy(&incMAC, mac, sizeof(incMAC)); if (len == sizeof(SystemPacket)) { SystemPacket command;