2014-05-29 13:04:59

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 1/6] android/gatt: Initial support for write test command

This is handled mostly the same way as read so we can use the same
function for sending att requests.

As test command parameters are of type uint16_t, we cannot write longer
values. We can figure out the ways to overcome this limitation if it
turns out that it's really needed (i.e. some PTS test cases cannot be
passed).
---
android/gatt.c | 19 +++++++++++++------
android/hal-msg.h | 1 +
2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index 9b51ab1..5919377 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3442,9 +3442,10 @@ 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)
+static uint8_t handle_test_command_read_write(bdaddr_t *bdaddr, bt_uuid_t *uuid,
+ uint16_t op, uint16_t u2,
+ uint16_t u3, uint16_t u4,
+ uint16_t u5)
{
guint16 length = 0;
struct gatt_device *dev;
@@ -3459,7 +3460,7 @@ static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
if (!pdu)
return HAL_STATUS_FAILED;

- switch (read_type) {
+ switch (op) {
case ATT_OP_READ_REQ:
length = enc_read_req(u2, pdu, mtu);
break;
@@ -3473,8 +3474,13 @@ static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
length = enc_read_by_grp_req(u2, u3, uuid, pdu, mtu);
break;
case ATT_OP_READ_MULTI_REQ:
+ return HAL_STATUS_UNSUPPORTED;
+ case ATT_OP_WRITE_REQ:
+ case ATT_OP_WRITE_CMD:
+ case ATT_OP_PREP_WRITE_REQ:
+ case ATT_OP_EXEC_WRITE_REQ:
default:
- error("gatt: Unknown read type");
+ error("gatt: Unknown operation type");

return HAL_STATUS_UNSUPPORTED;
}
@@ -3532,7 +3538,8 @@ static void handle_client_test_command(const void *buf, uint16_t len)
status = HAL_STATUS_FAILED;
break;
case GATT_CLIENT_TEST_CMD_READ:
- status = handle_test_command_read(&bdaddr, &uuid, cmd->u1,
+ case GATT_CLIENT_TEST_CMD_WRITE:
+ status = handle_test_command_read_write(&bdaddr, &uuid, cmd->u1,
cmd->u2, cmd->u3,
cmd->u4, cmd->u5);
break;
diff --git a/android/hal-msg.h b/android/hal-msg.h
index ae15499..5da62f3 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -752,6 +752,7 @@ struct hal_cmd_gatt_client_set_adv_data {
#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_WRITE 0xe1
#define GATT_CLIENT_TEST_CMD_PAIRING_CONFIG 0xf0

#define HAL_OP_GATT_CLIENT_TEST_COMMAND 0x16
--
1.9.3



2014-05-29 14:22:13

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH 1/6] android/gatt: Initial support for write test command

Hi Jakub,

On Thursday 29 of May 2014 15:04:59 Jakub Tyszkowski wrote:
> This is handled mostly the same way as read so we can use the same
> function for sending att requests.
>
> As test command parameters are of type uint16_t, we cannot write longer
> values. We can figure out the ways to overcome this limitation if it
> turns out that it's really needed (i.e. some PTS test cases cannot be
> passed).
> ---
> android/gatt.c | 19 +++++++++++++------
> android/hal-msg.h | 1 +
> 2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/android/gatt.c b/android/gatt.c
> index 9b51ab1..5919377 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -3442,9 +3442,10 @@ 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)
> +static uint8_t handle_test_command_read_write(bdaddr_t *bdaddr, bt_uuid_t *uuid,
> + uint16_t op, uint16_t u2,
> + uint16_t u3, uint16_t u4,
> + uint16_t u5)
> {
> guint16 length = 0;
> struct gatt_device *dev;
> @@ -3459,7 +3460,7 @@ static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
> if (!pdu)
> return HAL_STATUS_FAILED;
>
> - switch (read_type) {
> + switch (op) {
> case ATT_OP_READ_REQ:
> length = enc_read_req(u2, pdu, mtu);
> break;
> @@ -3473,8 +3474,13 @@ static uint8_t handle_test_command_read(bdaddr_t *bdaddr, bt_uuid_t *uuid,
> length = enc_read_by_grp_req(u2, u3, uuid, pdu, mtu);
> break;
> case ATT_OP_READ_MULTI_REQ:
> + return HAL_STATUS_UNSUPPORTED;
> + case ATT_OP_WRITE_REQ:
> + case ATT_OP_WRITE_CMD:
> + case ATT_OP_PREP_WRITE_REQ:
> + case ATT_OP_EXEC_WRITE_REQ:
> default:
> - error("gatt: Unknown read type");
> + error("gatt: Unknown operation type");
>
> return HAL_STATUS_UNSUPPORTED;
> }
> @@ -3532,7 +3538,8 @@ static void handle_client_test_command(const void *buf, uint16_t len)
> status = HAL_STATUS_FAILED;
> break;
> case GATT_CLIENT_TEST_CMD_READ:
> - status = handle_test_command_read(&bdaddr, &uuid, cmd->u1,
> + case GATT_CLIENT_TEST_CMD_WRITE:
> + status = handle_test_command_read_write(&bdaddr, &uuid, cmd->u1,
> cmd->u2, cmd->u3,
> cmd->u4, cmd->u5);
> break;
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index ae15499..5da62f3 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -752,6 +752,7 @@ struct hal_cmd_gatt_client_set_adv_data {
> #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_WRITE 0xe1
> #define GATT_CLIENT_TEST_CMD_PAIRING_CONFIG 0xf0
>
> #define HAL_OP_GATT_CLIENT_TEST_COMMAND 0x16
>

All patches applied. Thanks.

--
Best regards,
Szymon Janc

2014-05-29 13:05:04

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 6/6] android/pts: Update GATT results

---
android/pts-gatt.txt | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/android/pts-gatt.txt b/android/pts-gatt.txt
index 2d13330..003b439 100644
--- a/android/pts-gatt.txt
+++ b/android/pts-gatt.txt
@@ -436,7 +436,10 @@ TC_GAW_CL_BV_03_C PASS haltest:
handle from logs
gattc write_characteristic
gattc disconnect
-TC_GAW_CL_BI_02_C INC gatttool required
+TC_GAW_CL_BI_02_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 225 [u1] 18
+ gattc disconnect
TC_GAW_CL_BI_03_C PASS haltest:
gattc connect
gattc search_service
@@ -472,7 +475,10 @@ TC_GAW_CL_BV_05_C PASS haltest:
handle from logs
gattc write_characteristic 2 <long_value>
gattc disconnect
-TC_GAW_CL_BI_07_C INC gatttool required
+TC_GAW_CL_BI_07_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 225 [u1] 22
+ gattc disconnect
TC_GAW_CL_BI_08_C PASS haltest:
gattc connect
gattc search_service
@@ -515,7 +521,10 @@ TC_GAW_CL_BV_06_C PASS haltest:
handle from logs
gattc write_characteristic 2 <long_value>
gattc disconnect
-TC_GAW_CL_BI_14_C INC gatttool required
+TC_GAW_CL_BI_14_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 225 [u1] 22
+ gattc disconnect
TC_GAW_CL_BI_15_C PASS haltest:
gattc connect
gattc search_service
@@ -552,7 +561,10 @@ TC_GAW_CL_BV_08_C PASS haltest:
gattc get_descriptor
gattc write_descriptor 2 <short_value>
gattc disconnect
-TC_GAW_CL_BI_20_C INC gatttool required
+TC_GAW_CL_BI_20_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 225 [u1] 18
+ gattc disconnect
TC_GAW_CL_BI_21_C PASS haltest:
gattc connect
gattc search_service
@@ -593,7 +605,10 @@ TC_GAW_CL_BV_09_C PASS haltest:
gattc get_descriptor
gattc write_descriptor 2 <long_value>
gattc disconnect
-TC_GAW_CL_BI_25_C INC gatttool required
+TC_GAW_CL_BI_25_C PASS haltest:
+ gattc connect
+ test_command: <cmd> 225 [u1] 22
+ gattc disconnect
TC_GAW_CL_BI_26_C PASS haltest:
gattc connect
gattc search_service
--
1.9.3


2014-05-29 13:05:03

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 5/6] android/gatt: Support exec write request test command

'u2' parameter is used to pass exec write flag.
---
android/gatt.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/android/gatt.c b/android/gatt.c
index 81f8834..6708718 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3488,6 +3488,8 @@ static uint8_t handle_test_command_read_write(bdaddr_t *bdaddr, bt_uuid_t *uuid,
pdu, mtu);
break;
case ATT_OP_EXEC_WRITE_REQ:
+ length = enc_exec_write_req(u2, pdu, mtu);
+ break;
default:
error("gatt: Unknown operation type");

--
1.9.3


2014-05-29 13:05:02

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 4/6] android/gatt: Support prepare write request test command

'u2' parameter is used for handle value, 'u3' for offset and
'u4' holds the value.
---
android/gatt.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/android/gatt.c b/android/gatt.c
index dfa1a4f..81f8834 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3484,6 +3484,9 @@ static uint8_t handle_test_command_read_write(bdaddr_t *bdaddr, bt_uuid_t *uuid,
mtu);
break;
case ATT_OP_PREP_WRITE_REQ:
+ length = enc_prep_write_req(u2, u3, (uint8_t *) &u4, sizeof(u4),
+ pdu, mtu);
+ break;
case ATT_OP_EXEC_WRITE_REQ:
default:
error("gatt: Unknown operation type");
--
1.9.3


2014-05-29 13:05:01

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 3/6] android/gatt: Support write command test command

'u2' parameter is used to pass handle value.
---
android/gatt.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/android/gatt.c b/android/gatt.c
index 85c7b84..dfa1a4f 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3480,6 +3480,9 @@ static uint8_t handle_test_command_read_write(bdaddr_t *bdaddr, bt_uuid_t *uuid,
mtu);
break;
case ATT_OP_WRITE_CMD:
+ length = enc_write_cmd(u2, (uint8_t *) &u3, sizeof(u3), pdu,
+ mtu);
+ break;
case ATT_OP_PREP_WRITE_REQ:
case ATT_OP_EXEC_WRITE_REQ:
default:
--
1.9.3


2014-05-29 13:05:00

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 2/6] android/gatt: Support write request test command

'u2' parameter is used to pass handle value.
---
android/gatt.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/android/gatt.c b/android/gatt.c
index 5919377..85c7b84 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3476,6 +3476,9 @@ static uint8_t handle_test_command_read_write(bdaddr_t *bdaddr, bt_uuid_t *uuid,
case ATT_OP_READ_MULTI_REQ:
return HAL_STATUS_UNSUPPORTED;
case ATT_OP_WRITE_REQ:
+ length = enc_write_req(u2, (uint8_t *) &u3, sizeof(u3), pdu,
+ mtu);
+ break;
case ATT_OP_WRITE_CMD:
case ATT_OP_PREP_WRITE_REQ:
case ATT_OP_EXEC_WRITE_REQ:
--
1.9.3