zephyr/tests/bluetooth/controller/common/include/helper_features.h
Andries Kruithof f023b5f611 Bluetooth: controller: push topic branch to main
Pushes all work done in the topic-ble-llcp branch into main branch
This is a refactoring of the LL control procedures; the refactored
control procedures are hidden behind a KConfig option and
per default disabled

Goal of the refactoring:

close issue Link Layer Control Procedure overhaul #15256
make it easier to add/update control procedures
Refactoring consists in principal of writing explicit state machines
for the control procedures.
To reduce the risk of regression errors unit-tests have been added

Following control procedures are implemented:

Connection update procedure
Channel map update procedure
Encryption procedure
Feature exchange procedure
Version exchange procedure
ACL termination procedure
Connection parameters request procedure
LE Ping procedure
Data Length Update procedure
PHY update procedure
Min. nr. Of channels used procedure
Constant Tone extension request procedure

This is a joined work by the people listed in the signed-off-by
list (in alphabetical order)

Signed-off-by: Andries Kruithof Andries.Kruithof@nordicsemi.no
Signed-off-by: Erik Brockhoff erbr@oticon.com
Signed-off-by: Piotr Pryga piotr.pryga@nordicsemi.no
Signed-off-by: Szymon Janc szymon.janc@codecoup.pl
Signed-off-by: Thomas Ebert Hansen thoh@oticon.com
Signed-off-by: Tommie Skriver tosk@demant.com

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2021-11-16 21:24:37 -05:00

250 lines
5.4 KiB
C

/*
* Copyright (c) 2020 Nordic Semiconductor ASA
* Copyright (c) 2020 Demant
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* expected features on purpose defined here
* to keep implementation separate from test
*/
#if defined(CONFIG_BT_CTLR_LE_ENC)
#define FEAT_ENCODED 0x01
#else
#define FEAT_ENCODED 0x00
#endif
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
#define FEAT_PARAM_REQ 0x02
#else
#define FEAT_PARAM_REQ 0x00
#endif
#if defined(CONFIG_BT_CTLR_EXT_REJ_IND)
#define FEAT_EXT_REJ 0x04
#else
#define FEAT_EXT_REJ 0x00
#endif
#if defined(CONFIG_BT_CTLR_PER_INIT_FEAT_XCHG)
#define FEAT_SLAVE_FREQ 0x08
#else
#define FEAT_SLAVE_FREQ 0x00
#endif
#if defined(CONFIG_BT_CTLR_LE_PING)
#define FEAT_PING 0x10
#else
#define FEAT_PING 0x00
#endif
#if defined(CONFIG_BT_CTLR_DATA_LENGTH_MAX)
#define FEAT_DLE 0x20
#else
#define FEAT_DLE 0x00
#endif
#if defined(CONFIG_BT_CTLR_PRIVACY)
#define FEAT_PRIVACY 0x40
#else
#define FEAT_PRIVACY 0x00
#endif
#if defined(CONFIG_BT_CTLR_EXT_SCAN_FP)
#define FEAT_EXT_SCAN 0x80
#else
#define FEAT_EXT_SCAN 0x00
#endif
#if defined(CONFIG_BT_CTLR_PHY_2M)
#define FEAT_PHY_2M 0x100
#else
#define FEAT_PHY_2M 0x00
#endif
#if defined(CONFIG_BT_CTLR_SMI_TX)
#define FEAT_SMI_TX 0x200
#else
#define FEAT_SMI_TX 0x00
#endif
#if defined(CONFIG_BT_CTLR_SMI_RX)
#define FEAT_SMI_RX 0x400
#else
#define FEAT_SMI_RX 0x00
#endif
#if defined(CONFIG_BT_CTLR_PHY_CODED)
#define FEAT_PHY_CODED 0x800
#else
#define FEAT_PHY_CODED 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_EXT_ADV 0x1000
#else
#define FEAT_EXT_ADV 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_PER_ADV 0x2000
#else
#define FEAT_PER_ADV 0x00
#endif
#if defined(CONFIG_BT_CTLR_CHAN_SEL_2)
#define FEAT_CHAN_SEL_ALGO2 0x4000
#else
#define FEAT_CHAN_SEL_ALGO2 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_PWR_CLASS1 0x8000
#else
#define FEAT_PWR_CLASS1 0x00
#endif
#if defined(CONFIG_BT_CTLR_MIN_USED_CHAN)
#define FEAT_MIN_CHANN 0x10000
#else
#define FEAT_MIN_CHANN 0x00
#endif
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ)
#define FEAT_CONNECTION_CTE_REQ 0x20000
#else
#define FEAT_CONNECTION_CTE_REQ 0x00
#endif
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP)
#define FEAT_CONNECTION_CTE_RSP 0x40000
#else
#define FEAT_CONNECTION_CTE_RSP 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_CONNECTIONLESS_CTE_TX 0x80000
#else
#define FEAT_CONNECTIONLESS_CTE_TX 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_CONNECTIONLESS_CTE_RX 0x100000
#else
#define FEAT_CONNECTIONLESS_CTE_RX 0x00
#endif
#if defined(CONFIG_BT_CTLR_DF_ANT_SWITCH_TX)
#define FEAT_ANT_SWITCH_CTE_TX 0x200000
#else
#define FEAT_ANT_SWITCH_CTE_TX 0x00
#endif
#if defined(CONFIG_BT_CTLR_DF_ANT_SWITCH_RX)
#define FEAT_ANT_SWITCH_CTE_RX 0x400000
#else
#define FEAT_ANT_SWITCH_CTE_RX 0x00
#endif
#if defined(CONFIG_BT_CTLR_DF_CTE_RX)
#define FEAT_RX_CTE 0x800000
#else
#define FEAT_RX_CTE 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_PER_ADV_SYNC_TX 0x1000000
#else
#define FEAT_PER_ADV_SYNC_TX 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_PER_ADV_SYNC_RX 0x2000000
#else
#define FEAT_PER_ADV_SYNC_RX 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_SLEEP_UPD 0x4000000
#else
#define FEAT_SLEEP_UPD 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_RPK_VALID 0x8000000
#else
#define FEAT_RPK_VALID 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_ISO_MASTER 0x10000000
#else
#define FEAT_ISO_MASTER 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_ISO_SLAVE 0x20000000
#else
#define FEAT_ISO_SLAVE 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_ISO_BROADCAST 0x40000000
#else
#define FEAT_ISO_BROADCAST 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_ISO_RECEIVER 0x80000000
#else
#define FEAT_ISO_RECEIVER 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_ISO_CHANNELS 0x100000000
#else
#define FEAT_ISO_CHANNELS 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_LE_PWR_REQ 0x200000000
#else
#define FEAT_LE_PWR_REQ 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_LE_PWR_IND 0x400000000
#else
#define FEAT_LE_PWR_IND 0x00
#endif
#if defined(CONFIG_MISSING)
#define FEAT_LE_PATH_LOSS 0x800000000
#else
#define FEAT_LE_PATH_LOSS 0x00
#endif
#define DEFAULT_FEATURE \
(FEAT_ENCODED | FEAT_PARAM_REQ | FEAT_EXT_REJ | FEAT_SLAVE_FREQ | FEAT_PING | FEAT_DLE | \
FEAT_PRIVACY | FEAT_EXT_SCAN | FEAT_PHY_2M | FEAT_SMI_TX | FEAT_SMI_RX | FEAT_PHY_CODED | \
FEAT_EXT_ADV | FEAT_PER_ADV | FEAT_CHAN_SEL_ALGO2 | FEAT_PWR_CLASS1 | FEAT_MIN_CHANN | \
FEAT_CONNECTION_CTE_REQ | FEAT_CONNECTION_CTE_RSP | FEAT_ANT_SWITCH_CTE_TX | \
FEAT_ANT_SWITCH_CTE_RX | FEAT_RX_CTE | FEAT_PER_ADV_SYNC_TX | FEAT_PER_ADV_SYNC_RX | \
FEAT_SLEEP_UPD | FEAT_RPK_VALID | FEAT_ISO_MASTER | FEAT_ISO_SLAVE | FEAT_ISO_BROADCAST | \
FEAT_ISO_RECEIVER | FEAT_ISO_CHANNELS | FEAT_LE_PWR_REQ | FEAT_LE_PWR_IND | \
FEAT_LE_PATH_LOSS)
/*
* The following two are defined as per
* Core Spec V5.2 Volume 6, Part B, chapter 4.6
* LL_FEAT_BIT_MASK_VALID does not account for the bits
* for the new features in V5.2
* TODO: EXPECTED_FEAT_EXCH_VALID is not used at the moment
* but probably LL_FEAT_BIT_MASK_VALID should get this
* value in ll_feat.h
*/
#define EXPECTED_FEAT_EXCH_VALID 0x0000000FF787CF2F
#define FEAT_FILTER_OCTET0 0xFFFFFFFFFFFFFF00
#define COMMON_FEAT_OCTET0(x) (FEAT_FILTER_OCTET0 | ((x) & ~FEAT_FILTER_OCTET0))