summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-03-24 16:38:53 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-03-27 13:56:48 -0700
commit7610b9264147c387e0c12d17221ae83f97add776 (patch)
treee3d277d2c689fc55ed8152503a89f729197c1c92 /src
parentfb1c694100b2aff6ee1ad69d2a07c0f122e2e929 (diff)
downloadbluez-7610b9264147c387e0c12d17221ae83f97add776.tar.gz
shared/gatt-db: Make gatt_db_attribute_get_value public
This makes gatt_db_attribute_get_value public so it can be used by the likes of btmon.
Diffstat (limited to 'src')
-rw-r--r--src/shared/gatt-db.c12
-rw-r--r--src/shared/gatt-db.h2
2 files changed, 8 insertions, 6 deletions
diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index b696fe33d..676f963ec 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -1549,7 +1549,7 @@ static int gatt_db_attribute_get_index(const struct gatt_db_attribute *attrib)
return -1;
}
-static struct gatt_db_attribute *
+struct gatt_db_attribute *
gatt_db_attribute_get_value(struct gatt_db_attribute *attrib)
{
struct gatt_db_service *service;
@@ -1559,18 +1559,18 @@ gatt_db_attribute_get_value(struct gatt_db_attribute *attrib)
return NULL;
index = gatt_db_attribute_get_index(attrib);
- if (index < 0)
+ if (index <= 0)
return NULL;
service = attrib->service;
if (!bt_uuid_cmp(&characteristic_uuid, &attrib->uuid))
- index++;
- else if (bt_uuid_cmp(&characteristic_uuid,
+ return service->attributes[index + 1];
+ else if (!bt_uuid_cmp(&characteristic_uuid,
&service->attributes[index - 1]->uuid))
- return NULL;
+ return service->attributes[index];
- return service->attributes[index];
+ return gatt_db_attribute_get_value(service->attributes[index - 1]);
}
void gatt_db_service_foreach_desc(struct gatt_db_attribute *attrib,
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index 163a981df..fb939e40d 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
@@ -285,6 +285,8 @@ bool gatt_db_attribute_write_result(struct gatt_db_attribute *attrib,
unsigned int id, int err);
struct gatt_db_attribute *
+gatt_db_attribute_get_value(struct gatt_db_attribute *attrib);
+struct gatt_db_attribute *
gatt_db_attribute_get_ccc(struct gatt_db_attribute *attrib);
bool gatt_db_attribute_notify(struct gatt_db_attribute *attrib,