From e0cd316049ca99be9de6ad0035733685d300229c Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Wed, 3 Nov 2021 21:13:10 +0530 Subject: [PATCH] Bluetooth: Controller: Fix missing ll_adv_cmds_set Fix to include ll_adv_cmds_set when broadcast role is not enabled in the Controller but advertising extensions is enabled (Extended Scanning is used). Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/hci/hci.c | 28 +++++++++++++++++++ subsys/bluetooth/controller/include/ll.h | 14 ---------- .../controller/ll_sw/ull_adv_internal.h | 8 ++++++ 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index d9a39760d9..6667a7f500 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -206,6 +206,34 @@ static uint64_t le_event_mask = DEFAULT_LE_EVENT_MASK; static struct net_buf *cmd_complete_status(uint8_t status); #if defined(CONFIG_BT_CTLR_ADV_EXT) +#if defined(CONFIG_BT_HCI_RAW) +static uint8_t ll_adv_cmds; + +__weak int ll_adv_cmds_set(uint8_t adv_cmds) +{ + if (!ll_adv_cmds) { + ll_adv_cmds = adv_cmds; + } + + if (ll_adv_cmds != adv_cmds) { + return -EINVAL; + } + + return 0; +} + +__weak int ll_adv_cmds_is_ext(void) +{ + return ll_adv_cmds == LL_ADV_CMDS_EXT; +} + +#else /* !CONFIG_BT_HCI_RAW */ +__weak int ll_adv_cmds_is_ext(void) +{ + return 1; +} +#endif /* !CONFIG_BT_HCI_RAW */ + static int adv_cmds_legacy_check(struct net_buf **cc_evt) { int err; diff --git a/subsys/bluetooth/controller/include/ll.h b/subsys/bluetooth/controller/include/ll.h index d31e050c20..2ac3979ad1 100644 --- a/subsys/bluetooth/controller/include/ll.h +++ b/subsys/bluetooth/controller/include/ll.h @@ -5,10 +5,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define LL_ADV_CMDS_ANY 0 /* Any advertising cmd/evt allowed */ -#define LL_ADV_CMDS_LEGACY 1 /* Only legacy advertising cmd/evt allowed */ -#define LL_ADV_CMDS_EXT 2 /* Only extended advertising cmd/evt allowed */ - int ll_init(struct k_sem *sem_rx); void ll_reset(void); @@ -62,16 +58,6 @@ static inline uint8_t ll_adv_iso_by_hci_handle_new(uint8_t hci_handle, #endif #if defined(CONFIG_BT_CTLR_ADV_EXT) -#if defined(CONFIG_BT_HCI_RAW) -int ll_adv_cmds_set(uint8_t adv_cmds); -int ll_adv_cmds_is_ext(void); -#else -static inline int ll_adv_cmds_is_ext(void) -{ - return 1; -} -#endif /* CONFIG_BT_HCI_RAW */ - uint8_t ll_adv_params_set(uint8_t handle, uint16_t evt_prop, uint32_t interval, uint8_t adv_type, uint8_t own_addr_type, uint8_t direct_addr_type, uint8_t const *const direct_addr, diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_internal.h b/subsys/bluetooth/controller/ll_sw/ull_adv_internal.h index a815ee175c..0c770eabd5 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_internal.h +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_internal.h @@ -9,6 +9,14 @@ /* Bitmask value returned by ull_adv_is_enabled() */ #define ULL_ADV_ENABLED_BITMASK_ENABLED BIT(0) +/* Helper defined to check if Extended Advertising HCI commands used */ +#define LL_ADV_CMDS_ANY 0 /* Any advertising cmd/evt allowed */ +#define LL_ADV_CMDS_LEGACY 1 /* Only legacy advertising cmd/evt allowed */ +#define LL_ADV_CMDS_EXT 2 /* Only extended advertising cmd/evt allowed */ + +/* Helper function to check if Extended Advertising HCI commands used */ +int ll_adv_cmds_is_ext(void); + /* Helper functions to initialise and reset ull_adv module */ int ull_adv_init(void); int ull_adv_reset(void);