fix(nimble): De-register host cb in stack deinit

This commit is contained in:
Rahul Tank
2024-09-02 17:42:39 +05:30
parent 121739fe78
commit 81a116a815
7 changed files with 46 additions and 0 deletions
@@ -14,6 +14,13 @@
#include "esp_hci_transport.h"
#include "esp_hci_internal.h"
static int
ble_transport_dummy_host_recv_cb(hci_trans_pkt_ind_t type, uint8_t *data, uint16_t len)
{
/* Dummy function */
return 0;
}
static int
ble_transport_host_recv_cb(hci_trans_pkt_ind_t type, uint8_t *data, uint16_t len)
{
@@ -45,6 +52,12 @@ ble_transport_ll_init(void)
hci_transport_host_callback_register(ble_transport_host_recv_cb);
}
void
ble_transport_ll_deinit(void)
{
hci_transport_host_callback_register(ble_transport_dummy_host_recv_cb);
}
void *
ble_transport_alloc_cmd(void)
{
@@ -31,3 +31,9 @@ ble_transport_ll_init(void)
}
void
ble_transport_ll_deinit(void)
{
}
@@ -31,6 +31,8 @@ extern "C" {
extern void ble_transport_ll_init(void);
extern void ble_transport_hs_init(void);
extern void ble_transport_ll_deinit(void);
/* APIs to be implemented by HS/LL side of transports */
extern int ble_transport_to_ll_cmd_impl(void *buf);
extern int ble_transport_to_ll_acl_impl(struct os_mbuf *om);
+10
View File
@@ -243,3 +243,13 @@ ble_transport_ll_init(void)
STAILQ_INIT(&tx_q);
}
void
ble_transport_ll_deinit(void)
{
memset(&hci_uart_h4sm, 0, sizeof(hci_uart_h4sm));
hal_uart_close(MYNEWT_VAL(BLE_TRANSPORT_UART_PORT));
hal_uart_deinit_cbs();
}
+5
View File
@@ -50,6 +50,11 @@ typedef int (*hal_uart_rx_char)(void *arg, uint8_t byte);
int hal_uart_init_cbs(int uart, hal_uart_tx_char tx_func,
hal_uart_tx_done tx_done, hal_uart_rx_char rx_func, void *arg);
/**
* De Initialize already registerd callbacks
*/
void hal_uart_deinit_cbs(void);
enum hal_uart_parity {
/** No Parity */
HAL_UART_PARITY_NONE = 0,
+8
View File
@@ -43,6 +43,14 @@ int hal_uart_init_cbs(int uart_no, hal_uart_tx_char tx_func,
return 0;
}
void hal_uart_deinit_cbs(void)
{
hci_uart.tx_char = NULL;
hci_uart.rx_char = NULL;
hci_uart.tx_done = NULL;
hci_uart.u_func_arg = NULL;
}
static void IRAM_ATTR hci_uart_rx_task(void *pvParameters)
{
uart_event_t event;
+2
View File
@@ -156,6 +156,8 @@ esp_err_t esp_nimble_deinit(void)
#if !SOC_ESP_NIMBLE_CONTROLLER || !CONFIG_BT_CONTROLLER_ENABLED
npl_freertos_funcs_deinit();
#endif
ble_transport_ll_deinit();
return ESP_OK;
}