linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] android/gatt: Add read test command stub
@ 2014-05-29 10:34 Jakub Tyszkowski
  2014-05-29 10:34 ` [PATCH 2/6] android/gatt: Support read request in test command Jakub Tyszkowski
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jakub Tyszkowski @ 2014-05-29 10:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-29 11:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-29 10:34 [PATCH 1/6] android/gatt: Add read test command stub Jakub Tyszkowski
2014-05-29 10:34 ` [PATCH 2/6] android/gatt: Support read request in test command Jakub Tyszkowski
2014-05-29 10:34 ` [PATCH 3/6] android/gatt: Suport read by type " Jakub Tyszkowski
2014-05-29 10:34 ` [PATCH 4/6] android/gatt: Support read blob " Jakub Tyszkowski
2014-05-29 10:34 ` [PATCH 5/6] android/gatt: Support read by group in test commands Jakub Tyszkowski
2014-05-29 10:34 ` [PATCH 6/6] android/pts: Update GATT PTS status Jakub Tyszkowski
2014-05-29 11:24 ` [PATCH 1/6] android/gatt: Add read test command stub Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).