summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorMiao-chen Chou <mcchou@chromium.org>2020-08-21 00:28:12 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-08-21 10:50:04 -0700
commit4d0336ea40499714747c27389098f76ef10d3700 (patch)
treebeb8ff0630f1f2546c24219db67e23cc96f82d01 /client
parentef7e4848559cb8b8448303ad6eb68de8f901a558 (diff)
downloadbluez-4d0336ea40499714747c27389098f76ef10d3700.tar.gz
client: Add cancel-pairing command
This adds cancel-pairing command which can be used to cancel the ongoing pairing.
Diffstat (limited to 'client')
-rw-r--r--client/main.c35
1 files changed, 35 insertions, 0 deletions
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",