mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-10-30 01:03:33 +00:00
Nimble: Migration changes for nimble-1.5
This commit is contained in:
@@ -438,7 +438,7 @@ int bt_le_adv_start(const struct ble_gap_adv_params *param,
|
||||
const struct bt_data *ad, size_t ad_len,
|
||||
const struct bt_data *sd, size_t sd_len);
|
||||
|
||||
int bt_le_adv_stop();
|
||||
int bt_le_adv_stop(void);
|
||||
|
||||
struct k_work_delayable {
|
||||
struct ble_npl_callout work;
|
||||
|
||||
@@ -18,6 +18,14 @@
|
||||
#include "mesh/glue.h"
|
||||
#include "pb_gatt_srv.h"
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef max
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL(BLE_MESH_ADV_LEGACY)
|
||||
/* Convert from ms to 0.625ms units */
|
||||
#define ADV_SCAN_UNIT(_ms) ((_ms) * 8 / 5)
|
||||
|
||||
@@ -300,6 +300,7 @@ static void prov_dh_key_gen(void)
|
||||
uint8_t remote_pk_le[BT_PUB_KEY_LEN];
|
||||
|
||||
remote_pk = bt_mesh_prov_link.conf_inputs.pub_key_provisioner;
|
||||
#if !CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
|
||||
if (MYNEWT_VAL(BLE_MESH_PROV_OOB_PUBLIC_KEY) &&
|
||||
atomic_test_bit(bt_mesh_prov_link.flags, OOB_PUB_KEY)) {
|
||||
if (uECC_valid_public_key(remote_pk, &curve_secp256r1)) {
|
||||
@@ -316,6 +317,7 @@ static void prov_dh_key_gen(void)
|
||||
prov_fail(PROV_ERR_UNEXP_ERR);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Copy remote key in little-endian for bt_dh_key_gen().
|
||||
* X and Y halves are swapped independently. The bt_dh_key_gen()
|
||||
|
||||
@@ -27,6 +27,14 @@
|
||||
#include "proxy_msg.h"
|
||||
#include "pb_gatt_srv.h"
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef max
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME)
|
||||
#define ADV_OPT_USE_NAME BT_LE_ADV_OPT_USE_NAME
|
||||
#else
|
||||
|
||||
@@ -799,6 +799,11 @@ ble_hs_init(void)
|
||||
ble_hs_evq_set(nimble_port_get_dflt_eventq());
|
||||
#endif
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
/* Configure the HCI transport to communicate with a host. */
|
||||
ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL);
|
||||
#endif
|
||||
|
||||
/* Enqueue the start event to the default event queue. Using the default
|
||||
* queue ensures the event won't run until the end of main(). This allows
|
||||
* the application to configure this package in the meantime.
|
||||
@@ -844,7 +849,9 @@ ble_hs_deinit(void)
|
||||
ble_monitor_deinit();
|
||||
#endif
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
ble_hci_trans_cfg_hs(NULL, NULL, NULL, NULL);
|
||||
#endif
|
||||
|
||||
ble_npl_mutex_deinit(&ble_hs_mutex);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ static ble_npl_event_fn ble_hs_flow_event_cb;
|
||||
static struct ble_npl_event ble_hs_flow_ev;
|
||||
|
||||
/* Connection handle associated with each mbuf in ACL pool */
|
||||
static uint16_t ble_hs_flow_mbuf_conn_handle[ MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT) ];
|
||||
static uint16_t ble_hs_flow_mbuf_conn_handle[ MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_HS_COUNT) ];
|
||||
|
||||
static inline int
|
||||
ble_hs_flow_mbuf_index(const struct os_mbuf *om)
|
||||
@@ -135,7 +135,7 @@ ble_hs_flow_inc_completed_pkts(struct ble_hs_conn *conn)
|
||||
conn->bhc_completed_pkts++;
|
||||
ble_hs_flow_num_completed_pkts++;
|
||||
|
||||
if (ble_hs_flow_num_completed_pkts > MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT)) {
|
||||
if (ble_hs_flow_num_completed_pkts > MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_HS_COUNT)) {
|
||||
ble_hs_sched_reset(BLE_HS_ECONTROLLER);
|
||||
return;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ ble_hs_flow_inc_completed_pkts(struct ble_hs_conn *conn)
|
||||
/* If the number of free buffers is at or below the configured threshold,
|
||||
* send an immediate number-of-copmleted-packets event.
|
||||
*/
|
||||
num_free = MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT) -
|
||||
num_free = MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_HS_COUNT) -
|
||||
ble_hs_flow_num_completed_pkts;
|
||||
if (num_free <= MYNEWT_VAL(BLE_HS_FLOW_CTRL_THRESH)) {
|
||||
ble_npl_eventq_put(ble_hs_evq_get(), &ble_hs_flow_ev);
|
||||
@@ -231,7 +231,7 @@ ble_hs_flow_startup(void)
|
||||
struct ble_hci_cb_ctlr_to_host_fc_cp enable_cmd;
|
||||
struct ble_hci_cb_host_buf_size_cp buf_size_cmd = {
|
||||
.acl_data_len = htole16(MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)),
|
||||
.acl_num = htole16(MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT)),
|
||||
.acl_num = htole16(MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_HS_COUNT)),
|
||||
};
|
||||
int rc;
|
||||
|
||||
@@ -265,7 +265,11 @@ ble_hs_flow_startup(void)
|
||||
|
||||
/* Flow control successfully enabled. */
|
||||
ble_hs_flow_num_completed_pkts = 0;
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
ble_hci_trans_set_acl_free_cb(ble_hs_flow_acl_free, NULL);
|
||||
#else
|
||||
ble_transport_register_put_acl_from_ll_cb(ble_hs_flow_acl_free);
|
||||
#endif
|
||||
ble_npl_callout_init(&ble_hs_flow_timer, ble_hs_evq_get(),
|
||||
ble_hs_flow_event_cb, NULL);
|
||||
#endif
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "mem/mem.h"
|
||||
#include "ble_hs_priv.h"
|
||||
|
||||
#include "nimble/transport.h"
|
||||
|
||||
#define BLE_HCI_CMD_TIMEOUT_MS 2000
|
||||
|
||||
static struct ble_npl_mutex ble_hs_hci_mutex;
|
||||
|
||||
@@ -41,7 +41,7 @@ ble_hs_hci_cmd_transport(struct ble_hci_cmd *cmd)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = ble_transport_to_ll_cmd(cmd);
|
||||
rc = ble_transport_to_ll_cmd((uint8_t *)cmd);
|
||||
switch (rc) {
|
||||
case 0:
|
||||
return 0;
|
||||
@@ -61,7 +61,7 @@ ble_hs_hci_cmd_send(uint16_t opcode, uint8_t len, const void *cmddata)
|
||||
uint8_t *buf;
|
||||
int rc;
|
||||
|
||||
cmd = ble_transport_alloc_cmd();
|
||||
cmd = (struct ble_hci_cmd *)ble_transport_alloc_cmd();
|
||||
BLE_HS_DBG_ASSERT(cmd != NULL);
|
||||
|
||||
buf = (uint8_t *)cmd;
|
||||
|
||||
@@ -980,7 +980,7 @@ ble_hs_hci_evt_process(struct ble_hci_ev *ev)
|
||||
rc = entry->cb(ev->opcode, ev->data, ev->length);
|
||||
}
|
||||
|
||||
ble_transport_free(ev);
|
||||
ble_transport_free((uint8_t *)ev);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -26,10 +26,306 @@ extern "C" {
|
||||
|
||||
#include <nimble/transport_impl.h>
|
||||
#include <nimble/transport/monitor.h>
|
||||
#include <inttypes.h>
|
||||
#include "os/os_mempool.h"
|
||||
|
||||
#define BLE_HCI_TRANS_CMD_SZ 260
|
||||
/*** Type of buffers for holding commands and events. */
|
||||
/**
|
||||
* Controller-to-host event buffers. Events have one of two priorities:
|
||||
* o Low-priority (BLE_HCI_TRANS_BUF_EVT_LO)
|
||||
* o High-priority (BLE_HCI_TRANS_BUF_EVT_HI)
|
||||
*
|
||||
* Low-priority event buffers are only used for advertising reports. If there
|
||||
* are no free low-priority event buffers, then an incoming advertising report
|
||||
* will get dropped.
|
||||
*
|
||||
* High-priority event buffers are for everything except advertising reports.
|
||||
* If there are no free high-priority event buffers, a request to allocate one
|
||||
* will try to allocate a low-priority buffer instead.
|
||||
*
|
||||
* If you want all events to be given equal treatment, then you should allocate
|
||||
* low-priority events only.
|
||||
*
|
||||
* Event priorities solve the problem of critical events getting dropped due to
|
||||
* a flood of advertising reports. This solution is likely temporary: when
|
||||
* HCI flow control is added, event priorities may become obsolete.
|
||||
*
|
||||
* Not all transports distinguish between low and high priority events. If the
|
||||
* transport does not have separate settings for low and high buffer counts,
|
||||
* then it treats all events with equal priority.
|
||||
*/
|
||||
#define BLE_HCI_TRANS_BUF_EVT_LO 1
|
||||
#define BLE_HCI_TRANS_BUF_EVT_HI 2
|
||||
|
||||
/* Host-to-controller command. */
|
||||
#define BLE_HCI_TRANS_BUF_CMD 3
|
||||
|
||||
/** Callback function types; executed when HCI packets are received. */
|
||||
typedef int ble_hci_trans_rx_cmd_fn(uint8_t *cmd, void *arg);
|
||||
typedef int ble_hci_trans_rx_acl_fn(struct os_mbuf *om, void *arg);
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
#define ble_transport_alloc_cmd() ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_CMD)
|
||||
#define ble_transport_alloc_event(X) ble_hci_trans_buf_alloc(X ? BLE_HCI_TRANS_BUF_EVT_LO : BLE_HCI_TRANS_BUF_EVT_HI)
|
||||
#define ble_transport_free ble_hci_trans_buf_free
|
||||
|
||||
struct ble_hci_trans_funcs_t {
|
||||
int(*_ble_hci_trans_hs_acl_tx)(struct os_mbuf *om);
|
||||
int(*_ble_hci_trans_hs_cmd_tx)(uint8_t *cmd);
|
||||
int(*_ble_hci_trans_ll_acl_tx)(struct os_mbuf *om);
|
||||
int(*_ble_hci_trans_ll_evt_tx)(uint8_t *hci_ev);
|
||||
int(*_ble_hci_trans_reset)(void);
|
||||
int(*_ble_hci_trans_set_acl_free_cb)(os_mempool_put_fn *cb,void *arg);
|
||||
};
|
||||
|
||||
extern struct ble_hci_trans_funcs_t *ble_hci_trans_funcs_ptr;
|
||||
|
||||
/**
|
||||
* Sends an HCI event from the controller to the host.
|
||||
*
|
||||
* @param cmd The HCI event to send. This buffer must be
|
||||
* allocated via ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_ll_evt_tx(uint8_t *hci_ev);
|
||||
#define ble_hci_trans_ll_evt_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_ll_evt_tx
|
||||
|
||||
/**
|
||||
* Sends ACL data from controller to host.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_ll_acl_tx(struct os_mbuf *om);
|
||||
#define ble_hci_trans_ll_acl_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_ll_acl_tx
|
||||
|
||||
/**
|
||||
* Sends an HCI command from the host to the controller.
|
||||
*
|
||||
* @param cmd The HCI command to send. This buffer must be
|
||||
* allocated via ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
|
||||
#define ble_hci_trans_hs_cmd_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_hs_cmd_tx
|
||||
|
||||
/**
|
||||
* Sends ACL data from host to controller.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_hs_acl_tx(struct os_mbuf *om);
|
||||
#define ble_hci_trans_hs_acl_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_hs_acl_tx
|
||||
|
||||
/**
|
||||
* Allocates a flat buffer of the specified type.
|
||||
*
|
||||
* @param type The type of buffer to allocate; one of the
|
||||
* BLE_HCI_TRANS_BUF_[...] constants.
|
||||
*
|
||||
* @return The allocated buffer on success;
|
||||
* NULL on buffer exhaustion.
|
||||
*/
|
||||
extern uint8_t *r_ble_hci_trans_buf_alloc(int type);
|
||||
#define ble_hci_trans_buf_alloc r_ble_hci_trans_buf_alloc
|
||||
|
||||
/**
|
||||
* Frees the specified flat buffer. The buffer must have been allocated via
|
||||
* ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @param buf The buffer to free.
|
||||
*/
|
||||
extern void r_ble_hci_trans_buf_free(uint8_t *buf);
|
||||
#define ble_hci_trans_buf_free r_ble_hci_trans_buf_free
|
||||
|
||||
/**
|
||||
* Configures a callback to get executed whenever an ACL data packet is freed.
|
||||
* The function is called immediately before the free occurs.
|
||||
*
|
||||
* @param cb The callback to configure.
|
||||
* @param arg An optional argument to pass to the callback.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* BLE_ERR_UNSUPPORTED if the transport does not
|
||||
* support this operation.
|
||||
*/
|
||||
extern int r_ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg);
|
||||
#define ble_hci_trans_set_acl_free_cb ble_hci_trans_funcs_ptr->_ble_hci_trans_set_acl_free_cb
|
||||
|
||||
/**
|
||||
* Configures the HCI transport to operate with a controller. The transport
|
||||
* will execute specified callbacks upon receiving HCI packets from the host.
|
||||
*
|
||||
* @param cmd_cb The callback to execute upon receiving an HCI
|
||||
* command.
|
||||
* @param cmd_arg Optional argument to pass to the command
|
||||
* callback.
|
||||
* @param acl_cb The callback to execute upon receiving ACL
|
||||
* data.
|
||||
* @param acl_arg Optional argument to pass to the ACL
|
||||
* callback.
|
||||
*/
|
||||
extern void r_ble_hci_trans_cfg_ll(ble_hci_trans_rx_cmd_fn *cmd_cb,
|
||||
void *cmd_arg,
|
||||
ble_hci_trans_rx_acl_fn *acl_cb,
|
||||
void *acl_arg);
|
||||
#define ble_hci_trans_cfg_ll r_ble_hci_trans_cfg_ll
|
||||
|
||||
/**
|
||||
* Configures the HCI transport to operate with a host. The transport will
|
||||
* execute specified callbacks upon receiving HCI packets from the controller.
|
||||
*
|
||||
* @param evt_cb The callback to execute upon receiving an HCI
|
||||
* event.
|
||||
* @param evt_arg Optional argument to pass to the event
|
||||
* callback.
|
||||
* @param acl_cb The callback to execute upon receiving ACL
|
||||
* data.
|
||||
* @param acl_arg Optional argument to pass to the ACL
|
||||
* callback.
|
||||
*/
|
||||
extern void r_ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *evt_cb,
|
||||
void *evt_arg,
|
||||
ble_hci_trans_rx_acl_fn *acl_cb,
|
||||
void *acl_arg);
|
||||
#define ble_hci_trans_cfg_hs r_ble_hci_trans_cfg_hs
|
||||
|
||||
/**
|
||||
* Resets the HCI module to a clean state. Frees all buffers and reinitializes
|
||||
* the underlying transport.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_reset(void);
|
||||
#define ble_hci_trans_reset ble_hci_trans_funcs_ptr->_ble_hci_trans_reset
|
||||
|
||||
void esp_ble_hci_trans_init(uint8_t);
|
||||
|
||||
#else
|
||||
/**
|
||||
* Sends an HCI event from the controller to the host.
|
||||
*
|
||||
* @param cmd The HCI event to send. This buffer must be
|
||||
* allocated via ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int ble_hci_trans_ll_evt_tx(uint8_t *hci_ev);
|
||||
|
||||
/**
|
||||
* Sends ACL data from controller to host.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int ble_hci_trans_ll_acl_tx(struct os_mbuf *om);
|
||||
|
||||
/**
|
||||
* Sends an HCI command from the host to the controller.
|
||||
*
|
||||
* @param cmd The HCI command to send. This buffer must be
|
||||
* allocated via ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
|
||||
|
||||
/**
|
||||
* Sends ACL data from host to controller.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int ble_hci_trans_hs_acl_tx(struct os_mbuf *om);
|
||||
|
||||
/**
|
||||
* Allocates a flat buffer of the specified type.
|
||||
*
|
||||
* @param type The type of buffer to allocate; one of the
|
||||
* BLE_HCI_TRANS_BUF_[...] constants.
|
||||
*
|
||||
* @return The allocated buffer on success;
|
||||
* NULL on buffer exhaustion.
|
||||
*/
|
||||
int esp_ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
|
||||
|
||||
/**
|
||||
* Sends ACL data from host to controller.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int esp_ble_hci_trans_hs_acl_tx(struct os_mbuf *om);
|
||||
|
||||
/**
|
||||
* Allocates a flat buffer of the specified type.
|
||||
*
|
||||
* @param type The type of buffer to allocate; one of the
|
||||
* BLE_HCI_TRANS_BUF_[...] constants.
|
||||
*
|
||||
* @return The allocated buffer on success;
|
||||
* NULL on buffer exhaustion.
|
||||
*/
|
||||
uint8_t *esp_ble_hci_trans_buf_alloc(int type);
|
||||
|
||||
/**
|
||||
* Frees the specified flat buffer. The buffer must have been allocated via
|
||||
* ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @param buf The buffer to free.
|
||||
*/
|
||||
void esp_ble_hci_trans_buf_free(uint8_t *buf);
|
||||
|
||||
/**
|
||||
* Configures the HCI transport to operate with a host. The transport will
|
||||
* execute specified callbacks upon receiving HCI packets from the controller.
|
||||
*
|
||||
* @param evt_cb The callback to execute upon receiving an HCI
|
||||
* event.
|
||||
* @param evt_arg Optional argument to pass to the event
|
||||
* callback.
|
||||
* @param acl_cb The callback to execute upon receiving ACL
|
||||
* data.
|
||||
* @param acl_arg Optional argument to pass to the ACL
|
||||
* callback.
|
||||
*/
|
||||
void esp_ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *evt_cb,
|
||||
void *evt_arg,
|
||||
ble_hci_trans_rx_acl_fn *acl_cb,
|
||||
void *acl_arg);
|
||||
|
||||
/**
|
||||
* Resets the HCI module to a clean state. Frees all buffers and reinitializes
|
||||
* the underlying transport.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int esp_ble_hci_trans_reset(void);
|
||||
#endif
|
||||
struct os_mbuf;
|
||||
|
||||
/* Allocators for supported data types */
|
||||
#if !SOC_ESP_NIMBLE_CONTROLLER
|
||||
void *ble_transport_alloc_cmd(void);
|
||||
void *ble_transport_alloc_evt(int discardable);
|
||||
struct os_mbuf *ble_transport_alloc_acl_from_hs(void);
|
||||
@@ -37,13 +333,15 @@ struct os_mbuf *ble_transport_alloc_acl_from_ll(void);
|
||||
|
||||
/* Generic deallocator for cmd/evt buffers */
|
||||
void ble_transport_free(void *buf);
|
||||
#endif
|
||||
|
||||
/* Register put callback on acl_from_ll mbufs (for ll-hs flow control) */
|
||||
int ble_transport_register_put_acl_from_ll_cb(os_mempool_put_fn *cb);
|
||||
|
||||
/* Send data to hs/ll side */
|
||||
int ble_transport_to_ll_cmd(void *buf);
|
||||
int ble_transport_to_ll_acl(struct os_mbuf *om);
|
||||
#define ble_transport_to_ll_acl ble_hci_trans_hs_acl_tx
|
||||
#define ble_transport_to_ll_cmd ble_hci_trans_hs_cmd_tx
|
||||
|
||||
int ble_transport_to_hs_evt(void *buf);
|
||||
int ble_transport_to_hs_acl(struct os_mbuf *om);
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os/os_mempool.h"
|
||||
#include "syscfg/syscfg.h"
|
||||
|
||||
/* Init functions to be implemented for transport acting as HS/LL side */
|
||||
extern void ble_transport_ll_init(void);
|
||||
extern void ble_transport_hs_init(void);
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
BLE_MBUF_MEMBLOCK_OVERHEAD + \
|
||||
BLE_HCI_DATA_HDR_SZ, OS_ALIGNMENT))
|
||||
|
||||
#if !SOC_ESP_NIMBLE_CONTROLLER
|
||||
static uint8_t pool_cmd_buf[ OS_MEMPOOL_BYTES(POOL_CMD_COUNT, POOL_CMD_SIZE) ];
|
||||
static struct os_mempool pool_cmd;
|
||||
|
||||
@@ -162,6 +163,7 @@ ble_transport_acl_put(struct os_mempool_ext *mpe, void *data, void *arg)
|
||||
do_put = true;
|
||||
from_ll = (pkthdr->omp_flags & OMP_FLAG_FROM_MASK) == OMP_FLAG_FROM_LL;
|
||||
err = 0;
|
||||
from_ll = true;
|
||||
|
||||
if (from_ll && transport_put_acl_from_ll_cb) {
|
||||
err = transport_put_acl_from_ll_cb(mpe, data, arg);
|
||||
@@ -211,6 +213,22 @@ ble_transport_init(void)
|
||||
pool_acl.mpe_put_cb = ble_transport_acl_put;
|
||||
}
|
||||
|
||||
void
|
||||
ble_transport_deinit(void)
|
||||
{
|
||||
int rc = 0;
|
||||
rc = os_mempool_ext_clear(&pool_acl);
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
rc = os_mempool_clear(&pool_evt_lo);
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
rc = os_mempool_clear(&pool_evt);
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
rc = os_mempool_clear(&pool_cmd);
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
}
|
||||
int
|
||||
ble_transport_register_put_acl_from_ll_cb(os_mempool_put_fn (*cb))
|
||||
{
|
||||
@@ -218,3 +236,4 @@ ble_transport_register_put_acl_from_ll_cb(os_mempool_put_fn (*cb))
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include "nimble/ble_hci_trans.h"
|
||||
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@@ -105,9 +104,8 @@ esp_err_t esp_nimble_init(void)
|
||||
/* Initialize the global memory pool */
|
||||
os_mempool_module_init();
|
||||
os_msys_init();
|
||||
/* Initialize transport */
|
||||
ble_transport_init();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* Initialize the host */
|
||||
ble_transport_hs_init();
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ static const char *TAG = "Timer";
|
||||
#define OS_MEM_ALLOC (1)
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
#define BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT)
|
||||
#define BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT)
|
||||
#define BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
|
||||
#define BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
|
||||
#define BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)
|
||||
#define BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user