Skip to content

Commit 58d2ce1

Browse files
Tryton77rlubos
authored andcommitted
samples: bluetooth: Disable legacy pairing
Removed legacy pairing option from the following samples: - central_nrf_pairing - peripheral_power_profiling Leaved legacy pairing in peripherial_nfc_pairing sample for compatibility with older Android devices. JIRA: NCSDK-35217 Signed-off-by: Michał Strządała <[email protected]>
1 parent d5f1e22 commit 58d2ce1

File tree

7 files changed

+13
-69
lines changed

7 files changed

+13
-69
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,13 @@ Bluetooth samples
307307
* :ref:`peripheral_status`
308308
* :ref:`peripheral_uart`
309309

310+
* Disabled legacy pairing in the following samples:
311+
312+
* :ref:`central_nfc_pairing`
313+
* :ref:`power_profiling`
314+
315+
Support for legacy pairing remains exclusively for :ref:`peripheral_nfc_pairing` sample to retain compatibility with older Andorid devices.
316+
310317
* :ref:`direct_test_mode` sample:
311318

312319
* Updated by simplifying the 2-wire UART polling.

samples/bluetooth/central_nfc_pairing/README.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ The sample supports pairing in one of the following modes:
1717

1818
* LE Secure Connections Just Works pairing
1919
* LE Secure Connections OOB pairing
20-
* Legacy OOB pairing
21-
* Legacy Just Works pairing
2220
* Negotiated Handover (TNEP protocol) - two-way OOB pairing
2321

2422
Requirements

samples/bluetooth/central_nfc_pairing/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CONFIG_NCS_SAMPLES_DEFAULTS=y
1010
CONFIG_BT=y
1111
CONFIG_BT_CENTRAL=y
1212
CONFIG_BT_SMP=y
13-
CONFIG_BT_SMP_SC_PAIR_ONLY=n
13+
CONFIG_BT_SMP_SC_PAIR_ONLY=y
1414
CONFIG_BT_GATT_CLIENT=y
1515

1616
# Enable the BLE modules from NCS

samples/bluetooth/central_nfc_pairing/src/main.c

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,10 @@
3636
static struct k_poll_signal pair_signal;
3737
static struct k_poll_event events[K_POOL_EVENTS_CNT];
3838

39-
static bool use_remote_tk;
4039
static struct bt_le_oob oob_local;
41-
static uint8_t tk_value[NFC_NDEF_LE_OOB_REC_TK_LEN];
42-
static uint8_t remote_tk_value[NFC_NDEF_LE_OOB_REC_TK_LEN];
4340
static struct bt_le_oob oob_remote;
4441
static struct bt_conn *default_conn;
4542

46-
static int tk_value_generate(void)
47-
{
48-
int err;
49-
50-
err = bt_rand(tk_value, sizeof(tk_value));
51-
if (err) {
52-
printk("Random TK value generation failed: %d\n", err);
53-
}
54-
55-
return err;
56-
}
57-
5843
static void pair_key_generate_init(void)
5944
{
6045
k_poll_signal_init(&pair_signal);
@@ -74,7 +59,7 @@ static int paring_key_generate(void)
7459
printk("Error while fetching local OOB data: %d\n", err);
7560
}
7661

77-
return tk_value_generate();
62+
return err;
7863
}
7964

8065
static void paring_key_process(void)
@@ -268,31 +253,13 @@ static void lesc_oob_data_set(struct bt_conn *conn,
268253
}
269254
}
270255

271-
static void legacy_tk_value_set(struct bt_conn *conn)
272-
{
273-
int err;
274-
const uint8_t *tk = use_remote_tk ? remote_tk_value : tk_value;
275-
276-
err = bt_le_oob_set_legacy_tk(conn, tk);
277-
if (err) {
278-
printk("TK value set error: %d\n", err);
279-
}
280-
281-
use_remote_tk = false;
282-
}
283-
284256
static void auth_oob_data_request(struct bt_conn *conn,
285257
struct bt_conn_oob_info *info)
286258
{
287259
if (info->type == BT_CONN_OOB_LE_SC) {
288260
printk("LESC OOB data requested\n");
289261
lesc_oob_data_set(conn, info);
290262
}
291-
292-
if (info->type == BT_CONN_OOB_LE_LEGACY) {
293-
printk("Legacy TK value requested\n");
294-
legacy_tk_value_set(conn);
295-
}
296263
}
297264

298265
static void auth_cancel(struct bt_conn *conn)
@@ -315,7 +282,6 @@ static void pairing_complete(struct bt_conn *conn, bool bonded)
315282

316283
k_poll_signal_raise(&pair_signal, 0);
317284
bt_le_oob_set_sc_flag(false);
318-
bt_le_oob_set_legacy_flag(false);
319285
}
320286

321287

@@ -330,7 +296,6 @@ static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
330296

331297
k_poll_signal_raise(&pair_signal, 0);
332298
bt_le_oob_set_sc_flag(false);
333-
bt_le_oob_set_legacy_flag(false);
334299
}
335300

336301
static struct bt_conn_auth_cb conn_auth_callbacks = {
@@ -419,12 +384,6 @@ static int oob_le_data_handle(const struct nfc_ndef_record_desc *rec,
419384
bt_addr_le_copy(&oob_remote.addr, oob->addr);
420385
}
421386

422-
if (oob->tk_value) {
423-
bt_le_oob_set_legacy_flag(true);
424-
memcpy(remote_tk_value, oob->tk_value, sizeof(remote_tk_value));
425-
use_remote_tk = request;
426-
}
427-
428387
/* Remove all scanning filters. */
429388
bt_scan_filter_remove_all();
430389

@@ -453,7 +412,6 @@ static int carrier_prepare(void)
453412

454413
rec_payload.addr = &oob_local.addr;
455414
rec_payload.le_sc_data = &oob_local.le_sc_data;
456-
rec_payload.tk_value = tk_value;
457415
rec_payload.local_name = bt_get_name();
458416
rec_payload.le_role = NFC_NDEF_LE_OOB_REC_LE_ROLE(
459417
NFC_NDEF_LE_OOB_REC_LE_ROLE_CENTRAL_ONLY);

samples/bluetooth/peripheral_nfc_pairing/prj.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ CONFIG_NFC_TNEP_CH=y
2525
CONFIG_BT=y
2626
CONFIG_BT_SMP=y
2727
CONFIG_BT_SMP_APP_PAIRING_ACCEPT=y
28+
29+
# Keep support for legacy pairing to retain compatibility
30+
# with older Andorid phones that may not support OOB SC pairing
2831
CONFIG_BT_SMP_SC_PAIR_ONLY=n
2932
CONFIG_BT_PERIPHERAL=y
3033
CONFIG_BT_DEVICE_NAME="Nordic_NFC_pairing"

samples/bluetooth/peripheral_power_profiling/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
CONFIG_BT=y
88
CONFIG_BT_SMP=y
9-
CONFIG_BT_SMP_SC_PAIR_ONLY=n
9+
CONFIG_BT_SMP_SC_PAIR_ONLY=y
1010
CONFIG_BT_PERIPHERAL=y
1111
CONFIG_BT_DEVICE_NAME="Nordic_Power_Profiling"
1212
CONFIG_BT_EXT_ADV=y

samples/bluetooth/peripheral_power_profiling/src/main.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161

6262

6363
static struct bt_le_oob oob_local;
64-
static uint8_t tk_local[NFC_NDEF_LE_OOB_REC_TK_LEN];
6564
#if !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED)
6665
static uint8_t nfc_buffer[NFC_BUFFER_SIZE];
6766
static void adv_work_handler(struct k_work *work);
@@ -269,16 +268,6 @@ static void auth_cancel(struct bt_conn *conn)
269268
printk("Pairing cancelled: %s\n", addr);
270269
}
271270

272-
static void legacy_tk_value_set(struct bt_conn *conn)
273-
{
274-
int err;
275-
276-
err = bt_le_oob_set_legacy_tk(conn, tk_local);
277-
if (err) {
278-
printk("Failed to set local TK (err %d)\n", err);
279-
}
280-
}
281-
282271
static void lesc_oob_data_set(struct bt_conn *conn, struct bt_conn_oob_info *info)
283272
{
284273
int err;
@@ -315,11 +304,6 @@ static void oob_data_request(struct bt_conn *conn, struct bt_conn_oob_info *info
315304
printk("LESC OOB data requested\n");
316305
lesc_oob_data_set(conn, info);
317306
}
318-
319-
if (info->type == BT_CONN_OOB_LE_LEGACY) {
320-
printk("Legacy TK value requested\n");
321-
legacy_tk_value_set(conn);
322-
}
323307
}
324308

325309
static const struct bt_conn_auth_cb conn_auth_callbacks = {
@@ -479,11 +463,6 @@ static int pairing_key_generate(void)
479463
return err;
480464
}
481465

482-
err = bt_rand(tk_local, sizeof(tk_local));
483-
if (err) {
484-
printk("Failed to generate random TK value (err %d)\n", err);
485-
}
486-
487466
return err;
488467
}
489468

@@ -593,7 +572,6 @@ static int nfc_oob_data_setup(size_t *size)
593572
NFC_NDEF_LE_OOB_REC_LE_ROLE(NFC_NDEF_LE_OOB_REC_LE_ROLE_PERIPH_ONLY);
594573
oob_rec_payload.le_sc_data = &oob_local.le_sc_data;
595574
oob_rec_payload.local_name = bt_get_name();
596-
oob_rec_payload.tk_value = tk_local;
597575

598576
ch_msg_records.ac = &NFC_NDEF_CH_AC_RECORD_DESC(ac_rec);
599577
ch_msg_records.carrier = &NFC_NDEF_LE_OOB_RECORD_DESC(oob_rec);

0 commit comments

Comments
 (0)