Skip to content

Commit aa4b946

Browse files
HaavardReim-alperen-sener
authored andcommitted
[nrf fromtree] Bluetooth: Host: shell: Don't use BT_FIXED_PASSKEY
Updates the bt shell API to use the new Kconfig option BT_APP_PASSKEY instead of BT_FIXED_PASSKEY as this is being deprecated. Signed-off-by: Håvard Reierstad <[email protected]> (cherry picked from commit b6252b5) Signed-off-by: alperen sener <[email protected]>
1 parent 5f3e93d commit aa4b946

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

subsys/bluetooth/host/shell/bt.c

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4421,6 +4421,15 @@ static void br_bond_deleted(const bt_addr_t *peer)
44214421
}
44224422
#endif /* CONFIG_BT_CLASSIC */
44234423

4424+
#if defined(CONFIG_BT_APP_PASSKEY)
4425+
static uint32_t app_passkey = BT_PASSKEY_RAND;
4426+
4427+
static uint32_t auth_app_passkey(struct bt_conn *conn)
4428+
{
4429+
return app_passkey;
4430+
}
4431+
#endif /* CONFIG_BT_APP_PASSKEY */
4432+
44244433
static struct bt_conn_auth_cb auth_cb_display = {
44254434
.passkey_display = auth_passkey_display,
44264435
#if defined(CONFIG_BT_PASSKEY_KEYPRESS)
@@ -4437,6 +4446,9 @@ static struct bt_conn_auth_cb auth_cb_display = {
44374446
#if defined(CONFIG_BT_SMP_APP_PAIRING_ACCEPT)
44384447
.pairing_accept = pairing_accept,
44394448
#endif
4449+
#if defined(CONFIG_BT_APP_PASSKEY)
4450+
.app_passkey = auth_app_passkey,
4451+
#endif
44404452
};
44414453

44424454
static struct bt_conn_auth_cb auth_cb_display_yes_no = {
@@ -4445,6 +4457,9 @@ static struct bt_conn_auth_cb auth_cb_display_yes_no = {
44454457
.passkey_confirm = auth_passkey_confirm,
44464458
#if defined(CONFIG_BT_CLASSIC)
44474459
.pincode_entry = auth_pincode_entry,
4460+
#endif
4461+
#if defined(CONFIG_BT_APP_PASSKEY)
4462+
.app_passkey = auth_app_passkey,
44484463
#endif
44494464
.oob_data_request = NULL,
44504465
.cancel = auth_cancel,
@@ -4460,6 +4475,9 @@ static struct bt_conn_auth_cb auth_cb_input = {
44604475
.passkey_confirm = NULL,
44614476
#if defined(CONFIG_BT_CLASSIC)
44624477
.pincode_entry = auth_pincode_entry,
4478+
#endif
4479+
#if defined(CONFIG_BT_APP_PASSKEY)
4480+
.app_passkey = auth_app_passkey,
44634481
#endif
44644482
.oob_data_request = NULL,
44654483
.cancel = auth_cancel,
@@ -4472,6 +4490,9 @@ static struct bt_conn_auth_cb auth_cb_input = {
44724490
static struct bt_conn_auth_cb auth_cb_confirm = {
44734491
#if defined(CONFIG_BT_CLASSIC)
44744492
.pincode_entry = auth_pincode_entry,
4493+
#endif
4494+
#if defined(CONFIG_BT_APP_PASSKEY)
4495+
.app_passkey = auth_app_passkey,
44754496
#endif
44764497
.oob_data_request = NULL,
44774498
.cancel = auth_cancel,
@@ -4487,6 +4508,9 @@ static struct bt_conn_auth_cb auth_cb_all = {
44874508
.passkey_confirm = auth_passkey_confirm,
44884509
#if defined(CONFIG_BT_CLASSIC)
44894510
.pincode_entry = auth_pincode_entry,
4511+
#endif
4512+
#if defined(CONFIG_BT_APP_PASSKEY)
4513+
.app_passkey = auth_app_passkey,
44904514
#endif
44914515
.oob_data_request = auth_pairing_oob_data_request,
44924516
.cancel = auth_cancel,
@@ -4703,16 +4727,15 @@ static int cmd_fal_connect(const struct shell *sh, size_t argc, char *argv[])
47034727
#endif /* CONFIG_BT_CENTRAL */
47044728
#endif /* defined(CONFIG_BT_FILTER_ACCEPT_LIST) */
47054729

4706-
#if defined(CONFIG_BT_FIXED_PASSKEY)
4707-
static int cmd_fixed_passkey(const struct shell *sh,
4708-
size_t argc, char *argv[])
4730+
#if defined(CONFIG_BT_APP_PASSKEY)
4731+
static int cmd_app_passkey(const struct shell *sh,
4732+
size_t argc, char *argv[])
47094733
{
4710-
unsigned int passkey;
4711-
int err;
4734+
uint32_t passkey;
47124735

47134736
if (argc < 2) {
4714-
bt_passkey_set(BT_PASSKEY_INVALID);
4715-
shell_print(sh, "Fixed passkey cleared");
4737+
app_passkey = BT_PASSKEY_RAND;
4738+
shell_print(sh, "App passkey cleared");
47164739
return 0;
47174740
}
47184741

@@ -4722,14 +4745,12 @@ static int cmd_fixed_passkey(const struct shell *sh,
47224745
return -ENOEXEC;
47234746
}
47244747

4725-
err = bt_passkey_set(passkey);
4726-
if (err) {
4727-
shell_print(sh, "Setting fixed passkey failed (err %d)", err);
4728-
}
4748+
app_passkey = passkey;
4749+
shell_print(sh, "App passkey set to %06u", passkey);
47294750

4730-
return err;
4751+
return 0;
47314752
}
4732-
#endif
4753+
#endif /* CONFIG_BT_APP_PASSKEY */
47334754

47344755
static int cmd_auth_passkey(const struct shell *sh,
47354756
size_t argc, char *argv[])
@@ -5340,10 +5361,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds,
53405361
cmd_fal_connect, 2, 3),
53415362
#endif /* CONFIG_BT_CENTRAL */
53425363
#endif /* defined(CONFIG_BT_FILTER_ACCEPT_LIST) */
5343-
#if defined(CONFIG_BT_FIXED_PASSKEY)
5344-
SHELL_CMD_ARG(fixed-passkey, NULL, "[passkey]", cmd_fixed_passkey,
5364+
#if defined(CONFIG_BT_APP_PASSKEY)
5365+
SHELL_CMD_ARG(app-passkey, NULL, "[passkey]", cmd_app_passkey,
53455366
1, 1),
5346-
#endif
5367+
#endif /* CONFIG_BT_APP_PASSKEY */
53475368
#endif /* CONFIG_BT_SMP || CONFIG_BT_CLASSIC) */
53485369
#endif /* CONFIG_BT_CONN */
53495370

tests/bluetooth/shell/audio.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CONFIG_BT_GATT_AUTO_DISCOVER_CCC=y
2222
CONFIG_BT_GATT_AUTO_UPDATE_MTU=y
2323
CONFIG_BT_L2CAP_ECRED=y
2424
CONFIG_BT_SIGNING=y
25-
CONFIG_BT_FIXED_PASSKEY=y
25+
CONFIG_BT_APP_PASSKEY=y
2626
CONFIG_BT_ATT_PREPARE_COUNT=5
2727
CONFIG_BT_SHELL=y
2828
CONFIG_BT_DEVICE_NAME="audio test shell"

tests/bluetooth/shell/log.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CONFIG_BT_PERIPHERAL=y
99
CONFIG_BT_PRIVACY=y
1010
CONFIG_BT_SMP=y
1111
CONFIG_BT_SIGNING=y
12-
CONFIG_BT_FIXED_PASSKEY=y
12+
CONFIG_BT_APP_PASSKEY=y
1313
CONFIG_BT_ATT_PREPARE_COUNT=2
1414
CONFIG_BT_GATT_CLIENT=y
1515
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y

tests/bluetooth/shell/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CONFIG_BT_PRIVACY=y
1111
CONFIG_BT_SMP=y
1212
CONFIG_BT_PASSKEY_KEYPRESS=y
1313
CONFIG_BT_SIGNING=y
14-
CONFIG_BT_FIXED_PASSKEY=y
14+
CONFIG_BT_APP_PASSKEY=y
1515
CONFIG_BT_ATT_PREPARE_COUNT=2
1616
CONFIG_BT_GATT_CLIENT=y
1717
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y

0 commit comments

Comments
 (0)