All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Winkler <danielwinkler@google.com>
To: luiz.von.dentz@intel.com
Cc: linux-bluetooth@vger.kernel.org,
	chromeos-bluetooth-upstreaming@chromium.org,
	Daniel Winkler <danielwinkler@google.com>,
	Sonny Sasaka <sonnysasaka@chromium.org>,
	Alain Michaud <alainm@chromium.org>
Subject: [Bluez PATCH v4 08/10] advertising: Expose SupportedCapabilities for advertising
Date: Thu,  1 Oct 2020 16:01:50 -0700	[thread overview]
Message-ID: <20201001155738.Bluez.v4.8.I4e536cf2c9b6c5571b4b3800dfb8338fce8e4421@changeid> (raw)
In-Reply-To: <20201001230152.2422908-1-danielwinkler@google.com>

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 <sonnysasaka@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
---

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


  parent reply	other threads:[~2020-10-01 23:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01 23:01 [Bluez PATCH v4 00/10] Bluetooth: Add new MGMT interface for advertising add Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 01/10] doc/advertising-api: update API with new interface Daniel Winkler
2020-10-27 21:59   ` Luiz Augusto von Dentz
2020-10-01 23:01 ` [Bluez PATCH v4 02/10] doc/mgmt-api: Add new Advertising MGMT interfaces to mgmt-api Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 03/10] doc/mgmt-api: Update controller capabilities MGMT command in mgmt-api Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 04/10] advertising: Detect if extended advertising mgmt commands are supported Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 05/10] advertising: Parse intervals and tx power from adv Daniel Winkler
2020-10-27 22:03   ` Luiz Augusto von Dentz
2020-10-01 23:01 ` [Bluez PATCH v4 06/10] advertising: Use new mgmt interface for advertising add Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 07/10] advertising: Query LE TX range at manager initialization Daniel Winkler
2020-10-27 22:08   ` Luiz Augusto von Dentz
2020-10-01 23:01 ` Daniel Winkler [this message]
2020-10-27 22:05   ` [Bluez PATCH v4 08/10] advertising: Expose SupportedCapabilities for advertising Luiz Augusto von Dentz
2020-10-01 23:01 ` [Bluez PATCH v4 09/10] client: Add SupportedCapabilities to bluetoothctl Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 10/10] monitor: Add new MGMT adv commands and events to monitor Daniel Winkler
2020-10-12 15:53 ` [Bluez PATCH v4 00/10] Bluetooth: Add new MGMT interface for advertising add Daniel Winkler
2020-10-26 22:02 ` Daniel Winkler
2020-10-27 22:13   ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201001155738.Bluez.v4.8.I4e536cf2c9b6c5571b4b3800dfb8338fce8e4421@changeid \
    --to=danielwinkler@google.com \
    --cc=alainm@chromium.org \
    --cc=chromeos-bluetooth-upstreaming@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.von.dentz@intel.com \
    --cc=sonnysasaka@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.