From 3b102b1c80407048cb869a1b0590763356b2fbd5 Mon Sep 17 00:00:00 2001 From: Szymon Czapracki Date: Fri, 28 Mar 2025 18:13:29 +0100 Subject: [PATCH] nimble/eatt: Add manual EATT connection control to BTP tester Adds new BTP command `BTP_GATT_EATT_CONNECT` (opcode 0x1f) to trigger EATT connections with configurable L2CAP channels. Implements handler `eatt_conn()` that: * Calls `ble_eatt_connect()` with the requested channel count and proper address Enables testing scenarios requiring explicit control over EATT establishment and channel management. --- apps/bttester/src/btp/btp_gatt.h | 6 ++++++ apps/bttester/src/btp_gatt.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/apps/bttester/src/btp/btp_gatt.h b/apps/bttester/src/btp/btp_gatt.h index 6c57ade092..7e52efd46a 100644 --- a/apps/bttester/src/btp/btp_gatt.h +++ b/apps/bttester/src/btp/btp_gatt.h @@ -321,6 +321,12 @@ struct btp_gatt_notify_mult_val_cmd { uint16_t handles[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 { diff --git a/apps/bttester/src/btp_gatt.c b/apps/bttester/src/btp_gatt.c index 2baa1c8353..2b0e4908cf 100644 --- a/apps/bttester/src/btp_gatt.c +++ b/apps/bttester/src/btp_gatt.c @@ -1939,6 +1939,23 @@ notify_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 == 0 || rc == BLE_HS_EALREADY) { + return BTP_STATUS_SUCCESS; + } + + return BTP_STATUS_FAILED; +} + static uint8_t change_database(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len) @@ -2096,6 +2113,11 @@ static const struct btp_handler handlers[] = { .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = notify_mult, }, + { + .opcode = BTP_GATT_EATT_CONNECT, + .expect_len = sizeof(struct btp_gatt_eatt_conn_cmd), + .func = eatt_conn, + }, }; int