mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
smartconfig: fix the issue of sending failure and exit
This commit is contained in:
parent
60c57ade1d
commit
d52d1fc443
@ -92,6 +92,7 @@ static void sc_ack_send_task(void *pvParameters)
|
|||||||
port_bit = 0;
|
port_bit = 0;
|
||||||
}
|
}
|
||||||
remote_port = SC_ACK_TOUCH_V2_SERVER_PORT(port_bit);
|
remote_port = SC_ACK_TOUCH_V2_SERVER_PORT(port_bit);
|
||||||
|
memset(remote_ip, 0xFF, sizeof(remote_ip));
|
||||||
} else {
|
} else {
|
||||||
remote_port = SC_ACK_AIRKISS_SERVER_PORT;
|
remote_port = SC_ACK_AIRKISS_SERVER_PORT;
|
||||||
}
|
}
|
||||||
@ -165,15 +166,24 @@ static void sc_ack_send_task(void *pvParameters)
|
|||||||
memcpy(remote_ip, &from.sin_addr, 4);
|
memcpy(remote_ip, &from.sin_addr, 4);
|
||||||
server_addr.sin_addr.s_addr = from.sin_addr.s_addr;
|
server_addr.sin_addr.s_addr = from.sin_addr.s_addr;
|
||||||
} else {
|
} 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) {
|
while (s_sc_ack_send) {
|
||||||
/* Send smartconfig ACK every 100ms. */
|
/* Send smartconfig ACK every 100ms. */
|
||||||
vTaskDelay(100 / portTICK_RATE_MS);
|
vTaskDelay(100 / portTICK_RATE_MS);
|
||||||
|
|
||||||
|
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);
|
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) {
|
if (sendlen <= 0) {
|
||||||
err = sc_ack_send_get_errno(send_sock);
|
err = sc_ack_send_get_errno(send_sock);
|
||||||
ESP_LOGD(TAG, "send failed, errno %d", err);
|
ESP_LOGD(TAG, "send failed, errno %d", err);
|
||||||
|
Loading…
Reference in New Issue
Block a user