diff --git a/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c b/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c index 29b331a464e..c4bc32be7eb 100644 --- a/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c +++ b/components/esp_wifi/wifi_apps/roaming_app/src/roaming_app.c @@ -2200,8 +2200,11 @@ void roam_init_app(void) ESP_LOGE(ROAMING_TAG, "No roaming method enabled. Roaming app cannot be initialized"); return; #endif + if (g_roaming_app.app_active) { + ESP_LOGD(ROAMING_TAG, "Roaming app already initialized"); + return; + } memset(&g_roaming_app, 0, sizeof(g_roaming_app)); - g_roaming_app.app_active = true; #if LOW_RSSI_ROAMING_ENABLED ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_BSS_RSSI_LOW, &roaming_app_rssi_low_handler, NULL)); @@ -2212,6 +2215,7 @@ void roam_init_app(void) ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, &roaming_app_neighbor_report_recv_handler, NULL)); #endif /*PERIODIC_RRM_MONITORING*/ + g_roaming_app.app_active = true; ESP_LOGI(ROAMING_TAG, "Roaming app initialization done"); } @@ -2245,7 +2249,6 @@ static int roaming_app_deinit_internal(void *ctx, void *data) { (void) ctx; (void) data; - g_roaming_app.app_active = false; roaming_app_cancel_pending_events(); roaming_app_stop_periodic_monitors(); roaming_app_reset_connect_hint_state(); @@ -2287,6 +2290,7 @@ void roam_deinit_app(void) ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, &roaming_app_neighbor_report_recv_handler)); #endif /*PERIODIC_RRM_MONITORING*/ + g_roaming_app.app_active = false; } #if CONFIG_ESP_WIFI_ROAMING_BSSID_BLACKLIST