diff --git a/components/bt/host/nimble/Kconfig.in b/components/bt/host/nimble/Kconfig.in index ddc21f3556..b56b900f3f 100644 --- a/components/bt/host/nimble/Kconfig.in +++ b/components/bt/host/nimble/Kconfig.in @@ -187,6 +187,37 @@ config BT_NIMBLE_HCI_EVT_LO_BUF_COUNT low-priority event buffers, then an incoming advertising report will get dropped +config BT_NIMBLE_HS_FLOW_CTRL + bool "Enable Host Flow control" + depends on BT_NIMBLE_ENABLED + default y + help + Enable Host Flow control + +config BT_NIMBLE_HS_FLOW_CTRL_ITVL + int "Host Flow control interval" + depends on BT_NIMBLE_HS_FLOW_CTRL + default 1000 + help + Host flow control interval in msecs + +config BT_NIMBLE_HS_FLOW_CTRL_THRESH + int "Host Flow control threshold" + depends on BT_NIMBLE_HS_FLOW_CTRL + default 2 + help + Host flow control threshold, if the number of free buffers are at or + below this threshold, send an immediate number-of-completed-packets + event + +config BT_NIMBLE_HS_FLOW_CTRL_TX_ON_DISCONNECT + bool "Host Flow control on disconnect" + depends on BT_NIMBLE_HS_FLOW_CTRL + default y + help + Enable this option to send number-of-completed-packets event to + controller after disconnection + menuconfig BT_NIMBLE_MESH bool "Enable BLE mesh functionality" select BT_NIMBLE_SM_SC diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 4a4be39495..664d3d73bd 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 4a4be394951942cb86b8ed3f779d0c6e733f6e6b +Subproject commit 664d3d73bd4d6f8f57d46d6a1dc5d35429fb6563 diff --git a/components/bt/host/nimble/port/include/esp_nimble_cfg.h b/components/bt/host/nimble/port/include/esp_nimble_cfg.h index 6f163202eb..e74948fe94 100644 --- a/components/bt/host/nimble/port/include/esp_nimble_cfg.h +++ b/components/bt/host/nimble/port/include/esp_nimble_cfg.h @@ -452,19 +452,23 @@ #endif #ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL +#ifdef CONFIG_BT_NIMBLE_HS_FLOW_CTRL +#define MYNEWT_VAL_BLE_HS_FLOW_CTRL (1) +#else #define MYNEWT_VAL_BLE_HS_FLOW_CTRL (0) #endif +#endif #ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL -#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL (1000) +#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL CONFIG_BT_NIMBLE_HS_FLOW_CTRL_ITVL #endif #ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH -#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH (2) +#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH CONFIG_BT_NIMBLE_HS_FLOW_CTRL_THRESH #endif #ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_TX_ON_DISCONNECT -#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_TX_ON_DISCONNECT (0) +#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_TX_ON_DISCONNECT CONFIG_BT_NIMBLE_FLOW_CTRL_TX_ON_DISCONNECT #endif #ifndef MYNEWT_VAL_BLE_HS_PHONY_HCI_ACKS diff --git a/examples/bluetooth/nimble/blecent/main/main.c b/examples/bluetooth/nimble/blecent/main/main.c index be179a0699..604ca3cacf 100644 --- a/examples/bluetooth/nimble/blecent/main/main.c +++ b/examples/bluetooth/nimble/blecent/main/main.c @@ -319,6 +319,7 @@ blecent_should_connect(const struct ble_gap_disc_desc *disc) static void blecent_connect_if_interesting(const struct ble_gap_disc_desc *disc) { + uint8_t own_addr_type; int rc; /* Don't do anything if we don't care about this advertiser. */ @@ -333,16 +334,23 @@ blecent_connect_if_interesting(const struct ble_gap_disc_desc *disc) return; } + /* Figure out address to use for connect (no privacy for now) */ + rc = ble_hs_id_infer_auto(0, &own_addr_type); + if (rc != 0) { + MODLOG_DFLT(ERROR, "error determining address type; rc=%d\n", rc); + return; + } + /* Try to connect the the advertiser. Allow 30 seconds (30000 ms) for * timeout. */ - rc = ble_gap_connect(BLE_OWN_ADDR_PUBLIC, &disc->addr, 30000, NULL, + rc = ble_gap_connect(own_addr_type, &disc->addr, 30000, NULL, blecent_gap_event, NULL); if (rc != 0) { MODLOG_DFLT(ERROR, "Error: Failed to connect to device; addr_type=%d " - "addr=%s\n", - disc->addr.type, addr_str(disc->addr.val)); + "addr=%s; rc=%d\n", + disc->addr.type, addr_str(disc->addr.val), rc); return; } }