From dd6a87a73445584bd3e5713d781c5684e2f2c544 Mon Sep 17 00:00:00 2001 From: "tarun.kumar" Date: Wed, 2 Sep 2026 12:44:03 +0530 Subject: [PATCH] fix(wifi) : Roam handle unregister issue --- .../esp_wifi/wifi_apps/roaming_app/src/roaming_app.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 fe28e21f977..bb9b8d4e2cf 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 @@ -2198,8 +2198,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)); @@ -2210,6 +2213,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"); } @@ -2243,7 +2247,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(); @@ -2285,6 +2288,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