From patchwork Mon Mar 30 07:04:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464729 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 6D39A913 for ; Mon, 30 Mar 2020 07:05:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C0F220781 for ; Mon, 30 Mar 2020 07:05:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hh8o6sDL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729150AbgC3HFP (ORCPT ); Mon, 30 Mar 2020 03:05:15 -0400 Received: from mail-ua1-f74.google.com ([209.85.222.74]:36592 "EHLO mail-ua1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728489AbgC3HFO (ORCPT ); Mon, 30 Mar 2020 03:05:14 -0400 Received: by mail-ua1-f74.google.com with SMTP id l19so7331093uar.3 for ; Mon, 30 Mar 2020 00:05:12 -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=LqRKvlz2RXwyfDuS9QwSenyvzZ8B2ktok3zjnsNVt0c=; b=hh8o6sDLiYR1OU3kJsojsliWbt34KwwM6rMlHZdzz7bXK80ru2zB10uOksjJPm1LnB ed59lI0bM/a00uMmXmhUwX0PoeAdCWk9VLn2OakWIEiIzpN4o0Mxoh7ent6tGXlXkgNo JkS1OCy39fqXQZE2CRtniY9WXvKNbq1Xa0D9qbhIISKW7yopsTwgZUUSYZ4eqf8nIlTx Fgmc3rIX2Ldfv5ko44ZmtPsNIN6D6i1POVKyJMR/P6BRW3hY/aoEZU1dsLb1WlztEqrd lNkr6xo6eI4n02IctICYEeZ2hqkKr7eCaSxYHuO25tozEaLbTtbUre/djkFUgGCH2jh6 FRPQ== 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=LqRKvlz2RXwyfDuS9QwSenyvzZ8B2ktok3zjnsNVt0c=; b=BaKTfxOkeUm2gMYdHPqt/3GgrtLEJMvuDT0Sa8lsrnKtqRxij+1JqB8jf+Fo12ZJvU +xojGkBG6AM10N//mBsrrri5dZ2hYW31xxpRI04Y8QwHEL9tYZEzIsKESWkkO6FHUDzs 3UYP0D0u6N5gjXCpSHrleTqL4GEpZZHGKXG1/oHe7Gg8GGEstwNkz+pXBkFhJz0b+MBc EL8CuBV2aDEGLJ5mK9kFTflgz4scSPwiL8Vz86DxNwRWOQ1x7zQjdrVNEFZX2Q4Orq9A ZpIftVoVPJRoIJOoKVjfKOiONhnFu/jdfTlUwRu9k4i4yA7Bjr90TXG2V8UU3n5BHJ30 gdkw== X-Gm-Message-State: AGi0Pub4ndQUyUyi+pPhNKN2H3ZhaSGCUR3VL5tsQGbeapav5VYyJKt4 kh4ifGyGkk0HzRoYc9LFrKcwQMmll/Sc26i3g39inOuOVME6ITzSpZHtB77xrh4O7txcDlaL0jq wKyoLatGJScEA33yqZdvfQYostCZlqzEjTKOYWNgdlj/63EDSzv+M0Gigs9fVkVvsiTr282jruk FN+x6K4njHIdw= X-Google-Smtp-Source: APiQypLCxEEdrol1fNJu8Eh5Jqk+4ETihXlLuF5ofSlk/oXKc2C6kVnCJkZBJEhqC5BCNjkIkVuuzroi6VQuEnbjrA== X-Received: by 2002:a67:f81:: with SMTP id 123mr7235556vsp.50.1585551911960; Mon, 30 Mar 2020 00:05:11 -0700 (PDT) Date: Mon, 30 Mar 2020 15:04:33 +0800 In-Reply-To: <20200330070438.37316-1-howardchung@google.com> Message-Id: <20200330150424.Bluez.v1.1.I0c5d660478f6a1c2d70f4bf683460e11a96ec223@changeid> Mime-Version: 1.0 References: <20200330070438.37316-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v1 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 --- 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 07:04:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464731 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 71DC6913 for ; Mon, 30 Mar 2020 07:05:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5156920781 for ; Mon, 30 Mar 2020 07:05:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UW2TSgn3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729197AbgC3HFW (ORCPT ); Mon, 30 Mar 2020 03:05:22 -0400 Received: from mail-pj1-f74.google.com ([209.85.216.74]:57694 "EHLO mail-pj1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728489AbgC3HFV (ORCPT ); Mon, 30 Mar 2020 03:05:21 -0400 Received: by mail-pj1-f74.google.com with SMTP id np3so14385000pjb.7 for ; Mon, 30 Mar 2020 00:05: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=17WV3wHSshNZTqrKDBURt6jSVo9e/2Bnk+sFCCeMYic=; b=UW2TSgn33OQN+gAk46lO9oANxlnaofv7ViMHVOGmONBqjq4kqesSWI+4Eu4x4vApJv 0EJ1IWupicaByS1brKvPcKhjX6iuzNpBP+DpJklQP5vUaV4mkE5ttObdeClgRpL39cv/ GhRAW6PXdw80CR0SX9Ah8ST+kux+bu4TGFODqyk5DV+rSKHUCkqvY2yGkc/t9O5bp8zj rntAIazQPd6048zvl2WMuxjVGAFYXev6J7UbGp4AsXoeRyr2T/hCb+nBklDe3y6qovhy GVqhbvjavA9/W1cMVRRurPuTnYsnoOVtAOcsELZ7INenc/w4jYr7G17laEr6L4//EERa 3loQ== 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=17WV3wHSshNZTqrKDBURt6jSVo9e/2Bnk+sFCCeMYic=; b=WtI3RVyovErV7MEOsfuIOIS7dGAPblvwhW/3Nc4RLRTUYl/YCN2I8z67gQK7fJ+p7q K4EMQHI7semp0FRpvbD8G83aTGO6npitrqbHzPx3DBh/vWVhwIgi9O8odDFpW9TDTFZt 9yEpQwgUrQk96wGQLsMx6S2vo8R/t2SH/j8+Rrnimh9s0D5dGN4rmvOvWYbZRFlzD9Tp gCp8jEFH6OAL4QpD2JtdVbWo75KszUuP6FETfmvRL2tAXDlhSrEWAU0lqZrP2jMTkrwp eGTdy1ujwuWO46oh8mrFuPKM4loJzEwCOwaaMa+81zvHrRMZCKwQsdVcRNRJdqHboyl0 T5bQ== X-Gm-Message-State: ANhLgQ2TqJTHqPSiTakzyNfITuOtA5rTrP6AoIsGIJfPWT+pdi4jVDMJ j9674OmgG5kFIvK6NzJPG4nF8sxwIi37QIm4oTYcwuJTm0mmV3kSwzGk9gY24Eej0wMoOU+LFfS a6uT8KjVDtOGepO4HHISgMmVsz85wrEgJTqgv5cLVyHCG6q5otudAC2hlERsotDBfdxbYQr9ShT o1feXqziT9tSQ= X-Google-Smtp-Source: ADFU+vvSsEVpqdhf2NKBudC1DJ/mV+VxEtz7vH7UZPCdMVaYKYNxHWM0mqZJV8x3ggCKvER08RxfmViT95fvBkSlsQ== X-Received: by 2002:a17:90a:fa86:: with SMTP id cu6mr14187158pjb.93.1585551920298; Mon, 30 Mar 2020 00:05:20 -0700 (PDT) Date: Mon, 30 Mar 2020 15:04:34 +0800 In-Reply-To: <20200330070438.37316-1-howardchung@google.com> Message-Id: <20200330150424.Bluez.v1.2.I4fe5ed67f70011e5374e65929b845e13fe6ed59e@changeid> Mime-Version: 1.0 References: <20200330070438.37316-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v1 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 --- 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 07:04:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464733 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 A0F7A1392 for ; Mon, 30 Mar 2020 07:05:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FCA720776 for ; Mon, 30 Mar 2020 07:05:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="U2mhUasD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729309AbgC3HF3 (ORCPT ); Mon, 30 Mar 2020 03:05:29 -0400 Received: from mail-qv1-f74.google.com ([209.85.219.74]:56173 "EHLO mail-qv1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728489AbgC3HF3 (ORCPT ); Mon, 30 Mar 2020 03:05:29 -0400 Received: by mail-qv1-f74.google.com with SMTP id j7so13601434qvy.22 for ; Mon, 30 Mar 2020 00:05:28 -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=4N9Dp9kTeuqxUzbxjytSqdNoFslKRE9NnJSL/k7VjB0=; b=U2mhUasDps8kDbeKwefXcMyE0bei2tbRBns15g30Hv1lg4ST2TjqRJzoZo5bBuTUht pnrITyWfbFUa91RsgRNzOpCpQ4NLnbRDMdIT7YVct1TEZ918lzzKBnYkQebSAaUkhtC7 Dmcw68hp7nBT46iHFso988jLOcmUCPl1e3GynWTvKqhkeM4uLHNZkPaxJuUUTdGDE6wh FkdBFu/qqrPOgQqUUCFNJ5CU4UpLF4K0kQDMcBmgQXB+ifjPCSMda7hcduJ3w3RqMFgV 9idAk/37nKHzO7kXq0ydZtkPVXs/8VuTZysdleGBwWk53fUe6GJyEhi9i3bhIVTEXW/l g68g== 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=4N9Dp9kTeuqxUzbxjytSqdNoFslKRE9NnJSL/k7VjB0=; b=KLhG44QbiVqTrOThJL8Kq6QkzrVa2bZGE4GzxmFN+ZcWJJTfzeflrn+gIJ44Uw8FR/ ZCQikJ20Pbqlo6a8nanXNQcRP6OF2v53LVTgTEJIUOAhPWjn/XRvgTZ3ORlKVDsc/fWP TmCSTBQpMVFvQeKNtUUpv6y3dHvx2ljE0QfcqdvwCnhtlCYrkeo8EmsfuYmd12H2sjaX mjgkw7aSn6OLG5Gru8twxXd/Biz6h4Iw0tIdhlxp5hzNPc9yV3P2qE9UgtK4vWWOVaRb j1Habs4wZ5rWd9Vc3FZbwVuwDyNlqDNBSGCy7ZZK7l1tiI2iIpnLVJG2Q0BF4TQtKp7t eiAg== X-Gm-Message-State: ANhLgQ0KNnb/yYhmBgNOqyHwuRJt3iBgFmr0aoTrLnnTpxMKr8ZYCJHR H+8eeHNd7UFbRd5WeXJfLWrt9h5Mw+oNE9KRwIZt9fsag2VTUqgHILlpH4Gof4Dq1KN1h+Es3iX DquhrsEsoL0Og27fYL5FssAP+Hx4m1/Zz0GEj/mc1tkyraNKt+AnF6QCDa1iNS6kh3M9GB6kWT8 pLVYmi+TrlmUg= X-Google-Smtp-Source: ADFU+vvONcmpMbDRDdrdc0vZ3/th0gMH7+/ZJDtlb8kz+E36WIJA5sLEuPTO+5yVIg/eh3Wewkl7MocKwD2VrXAf/w== X-Received: by 2002:aed:3c4b:: with SMTP id u11mr10393773qte.208.1585551927866; Mon, 30 Mar 2020 00:05:27 -0700 (PDT) Date: Mon, 30 Mar 2020 15:04:35 +0800 In-Reply-To: <20200330070438.37316-1-howardchung@google.com> Message-Id: <20200330150424.Bluez.v1.3.Ia74c1ab0a71d90f46f10b4e32743cab722a97bbb@changeid> Mime-Version: 1.0 References: <20200330070438.37316-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v1 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 --- 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 07:04:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464735 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 2F0881392 for ; Mon, 30 Mar 2020 07:05:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D4B120781 for ; Mon, 30 Mar 2020 07:05:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ExilzM/D" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729150AbgC3HFg (ORCPT ); Mon, 30 Mar 2020 03:05:36 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:49000 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728957AbgC3HFg (ORCPT ); Mon, 30 Mar 2020 03:05:36 -0400 Received: by mail-pf1-f201.google.com with SMTP id d16so7501036pfo.15 for ; Mon, 30 Mar 2020 00:05:34 -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=1A8ERe+jjCXUJhlc7waAuAvi0lXDAcxG3TaIXHLmUDs=; b=ExilzM/DR+pArc4TRsrmIC9FTyqh4RW0IZ0N78AWhxduYu+Kfk6W5PQ5xXpY08kkbI XwJpjUMGMDrrXlAxxM8faw185Vqlb3K1QcDwrDvk26Uk10i8x6HSn3wYWidD+xRxjzSK ryijFeTOf7kMHS/pG8JfmNiMLmT0TdYa9YnC1vOlFZW9yFUrSYyHpKT1dmU7c3B60tcq aiuslyjyUjWlm3hHAM2MlYBDEFDEV8EODf7XNYfsFMmkOw2sxAcxMEoCGIEYYRur0H82 8RdZzs+2ycrYuOd3Oe6uIyER7SF29Cvn4GABVd3/w+S6A3nlsKdpPVcGzzI0ENdiL9jB dgwA== 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=1A8ERe+jjCXUJhlc7waAuAvi0lXDAcxG3TaIXHLmUDs=; b=IAf5+U5KnEpW/LE7tEfeiwcLfWKyEKdZ8Oe/Z4AMBa/13q7FzQkToozYcym8LnNMh+ 9JsEv+YBGNrOwAWc8jlmD5Pp1HKJNITXzHjgD3QLUblWc1J3c5YUzZJHIZzvY0GVSfL5 HIpRGkMcSBuphMFxW3Y7IKbj5g3XQtL42QmuiUH1ibpMPfmum4sKocAPhZWLkWzl8Alb gce2DRih3Mw4+XsjRmNALF51aq1CIN4B6tcCLr1va4UXsIoC6XJTLkTLHaQ7I/g9AQcH rg71NQ7yXLbQxdB0FLd0tSry2S5nfbBDUOKfdRNPKEAFEtev1IivUPViAeeFNJzbGKdM FVgQ== X-Gm-Message-State: ANhLgQ0Nvkf4bLiRj8VGpzEbnpe2PDjo6Frf3Y/2Ix2CBtsUFQ04tesa xXSJZA9g0dtFGLdNxUsk3X8dacvfu3yEqF+LRmVuclPZeE4JyWFY930kNxS3NF0QadJi+viSnCO FfUODBA5jkD3aLHCTFy9bhBbOHjegFv1f8jaR8XYO2mBopE3zXp04quV2RftKtdUsv2NhcbCryC QroNZlVjqmoGc= X-Google-Smtp-Source: ADFU+vvxKAsicVDxXQbx5V5UGYl7sBBieBnKQRsQSW7VHyuggSePvq7RWTWMgAa0p73jdzRMAK572jZuct/dHDwnYg== X-Received: by 2002:a17:90a:3ad0:: with SMTP id b74mr14870076pjc.58.1585551933518; Mon, 30 Mar 2020 00:05:33 -0700 (PDT) Date: Mon, 30 Mar 2020 15:04:36 +0800 In-Reply-To: <20200330070438.37316-1-howardchung@google.com> Message-Id: <20200330150424.Bluez.v1.4.I0a98775e764e9f8dba1652853b6e7ba440f4c75b@changeid> Mime-Version: 1.0 References: <20200330070438.37316-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v1 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 --- monitor/control.c | 1 + monitor/packet.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/monitor/control.c b/monitor/control.c index 790890fb4..cbf8d41da 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -201,6 +201,7 @@ static const char *settings_str[] = { "bondable", "link-security", "ssp", "br/edr", "hs", "le", "advertising", "secure-conn", "debug-keys", "privacy", "configuration", "static-addr", "phy-configuration", "wide-band-speech", + "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 07:04:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464737 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 AF5AA913 for ; Mon, 30 Mar 2020 07:05:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E47520776 for ; Mon, 30 Mar 2020 07:05:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="g2bqqkdj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729089AbgC3HFk (ORCPT ); Mon, 30 Mar 2020 03:05:40 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:47617 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728731AbgC3HFk (ORCPT ); Mon, 30 Mar 2020 03:05:40 -0400 Received: by mail-pl1-f201.google.com with SMTP id l1so12274156pld.14 for ; Mon, 30 Mar 2020 00:05:39 -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=sRxvBt9CbHrEaWbg6j4fY+lBQ0TJ6ryxG2Jm/LbqOgg=; b=g2bqqkdjudMNT02IE4EeyXbWWp3tAWdmRbnAuSj+zdL/5/cBgR5Ogh7+2Rp/3sh85M YXhZ1fK0ejcXS9Io8TMr9itHrkewI2f+447X+B5P/ONbZUHFt8agW3BBCg16M8MahZ48 BB0lxJ6x20rhd9KuzQlKU268xNFR+dNjIZlBlo0+yAV5hZ91ycqDCtnhSPYPnF1WPU+S UrDnyC4pIp/VRVvK/lL4x70FSYFKIfo6g0DEIepCINNqz62HR75+cpSZYVISBzJ96t93 lGyZLcDofST1lLsi8iNXEpgDFK9cVu90q6BjUKkMdWATQFBlKhfU9YhUQ4HOxMDqT2OY 8oWA== 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=sRxvBt9CbHrEaWbg6j4fY+lBQ0TJ6ryxG2Jm/LbqOgg=; b=Yv4dhbWPZJHUq6GdNXvDD02ty+Sp9SAzwuRH7mhAfKcW2Yq4zIp8ZoUaKh7vG2WUfW 4ssJKM9EStDYZVxzyQe5lLBV0r7ObETfWII89CBHOtxILqkKdREqUPcQh2T61Gi1vbxI bxzmXLyFxQU82WTkklX09POaZS15MNC8oHw2s6k6qVMbFGFbyRCbggd4pf4ev+rE5oHF 2tsTFr7TGWqSgxI1Y1BmLIajY2LlHKZaT9Lm1WkVkCuYPUgZ50iatf09OcpIuDULfR6D JvNWVsar1HwXvmV5rPtOe8zMO+nqYbM61NuLbOaDve8BR0cey4U9imbFXYwRE0qvvULz XScw== X-Gm-Message-State: AGi0PuapDA0pCfo3+QMcACYOGQf6dR33UAKMZk3GkpACYBBjz/MkA98J pJB4AHvgkrKxwt8ryRP1isTHKIRaHY8B9OlvSNMHh+0JCnmFb4UF55lzy6T9LgYD+pveFTgrGzX qFmc6uSneetFu+9sijLAE4moMsxu8nRZqgx1Oq6u+gDnvd05FVGyLfWYeMryKR8iW0FiiKZ4L7E jwjGvLQ1pDfXc= X-Google-Smtp-Source: APiQypJV8aSwyyhTAVElL8APbeWX7FnwdSF4Vecycg//QO4qUd8+wy5MaJZgya31Eg/igholOxkqWhxTViDOsiBRtA== X-Received: by 2002:a17:90b:1116:: with SMTP id gi22mr10026804pjb.134.1585551939036; Mon, 30 Mar 2020 00:05:39 -0700 (PDT) Date: Mon, 30 Mar 2020 15:04:37 +0800 In-Reply-To: <20200330070438.37316-1-howardchung@google.com> Message-Id: <20200330150424.Bluez.v1.5.Ie551a8a414d17604f04e10cf8d9c514a2b170e31@changeid> Mime-Version: 1.0 References: <20200330070438.37316-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v1 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 --- 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 07:04:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Chung X-Patchwork-Id: 11464739 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 A57951392 for ; Mon, 30 Mar 2020 07:05:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A72120776 for ; Mon, 30 Mar 2020 07:05:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bdWBaJio" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729150AbgC3HFr (ORCPT ); Mon, 30 Mar 2020 03:05:47 -0400 Received: from mail-pj1-f74.google.com ([209.85.216.74]:56055 "EHLO mail-pj1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728731AbgC3HFr (ORCPT ); Mon, 30 Mar 2020 03:05:47 -0400 Received: by mail-pj1-f74.google.com with SMTP id y21so14392679pjn.5 for ; Mon, 30 Mar 2020 00:05:46 -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=t2dXNqO1VZ6ka+XgAqt99Zn3WvCFoWXIyyD5CoC/I3k=; b=bdWBaJioddkC0e6GqJpMkiP1FnbfOMijF3RKhULLxMXsCxRtVKz0wu/UHiDQpp4460 B+1c2vA+zBWzLe5r3bwWcxECC1U07vJVv1P74yJps0TEQMc2QHzIEKEx8or99g81Zx4l Ab7JcRhGo+inTJch9awX+nuA7K7EM+Pc8hz8ZkcDe+dmK+OYUJd2DUZZ83WNmVf6B+sF IRWn56TZU7GKUgEAuLcUsX0Br1VZ5iZg4514x2PA8bFOAwpZfgzqEmVbyMunkqihal97 J+BgXzkG1J0bTl38nq1K3Zp8fspeVVd5BDr2WIjaiAT7oUaV+ec4K2NrXHxylBM9I5kY CkzQ== 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=t2dXNqO1VZ6ka+XgAqt99Zn3WvCFoWXIyyD5CoC/I3k=; b=Lec07HtO4nhq3WWunk1P00Rhd48Dawl6KXCuyYaDvBmOGv5Pocdk83xlvZ9UWHG2Vs q/6kImVhOBQaDoKo3hmxB5SCZ0uYsyfU+9ykh7ZKSDA6w7/OwzujVLezUMaN7ctWkuGp GaujQWiOAPzFSoiCcCsz7k6ec/Ifm/SZVqRbt0T8jYQrFhwTcecNCtm1bAexDJEJUCZd vwcP+fS7elsps2IE9zrXWb6gA74njo/Mb92WswvH9gPelHBfbHVe3d4c2bJCxdhdyNsw Nd2jdcrbg1UktGRIr20Uf1MDYoZ1/V5gxBiK1fMS5H/QPAzJbvo1evIhEc8KeejAAWNW iuIQ== X-Gm-Message-State: ANhLgQ3PtUkM4duQUekGcKgh6R6Jgrxfsmrmgfu7Bl6+EGgdKTtl8Bq9 bvzabCgKnlE22GxpvwnsoWQEUIaWKPjetwXVaXwoc9PXotjLbDaIRY4kjpIqw8X91tonoaBtJZX OIWf/p/toix1KaJQ2+o1wnmHgh4pdecTyyIq6ZoZot+f8ThSg7/LF+SJokTkBGpH5fB3EPlexLO lc+2NUbbevBsM= X-Google-Smtp-Source: ADFU+vsgtzPJHVcTKwL7O9LfHycSyDDyP9EOlEumDrQcEaUxPf8qQg6G6MWscyFhNYvvpPehuy/MQ0PkugL0uHVp1A== X-Received: by 2002:a17:90a:be11:: with SMTP id a17mr14735596pjs.150.1585551945709; Mon, 30 Mar 2020 00:05:45 -0700 (PDT) Date: Mon, 30 Mar 2020 15:04:38 +0800 In-Reply-To: <20200330070438.37316-1-howardchung@google.com> Message-Id: <20200330150424.Bluez.v1.6.I469418408aadd72a98d675c7d8835cb79741835b@changeid> Mime-Version: 1.0 References: <20200330070438.37316-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v1 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 --- 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)