All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv4 1/7] android/gatt: Add initial implementation of get_included_service
@ 2014-03-28 10:49 Marcin Kraglak
  2014-03-28 10:49 ` [PATCHv4 2/7] android/gatt: Add get_included_data struct and callback Marcin Kraglak
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Marcin Kraglak @ 2014-03-28 10:49 UTC (permalink / raw)
  To: linux-bluetooth

It will look for included service in range passed in command.
It call gatt_find_included(), but without result callback now,
as it is initial version.
---
 android/gatt.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index 92e16d4..cf0ad61 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -949,13 +949,67 @@ reply:
 			HAL_OP_GATT_CLIENT_SEARCH_SERVICE, status);
 }
 
+static bool match_service_by_uuid(const void *data, const void *user_data)
+{
+	const struct service *service = data;
+	const bt_uuid_t *uuid = user_data;
+	bt_uuid_t service_uuid;
+
+	if (bt_string_to_uuid(&service_uuid, service->primary.uuid) < 0)
+		return false;
+
+	return !bt_uuid_cmp(uuid, &service_uuid);
+}
+
+static struct service *find_service_by_uuid(struct gatt_device *device,
+								bt_uuid_t *uuid)
+{
+	return queue_find(device->services, match_service_by_uuid, uuid);
+}
+
 static void handle_client_get_included_service(const void *buf, uint16_t len)
 {
+	const struct hal_cmd_gatt_client_get_included_service *cmd = buf;
+	struct gatt_device *device;
+	struct service *service;
+	uint8_t status;
+
 	DBG("");
 
+	device = find_device_by_conn_id(cmd->conn_id);
+	if (!device) {
+		status = HAL_STATUS_FAILED;
+		goto failed;
+	}
+
+	if (queue_isempty(device->services)) {
+		status = HAL_STATUS_FAILED;
+		goto failed;
+	}
+
+	if (!cmd->number) {
+		service = queue_peek_head(device->services);
+	} else {
+		bt_uuid_t uuid;
+
+		android2uuid(cmd->srvc_id->uuid, &uuid);
+		service = find_service_by_uuid(device, &uuid);
+	}
+
+	if (!service) {
+		status = HAL_STATUS_FAILED;
+		goto failed;
+	}
+
+	gatt_find_included(device->attrib, service->primary.range.start,
+					service->primary.range.end, NULL, NULL);
+
+	status = HAL_STATUS_SUCCESS;
+
+failed:
 	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
 					HAL_OP_GATT_CLIENT_GET_INCLUDED_SERVICE,
-					HAL_STATUS_FAILED);
+					status);
 }
 
 static void send_client_char_notify(const struct characteristic *ch,
-- 
1.8.3.1


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

end of thread, other threads:[~2014-03-28 12:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-28 10:49 [PATCHv4 1/7] android/gatt: Add initial implementation of get_included_service Marcin Kraglak
2014-03-28 10:49 ` [PATCHv4 2/7] android/gatt: Add get_included_data struct and callback Marcin Kraglak
2014-03-28 10:49 ` [PATCHv4 3/7] android/gatt: Add implementation of get_included_cb Marcin Kraglak
2014-03-28 10:49 ` [PATCHv4 4/7] android/gatt: Add initial implementation of register_for_notification Marcin Kraglak
2014-03-28 10:49 ` [PATCHv4 5/7] android/gatt: Add send_register_for_notif_ev function Marcin Kraglak
2014-03-28 10:49 ` [PATCHv4 6/7] android/gatt: Add handler for ATT_OP_HANDLE_NOTIFY and ATT_OP_HANDLE_IND Marcin Kraglak
2014-03-28 10:49 ` [PATCHv4 7/7] android/gatt: Add deregister_for_notification implementation Marcin Kraglak
2014-03-28 12:28 ` [PATCHv4 1/7] android/gatt: Add initial implementation of get_included_service Szymon Janc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.