summaryrefslogtreecommitdiff
path: root/client/gatt.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2019-01-29 16:20:41 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2019-01-31 14:10:54 +0200
commitd5cb29ce5a3b5a50e2e1487a7de9d0ddd9bd61c5 (patch)
treea3c329753db499af0a7a6614fe9698a7510ad7bb /client/gatt.c
parent918f6f932ba8d944786bede7069666361ce28482 (diff)
downloadbluez-d5cb29ce5a3b5a50e2e1487a7de9d0ddd9bd61c5.tar.gz
client: Enable list-attributes to print local attributes
This enable passing "local" to list-attributes to print the attributes registered locally: > list-attributes local Primary Service (Handle 0x0400) /org/bluez/app/service0x74ccb0 0x1820 Internet Protocol Support
Diffstat (limited to 'client/gatt.c')
-rw-r--r--client/gatt.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/client/gatt.c b/client/gatt.c
index 42fe795d7..8e06e793f 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -414,8 +414,50 @@ static void list_attributes(const char *path, GList *source)
}
}
+static void list_descs(GList *descs)
+{
+ GList *l;
+
+ for (l = descs; l; l = g_list_next(l)) {
+ struct desc *desc = l->data;
+
+ print_desc(desc, NULL);
+ }
+}
+
+static void list_chrcs(GList *chrcs)
+{
+ GList *l;
+
+ for (l = chrcs; l; l = g_list_next(l)) {
+ struct chrc *chrc = l->data;
+
+ print_chrc(chrc, NULL);
+
+ list_descs(chrc->descs);
+ }
+}
+
+static void list_services(void)
+{
+ GList *l;
+
+ for (l = local_services; l; l = g_list_next(l)) {
+ struct service *service = l->data;
+
+ print_service(service, NULL);
+
+ list_chrcs(service->chrcs);
+ }
+}
+
void gatt_list_attributes(const char *path)
{
+ if (path && !strcmp(path, "local")) {
+ list_services();
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+ }
+
list_attributes(path, services);
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}