Older ESPNOW code no longer compiles

I have some code that used to work for several years. I recently made a change to a URL in the code and now the esp_now section no long compiles. I don't understand what the message means, no how to fix.

This is section of code that is failing:

void OnDataReceiver(const uint8_t *mac, const uint8_t *incomingData, int len) {
  memcpy(&myData, incomingData, sizeof(myData));
}

This is the line that the IDE is showing the error:

esp_now_register_recv_cb(OnDataReceiver);

And the error generated:

Compilation error: invalid conversion from 'void ()(const uint8_t , const uint8_t*, int)' {aka 'void ()(const unsigned char , const unsigned char*, int)'} to 'esp_now_recv_cb_t' {aka 'void ()(const esp_now_recv_info , const unsigned char*, int)'} [-fpermissive]

I don't understand what this error means or what to change to fix. Thanks.

Your esp32 Arduino core has probably auto updated to version 3 something..
Allot has changed..
See here..
can also downgrade your esp32 arduino core to like 2.0.14..

good luck.. ~q

I think I saw this before.

Try changing the line to:

esp_now_register_recv_cb(esp_now_recv_cb_t(OnDataReceiver));

the parameters have changed there not the return type..

void OnDataReceiver(const esp_now_recv_info_t * esp_now_info, const uint8_t *incomingData, int len) {
if (len <= sizeof(myData))
  memcpy(&myData, incomingData, sizeof(myData));
}

might get you past it but again allot has changed in core 3..

good luck.. ~q

Brilliant!! This fixed it. I don't understand why but happy to see it working again. Thanks very much!

You're welcome! Have fun! :upside_down_face: