tests/bluetooth/tester: Refactor Read UUID callback
ATT_READ_BY_TYPE_RSP returns Attribute Data List so handle it in the application. This affects GATT/CL/GAR/BV-03-C. Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
This commit is contained in:
parent
2abb2389a1
commit
54cd46ac68
2 changed files with 55 additions and 4 deletions
|
@ -575,6 +575,12 @@ struct gatt_read_rp {
|
|||
uint8_t data[];
|
||||
} __packed;
|
||||
|
||||
struct gatt_char_value {
|
||||
uint16_t handle;
|
||||
uint8_t data_len;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define GATT_READ_UUID 0x12
|
||||
struct gatt_read_uuid_cmd {
|
||||
uint8_t address_type;
|
||||
|
@ -586,8 +592,8 @@ struct gatt_read_uuid_cmd {
|
|||
} __packed;
|
||||
struct gatt_read_uuid_rp {
|
||||
uint8_t att_response;
|
||||
uint16_t data_length;
|
||||
uint8_t data[];
|
||||
uint8_t values_count;
|
||||
struct gatt_char_value values[0];
|
||||
} __packed;
|
||||
|
||||
#define GATT_READ_LONG 0x13
|
||||
|
|
|
@ -1396,6 +1396,51 @@ static uint8_t read_cb(struct bt_conn *conn, uint8_t err,
|
|||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
|
||||
static uint8_t read_uuid_cb(struct bt_conn *conn, uint8_t err,
|
||||
struct bt_gatt_read_params *params, const void *data,
|
||||
uint16_t length)
|
||||
{
|
||||
struct gatt_read_uuid_rp *rp = (void *)gatt_buf.buf;
|
||||
struct gatt_char_value value;
|
||||
|
||||
/* Respond to the Lower Tester with ATT Error received */
|
||||
if (err) {
|
||||
rp->att_response = err;
|
||||
}
|
||||
|
||||
/* read complete */
|
||||
if (!data) {
|
||||
tester_send(BTP_SERVICE_ID_GATT, btp_opcode, CONTROLLER_INDEX,
|
||||
gatt_buf.buf, gatt_buf.len);
|
||||
read_destroy(params);
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
||||
value.handle = params->by_uuid.start_handle;
|
||||
value.data_len = length;
|
||||
|
||||
if (!gatt_buf_add(&value, sizeof(struct gatt_char_value))) {
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, btp_opcode,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
read_destroy(params);
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
||||
if (!gatt_buf_add(data, length)) {
|
||||
tester_rsp(BTP_SERVICE_ID_GATT, btp_opcode,
|
||||
CONTROLLER_INDEX, BTP_STATUS_FAILED);
|
||||
read_destroy(params);
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
||||
rp->values_count++;
|
||||
|
||||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
|
||||
static void read_data(uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gatt_read_cmd *cmd = (void *) data;
|
||||
|
@ -1449,7 +1494,7 @@ static void read_uuid(uint8_t *data, uint16_t len)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_read_rp))) {
|
||||
if (!gatt_buf_reserve(sizeof(struct gatt_read_uuid_rp))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1457,7 +1502,7 @@ static void read_uuid(uint8_t *data, uint16_t len)
|
|||
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;
|
||||
read_params.func = read_uuid_cb;
|
||||
|
||||
btp_opcode = GATT_READ_UUID;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue