diff mbox series

[BlueZ,v1] gatt-database: Fix error registering characteristic with Handle 0x0000

Message ID 20240503145238.3771921-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,v1] gatt-database: Fix error registering characteristic with Handle 0x0000 | expand

Commit Message

Luiz Augusto von Dentz May 3, 2024, 2:52 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Registering a characteristic with handle 0x0000 means that the
application wants a handles to be auto allocated but requires to be
informed of what values they end up in the database.

Fixes: https://github.com/bluez/bluez/issues/821
---
 src/gatt-database.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

patchwork-bot+bluetooth@kernel.org May 6, 2024, 2:20 p.m. UTC | #1
Hello:

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

On Fri,  3 May 2024 10:52:38 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> Registering a characteristic with handle 0x0000 means that the
> application wants a handles to be auto allocated but requires to be
> informed of what values they end up in the database.
> 
> Fixes: https://github.com/bluez/bluez/issues/821
> 
> [...]

Here is the summary with links:
  - [BlueZ,v1] gatt-database: Fix error registering characteristic with Handle 0x0000
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f34cc1da5081

You are awesome, thank you!
diff mbox series

Patch

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 5823aebcbfdb..5756eb9d17cb 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -3334,12 +3334,12 @@  static void database_add_includes(struct external_service *service)
 static bool database_add_chrc(struct external_service *service,
 						struct external_chrc *chrc)
 {
-	uint16_t handle;
+	uint16_t handle = 0, value_handle;
 	bt_uuid_t uuid;
 	char str[MAX_LEN_UUID_STR];
 	const struct queue_entry *entry;
 
-	if (!parse_handle(chrc->proxy, &handle)) {
+	if (!parse_handle(chrc->proxy, &value_handle)) {
 		error("Failed to read \"Handle\" property of characteristic");
 		return false;
 	}
@@ -3354,8 +3354,11 @@  static bool database_add_chrc(struct external_service *service,
 		return false;
 	}
 
+	if (value_handle)
+		handle = value_handle - 1;
+
 	chrc->attrib = gatt_db_service_insert_characteristic(service->attrib,
-						handle - 1, handle, &uuid,
+						handle, value_handle, &uuid,
 						chrc->perm, chrc->props,
 						chrc_read_cb, chrc_write_cb,
 						chrc);