mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Nimble: Migrate to nimble 1.5
This commit is contained in:
parent
ae9713d227
commit
ba1119a725
@ -536,7 +536,8 @@ if(CONFIG_BT_ENABLED)
|
||||
host/nimble/nimble/nimble/host/store/config/include
|
||||
)
|
||||
|
||||
list(APPEND srcs "host/nimble/nimble/nimble/host/util/src/addr.c"
|
||||
list(APPEND srcs "host/nimble/nimble/nimble/transport/src/transport.c"
|
||||
"host/nimble/nimble/nimble/host/util/src/addr.c"
|
||||
"host/nimble/nimble/nimble/host/services/gatt/src/ble_svc_gatt.c"
|
||||
"host/nimble/nimble/nimble/host/services/tps/src/ble_svc_tps.c"
|
||||
"host/nimble/nimble/nimble/host/services/ias/src/ble_svc_ias.c"
|
||||
@ -568,7 +569,6 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/src/ble_store.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_sm_lgcy.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_hs_cfg.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_monitor.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_att_clt.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_l2cap_coc.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_hs_mbuf.c"
|
||||
@ -603,6 +603,7 @@ if(CONFIG_BT_ENABLED)
|
||||
porting/include
|
||||
host/nimble/nimble/porting/nimble/include
|
||||
host/nimble/port/include
|
||||
host/nimble/nimble/nimble/transport/include
|
||||
)
|
||||
|
||||
if(NOT CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT)
|
||||
@ -648,7 +649,10 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/mesh/src/crypto.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/settings.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/adv.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/adv_ext.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/adv_legacy.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/model_srv.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/msg.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/beacon.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/glue.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/model_cli.c"
|
||||
@ -661,7 +665,6 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/mesh/src/light_model.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/health_cli.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/lpn.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/proxy.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/health_srv.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/testing.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/aes-ccm.c"
|
||||
@ -670,11 +673,14 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/mesh/src/cfg.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/pb_adv.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/pb_gatt.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/pb_gatt_srv.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/prov_device.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/provisioner.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/heartbeat.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/rpl.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/subnet.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/proxy_msg.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/proxy_srv.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/net.c")
|
||||
endif()
|
||||
endif()
|
||||
|
@ -7,7 +7,7 @@
|
||||
#ifndef __ESP_NIMBLE_HCI_H__
|
||||
#define __ESP_NIMBLE_HCI_H__
|
||||
|
||||
#include "nimble/ble_hci_trans.h"
|
||||
#include "nimble/transport.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -30,27 +30,16 @@ static void *ble_hci_rx_cmd_hs_arg;
|
||||
static ble_hci_trans_rx_acl_fn *ble_hci_rx_acl_hs_cb;
|
||||
static void *ble_hci_rx_acl_hs_arg;
|
||||
|
||||
static struct os_mbuf_pool ble_hci_acl_mbuf_pool;
|
||||
static struct os_mempool_ext ble_hci_acl_pool;
|
||||
/*
|
||||
* The MBUF payload size must accommodate the HCI data header size plus the
|
||||
* maximum ACL data packet length. The ACL block size is the size of the
|
||||
* mbufs we will allocate.
|
||||
*/
|
||||
#define ACL_BLOCK_SIZE OS_ALIGN(MYNEWT_VAL(BLE_ACL_BUF_SIZE) \
|
||||
#define ACL_BLOCK_SIZE OS_ALIGN(MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE) \
|
||||
+ BLE_MBUF_MEMBLOCK_OVERHEAD \
|
||||
+ BLE_HCI_DATA_HDR_SZ, OS_ALIGNMENT)
|
||||
|
||||
static os_membuf_t *ble_hci_acl_buf;
|
||||
|
||||
static struct os_mempool ble_hci_cmd_pool;
|
||||
static os_membuf_t *ble_hci_cmd_buf;
|
||||
|
||||
static struct os_mempool ble_hci_evt_hi_pool;
|
||||
static os_membuf_t *ble_hci_evt_hi_buf;
|
||||
|
||||
static struct os_mempool ble_hci_evt_lo_pool;
|
||||
static os_membuf_t *ble_hci_evt_lo_buf;
|
||||
|
||||
static SemaphoreHandle_t vhci_send_sem;
|
||||
const static char *TAG = "NimBLE";
|
||||
@ -59,9 +48,9 @@ int os_msys_buf_alloc(void);
|
||||
void os_msys_buf_free(void);
|
||||
|
||||
void ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *cmd_cb,
|
||||
void *cmd_arg,
|
||||
ble_hci_trans_rx_acl_fn *acl_cb,
|
||||
void *acl_arg)
|
||||
void *cmd_arg,
|
||||
ble_hci_trans_rx_acl_fn *acl_cb,
|
||||
void *acl_arg)
|
||||
{
|
||||
ble_hci_rx_cmd_hs_cb = cmd_cb;
|
||||
ble_hci_rx_cmd_hs_arg = cmd_arg;
|
||||
@ -88,7 +77,7 @@ int ble_hci_trans_hs_cmd_tx(uint8_t *cmd)
|
||||
rc = BLE_HS_ETIMEOUT_HCI;
|
||||
}
|
||||
|
||||
ble_hci_trans_buf_free(cmd);
|
||||
ble_transport_free(cmd);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -96,16 +85,14 @@ int ble_hci_trans_ll_evt_tx(uint8_t *hci_ev)
|
||||
{
|
||||
int rc = ESP_FAIL;
|
||||
|
||||
if (ble_hci_rx_cmd_hs_cb) {
|
||||
rc = ble_hci_rx_cmd_hs_cb(hci_ev, ble_hci_rx_cmd_hs_arg);
|
||||
}
|
||||
rc = ble_transport_to_hs_evt((void *)hci_ev);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int ble_hci_trans_hs_acl_tx(struct os_mbuf *om)
|
||||
{
|
||||
uint16_t len = 0;
|
||||
uint8_t data[MYNEWT_VAL(BLE_ACL_BUF_SIZE) + 1], rc = 0;
|
||||
uint8_t data[MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE) + 1], rc = 0;
|
||||
/* If this packet is zero length, just free it */
|
||||
if (OS_MBUF_PKTLEN(om) == 0) {
|
||||
os_mbuf_free_chain(om);
|
||||
@ -136,76 +123,11 @@ int ble_hci_trans_ll_acl_tx(struct os_mbuf *om)
|
||||
{
|
||||
int rc = ESP_FAIL;
|
||||
|
||||
if (ble_hci_rx_acl_hs_cb) {
|
||||
rc = ble_hci_rx_acl_hs_cb(om, ble_hci_rx_acl_hs_arg);
|
||||
}
|
||||
rc = ble_transport_to_hs_acl((void *)om);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint8_t *ble_hci_trans_buf_alloc(int type)
|
||||
{
|
||||
uint8_t *buf;
|
||||
|
||||
switch (type) {
|
||||
case BLE_HCI_TRANS_BUF_CMD:
|
||||
buf = os_memblock_get(&ble_hci_cmd_pool);
|
||||
break;
|
||||
|
||||
case BLE_HCI_TRANS_BUF_EVT_HI:
|
||||
buf = os_memblock_get(&ble_hci_evt_hi_pool);
|
||||
if (buf == NULL) {
|
||||
/* If no high-priority event buffers remain, try to grab a
|
||||
* low-priority one.
|
||||
*/
|
||||
buf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_LO);
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_HCI_TRANS_BUF_EVT_LO:
|
||||
buf = os_memblock_get(&ble_hci_evt_lo_pool);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
buf = NULL;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void ble_hci_trans_buf_free(uint8_t *buf)
|
||||
{
|
||||
int rc;
|
||||
/* XXX: this may look a bit odd, but the controller uses the command
|
||||
* buffer to send back the command complete/status as an immediate
|
||||
* response to the command. This was done to insure that the controller
|
||||
* could always send back one of these events when a command was received.
|
||||
* Thus, we check to see which pool the buffer came from so we can free
|
||||
* it to the appropriate pool
|
||||
*/
|
||||
if (os_memblock_from(&ble_hci_evt_hi_pool, buf)) {
|
||||
rc = os_memblock_put(&ble_hci_evt_hi_pool, buf);
|
||||
assert(rc == 0);
|
||||
} else if (os_memblock_from(&ble_hci_evt_lo_pool, buf)) {
|
||||
rc = os_memblock_put(&ble_hci_evt_lo_pool, buf);
|
||||
assert(rc == 0);
|
||||
} else {
|
||||
assert(os_memblock_from(&ble_hci_cmd_pool, buf));
|
||||
rc = os_memblock_put(&ble_hci_cmd_pool, buf);
|
||||
assert(rc == 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsupported; the RAM transport does not have a dedicated ACL data packet
|
||||
* pool.
|
||||
*/
|
||||
int ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg)
|
||||
{
|
||||
ble_hci_acl_pool.mpe_put_cb = cb;
|
||||
ble_hci_acl_pool.mpe_put_arg = arg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ble_hci_trans_reset(void)
|
||||
{
|
||||
@ -215,39 +137,17 @@ int ble_hci_trans_reset(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a buffer (mbuf) for ACL operation.
|
||||
*
|
||||
* @return The allocated buffer on success;
|
||||
* NULL on buffer exhaustion.
|
||||
*/
|
||||
static struct os_mbuf *ble_hci_trans_acl_buf_alloc(void)
|
||||
{
|
||||
struct os_mbuf *m;
|
||||
uint8_t usrhdr_len;
|
||||
|
||||
#if MYNEWT_VAL(BLE_DEVICE)
|
||||
usrhdr_len = sizeof(struct ble_mbuf_hdr);
|
||||
#elif MYNEWT_VAL(BLE_HS_FLOW_CTRL)
|
||||
usrhdr_len = BLE_MBUF_HS_HDR_LEN;
|
||||
#else
|
||||
usrhdr_len = 0;
|
||||
#endif
|
||||
|
||||
m = os_mbuf_get_pkthdr(&ble_hci_acl_mbuf_pool, usrhdr_len);
|
||||
return m;
|
||||
}
|
||||
|
||||
static void ble_hci_rx_acl(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct os_mbuf *m;
|
||||
int rc;
|
||||
int sr;
|
||||
if (len < BLE_HCI_DATA_HDR_SZ || len > MYNEWT_VAL(BLE_ACL_BUF_SIZE)) {
|
||||
if (len < BLE_HCI_DATA_HDR_SZ || len > MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m = ble_hci_trans_acl_buf_alloc();
|
||||
m = ble_transport_alloc_acl_from_hs();
|
||||
|
||||
if (!m) {
|
||||
ESP_LOGE(TAG, "%s failed to allocate ACL buffers; increase ACL_BUF_COUNT", __func__);
|
||||
@ -259,59 +159,10 @@ static void ble_hci_rx_acl(uint8_t *data, uint16_t len)
|
||||
return;
|
||||
}
|
||||
OS_ENTER_CRITICAL(sr);
|
||||
if (ble_hci_rx_acl_hs_cb) {
|
||||
ble_hci_rx_acl_hs_cb(m, NULL);
|
||||
}
|
||||
ble_transport_to_hs_acl(m);
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
}
|
||||
|
||||
static void ble_hci_transport_init(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* Ensure this function only gets called by sysinit. */
|
||||
SYSINIT_ASSERT_ACTIVE();
|
||||
|
||||
rc = os_mempool_ext_init(&ble_hci_acl_pool,
|
||||
MYNEWT_VAL(BLE_ACL_BUF_COUNT),
|
||||
ACL_BLOCK_SIZE,
|
||||
ble_hci_acl_buf,
|
||||
"ble_hci_acl_pool");
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
rc = os_mbuf_pool_init(&ble_hci_acl_mbuf_pool,
|
||||
&ble_hci_acl_pool.mpe_mp,
|
||||
ACL_BLOCK_SIZE,
|
||||
MYNEWT_VAL(BLE_ACL_BUF_COUNT));
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
/*
|
||||
* Create memory pool of HCI command buffers. NOTE: we currently dont
|
||||
* allow this to be configured. The controller will only allow one
|
||||
* outstanding command. We decided to keep this a pool in case we allow
|
||||
* allow the controller to handle more than one outstanding command.
|
||||
*/
|
||||
rc = os_mempool_init(&ble_hci_cmd_pool,
|
||||
1,
|
||||
BLE_HCI_TRANS_CMD_SZ,
|
||||
ble_hci_cmd_buf,
|
||||
"ble_hci_cmd_pool");
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
rc = os_mempool_init(&ble_hci_evt_hi_pool,
|
||||
MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT),
|
||||
MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE),
|
||||
ble_hci_evt_hi_buf,
|
||||
"ble_hci_evt_hi_pool");
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
|
||||
rc = os_mempool_init(&ble_hci_evt_lo_pool,
|
||||
MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT),
|
||||
MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE),
|
||||
ble_hci_evt_lo_buf,
|
||||
"ble_hci_evt_lo_pool");
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief: BT controller callback function, used to notify the upper layer that
|
||||
@ -329,7 +180,6 @@ static void controller_rcv_pkt_ready(void)
|
||||
*/
|
||||
static int host_rcv_pkt(uint8_t *data, uint16_t len)
|
||||
{
|
||||
|
||||
if (data[0] == BLE_HCI_UART_H4_EVT) {
|
||||
uint8_t *evbuf;
|
||||
int totlen;
|
||||
@ -338,9 +188,9 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len)
|
||||
totlen = BLE_HCI_EVENT_HDR_LEN + data[2];
|
||||
assert(totlen <= UINT8_MAX + BLE_HCI_EVENT_HDR_LEN);
|
||||
|
||||
if (totlen > MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE)) {
|
||||
if (totlen > MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)) {
|
||||
ESP_LOGE(TAG, "Received HCI data length at host (%d) exceeds maximum configured HCI event buffer size (%d).",
|
||||
totlen, MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE));
|
||||
totlen, MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE));
|
||||
ble_hs_sched_reset(BLE_HS_ECONTROLLER);
|
||||
return 0;
|
||||
}
|
||||
@ -351,14 +201,14 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len)
|
||||
|
||||
/* Allocate LE Advertising Report Event from lo pool only */
|
||||
if ((data[1] == BLE_HCI_EVCODE_LE_META) &&
|
||||
(data[3] == BLE_HCI_LE_SUBEV_ADV_RPT || data[3] == BLE_HCI_LE_SUBEV_EXT_ADV_RPT)) {
|
||||
evbuf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_LO);
|
||||
(data[3] == BLE_HCI_LE_SUBEV_ADV_RPT || data[3] == BLE_HCI_LE_SUBEV_EXT_ADV_RPT)) {
|
||||
evbuf = ble_transport_alloc_evt(1);
|
||||
/* Skip advertising report if we're out of memory */
|
||||
if (!evbuf) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
evbuf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI);
|
||||
evbuf = ble_transport_alloc_evt(0);
|
||||
assert(evbuf != NULL);
|
||||
}
|
||||
|
||||
@ -380,15 +230,6 @@ static const esp_vhci_host_callback_t vhci_host_cb = {
|
||||
static void ble_buf_free(void)
|
||||
{
|
||||
os_msys_buf_free();
|
||||
|
||||
nimble_platform_mem_free(ble_hci_evt_hi_buf);
|
||||
ble_hci_evt_hi_buf = NULL;
|
||||
nimble_platform_mem_free(ble_hci_evt_lo_buf);
|
||||
ble_hci_evt_lo_buf = NULL;
|
||||
nimble_platform_mem_free(ble_hci_cmd_buf);
|
||||
ble_hci_cmd_buf = NULL;
|
||||
nimble_platform_mem_free(ble_hci_acl_buf);
|
||||
ble_hci_acl_buf = NULL;
|
||||
}
|
||||
|
||||
static esp_err_t ble_buf_alloc(void)
|
||||
@ -397,28 +238,9 @@ static esp_err_t ble_buf_alloc(void)
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
ble_hci_evt_hi_buf = (os_membuf_t *) nimble_platform_mem_calloc(1,
|
||||
(sizeof(os_membuf_t) * OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT),
|
||||
MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE))));
|
||||
|
||||
ble_hci_evt_lo_buf = (os_membuf_t *) nimble_platform_mem_calloc(1,
|
||||
(sizeof(os_membuf_t) * OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT),
|
||||
MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE))));
|
||||
|
||||
ble_hci_cmd_buf = (os_membuf_t *) nimble_platform_mem_calloc(1,
|
||||
(sizeof(os_membuf_t) * OS_MEMPOOL_SIZE(1, BLE_HCI_TRANS_CMD_SZ)));
|
||||
|
||||
ble_hci_acl_buf = (os_membuf_t *) nimble_platform_mem_calloc(1,
|
||||
(sizeof(os_membuf_t) * OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ACL_BUF_COUNT),
|
||||
ACL_BLOCK_SIZE)));
|
||||
|
||||
if (!ble_hci_evt_hi_buf || !ble_hci_evt_lo_buf || !ble_hci_cmd_buf || !ble_hci_acl_buf) {
|
||||
ble_buf_free();
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
extern void ble_transport_init(void);
|
||||
esp_err_t esp_nimble_hci_init(void)
|
||||
{
|
||||
esp_err_t ret;
|
||||
@ -431,7 +253,7 @@ esp_err_t esp_nimble_hci_init(void)
|
||||
goto err;
|
||||
}
|
||||
|
||||
ble_hci_transport_init();
|
||||
ble_transport_init();
|
||||
|
||||
vhci_send_sem = xSemaphoreCreateBinary();
|
||||
if (vhci_send_sem == NULL) {
|
||||
@ -448,25 +270,7 @@ err:
|
||||
|
||||
}
|
||||
|
||||
static esp_err_t ble_hci_transport_deinit(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret += os_mempool_clear(&ble_hci_evt_lo_pool);
|
||||
|
||||
ret += os_mempool_clear(&ble_hci_evt_hi_pool);
|
||||
|
||||
ret += os_mempool_clear(&ble_hci_cmd_pool);
|
||||
|
||||
ret += os_mempool_ext_clear(&ble_hci_acl_pool);
|
||||
|
||||
if (ret) {
|
||||
return ESP_FAIL;
|
||||
} else {
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
extern void ble_transport_deinit(void);
|
||||
esp_err_t esp_nimble_hci_deinit(void)
|
||||
{
|
||||
if (vhci_send_sem) {
|
||||
@ -476,10 +280,7 @@ esp_err_t esp_nimble_hci_deinit(void)
|
||||
vSemaphoreDelete(vhci_send_sem);
|
||||
vhci_send_sem = NULL;
|
||||
}
|
||||
esp_err_t ret = ble_hci_transport_deinit();
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
ble_transport_deinit();
|
||||
|
||||
ble_buf_free();
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 76b1f54737b7eba79155c5238a797b8865ce8206
|
||||
Subproject commit 86007550e226fd810135558c2aa08acbdc602e95
|
@ -799,6 +799,16 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_SC_LVL
|
||||
#define MYNEWT_VAL_BLE_SM_SC_LVL (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_SC_ONLY
|
||||
#define MYNEWT_VAL_BLE_SM_SC_ONLY (0)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST
|
||||
#define MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST (0)
|
||||
#endif
|
||||
@ -823,6 +833,26 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Value copied from BLE_TRANSPORT_ACL_COUNT */
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_ACL_FROM_LL_COUNT
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_ACL_FROM_LL_COUNT (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_ACL_SIZE
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_ACL_SIZE CONFIG_BT_NIMBLE_ACL_BUF_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_EVT_COUNT
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_EVT_COUNT CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_EVT_DISCARDABLE_COUNT
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_EVT_DISCARDABLE_COUNT CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT
|
||||
#endif
|
||||
|
||||
|
||||
/*** nimble/host/services/ans */
|
||||
#ifndef MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT
|
||||
#define MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT (0)
|
||||
@ -855,6 +885,18 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_ADV_BUF_COUNT (20)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_ADV_EXT
|
||||
#define MYNEWT_VAL_BLE_MESH_ADV_EXT (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_ADV_LEGACY
|
||||
#define MYNEWT_VAL_BLE_MESH_ADV_LEGACY (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_ADV_BUF_COUNT
|
||||
#define MYNEWT_VAL_BLE_MESH_ADV_BUF_COUNT (20)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_APP_KEY_COUNT
|
||||
#define MYNEWT_VAL_BLE_MESH_APP_KEY_COUNT (1)
|
||||
#endif
|
||||
@ -1005,6 +1047,10 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_IVU_DIVIDER (4)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_IV_UPDATE_SEQ_LIMIT
|
||||
#define MYNEWT_VAL_BLE_MESH_IV_UPDATE_SEQ_LIMIT (0x800000)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_IV_UPDATE_TEST
|
||||
#define MYNEWT_VAL_BLE_MESH_IV_UPDATE_TEST (0)
|
||||
#endif
|
||||
@ -1021,6 +1067,10 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_LOG_MOD (9)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_PROXY_MSG_LEN
|
||||
#define MYNEWT_VAL_BLE_MESH_PROXY_MSG_LEN (33)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_LOW_POWER
|
||||
#ifdef CONFIG_BT_NIMBLE_MESH_LOW_POWER
|
||||
#define MYNEWT_VAL_BLE_MESH_LOW_POWER (1)
|
||||
@ -1276,6 +1326,14 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_NETWORK_TRANSMIT_INTERVAL (20)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_NET_BUF_USER_DATA_SIZE
|
||||
#define MYNEWT_VAL_BLE_MESH_NET_BUF_USER_DATA_SIZE (4)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_MODEL_VND_MSG_CID_FORCE
|
||||
#define MYNEWT_VAL_BLE_MESH_MODEL_VND_MSG_CID_FORCE (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_COUNT
|
||||
#define MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_COUNT (2)
|
||||
#endif
|
||||
@ -1292,6 +1350,10 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_GATT_PROXY_ENABLED (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_GATT_SERVER
|
||||
#define MYNEWT_VAL_BLE_MESH_GATT_SERVER (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_FRIEND_ENABLED
|
||||
#define MYNEWT_VAL_BLE_MESH_FRIEND_ENABLED (1)
|
||||
#endif
|
||||
@ -1304,12 +1366,19 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_INTERVAL (20)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_PROV_OOB_PUBLIC_KEY
|
||||
#define MYNEWT_VAL_BLE_MESH_PROV_OOB_PUBLIC_KEY (0)
|
||||
#endif
|
||||
|
||||
/* Overridden by apps/blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_SETTINGS
|
||||
#define MYNEWT_VAL_BLE_MESH_SETTINGS (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_ACCESS_LAYER_MSG
|
||||
#define MYNEWT_VAL_BLE_MESH_ACCESS_LAYER_MSG (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_SETTINGS_LOG_LVL
|
||||
#define MYNEWT_VAL_BLE_MESH_SETTINGS_LOG_LVL (1)
|
||||
#endif
|
||||
@ -1523,39 +1592,29 @@
|
||||
#define MYNEWT_VAL_BLE_HCI_TRANSPORT_SOCKET (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_EVT_SIZE
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_EVT_SIZE CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_ACL_FROM_HS_COUNT
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_ACL_FROM_HS_COUNT CONFIG_BT_NIMBLE_ACL_BUF_COUNT
|
||||
#endif
|
||||
|
||||
|
||||
/* Overridden by targets/porting-nimble (defined by nimble/transport) */
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_TRANSPORT_UART
|
||||
#define MYNEWT_VAL_BLE_HCI_TRANSPORT_UART (1)
|
||||
#endif
|
||||
|
||||
|
||||
/*** nimble/transport/uart */
|
||||
#ifndef MYNEWT_VAL_BLE_ACL_BU24
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_ACL_BUF_COUNT
|
||||
#define MYNEWT_VAL_BLE_ACL_BUF_COUNT CONFIG_BT_NIMBLE_ACL_BUF_COUNT
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_ACL_BUF_SIZE
|
||||
#define MYNEWT_VAL_BLE_ACL_BUF_SIZE CONFIG_BT_NIMBLE_ACL_BUF_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_ACL_OUT_COUNT
|
||||
#define MYNEWT_VAL_BLE_HCI_ACL_OUT_COUNT (20)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_EVT_BUF_SIZE
|
||||
#define MYNEWT_VAL_BLE_HCI_EVT_BUF_SIZE CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_EVT_HI_BUF_COUNT
|
||||
#define MYNEWT_VAL_BLE_HCI_EVT_HI_BUF_COUNT CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_EVT_LO_BUF_COUNT
|
||||
#define MYNEWT_VAL_BLE_HCI_EVT_LO_BUF_COUNT CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT
|
||||
#endif
|
||||
|
||||
/* Overridden by targets/porting-nimble (defined by nimble/transport/uart) */
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_UART_BAUD
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_BAUD (115200)
|
||||
|
@ -32,14 +32,14 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST MYNEWT_VAL(BLE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS MYNEWT_VAL(BLE_MAX_PERIODIC_SYNCS)
|
||||
#define DEFAULT_BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_ACL_BUF_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_ACL_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_HS_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)
|
||||
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)
|
||||
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)
|
||||
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
|
||||
#else
|
||||
|
@ -31,14 +31,14 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST MYNEWT_VAL(BLE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS MYNEWT_VAL(BLE_MAX_PERIODIC_SYNCS)
|
||||
#define DEFAULT_BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_ACL_BUF_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_ACL_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_HS_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)
|
||||
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)
|
||||
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)
|
||||
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||
#else
|
||||
|
@ -33,14 +33,14 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST MYNEWT_VAL(BLE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS MYNEWT_VAL(BLE_MAX_PERIODIC_SYNCS)
|
||||
#define DEFAULT_BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_ACL_BUF_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_ACL_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_HS_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)
|
||||
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)
|
||||
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)
|
||||
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
|
||||
#else
|
||||
|
@ -20,17 +20,14 @@
|
||||
#ifndef H_HCI_TRANSPORT_
|
||||
#define H_HCI_TRANSPORT_
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "os/os_mempool.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct os_mbuf;
|
||||
#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:
|
||||
@ -67,13 +64,17 @@ 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);
|
||||
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;
|
||||
@ -173,9 +174,9 @@ extern int r_ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg);
|
||||
* 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);
|
||||
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
|
||||
|
||||
/**
|
||||
@ -192,9 +193,9 @@ extern void r_ble_hci_trans_cfg_ll(ble_hci_trans_rx_cmd_fn *cmd_cb,
|
||||
* 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);
|
||||
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
|
||||
|
||||
/**
|
||||
@ -208,6 +209,7 @@ 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.
|
||||
@ -260,84 +262,6 @@ int ble_hci_trans_hs_acl_tx(struct os_mbuf *om);
|
||||
* @return The allocated buffer on success;
|
||||
* NULL on buffer exhaustion.
|
||||
*/
|
||||
uint8_t *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 ble_hci_trans_buf_free(uint8_t *buf);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
int ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void 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);
|
||||
|
||||
/**
|
||||
* 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 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 ble_hci_trans_reset(void);
|
||||
|
||||
|
||||
/**
|
||||
* 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 esp_ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
|
||||
|
||||
/**
|
||||
@ -383,9 +307,9 @@ void esp_ble_hci_trans_buf_free(uint8_t *buf);
|
||||
* 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);
|
||||
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
|
||||
@ -395,11 +319,8 @@ void esp_ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *evt_cb,
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int esp_ble_hci_trans_reset(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -28,12 +28,13 @@
|
||||
#define H_BLE_HCI_COMMON_
|
||||
|
||||
#include "ble.h"
|
||||
#include "nimble/transport.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BLE_HCI_MAX_DATA_LEN (MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE) - \
|
||||
#define BLE_HCI_MAX_DATA_LEN (MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE) - \
|
||||
sizeof(struct ble_hci_ev))
|
||||
|
||||
/* Generic command header */
|
||||
@ -1967,8 +1968,7 @@ struct ble_hci_ev_le_subev_subrate_change {
|
||||
#define BLE_HCI_DATA_PB(handle_pb_bc) (((handle_pb_bc) & 0x3000) >> 12)
|
||||
#define BLE_HCI_DATA_BC(handle_pb_bc) (((handle_pb_bc) & 0xc000) >> 14)
|
||||
|
||||
struct hci_data_hdr
|
||||
{
|
||||
struct hci_data_hdr {
|
||||
uint16_t hdh_handle_pb_bc;
|
||||
uint16_t hdh_len;
|
||||
};
|
||||
|
@ -204,9 +204,9 @@ static void gen_onoff_set_unack(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
static const struct bt_mesh_model_op gen_onoff_op[] = {
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x01), 0, gen_onoff_get },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x02), 2, gen_onoff_set },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x03), 2, gen_onoff_set_unack },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x01), 0, (void *)gen_onoff_get },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x02), 2, (void *)gen_onoff_set },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x03), 2, (void *)gen_onoff_set_unack },
|
||||
BT_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
@ -305,13 +305,13 @@ static void gen_move_set_unack(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
static const struct bt_mesh_model_op gen_level_op[] = {
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x05), 0, gen_level_get },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x06), 3, gen_level_set },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x07), 3, gen_level_set_unack },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x09), 5, gen_delta_set },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x0a), 5, gen_delta_set_unack },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x0b), 3, gen_move_set },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x0c), 3, gen_move_set_unack },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x05), 0, (void *)gen_level_get },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x06), 3, (void *)gen_level_set },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x07), 3, (void *)gen_level_set_unack },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x09), 5, (void *)gen_delta_set },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x0a), 5, (void *)gen_delta_set_unack },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x0b), 3, (void *)gen_move_set },
|
||||
{ BT_MESH_MODEL_OP_2(0x82, 0x0c), 3, (void *)gen_move_set_unack },
|
||||
BT_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
@ -347,8 +347,8 @@ static void vnd_model_recv(struct bt_mesh_model *model,
|
||||
os_mbuf_free_chain(msg);
|
||||
}
|
||||
|
||||
static const struct bt_mesh_model_op vnd_model_op[] = {
|
||||
{ BT_MESH_MODEL_OP_3(0x01, CID_VENDOR), 0, vnd_model_recv },
|
||||
static struct bt_mesh_model_op vnd_model_op[] = {
|
||||
{ BT_MESH_MODEL_OP_3(0x01, CID_VENDOR), 0, (void *)vnd_model_recv },
|
||||
BT_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user