Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp859966pxk; Thu, 1 Oct 2020 16:05:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7lxfSdzkOfvkwGHGtlSSaQjyOSR9fgR7Q1/Foi99i2wYWG8GEJJcBiMDHbsI1sR1v28Hc X-Received: by 2002:aa7:d68c:: with SMTP id d12mr10959320edr.274.1601593548271; Thu, 01 Oct 2020 16:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601593548; cv=none; d=google.com; s=arc-20160816; b=TQXaGvRxQBeR6+4XRJaymJss6DtuSUNkeURKDEr4OBp24jS9VoN9WXsRrsffCHkbUc 82P2GHzaB0Cv88+8zYe5a+oxH0NbQfbPCPExUifAGlTZKpH15wDKDMS88bq9lMNZR0O4 RXUd3WpSivYEKTo1Ny4aOOjNM/vFRxgO4j+978LousdvicvptgQ1eG+RKk73lDldSaaL F5mD0oAoCorpO3yD+T5eXKgx1rxAsd/NdXrJTz3CdNnE88H/dKnVOghXTDjF+q/iPAIS IvocC47nXScIuqf2DUvV9dsZXd20b31pgMQ3qTDeRZLr4lFDu8YlkL3ijlzLd21fru2d FSog== 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=maUrfGT7jy9cVJbqXYrpdONDLxxV8RzyhqkrkcruXa0=; b=sQnVJsEsKItT2BvXDKAJBjrnleBIrvmNP1KS6E4itK1N3U5YxlN6T6DzKcS/9rqEN1 pDTciOKuU/Oc6zmGm+FE7ngNYERMvbZJJZtFYgjDWL+JiNfyVTK7sKZZo+laY/Fo8v0K 0Qnptfpc4FLEk0XYdHV2uI/Zh4bwr6E573TpN16LKsZFkwXyjhye/T29jpKU+njUHOcf GlmvadNc/za/ngAUUTKwi2JrYg5gOo+aBNMrx33YAuhMiYiUDKLrgPkUsZ8FOfjjJhu9 Cvr41hqv1Zo1IadEwx/NpNZkf5lQFqWcQgUnQ4sjUhbmRuWUNbfmuXz2sA+MDIqNn71G 3IEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="LVc7Q/yD"; 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 p17si4786588ejf.290.2020.10.01.16.05.24; Thu, 01 Oct 2020 16:05:48 -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=@google.com header.s=20161025 header.b="LVc7Q/yD"; 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 S1733251AbgJAXCP (ORCPT + 99 others); Thu, 1 Oct 2020 19:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733085AbgJAXCO (ORCPT ); Thu, 1 Oct 2020 19:02:14 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5A9CC0613D0 for ; Thu, 1 Oct 2020 16:02:14 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id s12so53750pfu.11 for ; Thu, 01 Oct 2020 16:02:14 -0700 (PDT) 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=maUrfGT7jy9cVJbqXYrpdONDLxxV8RzyhqkrkcruXa0=; b=LVc7Q/yDyoic0OxwZR1m9fScoMjTcknFfAWJs8BoUtA+SGyPsZJubCmUUpJRIOB08d w+cfE5en7HLZ+uuC+L7MAUjP6Hbhv4X9jfAh3gZmjqBkHkglLCYyGIkrRlt02rVnZ6Fz zTH+H3ZuYZrT1SOZ+SOSX6jKegaPbtDwMdzWyL23AKT59pEDk2AwrHT7wziNVeO+o0ME 8p6F886eKMCu6wVjVYXvFAsj4R7a29IsGjALb32stLWrQAABrThaC8XnqS6ypmEyg3+5 MXdkjDrhmbMAB07WXVsjrQXoGuPPJevLXdmGnOQgUVl+8acJyqi4CoWZ1sNIicfAvrfH DfvA== 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=maUrfGT7jy9cVJbqXYrpdONDLxxV8RzyhqkrkcruXa0=; b=MqVtAQZIJ6prYdRmu7ouE3+KYxR9cDe/6UDvsH4RZpByUZfIGKZhSJCqgAfi4VAw12 v8gF5Y63kwMh2uOPyoGAOixZecuz0XobRnE3WxqQZoii3//sckDz9m7bHlq+LB8RQktp 9ysSvt7WRc74M8XZT4P1HEkaWZaugoQ5IkIM8x7SZHgWayJIdX1vjUF3mhvTbjmNiZrj P7HnWxPVW1Vog+grLFwvryRo/nvetFELa6qHfrfuGUUi4daTZ3ppDN6Zy5i2DyqXyCrY kopl+ekarKtK39j91QsgXvMt/1kygqE8dxdZE5Kp0Itl8iwXt0e5XSO4Jaw8ZzzOAfSk RT2g== X-Gm-Message-State: AOAM533hKV47nsj1ZqkxD+jwYh+wPSOcvYVYrvwH34rreGRhI3OCLHP7 QWgX7YruKxWhHnYq/tmrvBHtL+o85oA7rK9Dl8ER Sender: "danielwinkler via sendgmr" X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a63:e145:: with SMTP id h5mr8179334pgk.334.1601593334146; Thu, 01 Oct 2020 16:02:14 -0700 (PDT) Date: Thu, 1 Oct 2020 16:01:50 -0700 In-Reply-To: <20201001230152.2422908-1-danielwinkler@google.com> Message-Id: <20201001155738.Bluez.v4.8.I4e536cf2c9b6c5571b4b3800dfb8338fce8e4421@changeid> Mime-Version: 1.0 References: <20201001230152.2422908-1-danielwinkler@google.com> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [Bluez PATCH v4 08/10] advertising: Expose SupportedCapabilities for advertising From: Daniel Winkler To: luiz.von.dentz@intel.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler , Sonny Sasaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org To help our advertising clients understand the device capabilities, this patch adds a SupportedCapabilities dbus endpoint for the advertising manager. The primary reason behind this is to provide the valid LE tx power range the controller supports (populated if controller supports BT5), so a client can know the valid power range before requesting a tx power for their advertisement. I also thought it would be useful to indicate the max advertising data length and scan response length in this endpoint, since some clients will find it useful to set their advertising data (currently experimental feature) or scan response data (possible future feature) directly. This patch has been tested on Hatch (BT5 support) and Kukui (No BT5 support) chromebooks to verify that the dbus endpoint contains the correct data. Reviewed-by: Sonny Sasaka Reviewed-by: Alain Michaud --- Changes in v4: None Changes in v3: None Changes in v2: None src/advertising.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/advertising.c b/src/advertising.c index 41d0658c8..f76831594 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -1619,12 +1619,46 @@ static gboolean get_supported_secondary(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_supported_cap(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_adv_manager *manager = data; + DBusMessageIter dict; + int16_t min_tx_power = manager->min_tx_power; + int16_t max_tx_power = manager->max_tx_power; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, + &dict); + + if (min_tx_power != ADV_TX_POWER_NO_PREFERENCE) + dict_append_entry(&dict, "MinTxPower", DBUS_TYPE_INT16, + &min_tx_power); + + if (max_tx_power != ADV_TX_POWER_NO_PREFERENCE) + dict_append_entry(&dict, "MaxTxPower", DBUS_TYPE_INT16, + &max_tx_power); + + dict_append_entry(&dict, "MaxAdvLen", DBUS_TYPE_BYTE, + &manager->max_adv_len); + dict_append_entry(&dict, "MaxScnRspLen", DBUS_TYPE_BYTE, + &manager->max_scan_rsp_len); + + dbus_message_iter_close_container(iter, &dict); + + return TRUE; +} + static const GDBusPropertyTable properties[] = { { "ActiveInstances", "y", get_active_instances, NULL, NULL }, { "SupportedInstances", "y", get_instances, NULL, NULL }, { "SupportedIncludes", "as", get_supported_includes, NULL, NULL }, { "SupportedSecondaryChannels", "as", get_supported_secondary, NULL, secondary_exits }, + { "SupportedCapabilities", "a{sv}", get_supported_cap, NULL, NULL}, { } }; -- 2.28.0.709.gb0816b6eb0-goog