Skip to content

nimble/bttester: Add manual EATT connection control to BTP tester #2017

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

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
6 changes: 6 additions & 0 deletions apps/bttester/src/btp/btp_gatt.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ struct btp_gatt_set_mult_val_cmd {
uint8_t data[0];
} __packed;

#define BTP_GATT_EATT_CONNECT 0x1f
struct btp_gatt_eatt_conn_cmd {
ble_addr_t address;
uint8_t num_channels;
} __packed;

/* GATT events */
#define BTP_GATT_EV_NOTIFICATION 0x80
struct btp_gatt_notification_ev {
Expand Down
27 changes: 27 additions & 0 deletions apps/bttester/src/btp_gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,27 @@ set_mult(const void *cmd, uint16_t cmd_len,
return BTP_STATUS_SUCCESS;
}

static uint8_t
eatt_conn(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
uint16_t conn_handle;
const struct btp_gatt_eatt_conn_cmd *cp = cmd;
int rc;

ble_gap_conn_find_handle_by_addr(&cp->address, &conn_handle);

rc = ble_eatt_connect(conn_handle, cp->num_channels);
if (rc == BLE_HS_EALREADY) {
/* Return sucess as another connect is already scheduled */
return BTP_STATUS_SUCCESS;
} else {
return BTP_STATUS_FAILED;
}

return BTP_STATUS_SUCCESS;
}

static uint8_t
change_database(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
Expand Down Expand Up @@ -2001,6 +2022,7 @@ supported_commands(const void *cmd, uint16_t cmd_len,
tester_set_bit(rp->data, BTP_GATT_GET_ATTRIBUTES);
tester_set_bit(rp->data, BTP_GATT_GET_ATTRIBUTE_VALUE);
tester_set_bit(rp->data, BTP_GATT_CHANGE_DATABASE);
tester_set_bit(rp->data, BTP_GATT_EATT_CONNECT);

*rsp_len = sizeof(*rp) + 4;

Expand Down Expand Up @@ -2137,6 +2159,11 @@ static const struct btp_handler handlers[] = {
.expect_len = BTP_HANDLER_LENGTH_VARIABLE,
.func = set_mult,
},
{
.opcode = BTP_GATT_EATT_CONNECT,
.expect_len = sizeof(struct btp_gatt_eatt_conn_cmd),
.func = eatt_conn,
},
};

int
Expand Down