espressif / esp-now

A connectionless Wi-Fi communication protocol
Apache License 2.0
477 stars 90 forks source link

Problem with lost packets during OTA (AEGHB-410) #94

Closed n3b0j5a closed 9 months ago

n3b0j5a commented 9 months ago

Hello, i have a problem with OTA, sometimes packages are lost between initiator and responder which causes whole process to block. I think it is a problem is both in responderer and initiator code.

    espnow_frame_head_t frame_head = {
        .broadcast        = true,
        .retransmit_count = CONFIG_ESPNOW_OTA_SEND_RETRY_NUM,
        .group            = true,
        .forward_ttl      = CONFIG_ESPNOW_OTA_SEND_FORWARD_TTL,
        .forward_rssi     = CONFIG_ESPNOW_OTA_SEND_FORWARD_RSSI,
        .security         = CONFIG_ESPNOW_OTA_SECURITY,
    };

CONFIG_ESPNOW_OTA_SEND_RETRY_NUM doesn't exist in Kconfig file so it is defined here as 1:

 #ifndef CONFIG_ESPNOW_OTA_SEND_RETRY_NUM
#define CONFIG_ESPNOW_OTA_SEND_RETRY_NUM        1
#endif

In responderer code it is even worse, it is global variable so retransmit_count is initialized as 0:

static espnow_frame_head_t g_frame_config = { .security = CONFIG_ESPNOW_OTA_SECURITY };

I will create another PR to fix this, please merge previous two as well.