All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: szymon.janc@tieto.com, johan.hedberg@gmail.com,
	Marcin Kraglak <marcin.kraglak@tieto.com>
Subject: [PATCH v4 24/38] shared/gatt: Add function to find information
Date: Wed, 30 Apr 2014 11:13:55 +0200	[thread overview]
Message-ID: <1398849249-5868-25-git-send-email-lukasz.rymanowski@tieto.com> (raw)
In-Reply-To: <1398849249-5868-1-git-send-email-lukasz.rymanowski@tieto.com>

From: Marcin Kraglak <marcin.kraglak@tieto.com>

It will return list of handle and uuid
---
 src/shared/gatt-db.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/shared/gatt-db.h |  9 ++++++++
 2 files changed, 67 insertions(+)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 60d3140..cbdd8a0 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -613,3 +613,61 @@ void gatt_db_read_by_type(struct gatt_db *db, uint16_t start_handle,
 
 	queue_foreach(db->services, read_by_type, &data);
 }
+
+
+struct find_information_data {
+	struct queue *queue;
+	uint16_t start_handle;
+	uint16_t end_handle;
+};
+
+static void find_information(void *data, void *user_data)
+{
+	struct find_information_data *search_data = user_data;
+	struct gatt_db_service *service = data;
+	struct gatt_db_attribute *attribute;
+	struct gatt_db_find_information *value;
+	int i;
+
+	if (!service->active)
+		return;
+
+	/* Check if service is in range */
+	if ((service->attributes[0]->handle + service->num_handles - 1) <
+						search_data->start_handle)
+		return;
+
+	for (i = 0; i < service->num_handles; i++) {
+		attribute = service->attributes[i];
+		if (!attribute)
+			continue;
+
+		if (attribute->handle < search_data->start_handle)
+			continue;
+
+		if (attribute->handle > search_data->end_handle)
+			return;
+
+		value = new0(struct gatt_db_find_information, 1);
+		if (!value)
+			return;
+
+		value->handle = attribute->handle;
+		value->uuid = attribute->uuid;
+		if (!queue_push_tail(search_data->queue, value))
+			free(value);
+	}
+}
+
+void gatt_db_find_information(struct gatt_db *db, uint16_t start_handle,
+							uint16_t end_handle,
+							struct queue *queue)
+{
+	struct find_information_data data;
+
+	data.start_handle = start_handle;
+	data.end_handle = end_handle;
+	data.queue = queue;
+
+	queue_foreach(db->services, find_information, &data);
+}
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index b5f9073..a91c798 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
@@ -95,3 +95,12 @@ void gatt_db_read_by_type(struct gatt_db *db, uint16_t start_handle,
 							uint16_t end_handle,
 							const bt_uuid_t type,
 							struct queue *queue);
+
+struct gatt_db_find_information {
+	uint16_t handle;
+	bt_uuid_t uuid;
+};
+
+void gatt_db_find_information(struct gatt_db *db, uint16_t start_handle,
+							uint16_t end_handle,
+							struct queue *queue);
-- 
1.8.4


  parent reply	other threads:[~2014-04-30  9:13 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-30  9:13 [PATCH v4 00/38] android/gatt: GATT server implementation Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 01/38] android/gatt: Rename listen_clients to listen_apps Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 02/38] android/gatt: Remove redundant find function parameter Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 03/38] android/gatt: Add service functionality Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 04/38] android/gatt: Add implementation of delete service Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 05/38] android/gatt: Add included service implementation Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 06/38] android/gatt: Add characteristic implementation Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 07/38] android/gatt: Add handling of start service command Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 08/38] android/gatt: Add stop service command handling Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 09/38] android/gatt: Add descriptor implementation Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 10/38] android/gatt: Add listening socket for GATT Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 11/38] android/gatt: Assume that each server wants waits for connection Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 12/38] android/gatt: Add ATT msg handler Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 13/38] shared/gatt: Use bdaddr instead of request_id Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 14/38] shared/gatt: Extend read/write callback with offset Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 15/38] shared/gatt: Add att_opcode to read/write callback Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 16/38] android/bluetooth: Add function for getting device Android name Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 17/38] android/gatt: Add register GAP Service Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 18/38] gatt: Add some characteristics uuids Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 19/38] android/gatt: Register device information service Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 20/38] android/gatt: Register GATT service Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 21/38] shared/gatt: Add function to read by group type Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 22/38] shared/gatt: Add function to find by type Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 23/38] shared/gatt: Add function to read " Lukasz Rymanowski
2014-04-30  9:13 ` Lukasz Rymanowski [this message]
2014-04-30  9:13 ` [PATCH v4 25/38] android/gatt: Add support for ATT read by group type Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 26/38] android/gatt: Add support for ATT read by type Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 27/38] shared/gatt: Add support to read from database Lukasz Rymanowski
2014-04-30  9:13 ` [PATCH v4 28/38] android/gatt: Add support to read request Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 29/38] android/gatt: Add MTU request cmd handling Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 30/38] android/gatt: Add Find info gatt server " Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 31/38] shared/gatt: Add support for write request Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 32/38] android/gatt: " Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 33/38] android/gatt: Add support for execute write Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 34/38] android/gatt: Add write_cb to GATT server Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 35/38] android/gatt: Add read_cb for GATT Server Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 36/38] android/hal-gatt-api: Fix IPC definition for send response Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 37/38] android/gatt: Add support for GATT server " Lukasz Rymanowski
2014-04-30  9:14 ` [PATCH v4 38/38] android/gatt: Add support for send indication Lukasz Rymanowski
2014-04-30 11:31 ` [PATCH v4 00/38] android/gatt: GATT server implementation Szymon Janc
2014-04-30 15:31 ` 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=1398849249-5868-25-git-send-email-lukasz.rymanowski@tieto.com \
    --to=lukasz.rymanowski@tieto.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcin.kraglak@tieto.com \
    --cc=szymon.janc@tieto.com \
    /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 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.