All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] client: Add cancel-pairing command
@ 2020-08-21  7:28 Sonny Sasaka
  2020-08-21 17:54 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Sonny Sasaka @ 2020-08-21  7:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Miao-chen Chou, Sonny Sasaka

From: Miao-chen Chou <mcchou@chromium.org>

This adds cancel-pairing command which can be used to cancel the ongoing
pairing.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>

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

diff --git a/client/main.c b/client/main.c
index 9abada69f..da877b546 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1742,6 +1742,39 @@ static void cmd_pair(int argc, char *argv[])
 	bt_shell_printf("Attempting to pair with %s\n", proxy_address(proxy));
 }
 
+static void cancel_pairing_reply(DBusMessage *message, void *user_data)
+{
+	DBusError error;
+
+	dbus_error_init(&error);
+
+	if (dbus_set_error_from_message(&error, message) == TRUE) {
+		bt_shell_printf("Failed to cancel pairing: %s\n", error.name);
+		dbus_error_free(&error);
+		return;
+	}
+
+	bt_shell_printf("Cancel pairing successful\n");
+}
+
+static void cmd_cancel_pairing(int argc, char *argv[])
+{
+	GDBusProxy *proxy;
+
+	proxy = find_device(argc, argv);
+	if (!proxy)
+		return;
+
+	if (g_dbus_proxy_method_call(proxy, "CancelPairing", NULL,
+				cancel_pairing_reply, NULL, NULL) == FALSE) {
+		bt_shell_printf("Failed to cancel pairing\n");
+		return;
+	}
+
+	bt_shell_printf("Attempting to cancel pairing with %s\n",
+							proxy_address(proxy));
+}
+
 static void cmd_trust(int argc, char *argv[])
 {
 	GDBusProxy *proxy;
@@ -2816,6 +2849,8 @@ static const struct bt_shell_menu main_menu = {
 							dev_generator },
 	{ "pair",         "[dev]",    cmd_pair, "Pair with device",
 							dev_generator },
+	{ "cancel-pairing",  "[dev]",    cmd_cancel_pairing,
+				"Cancel pairing with device", dev_generator },
 	{ "trust",        "[dev]",    cmd_trust, "Trust device",
 							dev_generator },
 	{ "untrust",      "[dev]",    cmd_untrust, "Untrust device",
-- 
2.26.2


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

* Re: [PATCH BlueZ] client: Add cancel-pairing command
  2020-08-21  7:28 [PATCH BlueZ] client: Add cancel-pairing command Sonny Sasaka
@ 2020-08-21 17:54 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2020-08-21 17:54 UTC (permalink / raw)
  To: Sonny Sasaka; +Cc: linux-bluetooth, Miao-chen Chou

Hi Sonny,

On Fri, Aug 21, 2020 at 12:30 AM Sonny Sasaka <sonnysasaka@chromium.org> wrote:
>
> From: Miao-chen Chou <mcchou@chromium.org>
>
> This adds cancel-pairing command which can be used to cancel the ongoing
> pairing.
>
> Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
>
> ---
>  client/main.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
>
> diff --git a/client/main.c b/client/main.c
> index 9abada69f..da877b546 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -1742,6 +1742,39 @@ static void cmd_pair(int argc, char *argv[])
>         bt_shell_printf("Attempting to pair with %s\n", proxy_address(proxy));
>  }
>
> +static void cancel_pairing_reply(DBusMessage *message, void *user_data)
> +{
> +       DBusError error;
> +
> +       dbus_error_init(&error);
> +
> +       if (dbus_set_error_from_message(&error, message) == TRUE) {
> +               bt_shell_printf("Failed to cancel pairing: %s\n", error.name);
> +               dbus_error_free(&error);
> +               return;
> +       }
> +
> +       bt_shell_printf("Cancel pairing successful\n");
> +}
> +
> +static void cmd_cancel_pairing(int argc, char *argv[])
> +{
> +       GDBusProxy *proxy;
> +
> +       proxy = find_device(argc, argv);
> +       if (!proxy)
> +               return;
> +
> +       if (g_dbus_proxy_method_call(proxy, "CancelPairing", NULL,
> +                               cancel_pairing_reply, NULL, NULL) == FALSE) {
> +               bt_shell_printf("Failed to cancel pairing\n");
> +               return;
> +       }
> +
> +       bt_shell_printf("Attempting to cancel pairing with %s\n",
> +                                                       proxy_address(proxy));
> +}
> +
>  static void cmd_trust(int argc, char *argv[])
>  {
>         GDBusProxy *proxy;
> @@ -2816,6 +2849,8 @@ static const struct bt_shell_menu main_menu = {
>                                                         dev_generator },
>         { "pair",         "[dev]",    cmd_pair, "Pair with device",
>                                                         dev_generator },
> +       { "cancel-pairing",  "[dev]",    cmd_cancel_pairing,
> +                               "Cancel pairing with device", dev_generator },
>         { "trust",        "[dev]",    cmd_trust, "Trust device",
>                                                         dev_generator },
>         { "untrust",      "[dev]",    cmd_untrust, "Untrust device",
> --
> 2.26.2

Applied, thanks.

-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2020-08-21 17:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21  7:28 [PATCH BlueZ] client: Add cancel-pairing command Sonny Sasaka
2020-08-21 17:54 ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.