client/btpclient: Add GATT support to get Device name
Subsystems (2)
PATCH v3 1/1 client/btpclient: Add GATT support to get Device name
Add GATT support to btpclient so the it can read the "Device Name" characteristic (UUID 0x2A00) from the DBus interface resolved during device connection.
The device connected event is postponed until ServicesResolved property is set to true to ensure that the services, characteristics and descriptors lists has been fully populated.
This allows to pass GAP/IDLE/NAMP/BV-01-C.
---
v1 -> v2: Fix memory leak
v2 -> v3:
- Rebase to client/btpclient
- store attributes informations
- postponed connection event after services are resolved
- Rework it to read UUID to get real attribute value
Makefile.tools | 3 +- client/btpclient/btpclient.c | 239 ++++++++++++++++++++++++++++++++++- client/btpclient/btpclient.h | 9 ++ client/btpclient/core.c | 14 ++ client/btpclient/gap.c | 22 +++- client/btpclient/gatt.c | 215 +++++++++++++++++++++++++++++++ client/btpclient/gatt.h | 13 ++ src/shared/btp.h | 24 ++++ 8 files changed, 534 insertions(+), 5 deletions(-) create mode 100644 client/btpclient/gatt.c create mode 100644 client/btpclient/gatt.h
Makefile.tools +2 -1
@@ -589,7 +589,8 @@ client_btpclient_btpclient_SOURCES = client/btpclient/btpclient.c \ client/btpclient/btpclient.h \ src/shared/btp.c src/shared/btp.h \ client/btpclient/core.c client/btpclient/core.h \ - client/btpclient/gap.c client/btpclient/gap.h + client/btpclient/gap.c client/btpclient/gap.h \ + client/btpclient/gatt.c client/btpclient/gatt.h client_btpclient_btpclient_LDADD = lib/libbluetooth-internal.la \ src/libshared-ell.la $(ell_ldadd) client/btpclient/btpclient.$(OBJEXT): src/libshared-ell.la ell/internal
client/btpclient/btpclient.c +238 -1
285 lines not on this page · raw message
client/btpclient/btpclient.h +9 -0
@@ -21,6 +21,9 @@ struct btp_device {struct l_dbus_proxy *proxy;uint8_t address_type;bdaddr_t address; +struct l_queue *services; +struct l_queue *characteristics; +struct l_queue *descriptors; };struct btp_agent {
@@ -29,6 +32,12 @@ struct btp_agent {struct l_dbus_message *pending_req; }; +struct gatt_attribute { +struct l_dbus_proxy *proxy; +uint16_t handle; +bt_uuid_t uuid; +}; +struct l_queue *get_adapters_list (void );struct btp_adapter *find_adapter_by_proxy (struct l_dbus_proxy *proxy);struct btp_adapter *find_adapter_by_index (uint8_t index);
client/btpclient/core.c +14 -0
@@ -10,10 +10,12 @@#include <ell/ell.h> #include "bluetooth/bluetooth.h" +#include "bluetooth/uuid.h" #include "src/shared/btp.h" #include "btpclient.h" #include "core.h" #include "gap.h" +#include "gatt.h" static struct btp *btp;static struct l_dbus *dbus;
@@ -81,6 +83,13 @@ static void btp_core_register(uint8_t index, const void *param,return ;case BTP_GATT_SERVICE : +if (gatt_is_service_registered ()) + goto failed; + +if (!gatt_register_service (btp, dbus, client)) + goto failed; + +break ;case BTP_L2CAP_SERVICE :case BTP_MESH_NODE_SERVICE :case BTP_CORE_SERVICE :
@@ -118,6 +127,11 @@ static void btp_core_unregister(uint8_t index, const void *param,gap_unregister_service ();break ;case BTP_GATT_SERVICE : +if (!gatt_is_service_registered ()) + goto failed; + +gatt_unregister_service (btp); +break ;case BTP_L2CAP_SERVICE :case BTP_MESH_NODE_SERVICE :case BTP_CORE_SERVICE :
client/btpclient/gap.c +19 -3
@@ -16,6 +16,7 @@#include <ell/ell.h> #include "bluetooth/bluetooth.h" +#include "bluetooth/uuid.h" #include "src/shared/btp.h" #include "btpclient.h" #include "core.h"
@@ -2381,7 +2382,7 @@ static void btp_gap_device_found_ev(struct l_dbus_proxy *proxy)const char *str, *addr_str;int16_t rssi;uint8_t address_type; -bool connected; +bool connected, resolved;struct l_dbus_message_iter iter, var; ev =l_malloc (sizeof (struct btp_device_found_ev ));
@@ -2481,8 +2482,11 @@ static void btp_gap_device_found_ev(struct l_dbus_proxy *proxy)btp_send (btp,BTP_GAP_SERVICE ,BTP_EV_GAP_DEVICE_FOUND , adapter->index,sizeof (*ev) + ev->eir_len, ev); +/* Postponed BTP_EV_GAP_DEVICE_CONNECTED up to services are resolved */ if (l_dbus_proxy_get_property (proxy,"Connected" ,"b" , &connected) && - connected) { +l_dbus_proxy_get_property (proxy,"ServicesResolved" , +"b" , &resolved) && + connected && resolved) { ev_conn.address_type = address_type;str2ba (addr_str, &ev_conn.address);
@@ -2700,12 +2704,24 @@ void gap_property_changed(struct l_dbus_proxy *proxy, const char *name,if (!l_dbus_message_get_arguments (msg,"b" , &prop))return ; -btp_gap_device_connection_ev (proxy, prop); +/* Send disconnection event and postponed connection +* event up to services are resolved. +*/ +if (!prop) +btp_gap_device_connection_ev (proxy, prop); }else if (!strcmp (name,"AddressType" )) {/* Address property change came first along with address * type. */ btp_identity_resolved_ev (proxy); + }else if (!strcmp (name,"ServicesResolved" )) { +bool prop; + +if (!l_dbus_message_get_arguments (msg,"b" , &prop)) +return ; + +if (prop) +btp_gap_device_connection_ev (proxy, prop); } } }
client/btpclient/gatt.c new file +215 -0
215 lines not on this page · raw message
client/btpclient/gatt.h new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2026 Collabora Ltd. +* +*/ + +bool gatt_register_service (struct btp *btp_,struct l_dbus *dbus_, +struct l_dbus_client *client); +void gatt_unregister_service (struct btp *btp); +bool gatt_is_service_registered (void );
src/shared/btp.h +24 -0
@@ -285,6 +285,30 @@ struct btp_gap_identity_resolved_ev {bdaddr_t identity_address; } __packed; +struct btp_gatt_char_value { +uint16_t handle; +uint8_t data_len; +uint8_t data[]; +} __packed; + +#define BTP_OP_GATT_READ_SUPPORTED_COMMANDS 0x01 + +#define BTP_OP_GATT_READ_UUID 0x12 +struct btp_gatt_read_uuid_cp { +uint8_t address_type; +bdaddr_t address; +uint16_t start_handle; +uint16_t end_handle; +uint8_t uuid_len; +uint8_t uuid[]; +} __packed; + +struct btp_gatt_read_uuid_rp { +uint8_t att_response; +uint8_t values_count; +struct btp_gatt_char_value values[]; +} __packed; +struct btp ;typedef void (*btp_destroy_func_t )(void *user_data);
Signature · 1 line
2.43.0
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=1055133
---Test result---
Test Summary:
CheckPatch PENDING 0.43 seconds GitLint PENDING 0.36 seconds BuildEll PASS 20.76 seconds BluezMake PASS 648.63 seconds MakeCheck PASS 18.57 seconds MakeDistcheck PASS 246.29 seconds CheckValgrind PASS 299.91 seconds CheckSmatch PASS 361.77 seconds bluezmakeextell PASS 184.36 seconds IncrementalBuild PENDING 0.44 seconds ScanBuild PASS 1033.91 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 9 lines · On Wed, 18 Feb 2026 09:52:06 +0100 you wrote:
Add GATT support to btpclient so the it can read the "Device Name" characteristic (UUID
0x2A00) from the DBus interface resolved during device connection.The device connected event is postponed until ServicesResolved property is set to true to ensure that the services, characteristics and descriptors lists has been fully populated.
[...]
Here is the summary with links:
- [BlueZ,v3] client/btpclient: Add GATT support to get Device name
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8d82d3e1e539
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html