Skip to content

Commit 0b2fbf9

Browse files
kedMertenskartben
authored andcommitted
bluetooth: tester: btp: fixes ext adv selection
Disabling extended advertising, CONFIG_BT_EXT_ADV, fails to compile cause references not guarded ext_adv variable when tester_gap_create_adv_instance is called. Fixes by taking in use IS_ENABLED as preferred way of guarding Kconfig option. It enables compiling guarded code to get warning/errors and not to link if not used. Signed-off-by: Evgenii Kosenko <[email protected]>
1 parent bf7dfc5 commit 0b2fbf9

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

tests/bluetooth/tester/src/btp_gap.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ static uint8_t supported_commands(const void *cmd, uint16_t cmd_len,
264264
}
265265
tester_set_bit(rp->data, BTP_GAP_SET_MITM);
266266
tester_set_bit(rp->data, BTP_GAP_SET_FILTER_LIST);
267-
#if defined(CONFIG_BT_EXT_ADV)
268-
tester_set_bit(rp->data, BTP_GAP_SET_EXTENDED_ADVERTISING);
269-
#endif
267+
if (IS_ENABLED(CONFIG_BT_EXT_ADV)) {
268+
tester_set_bit(rp->data, BTP_GAP_SET_EXTENDED_ADVERTISING);
269+
}
270270

271271
*rsp_len = sizeof(*rp) + 4;
272272

@@ -425,7 +425,7 @@ static void oob_data_request(struct bt_conn *conn,
425425
}
426426
}
427427

428-
# if !defined (CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
428+
#if !defined(CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY)
429429
static uint8_t get_oob_sc_local_data(const void *cmd, uint16_t cmd_len,
430430
void *rsp, uint16_t *rsp_len)
431431
{
@@ -516,16 +516,22 @@ static struct bt_data ad[10] = {
516516
};
517517
static struct bt_data sd[10];
518518

519-
#if defined(CONFIG_BT_EXT_ADV)
520519
static struct bt_le_ext_adv *ext_adv;
521520

522521
struct bt_le_ext_adv *tester_gap_ext_adv_get(void)
523522
{
523+
if (!IS_ENABLED(CONFIG_BT_EXT_ADV)) {
524+
return NULL;
525+
}
524526
return ext_adv;
525527
}
526528

527529
int tester_gap_start_ext_adv(void)
528530
{
531+
if (!IS_ENABLED(CONFIG_BT_EXT_ADV)) {
532+
return -ENOTSUP;
533+
}
534+
529535
int err;
530536

531537
err = bt_le_ext_adv_start(ext_adv, BT_LE_EXT_ADV_START_DEFAULT);
@@ -542,6 +548,10 @@ int tester_gap_start_ext_adv(void)
542548

543549
int tester_gap_stop_ext_adv(void)
544550
{
551+
if (!IS_ENABLED(CONFIG_BT_EXT_ADV)) {
552+
return -ENOTSUP;
553+
}
554+
545555
int err;
546556

547557
err = bt_le_ext_adv_stop(ext_adv);
@@ -555,7 +565,6 @@ int tester_gap_stop_ext_adv(void)
555565

556566
return 0;
557567
}
558-
#endif /* defined(CONFIG_BT_EXT_ADV) */
559568

560569
static uint8_t set_discoverable(const void *cmd, uint16_t cmd_len,
561570
void *rsp, uint16_t *rsp_len)
@@ -744,12 +753,9 @@ static uint8_t start_advertising(const void *cmd, uint16_t cmd_len,
744753
return BTP_STATUS_FAILED;
745754
}
746755

747-
#if defined(CONFIG_BT_EXT_ADV)
748-
if (atomic_test_bit(&current_settings, BTP_GAP_SETTINGS_EXTENDED_ADVERTISING)) {
756+
if (IS_ENABLED(CONFIG_BT_EXT_ADV) &&
757+
atomic_test_bit(&current_settings, BTP_GAP_SETTINGS_EXTENDED_ADVERTISING)) {
749758
err = bt_le_ext_adv_start(ext_adv, BT_LE_EXT_ADV_START_DEFAULT);
750-
#else
751-
if (0) {
752-
#endif
753759
} else {
754760
err = bt_le_adv_start(&param, ad, adv_len, sd_len ? sd : NULL, sd_len);
755761
}
@@ -1370,27 +1376,27 @@ static uint8_t set_filter_list(const void *cmd, uint16_t cmd_len,
13701376
return BTP_STATUS_SUCCESS;
13711377
}
13721378

1373-
static uint8_t set_extended_advertising(const void *cmd, uint16_t cmd_len,
1374-
void *rsp, uint16_t *rsp_len)
1379+
#if defined(CONFIG_BT_EXT_ADV)
1380+
static uint8_t set_extended_advertising(const void *cmd, uint16_t cmd_len, void *rsp,
1381+
uint16_t *rsp_len)
13751382
{
13761383
const struct btp_gap_set_extended_advertising_cmd *cp = cmd;
13771384
struct btp_gap_set_extended_advertising_rp *rp = rsp;
13781385

13791386
LOG_DBG("ext adv settings: %u", cp->settings);
13801387

13811388
if (cp->settings != 0) {
1382-
atomic_set_bit(&current_settings,
1383-
BTP_GAP_SETTINGS_EXTENDED_ADVERTISING);
1389+
atomic_set_bit(&current_settings, BTP_GAP_SETTINGS_EXTENDED_ADVERTISING);
13841390
} else {
1385-
atomic_clear_bit(&current_settings,
1386-
BTP_GAP_SETTINGS_EXTENDED_ADVERTISING);
1391+
atomic_clear_bit(&current_settings, BTP_GAP_SETTINGS_EXTENDED_ADVERTISING);
13871392
}
13881393

13891394
rp->current_settings = sys_cpu_to_le32(current_settings);
13901395

13911396
*rsp_len = sizeof(*rp);
13921397
return BTP_STATUS_SUCCESS;
13931398
}
1399+
#endif /* defined(CONFIG_BT_EXT_ADV) */
13941400

13951401
#if defined(CONFIG_BT_PER_ADV)
13961402
static struct bt_data padv[10];

0 commit comments

Comments
 (0)