Skip to content

Commit 4b0182a

Browse files
nimble/eatt: Add manual EATT connection control to BTP tester
Added new BTP command `BTP_GATT_EATT_CONNECT` (opcode 0x1f) to trigger EATT connections with configurable L2CAP channels. Implemented handler `eatt_conn()` that: * Calls `ble_eatt_connect()` with the requested channel count and proper address Updated `supported_commands` response to advertise the new capability. Enables testing scenarios requiring explicit control over EATT establishment and channel management.
1 parent 5ab995f commit 4b0182a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

apps/bttester/src/btp/btp_gatt.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ struct btp_gatt_set_mult_val_cmd {
320320
uint8_t data[0];
321321
} __packed;
322322

323+
#define BTP_GATT_EATT_CONNECT 0x1f
324+
struct btp_gatt_eatt_conn_cmd {
325+
ble_addr_t address;
326+
uint8_t num_channels;
327+
} __packed;
328+
323329
/* GATT events */
324330
#define BTP_GATT_EV_NOTIFICATION 0x80
325331
struct btp_gatt_notification_ev {

apps/bttester/src/btp_gatt.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,27 @@ set_mult(const void *cmd, uint16_t cmd_len,
19501950
return BTP_STATUS_SUCCESS;
19511951
}
19521952

1953+
static uint8_t
1954+
eatt_conn(const void *cmd, uint16_t cmd_len,
1955+
void *rsp, uint16_t *rsp_len)
1956+
{
1957+
uint16_t conn_handle;
1958+
const struct btp_gatt_eatt_conn_cmd *cp = cmd;
1959+
int rc;
1960+
1961+
ble_gap_conn_find_handle_by_addr(&cp->address, &conn_handle);
1962+
1963+
rc = ble_eatt_connect(conn_handle, cp->num_channels);
1964+
if (rc == BLE_HS_EALREADY) {
1965+
/* Return sucess as another connect is already scheduled */
1966+
return BTP_STATUS_SUCCESS;
1967+
} else {
1968+
return BTP_STATUS_FAILED;
1969+
}
1970+
1971+
return BTP_STATUS_SUCCESS;
1972+
}
1973+
19531974
static uint8_t
19541975
change_database(const void *cmd, uint16_t cmd_len,
19551976
void *rsp, uint16_t *rsp_len)
@@ -2001,6 +2022,7 @@ supported_commands(const void *cmd, uint16_t cmd_len,
20012022
tester_set_bit(rp->data, BTP_GATT_GET_ATTRIBUTES);
20022023
tester_set_bit(rp->data, BTP_GATT_GET_ATTRIBUTE_VALUE);
20032024
tester_set_bit(rp->data, BTP_GATT_CHANGE_DATABASE);
2025+
tester_set_bit(rp->data, BTP_GATT_EATT_CONNECT);
20042026

20052027
*rsp_len = sizeof(*rp) + 4;
20062028

@@ -2137,6 +2159,11 @@ static const struct btp_handler handlers[] = {
21372159
.expect_len = BTP_HANDLER_LENGTH_VARIABLE,
21382160
.func = set_mult,
21392161
},
2162+
{
2163+
.opcode = BTP_GATT_EATT_CONNECT,
2164+
.expect_len = sizeof(struct btp_gatt_eatt_conn_cmd),
2165+
.func = eatt_conn,
2166+
},
21402167
};
21412168

21422169
int

0 commit comments

Comments
 (0)