diff mbox series

[BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data

Message ID 20220512005515.844857-1-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Commit 83497bbb307fcc6eb7f11e996c9bfdbd97147a7e
Headers show
Series [BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint fail [BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data 1: T1 Title exceeds max length (86>80): "[BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data"
tedd_an/setupell success Setup ELL PASS
tedd_an/buildprep success Build Prep PASS
tedd_an/build success Build Configuration PASS
tedd_an/makecheck success Make Check PASS
tedd_an/makecheckvalgrind success Make Check PASS
tedd_an/makedistcheck success Make Distcheck PASS
tedd_an/build_extell success Build External ELL PASS
tedd_an/build_extell_make success Build Make with External ELL PASS

Commit Message

Luiz Augusto von Dentz May 12, 2022, 12:55 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes gatt_db_attribute_get_char_data work with Characteristic
Value rather than only with Characteristic Declaration.
---
 src/shared/gatt-db.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

bluez.test.bot@gmail.com May 12, 2022, 3:16 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=640776

---Test result---

Test Summary:
CheckPatch                    PASS      1.66 seconds
GitLint                       FAIL      1.10 seconds
Prep - Setup ELL              PASS      52.47 seconds
Build - Prep                  PASS      0.82 seconds
Build - Configure             PASS      10.66 seconds
Build - Make                  PASS      1520.85 seconds
Make Check                    PASS      13.21 seconds
Make Check w/Valgrind         PASS      538.52 seconds
Make Distcheck                PASS      281.07 seconds
Build w/ext ELL - Configure   PASS      10.57 seconds
Build w/ext ELL - Make        PASS      1484.25 seconds
Incremental Build with patchesPASS      0.00 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint with rule in .gitlint
Output:
[BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data
1: T1 Title exceeds max length (86>80): "[BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data"




---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org May 13, 2022, midnight UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Wed, 11 May 2022 17:55:14 -0700 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This makes gatt_db_attribute_get_char_data work with Characteristic
> Value rather than only with Characteristic Declaration.
> ---
>  src/shared/gatt-db.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)

Here is the summary with links:
  - [BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=83497bbb307f

You are awesome, thank you!
diff mbox series

Patch

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 4f5d10b57..d3b5cec1d 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -1528,7 +1528,7 @@  void gatt_db_service_foreach_char(struct gatt_db_attribute *attrib,
 	gatt_db_service_foreach(attrib, &characteristic_uuid, func, user_data);
 }
 
-static int gatt_db_attribute_get_index(struct gatt_db_attribute *attrib)
+static int gatt_db_attribute_get_index(const struct gatt_db_attribute *attrib)
 {
 	struct gatt_db_service *service;
 	int index;
@@ -1853,8 +1853,18 @@  bool gatt_db_attribute_get_char_data(const struct gatt_db_attribute *attrib,
 	if (!attrib)
 		return false;
 
-	if (bt_uuid_cmp(&characteristic_uuid, &attrib->uuid))
-		return false;
+	if (bt_uuid_cmp(&characteristic_uuid, &attrib->uuid)) {
+		int index;
+
+		/* Check if Characteristic Value was passed instead */
+		index = gatt_db_attribute_get_index(attrib);
+		if (index < 0)
+			return NULL;
+
+		attrib = attrib->service->attributes[index - 1];
+		if (bt_uuid_cmp(&characteristic_uuid, &attrib->uuid))
+			return false;
+	}
 
 	/*
 	 * Characteristic declaration value: