Hi,
There is a racing issue in file:nRF5_SDK_for_Thread_and_Zigbee/components/iot/background_dfu/transport/coap/coap_dfu.c
in function:
static void coap_dfu_delayed_message_send(coap_message_t * p_message) { if (!m_coap_dfu_ctx.timer_active) { uint8_t delay = (background_dfu_random() % DEFAULT_DELAY_MAX_MS) + 1; app_timer_start(m_send_timer, APP_TIMER_TICKS(delay), p_message); m_coap_dfu_ctx.timer_active = true; } else { // Drop the message in case another message is pending for transmission. coap_message_delete(p_message); } }
Sometimes calculated dalay is 1 which causes that timer's callback:
static void delayed_send_handler(void * p_context) { coap_dfu_message_send((coap_message_t *)p_context); m_coap_dfu_ctx.timer_active = false; }
is called before execution of following line in coap_dfu_delayed_message_send()
function:m_coap_dfu_ctx.timer_active = true;
The issue does not appear after moving this line up before line:app_timer_start(m_send_timer, APP_TIMER_TICKS(delay), p_message);
So the working code is:
static void coap_dfu_delayed_message_send(coap_message_t * p_message) { if (!m_coap_dfu_ctx.timer_active) { uint8_t delay = (background_dfu_random() % DEFAULT_DELAY_MAX_MS) + 1; m_coap_dfu_ctx.timer_active = true; app_timer_start(m_send_timer, APP_TIMER_TICKS(delay), p_message); } else { // Drop the message in case another message is pending for transmission. coap_message_delete(p_message); } }
Can you please fix it in next SDK version?
Kind regards,
Krzysztof