Skip to content

Commit 7e6e3e9

Browse files
Thalleycarlescufi
authored andcommitted
Bluetooth: ISO: Document usage of broadcast code
Add a short example of how the broadcast code for BIGs shall be used. The spec states: "On all levels other than UI, the Broadcast Code parameter shall be represented as a 128-bit value. The transformation from string to number shall be by representing the string in UTF-8, placing the resulting bytes in 8-bit fields of the value starting at the least significant bit, and then padding with zeros in the most significant bits if necessary. For example, the string “Børne House” is represented as the value 0x00000000_6573756F_4820656E_72B8C342. " So "Børne House" becomes [42, C3, B8, 72, 63, 65, 20, 48, 6F, 75, 73, 65, 00, 00, 00, 00] when sending over HCI. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 0e17395 commit 7e6e3e9

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

include/zephyr/bluetooth/audio/audio.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,16 @@ struct bt_audio_broadcast_source_create_param {
20912091
/** Whether or not to encrypt the streams. */
20922092
bool encryption;
20932093

2094-
/** @brief Broadcast code */
2094+
/**
2095+
* @brief Broadcast code
2096+
*
2097+
* If the value is a string or a the value is less than 16 octets,
2098+
* the remaining octets shall be 0.
2099+
*
2100+
* Example:
2101+
* The string "Broadcast Code" shall be
2102+
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
2103+
*/
20952104
uint8_t broadcast_code[BT_BAP_BROADCAST_CODE_SIZE];
20962105
};
20972106

@@ -2262,6 +2271,12 @@ int bt_audio_broadcast_sink_scan_stop(void);
22622271
* @param broadcast_code The 16-octet broadcast code. Shall be supplied if
22632272
* the broadcast is encrypted (see the syncable
22642273
* callback).
2274+
* If the value is a string or a the value is less
2275+
* than 16 octets, the remaining octets shall be 0.
2276+
*
2277+
* Example:
2278+
* The string "Broadcast Code" shall be
2279+
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
22652280
*
22662281
* @return 0 in case of success or negative value in case of error.
22672282
*/

include/zephyr/bluetooth/audio/cap.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,17 @@ struct bt_cap_broadcast_audio_start_param {
271271
*/
272272
bool encrypt;
273273

274-
/** 16-octet broadcast code.
274+
/**
275+
* @brief 16-octet broadcast code.
275276
*
276277
* Only valid if @p encrypt is true.
278+
*
279+
* If the value is a string or a the value is less than 16 octets,
280+
* the remaining octets shall be 0.
281+
*
282+
* Example:
283+
* The string "Broadcast Code" shall be
284+
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
277285
*/
278286
uint8_t broadcast_code[BT_ISO_BROADCAST_CODE_SIZE];
279287
};
@@ -344,9 +352,17 @@ struct bt_cap_unicast_to_broadcast_param {
344352
*/
345353
bool encrypt;
346354

347-
/** 16-octet broadcast code.
355+
/**
356+
* @brief 16-octet broadcast code.
348357
*
349358
* Only valid if @p encrypt is true.
359+
*
360+
* If the value is a string or a the value is less than 16 octets,
361+
* the remaining octets shall be 0.
362+
*
363+
* Example:
364+
* The string "Broadcast Code" shall be
365+
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
350366
*/
351367
uint8_t broadcast_code[BT_ISO_BROADCAST_CODE_SIZE];
352368
};

include/zephyr/bluetooth/iso.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ struct bt_iso_big_create_param {
349349
*
350350
* The code used to derive the session key that is used to encrypt and
351351
* decrypt BIS payloads.
352+
*
353+
* If the value is a string or a the value is less than 16 octets,
354+
* the remaining octets shall be 0.
355+
*
356+
* Example:
357+
* The string "Broadcast Code" shall be
358+
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
352359
*/
353360
uint8_t bcode[BT_ISO_BROADCAST_CODE_SIZE];
354361
};
@@ -396,6 +403,13 @@ struct bt_iso_big_sync_param {
396403
*
397404
* The code used to derive the session key that is used to encrypt and
398405
* decrypt BIS payloads.
406+
*
407+
* If the value is a string or a the value is less than 16 octets,
408+
* the remaining octets shall be 0.
409+
*
410+
* Example:
411+
* The string "Broadcast Code" shall be
412+
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
399413
*/
400414
uint8_t bcode[BT_ISO_BROADCAST_CODE_SIZE];
401415
};

0 commit comments

Comments
 (0)