Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/bluetooth/tester/src/btp/btp_gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ struct btp_gap_stop_advertising_rp {
#define BTP_GAP_DISCOVERY_FLAG_OWN_ID_ADDR 0x20
#define BTP_GAP_DISCOVERY_FLAG_USE_FILTER_LIST 0x40

#define BTP_GAP_SET_DISCOVERY_PARAMS 0x2f

#define BTP_GAP_PHY_LE_1M 0x01
#define BTP_GAP_PHY_LE_CODED 0x02
struct btp_gap_set_discovery_params_cmd {
uint16_t interval;
uint16_t window;
uint8_t phy; /* 1M and Coded */
uint8_t flags; /* For future use */
} __packed;

#define BTP_GAP_START_DISCOVERY 0x0c
struct btp_gap_start_discovery_cmd {
uint8_t flags;
Expand Down
50 changes: 40 additions & 10 deletions tests/bluetooth/tester/src/btp_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,41 @@ static uint8_t br_start_discovery(const struct btp_gap_start_discovery_cmd *cp)
}
#endif /* CONFIG_BT_CLASSIC */

static struct bt_le_scan_param scan_param = {
.type = BT_LE_SCAN_TYPE_PASSIVE,
.options = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
.interval = BT_GAP_SCAN_FAST_INTERVAL,
.window = BT_GAP_SCAN_FAST_WINDOW,
.timeout = 0,
.interval_coded = 0,
.window_coded = 0,
};

static uint8_t set_discovery_params(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len)
{
const struct btp_gap_set_discovery_params_cmd *cp = cmd;

if (cp->interval < 4 || cp->window < 4 || cp->window > cp->interval) {
LOG_ERR("Invalid discovery parameters");
return BTP_STATUS_FAILED;
}

/* 1M default we do not need to test for it */
if (cp->phy & ~(BTP_GAP_PHY_LE_1M | BTP_GAP_PHY_LE_CODED)) {
LOG_ERR("Invalid PHY");
return BTP_STATUS_FAILED;
}

scan_param.interval = cp->interval;
scan_param.window = cp->window;

if (cp->phy & BTP_GAP_PHY_LE_CODED) {
scan_param.options |= BT_LE_SCAN_OPT_CODED;
}

return BTP_STATUS_SUCCESS;
}

static uint8_t start_discovery(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
Expand All @@ -1206,16 +1241,6 @@ static uint8_t start_discovery(const void *cmd, uint16_t cmd_len,
return br_start_discovery(cp);
}

struct bt_le_scan_param scan_param = {
.type = BT_LE_SCAN_TYPE_PASSIVE,
.options = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
.interval = BT_GAP_SCAN_FAST_INTERVAL,
.window = BT_GAP_SCAN_FAST_WINDOW,
.timeout = 0,
.interval_coded = 0,
.window_coded = 0,
};

if (cp->flags & BTP_GAP_DISCOVERY_FLAG_LE_ACTIVE_SCAN) {
scan_param.type = BT_LE_SCAN_TYPE_ACTIVE;
}
Expand Down Expand Up @@ -2884,6 +2909,11 @@ static const struct btp_handler handlers[] = {
.expect_len = 0,
.func = stop_advertising,
},
{
.opcode = BTP_GAP_SET_DISCOVERY_PARAMS,
.expect_len = sizeof(struct btp_gap_set_discovery_params_cmd),
.func = set_discovery_params,
},
{
.opcode = BTP_GAP_START_DISCOVERY,
.expect_len = sizeof(struct btp_gap_start_discovery_cmd),
Expand Down