Skip to content

Commit

Permalink
Merge branch 'bugfix/backport_ble_nimble_fixes_5.2' into 'release/v5.2'
Browse files Browse the repository at this point in the history
fix(nimble) : Bugfix/backport ble nimble fixes 5.2

See merge request espressif/esp-idf!29098
  • Loading branch information
rahult-github committed Feb 19, 2024
2 parents 1c2a671 + d9561b8 commit e094428
Show file tree
Hide file tree
Showing 32 changed files with 1,562 additions and 2,020 deletions.
30 changes: 29 additions & 1 deletion components/bt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ set(ble_mesh_include_dirs

set(bluedroid_include_dirs host/bluedroid/api/include/api)

if(CONFIG_BT_CONTROLLER_ENABLED OR CONFIG_IDF_DOC_BUILD)
set(nimble_hci_include_dirs host/nimble/esp-hci/include)
endif()

if(CONFIG_IDF_DOC_BUILD)
list(APPEND include_dirs
Expand Down Expand Up @@ -567,6 +569,11 @@ if(CONFIG_BT_ENABLED)
"porting/nimble/src/os_msys_init.c"
)

if(CONFIG_BT_CONTROLLER_DISABLED)
list(APPEND srcs
"host/nimble/nimble/porting/nimble/src/hal_uart.c"
)
endif()
list(APPEND include_dirs
porting/include
porting/nimble/include
Expand Down Expand Up @@ -608,6 +615,7 @@ if(CONFIG_BT_ENABLED)
list(APPEND include_dirs

host/nimble/nimble/nimble/host/include
host/nimble/nimble/nimble/include
host/nimble/nimble/nimble/host/services/ans/include
host/nimble/nimble/nimble/host/services/bas/include
host/nimble/nimble/nimble/host/services/dis/include
Expand Down Expand Up @@ -697,6 +705,13 @@ if(CONFIG_BT_ENABLED)
"host/nimble/nimble/nimble/host/src/ble_gattc_cache_conn.c"
)

if(CONFIG_BT_CONTROLLER_DISABLED AND CONFIG_BT_NIMBLE_TRANSPORT_UART)
list(APPEND srcs
"host/nimble/nimble/nimble/transport/uart_ll/src/hci_uart.c"
"host/nimble/nimble/nimble/transport/common/hci_h4/src/hci_h4.c"
)
endif()

list(APPEND srcs
"host/nimble/nimble/porting/nimble/src/nimble_port.c"
"host/nimble/nimble/porting/npl/freertos/src/nimble_port_freertos.c"
Expand All @@ -709,6 +724,12 @@ if(CONFIG_BT_ENABLED)
host/nimble/nimble/nimble/transport/include
)

if(CONFIG_BT_CONTROLLER_DISABLED)
list(APPEND include_dirs
host/nimble/nimble/nimble/transport/common/hci_h4/include
)
endif()

if(NOT CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT)
list(APPEND srcs
"host/nimble/nimble/porting/nimble/src/endian.c"
Expand All @@ -718,14 +739,21 @@ if(CONFIG_BT_ENABLED)
"host/nimble/nimble/porting/nimble/src/os_msys_init.c"
"host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c"
)

if(CONFIG_BT_CONTROLLER_DISABLED AND CONFIG_BT_NIMBLE_TRANSPORT_UART)
list(APPEND srcs
"host/nimble/nimble/porting/nimble/src/hal_uart.c"
)
endif()

list(APPEND include_dirs
host/nimble/nimble/porting/npl/freertos/include
host/nimble/nimble/porting/nimble/include
host/nimble/nimble/nimble/include
)
endif()

if(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE)
if(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE AND CONFIG_BT_CONTROLLER_ENABLED)
list(APPEND srcs
"host/nimble/esp-hci/src/esp_nimble_hci.c"
)
Expand Down
1 change: 0 additions & 1 deletion components/bt/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ menu "Bluetooth"

config BT_NIMBLE_ENABLED
bool "NimBLE - BLE only"
depends on BT_CONTROLLER_ENABLED
help
This option is recommended for BLE only usecases to save on memory

Expand Down
34 changes: 34 additions & 0 deletions components/bt/host/nimble/Kconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@ config BT_NIMBLE_LL_CFG_FEAT_LE_ENCRYPTION
help
Enable encryption connection

config BT_NIMBLE_SM_SC_LVL
int "Security level"
depends on BT_NIMBLE_SECURITY_ENABLE
default 0
help
LE Security Mode 1 Levels:
1. No Security
2. Unauthenticated pairing with encryption
3. Authenticated pairing with encryption
4. Authenticated LE Secure Connections pairing with encryption using a 128-bit strength encryption key.

config BT_NIMBLE_DEBUG
bool "Enable extra runtime asserts and host debugging"
default n
Expand Down Expand Up @@ -915,3 +926,26 @@ config BT_NIMBLE_HOST_QUEUE_CONG_CHECK
When scanning and scan duplicate is not enabled, if there are a lot of adv packets around
or application layer handling adv packets is slow, it will cause the controller memory
to run out. if enabled, adv packets will be lost when host queue is congested.

menu "Host-controller Transport"
config BT_NIMBLE_TRANSPORT_UART
bool "Enable Uart Transport"
default y
depends on BT_CONTROLLER_DISABLED
help
Use UART transport

config BT_NIMBLE_UART_RX_PIN
int "Rx pin for Nimble Uart"
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
default 5
help
Rx pin for Nimble Transport

config BT_NIMBLE_UART_TX_PIN
int "Tx pin for Nimble Uart"
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
default 4
help
Tx pin for Nimble Transport
endmenu
2 changes: 2 additions & 0 deletions components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include "esp_nimble_hci.h"
#include "esp_nimble_mem.h"
#include "bt_osi_mem.h"
#if CONFIG_BT_CONTROLLER_ENABLED
#include "esp_bt.h"
#endif
#include "freertos/semphr.h"
#include "esp_compiler.h"
#include "soc/soc_caps.h"
Expand Down
2 changes: 1 addition & 1 deletion components/bt/host/nimble/nimble
Submodule nimble updated 50 files
+1 −0 nimble/host/include/host/ble_att.h
+25 −0 nimble/host/include/host/ble_esp_gap.h
+126 −0 nimble/host/include/host/ble_gap.h
+258 −0 nimble/host/include/host/ble_gatt.h
+40 −0 nimble/host/include/host/ble_hs_adv.h
+1 −0 nimble/host/include/host/ble_store.h
+1 −0 nimble/host/src/ble_att.c
+89 −0 nimble/host/src/ble_att_clt.c
+14 −0 nimble/host/src/ble_att_cmd_priv.h
+4 −0 nimble/host/src/ble_att_priv.h
+111 −1 nimble/host/src/ble_att_svr.c
+303 −24 nimble/host/src/ble_gap.c
+1 −0 nimble/host/src/ble_gap_priv.h
+14 −0 nimble/host/src/ble_gatt_priv.h
+65 −0 nimble/host/src/ble_gattc.c
+174 −0 nimble/host/src/ble_gatts.c
+2 −2 nimble/host/src/ble_hs.c
+156 −0 nimble/host/src/ble_hs_adv.c
+1 −1 nimble/host/src/ble_hs_flow.c
+16 −2 nimble/host/src/ble_hs_hci.c
+2 −2 nimble/host/src/ble_hs_hci_cmd.c
+41 −1 nimble/host/src/ble_hs_hci_evt.c
+8 −0 nimble/host/src/ble_hs_hci_priv.h
+69 −0 nimble/host/src/ble_hs_hci_util.c
+1 −1 nimble/host/src/ble_hs_resolv.c
+182 −4 nimble/host/src/ble_sm.c
+9 −0 nimble/host/src/ble_sm_priv.h
+10 −0 nimble/host/src/ble_sm_sc.c
+1 −1 nimble/host/store/config/src/ble_store_config.c
+2 −2 nimble/host/util/src/addr.c
+12 −1 nimble/include/nimble/hci_common.h
+4 −0 nimble/include/nimble/nimble_opt_auto.h
+4 −0 nimble/transport/common/hci_h4/src/hci_h4.c
+12 −2 nimble/transport/include/nimble/transport.h
+2 −0 nimble/transport/pkg.yml
+1 −1 nimble/transport/src/transport.c
+1 −0 nimble/transport/syscfg.yml
+32 −0 nimble/transport/uart_ll/pkg.yml
+245 −0 nimble/transport/uart_ll/src/hci_uart.c
+39 −0 nimble/transport/uart_ll/syscfg.yml
+1 −1 porting/nimble/include/hal/hal_uart.h
+2 −2 porting/nimble/include/mem/mem.h
+1 −1 porting/nimble/include/nimble/nimble_port.h
+1 −1 porting/nimble/include/os/endian.h
+1 −1 porting/nimble/include/os/os_mbuf.h
+1 −1 porting/nimble/include/os/os_mempool.h
+132 −345 porting/nimble/src/hal_uart.c
+35 −4 porting/nimble/src/nimble_port.c
+2 −0 porting/npl/freertos/src/nimble_port_freertos.c
+4 −4 porting/npl/freertos/src/npl_os_freertos.c
38 changes: 37 additions & 1 deletion components/bt/host/nimble/port/include/esp_nimble_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@


#ifndef MYNEWT_VAL_BLE_SM_SC_LVL
#define MYNEWT_VAL_BLE_SM_SC_LVL (0)
#define MYNEWT_VAL_BLE_SM_SC_LVL CONFIG_BT_NIMBLE_SM_SC_LVL
#endif

#ifndef MYNEWT_VAL_BLE_SM_SC_ONLY
Expand Down Expand Up @@ -1792,4 +1792,40 @@
#endif
#endif

#if CONFIG_BT_CONTROLLER_DISABLED
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PORT
/* #ifdef CONFIG_BT_NIMBLE_TRANSPORT_UART_PORT */
#define MYNEWT_VAL_BLE_TRANSPORT_UART_PORT /* CONFIG_BT_NIMBLE_TRANSPORT_UART_PORT */ (1)
/* #endif */
#endif

#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY_none
#define MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY_none MYNEWT_VAL_BLE_HCI_UART_PARITY
#endif

#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__odd
#define MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__odd (0)
#endif

#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__even
#define MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__even (0)
#endif

#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_FLOW_CONTROL__rtscts
#define MYNEWT_VAL_BLE_TRANSPORT_UART_FLOW_CONTROL__rtscts (0)
#endif

#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_BAUDRATE
#define MYNEWT_VAL_BLE_TRANSPORT_UART_BAUDRATE (921600)
#endif

#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_DATA_BITS
#define MYNEWT_VAL_BLE_TRANSPORT_UART_DATA_BITS (3)
#endif

#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_STOP_BITS
#define MYNEWT_VAL_BLE_TRANSPORT_UART_STOP_BITS (1)
#endif
#endif

#endif
2 changes: 1 addition & 1 deletion components/bt/porting/include/mem_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
extern "C" {
#endif

#if SOC_ESP_NIMBLE_CONTROLLER
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED

struct os_mempool;
struct os_mbuf_pool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extern "C" {
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
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
#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
Expand Down
Loading

0 comments on commit e094428

Please sign in to comment.