[PATCH 2/4] shared/gatt: Add function to check if handle was found in database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux