diff --git a/client/gatt.c b/client/gatt.c
index 47785a8..7c44a9f 100644
--- a/client/gatt.c
+++ b/client/gatt.c
print_descriptor(proxy, COLORED_DEL);
}
+
+static void list_attributes(const char *path, GList *source)
+{
+ GList *l;
+
+ for (l = source; l; l = g_list_next(l)) {
+ GDBusProxy *proxy = l->data;
+ const char *proxy_path;
+
+ proxy_path = g_dbus_proxy_get_path(proxy);
+
+ if (!g_str_has_prefix(proxy_path, path))
+ continue;
+
+ if (source == services) {
+ print_service(proxy, NULL);
+ list_attributes(proxy_path, characteristics);
+ } else if (source == characteristics) {
+ print_characteristic(proxy, NULL);
+ list_attributes(proxy_path, descriptors);
+ } else if (source == descriptors)
+ print_descriptor(proxy, NULL);
+ }
+}
+
+void gatt_list_attributes(const char *path)
+{
+ list_attributes(path, services);
+}
diff --git a/client/gatt.h b/client/gatt.h
index 8b30668..5785073 100644
--- a/client/gatt.h
+++ b/client/gatt.h
void gatt_add_descriptor(GDBusProxy *proxy);
void gatt_remove_descriptor(GDBusProxy *proxy);
+
+void gatt_list_attributes(const char *device);
diff --git a/client/main.c b/client/main.c
index 72223d5..7cdb19a 100644
--- a/client/main.c
+++ b/client/main.c
rl_printf("Attempting to disconnect from %s\n", arg);
}
+static void cmd_list_attributes(const char *arg)
+{
+ GDBusProxy *proxy;
+
+ proxy = find_device(arg);
+ if (!proxy)
+ return;
+
+ gatt_list_attributes(g_dbus_proxy_get_path(proxy));
+}
+
static void cmd_version(const char *arg)
{
rl_printf("Version %s\n", VERSION);
dev_generator },
{ "disconnect", "[dev]", cmd_disconn, "Disconnect device",
dev_generator },
+ { "list-attributes", "[dev]", cmd_list_attributes, "List attributes",
+ dev_generator },
{ "version", NULL, cmd_version, "Display version" },
{ "quit", NULL, cmd_quit, "Quit program" },
{ "exit", NULL, cmd_quit },