Skip to content

Commit d5160f6

Browse files
lylezhu2012aescolar
authored andcommitted
Bluetooth: BR: Improve bt_conn_set_bondable
In current, the bondable flag cannot be configured for each specific BR connection. But for LE conn, there is a function `bt_conn_set_bondable` for this purpose. Improve `bt_conn_set_bondable` to support BR conn. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
1 parent e772c45 commit d5160f6

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

subsys/bluetooth/host/classic/br.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ void bt_hci_conn_complete(struct net_buf *buf)
240240

241241
bt_conn_set_state(conn, BT_CONN_CONNECTED);
242242

243+
atomic_set_bit_to(conn->flags, BT_CONN_BR_BONDABLE, bt_get_bondable());
244+
243245
bt_conn_connected(conn);
244246

245247
bt_conn_unref(conn);

subsys/bluetooth/host/classic/ssp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ void bt_hci_io_capa_req(struct net_buf *buf)
693693
auth = ssp_get_auth(conn);
694694
}
695695

696-
if (!bt_get_bondable()) {
696+
if (!atomic_test_bit(conn->flags, BT_CONN_BR_BONDABLE)) {
697697
/* If bondable is false, clear bonding flag. */
698698
auth = BT_HCI_SET_NO_BONDING(auth);
699699
}

subsys/bluetooth/host/conn_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ enum {
5757
*/
5858
BT_CONN_AUTO_CONNECT,
5959
BT_CONN_BR_LEGACY_SECURE, /* 16 digits legacy PIN tracker */
60+
BT_CONN_BR_BONDABLE, /* BR connection is bondable */
6061
BT_CONN_USER, /* user I/O when pairing */
6162
BT_CONN_BR_PAIRING, /* BR connection in pairing context */
6263
BT_CONN_BR_PAIRED, /* BR connection pairing is done */

subsys/bluetooth/host/smp.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5447,6 +5447,16 @@ int bt_conn_set_bondable(struct bt_conn *conn, bool enable)
54475447
{
54485448
struct bt_smp *smp;
54495449

5450+
if (IS_ENABLED(CONFIG_BT_CLASSIC) && (conn->type == BT_CONN_TYPE_BR)) {
5451+
if (enable && atomic_test_and_set_bit(conn->flags, BT_CONN_BR_BONDABLE)) {
5452+
return -EALREADY;
5453+
}
5454+
if (!enable && !atomic_test_and_clear_bit(conn->flags, BT_CONN_BR_BONDABLE)) {
5455+
return -EALREADY;
5456+
}
5457+
return 0;
5458+
}
5459+
54505460
smp = smp_chan_get(conn);
54515461
if (!smp) {
54525462
return -EINVAL;

0 commit comments

Comments
 (0)