From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/4] shared/gatt-db: Make gatt_db_attribute_get_value public
Date: Fri, 24 Mar 2023 16:38:53 -0700 [thread overview]
Message-ID: <20230324233856.3693370-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes gatt_db_attribute_get_value public so it can be used by the
likes of btmon.
---
src/shared/gatt-db.c | 12 ++++++------
src/shared/gatt-db.h | 2 ++
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index b696fe33da93..676f963eca94 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 163a981df233..fb939e40d40e 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
@@ -284,6 +284,8 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset,
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);
--
2.39.2
next reply other threads:[~2023-03-24 23:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 23:38 Luiz Augusto von Dentz [this message]
2023-03-24 23:38 ` [PATCH BlueZ 2/4] monitor/att: Print value when printing descriptors Luiz Augusto von Dentz
2023-03-24 23:38 ` [PATCH BlueZ 3/4] monitor/att: Fix not loading gatt_db for devices using RPA Luiz Augusto von Dentz
2023-03-24 23:38 ` [PATCH BlueZ 4/4] monitor: Cache IRK being parsed Luiz Augusto von Dentz
2023-03-25 2:27 ` [BlueZ,1/4] shared/gatt-db: Make gatt_db_attribute_get_value public bluez.test.bot
2023-03-27 21:20 ` [PATCH BlueZ 1/4] " patchwork-bot+bluetooth
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=20230324233856.3693370-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.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