From: Szymon Janc <szymon.janc@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Szymon Janc <szymon.janc@tieto.com>
Subject: [PATCH v2 4/5] shared/gatt: Add function for getting service UUID
Date: Thu, 10 Jul 2014 16:30:35 +0200 [thread overview]
Message-ID: <1405002636-10737-4-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1405002636-10737-1-git-send-email-szymon.janc@tieto.com>
---
src/shared/gatt-db.c | 31 +++++++++++++++++++++++++++++++
src/shared/gatt-db.h | 2 ++
2 files changed, 33 insertions(+)
diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 9cbf409..bd25d47 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -732,6 +732,37 @@ uint16_t gatt_db_get_end_handle(struct gatt_db *db, uint16_t handle)
return service->attributes[0]->handle + service->num_handles - 1;
}
+bool gatt_db_get_service_uuid(struct gatt_db *db, uint16_t handle,
+ bt_uuid_t *uuid)
+{
+ struct gatt_db_service *service;
+
+ service = queue_find(db->services, find_service_for_handle,
+ INT_TO_PTR(handle));
+ if (!service)
+ return false;
+
+ if (service->attributes[0]->value_len == 2) {
+ uint16_t value;
+
+ value = get_le16(service->attributes[0]->value);
+ bt_uuid16_create(uuid, value);
+
+ return true;
+ }
+
+ if (service->attributes[0]->value_len == 8) {
+ uint128_t value;
+
+ bswap_128(service->attributes[0]->value, &value);
+ bt_uuid128_create(uuid, value);
+
+ return true;
+ }
+
+ return false;
+}
+
bool gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle,
uint32_t *permissions)
{
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index a88f637..8d18434 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
@@ -91,6 +91,8 @@ const bt_uuid_t *gatt_db_get_attribute_type(struct gatt_db *db,
uint16_t handle);
uint16_t gatt_db_get_end_handle(struct gatt_db *db, uint16_t handle);
+bool gatt_db_get_service_uuid(struct gatt_db *db, uint16_t handle,
+ bt_uuid_t *uuid);
bool gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle,
uint32_t *permissions);
--
1.9.1
next prev parent reply other threads:[~2014-07-10 14:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-10 14:30 [PATCH v2 1/5] android/gatt: Add support for GATT over BR/EDR Szymon Janc
2014-07-10 14:30 ` [PATCH v2 2/5] android/bluetooth: Add function for checking last seen bearer Szymon Janc
2014-07-10 14:30 ` [PATCH v2 3/5] android/gatt: Choose LE or BR/EDR based on " Szymon Janc
2014-07-10 14:30 ` Szymon Janc [this message]
2014-07-10 14:30 ` [PATCH v2 5/5] android/gatt: Register SDP records for services Szymon Janc
2014-07-11 20:10 ` [PATCH v2 1/5] android/gatt: Add support for GATT over BR/EDR 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=1405002636-10737-4-git-send-email-szymon.janc@tieto.com \
--to=szymon.janc@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