From 9cd7e32a5bae5edcfc22b361a7c4fb6794bcbe44 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Fri, 6 Sep 2024 15:26:33 +0530 Subject: [PATCH] fix(nimble): De-register host cb in stack deinit --- .../host/nimble/esp-hci/src/esp_nimble_hci.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c b/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c index 4990859e57..7c3a449045 100644 --- a/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c +++ b/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c @@ -338,6 +338,12 @@ static void controller_rcv_pkt_ready(void) } } +static void dummy_controller_rcv_pkt_ready(void) +{ + /* Dummy function */ + return; +} + void bt_record_hci_data(uint8_t *data, uint16_t len) { #if (BT_HCI_LOG_INCLUDED == TRUE) @@ -407,11 +413,23 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len) return 0; } +static int dummy_host_rcv_pkt(uint8_t *data, uint16_t len) +{ + /* Dummy function */ + return 0; +} + + static const esp_vhci_host_callback_t vhci_host_cb = { .notify_host_send_available = controller_rcv_pkt_ready, .notify_host_recv = host_rcv_pkt, }; +static const esp_vhci_host_callback_t dummy_vhci_host_cb = { + .notify_host_send_available = dummy_controller_rcv_pkt_ready, + .notify_host_recv = dummy_host_rcv_pkt, +}; + static void ble_buf_free(void) { os_msys_buf_free(); @@ -520,6 +538,11 @@ esp_err_t esp_nimble_hci_deinit(void) return ret; } + ret = esp_vhci_host_register_callback(&dummy_vhci_host_cb); + if (ret != ESP_OK) { + return ret; + } + ble_buf_free(); #if MYNEWT_VAL(BLE_QUEUE_CONG_CHECK)