You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2019/06/03 09:22:21 UTC
[mynewt-nimble] branch master updated: apps/bttester: Add support
for Read by UUID
This is an automated email from the ASF dual-hosted git repository.
naraj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new cfcaa8a apps/bttester: Add support for Read by UUID
cfcaa8a is described below
commit cfcaa8a046b564193bb43099a06f71605dec7348
Author: MichaĆ Narajowski <mi...@codecoup.pl>
AuthorDate: Thu May 30 10:48:44 2019 +0200
apps/bttester: Add support for Read by UUID
This can be used to pass GAP/IDLE/NAMP/BV-01-C.
---
apps/bttester/src/bttester.h | 10 +++++++++
apps/bttester/src/gatt.c | 50 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/apps/bttester/src/bttester.h b/apps/bttester/src/bttester.h
index 59a13c3..04f4501 100644
--- a/apps/bttester/src/bttester.h
+++ b/apps/bttester/src/bttester.h
@@ -513,6 +513,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;
diff --git a/apps/bttester/src/gatt.c b/apps/bttester/src/gatt.c
index 6792e69..b162ce5 100644
--- a/apps/bttester/src/gatt.c
+++ b/apps/bttester/src/gatt.c
@@ -1381,26 +1381,27 @@ static int read_long_cb(uint16_t conn_handle,
void *arg)
{
struct gatt_read_rp *rp = (void *) gatt_buf.buf;
+ u8_t btp_opcode = (uint8_t) (int) arg;
SYS_LOG_DBG("status=%d", error->status);
if (error->status != 0 && error->status != BLE_HS_EDONE) {
rp->att_response = (uint8_t) BLE_HS_ATT_ERR(error->status);
- tester_send(BTP_SERVICE_ID_GATT, GATT_READ_LONG,
+ tester_send(BTP_SERVICE_ID_GATT, btp_opcode,
CONTROLLER_INDEX, gatt_buf.buf, gatt_buf.len);
read_destroy();
return 0;
}
if (error->status == BLE_HS_EDONE) {
- tester_send(BTP_SERVICE_ID_GATT, GATT_READ_LONG,
+ tester_send(BTP_SERVICE_ID_GATT, btp_opcode,
CONTROLLER_INDEX, gatt_buf.buf, gatt_buf.len);
read_destroy();
return 0;
}
if (gatt_buf_add(attr->om->om_data, attr->om->om_len) == NULL) {
- tester_rsp(BTP_SERVICE_ID_GATT, GATT_READ_LONG,
+ tester_rsp(BTP_SERVICE_ID_GATT, btp_opcode,
CONTROLLER_INDEX, BTP_STATUS_FAILED);
read_destroy();
return 0;
@@ -1441,6 +1442,44 @@ fail:
BTP_STATUS_FAILED);
}
+static void read_uuid(u8_t *data, u16_t len)
+{
+ const struct gatt_read_uuid_cmd *cmd = (void *) data;
+ struct ble_gap_conn_desc conn;
+ ble_uuid_any_t uuid;
+ int rc;
+
+ SYS_LOG_DBG("");
+
+ rc = ble_gap_conn_find_by_addr((ble_addr_t *)data, &conn);
+ if (rc) {
+ goto fail;
+ }
+
+ if (btp2bt_uuid(cmd->uuid, cmd->uuid_length, &uuid)) {
+ goto fail;
+ }
+
+ if (!gatt_buf_reserve(sizeof(struct gatt_read_rp))) {
+ goto fail;
+ }
+
+ if (ble_gattc_read_by_uuid(conn.conn_handle,
+ sys_le16_to_cpu(cmd->start_handle),
+ sys_le16_to_cpu(cmd->end_handle),
+ &uuid.u,
+ read_long_cb, (void *)GATT_READ_UUID)) {
+ discover_destroy();
+ goto fail;
+ }
+
+ return;
+
+fail:
+ tester_rsp(BTP_SERVICE_ID_GATT, GATT_READ, CONTROLLER_INDEX,
+ BTP_STATUS_FAILED);
+}
+
static void read_long(u8_t *data, u16_t len)
{
const struct gatt_read_long_cmd *cmd = (void *) data;
@@ -1461,7 +1500,7 @@ static void read_long(u8_t *data, u16_t len)
if (ble_gattc_read_long(conn.conn_handle,
sys_le16_to_cpu(cmd->handle),
sys_le16_to_cpu(cmd->offset),
- read_long_cb, NULL)) {
+ read_long_cb, (void *)GATT_READ_LONG)) {
discover_destroy();
goto fail;
}
@@ -2173,6 +2212,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;