espressif / esp-now

A connectionless Wi-Fi communication protocol
Apache License 2.0
526 stars 93 forks source link

Wrong channel logged on send error (AEGHB-532) #106

Closed n3b0j5a closed 8 months ago

n3b0j5a commented 8 months ago

Im pretty sure that on line 639 in espnow.c, there is an error, causing that logged channel where error happened is always 1 when we send only on current channel.

I would at least change that to:

            ESP_ERROR_CONTINUE(ret != ESP_OK, "[%s, %d] <%s> esp_now_send, channel: %d",
                               __func__, __LINE__, esp_err_to_name(ret), frame_head->channel == ESPNOW_CHANNEL_ALL ? g_self_country.schan + i : primary);

Or in better case, refactor everything in that function between lines 588 and 639 or maybe even split the code into multiple functions. Channel selection is done on multiple places so code is hard to follow and debug.

lhespress commented 8 months ago

@n3b0j5a Thanks for your contribution. I have modified it on master branch.