Merge branch 'bugfix/fix_airkiss_bug_v3.2' into 'release/v3.2'
fix the bug for Airkiss (backport v3.2) See merge request espressif/esp-idf!7667
This commit is contained in:
commit
5693dd69ed
2 changed files with 29 additions and 0 deletions
|
@ -24,6 +24,8 @@ 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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue