From patchwork Mon Mar 30 08:03:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8471481 for ; Mon, 30 Mar 2020 08:04:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 61D5D20A8B for ; Mon, 30 Mar 2020 08:04:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cyUm7P1K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729597AbgC3IEL (ORCPT ); Mon, 30 Mar 2020 04:04:11 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:43821 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729555AbgC3IEL (ORCPT ); Mon, 30 Mar 2020 04:04:11 -0400 Received: by mail-pf1-f201.google.com with SMTP id 20so14727117pfw.10 for ; Mon, 30 Mar 2020 01:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=J6H28Klia+nbbPjZRhE37qHnAkPZWC0Dwshk4a+wzMs=; b=cyUm7P1KQPFg++nCDUmpuDPJgRF+fbJoqtUKfu2VaY1gHhG1kI3zVimZZYIT6tI8aJ xJla3/kRp43KiP47oYFCUi+F8yBP69T+BkXpK6Zl+Y7qCBMiHv3h1kEoPYaWmBCcZyQL OWkMsBcHYwhWTmJKYGYk4Imumvzf6tX15OHRSs6l0XCWrZQjeOLQQvbHnN3KD7Fs98h8 jcA8g+rpUTxKn7TaucF1yNWIdTlOYGWVGl7KKXwM79ZOdBdEemHzNrHrztZ9Ofe7Yzll zkgDV66oprVUyE8TQqMm46z5hfpOFwY04ARvK+9B57raVx/BaFDWgWnLq/GW5mX/vUAN YShA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=J6H28Klia+nbbPjZRhE37qHnAkPZWC0Dwshk4a+wzMs=; b=ivM5uRAT6gU6PJCau99PcnT888A3aAUKa2WeNBBhcRlS8hfJ2RcWf96bmywxOz9C84 EXHxQfLvmpaEdgjkhs+8k2qj8Jw+Y+kYJQi7Phs4DQjNYyiL7GO6skrBsnNQSwyh3b9H JCs66OKMj6uInIFx2UVppBEqem6+3x4/4ywHDMoI3zscIjYgUw0emvb4OBpnXCCFvGZX 61q5WZURxaPehrP7MxvEFjBDAGFZ2k4OjB4PWNsfMHvC1BDZxuG8D6ooqcp6+OzGCkl/ 980yDV6m2NCRxv2n6R0jZPQ7WbMPLx+4esh+pa3t3nqduVH/th1lXdPwfRofWWR3CnAR 2gmQ== X-Gm-Message-State: ANhLgQ3L3W6l8G41hwal4uWDtJwerDWhjg2sCi353+HoYRjhM8EDVLfp ohL5aZeTRybMMo4Gaj1+HVLcvXk1usltM6ueJb42cp9IBO7IAyOpXEDDVHmrTzvlBireU2794u4 sxbQXxCWDtkMjbroZRZfRzk96laDJFWMtNlfEAlwnU3bL3kIwsofnPrDifEIwvsw7j4yzd3btcQ zikVkimrCiH0s= X-Google-Smtp-Source: ADFU+vv0IhByRpco9vm5vcXHGWuvf47bupyYbZ/7scNcRRGDTKdz/mPF7V0/y2RDK47sVCCmgR9dIXKRVwW3+95vkw== X-Received: by 2002:a17:90a:bf18:: with SMTP id c24mr14308679pjs.125.1585555450046; Mon, 30 Mar 2020 01:04:10 -0700 (PDT) Date: Mon, 30 Mar 2020 16:03:52 +0800 In-Reply-To: <20200330080357.96989-1-howardchung@google.com> Message-Id: <20200330160343.Bluez.v2.1.I0c5d660478f6a1c2d70f4bf683460e11a96ec223@changeid> Mime-Version: 1.0 References: <20200330080357.96989-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v2 1/6] lib/mgmt: Add LE Set Advertising Interval definition From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, Howard Chung , josephsih@chromium.org Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Suggested-by: josephsih@chromium.org Signed-off-by: Howard Chung --- Changes in v2: - Rebase and resolve conflict in monitor/control.c lib/mgmt.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 7520c7ae9..75302f5fd 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -103,6 +103,7 @@ struct mgmt_rp_read_index_list { #define MGMT_SETTING_STATIC_ADDRESS 0x00008000 #define MGMT_SETTING_PHY_CONFIGURATION 0x00010000 #define MGMT_SETTING_WIDEBAND_SPEECH 0x00020000 +#define MGMT_SETTING_ADVERTISING_INTERVALS 0x00040000 #define MGMT_OP_READ_INFO 0x0004 struct mgmt_rp_read_info { @@ -602,6 +603,15 @@ struct mgmt_cp_set_blocked_keys { #define MGMT_OP_SET_WIDEBAND_SPEECH 0x0047 +#define MGMT_OP_SET_ADVERTISING_INTERVALS 0x0048 +#define ADVERTISING_INTERVAL_UNIT_TIME 0.625 +struct mgmt_cp_set_advertising_intervals { + /* A unit of the intervals below is 0.625 ms.*/ + uint16_t min_interval; + uint16_t max_interval; +} __packed; +#define MGMT_SET_ADVERTISING_INTERVALS_SIZE 4 + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { uint16_t opcode; @@ -898,6 +908,7 @@ static const char *mgmt_op[] = { "Set PHY Configuration", "Set Blocked Keys", "Set Wideband Speech", + "Set Advertising Intervals", /* 0x0048 */ }; static const char *mgmt_ev[] = { From patchwork Mon Mar 30 08:03:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 837BA81 for ; Mon, 30 Mar 2020 08:04:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6310220776 for ; Mon, 30 Mar 2020 08:04:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ibzYmoFl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729602AbgC3IEQ (ORCPT ); Mon, 30 Mar 2020 04:04:16 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:51487 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729588AbgC3IEQ (ORCPT ); Mon, 30 Mar 2020 04:04:16 -0400 Received: by mail-pg1-f201.google.com with SMTP id p13so14236466pgk.18 for ; Mon, 30 Mar 2020 01:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=axUhYrK/4mE+ijb5p6RZuq2PLRRjrVtRjO2FiDK+tvg=; b=ibzYmoFl9N24F7rKcDhChsIlb474+3mXUiovL8oAoSDpw9typ2Nw72GjIB0jVv0QtW rmD+sHMJ+lMwGPGxhog9tLvf+XNZTf3Uhl2KcFeO+mgbgFSa8WELK+0LlL7aqb5FRari Bb3g3I+IrKdH51Z189AJPe7OnJb4oP5vSnB8vAYUZw49MqrSJ5tIKGGiCPE5xsy6E/HI GpU4l7BRqGGrKq5XbklibeL5dBVLumGLavux+M6Xq+b6f9isl5nIsKv2/gymts+Y9E// mhEY6lXTvmNBYA5qI09NUGQ4hI/BkxwvlJqPXrXBvftULSfjILjeiCEUO4EbOiN7KpzN RykA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=axUhYrK/4mE+ijb5p6RZuq2PLRRjrVtRjO2FiDK+tvg=; b=DsYblU5J9lLxmrjOCYr4lBWTFJgI/pKsGVP9+nCXRMdKUAP4rqvzuVXQJS+KeooU6c pmFMJEr/lUbtwEiKtKTSP8D7PvRaBZfAgHkpimyJMW7b69ga64a6wYqqsHrmQdzUq7wD 8m2evf48sLLbf9WV/xAKdCkLBHluj8DARcEG0daoeb4WuaEK1jxWfQZboPZ/vCBGQfv4 AHpff60cEaOFc2Gcy4NLZnHd46Z2nnVa6yfxFcR11hNMmF0FoSMuy7dwkrKAIxdb/GKq KwDS3eAfqxEadVS+D8LM9k8RkP7/uSrAeo0Vpe2u5h+iUQrj3PLOsOtDKg0dRoMAmww8 eRHQ== X-Gm-Message-State: ANhLgQ1kKlfxpEnaZnZZ2ccTYr1FA0IsPYmVyfEMr5hOUUTxYCJscT6B 3IpQDw3HW5P+WJkHW2OJfh/3ULHL7I2C9fkmiFJbfqzsEvf03ia5mDbCRguS3uOfuhut4peSfwx c5gVqiUKLcPp8S4Aex33h9HI78q7+v0bJBalX0JyrqBQGi7p52ISoj7Cgpq1D56ohHDWc8c/h6t kEw37kzrv65gU= X-Google-Smtp-Source: ADFU+vt7EWP7WVaZVOyojGAQAezT65jZ7njFtq5pCByynRBvK7MkTcMpSDiNsn3rnyNy/gm4usNI6QumxaRthcAMlA== X-Received: by 2002:a17:90a:21ce:: with SMTP id q72mr14135128pjc.160.1585555455117; Mon, 30 Mar 2020 01:04:15 -0700 (PDT) Date: Mon, 30 Mar 2020 16:03:53 +0800 In-Reply-To: <20200330080357.96989-1-howardchung@google.com> Message-Id: <20200330160343.Bluez.v2.2.I4fe5ed67f70011e5374e65929b845e13fe6ed59e@changeid> Mime-Version: 1.0 References: <20200330080357.96989-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v2 2/6] core/advertising: Add support for LE set adverting interval From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, Howard Chung Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Implement a new dbus method to set advertising intervals. The advertising inervals are sent through a new mgmt method with the opcode MGMT_OP_SET_ADVERTISING_INTERVALS to bluetooth kernel subsystem. Signed-off-by: Howard Chung --- Changes in v2: None src/advertising.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/src/advertising.c b/src/advertising.c index 45ff19fa0..444969f04 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1342,6 +1342,92 @@ static const GDBusPropertyTable properties[] = { { } }; +static void set_advertising_intervals_callback(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + DBusMessage *msg = user_data; + DBusMessage *reply; + + switch (status) { + case MGMT_STATUS_SUCCESS: + reply = dbus_message_new_method_return(msg); + break; + case MGMT_STATUS_REJECTED: + reply = btd_error_failed( + msg, "A non-BLE device should not advertise!"); + break; + case MGMT_STATUS_INVALID_PARAMS: + reply = btd_error_invalid_args(msg); + break; + case MGMT_STATUS_BUSY: + reply = btd_error_busy(msg); + break; + default: + reply = btd_error_failed( + msg, "failed to set advertising intervals"); + } + + g_dbus_send_message(btd_get_dbus_connection(), reply); + dbus_message_unref(msg); +} + +static int adapter_set_advertising_intervals(struct btd_adv_manager *manager, + DBusMessage *msg, + uint16_t min_interval_ms, + uint16_t max_interval_ms) +{ + struct mgmt_cp_set_advertising_intervals cp; + + memset(&cp, 0, sizeof(cp)); + + /* Convert milli-seconds to multiples of 0.625 ms which are used + * in kernel. + */ + cp.min_interval = min_interval_ms / ADVERTISING_INTERVAL_UNIT_TIME; + cp.max_interval = max_interval_ms / ADVERTISING_INTERVAL_UNIT_TIME; + + btd_info(manager->mgmt_index, + "Set Advertising Intervals: 0x%04x, 0x%04x", + cp.min_interval, cp.max_interval); + + if (mgmt_send(manager->mgmt, + MGMT_OP_SET_ADVERTISING_INTERVALS, manager->mgmt_index, + sizeof(cp), &cp, set_advertising_intervals_callback, + dbus_message_ref(msg), NULL) > 0) { + return true; + } + + return false; +} + +static DBusMessage *set_advertising_intervals(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + struct btd_adv_manager *manager = user_data; + const char *sender = dbus_message_get_sender(msg); + dbus_uint16_t min_interval_ms, max_interval_ms; + + DBG("set_advertising_intervals: sender %s", sender); + + if (!dbus_message_get_args(msg, NULL, + DBUS_TYPE_UINT16, &min_interval_ms, + DBUS_TYPE_UINT16, &max_interval_ms, + DBUS_TYPE_INVALID)) { + return btd_error_invalid_args(msg); + } + + /* The adapter is not required to be powered to set advertising + * intervals. Hence, just go ahead to set the intervals. + */ + if (!adapter_set_advertising_intervals(manager, msg, min_interval_ms, + max_interval_ms)) { + return btd_error_failed(msg, + "failed to set advertising intervals"); + } + + return NULL; +} + static const GDBusMethodTable methods[] = { { GDBUS_ASYNC_METHOD("RegisterAdvertisement", GDBUS_ARGS({ "advertisement", "o" }, @@ -1351,6 +1437,10 @@ static const GDBusMethodTable methods[] = { GDBUS_ARGS({ "service", "o" }), NULL, unregister_advertisement) }, + { GDBUS_ASYNC_METHOD("SetAdvertisingIntervals", + GDBUS_ARGS({"min_interval_ms", "q"}, + {"max_interval_ms", "q"}), + NULL, set_advertising_intervals)}, { } }; From patchwork Mon Mar 30 08:03:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464911 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3D5292C for ; Mon, 30 Mar 2020 08:04:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92CDC2073B for ; Mon, 30 Mar 2020 08:04:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FXYNFLRh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729603AbgC3IEV (ORCPT ); Mon, 30 Mar 2020 04:04:21 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:49017 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729586AbgC3IEV (ORCPT ); Mon, 30 Mar 2020 04:04:21 -0400 Received: by mail-pl1-f202.google.com with SMTP id w3so12381423plz.15 for ; Mon, 30 Mar 2020 01:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=oOIxK3ZqM6LAAqkV1X/+V85HxrPtsXuK8F3nIXKiwNw=; b=FXYNFLRhaCq6XHrYgg4fWOre+j9fLqwuoc9GbelSkdVsYcXrUXg3xr+qiGG5XNlIAm 2Big+71X0uGHSXe6T0g4+zMYUxvAHOAwofHgPfMnrxIbjjgoJwiJyMpkimqLIbSMqB01 QLiuC/vWF8BtI8BjhsEFw15YXMBwULQfpBYCTM9xzGSE7WBoPVkveQE1MHEVRQnC7sGk erbai/tjC/QsVlYY6r8nMO94BlsvYWRaegIlXfIfocUGhFPDV3qvCXw5ssccrMYRO0zz 9v3KsU6oTwtw0DD81qdjMEhaoaO9N89qT0xSzYT7Yu05p8HpzhB/91W636lIx+ZESQVm Cibg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=oOIxK3ZqM6LAAqkV1X/+V85HxrPtsXuK8F3nIXKiwNw=; b=l2gRb54wpVkEFbiQL+vkXFNkqq52/0nb49TtalM2C4aG2ZKpgB+zk3iqLrXNAR1UlU bphS1trBlEaTgvo5W7lYeZcpnTQTXHN2EVkuB6ZcpW4GhIpRG5Cn1A2Qerpt0y0o0364 F6QCuYUW2SVPazivCUXU3uixPA66dgepZ4czC9yoBvQxSFqcp1YbngMLV4XamjZ80rCR 0nmg/MQdkDznvm6D5Y9JCniidTZaklhC9+E+wVEGQZ4/0gIFQf8/Ow94Bjagjp5z1ikf lEnnOzxjkTKYJek5IaTz5vP8V5yucNabkuPlWyo5mQ4Ni+LHCFmCLXi4CjBg1P60kGQA OirA== X-Gm-Message-State: ANhLgQ1YTXBgeEBH1LHF7Q8zr+r+7D4lMmtzcJK6vsi5AHSOXJ0tIX1d A48rIH9jzzYrQLDFCx/VPsdKBISDn8lFnfhhlBsJTbOdHlws4Cs9zh/y/noMxk8Mki/aElQuQb/ cHhFrI4LyTPooa3myEStsnPGRzjumU4sb2qLpuoV3wfQA99YCjc+tDA6uU4pIxje1bk4hGp8P23 Bzdhw5IlhSko0= X-Google-Smtp-Source: ADFU+vuVXlyYF1UEpqbgBbsSsKB7dcFdgPJqh+YYyV2fnIAQwDBSJqHLK8d+ll0N2iCcZg/Bw4mvRksr6o8iyJrOmg== X-Received: by 2002:a17:90b:3849:: with SMTP id nl9mr14060702pjb.86.1585555459981; Mon, 30 Mar 2020 01:04:19 -0700 (PDT) Date: Mon, 30 Mar 2020 16:03:54 +0800 In-Reply-To: <20200330080357.96989-1-howardchung@google.com> Message-Id: <20200330160343.Bluez.v2.3.Ia74c1ab0a71d90f46f10b4e32743cab722a97bbb@changeid> Mime-Version: 1.0 References: <20200330080357.96989-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v2 3/6] doc: Add documentation for LE Set Advertising Interval From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, Howard Chung Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Signed-off-by: Howard Chung --- Changes in v2: None doc/advertising-api.txt | 13 +++++++++++++ doc/mgmt-api.txt | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt index b0565eab2..9264cdb27 100644 --- a/doc/advertising-api.txt +++ b/doc/advertising-api.txt @@ -209,3 +209,16 @@ Properties byte ActiveInstances Possible values: "1M" "2M" "Coded" + + void SetAdvertisingIntervals(uint16 min_interval_ms, + uint16 max_interval_ms) + + This method sets the advertising intervals. + + The parameters min_interval_ms and max_interval_ms + are specified in milli-seconds. Valid values of + the intervals must fall between 20 ms and 10,240 ms. + + Possible errors: org.bluez.Error.Failed + org.bluez.Error.InProgress + org.bluez.Error.InvalidArguments diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 27a41f334..5eff87e24 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -2925,6 +2925,31 @@ Read Extended Controller Information Command Invalid Index +Set Advertising Intervals Command +================================= + + Command Code: 0x0101 + Controller Index: + Command Parameters: Min_Interval (2 Octets) + Max_Interval (2 Octets) + Return Parameters: Current_Settings (4 Octets) + + This command is used to set advertising intervals. The intervals + are expressed in multiples of 0.625 ms. The default values of + both intervals are 0x0800. Valid Min_Interval and Max_Interval + values must fall between 0x0020 and 0x4000. + + The advertising intervals are first kept in hdev struct. The values + would be sent to the controller and take effect when advertising is + actually enabled. If the advertising intervals are set when + advertising is already on, the advertising would be disabled and + re-enabled to make the intervals take effect. + + Possible errors: Busy + Rejected + Invalid Parameters + + Set Appearance Command ====================== From patchwork Mon Mar 30 08:03:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464913 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9819392C for ; Mon, 30 Mar 2020 08:04:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76A25206E6 for ; Mon, 30 Mar 2020 08:04:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fFIbd/iQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729605AbgC3IE2 (ORCPT ); Mon, 30 Mar 2020 04:04:28 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:37704 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729586AbgC3IE2 (ORCPT ); Mon, 30 Mar 2020 04:04:28 -0400 Received: by mail-pf1-f202.google.com with SMTP id n28so14731646pfq.4 for ; Mon, 30 Mar 2020 01:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=DK0WI8AjNOdJ0HpShf0kaJsDhms0l6HDXBAdYLD2yWg=; b=fFIbd/iQfmusNX5pncc1J3JWwI9WNrQZY6XwVEx/F2N7GTGG3T3xchIUQU9+p43jaY ZWtIOwxvLKDcbAwsFExbFD9W4tIz1dQn1pIceXnJ1cqH9ivo5uO/cTT2j0l4XAaETpGV imBijkNXLc4M60Fy94ORltp/dmtT/4huBN5HwKGEOEVvyumhqBLtpWIbH0pEbutICHgb l9WKxNCkt7BI6LJhisz/IcwLuEh4Cse9tBOCeE+8lxH+UPyEx9Tcqhh7JX5aP8HIKAoK MAtp9adLsJpDYWrob1jSQYI6cg10VTJrZZDAzn/u6JGrucwqndNho+a2erkQ5vXz9vSx 8fiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DK0WI8AjNOdJ0HpShf0kaJsDhms0l6HDXBAdYLD2yWg=; b=L+YIddl7Zb4frtVaRnDj8i5eQjpULU1slEEiVLb0AyL57jN6wu72Uy692JA5h5pxgy L3kT2z7GGY4jApZC30B0FHP5CVe6c8PWxzolo1VCF+6lj1MVlHkChk8mXOaTSXijg19p vMDcU0VgsnL0dGE6jCE41bXNW9a/ygolTTTGzDwFXI970MQ4pCciLEwzAPRa1SP7hKBB JkUeVIyN2gs6LaGe/qpzssEiyzusG8oVKH4eJWX/pn9vttorLWLkZ9e+3JugSKHcwaY4 WI2XoULcGY/eZWgnmorvZIb67KZza7L1Gi+K+Uu3Iyyio8TiTzqO0Cbpz+KDpI6LsdbE kpgw== X-Gm-Message-State: ANhLgQ1epwF8wv/qLo631ZnLf5dao2tm9ILlEY3szi0aVwQ6cqEO+yzy LK6cAz9lQTzPc8Gaz5pdVws7uECy6q+XohtOfJg/3H3222Go0LxEtVejUqU4y5Yr4cGs4DF4geN G0fi2UtrpdIpHU4HN5sVG/koRlq98TlJJEawAe4058clwja6EVR3gzMf7cnyzHPVYHRMy1ZAEZC as0NrZ31oIx9U= X-Google-Smtp-Source: ADFU+vsgmP6FVXLRehP83QdCph8TdQ0tLd3SqQkx2uzuxuxn06s5YkevKEEz7EHCmOXDmltwsWpPoKis2BqxNNGk6g== X-Received: by 2002:a17:90b:1985:: with SMTP id mv5mr14650899pjb.69.1585555464803; Mon, 30 Mar 2020 01:04:24 -0700 (PDT) Date: Mon, 30 Mar 2020 16:03:55 +0800 In-Reply-To: <20200330080357.96989-1-howardchung@google.com> Message-Id: <20200330160343.Bluez.v2.4.I0a98775e764e9f8dba1652853b6e7ba440f4c75b@changeid> Mime-Version: 1.0 References: <20200330080357.96989-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v2 4/6] monitor: Add support for decoding LE Set Advertising Interval From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, Howard Chung Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The following lines will show in btmon: bluetoothd: Set Advertising Intervals: 0x0140, 0x0280 @ MGMT Command: LE Set Advertising Interval (0x0060) plen 4 Min advertising interval: 0x0140 Max advertising interval: 0x0280 @ MGMT Event: Command Complete (0x0001) plen 7 LE Set Advertising Interval (0x0060) plen 4 Status: Success (0x00) Current settings: 0x00040ad0 Signed-off-by: Howard Chung --- Changes in v2: None monitor/control.c | 2 +- monitor/packet.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/monitor/control.c b/monitor/control.c index 6dfefd05f..75457029e 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -200,7 +200,7 @@ static const char *settings_str[] = { "powered", "connectable", "fast-connectable", "discoverable", "bondable", "link-security", "ssp", "br/edr", "hs", "le", "advertising", "secure-conn", "debug-keys", "privacy", - "configuration", "static-addr", "phy", "wbs" + "configuration", "static-addr", "phy", "wbs" "advertising-intervals", }; static void mgmt_new_settings(uint16_t len, const void *buf) diff --git a/monitor/packet.c b/monitor/packet.c index 3d32563e6..00825cbb4 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -11669,6 +11669,7 @@ static const struct bitfield_data mgmt_settings_table[] = { { 15, "Static Address" }, { 16, "PHY Configuration" }, { 17, "Wideband Speech" }, + { 18, "Advertising Intervals" }, { } }; @@ -12988,6 +12989,23 @@ static void mgmt_set_phy_cmd(const void *data, uint16_t size) mgmt_print_phys("Selected PHYs", selected_phys); } +static void mgmt_set_adv_interval_cmd(const void *data, uint16_t size) +{ + uint16_t min_adv_interval = get_le16(data); + uint16_t max_adv_interval = get_le16(data+2); + + print_field("Min advertising interval: 0x%4.4x", min_adv_interval); + print_field("Max advertising interval: 0x%4.4x", max_adv_interval); +} + +static void mgmt_set_adv_interval_rsp(const void *data, uint16_t size) +{ + uint32_t current_settings = get_le32(data); + + print_field("Current settings: 0x%8.8x", current_settings); +} + + struct mgmt_data { uint16_t opcode; const char *str; @@ -13207,6 +13225,9 @@ static const struct mgmt_data mgmt_command_table[] = { { 0x0045, "Set PHY Configuration", mgmt_set_phy_cmd, 4, true, mgmt_null_rsp, 0, true }, + { 0x0060, "LE Set Advertising Interval", + mgmt_set_adv_interval_cmd, 4, true, + mgmt_set_adv_interval_rsp, 4, true}, { } }; From patchwork Mon Mar 30 08:03:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464915 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD15F81 for ; Mon, 30 Mar 2020 08:04:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC19320748 for ; Mon, 30 Mar 2020 08:04:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ffyP0Yfe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729606AbgC3IEd (ORCPT ); Mon, 30 Mar 2020 04:04:33 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:54606 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729586AbgC3IEd (ORCPT ); Mon, 30 Mar 2020 04:04:33 -0400 Received: by mail-vk1-f202.google.com with SMTP id i26so5249050vkk.21 for ; Mon, 30 Mar 2020 01:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=t9KWA9TXseSGKzSaj2xUqPufvYRn2IcAIkpo4hpGUsc=; b=ffyP0YfeWxCIApygAbhLHpnjKIfPKABqJpPKCFr0wm7vM/pBH7Q77tFwzLta0vKY2M OuGEcVtwXb8b8MfALymPYYoSSdUVbuGB6L/my4jIktEeFbbA7mHtyvtKwDuexR5+6KiQ +kxti8BKd7RoTNO+5j9S86SbE0Uv7lDgXwWDrn+JmBDe1M+JPdIUuYDHQkQAQLUqHVEF Jk/JR9skcw7oqK9D9aHnFOXfbN98hTy8Abm4bdwDCLt8/g5/+F576q5DcCx8rqk3DRpu GlNjol8OOLWCGKSuYM3IgayzsoOckJFj8+TPMS4ohYay8jFi0cg0Z+rsvW8ZDM3HU7D4 t0EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=t9KWA9TXseSGKzSaj2xUqPufvYRn2IcAIkpo4hpGUsc=; b=eevGhsEe8aGKIGOMvvNo2SS9DAPbnsfMBigmxBBwiD4QK8b8quxxELAOTTGtDzRGsc PR76FYOIkue9GZfhah55y7GOrtsg08jjSTmfOlyZ4P1xEal9cxm+h9UCccAz0fdINkP4 kTCnR/wjv3Hk/COWBjZQZMJvGOHt+4QqUT2bxomDXxPqcGChU6vPFLPvZoSsQHmGX3He AuF/tRfvilnXSRgG5RoTJ+bcU70h+DXNL8NnYK1BsIrVSm3wBzhvlBmS3XwbTIDdxijM w3W6ol11+6fuhq4j4+l/bPrFJ32T0yzg/6SmfCLkP675oQiXg06JB5CZML835a524TqQ M/dQ== X-Gm-Message-State: AGi0PuYIAxykrmZsxTfpBmYjphq/CasdRFlDAFOBWHsaxirp2fpFXhDY WGM0DOw0Cv5nQEm0vI0SdPYUR8fl4yI5GMfOUys2gLWRf6P8aLHiRRZbZaISojEemGvkPr9mBRi b81P8hAQUTwj7eqgCP91XjjzIS5C8GW0JCtPxvPixV3m0UoTFSKyB0AH5hmPNyXcUE6DLVsKka3 DGOnuwTLFBIWw= X-Google-Smtp-Source: APiQypJWq/jMiO9R9NJkeJqgdv8vPdBSslwLiONw8f+xVCg5bfDNbKB1Gej+EdOly+MZAV6wDdTk571ABgbKXg75rw== X-Received: by 2002:a1f:a2d0:: with SMTP id l199mr6578040vke.77.1585555470048; Mon, 30 Mar 2020 01:04:30 -0700 (PDT) Date: Mon, 30 Mar 2020 16:03:56 +0800 In-Reply-To: <20200330080357.96989-1-howardchung@google.com> Message-Id: <20200330160343.Bluez.v2.5.Ie551a8a414d17604f04e10cf8d9c514a2b170e31@changeid> Mime-Version: 1.0 References: <20200330080357.96989-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v2 5/6] test: Add test for LE Set Advertising Interval From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, Howard Chung Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Perform the following steps to verify advertising intervals. Open a terminal on the DUT, and execute $ btmon Open another terminal on the DUT, and register an advertisement. $ ./example-advertisement Observe that the default intervals are 1280 msec in btmon log. < HCI Command: LE Set Advertising Parameters (0x08|0x0006) plen 15 Min advertising interval: 1280.000 msec (0x0800) Max advertising interval: 1280.000 msec (0x0800) Press ctrl-c to terminate the advertisement. Set new intervals to 200 ms. $ ./example-advertising-intervals 200 200 It would show the following line in btmon log. = bluetoothd: Set Advertising Intervals: 0x0140, 0x0140 Register an advertisement again. $ ./example-advertisement Observe that the new intervals bcome 200 msec in btmon log. < HCI Command: LE Set Advertising Parameters (0x08|0x0006) plen 15 Min advertising interval: 200.000 msec (0x0140) Max advertising interval: 200.000 msec (0x0140) Press ctrl-c to terminate the advertisement. Signed-off-by: Howard Chung --- Changes in v2: None test/example-advertising-intervals | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 test/example-advertising-intervals diff --git a/test/example-advertising-intervals b/test/example-advertising-intervals new file mode 100644 index 000000000..8afc7225e --- /dev/null +++ b/test/example-advertising-intervals @@ -0,0 +1,48 @@ +#!/usr/bin/python + +"""A simple script to set advertising intervals through the dbus method. + +Usage: + $ ./example_advertising_intervals.py min_interval_ms max_interval_ms + + Example: + # Set both min and max advertising intervals to 200 ms. + $ ./exampel_advertising_intervals.py 200 200 +""" + +import dbus +import time +import subprocess +import sys + +argv = sys.argv +argc = len(argv) +prog = argv[0] +if argc == 3: + min_interval_ms = int(argv[1]) + max_interval_ms = int(argv[2]) + print 'Set advertising intervals: [%d, %d]' % (min_interval_ms, + max_interval_ms) +else: + print 'Usage: python %s min_interval_ms max_interval_ms' % prog + print ' python %s 200 200' % prog + sys.exit(1) + + +# Set advertising intervals. +bus = dbus.SystemBus() +adapter = bus.get_object('org.bluez', '/org/bluez/hci0') +adapter.SetAdvertisingIntervals( + min_interval_ms, max_interval_ms, + dbus_interface='org.bluez.LEAdvertisingManager1') + + +# Wait a little while for dbus method to complete. +time.sleep(0.2) + + +# Check the current settings using btmgmt. +btmgmt_cmd = 'btmgmt info' +for line in subprocess.check_output(btmgmt_cmd.split()).splitlines(): + if 'current settings' in line: + print line.strip() From patchwork Mon Mar 30 08:03:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464917 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F3A492C for ; Mon, 30 Mar 2020 08:04:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0337F20748 for ; Mon, 30 Mar 2020 08:04:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vLofLdyW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729608AbgC3IEg (ORCPT ); Mon, 30 Mar 2020 04:04:36 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:37995 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729586AbgC3IEg (ORCPT ); Mon, 30 Mar 2020 04:04:36 -0400 Received: by mail-pg1-f201.google.com with SMTP id n28so14289578pgb.5 for ; Mon, 30 Mar 2020 01:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=VzELVSkza2NBbJ60g1fS4kM/+lVRPquVxHqN+RjbPbg=; b=vLofLdyW4xlcHe8x+w5SGq68i0lZ9xIJc+QKhBG0QvoXzbKhFNnOYgBlDPZgY46v3e izg/EGZoexQAeQRwQaW+Erazryj8p0uClfWx1cvilSV2Jq03ifQpTlX9jTTW89ZIUVhX rYdOFMSCmsfHw/+JAvcUbyAiC+b1TdOOAvthJj9Dz0Sh3za0DBLoB0YWCU2ceB7PknDE WwcHKT5qGI/YQf/oKmWt+lRpHjPrnppBoMTGlJQ9ZYrTJ5ZqfHNJ6nccTyMm9wQU3jZj S9IVINQVwXGUKj/TOrkNERvsFiDjWWExrk7nXUohFyvMVOZfzZuwp8baBUfD4gNxMn8h 8ibA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=VzELVSkza2NBbJ60g1fS4kM/+lVRPquVxHqN+RjbPbg=; b=MO7ewU8UpwXXJWznBU2U+8eaeXe7qVjtCx3JeJ98uDoRZZlh0afBT80cePZvj34RZ6 hTGiGFkd3SJyShKGCZLdc0eY9z3xhRGXMtJVPvG6MimgwP+mBxjZ9ctxwqWSSkBIraMo 7ot9KmujuYFuBpkfSeWDYdQ6juv8tKlHZxFAuGz6jv0DCPNeb13HfGD/LIQsPFUBGnn6 bbUQKsRUd9KPKCSKl7Q3W4amhsFQy/VfTUMSTBDFUfh2ZDCbTfsF/yVI+ju5x05zZnkw MRa0/+26PVCr/rX2UJq8T3cn3SOi8jTDUM5syygN0QyMGvNY7dCsnE3fD/D1dEvBKDNr 0big== X-Gm-Message-State: ANhLgQ1ZWmOP5WDVqR3zuA93BUh8Or1FXPZTFwtfOMSJ4HhYUpQoT6cy xnCDvwiEwUsyzxJ7LciLTcappmEKpWdfmahnomfaVzxLQkpWt6wsQ6FOFU0I+1L7eJm3XSFGDCE kCMybJ13J1lQXp4fL5m84w6lOwwJYJ9wGuERMlSegsk87EWhuXT4+R37vCzltCkmW7TRbqsXad7 6o6UedxR3OVzE= X-Google-Smtp-Source: ADFU+vu8XXO0GAslRBTQAbVjtN5biw36pvtGkKzIoP+Q3Pb3eWveAScsR4WMX3kS5A228rvAbe/9mqlAuVPCCZlEUg== X-Received: by 2002:a17:90a:2503:: with SMTP id j3mr15061972pje.83.1585555475151; Mon, 30 Mar 2020 01:04:35 -0700 (PDT) Date: Mon, 30 Mar 2020 16:03:57 +0800 In-Reply-To: <20200330080357.96989-1-howardchung@google.com> Message-Id: <20200330160343.Bluez.v2.6.I469418408aadd72a98d675c7d8835cb79741835b@changeid> Mime-Version: 1.0 References: <20200330080357.96989-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v2 6/6] tools/btmgmt: Add setting string for LE Set Advertising Interval From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, Howard Chung Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org $ btmgmt info current settings: powered bondable ... advertising-intervals Signed-off-by: Howard Chung --- Changes in v2: None tools/btmgmt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index b1820b41c..91e9c0b40 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -355,6 +355,7 @@ static const char *settings_str[] = { "static-addr", "phy-configuration", "wide-band-speech", + "advertising-intervals", }; static const char *settings2str(uint32_t settings)