Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp51741pxa; Fri, 21 Aug 2020 00:28:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIoMUamh++/jM+yXgvpqhn+Rn1SLH/OfAUQWf/DcwgF1TLrtcjIpyXLmEKj/ZV1rkRQeaQ X-Received: by 2002:aa7:d607:: with SMTP id c7mr1557266edr.184.1597994937106; Fri, 21 Aug 2020 00:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597994937; cv=none; d=google.com; s=arc-20160816; b=eHLklbSGoEBwbGUHAsFdRWrBABAFqPp/QZMLbxX8GbHw/tiy6atTGrzPnYHsbAEb4g jOzEB0GMsVWBYZZf5BlHNRHSQw4ICLybdYRYxpCPm1DX1yg5+VMKSzlxAVxnants9V8f elbVTtu1bv+ptjDz6GEkCmp2lx7k0YhS3g+uvl98TYqou6+8RaE43iQn3yrUONd3WE0Y tyfMz/MGn9gzWlSRi88GN2J2eaOiwIX+d1dwQIJikjcn+sRiyReD4x6TrqxolpMvdSQw 7wSUicohbJQ8xrF7qZ7VkZSGuN4VmywpsbNd/42To7C0IXsHzlt1ivTiFrxPl7oGyr6C AVRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=f3sU0357hYiDl5l/vHKQ4nLAzIRHctOnyhKqk4fMM/Q=; b=T2154VKGrr8nYK2KttXiWTKVb55OyCo+5nDJa8zsP3lqQv7UlaitgWOF2k0QHIOAIy X+wuULmdUcjeGUBExk1xeJbYzwi2C9LSKxydXtmo9/wQRZD54M+egx6tHpL2rgps+GpT yqleefyq29+VYvvEIzea+VdxPVZukgxZROZdRVVejWE8lfraW4UG+Q4goYH3j4A43OI7 BJBqJNJ3AcGF7UphKkw6/l8Y5aEpMSjy71+1vCNCI0nl+e6FZ5jAC8hShhwjnGg73WM1 YeQ1W1/RigegRAsjDQ8Kroz/y36RNECT1ZvsunKOs9Sc2XRs5EnBD1m2mt+GTp4u2GKI L/8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TYaU/oTL"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a20si671107edr.171.2020.08.21.00.28.31; Fri, 21 Aug 2020 00:28:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TYaU/oTL"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727846AbgHUH20 (ORCPT + 99 others); Fri, 21 Aug 2020 03:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbgHUH2Z (ORCPT ); Fri, 21 Aug 2020 03:28:25 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D956CC061385 for ; Fri, 21 Aug 2020 00:28:25 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id a79so649883pfa.8 for ; Fri, 21 Aug 2020 00:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=f3sU0357hYiDl5l/vHKQ4nLAzIRHctOnyhKqk4fMM/Q=; b=TYaU/oTLt1fs416s8kkfo9n0n6L1TdbJmfyDGQmTDNtDL7XH49zN0s7hkjU07FDC0B R0M3hAi5RpMvGga1vSYErUVUtNXxm/pBMBwxxyPs2SKlvnNsq3kar0cgu2IjmgcxrmQh xP6Uqx2RRf223OdUvMcqtiKfa/UOyJ1abMtQM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=f3sU0357hYiDl5l/vHKQ4nLAzIRHctOnyhKqk4fMM/Q=; b=BDqBSHhYURdetT1Kdptxy7nyZsEn/pdT6WdnrEQYSipqzrg2nau6+Ee7phigpuPief xomS632OsE8xmHRtaq+qjYNY52+h3f/cWeS4AVj2O4ktfwnAzRci5jMcEv9gqi6Ok4xi 2pPagO3CKjeRGsRPujnqwPUDYV22VTfd0GjoMFavR6WO2zrmW4rElFSPX1A87UH1os3M ncVNeKGhXNgCfkUBjBbYztMepZTBTbWIDaxqNvwUBfBpsvnX9sv/a8ZCMGpfNQ2BlmG+ mmsUa7fIL1O46O1f77zvAq3hBXmKdfuSqV93alid5sPwbcw3Q7j4TIHKxyv3ZUckGM7j DI5g== X-Gm-Message-State: AOAM532Qofm3m86NZWFrKEBmlkTiTD7wClhkHiKdJw1U9iyesaX9+NNB MkEhQBDtx0X0T2ueum0ZTX3nk46UC773mg== X-Received: by 2002:a63:441c:: with SMTP id r28mr1390657pga.84.1597994905039; Fri, 21 Aug 2020 00:28:25 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id b15sm1107738pgk.14.2020.08.21.00.28.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2020 00:28:24 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Miao-chen Chou , Sonny Sasaka Subject: [PATCH BlueZ] client: Add cancel-pairing command Date: Fri, 21 Aug 2020 00:28:12 -0700 Message-Id: <20200821072812.19131-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Miao-chen Chou This adds cancel-pairing command which can be used to cancel the ongoing pairing. Reviewed-by: Sonny Sasaka --- 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