Skip to content

Commit

Permalink
Bluetooth: Host: Minor doc and rename for LE remote feature exchange
Browse files Browse the repository at this point in the history
Rename `BT_CONN_AUTO_FEATURE_EXCH` to `BT_CONN_LE_FEATURES_EXCHANGED`,
and add some comments for readability.

Signed-off-by: Aleksander Wasaznik <[email protected]>
  • Loading branch information
alwa-nordic committed Aug 29, 2024
1 parent 874e4e2 commit 0442b49
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2812,7 +2812,7 @@ int bt_conn_get_info(const struct bt_conn *conn, struct bt_conn_info *info)
int bt_conn_get_remote_info(struct bt_conn *conn,
struct bt_conn_remote_info *remote_info)
{
if (!atomic_test_bit(conn->flags, BT_CONN_AUTO_FEATURE_EXCH) ||
if (!atomic_test_bit(conn->flags, BT_CONN_LE_FEATURES_EXCHANGED) ||
(IS_ENABLED(CONFIG_BT_REMOTE_VERSION) &&
!atomic_test_bit(conn->flags, BT_CONN_AUTO_VERSION_INFO))) {
return -EBUSY;
Expand Down
7 changes: 6 additions & 1 deletion subsys/bluetooth/host/conn_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ enum {
BT_CONN_ATT_MTU_EXCHANGED, /* If ATT MTU has been exchanged. */
#endif /* CONFIG_BT_GATT_CLIENT */

BT_CONN_AUTO_FEATURE_EXCH, /* Auto-initiated LE Feat done */
BT_CONN_LE_FEATURES_EXCHANGED, /* bt_conn.le.features is valid */
BT_CONN_AUTO_VERSION_INFO, /* Auto-initiated LE version done */

BT_CONN_CTE_RX_ENABLED, /* CTE receive and sampling is enabled */
Expand Down Expand Up @@ -103,6 +103,11 @@ struct bt_conn_le {
uint8_t conn_param_retry_countdown;
#endif

/** @brief Remote LE features
*
* Available after `atomic_test_bit(conn->flags, BT_CONN_LE_FEATURES_EXCHANGED)`.
* Signaled by bt_conn_cb.remote_info_available().
*/
uint8_t features[8];

struct bt_keys *keys;
Expand Down
5 changes: 3 additions & 2 deletions subsys/bluetooth/host/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ static int hci_le_read_remote_features(struct bt_conn *conn)

cp = net_buf_add(buf, sizeof(*cp));
cp->handle = sys_cpu_to_le16(conn->handle);
/* Results in BT_HCI_EVT_LE_REMOTE_FEAT_COMPLETE */
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_REMOTE_FEATURES, buf, NULL);
}

Expand Down Expand Up @@ -1206,7 +1207,7 @@ static void conn_auto_initiate(struct bt_conn *conn)
return;
}

if (!atomic_test_bit(conn->flags, BT_CONN_AUTO_FEATURE_EXCH) &&
if (!atomic_test_bit(conn->flags, BT_CONN_LE_FEATURES_EXCHANGED) &&
((conn->role == BT_HCI_ROLE_CENTRAL) ||
BT_FEAT_LE_PER_INIT_FEAT_XCHG(bt_dev.le.features))) {
err = hci_le_read_remote_features(conn);
Expand Down Expand Up @@ -1801,7 +1802,7 @@ static void le_remote_feat_complete(struct net_buf *buf)
sizeof(conn->le.features));
}

atomic_set_bit(conn->flags, BT_CONN_AUTO_FEATURE_EXCH);
atomic_set_bit(conn->flags, BT_CONN_LE_FEATURES_EXCHANGED);

if (IS_ENABLED(CONFIG_BT_REMOTE_INFO) &&
!IS_ENABLED(CONFIG_BT_REMOTE_VERSION)) {
Expand Down

0 comments on commit 0442b49

Please sign in to comment.