Merge branch 'bugfix/fix_sc_send_failure_and_exit_issue' into 'master'

smartconfig: fix the issue of sending failure and exit

Closes WIFI-3844

See merge request espressif/esp-idf!22604
This commit is contained in:
Jiang Jiang Jian 2023-03-13 10:41:28 +08:00
commit d4a358a115

View File

@ -90,6 +90,7 @@ static void sc_ack_send_task(void *pvParameters)
port_bit = 0;
}
remote_port = SC_ACK_TOUCH_V2_SERVER_PORT(port_bit);
memset(remote_ip, 0xFF, sizeof(remote_ip));
} else {
remote_port = SC_ACK_AIRKISS_SERVER_PORT;
}
@ -163,15 +164,24 @@ static void sc_ack_send_task(void *pvParameters)
memcpy(remote_ip, &from.sin_addr, 4);
server_addr.sin_addr.s_addr = from.sin_addr.s_addr;
} else {
goto _end;
server_addr.sin_addr.s_addr = INADDR_BROADCAST;
}
}
uint32_t ip_addr = server_addr.sin_addr.s_addr;
while (s_sc_ack_send) {
/* Send smartconfig ACK every 100ms. */
vTaskDelay(100 / portTICK_PERIOD_MS);
sendlen = sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size);
if (ip_addr != INADDR_BROADCAST) {
sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size);
server_addr.sin_addr.s_addr = INADDR_BROADCAST;
sendlen = sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size);
server_addr.sin_addr.s_addr = ip_addr;
} else {
sendlen = sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size);
}
if (sendlen <= 0) {
err = sc_ack_send_get_errno(send_sock);
ESP_LOGD(TAG, "send failed, errno %d", err);