From 51e196ac9319fc7d096328cba61f2068c646780e Mon Sep 17 00:00:00 2001 From: yuanjm Date: Tue, 4 Jan 2022 14:42:46 +0800 Subject: [PATCH] smartconfig: Fix smartconfig set socket option fail --- components/esp_wifi/src/smartconfig_ack.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/src/smartconfig_ack.c b/components/esp_wifi/src/smartconfig_ack.c index 76d1c618a8..1fd64b0a58 100644 --- a/components/esp_wifi/src/smartconfig_ack.c +++ b/components/esp_wifi/src/smartconfig_ack.c @@ -127,7 +127,15 @@ static void sc_ack_send_task(void *pvParameters) goto _end; } - setsockopt(send_sock, SOL_SOCKET, SO_BROADCAST | SO_REUSEADDR, &optval, sizeof(int)); + if (setsockopt(send_sock, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(int)) < 0) { + ESP_LOGE(TAG, "setsockopt SO_BROADCAST failed"); + goto _end; + } + + if (setsockopt(send_sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int)) < 0) { + ESP_LOGE(TAG, "setsockopt SO_REUSEADDR failed"); + goto _end; + } if (ack->type == SC_TYPE_AIRKISS) { char data = 0;