Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp104940pxb; Fri, 5 Mar 2021 15:59:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+WFksdIKbaqjVJ3vkK1wwYNPpjXbVPrYun1lZfcsydvV2AwT9h8TCEXVTRIQmymdZRSBz X-Received: by 2002:a17:906:2743:: with SMTP id a3mr4787760ejd.378.1614988742962; Fri, 05 Mar 2021 15:59:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614988742; cv=none; d=google.com; s=arc-20160816; b=MUxQur29/2C6wqsxgqpz8M926FNYGjqohOpSeoJhDd6o8jze4ciCa++Nql+J9AJKg5 VEhnUNYsT8GnjN8iTAszdS7kG6sKL7MwNBFy517fEgTKI0byWcBtlPiIapGIuj/rmtIW HyQ/NAU9U66rWvkqtZQxWiVGUuVZlYOoEKK4h3Mq35ElwcTOA2xywpLAbJQg983bJMeu qv7ufCl6DrnUBPiu0N7OgbVL1aQXIGq9XJgcyArbCYLyCFJi62rO3nueWC9JSGIOZD10 ycQ3q3d8NIm3xusksQapHNA2EikiT3KSCnAW1zf2RztJ6RRwysyGkqgQ9hyo26eyxBdQ jiwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=QXCaWeacRSyK84p34eElm2tdjRHFV2ozbDFoOiTQlIM=; b=yfqpAsRx4Dzt9//SCtyL6tUazIXg8L/z26Hnalrho1b6xJdEkUSvDRpURXDi3gIee6 OSk7g7YW8qFwnTU4f4pb0rOJ776IxCH7daf3ntTnqdXkPqM1L9Q7vNFGSX63DcVusCuL QbD0ejTPGaX+KlGooaOvHmZ/qGhicXPbgoSBpIIosL2BJ9DWEqrelF9ozbinguZ2nFUF /hoysgsmLHBHfBSgZLYRYokUWyR2a7kTc2xP9+M8xOffh2HokEAX8Y1Rngh4KZGu+PXD bxcTSkKBmYrLNn4tMl5mdqcE4rOG4cCvTAJcpUsrftHUUp+v0zQyiJ0zUItD/n6G2Igq zrgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QVRJwjdL; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si2009272eje.538.2021.03.05.15.58.25; Fri, 05 Mar 2021 15:59:02 -0800 (PST) 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=@google.com header.s=20161025 header.b=QVRJwjdL; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbhCEXwl (ORCPT + 99 others); Fri, 5 Mar 2021 18:52:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbhCEXwZ (ORCPT ); Fri, 5 Mar 2021 18:52:25 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E1CC06175F for ; Fri, 5 Mar 2021 15:52:24 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id v196so4288779ybv.3 for ; Fri, 05 Mar 2021 15:52:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=QXCaWeacRSyK84p34eElm2tdjRHFV2ozbDFoOiTQlIM=; b=QVRJwjdLKTCRFelNUHOGp2Rlne4TrfetuJp/0+RRzuX8o1aPo6RxiXUTYr7HeqU140 S/lcaK3e2egnY48YV88pSoENZSQhITZVfmC58h4r29Yio3QfMe7B24NvdKa5nxMcZVOy dWmh3XmeeEb//SHl5Vz5+4Fm9r/BBoib9+JMif1Z/bepbBrT7tObmTbwnYuc+4u0/Tiy UKK+eaSYgX5zcx9tMoAxIHKo8mitFHQ7OVeaOQrFL6h74z7KqIAXPE6NK33L3J2izBCn WD5U0Val0iO19NziqkwexMkqZFxHEQUEOxjDu1uMPmr7sqPEtWyfvxrCeP6HzdXDQkwC gCNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QXCaWeacRSyK84p34eElm2tdjRHFV2ozbDFoOiTQlIM=; b=L/52QaG//C/ZiteuF1pfRf4LC6UzKiqJLkOFXwr1iB30Ixeijpyjowdzteyej/2Dum iatULml/x9Mrs/U5sKRCJNy3E5jqXE6XMIne481Nk+RMR0KErY18ILKb8bZTQ1jfaAbP 86en7gRe0mDLQuWxYQHz4j2Eq9E08ibOTc5ySRy/ObYZTEcTC8o/O8btSSSM6SGCA9xo ygxpZg0P/agw2mZCYw0Z4X4A3FNMyCsH7GbOEOhEKAEthKSctZ0neugJgJA0RQb28XYH EOYrr++/kM3hT+LxaNiqAMiE4Ask2TyjO9dSF1PlM7HNZHNKoglVSxWqQF5eKZdMJPxg VlbQ== X-Gm-Message-State: AOAM530PA13b53mqB1VYaPdOarfQZLnq9pVtJGJ59ZAbOk1qgrW0NYfe TPlQORKcftCoPqHK0CJkoLcfRR1kp+mP8bXaJZykeWoODkVz4IGl5ZoU9Y8dxNCm8RAdXzsFsyW uAoAexq/PIz67QNtiiZPr+LHOaNyr9ZW9H6Z7mE9Dtf4dDVLRrDOel8MO5cEO6+qgEZtTZC1mOB c5B1I5fqXCS4xHTD9A Sender: "danielwinkler via sendgmr" X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:94dd:309a:2fcb:13a]) (user=danielwinkler job=sendgmr) by 2002:a25:d943:: with SMTP id q64mr16822819ybg.508.1614988344178; Fri, 05 Mar 2021 15:52:24 -0800 (PST) Date: Fri, 5 Mar 2021 15:52:15 -0800 In-Reply-To: <20210305235217.2382976-1-danielwinkler@google.com> Message-Id: <20210305155113.Bluez.v3.1.Idf2f9f409a4df20b466ba723dd9b729275a5afbf@changeid> Mime-Version: 1.0 References: <20210305235217.2382976-1-danielwinkler@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [Bluez PATCH v3 1/3] advertising: Add SupportedFeatures to LEAdvertisingManager1 From: Daniel Winkler To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The new SupportedFeatures member tells advertising clients whether the platform has hardware support for advertising or capability to set tx power of advertisements. Additionally, fix small typo in "secondary_exists" function name. Change is tested on hatch and kukui chromebooks by using dbus-send to verify that SupportedFeatures always exists, and is only populated when extended advertising is available. Reviewed-by: Miao-chen Chou --- Changes in v3: None Changes in v2: - Expose empty SupportedFeatures if no support available lib/mgmt.h | 2 ++ src/advertising.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index 76a03c9c2..c0021abd8 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -503,6 +503,8 @@ struct mgmt_rp_add_advertising { #define MGMT_ADV_FLAG_SEC_1M (1 << 7) #define MGMT_ADV_FLAG_SEC_2M (1 << 8) #define MGMT_ADV_FLAG_SEC_CODED (1 << 9) +#define MGMT_ADV_FLAG_CAN_SET_TX_POWER (1 << 10) +#define MGMT_ADV_FLAG_HW_OFFLOAD (1 << 11) #define MGMT_ADV_PARAM_DURATION (1 << 12) #define MGMT_ADV_PARAM_TIMEOUT (1 << 13) #define MGMT_ADV_PARAM_INTERVALS (1 << 14) diff --git a/src/advertising.c b/src/advertising.c index 15a343e52..dd6008cb9 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1616,7 +1616,8 @@ static void append_secondary(struct btd_adv_manager *manager, } } -static gboolean secondary_exits(const GDBusPropertyTable *property, void *data) +static gboolean secondary_exists(const GDBusPropertyTable *property, + void *data) { struct btd_adv_manager *manager = data; @@ -1640,6 +1641,43 @@ static gboolean get_supported_secondary(const GDBusPropertyTable *property, return TRUE; } +static struct adv_feature { + int flag; + const char *name; +} features[] = { + { MGMT_ADV_FLAG_CAN_SET_TX_POWER, "CanSetTxPower" }, + { MGMT_ADV_FLAG_HW_OFFLOAD, "HardwareOffload" }, + { }, +}; + +static void append_features(struct btd_adv_manager *manager, + DBusMessageIter *iter) +{ + struct adv_feature *feat; + + for (feat = features; feat->name; feat++) { + if (manager->supported_flags & feat->flag) + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &feat->name); + } +} + +static gboolean get_supported_features(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_adv_manager *manager = data; + DBusMessageIter entry; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &entry); + + append_features(manager, &entry); + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + static gboolean get_supported_cap(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -1678,7 +1716,8 @@ static const GDBusPropertyTable properties[] = { { "SupportedInstances", "y", get_instances, NULL, NULL }, { "SupportedIncludes", "as", get_supported_includes, NULL, NULL }, { "SupportedSecondaryChannels", "as", get_supported_secondary, NULL, - secondary_exits }, + secondary_exists }, + { "SupportedFeatures", "as", get_supported_features, NULL, NULL }, { "SupportedCapabilities", "a{sv}", get_supported_cap, NULL, NULL, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL}, { } -- 2.30.1.766.gb4fecdf3b7-goog