From 9dafd9f7786ed381a37b3dced0154af19add5907 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Thu, 13 Jul 2023 12:08:03 +0530 Subject: [PATCH] feat(mesh): Add support for Duplicate Exception list update VSC for Nimble --- components/bt/esp_ble_mesh/Kconfig.in | 1 - .../mesh_core/nimble_host/mesh_bearer_adapt.c | 42 +++++++++++++++++-- components/bt/host/nimble/nimble | 2 +- .../nimble/include/nimble/hci_common.h | 6 +++ 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/components/bt/esp_ble_mesh/Kconfig.in b/components/bt/esp_ble_mesh/Kconfig.in index 714c476b8e..807f1a4fe3 100644 --- a/components/bt/esp_ble_mesh/Kconfig.in +++ b/components/bt/esp_ble_mesh/Kconfig.in @@ -8,7 +8,6 @@ if BLE_MESH config BLE_MESH_USE_DUPLICATE_SCAN bool "Support Duplicate Scan in BLE Mesh" - depends on BT_BLUEDROID_ENABLED select BTDM_BLE_SCAN_DUPL if IDF_TARGET_ESP32 select BTDM_BLE_MESH_SCAN_DUPL_EN if IDF_TARGET_ESP32 select BT_CTRL_BLE_SCAN_DUPL if IDF_TARGET_ESP32C3 diff --git a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c index 96dedbeb5d..be3a11595d 100644 --- a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c @@ -1,7 +1,7 @@ /* * SPDX-FileCopyrightText: 2017 Nordic Semiconductor ASA * SPDX-FileCopyrightText: 2015-2016 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1943,9 +1943,43 @@ int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], } #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) -int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info) +int bt_mesh_update_exceptional_list(uint8_t sub_code, uint32_t type, void *info) { - BT_ERR("Unsupported for NimBLE host"); - return 0; + uint8_t value[6] = {0}; + int rc = 0; + +#if MYNEWT_VAL(BLE_HCI_VS) + struct ble_hci_vs_duplicate_exception_list_cp cmd; +#endif + + if ((sub_code > BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN) || + (sub_code < BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN && + type > BLE_MESH_EXCEP_LIST_TYPE_MESH_PROXY_ADV) || + (sub_code == BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN && + !(type & BLE_MESH_EXCEP_LIST_CLEAN_ALL_LIST))) { + BT_ERR("%s, Invalid parameter", __func__); + return -EINVAL; + } + + if (type == BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID) { + if (!info) { + BT_ERR("Invalid Provisioning Link ID"); + return -EINVAL; + } + sys_memcpy_swap(value, info, sizeof(uint32_t)); + } + + BT_DBG("%s exceptional list, type 0x%08x", sub_code ? "Remove" : "Add", type); + +#if MYNEWT_VAL(BLE_HCI_VS) + cmd.operation = sub_code; + cmd.type = htole32(type); + memcpy(&cmd.device_info, value, 6); + + rc = ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_DUPLICATE_EXCEPTION_LIST, + &cmd, sizeof(cmd), NULL, 0); +#endif + + return rc; } #endif diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 159f6a9861..5598e60293 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 159f6a98619fbde8ac08f20a485a3253afa98529 +Subproject commit 5598e602932722970448625cfbd85f2744e1ea55 diff --git a/components/bt/porting/nimble/include/nimble/hci_common.h b/components/bt/porting/nimble/include/nimble/hci_common.h index cb743efac1..b9791ca721 100644 --- a/components/bt/porting/nimble/include/nimble/hci_common.h +++ b/components/bt/porting/nimble/include/nimble/hci_common.h @@ -1136,6 +1136,12 @@ struct ble_hci_vs_rd_static_addr_rp { uint8_t addr[6]; } __attribute__((packed)); +#define BLE_HCI_OCF_VS_DUPLICATE_EXCEPTION_LIST (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0108)) +struct ble_hci_vs_duplicate_exception_list_cp { + uint8_t operation; + uint32_t type; + uint8_t device_info[6]; +} __attribute__((packed)); #if SOC_BLE_POWER_CONTROL_SUPPORTED && MYNEWT_VAL(BLE_HCI_VS) #define BLE_HCI_OCF_VS_PCL_SET_RSSI (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0111))