From: Luiz Augusto von Dentz Date: Fri, 24 Mar 2023 23:38:53 +0000 (-0700) Subject: shared/gatt-db: Make gatt_db_attribute_get_value public X-Git-Tag: accepted/tizen/unified/20240117.163238~273 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df61af59be6fb9b218c7541f09387911ef8f8257;p=platform%2Fupstream%2Fbluez.git 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. --- diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 117646b..064f73a 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -1560,7 +1560,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; @@ -1570,18 +1570,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 05deae5..771d291 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,