20#ifndef H_NIMBLE_TRANSPORT_
21#define H_NIMBLE_TRANSPORT_
27#include "transport_impl.h"
28#include "transport/monitor.h"
33#include "nimble/porting/nimble/include/os/os_mempool.h"
35#define BLE_HCI_TRANS_CMD_SZ 260
61#define BLE_HCI_TRANS_BUF_EVT_LO 1
62#define BLE_HCI_TRANS_BUF_EVT_HI 2
65#define BLE_HCI_TRANS_BUF_CMD 3
67void ble_transport_init(
void);
69esp_err_t ble_buf_alloc(
void);
71void ble_buf_free(
void);
73void ble_transport_deinit(
void);
76typedef int ble_hci_trans_rx_cmd_fn(uint8_t *cmd,
void *arg);
77typedef int ble_hci_trans_rx_acl_fn(
struct os_mbuf *om,
void *arg);
79#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
80#define ble_transport_alloc_cmd() ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_CMD)
81#define ble_transport_alloc_event(X) ble_hci_trans_buf_alloc(X ? BLE_HCI_TRANS_BUF_EVT_LO : BLE_HCI_TRANS_BUF_EVT_HI)
82#define ble_transport_free ble_hci_trans_buf_free
84struct ble_hci_trans_funcs_t {
85 int(*_ble_hci_trans_hs_acl_tx)(
struct os_mbuf *om);
86 int(*_ble_hci_trans_hs_cmd_tx)(uint8_t *cmd);
87 int(*_ble_hci_trans_ll_acl_tx)(
struct os_mbuf *om);
88 int(*_ble_hci_trans_ll_evt_tx)(uint8_t *hci_ev);
89 int(*_ble_hci_trans_reset)(void);
93extern struct ble_hci_trans_funcs_t *ble_hci_trans_funcs_ptr;
104extern int r_ble_hci_trans_ll_evt_tx(uint8_t *hci_ev);
105#define ble_hci_trans_ll_evt_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_ll_evt_tx
115extern int r_ble_hci_trans_ll_acl_tx(
struct os_mbuf *om);
116#define ble_hci_trans_ll_acl_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_ll_acl_tx
127extern int r_ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
128#define ble_hci_trans_hs_cmd_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_hs_cmd_tx
138extern int r_ble_hci_trans_hs_acl_tx(
struct os_mbuf *om);
139#define ble_hci_trans_hs_acl_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_hs_acl_tx
150extern uint8_t *r_ble_hci_trans_buf_alloc(
int type);
151#define ble_hci_trans_buf_alloc r_ble_hci_trans_buf_alloc
159extern void r_ble_hci_trans_buf_free(uint8_t *buf);
160#define ble_hci_trans_buf_free r_ble_hci_trans_buf_free
174#define ble_hci_trans_set_acl_free_cb ble_hci_trans_funcs_ptr->_ble_hci_trans_set_acl_free_cb
189extern void r_ble_hci_trans_cfg_ll(ble_hci_trans_rx_cmd_fn *cmd_cb,
191 ble_hci_trans_rx_acl_fn *acl_cb,
193#define ble_hci_trans_cfg_ll r_ble_hci_trans_cfg_ll
208extern void r_ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *evt_cb,
210 ble_hci_trans_rx_acl_fn *acl_cb,
212#define ble_hci_trans_cfg_hs r_ble_hci_trans_cfg_hs
221extern int r_ble_hci_trans_reset(
void);
222#define ble_hci_trans_reset ble_hci_trans_funcs_ptr->_ble_hci_trans_reset
224void esp_ble_hci_trans_init(uint8_t);
236int ble_hci_trans_ll_evt_tx(uint8_t *hci_ev);
246int ble_hci_trans_ll_acl_tx(
struct os_mbuf *om);
257int ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
267int ble_hci_trans_hs_acl_tx(
struct os_mbuf *om);
278int esp_ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
288int esp_ble_hci_trans_hs_acl_tx(
struct os_mbuf *om);
299uint8_t *esp_ble_hci_trans_buf_alloc(
int type);
307void esp_ble_hci_trans_buf_free(uint8_t *buf);
322void esp_ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *evt_cb,
324 ble_hci_trans_rx_acl_fn *acl_cb,
334int esp_ble_hci_trans_reset(
void);
339#if !SOC_ESP_NIMBLE_CONTROLLER || !CONFIG_BT_CONTROLLER_ENABLED
340void *ble_transport_alloc_cmd(
void);
341void *ble_transport_alloc_evt(
int discardable);
342struct os_mbuf *ble_transport_alloc_acl_from_hs(
void);
343struct os_mbuf *ble_transport_alloc_acl_from_ll(
void);
346void ble_transport_free(
void *buf);
353#if CONFIG_BT_CONTROLLER_ENABLED
354#define ble_transport_to_ll_acl ble_hci_trans_hs_acl_tx
355#define ble_transport_to_ll_cmd ble_hci_trans_hs_cmd_tx
358int ble_transport_to_hs_evt(
void *buf);
359int ble_transport_to_hs_acl(
struct os_mbuf *om);
365void ble_transport_init(
void);
366void ble_transport_deinit(
void);
369void *ble_transport_alloc_cmd(
void);
370void *ble_transport_alloc_evt(
int discardable);
371struct os_mbuf *ble_transport_alloc_acl_from_hs(
void);
372struct os_mbuf *ble_transport_alloc_acl_from_ll(
void);
375void ble_transport_free(
void *buf);
381int ble_transport_to_ll_cmd(
void *buf);
382int ble_transport_to_ll_acl(
struct os_mbuf *om);
383int ble_transport_to_hs_evt(
void *buf);
384int ble_transport_to_hs_acl(
struct os_mbuf *om);
os_error_t os_mempool_put_fn(struct os_mempool_ext *ome, void *data, void *arg)
Definition os_mempool.h:102