* [PATCH BlueZ 1/7] client/player: Add support to set empty bcode
2024-10-08 8:01 [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op Iulia Tanasescu
@ 2024-10-08 8:01 ` Iulia Tanasescu
2024-10-08 12:14 ` Add Scan Delegator support for Set Broadcast Code op bluez.test.bot
2024-10-08 8:01 ` [PATCH BlueZ 2/7] shared/bass: Add API to set BIG enc state Iulia Tanasescu
` (6 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Iulia Tanasescu @ 2024-10-08 8:01 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
luiz.dentz, Iulia Tanasescu
A Broadcast Sink might scan encrypted streams, and the user might not
know the Broadcast Code to decrypt them.
This commit adds the option to set an empty Broadcast Code when prompted
for it after transport.select, if the Code is unknown. In this case, if
the Broadcast Sink is acting as a Scan Delegator, it can ask its peer
Broadcast Assistants to provide the Code through BASS.
---
client/player.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/client/player.c b/client/player.c
index df2246516..188378175 100644
--- a/client/player.c
+++ b/client/player.c
@@ -5150,15 +5150,23 @@ static void set_bcode_cb(const DBusError *error, void *user_data)
static void set_bcode(const char *input, void *user_data)
{
GDBusProxy *proxy = user_data;
- char *bcode = g_strdup(input);
+ char *bcode;
+
+ if (!strcasecmp(input, "n") || !strcasecmp(input, "no"))
+ bcode = g_new0(char, 16);
+ else
+ bcode = g_strdup(input);
if (g_dbus_proxy_set_property_dict(proxy, "QoS",
set_bcode_cb, user_data,
NULL, "BCode", DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
strlen(bcode), bcode, NULL) == FALSE) {
bt_shell_printf("Setting broadcast code failed\n");
+ g_free(bcode);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
+
+ g_free(bcode);
}
static void transport_select(GDBusProxy *proxy, bool prompt)
@@ -5183,7 +5191,8 @@ static void transport_select(GDBusProxy *proxy, bool prompt)
dbus_message_iter_get_basic(&value, &encryption);
if (encryption == 1) {
bt_shell_prompt_input("",
- "Enter broadcast code:", set_bcode, proxy);
+ "Enter brocast code[value/no]:",
+ set_bcode, proxy);
return;
}
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH BlueZ 2/7] shared/bass: Add API to set BIG enc state
2024-10-08 8:01 [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op Iulia Tanasescu
2024-10-08 8:01 ` [PATCH BlueZ 1/7] client/player: Add support to set empty bcode Iulia Tanasescu
@ 2024-10-08 8:01 ` Iulia Tanasescu
2024-10-08 8:01 ` [PATCH BlueZ 3/7] bass: Add support to request bcode Iulia Tanasescu
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Iulia Tanasescu @ 2024-10-08 8:01 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
luiz.dentz, Iulia Tanasescu
This adds a shared/bass API to set the BIG encryption state field inside
a Broadcast Receive State characteristic. Notifications are then sent to
inform all peers about the update.
---
src/shared/bass.c | 24 ++++++++++++++++++++++++
src/shared/bass.h | 1 +
2 files changed, 25 insertions(+)
diff --git a/src/shared/bass.c b/src/shared/bass.c
index 76287cfbc..9ee13bf4a 100644
--- a/src/shared/bass.c
+++ b/src/shared/bass.c
@@ -1832,3 +1832,27 @@ bool bt_bass_check_bis(struct bt_bcast_src *bcast_src, uint8_t bis)
return false;
}
+
+int bt_bass_set_enc(struct bt_bcast_src *bcast_src, uint8_t enc)
+{
+ struct iovec *iov;
+
+ if (!bcast_src)
+ return -EINVAL;
+
+ if (bcast_src->enc == enc)
+ return 0;
+
+ bcast_src->enc = enc;
+
+ iov = bass_parse_bcast_src(bcast_src);
+ if (!iov)
+ return -ENOMEM;
+
+ bt_bass_notify_all(bcast_src->attr, iov);
+
+ free(iov->iov_base);
+ free(iov);
+
+ return 0;
+}
diff --git a/src/shared/bass.h b/src/shared/bass.h
index b21256efd..d256b920d 100644
--- a/src/shared/bass.h
+++ b/src/shared/bass.h
@@ -133,3 +133,4 @@ int bt_bass_set_pa_sync(struct bt_bcast_src *bcast_src, uint8_t sync_state);
int bt_bass_set_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis);
int bt_bass_clear_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis);
bool bt_bass_check_bis(struct bt_bcast_src *bcast_src, uint8_t bis);
+int bt_bass_set_enc(struct bt_bcast_src *bcast_src, uint8_t enc);
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH BlueZ 3/7] bass: Add support to request bcode
2024-10-08 8:01 [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op Iulia Tanasescu
2024-10-08 8:01 ` [PATCH BlueZ 1/7] client/player: Add support to set empty bcode Iulia Tanasescu
2024-10-08 8:01 ` [PATCH BlueZ 2/7] shared/bass: Add API to set BIG enc state Iulia Tanasescu
@ 2024-10-08 8:01 ` Iulia Tanasescu
2024-10-08 8:01 ` [PATCH BlueZ 4/7] shared/bass: Call cp handler for the Set Broadcast Code op Iulia Tanasescu
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Iulia Tanasescu @ 2024-10-08 8:01 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
luiz.dentz, Iulia Tanasescu
This adds support for a Scan Delegator to request the Broadcast Code
from peer Broadcast Assistants and to update a BAP stream QoS with the
value.
A BASS API is added to update the BIG encryption status of a Broadcast
Receive State characteristic and to notify peers. When a peer provides
the Code using the BASS "Set Broadcast Code" operation, the BAP stream
QoS is updated. The driver calling this API will pass a callback as
parameter, which will be called to signal that the Broadcast Code has
been received and stored in the stream QoS.
A timeout is set to wait for Broadcast Assistants to provide the Code.
If the timeout expires, the callback will be code with the appropriate
error status.
---
profiles/audio/bass.c | 141 ++++++++++++++++++++++++++++++++++++++++++
profiles/audio/bass.h | 6 ++
2 files changed, 147 insertions(+)
diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c
index 7553d1bec..6237f5acc 100644
--- a/profiles/audio/bass.c
+++ b/profiles/audio/bass.c
@@ -104,6 +104,15 @@ struct bass_delegator {
struct bt_bcast_src *src;
struct bt_bap *bap;
unsigned int state_id;
+ uint8_t *bcode;
+ unsigned int timeout;
+ struct queue *bcode_reqs;
+};
+
+struct bass_bcode_req {
+ struct bt_bap_stream *stream;
+ bt_bass_bcode_func_t cb;
+ void *user_data;
};
static struct queue *sessions;
@@ -117,6 +126,90 @@ static void bass_debug(const char *str, void *user_data)
DBG_IDX(0xffff, "%s", str);
}
+static gboolean req_timeout(gpointer user_data)
+{
+ struct bass_delegator *dg = user_data;
+ struct bass_bcode_req *req;
+
+ DBG("delegator %p", dg);
+
+ dg->timeout = 0;
+
+ while ((req = queue_pop_head(dg->bcode_reqs))) {
+ if (req->cb)
+ req->cb(req->user_data, -ETIMEDOUT);
+
+ free(req);
+ }
+
+ return FALSE;
+}
+
+static bool delegator_match_bap(const void *data, const void *match_data)
+{
+ const struct bass_delegator *dg = data;
+ const struct bt_bap *bap = match_data;
+
+ return dg->bap == bap;
+}
+
+static void stream_set_bcode(uint8_t *bcode, struct bt_bap_stream *stream,
+ bt_bass_bcode_func_t cb, void *user_data)
+{
+ struct bt_bap_qos *qos = bt_bap_stream_get_qos(stream);
+
+ /* Allocate Broadcast Code inside stream QoS */
+ qos->bcast.bcode = util_iov_new(bcode, BT_BASS_BCAST_CODE_SIZE);
+
+ if (cb)
+ cb(user_data, 0);
+}
+
+void bass_req_bcode(struct bt_bap_stream *stream,
+ bt_bass_bcode_func_t cb,
+ void *user_data)
+{
+ struct bt_bap *bap = bt_bap_stream_get_session(stream);
+ struct bass_delegator *dg;
+ struct bass_bcode_req *req;
+
+ dg = queue_find(delegators, delegator_match_bap, bap);
+ if (!dg) {
+ cb(user_data, -EINVAL);
+ return;
+ }
+
+ if (dg->bcode) {
+ /* Broadcast Code has already been received before. */
+ stream_set_bcode(dg->bcode, stream, cb, user_data);
+ return;
+ }
+
+ /* Create a request for the Broadcast Code. The request
+ * will be considered handled when the Broadcast Code is
+ * received from a Broadcast Assistant.
+ */
+ req = new0(struct bass_bcode_req, 1);
+ if (!req)
+ return;
+
+ req->stream = stream;
+ req->cb = cb;
+ req->user_data = user_data;
+
+ queue_push_tail(dg->bcode_reqs, req);
+
+ /* Mark the encryption status as "Broadcast Code Required"
+ * in the Broadcast Receive State characteristic and notify
+ * Broadcast Assistants.
+ */
+ bt_bass_set_enc(dg->src, BT_BASS_BIG_ENC_STATE_BCODE_REQ);
+
+ /* Add timeout for Broadcast Assistants to provide the Code. */
+ if (!dg->timeout)
+ dg->timeout = g_timeout_add_seconds(10, req_timeout, dg);
+}
+
static bool delegator_match_device(const void *data, const void *match_data)
{
const struct bass_delegator *dg = data;
@@ -233,6 +326,13 @@ bool bass_bcast_remove(struct btd_device *device)
/* Unregister BAP stream state changed callback. */
bt_bap_state_unregister(dg->bap, dg->state_id);
+ if (dg->timeout)
+ g_source_remove(dg->timeout);
+
+ queue_destroy(dg->bcode_reqs, free);
+
+ free(dg->bcode);
+
free(dg);
return true;
@@ -794,6 +894,7 @@ probe:
dg->device = device;
dg->src = bcast_src;
+ dg->bcode_reqs = queue_new();
if (!delegators)
delegators = queue_new();
@@ -808,6 +909,43 @@ probe:
return 0;
}
+static bool delegator_match_src(const void *data, const void *match_data)
+{
+ const struct bass_delegator *dg = data;
+ const struct bt_bcast_src *src = match_data;
+
+ return dg->src == src;
+}
+
+static int handle_set_bcode_req(struct bt_bcast_src *bcast_src,
+ struct bt_bass_set_bcast_code_params *params,
+ struct bass_data *data)
+{
+ struct bass_delegator *dg;
+ struct bass_bcode_req *req;
+
+ dg = queue_find(delegators, delegator_match_src, bcast_src);
+ if (!dg)
+ return -EINVAL;
+
+ dg->bcode = new0(uint8_t, BT_BASS_BCAST_CODE_SIZE);
+ memcpy(dg->bcode, params->bcast_code, BT_BASS_BCAST_CODE_SIZE);
+
+ if (dg->timeout) {
+ g_source_remove(dg->timeout);
+ dg->timeout = 0;
+ }
+
+ /* Set the Broadcast Code for each stream that required it. */
+ while ((req = queue_pop_head(dg->bcode_reqs))) {
+ stream_set_bcode(dg->bcode, req->stream, req->cb,
+ req->user_data);
+ free(req);
+ }
+
+ return 0;
+}
+
static int cp_handler(struct bt_bcast_src *bcast_src, uint8_t op, void *params,
void *user_data)
{
@@ -818,6 +956,9 @@ static int cp_handler(struct bt_bcast_src *bcast_src, uint8_t op, void *params,
case BT_BASS_ADD_SRC:
err = handle_add_src_req(bcast_src, params, data);
break;
+ case BT_BASS_SET_BCAST_CODE:
+ err = handle_set_bcode_req(bcast_src, params, data);
+ break;
}
return err;
diff --git a/profiles/audio/bass.h b/profiles/audio/bass.h
index 5e34db90a..257346374 100644
--- a/profiles/audio/bass.h
+++ b/profiles/audio/bass.h
@@ -16,3 +16,9 @@ bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap);
bool bass_bcast_remove(struct btd_device *device);
bool bass_check_bis(struct btd_device *device, uint8_t bis);
+
+typedef void (*bt_bass_bcode_func_t)(void *user_data, int err);
+
+void bass_req_bcode(struct bt_bap_stream *stream,
+ bt_bass_bcode_func_t cb,
+ void *user_data);
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH BlueZ 4/7] shared/bass: Call cp handler for the Set Broadcast Code op
2024-10-08 8:01 [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op Iulia Tanasescu
` (2 preceding siblings ...)
2024-10-08 8:01 ` [PATCH BlueZ 3/7] bass: Add support to request bcode Iulia Tanasescu
@ 2024-10-08 8:01 ` Iulia Tanasescu
2024-10-08 8:01 ` [PATCH BlueZ 5/7] shared/bass: Set correct BIG enc state after sync Iulia Tanasescu
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Iulia Tanasescu @ 2024-10-08 8:01 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
luiz.dentz, Iulia Tanasescu
This updates the Set Broadcast Code control point handler inside
shared/bass to call the handlers queued inside bt_bass.
---
src/shared/bass.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/shared/bass.c b/src/shared/bass.c
index 9ee13bf4a..6efacb2da 100644
--- a/src/shared/bass.c
+++ b/src/shared/bass.c
@@ -944,6 +944,8 @@ static void bass_handle_set_bcast_code_op(struct bt_bass *bass,
struct bt_bass_set_bcast_code_params *params;
struct bt_bcast_src *bcast_src;
struct iovec *notif;
+ const struct queue_entry *entry;
+ int ret;
/* Get Set Broadcast Code command parameters */
params = util_iov_pull_mem(iov, sizeof(*params));
@@ -978,7 +980,19 @@ static void bass_handle_set_bcast_code_op(struct bt_bass *bass,
return;
}
- /* TODO: Call BASS plugin callback to sync with required BIS */
+ for (entry = queue_get_entries(bass->cp_handlers); entry;
+ entry = entry->next) {
+ struct bt_bass_cp_handler *cb = entry->data;
+
+ if (cb->handler) {
+ ret = cb->handler(bcast_src,
+ BT_BASS_SET_BCAST_CODE,
+ params, cb->data);
+ if (ret)
+ DBG(bass, "Unable to handle Set "
+ "Broadcast Code operation");
+ }
+ }
}
#define BASS_OP(_str, _op, _size, _func) \
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH BlueZ 5/7] shared/bass: Set correct BIG enc state after sync
2024-10-08 8:01 [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op Iulia Tanasescu
` (3 preceding siblings ...)
2024-10-08 8:01 ` [PATCH BlueZ 4/7] shared/bass: Call cp handler for the Set Broadcast Code op Iulia Tanasescu
@ 2024-10-08 8:01 ` Iulia Tanasescu
2024-10-08 8:01 ` [PATCH BlueZ 6/7] transport: Add support to request bcode from Assistant Iulia Tanasescu
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Iulia Tanasescu @ 2024-10-08 8:01 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
luiz.dentz, Iulia Tanasescu
A Scan Delegator might set the BIG encryption state of a Broadcast
Receive State characteristic to "Broadcast Code Required", to notify
Broadcast Assistants that the value is needed to decrypt the streams.
If the Broadcast Code was received and BIG sync was established, the
BIG encryption state must be transitioned to "Decrypting" state, to
inform Assistants that BIG sync was successfully established with the
correct Code.
---
src/shared/bass.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/shared/bass.c b/src/shared/bass.c
index 6efacb2da..d99a140a1 100644
--- a/src/shared/bass.c
+++ b/src/shared/bass.c
@@ -1793,6 +1793,9 @@ int bt_bass_set_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis)
if (sgrp->pending_bis_sync & bitmask) {
sgrp->bis_sync |= bitmask;
+ if (bcast_src->enc == BT_BASS_BIG_ENC_STATE_BCODE_REQ)
+ bcast_src->enc = BT_BASS_BIG_ENC_STATE_DEC;
+
iov = bass_parse_bcast_src(bcast_src);
if (!iov)
return -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH BlueZ 6/7] transport: Add support to request bcode from Assistant
2024-10-08 8:01 [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op Iulia Tanasescu
` (4 preceding siblings ...)
2024-10-08 8:01 ` [PATCH BlueZ 5/7] shared/bass: Set correct BIG enc state after sync Iulia Tanasescu
@ 2024-10-08 8:01 ` Iulia Tanasescu
2024-10-08 8:01 ` [PATCH BlueZ 7/7] client: Update scripts to include encrypted stream scenario Iulia Tanasescu
2024-10-15 15:00 ` [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op patchwork-bot+bluetooth
7 siblings, 0 replies; 10+ messages in thread
From: Iulia Tanasescu @ 2024-10-08 8:01 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
luiz.dentz, Iulia Tanasescu
A Broadcast Sink might scan an encrypted stream, but the user might
not know the Broadacst Code to decrypt it. However, if the Broadcast
Sink is acting as a Scan Delegator, it can request the Code from
Broadcast Assistants.
This adds support to ask for the Broadcast Code through BASS, if an
empty Code was entered by the user at transport select.
The bluetoothctl log below shows a Scan Delegator creating a media
transport for an encrypted BIS added by a Broadcast Assistant through
the Add Source operation. The user is asked to enter the Broadcast Code
at transport.select, and the "no" option is chosen, since the Code is
unknown. However, the Code is received from the Broadcast Assistant and
the transport is successfully acquired.
client/bluetoothctl
[bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): a
[/local/endpoint/ep0] Locations: 1
[/local/endpoint/ep0] Supported Context (value): 1
[bluetooth]# Endpoint /local/endpoint/ep0 registered
[bluetooth]# advertise on
[bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F
[00-60-37-31-7E-3F]# [NEW] Device 23:E1:A6:85:D9:11 23-E1-A6-85-D9-11
[00-60-37-31-7E-3F]# [NEW] Transport
/org/bluez/hci2/dev_23_E1_A6_85_D9_11/bis1/fd0
[00-60-37-31-7E-3F]# transport.select
/org/bluez/hci2/dev_23_E1_A6_85_D9_11/bis1/fd0
[] Enter brocast code[value/no]: no
[00-60-37-31-7E-3F]# Setting broadcast code succeeded
[00-60-37-31-7E-3F]# [CHG] Transport
/org/bluez/hci2/dev_23_E1_A6_85_D9_11/bis1/fd0 State: broadcasting
[00-60-37-31-7E-3F]# transport.acquire
/org/bluez/hci2/dev_23_E1_A6_85_D9_11/bis1/fd0
[00-60-37-31-7E-3F]# Transport
/org/bluez/hci2/dev_23_E1_A6_85_D9_11/bis1/fd0 acquiring complete
[00-60-37-31-7E-3F]# [CHG] Transport
/org/bluez/hci2/dev_23_E1_A6_85_D9_11/bis1/fd0 State: active
The btmon log shows the BASS GATT write commands and notifications
exchanged between the Scan Delegator and the Broadcast Assistant:
> ACL Data RX: Handle 0 flags 0x01 dlen 1
ATT: Write Command (0x52) len 23
Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7)
Data[21]: 020111d985a6e12300f9bb8502ffff010100000000
Opcode: Add Source (0x02)
Source_Address_Type: 1
Source_Address: 23:E1:A6:85:D9:11
Source_Adv_SID: 0
Broadcast_ID: 0x85bbf9
PA_Sync_State: Synchronize to PA - PAST not available
PA_Interval: 0xffff
Num_Subgroups: 1
Subgroup #0:
BIS_Sync State: 0x00000001
< HCI Command: LE Periodic Advertising Create Sync (0x08|0x0044) plen 14
Options: 0x0000
Use advertising SID, Advertiser Address Type and address
Reporting initially enabled
SID: 0x00
Adv address type: Random (0x01)
Adv address: 23:E1:A6:85:D9:11 (Non-Resolvable)
Skip: 0x0000
Sync timeout: 20000 msec (0x07d0)
Sync CTE type: 0x0000
> HCI Event: LE Meta Event (0x3e) plen 16
LE Periodic Advertising Sync Established (0x0e)
Status: Success (0x00)
Sync handle: 0
Advertising SID: 0x00
Advertiser address type: Random (0x01)
Advertiser address: 23:E1:A6:85:D9:11 (Non-Resolvable)
Advertiser PHY: LE 2M (0x02)
Periodic advertising interval: 10.00 msec (0x0008)
Advertiser clock accuracy: 0x07
> HCI Event: LE Meta Event (0x3e) plen 42
LE Periodic Advertising Report (0x0f)
Sync handle: 0
TX power: 127 dbm (0x7f)
RSSI: -57 dBm (0xc7)
CTE Type: No Constant Tone Extension (0xff)
Data status: Complete
Data length: 0x22
Service Data: Basic Audio Announcement (0x1851)
Presetation Delay: 40000
Number of Subgroups: 1
Subgroup #0:
Number of BIS(s): 1
Codec: LC3 (0x06)
Codec Specific Configuration: #0: len 0x02 type 0x01
Codec Specific Configuration: Sampling Frequency: 16 Khz (0x03)
Codec Specific Configuration: #1: len 0x02 type 0x02
Codec Specific Configuration: Frame Duration: 10 ms (0x01)
Codec Specific Configuration: #2: len 0x03 type 0x04
Codec Specific Configuration: Frame Length: 40 (0x0028)
Codec Specific Configuration: #3: len 0x05 type 0x03
Codec Specific Configuration: Location: 0x00000001
Codec Specific Configuration: Location: Front Left (0x00000001)
BIS #0:
Index: 1
> HCI Event: LE Meta Event (0x3e) plen 20
LE Broadcast Isochronous Group Info Advertising Report (0x22)
Sync Handle: 0x0000
Number BIS: 1
NSE: 3
ISO Interval: 10.00 msec (0x0008)
BN: 1
PTO: 1
IRC: 3
Maximum PDU: 40
SDU Interval: 10000 us (0x002710)
Maximum SDU: 40
PHY: LE 2M (0x02)
Framing: Unframed (0x00)
Encryption: 0x01
bluetoothd[5431]: < ACL Data TX: Handle 0 flags 0x00 dlen 29
ATT: Handle Multiple Value Notification (0x23) len 24
Length: 0x0014
Handle: 0x003a Type: Broadcast Receive State (0x2bc8)
Data[20]: 010111d985a6e12300f9bb850200010000000000
Source_ID: 1
Source_Address_Type: 1
Source_Address: 23:E1:A6:85:D9:11
Source_Adv_SID: 0
Broadcast_ID: 0x85bbf9
PA_Sync_State: Synchronized to PA
BIG_Encryption: Not encrypted
Num_Subgroups: 1
Subgroup #0:
BIS_Sync State: 0x00000000
bluetoothd[5431]: < ACL Data TX: Handle 0 flags 0x00 dlen 29
ATT: Handle Multiple Value Notification (0x23) len 24
Length: 0x0014
Handle: 0x003a Type: Broadcast Receive State (0x2bc8)
Data[20]: 010111d985a6e12300f9bb850201010000000000
Source_ID: 1
Source_Address_Type: 1
Source_Address: 23:E1:A6:85:D9:11
Source_Adv_SID: 0
Broadcast_ID: 0x85bbf9
PA_Sync_State: Synchronized to PA
BIG_Encryption: Broadcast_Code required
Num_Subgroups: 1
Subgroup #0:
BIS_Sync State: 0x00000000
> ACL Data RX: Handle 0 flags 0x02 dlen 25
ATT: Write Command (0x52) len 20
Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7)
Data[18]: 040161616100000000000000000000000000
Opcode: Set Broadcast_Code (0x04)
Source_ID: 1
Broadcast_Code[16]: 61616100000000000000000000000000
< HCI Command: LE Broadcast Isochronous Group Create Sync (0x08|0x006b)
BIG Handle: 0x00
BIG Sync Handle: 0x0000
Encryption: Encrypted (0x01)
Broadcast Code[16]: 61616100000000000000000000000000
Maximum Number Subevents: 0x00
Timeout: 20000 ms (0x07d0)
Number of BIS: 1
BIS ID: 0x01
> HCI Event: LE Meta Event (0x3e) plen 17
LE Broadcast Isochronous Group Sync Estabilished (0x1d)
Status: Success (0x00)
BIG Handle: 0x00
Transport Latency: 960 us (0x0003c0)
NSE: 3
BN: 1
PTO: 1
IRC: 3
Maximum PDU: 40
ISO Interval: 10.00 msec (0x0008)
Connection Handle #0: 10
< HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13
Handle: 10
Data Path Direction: Output (Controller to Host) (0x01)
Data Path: HCI (0x00)
Coding Format: Transparent (0x03)
Company Codec ID: Ericsson Technology Licensing (0)
Vendor Codec ID: 0
Controller Delay: 0 us (0x000000)
Codec Configuration Length: 0
Codec Configuration[0]:
> HCI Event: Command Complete (0x0e) plen 6
LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
Status: Success (0x00)
Handle: 10
bluetoothd[5431]: < ACL Data TX: Handle 0 flags 0x00 dlen 29
ATT: Handle Multiple Value Notification (0x23) len 24
Length: 0x0014
Handle: 0x003a Type: Broadcast Receive State (0x2bc8)
Data[20]: 010111d985a6e12300f9bb850202010100000000
Source_ID: 1
Source_Address_Type: 1
Source_Address: 23:E1:A6:85:D9:11
Source_Adv_SID: 0
Broadcast_ID: 0x85bbf9
PA_Sync_State: Synchronized to PA
BIG_Encryption: Decrypting
Num_Subgroups: 1
Subgroup #0:
BIS_Sync State: 0x00000001
---
profiles/audio/transport.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index caa7287db..6b6365289 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -35,6 +35,7 @@
#include "src/shared/util.h"
#include "src/shared/queue.h"
#include "src/shared/bap.h"
+#include "src/shared/bass.h"
#include "src/shared/io.h"
#include "asha.h"
@@ -45,6 +46,7 @@
#include "sink.h"
#include "source.h"
#include "avrcp.h"
+#include "bass.h"
#define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1"
@@ -1208,6 +1210,18 @@ static gboolean qos_bcast_exists(const GDBusPropertyTable *property, void *data)
return bap->qos.bcast.io_qos.phy != 0x00;
}
+static void bcast_qos_set(void *user_data, int err)
+{
+ GDBusPendingPropertySet id = GPOINTER_TO_UINT(user_data);
+
+ if (!err)
+ g_dbus_pending_property_success(id);
+ else
+ g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".Failed",
+ "Failed to set Broadcast Code");
+}
+
static void set_bcast_qos(const GDBusPropertyTable *property,
DBusMessageIter *dict, GDBusPendingPropertySet id,
void *data)
@@ -1230,10 +1244,28 @@ static void set_bcast_qos(const GDBusPropertyTable *property,
uint8_t *val;
int len;
DBusMessageIter array;
+ uint8_t empty_bcode[BT_BASS_BCAST_CODE_SIZE] = {0};
dbus_message_iter_recurse(&value, &array);
dbus_message_iter_get_fixed_array(&array, &val, &len);
+ if (len > BT_BASS_BCAST_CODE_SIZE) {
+ g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
+ return;
+ }
+
+ if (!memcmp(val, empty_bcode, len)) {
+ /* If the user did not provide a Broadcast Code
+ * for the encrypted stream, request the code from
+ * Broadcast Assistants, if any are available.
+ */
+ bass_req_bcode(bap->stream, bcast_qos_set,
+ GUINT_TO_POINTER(id));
+ return;
+ }
+
bap_qos->bcast.bcode = util_iov_new(val, len);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH BlueZ 7/7] client: Update scripts to include encrypted stream scenario
2024-10-08 8:01 [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op Iulia Tanasescu
` (5 preceding siblings ...)
2024-10-08 8:01 ` [PATCH BlueZ 6/7] transport: Add support to request bcode from Assistant Iulia Tanasescu
@ 2024-10-08 8:01 ` Iulia Tanasescu
2024-10-15 15:00 ` [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op patchwork-bot+bluetooth
7 siblings, 0 replies; 10+ messages in thread
From: Iulia Tanasescu @ 2024-10-08 8:01 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, andrei.istodorescu,
luiz.dentz, Iulia Tanasescu
This updates the broadcast-assistant/scan-delegator scripts to include
the encrypted stream scenario.
---
client/scripts/broadcast-assistant.bt | 5 ++++-
client/scripts/scan-delegator.bt | 17 ++++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/client/scripts/broadcast-assistant.bt b/client/scripts/broadcast-assistant.bt
index 15e9d0980..81bb147a0 100644
--- a/client/scripts/broadcast-assistant.bt
+++ b/client/scripts/broadcast-assistant.bt
@@ -25,10 +25,13 @@ scan on
# using the "push" command from the assistant submenu. When asked
# to enter stream metadata, the "auto" option will keep the LTV
# values advertised by the Broadcast Source. By entering new LTV
-# values, the default metadata will be overwritten.
+# values, the default metadata will be overwritten. If the stream
+# is encrypted, a prompt will be displayed to enter the Broadcast
+# Code for decrypting.
#
# assistant.push /org/bluez/hci0/src_yy_yy_yy_yy_yy_yy/dev_xx_xx_xx_xx_xx_xx/bis_n
# [Assistant] Enter Metadata (auto/value): a
+# [Assistant] Enter Broadcast Code (auto/value): Borne House
#
#
# Wait for the MediaAssistant object to transition to "active"
diff --git a/client/scripts/scan-delegator.bt b/client/scripts/scan-delegator.bt
index 68c7fb498..5ff7bcb89 100644
--- a/client/scripts/scan-delegator.bt
+++ b/client/scripts/scan-delegator.bt
@@ -18,7 +18,22 @@ advertise on
# After the connection has been established, transports will
# be created for streams added by the Bradcast Assistant that
# match the audio capabilities chosen at endpoint register.
-# Acquire the desired transport to start receiving audio.
+# Select the desired transport. If the stream is encrypted,
+# a prompt will be displayed to enter the Broadacast Code for
+# decrypting. If the code is unknown, the "no" option will
+# request the code from the Broadcast Assistant.
+#
+# transport.select /org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/bis_n/fd_m
+# [] Enter brocast code[value/no]: no
+#
+#
+# If the Broadcast Assistant provided the Broadcast Code, the
+# transport will transition to "broadcasting" state.
+#
+# [CHG] Transport /org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/bis_n/fd_m State: broadcasting
+#
+#
+# Acquire the transport to start receiving audio.
#
# transport.acquire /org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/bis_n/fd_m
#
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op
2024-10-08 8:01 [PATCH BlueZ 0/7] Add Scan Delegator support for Set Broadcast Code op Iulia Tanasescu
` (6 preceding siblings ...)
2024-10-08 8:01 ` [PATCH BlueZ 7/7] client: Update scripts to include encrypted stream scenario Iulia Tanasescu
@ 2024-10-15 15:00 ` patchwork-bot+bluetooth
7 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+bluetooth @ 2024-10-15 15:00 UTC (permalink / raw)
To: Iulia Tanasescu
Cc: linux-bluetooth, claudia.rosu, mihai-octavian.urzica,
andrei.istodorescu, luiz.dentz
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 8 Oct 2024 11:01:19 +0300 you wrote:
> This patch adds Scan Delegator support to request the Broadcast Code from
> connected Broadcast Assistants.
>
> The bluetoothctl log below shows a Scan Delegator creating a media
> transport for an encrypted BIS added by a Broadcast Assistant through
> the Add Source operation. The user is asked to enter the Broadcast Code
> at transport.select, and the "no" option is chosen, since the Code is
> unknown. However, the Code is received from the Broadcast Assistant and
> the transport is successfully acquired.
>
> [...]
Here is the summary with links:
- [BlueZ,1/7] client/player: Add support to set empty bcode
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=1c681c553f45
- [BlueZ,2/7] shared/bass: Add API to set BIG enc state
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f5c0fe68539f
- [BlueZ,3/7] bass: Add support to request bcode
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=4bc20f9df405
- [BlueZ,4/7] shared/bass: Call cp handler for the Set Broadcast Code op
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=29cb1b0b10fd
- [BlueZ,5/7] shared/bass: Set correct BIG enc state after sync
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c5616c255b13
- [BlueZ,6/7] transport: Add support to request bcode from Assistant
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c7119b4f4e42
- [BlueZ,7/7] client: Update scripts to include encrypted stream scenario
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5d7e6a64b2fc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 10+ messages in thread