Skip to content
Permalink
Browse files

tests: bluetooth/tester: Add support Read Using Characteristic UUID

This patch adds an API to support Read Using Characteristic UUID.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
  • Loading branch information...
tedd-an authored and jhedberg committed Apr 15, 2019
1 parent 6576efe commit 543b9c972dab44ddb84a0b89f601d28f054b5cc8
Showing with 56 additions and 0 deletions.
  1. +10 −0 tests/bluetooth/tester/src/bttester.h
  2. +46 −0 tests/bluetooth/tester/src/gatt.c
@@ -457,6 +457,16 @@ struct gatt_read_rp {
u8_t data[0];
} __packed;

#define GATT_READ_UUID 0x12
struct gatt_read_uuid_cmd {
u8_t address_type;
u8_t address[6];
u16_t start_handle;
u16_t end_handle;
u8_t uuid_length;
u8_t uuid[0];
} __packed;

#define GATT_READ_LONG 0x13
struct gatt_read_long_cmd {
u8_t address_type;
@@ -1374,6 +1374,49 @@ static void read(u8_t *data, u16_t len)
BTP_STATUS_FAILED);
}

static void read_uuid(u8_t *data, u16_t len)
{
const struct gatt_read_uuid_cmd *cmd = (void *) data;
struct bt_conn *conn;

conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, (bt_addr_le_t *)data);
if (!conn) {
goto fail_conn;
}

if (btp2bt_uuid(cmd->uuid, cmd->uuid_length, &uuid.uuid)) {
goto fail;
}

if (!gatt_buf_reserve(sizeof(struct gatt_read_rp))) {
goto fail;
}

read_params.by_uuid.uuid = &uuid.uuid;
read_params.handle_count = 0;
read_params.by_uuid.start_handle = sys_le16_to_cpu(cmd->start_handle);
read_params.by_uuid.end_handle = sys_le16_to_cpu(cmd->end_handle);
read_params.func = read_cb;

btp_opcode = GATT_READ_UUID;

if (bt_gatt_read(conn, &read_params) < 0) {
read_destroy(&read_params);

goto fail;
}

bt_conn_unref(conn);

return;
fail:
bt_conn_unref(conn);

fail_conn:
tester_rsp(BTP_SERVICE_ID_GATT, GATT_READ_UUID, CONTROLLER_INDEX,
BTP_STATUS_FAILED);
}

static void read_long(u8_t *data, u16_t len)
{
const struct gatt_read_long_cmd *cmd = (void *) data;
@@ -1908,6 +1951,9 @@ void tester_handle_gatt(u8_t opcode, u8_t index, u8_t *data,
case GATT_READ:
read(data, len);
return;
case GATT_READ_UUID:
read_uuid(data, len);
return;
case GATT_READ_LONG:
read_long(data, len);
return;

0 comments on commit 543b9c9

Please sign in to comment.
You can’t perform that action at this time.