From 9cf57a86a0cb5d03bf37915cce113ddfcdcb61a1 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 Closes https://github.com/espressif/esp-idf/issues/8189 --- components/esp_wifi/src/smartconfig_ack.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/esp_wifi/src/smartconfig_ack.c b/components/esp_wifi/src/smartconfig_ack.c index 1d11528950..5df5dcc189 100644 --- a/components/esp_wifi/src/smartconfig_ack.c +++ b/components/esp_wifi/src/smartconfig_ack.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -121,8 +121,13 @@ static void sc_ack_send_task(void *pvParameters) goto _end; } - if (setsockopt(send_sock, SOL_SOCKET, SO_BROADCAST | SO_REUSEADDR, &optval, sizeof(int)) < 0) { - ESP_LOGE(TAG, "setsockopt failed"); + 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; }