Skip to content

Commit 2999999

Browse files
sample: bluetooth: mesh: start using BT_APP_PASSKEY
BT_FIXED_PASSKEY is deprecated, thus we start using BT_APP_PASSKEY Signed-off-by: alperen sener <[email protected]>
1 parent 7476d7c commit 2999999

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

samples/bluetooth/mesh/common/smp_bt_auth.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,22 @@ static void pairing_confirm(struct bt_conn *conn)
4747
printk("Pairing confirmed: %s\n", addr);
4848
}
4949

50+
#if defined(CONFIG_BT_APP_PASSKEY)
51+
static uint32_t app_passkey(struct bt_conn *conn)
52+
{
53+
return bt_mesh_le_pair_resp_passkey_get();
54+
}
55+
#endif /* CONFIG_BT_APP_PASSKEY */
56+
5057
static struct bt_conn_auth_cb auth_cb = {
5158
/* Enable passkey_display callback to enable the display capability. */
5259
.passkey_display = passkey_display,
5360
/* These 2 callbacks are required for passkey_display callback. */
5461
.cancel = cancel,
5562
.pairing_confirm = pairing_confirm,
63+
#if defined(CONFIG_BT_APP_PASSKEY)
64+
.app_passkey = app_passkey,
65+
#endif /* CONFIG_BT_APP_PASSKEY */
5666
};
5767

5868
static void pairing_complete(struct bt_conn *conn, bool bonded)
@@ -63,8 +73,10 @@ static void pairing_complete(struct bt_conn *conn, bool bonded)
6373

6474
printk("Pairing completed: %s, bonded: %d\n", addr, bonded);
6575

76+
#if defined(CONFIG_BT_FIXED_PASSKEY)
6677
/* Invalidate the previously used passkey. */
6778
bt_mesh_le_pair_resp_passkey_invalidate();
79+
#endif /* CONFIG_BT_FIXED_PASSKEY */
6880
}
6981

7082
static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
@@ -75,8 +87,10 @@ static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
7587

7688
printk("Pairing failed: %s, reason %d\n", addr, reason);
7789

90+
#if defined(CONFIG_BT_FIXED_PASSKEY)
7891
/* Invalidate the previously used passkey. */
7992
bt_mesh_le_pair_resp_passkey_invalidate();
93+
#endif /* CONFIG_BT_FIXED_PASSKEY */
8094
}
8195

8296
static struct bt_conn_auth_info_cb conn_auth_info_callbacks = {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN=y
22
CONFIG_BT_SMP=y
3-
CONFIG_BT_FIXED_PASSKEY=y
3+
CONFIG_BT_APP_PASSKEY=y
44
CONFIG_BT_MESH_LE_PAIR_RESP=y
55
CONFIG_BT_SMP_SC_ONLY=y
66
CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=n

0 commit comments

Comments
 (0)