diff options
author | Jakub Tyszkowski <jakub.tyszkowski@tieto.com> | 2014-05-29 15:04:59 +0200 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-05-29 16:20:40 +0200 |
commit | 23f5f2fc3c4800ac4f132883bf8565f3af004309 (patch) | |
tree | c1843ef8c1d0549cd11e28ebc74e10c50a55c558 | |
parent | be129c891adb2b9709adbd455811b388afd54947 (diff) | |
download | bluez-23f5f2fc3c4800ac4f132883bf8565f3af004309.tar.gz |
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).
-rw-r--r-- | android/gatt.c | 21 | ||||
-rw-r--r-- | android/hal-msg.h | 1 |
2 files changed, 14 insertions, 8 deletions
diff --git a/android/gatt.c b/android/gatt.c index 9b51ab1ef..c455695fb 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -3442,9 +3442,9 @@ 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 test_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 +3459,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 +3473,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,9 +3537,9 @@ 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, - cmd->u2, cmd->u3, - cmd->u4, cmd->u5); + case GATT_CLIENT_TEST_CMD_WRITE: + status = test_read_write(&bdaddr, &uuid, cmd->u1, cmd->u2, + cmd->u3, cmd->u4, cmd->u5); break; case GATT_CLIENT_TEST_CMD_PAIRING_CONFIG: default: diff --git a/android/hal-msg.h b/android/hal-msg.h index ae1549900..5da62f38b 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 |