linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] Add device set-alias bluetoothctl command
@ 2016-09-02  9:08 Francois Beaufort
  2016-09-02  9:08 ` Francois Beaufort
  0 siblings, 1 reply; 5+ messages in thread
From: Francois Beaufort @ 2016-09-02  9:08 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds support for setting a device alias from bluetoothctl.

Francois Beaufort (1):
  Add device set-alias bluetoothctl command

 client/main.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

-- 
2.7.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH BlueZ] Add device set-alias bluetoothctl command
  2016-09-02  9:08 [PATCH BlueZ] Add device set-alias bluetoothctl command Francois Beaufort
@ 2016-09-02  9:08 ` Francois Beaufort
  2016-09-02 14:14   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 5+ messages in thread
From: Francois Beaufort @ 2016-09-02  9:08 UTC (permalink / raw)
  To: linux-bluetooth

---
 client/main.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/client/main.c b/client/main.c
index 9ba5a40..e1198a8 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1666,6 +1666,30 @@ static void cmd_list_attributes(const char *arg)
 	gatt_list_attributes(g_dbus_proxy_get_path(proxy));
 }
 
+static void cmd_set_alias(const char *arg)
+{
+	char *name;
+
+	if (!arg || !strlen(arg)) {
+		rl_printf("Missing name argument\n");
+		return;
+	}
+
+	if (!default_dev) {
+		rl_printf("No device connected\n");
+		return;
+	}
+
+	name = g_strdup(arg);
+
+	if (g_dbus_proxy_set_property_basic(default_dev, "Alias",
+					DBUS_TYPE_STRING, &name,
+					generic_callback, name, g_free) == TRUE)
+		return;
+
+	g_free(name);
+}
+
 static void cmd_select_attribute(const char *arg)
 {
 	GDBusProxy *proxy;
@@ -2105,6 +2129,7 @@ static const struct {
 							dev_generator },
 	{ "list-attributes", "[dev]", cmd_list_attributes, "List attributes",
 							dev_generator },
+	{ "set-alias",    "<alias>",  cmd_set_alias, "Set device alias" },
 	{ "select-attribute", "<attribute>",  cmd_select_attribute,
 				"Select attribute", attribute_generator },
 	{ "attribute-info", "[attribute]",  cmd_attribute_info,
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ] Add device set-alias bluetoothctl command
  2016-09-02  9:08 ` Francois Beaufort
@ 2016-09-02 14:14   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2016-09-02 14:14 UTC (permalink / raw)
  To: Francois Beaufort; +Cc: linux-bluetooth@vger.kernel.org

Hi Francois,

On Fri, Sep 2, 2016 at 12:08 PM, Francois Beaufort
<beaufort.francois@gmail.com> wrote:
> ---
>  client/main.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>
> diff --git a/client/main.c b/client/main.c
> index 9ba5a40..e1198a8 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -1666,6 +1666,30 @@ static void cmd_list_attributes(const char *arg)
>         gatt_list_attributes(g_dbus_proxy_get_path(proxy));
>  }
>
> +static void cmd_set_alias(const char *arg)
> +{
> +       char *name;
> +
> +       if (!arg || !strlen(arg)) {
> +               rl_printf("Missing name argument\n");
> +               return;
> +       }
> +
> +       if (!default_dev) {
> +               rl_printf("No device connected\n");
> +               return;
> +       }
> +
> +       name = g_strdup(arg);
> +
> +       if (g_dbus_proxy_set_property_basic(default_dev, "Alias",
> +                                       DBUS_TYPE_STRING, &name,
> +                                       generic_callback, name, g_free) == TRUE)
> +               return;
> +
> +       g_free(name);
> +}
> +
>  static void cmd_select_attribute(const char *arg)
>  {
>         GDBusProxy *proxy;
> @@ -2105,6 +2129,7 @@ static const struct {
>                                                         dev_generator },
>         { "list-attributes", "[dev]", cmd_list_attributes, "List attributes",
>                                                         dev_generator },
> +       { "set-alias",    "<alias>",  cmd_set_alias, "Set device alias" },
>         { "select-attribute", "<attribute>",  cmd_select_attribute,
>                                 "Select attribute", attribute_generator },
>         { "attribute-info", "[attribute]",  cmd_attribute_info,
> --
> 2.7.0

Applied, thanks.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH BlueZ] Add device set-alias bluetoothctl command
  2016-09-20 13:12 [PATCH BlueZ] client: Show UUIDs when listing services, characteristics and descriptors Francois Beaufort
@ 2016-09-20 13:12 ` Francois Beaufort
  0 siblings, 0 replies; 5+ messages in thread
From: Francois Beaufort @ 2016-09-20 13:12 UTC (permalink / raw)
  To: linux-bluetooth

---
 client/main.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/client/main.c b/client/main.c
index 9ba5a40..e1198a8 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1666,6 +1666,30 @@ static void cmd_list_attributes(const char *arg)
 	gatt_list_attributes(g_dbus_proxy_get_path(proxy));
 }
 
+static void cmd_set_alias(const char *arg)
+{
+	char *name;
+
+	if (!arg || !strlen(arg)) {
+		rl_printf("Missing name argument\n");
+		return;
+	}
+
+	if (!default_dev) {
+		rl_printf("No device connected\n");
+		return;
+	}
+
+	name = g_strdup(arg);
+
+	if (g_dbus_proxy_set_property_basic(default_dev, "Alias",
+					DBUS_TYPE_STRING, &name,
+					generic_callback, name, g_free) == TRUE)
+		return;
+
+	g_free(name);
+}
+
 static void cmd_select_attribute(const char *arg)
 {
 	GDBusProxy *proxy;
@@ -2105,6 +2129,7 @@ static const struct {
 							dev_generator },
 	{ "list-attributes", "[dev]", cmd_list_attributes, "List attributes",
 							dev_generator },
+	{ "set-alias",    "<alias>",  cmd_set_alias, "Set device alias" },
 	{ "select-attribute", "<attribute>",  cmd_select_attribute,
 				"Select attribute", attribute_generator },
 	{ "attribute-info", "[attribute]",  cmd_attribute_info,
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ] Add device set-alias bluetoothctl command
  2016-09-20 13:13 [PATCH BlueZ] client: Show UUIDs when listing services, characteristics and descriptors Francois Beaufort
@ 2016-09-20 13:13 ` Francois Beaufort
  0 siblings, 0 replies; 5+ messages in thread
From: Francois Beaufort @ 2016-09-20 13:13 UTC (permalink / raw)
  To: linux-bluetooth

---
 client/main.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/client/main.c b/client/main.c
index 9ba5a40..e1198a8 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1666,6 +1666,30 @@ static void cmd_list_attributes(const char *arg)
 	gatt_list_attributes(g_dbus_proxy_get_path(proxy));
 }
 
+static void cmd_set_alias(const char *arg)
+{
+	char *name;
+
+	if (!arg || !strlen(arg)) {
+		rl_printf("Missing name argument\n");
+		return;
+	}
+
+	if (!default_dev) {
+		rl_printf("No device connected\n");
+		return;
+	}
+
+	name = g_strdup(arg);
+
+	if (g_dbus_proxy_set_property_basic(default_dev, "Alias",
+					DBUS_TYPE_STRING, &name,
+					generic_callback, name, g_free) == TRUE)
+		return;
+
+	g_free(name);
+}
+
 static void cmd_select_attribute(const char *arg)
 {
 	GDBusProxy *proxy;
@@ -2105,6 +2129,7 @@ static const struct {
 							dev_generator },
 	{ "list-attributes", "[dev]", cmd_list_attributes, "List attributes",
 							dev_generator },
+	{ "set-alias",    "<alias>",  cmd_set_alias, "Set device alias" },
 	{ "select-attribute", "<attribute>",  cmd_select_attribute,
 				"Select attribute", attribute_generator },
 	{ "attribute-info", "[attribute]",  cmd_attribute_info,
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-20 13:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-02  9:08 [PATCH BlueZ] Add device set-alias bluetoothctl command Francois Beaufort
2016-09-02  9:08 ` Francois Beaufort
2016-09-02 14:14   ` Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2016-09-20 13:12 [PATCH BlueZ] client: Show UUIDs when listing services, characteristics and descriptors Francois Beaufort
2016-09-20 13:12 ` [PATCH BlueZ] Add device set-alias bluetoothctl command Francois Beaufort
2016-09-20 13:13 [PATCH BlueZ] client: Show UUIDs when listing services, characteristics and descriptors Francois Beaufort
2016-09-20 13:13 ` [PATCH BlueZ] Add device set-alias bluetoothctl command Francois Beaufort

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).