Bluetooth: Add LE Features test macro

Added HCI macros to check LE Features. Also, added test
macros for 2M and Coded PHY support in HCI Controller.

Earlier a common test macro was used between BR/EDR and LE,
but since LE features do not use pages for feature, an
explicit macro for testing LE feature is added now.

Also, features field in LE device structure is now a single
dimension array of 8 octets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2017-05-06 07:08:56 +02:00 committed by Johan Hedberg
commit 2a40bf6a87
4 changed files with 19 additions and 12 deletions

View file

@ -189,21 +189,28 @@ struct bt_hci_cmd_hdr {
#define BT_LE_FEAT_BIT_PHY_2M 8 #define BT_LE_FEAT_BIT_PHY_2M 8
#define BT_LE_FEAT_BIT_SMI_TX 9 #define BT_LE_FEAT_BIT_SMI_TX 9
#define BT_LE_FEAT_BIT_SMI_RX 10 #define BT_LE_FEAT_BIT_SMI_RX 10
#define BT_LE_FEAT_BIT_COD_PHY 11 #define BT_LE_FEAT_BIT_PHY_CODED 11
#define BT_LE_FEAT_BIT_EXT_ADV 12 #define BT_LE_FEAT_BIT_ADV_EXT 12
#define BT_LE_FEAT_BIT_PER_ADV 13 #define BT_LE_FEAT_BIT_ADV_PER 13
#define BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2 14 #define BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2 14
#define BT_LE_FEAT_BIT_PWR_CLASS_1 15 #define BT_LE_FEAT_BIT_PWR_CLASS_1 15
#define BT_LE_FEAT_BIT_MIN_USED_CHAN_PROC 16 #define BT_LE_FEAT_BIT_MIN_USED_CHAN_PROC 16
#define BT_FEAT_LE_ENCR(feat) BT_FEAT_TEST(feat, 0, 0, \ #define BT_LE_FEAT_TEST(feat, n) (feat[(n) >> 3] & \
BIT((n) & 7))
#define BT_FEAT_LE_ENCR(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_ENC) BT_LE_FEAT_BIT_ENC)
#define BT_FEAT_LE_CONN_PARAM_REQ_PROC(feat) BT_FEAT_TEST(feat, 0, 0, \ #define BT_FEAT_LE_CONN_PARAM_REQ_PROC(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CONN_PARAM_REQ) BT_LE_FEAT_BIT_CONN_PARAM_REQ)
#define BT_FEAT_LE_SLAVE_FEATURE_XCHG(feat) BT_FEAT_TEST(feat, 0, 0, \ #define BT_FEAT_LE_SLAVE_FEATURE_XCHG(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_SLAVE_FEAT_REQ) BT_LE_FEAT_BIT_SLAVE_FEAT_REQ)
#define BT_FEAT_LE_DLE(feat) BT_FEAT_TEST(feat, 0, 0, \ #define BT_FEAT_LE_DLE(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_DLE) BT_LE_FEAT_BIT_DLE)
#define BT_FEAT_LE_PHY_2M(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PHY_2M)
#define BT_FEAT_LE_PHY_CODED(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PHY_CODED)
/* LE States */ /* LE States */
#define BT_LE_STATES_SLAVE_CONN_ADV(states) (states & 0x0000004000000000) #define BT_LE_STATES_SLAVE_CONN_ADV(states) (states & 0x0000004000000000)
@ -964,7 +971,7 @@ struct bt_hci_cp_le_read_phy {
} __packed; } __packed;
struct bt_hci_rp_le_read_phy { struct bt_hci_rp_le_read_phy {
u8_t status; u8_t status;
u16_t conn_handle; u16_t handle;
u8_t tx_phy; u8_t tx_phy;
u8_t rx_phy; u8_t rx_phy;
} __packed; } __packed;
@ -989,7 +996,7 @@ struct bt_hci_cp_le_set_default_phy {
#define BT_HCI_OP_LE_SET_PHY BT_OP(BT_OGF_LE, 0x0032) #define BT_HCI_OP_LE_SET_PHY BT_OP(BT_OGF_LE, 0x0032)
struct bt_hci_cp_le_set_phy { struct bt_hci_cp_le_set_phy {
u16_t conn_handle; u16_t handle;
u8_t all_phys; u8_t all_phys;
u8_t tx_phys; u8_t tx_phys;
u8_t rx_phys; u8_t rx_phys;

View file

@ -1671,7 +1671,7 @@ int bt_conn_le_param_update(struct bt_conn *conn,
const struct bt_le_conn_param *param) const struct bt_le_conn_param *param)
{ {
BT_DBG("conn %p features 0x%02x params (%d-%d %d %d)", conn, BT_DBG("conn %p features 0x%02x params (%d-%d %d %d)", conn,
conn->le.features[0][0], param->interval_min, conn->le.features[0], param->interval_min,
param->interval_max, param->latency, param->timeout); param->interval_max, param->latency, param->timeout);
/* Check if there's a need to update conn params */ /* Check if there's a need to update conn params */

View file

@ -42,7 +42,7 @@ struct bt_conn_le {
u16_t latency; u16_t latency;
u16_t timeout; u16_t timeout;
u8_t features[1][8]; u8_t features[8];
struct bt_keys *keys; struct bt_keys *keys;

View file

@ -54,7 +54,7 @@ enum {
struct bt_dev_le { struct bt_dev_le {
/* LE features */ /* LE features */
u8_t features[1][8]; u8_t features[8];
/* LE states */ /* LE states */
u64_t states; u64_t states;