Bluetooth: controller: split: Rework with defines for adv set states
Review rework, added comments, TODOs, FIXMEs and converted magic number use in advertising set state flags to defines. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
322561c6bb
commit
28f4c1b703
12 changed files with 63 additions and 14 deletions
|
@ -1837,20 +1837,36 @@ static void le_set_ext_scan_param(struct net_buf *buf, struct net_buf **evt)
|
|||
phys = cmd->phys;
|
||||
p = cmd->p;
|
||||
|
||||
/* Number of bits set indicate scan sets to be configured by calling
|
||||
* ll_scan_params_set function.
|
||||
*/
|
||||
phys_bitmask = BT_HCI_LE_EXT_SCAN_PHY_1M;
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_PHY_CODED)) {
|
||||
phys_bitmask |= BT_HCI_LE_EXT_SCAN_PHY_CODED;
|
||||
}
|
||||
|
||||
/* Irrespective of enabled PHYs to scan for, ll_scan_params_set needs
|
||||
* to be called to initialise the scan sets.
|
||||
* Passing interval and window as 0, disable the particular scan set
|
||||
* from being enabled.
|
||||
*/
|
||||
do {
|
||||
uint16_t interval;
|
||||
uint16_t window;
|
||||
uint8_t type;
|
||||
uint8_t phy;
|
||||
|
||||
/* Get single PHY bit from the loop bitmask */
|
||||
phy = BIT(find_lsb_set(phys_bitmask) - 1);
|
||||
|
||||
/* Pass the PHY (1M or Coded) of scan set in MSbits of type
|
||||
* parameter
|
||||
*/
|
||||
type = (phy << 1);
|
||||
|
||||
/* If current PHY is one of the PHY in the Scanning_PHYs,
|
||||
* pick the supplied scan type, interval and window.
|
||||
*/
|
||||
if (phys & phy) {
|
||||
type |= (p->type & 0x01);
|
||||
interval = sys_le16_to_cpu(p->interval);
|
||||
|
@ -1890,6 +1906,7 @@ static void le_set_ext_scan_enable(struct net_buf *buf, struct net_buf **evt)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* FIXME: Add implementation to use duration and period parameters. */
|
||||
status = ll_scan_enable(cmd->enable);
|
||||
|
||||
ccst = hci_cmd_complete(evt, sizeof(*ccst));
|
||||
|
@ -1965,7 +1982,7 @@ static void le_ext_create_connection(struct net_buf *buf, struct net_buf **evt)
|
|||
*evt = cmd_status(status);
|
||||
}
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
#endif /* !CONFIG_BT_CTLR_ADV_EXT */
|
||||
#endif /* CONFIG_BT_CTLR_ADV_EXT */
|
||||
|
||||
static int controller_cmd_handle(uint16_t ocf, struct net_buf *cmd,
|
||||
struct net_buf **evt, void **node_rx)
|
||||
|
|
|
@ -55,7 +55,9 @@ uint32_t ll_addr_set(uint8_t addr_type, uint8_t const *const bdaddr)
|
|||
uint32_t status = ull_adv_is_enabled(0);
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_ADV_EXT)
|
||||
if ((status & 5U) == 1U) {
|
||||
if ((status & (ULL_ADV_ENABLED_BITMASK_ENABLED |
|
||||
ULL_ADV_ENABLED_BITMASK_EXTENDED)) ==
|
||||
ULL_ADV_ENABLED_BITMASK_ENABLED) {
|
||||
#else /* !CONFIG_BT_CTLR_ADV_EXT */
|
||||
if (status) {
|
||||
#endif /* !CONFIG_BT_CTLR_ADV_EXT */
|
||||
|
|
|
@ -642,6 +642,9 @@ void ll_rx_dequeue(void)
|
|||
if (IS_ENABLED(CONFIG_BT_CTLR_PRIVACY)) {
|
||||
uint8_t bm;
|
||||
|
||||
/* FIXME: use the correct adv and scan set to get
|
||||
* enabled status bitmask
|
||||
*/
|
||||
bm = (IS_ENABLED(CONFIG_BT_OBSERVER) &&
|
||||
ull_scan_is_enabled(0) << 1) |
|
||||
(IS_ENABLED(CONFIG_BT_BROADCASTER) &&
|
||||
|
|
|
@ -152,12 +152,13 @@ uint8_t ll_adv_params_set(uint16_t interval, uint8_t adv_type,
|
|||
}
|
||||
|
||||
/* Mark the adv set as created by extended advertising cmd */
|
||||
adv->is_created = 3U;
|
||||
adv->is_created = ULL_ADV_CREATED_BITMASK_CREATED |
|
||||
ULL_ADV_CREATED_BITMASK_EXTENDED;
|
||||
} else {
|
||||
adv->lll.phy_p = BIT(0);
|
||||
|
||||
/* Mark the adv set as created by legacy advertising cmd */
|
||||
adv->is_created = 1U;
|
||||
adv->is_created = ULL_ADV_CREATED_BITMASK_CREATED;
|
||||
}
|
||||
#endif /* CONFIG_BT_CTLR_ADV_EXT */
|
||||
|
||||
|
@ -595,7 +596,9 @@ uint8_t ll_adv_enable(uint8_t enable)
|
|||
if (!priv) {
|
||||
uint8_t const *tx_addr;
|
||||
#if defined(CONFIG_BT_CTLR_ADV_EXT)
|
||||
if ((adv->is_created & BIT(1)) && pdu_adv->tx_addr) {
|
||||
if ((adv->is_created &
|
||||
ULL_ADV_CREATED_BITMASK_EXTENDED) &&
|
||||
pdu_adv->tx_addr) {
|
||||
tx_addr = ll_adv_aux_random_addr_get(adv, NULL);
|
||||
} else
|
||||
#endif /* CONFIG_BT_CTLR_ADV_EXT */
|
||||
|
|
|
@ -80,7 +80,6 @@ uint8_t const *ll_adv_aux_random_addr_get(struct ll_adv_set const *const adv,
|
|||
return adv->rnd_addr;
|
||||
}
|
||||
|
||||
#if (CONFIG_BT_CTLR_ADV_AUX_SET > 0)
|
||||
uint8_t ll_adv_aux_ad_data_set(uint8_t handle, uint8_t op, uint8_t frag_pref, uint8_t len,
|
||||
uint8_t const *const data)
|
||||
{
|
||||
|
@ -105,7 +104,8 @@ uint8_t ll_adv_aux_ad_data_set(uint8_t handle, uint8_t op, uint8_t frag_pref, ui
|
|||
*/
|
||||
|
||||
/* TODO: handle other op values */
|
||||
if ((op != 0x03) && (op != 0x04)) {
|
||||
if ((op != BT_HCI_LE_EXT_ADV_OP_COMPLETE_DATA) &&
|
||||
(op != BT_HCI_LE_EXT_ADV_OP_UNCHANGED_DATA)) {
|
||||
/* FIXME: error code */
|
||||
return BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
|
@ -496,7 +496,6 @@ uint16_t ll_adv_aux_max_data_length_get(void)
|
|||
{
|
||||
return CONFIG_BT_CTLR_ADV_DATA_LEN_MAX;
|
||||
}
|
||||
#endif /* (CONFIG_BT_CTLR_ADV_AUX_SET > 0) */
|
||||
|
||||
uint8_t ll_adv_aux_set_count_get(void)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,16 @@
|
|||
|
||||
#define ULL_ADV_RANDOM_DELAY HAL_TICKER_US_TO_TICKS(10000)
|
||||
|
||||
/* Bitmask values used in is_created field of adv set */
|
||||
#define ULL_ADV_CREATED_BITMASK_CREATED BIT(0)
|
||||
#define ULL_ADV_CREATED_BITMASK_EXTENDED BIT(1)
|
||||
|
||||
/* Bitmask value returned by ull_adv_is_enabled() */
|
||||
#define ULL_ADV_ENABLED_BITMASK_ENABLED BIT(0)
|
||||
#define ULL_ADV_ENABLED_BITMASK_CREATED (ULL_ADV_CREATED_BITMASK_CREATED << 1)
|
||||
#define ULL_ADV_ENABLED_BITMASK_EXTENDED (ULL_ADV_CREATED_BITMASK_EXTENDED << 1)
|
||||
|
||||
/* Helper functions to initialise and reset ull_adv module */
|
||||
int ull_adv_init(void);
|
||||
int ull_adv_reset(void);
|
||||
|
||||
|
@ -36,6 +46,7 @@ uint8_t scan_rsp_set(struct ll_adv_set *adv, uint8_t len,
|
|||
uint8_t const *const data);
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_ADV_EXT)
|
||||
/* Helper functions to initialise and reset ull_adv_aux module */
|
||||
int ull_adv_aux_init(void);
|
||||
int ull_adv_aux_reset(void);
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ uint8_t ll_adv_sync_param_set(uint8_t handle, uint16_t interval, uint16_t flags)
|
|||
uint8_t *_pp, *pp, *ps, *_ps;
|
||||
uint8_t ip, is, ad_len;
|
||||
struct lll_adv *lll;
|
||||
int err;
|
||||
|
||||
sync = sync_acquire();
|
||||
if (!sync) {
|
||||
|
@ -94,7 +95,9 @@ uint8_t ll_adv_sync_param_set(uint8_t handle, uint16_t interval, uint16_t flags)
|
|||
/* NOTE: ull_hdr_init(&sync->ull); is done on start */
|
||||
lll_hdr_init(lll_sync, sync);
|
||||
|
||||
util_aa_to_le32(lll_sync->access_addr);
|
||||
err = util_aa_le32(lll_sync->access_addr);
|
||||
LL_ASSERT(!err);
|
||||
|
||||
util_rand(lll_sync->crc_init, sizeof(lll_sync->crc_init));
|
||||
|
||||
lll_sync->latency_prepare = 0;
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
|
||||
#include "util/util.h"
|
||||
|
||||
/* Initial channel map indicating Used and Unused data channels.
|
||||
* The HCI LE Set Host Channel Classification command allows the Host to
|
||||
* specify a channel classification for the data, secondary advertising,
|
||||
* periodic, and isochronous physical channels based on its local information.
|
||||
*/
|
||||
static uint8_t map[5] = {0xFF, 0xFF, 0xFF, 0xFF, 0x1F};
|
||||
static uint8_t count = 37U;
|
||||
|
||||
|
|
|
@ -589,7 +589,8 @@ void ull_filter_adv_pdu_update(struct ll_adv_set *adv, struct pdu_adv *pdu)
|
|||
} else {
|
||||
pdu->tx_addr = adv->own_addr_type & 0x1;
|
||||
#if defined(CONFIG_BT_CTLR_ADV_EXT)
|
||||
if ((adv->is_created & BIT(1)) && pdu->tx_addr) {
|
||||
if ((adv->is_created & ULL_ADV_CREATED_BITMASK_EXTENDED) &&
|
||||
pdu->tx_addr) {
|
||||
ll_adv_aux_random_addr_get(adv, adva);
|
||||
} else
|
||||
#endif /* CONFIG_BT_CTLR_ADV_EXT */
|
||||
|
|
|
@ -145,7 +145,7 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
|
|||
|
||||
conn_lll = &conn->lll;
|
||||
|
||||
err = util_aa_to_le32(conn_lll->access_addr);
|
||||
err = util_aa_le32(conn_lll->access_addr);
|
||||
LL_ASSERT(!err);
|
||||
|
||||
util_rand(conn_lll->crc_init, sizeof(conn_lll->crc_init));
|
||||
|
@ -414,6 +414,10 @@ uint8_t ll_connect_disable(void **rx)
|
|||
return status;
|
||||
}
|
||||
|
||||
/* FIXME: Refactor out this interface so that its usable by extended
|
||||
* advertising channel classification, and also master role connections can
|
||||
* perform channel map update control procedure.
|
||||
*/
|
||||
uint8_t ll_chm_update(uint8_t const *const chm)
|
||||
{
|
||||
uint16_t handle;
|
||||
|
|
|
@ -76,7 +76,7 @@ int util_rand(void *buf, size_t len)
|
|||
* - It shall have no more than eleven transitions in the least significant 16
|
||||
* bits.
|
||||
*/
|
||||
int util_aa_to_le32(uint8_t *dst)
|
||||
int util_aa_le32(uint8_t *dst)
|
||||
{
|
||||
#if defined(CONFIG_BT_CTLR_PHY_CODED)
|
||||
uint8_t transitions_lsb16;
|
||||
|
@ -97,7 +97,8 @@ again:
|
|||
}
|
||||
retry--;
|
||||
|
||||
util_rand((void *)&aa, sizeof(aa));
|
||||
util_rand(dst, sizeof(uint32_t));
|
||||
aa = sys_get_le32(dst);
|
||||
|
||||
bit_idx = 31U;
|
||||
transitions = 0U;
|
||||
|
|
|
@ -17,4 +17,4 @@
|
|||
|
||||
uint8_t util_ones_count_get(uint8_t *octets, uint8_t octets_len);
|
||||
int util_rand(void *buf, size_t len);
|
||||
int util_aa_to_le32(uint8_t *dst);
|
||||
int util_aa_le32(uint8_t *dst);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue