Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcin Kraglak <marcin.kraglak@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCHv3 4/8] android/gatt: Add implementation of get_included_cb
Date: Fri, 28 Mar 2014 10:45:55 +0100	[thread overview]
Message-ID: <1395999959-2396-4-git-send-email-marcin.kraglak@tieto.com> (raw)
In-Reply-To: <1395999959-2396-1-git-send-email-marcin.kraglak@tieto.com>

It will pass found services to upper layer with notification.
Caching included services should be done later.
---
 android/gatt.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index e2accb7..9c17963 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -974,10 +974,52 @@ struct get_included_data {
 
 static void get_included_cb(uint8_t status, GSList *included, void *user_data)
 {
+	struct hal_ev_gatt_client_get_inc_service ev;
 	struct get_included_data *data = user_data;
+	struct gatt_device *device = data->device;
+	struct service *service = data->service;
+	bt_uuid_t uuid;
+
+	DBG("");
 
-	/* TODO pass included services to notification */
 	free(data);
+
+	if (status) {
+		error("gatt: no included services found");
+		return;
+	}
+
+	bt_string_to_uuid(&uuid, service->primary.uuid);
+
+	/* TODO store included services in device->services list */
+	for (; included; included = included->next) {
+		struct gatt_included *included_service = included->data;
+		bt_uuid_t included_uuid;
+
+		ev.conn_id = device->conn_id;
+		ev.status = HAL_STATUS_SUCCESS;
+
+		ev.srvc_id.inst_id = 0;
+		uuid2android(&uuid, ev.srvc_id.uuid);
+
+		ev.incl_srvc_id.inst_id = 0;
+		bt_string_to_uuid(&included_uuid, included_service->uuid);
+		uuid2android(&included_uuid, ev.incl_srvc_id.uuid);
+
+		ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT ,
+					HAL_EV_GATT_CLIENT_GET_INC_SERVICE,
+					sizeof(ev), &ev);
+	}
+
+	/* Android expects notification with error status in the end */
+	ev.conn_id = device->conn_id;
+	ev.status = HAL_STATUS_FAILED;
+	ev.srvc_id.inst_id = 0;
+	uuid2android(&uuid, ev.srvc_id.uuid);
+
+	ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT ,
+					HAL_EV_GATT_CLIENT_GET_INC_SERVICE,
+					sizeof(ev), &ev);
 }
 
 static void handle_client_get_included_service(const void *buf, uint16_t len)
-- 
1.8.3.1


  parent reply	other threads:[~2014-03-28  9:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28  9:45 [PATCHv3 1/8] android/gatt: Add helper for getting device by conn_id Marcin Kraglak
2014-03-28  9:45 ` [PATCHv3 2/8] android/gatt: Add initial implementation of get_included_service Marcin Kraglak
2014-03-28  9:45 ` [PATCHv3 3/8] android/gatt: Add get_included_data struct and callback Marcin Kraglak
2014-03-28  9:45 ` Marcin Kraglak [this message]
2014-03-28  9:45 ` [PATCHv3 5/8] android/gatt: Add initial implementation of register_for_notification Marcin Kraglak
2014-03-28  9:45 ` [PATCHv3 6/8] android/gatt: Add send_register_for_notif_ev function Marcin Kraglak
2014-03-28  9:45 ` [PATCHv3 7/8] android/gatt: Add handler for ATT_OP_HANDLE_NOTIFY and ATT_OP_HANDLE_IND Marcin Kraglak
2014-03-28  9:45 ` [PATCHv3 8/8] android/gatt: Add deregister_for_notification implementation Marcin Kraglak
2014-03-28 10:28 ` [PATCHv3 1/8] android/gatt: Add helper for getting device by conn_id Szymon Janc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395999959-2396-4-git-send-email-marcin.kraglak@tieto.com \
    --to=marcin.kraglak@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox