From 83ec9997e0422f2d61e6255abd9e7d43ee724cba Mon Sep 17 00:00:00 2001 From: entrop1a Date: Mon, 21 Oct 2024 23:40:40 -0300 Subject: [PATCH 1/4] 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; From 4301645bea2ab749a76c47909cc2e34cd575e799 Mon Sep 17 00:00:00 2001 From: entrop1a Date: Tue, 22 Oct 2024 21:26:17 -0300 Subject: [PATCH 2/4] fix(nan_console): Removal of network interface unconditional initialization --- examples/wifi/wifi_aware/nan_console/main/nan_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 037e52c35e5f..a8ff529ed021 100644 --- a/examples/wifi/wifi_aware/nan_console/main/nan_main.c +++ b/examples/wifi/wifi_aware/nan_console/main/nan_main.c @@ -235,12 +235,10 @@ 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) - { + 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"); esp_netif_destroy_default_wifi(g_nan_netif); From 545777e5cee462959a6d7f757c0c5e559829ac50 Mon Sep 17 00:00:00 2001 From: entrop1a Date: Wed, 30 Oct 2024 22:20:35 -0300 Subject: [PATCH 3/4] fix(nan_console): extending the logic for case netif start fails --- examples/wifi/wifi_aware/nan_console/main/nan_main.c | 1 + 1 file changed, 1 insertion(+) 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 a8ff529ed021..4884dd723b30 100644 --- a/examples/wifi/wifi_aware/nan_console/main/nan_main.c +++ b/examples/wifi/wifi_aware/nan_console/main/nan_main.c @@ -242,6 +242,7 @@ static int wifi_cmd_nan_disc(int argc, char **argv) if ((esp_wifi_nan_start(&nan_cfg)) != ESP_OK) { ESP_LOGI(TAG, "Failed to start NAN"); esp_netif_destroy_default_wifi(g_nan_netif); + g_nan_netif = NULL; return 1; } return 0; From 71d2e16b46daae5818455fef8cd485877efd0cb3 Mon Sep 17 00:00:00 2001 From: entrop1a Date: Thu, 31 Oct 2024 23:04:10 -0300 Subject: [PATCH 4/4] fix(nan_console): fix redundant global variable initialization --- examples/wifi/wifi_aware/nan_console/main/nan_main.c | 2 +- 1 file changed, 1 insertion(+), 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 4884dd723b30..e37156859c84 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 = NULL; +static esp_netif_t *g_nan_netif; #define NAN_EXAMPLE_SERVICE_NAME "ESP_NAN-Service"