diff --git a/components/smartconfig_ack/smartconfig_ack.c b/components/smartconfig_ack/smartconfig_ack.c index 91edc7b2ad..afe831f62d 100644 --- a/components/smartconfig_ack/smartconfig_ack.c +++ b/components/smartconfig_ack/smartconfig_ack.c @@ -118,25 +118,21 @@ static void sc_ack_send_task(void *pvParameters) vTaskDelay(100 / portTICK_RATE_MS); sendlen = sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size); - if (sendlen > 0) { - /* Totally send 30 smartconfig ACKs. Then smartconfig is successful. */ - if (packet_count++ >= SC_ACK_MAX_COUNT) { - if (ack->link_flag) { - *ack->link_flag = 1; - } - if (ack->cb) { - ack->cb(SC_STATUS_LINK_OVER, remote_ip); - } - goto _end; - } - } - else { + + if (sendlen <= 0) { err = sc_ack_send_get_errno(send_sock); - if (err == ENOMEM || err == EAGAIN) { - ESP_LOGD(TAG, "send failed, errno %d", err); - continue; + ESP_LOGD(TAG, "send failed, errno %d", err); + vTaskDelay(100 / portTICK_RATE_MS); + } + + /* Send 30 smartconfig ACKs. Then smartconfig is successful. */ + if (packet_count++ >= SC_ACK_MAX_COUNT) { + if (ack->link_flag) { + *ack->link_flag = 1; + } + if (ack->cb) { + ack->cb(SC_STATUS_LINK_OVER, remote_ip); } - ESP_LOGE(TAG, "send failed, errno %d", err); goto _end; } }