From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 7/8] client: Enable list-attributes to print local attributes
Date: Wed, 30 Jan 2019 15:54:23 +0200 [thread overview]
Message-ID: <20190130135424.2091-7-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20190130135424.2091-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
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
---
client/gatt.c | 42 ++++++++++++++++++++++++++++++++++++++++++
client/main.c | 15 ++++++++++++---
2 files changed, 54 insertions(+), 3 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);
}
diff --git a/client/main.c b/client/main.c
index 07c8ec008..16433f96d 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1905,12 +1905,21 @@ static void cmd_disconn(int argc, char *argv[])
static void cmd_list_attributes(int argc, char *argv[])
{
GDBusProxy *proxy;
+ const char *path;
+
+ if (argc > 1 && !strcmp(argv[1], "local")) {
+ path = argv[1];
+ goto done;
+ }
proxy = find_device(argc, argv);
if (!proxy)
return bt_shell_noninteractive_quit(EXIT_FAILURE);
- gatt_list_attributes(g_dbus_proxy_get_path(proxy));
+ path = g_dbus_proxy_get_path(proxy);
+
+done:
+ gatt_list_attributes(path);
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
@@ -2596,8 +2605,8 @@ static const struct bt_shell_menu gatt_menu = {
.name = "gatt",
.desc = "Generic Attribute Submenu",
.entries = {
- { "list-attributes", "[dev]", cmd_list_attributes, "List attributes",
- dev_generator },
+ { "list-attributes", "[dev/local]", cmd_list_attributes,
+ "List attributes", dev_generator },
{ "select-attribute", "<attribute/UUID>", cmd_select_attribute,
"Select attribute", attribute_generator },
{ "attribute-info", "[attribute/UUID]", cmd_attribute_info,
--
2.17.2
next prev parent reply other threads:[~2019-01-30 13:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-30 13:54 [PATCH v2 1/8] doc/gatt-api: Add Handle property Luiz Augusto von Dentz
2019-01-30 13:54 ` [PATCH v2 2/8] shared/gatt-db: Allow passing 0 as handle to gatt_db_insert_* Luiz Augusto von Dentz
2019-01-30 13:54 ` [PATCH v2 3/8] gatt: Implement Handle property Luiz Augusto von Dentz
2019-01-30 13:54 ` [PATCH v2 4/8] gatt: Write back the handle to " Luiz Augusto von Dentz
2019-01-30 13:54 ` [PATCH v2 5/8] client: Enable Handle property for GATT attributes Luiz Augusto von Dentz
2019-01-30 13:54 ` [PATCH v2 6/8] client: Enable setting attribute handles Luiz Augusto von Dentz
2019-01-30 13:54 ` Luiz Augusto von Dentz [this message]
2019-01-30 13:54 ` [PATCH v2 8/8] client: Don't expose pointer value in attribute path Luiz Augusto von Dentz
2019-01-31 12:17 ` [PATCH v2 1/8] doc/gatt-api: Add Handle property Luiz Augusto von Dentz
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=20190130135424.2091-7-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;
as well as URLs for NNTP newsgroup(s).