Merge branch 'bugfix/fix_airkiss_bug_v3.1' into 'release/v3.1'

fix the bug for Airkiss (backport v3.1)

See merge request espressif/esp-idf!7668
This commit is contained in:
Jiang Jiang Jian 2020-02-19 16:39:44 +08:00
commit ebf9bc3051
2 changed files with 30 additions and 0 deletions

View File

@ -24,6 +24,9 @@ extern "C" {
#define SC_ACK_TOUCH_SERVER_PORT 18266 /*!< ESP touch UDP port of server on cellphone */
#define SC_ACK_AIRKISS_SERVER_PORT 10000 /*!< Airkiss UDP port of server on cellphone */
#define SC_ACK_AIRKISS_DEVICE_PORT 10001 /*!< Airkiss UDP port of server on device */
#define SC_ACK_AIRKISS_TIMEOUT 1500 /*!< Airkiss read data timeout millisecond */
#define SC_ACK_TOUCH_LEN 11 /*!< Length of ESP touch ACK context */
#define SC_ACK_AIRKISS_LEN 7 /*!< Length of Airkiss ACK context */

View File

@ -86,6 +86,33 @@ static void sc_ack_send_task(void *pvParameters)
setsockopt(send_sock, SOL_SOCKET, SO_BROADCAST | SO_REUSEADDR, &optval, sizeof(int));
if (ack->type == SC_ACK_TYPE_AIRKISS) {
char data = 0;
struct sockaddr_in local_addr, from;
socklen_t sockadd_len = sizeof(struct sockaddr);
struct timeval timeout = {
SC_ACK_AIRKISS_TIMEOUT / 1000,
SC_ACK_AIRKISS_TIMEOUT % 1000 * 1000
};
bzero(&local_addr, sizeof(struct sockaddr_in));
bzero(&from, sizeof(struct sockaddr_in));
local_addr.sin_family = AF_INET;
local_addr.sin_addr.s_addr = INADDR_ANY;
local_addr.sin_port = htons(SC_ACK_AIRKISS_DEVICE_PORT);
bind(send_sock, (struct sockaddr *)&local_addr, sockadd_len);
setsockopt(send_sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
recvfrom(send_sock, &data, 1, 0, (struct sockaddr *)&from, &sockadd_len);
if (from.sin_addr.s_addr != INADDR_ANY) {
memcpy(remote_ip, &from.sin_addr, 4);
server_addr.sin_addr.s_addr = from.sin_addr.s_addr;
} else {
goto _end;
}
}
while (s_sc_ack_send) {
/* Send smartconfig ACK every 100ms. */
vTaskDelay(100 / portTICK_RATE_MS);