From: Marcin Kraglak <marcin.kraglak@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 2/4] shared/gatt: Add function to check if handle was found in database
Date: Fri, 30 May 2014 07:51:12 +0200 [thread overview]
Message-ID: <1401429074-31535-2-git-send-email-marcin.kraglak@tieto.com> (raw)
In-Reply-To: <1401429074-31535-1-git-send-email-marcin.kraglak@tieto.com>
It will return true if attribute with given handle exists in db, otherwise
false.
---
src/shared/gatt-db.c | 18 ++++++++++++++++++
src/shared/gatt-db.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 998e93e..de1de57 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -758,3 +758,21 @@ uint32_t gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle)
return attribute->permissions;
}
+
+bool gatt_db_has_attribute(struct gatt_db *db, uint16_t handle)
+{
+ struct gatt_db_attribute *attribute;
+ struct gatt_db_service *service;
+ uint16_t service_handle;
+
+ service = queue_find(db->services, find_service_for_handle,
+ INT_TO_PTR(handle));
+ if (!service)
+ return false;
+
+ service_handle = service->attributes[0]->handle;
+
+ attribute = service->attributes[handle - service_handle];
+
+ return attribute ? true : false;
+}
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index f2f2f4d..ca36d32 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
@@ -93,3 +93,4 @@ const bt_uuid_t *gatt_db_get_attribute_type(struct gatt_db *db,
uint16_t gatt_db_get_end_handle(struct gatt_db *db, uint16_t handle);
uint32_t gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle);
+bool gatt_db_has_attribute(struct gatt_db *db, uint16_t handle);
--
1.9.0
next prev parent reply other threads:[~2014-05-30 5:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-30 5:51 [PATCH 1/4] android/gatt: Fix parallel reading/writing attributes values from applications Marcin Kraglak
2014-05-30 5:51 ` Marcin Kraglak [this message]
2014-05-30 8:32 ` [PATCH 2/4] shared/gatt: Add function to check if handle was found in database Luiz Augusto von Dentz
2014-05-30 9:16 ` Szymon Janc
2014-05-30 5:51 ` [PATCH 3/4] android/gatt: Chack if given handle exists " Marcin Kraglak
2014-05-30 5:51 ` [PATCH 4/4] android/gatt: Check for invalid handle errors Marcin Kraglak
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=1401429074-31535-2-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