fix: ESP-NOW callback signature for new ESP-IDF, volatile qualifier

This commit is contained in:
salty 2026-03-14 12:32:11 -04:00
parent 30e012255f
commit b7dcc00c5e

View File

@ -77,16 +77,16 @@ struct EspNowPacket {
/* ISR ring buffer for ESP-NOW */
#define ESPNOW_Q_SIZE 8
static volatile EspNowPacket g_enq[ESPNOW_Q_SIZE];
static EspNowPacket g_enq[ESPNOW_Q_SIZE];
static volatile int g_en_head = 0, g_en_tail = 0;
static void IRAM_ATTR espnow_rx_cb(const uint8_t *mac, const uint8_t *data, int len) {
static void IRAM_ATTR espnow_rx_cb(const esp_now_recv_info_t *info, const uint8_t *data, int len) {
if (len < (int)sizeof(EspNowPacket)) return;
const EspNowPacket *p = (const EspNowPacket *)data;
if (p->magic[0] != ESPNOW_MAGIC_0 || p->magic[1] != ESPNOW_MAGIC_1) return;
int next = (g_en_head + 1) % ESPNOW_Q_SIZE;
if (next == g_en_tail) return;
g_enq[g_en_head] = *p;
memcpy(&g_enq[g_en_head], p, sizeof(EspNowPacket));
g_en_head = next;
}