From b4c8d92d944fe7f9221fdf582ee7e9850371137a Mon Sep 17 00:00:00 2001 From: Roshan Bangar Date: Fri, 30 Jun 2023 12:40:44 +0530 Subject: [PATCH] fix(nimble): Fix assert due to controller event while stack deinit --- components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 f60276dbea..d6d184354e 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 @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -57,6 +57,7 @@ const static char *TAG = "NimBLE"; int os_msys_buf_alloc(void); void os_msys_buf_free(void); +extern uint8_t ble_hs_enabled_state; void ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *cmd_cb, void *cmd_arg, @@ -333,6 +334,11 @@ static void controller_rcv_pkt_ready(void) */ static int host_rcv_pkt(uint8_t *data, uint16_t len) { + if(!ble_hs_enabled_state) { + /* If host is not enabled, drop the packet */ + ESP_LOGE(TAG, "Host not enabled. Dropping the packet!"); + return 0; + } if (data[0] == BLE_HCI_UART_H4_EVT) { uint8_t *evbuf;