From 83ec9997e0422f2d61e6255abd9e7d43ee724cba Mon Sep 17 00:00:00 2001 From: entrop1a Date: Mon, 21 Oct 2024 23:40:40 -0300 Subject: [PATCH] fix(nan_console): Error when NAN Discovery is started more than once --- examples/wifi/wifi_aware/nan_console/main/nan_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/wifi/wifi_aware/nan_console/main/nan_main.c b/examples/wifi/wifi_aware/nan_console/main/nan_main.c index a2734340ce28..037e52c35e5f 100644 --- a/examples/wifi/wifi_aware/nan_console/main/nan_main.c +++ b/examples/wifi/wifi_aware/nan_console/main/nan_main.c @@ -103,7 +103,7 @@ static struct { } ping_args; static const char *TAG = "nan_console"; -static esp_netif_t *g_nan_netif; +static esp_netif_t *g_nan_netif = NULL; #define NAN_EXAMPLE_SERVICE_NAME "ESP_NAN-Service" @@ -235,6 +235,11 @@ static int wifi_cmd_nan_disc(int argc, char **argv) nan_cfg.warm_up_sec = nan_args.warmup_time->ival[0]; } + if(!g_nan_netif) + { + g_nan_netif = esp_netif_create_default_wifi_nan(); + } + g_nan_netif = esp_netif_create_default_wifi_nan(); if ((esp_wifi_nan_start(&nan_cfg)) != ESP_OK) { ESP_LOGI(TAG, "Failed to start NAN"); @@ -252,6 +257,7 @@ static int wifi_cmd_nan_disc(int argc, char **argv) return 1; } esp_netif_destroy_default_wifi(g_nan_netif); + g_nan_netif = NULL; } return 0;