ESP_Now new problem after library change

Hello
Recently a library was changed in Arduino and my Esp_Now receiver code cannot be compiled anymore. As read in other post I changed the definition of the first parameter in the callback function but I still have an error.
Here is a very simplified code:

#include <ESP32_NOW.h>
#include <WiFi.h>

// callback function that will be executed when data is received
 void onDataRecv(esp_now_recv_info_t  *mac_addr, const uint8_t *incomingData, int len) { 
 }

void setup() {
  // put your setup code here, to run once:
  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
 // Once ESPNow is successfully Init, we will register for recv CB to
  // get recv packer info
  esp_now_register_recv_cb(OnDataRecv);

}

void loop() {
  // put your main code here, to run repeatedly:

}

and the message error:
C:\Users\mabil\Documents\Arduino\ESP32_exemples\ESPNOW\Test_Call_Back\Test_Call_Back.ino: In function 'void setup()':
C:\Users\mabil\Documents\Arduino\ESP32_exemples\ESPNOW\Test_Call_Back\Test_Call_Back.ino:18:28: error: 'OnDataRecv' was not declared in this scope; did you mean 'onDataRecv'?
18 | esp_now_register_recv_cb(OnDataRecv);
| ^~~~~~~~~~
| onDataRecv

exit status 1

Compilation error: 'OnDataRecv' was not declared in this scope; did you mean 'onDataRecv'?

I have look at the documentation but not beeing familiar with the use of typedef I don't find a way to correct my code

Can you help?

Claude

capital O

think you also missed the const on first parameter, e.g.

void OnDataRecv(const esp_now_recv_info* mac, const uint8_t *incomingData, int len) {

Thank you for both of you its working now :smiley:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.