Skip to content

Commit fed5561

Browse files
kedMertenskartben
authored andcommitted
bluetooth: tester: btp: refactors OOB legacy selection
Takes in use IS_ENABLED as preferred way of guarding Kconfig option for forcing OOB legacy, CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY. It enables compiling guarded code get warning/errors and not link it if not used. If def macro is left in btp_handler structure to reduce code size when the config is not present. Signed-off-by: Evgenii Kosenko <[email protected]>
1 parent de91ecd commit fed5561

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

tests/bluetooth/tester/src/btp_gap.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ static uint8_t oob_legacy_tk[16] = { 0 };
4545

4646
static bool filter_list_in_use;
4747

48-
#if !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
4948
static struct bt_le_oob oob_sc_local = { 0 };
5049
static struct bt_le_oob oob_sc_remote = { 0 };
51-
#endif /* !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) */
5250

5351
/* connection parameters for rejection test */
5452
#define REJECT_INTERVAL_MIN 0x0C80
@@ -266,10 +264,10 @@ static uint8_t supported_commands(const void *cmd, uint16_t cmd_len,
266264

267265
/* octet 3 */
268266
tester_set_bit(rp->data, BTP_GAP_OOB_LEGACY_SET_DATA);
269-
#if !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
270-
tester_set_bit(rp->data, BTP_GAP_OOB_SC_GET_LOCAL_DATA);
271-
tester_set_bit(rp->data, BTP_GAP_OOB_SC_SET_REMOTE_DATA);
272-
#endif /* !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) */
267+
if (!IS_ENABLED(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)) {
268+
tester_set_bit(rp->data, BTP_GAP_OOB_SC_GET_LOCAL_DATA);
269+
tester_set_bit(rp->data, BTP_GAP_OOB_SC_SET_REMOTE_DATA);
270+
}
273271
tester_set_bit(rp->data, BTP_GAP_SET_MITM);
274272
tester_set_bit(rp->data, BTP_GAP_SET_FILTER_LIST);
275273
#if defined(CONFIG_BT_EXT_ADV)
@@ -308,9 +306,9 @@ static uint8_t controller_info(const void *cmd, uint16_t cmd_len,
308306
/*
309307
* Re-use the oob data read here in get_oob_sc_local_data()
310308
*/
311-
#if !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
312-
oob_sc_local = oob_local;
313-
#endif /* !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) */
309+
if (!IS_ENABLED(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)) {
310+
oob_sc_local = oob_local;
311+
}
314312

315313
/*
316314
* If privacy is used, the device uses random type address, otherwise
@@ -339,9 +337,11 @@ static uint8_t controller_info(const void *cmd, uint16_t cmd_len,
339337
return BTP_STATUS_SUCCESS;
340338
}
341339

342-
#if !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
343340
static const char *oob_config_str(int oob_config)
344341
{
342+
if (!IS_ENABLED(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)) {
343+
return "no";
344+
}
345345
switch (oob_config) {
346346
case BT_CONN_OOB_LOCAL_ONLY:
347347
return "Local";
@@ -354,7 +354,6 @@ static const char *oob_config_str(int oob_config)
354354
return "no";
355355
}
356356
}
357-
#endif /* !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) */
358357

359358
static void oob_data_request(struct bt_conn *conn,
360359
struct bt_conn_oob_info *oob_info)
@@ -371,9 +370,12 @@ static void oob_data_request(struct bt_conn *conn,
371370
bt_addr_le_to_str(info.le.dst, addr, sizeof(addr));
372371

373372
switch (oob_info->type) {
374-
#if !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
375373
case BT_CONN_OOB_LE_SC:
376374
{
375+
if (!IS_ENABLED(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)) {
376+
LOG_ERR("OOB LE SC not supported");
377+
break;
378+
}
377379
LOG_DBG("Set %s OOB SC data for %s, ",
378380
oob_config_str(oob_info->lesc.oob_config),
379381
addr);
@@ -411,7 +413,6 @@ static void oob_data_request(struct bt_conn *conn,
411413

412414
break;
413415
}
414-
#endif /* !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY) */
415416

416417
#if !defined(CONFIG_BT_SMP_SC_PAIR_ONLY)
417418
case BT_CONN_OOB_LE_LEGACY:
@@ -430,7 +431,7 @@ static void oob_data_request(struct bt_conn *conn,
430431
}
431432
}
432433

433-
#if !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
434+
# if !defined (CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
434435
static uint8_t get_oob_sc_local_data(const void *cmd, uint16_t cmd_len,
435436
void *rsp, uint16_t *rsp_len)
436437
{

0 commit comments

Comments
 (0)