This adds read support to test command handler. Particular read types will be
handled basing on the 'u1' command parameter.
---
android/gatt.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
android/hal-msg.h | 1 +
2 files changed, 46 insertions(+)
diff --git a/android/gatt.c b/android/gatt.c
index fd35442..d9a76c6 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3442,6 +3442,44 @@ failed:
HAL_OP_GATT_CLIENT_SET_ADV_DATA, status);
}
+static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
+ uint16_t read_type, uint16_t u2, uint16_t u3,
+ uint16_t u4, uint16_t u5)
+{
+ guint16 length = 0;
+ struct gatt_device *dev;
+ uint8_t *pdu;
+ size_t mtu;
+
+ dev = find_device_by_addr(bdaddr);
+ if (!dev || dev->state != DEVICE_CONNECTED)
+ return HAL_STATUS_FAILED;
+
+ pdu = g_attrib_get_buffer(dev->attrib, &mtu);
+ if (!pdu)
+ return HAL_STATUS_FAILED;
+
+ switch (read_type) {
+ case ATT_OP_READ_REQ:
+ case ATT_OP_READ_BY_TYPE_REQ:
+ case ATT_OP_READ_BLOB_REQ:
+ case ATT_OP_READ_BY_GROUP_REQ:
+ case ATT_OP_READ_MULTI_REQ:
+ default:
+ error("gatt: Unknown read type");
+
+ return HAL_STATUS_UNSUPPORTED;
+ }
+
+ if (!length)
+ return HAL_STATUS_FAILED;
+
+ g_attrib_send(dev->attrib, 0, pdu, length, NULL, NULL, NULL);
+
+ return HAL_STATUS_SUCCESS;
+}
+
+
static void handle_client_test_command(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_test_command *cmd = buf;
@@ -3484,6 +3522,13 @@ static void handle_client_test_command(const void *buf, uint16_t len)
status = HAL_STATUS_SUCCESS;
break;
case GATT_CLIENT_TEST_CMD_DISCOVER:
+ status = HAL_STATUS_FAILED;
+ break;
+ case GATT_CLIENT_TEST_CMD_READ:
+ status = handle_test_command_read(&bdaddr, &uuid, cmd->u1,
+ cmd->u2, cmd->u3,
+ cmd->u4, cmd->u5);
+ break;
case GATT_CLIENT_TEST_CMD_PAIRING_CONFIG:
default:
status = HAL_STATUS_FAILED;
diff --git a/android/hal-msg.h b/android/hal-msg.h
index d051b67..ae15499 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -751,6 +751,7 @@ struct hal_cmd_gatt_client_set_adv_data {
#define GATT_CLIENT_TEST_CMD_CONNECT 0x02
#define GATT_CLIENT_TEST_CMD_DISCONNECT 0x03
#define GATT_CLIENT_TEST_CMD_DISCOVER 0x04
+#define GATT_CLIENT_TEST_CMD_READ 0xe0
#define GATT_CLIENT_TEST_CMD_PAIRING_CONFIG 0xf0
#define HAL_OP_GATT_CLIENT_TEST_COMMAND 0x16
--
1.9.3
Hi Jakub,
On Thursday 29 of May 2014 12:34:03 Jakub Tyszkowski wrote:
> This adds read support to test command handler. Particular read types will be
> handled basing on the 'u1' command parameter.
> ---
> android/gatt.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> android/hal-msg.h | 1 +
> 2 files changed, 46 insertions(+)
>
> diff --git a/android/gatt.c b/android/gatt.c
> index fd35442..d9a76c6 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -3442,6 +3442,44 @@ failed:
> HAL_OP_GATT_CLIENT_SET_ADV_DATA, status);
> }
>
> +static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
> + uint16_t read_type, uint16_t u2, uint16_t u3,
> + uint16_t u4, uint16_t u5)
> +{
> + guint16 length = 0;
> + struct gatt_device *dev;
> + uint8_t *pdu;
> + size_t mtu;
> +
> + dev = find_device_by_addr(bdaddr);
> + if (!dev || dev->state != DEVICE_CONNECTED)
> + return HAL_STATUS_FAILED;
> +
> + pdu = g_attrib_get_buffer(dev->attrib, &mtu);
> + if (!pdu)
> + return HAL_STATUS_FAILED;
> +
> + switch (read_type) {
> + case ATT_OP_READ_REQ:
> + case ATT_OP_READ_BY_TYPE_REQ:
> + case ATT_OP_READ_BLOB_REQ:
> + case ATT_OP_READ_BY_GROUP_REQ:
> + case ATT_OP_READ_MULTI_REQ:
> + default:
> + error("gatt: Unknown read type");
> +
> + return HAL_STATUS_UNSUPPORTED;
> + }
> +
> + if (!length)
> + return HAL_STATUS_FAILED;
> +
> + g_attrib_send(dev->attrib, 0, pdu, length, NULL, NULL, NULL);
> +
> + return HAL_STATUS_SUCCESS;
> +}
> +
> +
> static void handle_client_test_command(const void *buf, uint16_t len)
> {
> const struct hal_cmd_gatt_client_test_command *cmd = buf;
> @@ -3484,6 +3522,13 @@ static void handle_client_test_command(const void *buf, uint16_t len)
> status = HAL_STATUS_SUCCESS;
> break;
> case GATT_CLIENT_TEST_CMD_DISCOVER:
> + status = HAL_STATUS_FAILED;
> + break;
> + case GATT_CLIENT_TEST_CMD_READ:
> + status = handle_test_command_read(&bdaddr, &uuid, cmd->u1,
> + cmd->u2, cmd->u3,
> + cmd->u4, cmd->u5);
> + break;
> case GATT_CLIENT_TEST_CMD_PAIRING_CONFIG:
> default:
> status = HAL_STATUS_FAILED;
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index d051b67..ae15499 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -751,6 +751,7 @@ struct hal_cmd_gatt_client_set_adv_data {
> #define GATT_CLIENT_TEST_CMD_CONNECT 0x02
> #define GATT_CLIENT_TEST_CMD_DISCONNECT 0x03
> #define GATT_CLIENT_TEST_CMD_DISCOVER 0x04
> +#define GATT_CLIENT_TEST_CMD_READ 0xe0
> #define GATT_CLIENT_TEST_CMD_PAIRING_CONFIG 0xf0
>
> #define HAL_OP_GATT_CLIENT_TEST_COMMAND 0x16
>
All patches applied (with minor whitespace fixes in first one), thanks.
--
Best regards,
Szymon Janc
'u2' command parameter is used as start handle, 'u3' as end handle and
uuid as group type.
---
android/gatt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/gatt.c b/android/gatt.c
index 40325bc..801c6c1 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3470,6 +3470,8 @@ static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
length = enc_read_blob_req(u2, u3, pdu, mtu);
break;
case ATT_OP_READ_BY_GROUP_REQ:
+ length = enc_read_by_grp_req(u2, u3, uuid, pdu, mtu);
+ break;
case ATT_OP_READ_MULTI_REQ:
default:
error("gatt: Unknown read type");
--
1.9.3
---
android/pts-gatt.txt | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/android/pts-gatt.txt b/android/pts-gatt.txt
index a15c1d2..dde7267 100644
--- a/android/pts-gatt.txt
+++ b/android/pts-gatt.txt
@@ -78,12 +78,27 @@ TC_GAR_CL_BI_03_C PASS haltest:
TC_GAR_CL_BI_04_C PASS haltest:
gattc read_characteristic
TC_GAR_CL_BI_05_C INC not implemented (encryption)
-TC_GAR_CL_BV_03_C INC JIRA: BZ-31
-TC_GAR_CL_BI_06_C INC JIRA: BZ-31
-TC_GAR_CL_BI_07_C INC JIRA: BZ-31
-TC_GAR_CL_BI_09_C INC JIRA: BZ-31
-TC_GAR_CL_BI_10_C INC JIRA: BZ-31
-TC_GAR_CL_BI_11_C INC not implemented (encryption)
+TC_GAR_CL_BV_03_C INC JIRA: BZ-31, Possible PTS issue #12227
+TC_GAR_CL_BI_06_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 224 [u1] 8
+ gattc disconnect
+TC_GAR_CL_BI_07_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 224 [u1] 8
+ gattc disconnect
+TC_GAR_CL_BI_09_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 224 [u1] 8
+ gattc disconnect
+TC_GAR_CL_BI_10_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 224 [u1] 8
+ gattc disconnect
+TC_GAR_CL_BI_11_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 224 [u1] 8
+ gattc disconnect
TC_GAR_CL_BV_04_C PASS haltest:
gattc read_characteristic
TC_GAR_CL_BI_12_C PASS haltest:
--
1.9.3
'u2' command paremeter is used as handle and 'u3' as offset value.
---
android/gatt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/gatt.c b/android/gatt.c
index ec75594..40325bc 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3467,6 +3467,8 @@ static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
length = enc_read_by_type_req(u2, u3, uuid, pdu, mtu);
break;
case ATT_OP_READ_BLOB_REQ:
+ length = enc_read_blob_req(u2, u3, pdu, mtu);
+ break;
case ATT_OP_READ_BY_GROUP_REQ:
case ATT_OP_READ_MULTI_REQ:
default:
--
1.9.3
'u2' parameter is used as start handle, 'u3' as end handle and uuid as
attribute type.
---
android/gatt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/gatt.c b/android/gatt.c
index 9153ec8..ec75594 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3464,6 +3464,8 @@ static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
length = enc_read_req(u2, pdu, mtu);
break;
case ATT_OP_READ_BY_TYPE_REQ:
+ length = enc_read_by_type_req(u2, u3, uuid, pdu, mtu);
+ break;
case ATT_OP_READ_BLOB_REQ:
case ATT_OP_READ_BY_GROUP_REQ:
case ATT_OP_READ_MULTI_REQ:
--
1.9.3
'u2' command parameter is used to pass attribute handle.
---
android/gatt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/gatt.c b/android/gatt.c
index d9a76c6..9153ec8 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3461,6 +3461,8 @@ static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
switch (read_type) {
case ATT_OP_READ_REQ:
+ length = enc_read_req(u2, pdu, mtu);
+ break;
case ATT_OP_READ_BY_TYPE_REQ:
case ATT_OP_READ_BLOB_REQ:
case ATT_OP_READ_BY_GROUP_REQ:
--
1.9.3