Skip to content

Commit

Permalink
fix(nan_console): Error when NAN Discovery is started more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
entrop1a committed Oct 22, 2024
1 parent a97a7b0 commit 83ec999
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/wifi/wifi_aware/nan_console/main/nan_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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");
Expand All @@ -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;
Expand Down

0 comments on commit 83ec999

Please sign in to comment.