Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to set scannable adv #1913

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions apps/bttester/src/btp/btp_gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct btp_gap_read_controller_index_list_rp {
#define BTP_GAP_SETTINGS_STATIC_ADDRESS 15
#define BTP_GAP_SETTINGS_EXTENDED_ADVERTISING 17
#define BTP_GAP_SETTINGS_PERIODIC_ADVERTISING 18
#define BTP_GAP_SETTINGS_SCANNABLE 19

#define BTP_GAP_READ_CONTROLLER_INFO 0x03
struct btp_gap_read_controller_info_rp {
Expand Down Expand Up @@ -328,6 +329,15 @@ struct gap_periodic_adv_sync_transfer_recv_cmd {
uint16_t sync_timeout;
uint8_t flags;
} __packed;

#define BTP_GAP_SET_SCANNABLE 0x30
struct btp_gap_set_scannable_cmd {
uint8_t scannable;
} __packed;
struct btp_gap_set_scannable_rp {
uint32_t current_settings;
} __packed;

/* events */
#define BTP_GAP_EV_NEW_SETTINGS 0x80
struct btp_gap_new_settings_ev {
Expand Down
33 changes: 33 additions & 0 deletions apps/bttester/src/btp_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,34 @@ set_connectable(const void *cmd, uint16_t cmd_len,
return BTP_STATUS_SUCCESS;
}

static uint8_t
set_scannable(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
const struct btp_gap_set_scannable_cmd *cp = cmd;
struct btp_gap_set_scannable_rp *rp = rsp;

SYS_LOG_DBG("")

if (cp->scannable) {
current_settings |= BIT(BTP_GAP_SETTINGS_SCANNABLE);
#if MYNEWT_VAL(BLE_EXT_ADV)
adv_params.scannable = 0;
#endif
} else {
current_settings &= ~BIT(BTP_GAP_SETTINGS_SCANNABLE);
#if MYNEWT_VAL(BLE_EXT_ADV)
adv_params.scannable = 0;
#endif
}

rp->current_settings = htole32(current_settings);

*rsp_len = sizeof(*rp);

return BTP_STATUS_SUCCESS;
}

static uint8_t
set_discoverable(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
Expand Down Expand Up @@ -2261,6 +2289,11 @@ static const struct btp_handler handlers[] = {
.expect_len = sizeof(struct btp_gap_set_connectable_cmd),
.func = set_connectable,
},
{
.opcode = BTP_GAP_SET_SCANNABLE,
.expect_len = sizeof(struct btp_gap_set_scannable_cmd),
.func = set_scannable,
},
{
.opcode = BTP_GAP_SET_DISCOVERABLE,
.expect_len = sizeof(struct btp_gap_set_discoverable_cmd),
Expand Down
Loading