From 54e42973468d483b2bf6a1221a9d02d01235e89d Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Mon, 23 Sep 2024 19:00:38 +0530 Subject: [PATCH] fix(nimble): Fixed deinit sequence in blufi --- .../btc/profile/esp/blufi/nimble_host/esp_blufi.c | 4 +++- examples/bluetooth/blufi/main/blufi_init.c | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c index 9698e9da58..7cfcf0dfd7 100644 --- a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c +++ b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c @@ -442,8 +442,10 @@ uint8_t esp_blufi_init(void) void esp_blufi_deinit(void) { blufi_env.enabled = false; - btc_msg_t msg; esp_blufi_cb_param_t param; + btc_msg_t msg; + memset (&msg, 0x0, sizeof (msg)); + msg.sig = BTC_SIG_API_CB; msg.pid = BTC_PID_BLUFI; msg.act = ESP_BLUFI_EVENT_DEINIT_FINISH; param.deinit_finish.state = ESP_BLUFI_DEINIT_OK; diff --git a/examples/bluetooth/blufi/main/blufi_init.c b/examples/bluetooth/blufi/main/blufi_init.c index 378344e422..6df7056a8a 100644 --- a/examples/bluetooth/blufi/main/blufi_init.c +++ b/examples/bluetooth/blufi/main/blufi_init.c @@ -227,6 +227,12 @@ esp_err_t esp_blufi_host_deinit(void) { esp_err_t ret = ESP_OK; + ret = nimble_port_stop(); + + if (ret == 0) { + esp_nimble_deinit(); + } + ret = esp_blufi_profile_deinit(); if(ret != ESP_OK) { return ret; @@ -234,11 +240,6 @@ esp_err_t esp_blufi_host_deinit(void) esp_blufi_btc_deinit(); - ret = nimble_port_stop(); - if (ret == 0) { - esp_nimble_deinit(); - } - return ret; }