Skip to content

Commit c47dae8

Browse files
Thalleycfriedt
authored andcommitted
Bluetooth: ISO: Update connected ISO API
Update the connected ISO API to be more similar to the broadcast ISO API as well as the HCI spec. This updated API allows for more flexibility and will better support scenarios such as true wireless setup, as ISO channels and connections are more independent now. Signed-off-by: Emil Gydesen <[email protected]>
1 parent c74fe1f commit c47dae8

File tree

6 files changed

+364
-307
lines changed

6 files changed

+364
-307
lines changed

include/bluetooth/iso.h

Lines changed: 89 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
/*
66
* Copyright (c) 2020 Intel Corporation
7+
* Copyright (c) 2021 Nordic Semiconductor ASA
78
*
89
* SPDX-License-Identifier: Apache-2.0
910
*/
@@ -70,10 +71,6 @@ struct bt_iso_chan {
7071

7172
/** @brief ISO Channel IO QoS structure. */
7273
struct bt_iso_chan_io_qos {
73-
/** Channel interval in us. Value range 0x0000FF - 0x0FFFFFF. */
74-
uint32_t interval;
75-
/** Channel Latency in ms. Value range 0x0005 - 0x0FA0. */
76-
uint16_t latency;
7774
/** Channel SDU. Value range 0x0000 - 0x0FFF. */
7875
uint16_t sdu;
7976
/** Channel PHY - See BT_GAP_LE_PHY for values.
@@ -92,16 +89,6 @@ struct bt_iso_chan_io_qos {
9289

9390
/** @brief ISO Channel QoS structure. */
9491
struct bt_iso_chan_qos {
95-
/** @brief Channel peripherals sleep clock accuracy Only for CIS
96-
*
97-
* Shall be worst case sleep clock accuracy of all the peripherals.
98-
* If unknown for the peripherals, this should be set to BT_GAP_SCA_UNKNOWN.
99-
*/
100-
uint8_t sca;
101-
/** Channel packing mode. 0 for unpacked, 1 for packed. */
102-
uint8_t packing;
103-
/** Channel framing mode. 0 for unframed, 1 for framed. */
104-
uint8_t framing;
10592
/** @brief Channel Receiving QoS.
10693
*
10794
* Setting NULL disables data path BT_HCI_DATAPATH_DIR_CTLR_TO_HOST.
@@ -165,16 +152,75 @@ struct bt_iso_recv_info {
165152
uint8_t flags;
166153
};
167154

155+
156+
/** Opaque type representing an Connected Isochronous Group (CIG). */
157+
struct bt_iso_cig;
158+
159+
struct bt_iso_cig_create_param {
160+
/** Array of pointers to CIS channels
161+
*
162+
* This array shall remain valid for the duration of the CIG.
163+
*/
164+
struct bt_iso_chan **cis_channels;
165+
166+
/** Number channels in @p cis_channels */
167+
uint8_t num_cis;
168+
169+
/** Channel interval in us. Value range 0x0000FF - 0xFFFFFF. */
170+
uint32_t interval;
171+
172+
/** Channel Latency in ms. Value range 0x0005 - 0x0FA0. */
173+
uint16_t latency;
174+
175+
/** @brief Channel peripherals sleep clock accuracy Only for CIS
176+
*
177+
* Shall be worst case sleep clock accuracy of all the peripherals.
178+
* For possible values see the BT_GAP_SCA_* values.
179+
* If unknown for the peripherals, this should be set to
180+
* BT_GAP_SCA_UNKNOWN.
181+
*/
182+
uint8_t sca;
183+
184+
/** Channel packing mode. 0 for unpacked, 1 for packed. */
185+
uint8_t packing;
186+
187+
/** Channel framing mode. 0 for unframed, 1 for framed. */
188+
uint8_t framing;
189+
};
190+
191+
struct bt_iso_connect_param {
192+
/* The ISO channel to connect */
193+
struct bt_iso_chan *iso;
194+
195+
/* The ACL connection */
196+
struct bt_conn *conn;
197+
};
198+
168199
/** Opaque type representing an Broadcast Isochronous Group (BIG). */
169200
struct bt_iso_big;
170201

171202
struct bt_iso_big_create_param {
172-
/** Array of pointers to BIS channels */
203+
/** Array of pointers to BIS channels
204+
*
205+
* This array shall remain valid for the duration of the BIG.
206+
*/
173207
struct bt_iso_chan **bis_channels;
174208

175209
/** Number channels in @p bis_channels */
176210
uint8_t num_bis;
177211

212+
/** Channel interval in us. Value range 0x0000FF - 0xFFFFFF. */
213+
uint32_t interval;
214+
215+
/** Channel Latency in ms. Value range 0x0005 - 0x0FA0. */
216+
uint16_t latency;
217+
218+
/** Channel packing mode. 0 for unpacked, 1 for packed. */
219+
uint8_t packing;
220+
221+
/** Channel framing mode. 0 for unframed, 1 for framed. */
222+
uint8_t framing;
223+
178224
/** Whether or not to encrypt the streams. */
179225
bool encryption;
180226

@@ -337,49 +383,51 @@ struct bt_iso_server {
337383
*/
338384
int bt_iso_server_register(struct bt_iso_server *server);
339385

340-
/** @brief Bind ISO channels
386+
/** @brief Creates a CIG as a central
341387
*
342-
* Bind ISO channels with existing ACL connections, Channel objects passed
343-
* (over an address of it) shouldn't be instantiated in application as
344-
* standalone.
388+
* This can called at any time, even before connecting to a remote device.
389+
* This must be called before any connected isochronous stream (CIS) channel
390+
* can be connected.
345391
*
346-
* @param conns Array of ACL connection objects
347-
* @param num_conns Number of connection objects
348-
* @param chans Array of ISO Channel objects to be created
392+
* Once a CIG is created, the channels supplied in the @p param can be
393+
* connected using bt_iso_chan_connect.
394+
*
395+
* @param[in] param The parameters used to create and enable the CIG.
396+
* @param[out] out_cig Connected Isochronous Group object on success.
349397
*
350398
* @return 0 in case of success or negative value in case of error.
351399
*/
352-
int bt_iso_chan_bind(struct bt_conn **conns, uint8_t num_conns,
353-
struct bt_iso_chan **chans);
400+
int bt_iso_cig_create(const struct bt_iso_cig_create_param *param,
401+
struct bt_iso_cig **out_cig);
354402

355-
/** @brief Unbind ISO channel
356-
*
357-
* Unbind ISO channel from ACL connection, channel must be in BT_ISO_BOUND
358-
* state.
403+
/** @brief Terminates a CIG as a central
359404
*
360-
* Note: Channels which the ACL connection has been disconnected are unbind
361-
* automatically.
405+
* All the CIS in the CIG shall be disconnected first.
362406
*
363-
* @param chan Channel object.
407+
* @param cig Pointer to the CIG structure.
364408
*
365409
* @return 0 in case of success or negative value in case of error.
366410
*/
367-
int bt_iso_chan_unbind(struct bt_iso_chan *chan);
411+
int bt_iso_cig_terminate(struct bt_iso_cig *cig);
368412

369-
/** @brief Connect ISO channels
413+
/** @brief Connect ISO channels on ACL connections
414+
*
415+
* Connect ISO channels. The ISO channels must have been initialized in a CIG
416+
* first by calling bt_iso_cig_create.
417+
*
418+
* Once the connection is completed the channels' connected() callback will be
419+
* called. If the connection is rejected disconnected() callback is called
420+
* instead.
370421
*
371-
* Connect ISO channels, once the connection is completed each channel
372-
* connected() callback will be called. If the connection is rejected
373-
* disconnected() callback is called instead.
374-
* Channel object passed (over an address of it) as second parameter shouldn't
375-
* be instantiated in application as standalone.
422+
* This function will also setup the ISO data path based on the @p path
423+
* parameter of the bt_iso_chan_io_qos for each channel.
376424
*
377-
* @param chans Array of ISO channel objects
378-
* @param num_chans Number of channel objects
425+
* @param param Pointer to a connect parameter array with the ISO and ACL pointers.
426+
* @param count Number of connect parameters.
379427
*
380428
* @return 0 in case of success or negative value in case of error.
381429
*/
382-
int bt_iso_chan_connect(struct bt_iso_chan **chans, uint8_t num_chans);
430+
int bt_iso_chan_connect(const struct bt_iso_connect_param *param, size_t count);
383431

384432
/** @brief Disconnect ISO channel
385433
*

subsys/bluetooth/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Bluetooth configuration options
22

33
# Copyright (c) 2016 Intel Corporation
4+
# Copyright (c) 2021 Nordic Semiconductor ASA
45
# SPDX-License-Identifier: Apache-2.0
56

67
menuconfig BT
@@ -307,6 +308,17 @@ config BT_ISO_RX_MTU
307308
help
308309
Maximum MTU for Isochronous channels RX buffers.
309310

311+
if BT_ISO_UNICAST
312+
313+
config BT_ISO_MAX_CIG
314+
int "Maximum number of Connected Isochronous Groups (CIGs) to support"
315+
default 1
316+
help
317+
Maximum number of CIGs that are supported by the host. A CIG can be
318+
used for either transmitting or receiving.
319+
320+
endif # BT_ISO_UNICAST
321+
310322
if BT_ISO_BROADCAST
311323

312324
config BT_ISO_MAX_BIG

subsys/bluetooth/host/conn_internal.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ struct bt_conn_iso {
107107
};
108108

109109
union {
110-
/* CIS ID */
110+
/* CIS ID within the CIG */
111111
uint8_t cis_id;
112112

113-
/* BIS ID */
113+
/* BIS ID within the BIG*/
114114
uint8_t bis_id;
115115
};
116116

@@ -247,12 +247,6 @@ struct bt_iso_create_param {
247247
struct bt_iso_chan **chans;
248248
};
249249

250-
/* Bind ISO connections parameters */
251-
int bt_conn_bind_iso(struct bt_iso_create_param *param);
252-
253-
/* Connect ISO connections */
254-
int bt_conn_connect_iso(struct bt_conn **conns, uint8_t num_conns);
255-
256250
/* Add a new ISO connection */
257251
struct bt_conn *bt_conn_add_iso(struct bt_conn *acl);
258252

0 commit comments

Comments
 (0)