espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.44k stars 7.25k forks source link

Add ESP_ERR_NOT_FINISHED to esp_now_send (IDFGH-13335) #14252

Open dizcza opened 2 months ago

dizcza commented 2 months ago

Is your feature request related to a problem?

I was getting ESP_ERR_ESPNOW_ARG and thinking that my input data format was incorrect. There was nothing wrong with the input data. The previous message hadn't been sent when I issued this command again getting ESP_ERR_ESPNOW_ARG instead of ESP_ERR_NOT_FINISHED.

Describe the solution you'd like.

Output ESP_ERR_NOT_FINISHED when you call esp_now_send but the previous send command is not completed.

Describe alternatives you've considered.

At least print a message in esp-wifi-lib that the esp-now is busy! Because it prints "Invalid argument" which is nonsense.

Additional context.

No response

dizcza commented 2 months ago

Well, I see in the docs

Note that too short interval between sending two ESP-NOW data may lead to disorder of sending callback function. So, it is recommended that sending the next ESP-NOW data after the sending callback function of the previous sending has returned.

but it'd be nice to have a meaningful error in the code.

dizcza commented 2 months ago

On second thought, maybe I was passing more than 250 bytes to esp_now_send... In either case, it's not clear:

Is esp_now_send a blocking operation? Does it return AFTER the data have been sent or does it queue the data to be sent later on?