All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Winkler <danielwinkler@google.com>
To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com
Cc: chromeos-bluetooth-upstreaming@chromium.org,
	Daniel Winkler <danielwinkler@google.com>,
	Alain Michaud <alainm@chromium.org>,
	Sonny Sasaka <sonnysasaka@chromium.org>
Subject: [Bluez PATCH v2 2/3] advertising: Create and use scannable adv param flag
Date: Thu,  4 Mar 2021 12:24:51 -0800	[thread overview]
Message-ID: <20210304122005.Bluez.v2.2.I45b896f4512038309cbeab7a01f51e503141edab@changeid> (raw)
In-Reply-To: <20210304202452.1998022-1-danielwinkler@google.com>

In order for the advertising parameters hci request to indicate that an
advertising set uses a scannable PDU, we pass a scannable flag along
with the initial parameters MGMT request.

Without this patch, a broadcast advertisement with a scan response will
either be rejected by the controller, or will ignore the requested scan
response. The patch is tested by performing the above and confirming
that the scan response is retrievable from a peer as expected.

Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>

---

Changes in v2:
- Check kernel supports flag before setting it

 lib/mgmt.h        | 1 +
 src/advertising.c | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/mgmt.h b/lib/mgmt.h
index 76a03c9c2..7b1b9ab54 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -507,6 +507,7 @@ struct mgmt_rp_add_advertising {
 #define MGMT_ADV_PARAM_TIMEOUT		(1 << 13)
 #define MGMT_ADV_PARAM_INTERVALS	(1 << 14)
 #define MGMT_ADV_PARAM_TX_POWER		(1 << 15)
+#define MGMT_ADV_PARAM_SCAN_RSP		(1 << 16)
 
 #define MGMT_OP_REMOVE_ADVERTISING	0x003F
 struct mgmt_cp_remove_advertising {
diff --git a/src/advertising.c b/src/advertising.c
index f3dc357a1..cdf06154d 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -945,7 +945,13 @@ static int refresh_extended_adv(struct btd_adv_client *client,
 		return -EINVAL;
 	}
 
-	cp.flags = htobl(flags);
+	/* Indicate that this instance will be configured as scannable */
+	if (client->scan_rsp_len &&
+		client->manager->supported_flags & MGMT_ADV_PARAM_SCAN_RSP) {
+		flags |= MGMT_ADV_PARAM_SCAN_RSP;
+	}
+
+	cp.flags = cpu_to_le32(flags);
 
 	mgmt_ret = mgmt_send(client->manager->mgmt, MGMT_OP_ADD_EXT_ADV_PARAMS,
 			client->manager->mgmt_index, sizeof(cp), &cp,
-- 
2.30.1.766.gb4fecdf3b7-goog


  parent reply	other threads:[~2021-03-04 20:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 20:24 [Bluez PATCH v2 0/3] Bluetooth: Fix scannable broadcast advertising on extended APIs Daniel Winkler
2021-03-04 20:24 ` [Bluez PATCH v2 1/3] advertising: Generate advertising data earlier in pipeline Daniel Winkler
2021-03-04 22:49   ` Luiz Augusto von Dentz
2021-03-04 23:27     ` Daniel Winkler
2021-03-04 23:43       ` Luiz Augusto von Dentz
2021-03-16 22:51         ` Daniel Winkler
2021-03-04 20:24 ` Daniel Winkler [this message]
2021-03-04 20:24 ` [Bluez PATCH v2 3/3] doc/mgmt-api: Update documentation for scan_rsp param flag Daniel Winkler

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=20210304122005.Bluez.v2.2.I45b896f4512038309cbeab7a01f51e503141edab@changeid \
    --to=danielwinkler@google.com \
    --cc=alainm@chromium.org \
    --cc=chromeos-bluetooth-upstreaming@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.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.