From 2d71f640332b7d0aecb051c0147e2cc3c86ee329 Mon Sep 17 00:00:00 2001 From: SumeetSingh19 Date: Thu, 18 Jan 2024 17:05:52 +0530 Subject: [PATCH 1/5] fix(nimble): allow auto connection and observer role --- components/bt/host/nimble/Kconfig.in | 11 +++++++++++ components/bt/host/nimble/nimble | 2 +- .../bt/host/nimble/port/include/esp_nimble_cfg.h | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/components/bt/host/nimble/Kconfig.in b/components/bt/host/nimble/Kconfig.in index df2c193d84..e1fde4d0d3 100644 --- a/components/bt/host/nimble/Kconfig.in +++ b/components/bt/host/nimble/Kconfig.in @@ -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 diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 0eed0eb2f4..f9adf083d8 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 0eed0eb2f41d79209f7a36f58b90530e133bc605 +Subproject commit f9adf083d8d3c81c86ae1094d0d4450862fa4b04 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 8942eeb506..49b93c870b 100644 --- a/components/bt/host/nimble/port/include/esp_nimble_cfg.h +++ b/components/bt/host/nimble/port/include/esp_nimble_cfg.h @@ -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 From 7bda1db4f89b5ee84cf8fbbf57a90b233b7f6fab Mon Sep 17 00:00:00 2001 From: SumeetSingh19 Date: Thu, 18 Jan 2024 17:07:05 +0530 Subject: [PATCH 2/5] feat(nimble): authorization permission on gatt read and write --- components/bt/host/nimble/nimble | 2 +- examples/bluetooth/nimble/bleprph/main/main.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index f9adf083d8..8c93324990 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit f9adf083d8d3c81c86ae1094d0d4450862fa4b04 +Subproject commit 8c93324990e26af4ae7f80118adf895dd1b0e3e5 diff --git a/examples/bluetooth/nimble/bleprph/main/main.c b/examples/bluetooth/nimble/bleprph/main/main.c index e91811dce0..d86364c41c 100644 --- a/examples/bluetooth/nimble/bleprph/main/main.c +++ b/examples/bluetooth/nimble/bleprph/main/main.c @@ -393,6 +393,16 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg) } return 0; + case BLE_GAP_EVENT_AUTHORIZE: + MODLOG_DFLT(INFO, "authorize event: conn_handle=%d attr_handle=%d is_read=%d", + event->authorize.conn_handle, + event->authorize.attr_handle, + event->authorize.is_read); + + /* The default behaviour for the event is to reject authorize request */ + event->authorize.out_response = BLE_GAP_AUTHORIZE_REJECT; + return 0; + #if MYNEWT_VAL(BLE_POWER_CONTROL) case BLE_GAP_EVENT_TRANSMIT_POWER: MODLOG_DFLT(INFO, "Transmit power event : status=%d conn_handle=%d reason=%d " From 7ad6df977ecab3251c94ee7ee0a28de56482070d Mon Sep 17 00:00:00 2001 From: SumeetSingh19 Date: Thu, 25 Jan 2024 18:22:03 +0530 Subject: [PATCH 3/5] feat(nimble): additional AD types for advertisements --- components/bt/host/nimble/nimble | 2 +- .../nimble/common/nimble_central_utils/misc.c | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 8c93324990..bb736f15dc 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 8c93324990e26af4ae7f80118adf895dd1b0e3e5 +Subproject commit bb736f15dc981b21762a86d3197736bddda1dfc6 diff --git a/examples/bluetooth/nimble/common/nimble_central_utils/misc.c b/examples/bluetooth/nimble/common/nimble_central_utils/misc.c index e901adde92..44dfade97b 100644 --- a/examples/bluetooth/nimble/common/nimble_central_utils/misc.c +++ b/examples/bluetooth/nimble/common/nimble_central_utils/misc.c @@ -169,6 +169,43 @@ print_adv_fields(const struct ble_hs_adv_fields *fields) MODLOG_DFLT(DEBUG, "\n"); } + if (fields->sm_tk_value_is_present) { + MODLOG_DFLT(DEBUG, " sm_tk_value="); + print_bytes(fields->sm_tk_value, 16); + MODLOG_DFLT(DEBUG, "\n"); + } + + if (fields->sm_oob_flag_is_present) { + MODLOG_DFLT(DEBUG, " sm_oob_flag=%d\n", fields->sm_oob_flag); + } + + if (fields->sol_uuids16 != NULL) { + MODLOG_DFLT(DEBUG, " sol_uuids16="); + for (i = 0; i < fields->sol_num_uuids16; i++) { + print_uuid(&fields->sol_uuids16[i].u); + MODLOG_DFLT(DEBUG, " "); + } + MODLOG_DFLT(DEBUG, "\n"); + } + + if (fields->sol_uuids32 != NULL) { + MODLOG_DFLT(DEBUG, " sol_uuids32="); + for (i = 0; i < fields->sol_num_uuids32; i++) { + print_uuid(&fields->sol_uuids32[i].u); + MODLOG_DFLT(DEBUG, "\n"); + } + MODLOG_DFLT(DEBUG, "\n"); + } + + if (fields->sol_uuids128 != NULL) { + MODLOG_DFLT(DEBUG, " sol_uuids128="); + for (i = 0; i < fields->sol_num_uuids128; i++) { + print_uuid(&fields->sol_uuids128[i].u); + MODLOG_DFLT(DEBUG, " "); + } + MODLOG_DFLT(DEBUG, "\n"); + } + if (fields->svc_data_uuid16 != NULL) { MODLOG_DFLT(DEBUG, " svc_data_uuid16="); print_bytes(fields->svc_data_uuid16, fields->svc_data_uuid16_len); @@ -185,6 +222,16 @@ print_adv_fields(const struct ble_hs_adv_fields *fields) MODLOG_DFLT(DEBUG, "\n"); } + if (fields->random_tgt_addr != NULL) { + MODLOG_DFLT(DEBUG, " random_tgt_addr="); + u8p = fields->random_tgt_addr; + for (i = 0; i < fields->num_random_tgt_addrs; i++) { + MODLOG_DFLT(DEBUG, "random_tgt_addr=%s ", addr_str(u8p)); + u8p += BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN; + } + MODLOG_DFLT(DEBUG, "\n"); + } + if (fields->appearance_is_present) { MODLOG_DFLT(DEBUG, " appearance=0x%04x\n", fields->appearance); } @@ -193,6 +240,19 @@ print_adv_fields(const struct ble_hs_adv_fields *fields) MODLOG_DFLT(DEBUG, " adv_itvl=0x%04x\n", fields->adv_itvl); } + if (fields->device_addr_is_present) { + MODLOG_DFLT(DEBUG, " device_addr="); + u8p = fields->device_addr; + MODLOG_DFLT(DEBUG, "%s ", addr_str(u8p)); + + u8p += BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN; + MODLOG_DFLT(DEBUG, "addr_type %d ", *u8p); + } + + if (fields->le_role_is_present) { + MODLOG_DFLT(DEBUG, " le_role=%d\n", fields->le_role); + } + if (fields->svc_data_uuid32 != NULL) { MODLOG_DFLT(DEBUG, " svc_data_uuid32="); print_bytes(fields->svc_data_uuid32, fields->svc_data_uuid32_len); From 0bd83017559832ae95df66b32a8fa3e4ee395abf Mon Sep 17 00:00:00 2001 From: SumeetSingh19 Date: Mon, 22 Jan 2024 12:43:44 +0530 Subject: [PATCH 4/5] feat(nimble): signed write support --- components/bt/host/nimble/nimble | 2 +- components/bt/porting/nimble/include/nimble/nimble_opt_auto.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index bb736f15dc..e6c502f259 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit bb736f15dc981b21762a86d3197736bddda1dfc6 +Subproject commit e6c502f259812a6d09064fb684e3b56195c80341 diff --git a/components/bt/porting/nimble/include/nimble/nimble_opt_auto.h b/components/bt/porting/nimble/include/nimble/nimble_opt_auto.h index 7aeafcc321..daf2153348 100644 --- a/components/bt/porting/nimble/include/nimble/nimble_opt_auto.h +++ b/components/bt/porting/nimble/include/nimble/nimble_opt_auto.h @@ -92,6 +92,10 @@ extern "C" { #define NIMBLE_BLE_ATT_CLT_WRITE \ (MYNEWT_VAL(BLE_GATT_WRITE)) +#undef NIMBLE_BLE_ATT_CLT_SIGNED_WRITE +#define NIMBLE_BLE_ATT_CLT_SIGNED_WRITE \ + (MYNEWT_VAL(BLE_GATT_SIGNED_WRITE)) + #undef NIMBLE_BLE_ATT_CLT_WRITE_NO_RSP #define NIMBLE_BLE_ATT_CLT_WRITE_NO_RSP \ (MYNEWT_VAL(BLE_GATT_WRITE_NO_RSP)) From 92d20f6708ccfe43098e66cab023ba9de2e2bb02 Mon Sep 17 00:00:00 2001 From: SumeetSingh19 Date: Thu, 25 Jan 2024 18:25:40 +0530 Subject: [PATCH 5/5] feat(nimble): client presentation and aggregate format descriptor support --- components/bt/host/nimble/nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index e6c502f259..0273e0e83a 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit e6c502f259812a6d09064fb684e3b56195c80341 +Subproject commit 0273e0e83a05559809c317e41fa4fd88a244620e