From 2a40bf6a87fdae86ee16cbf6f8d58b440e5fc250 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Sat, 6 May 2017 07:08:56 +0200 Subject: [PATCH] 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 --- include/bluetooth/hci.h | 25 ++++++++++++++++--------- subsys/bluetooth/host/conn.c | 2 +- subsys/bluetooth/host/conn_internal.h | 2 +- subsys/bluetooth/host/hci_core.h | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/include/bluetooth/hci.h b/include/bluetooth/hci.h index 924dce13b09..fcdfd4d416c 100644 --- a/include/bluetooth/hci.h +++ b/include/bluetooth/hci.h @@ -189,21 +189,28 @@ struct bt_hci_cmd_hdr { #define BT_LE_FEAT_BIT_PHY_2M 8 #define BT_LE_FEAT_BIT_SMI_TX 9 #define BT_LE_FEAT_BIT_SMI_RX 10 -#define BT_LE_FEAT_BIT_COD_PHY 11 -#define BT_LE_FEAT_BIT_EXT_ADV 12 -#define BT_LE_FEAT_BIT_PER_ADV 13 +#define BT_LE_FEAT_BIT_PHY_CODED 11 +#define BT_LE_FEAT_BIT_ADV_EXT 12 +#define BT_LE_FEAT_BIT_ADV_PER 13 #define BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2 14 #define BT_LE_FEAT_BIT_PWR_CLASS_1 15 #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) -#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) -#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) -#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) +#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 */ #define BT_LE_STATES_SLAVE_CONN_ADV(states) (states & 0x0000004000000000) @@ -964,7 +971,7 @@ struct bt_hci_cp_le_read_phy { } __packed; struct bt_hci_rp_le_read_phy { u8_t status; - u16_t conn_handle; + u16_t handle; u8_t tx_phy; u8_t rx_phy; } __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) struct bt_hci_cp_le_set_phy { - u16_t conn_handle; + u16_t handle; u8_t all_phys; u8_t tx_phys; u8_t rx_phys; diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 0f138765865..3faa835a9e4 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -1671,7 +1671,7 @@ int bt_conn_le_param_update(struct bt_conn *conn, const struct bt_le_conn_param *param) { 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); /* Check if there's a need to update conn params */ diff --git a/subsys/bluetooth/host/conn_internal.h b/subsys/bluetooth/host/conn_internal.h index a2c488fba61..e679d42b9a0 100644 --- a/subsys/bluetooth/host/conn_internal.h +++ b/subsys/bluetooth/host/conn_internal.h @@ -42,7 +42,7 @@ struct bt_conn_le { u16_t latency; u16_t timeout; - u8_t features[1][8]; + u8_t features[8]; struct bt_keys *keys; diff --git a/subsys/bluetooth/host/hci_core.h b/subsys/bluetooth/host/hci_core.h index b987423ca8f..21128eeb5c2 100644 --- a/subsys/bluetooth/host/hci_core.h +++ b/subsys/bluetooth/host/hci_core.h @@ -54,7 +54,7 @@ enum { struct bt_dev_le { /* LE features */ - u8_t features[1][8]; + u8_t features[8]; /* LE states */ u64_t states;