Skip to content

Commit d8d8d82

Browse files
Thalleynashif
authored andcommitted
Bluetooth: ISO: Add ISO limits as #defines and use them
Add #define's for ISO HCI limits and use them to validate input parameters. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 50280c6 commit d8d8d82

File tree

2 files changed

+241
-28
lines changed

2 files changed

+241
-28
lines changed

include/bluetooth/iso.h

Lines changed: 103 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,44 @@ extern "C" {
3535
BT_HCI_ISO_DATA_HDR_SIZE)
3636

3737
/** Value to set the ISO data path over HCi. */
38-
#define BT_ISO_DATA_PATH_HCI 0x00
38+
#define BT_ISO_DATA_PATH_HCI 0x00
39+
40+
/** Minimum interval value in microseconds */
41+
#define BT_ISO_INTERVAL_MIN 0x0000FF
42+
/** Maximum interval value in microseconds */
43+
#define BT_ISO_INTERVAL_MAX 0x0FFFFF
44+
/** Minimum latency value in milliseconds */
45+
#define BT_ISO_LATENCY_MIN 0x0005
46+
/** Maximum latency value in milliseconds */
47+
#define BT_ISO_LATENCY_MAX 0x0FA0
48+
/** Packets will be sent sequentially between the channels in the group */
49+
#define BT_ISO_PACKING_SEQUENTIAL 0x00
50+
/** Packets will be sent interleaved between the channels in the group */
51+
#define BT_ISO_PACKING_INTERLEAVED 0x01
52+
/** Packets may be framed or unframed */
53+
#define BT_ISO_FRAMING_UNFRAMED 0x00
54+
/** Packets are always framed */
55+
#define BT_ISO_FRAMING_FRAMED 0x01
56+
/** Maximum number of isochronous channels in a single group */
57+
#define BT_ISO_MAX_GROUP_ISO_COUNT 0x1F
58+
/** Maximum SDU size */
59+
#define BT_ISO_MAX_SDU 0x0FFF
60+
/** Minimum BIG sync timeout value (N * 10 ms) */
61+
#define BT_ISO_SYNC_TIMEOUT_MIN 0x000A
62+
/** Maximum BIG sync timeout value (N * 10 ms) */
63+
#define BT_ISO_SYNC_TIMEOUT_MAX 0x4000
64+
/** Controller controlled maximum subevent count value */
65+
#define BT_ISO_SYNC_MSE_ANY 0x00
66+
/** Minimum BIG sync maximum subevent count value */
67+
#define BT_ISO_SYNC_MSE_MIN 0x01
68+
/** Maximum BIG sync maximum subevent count value */
69+
#define BT_ISO_SYNC_MSE_MAX 0x1F
70+
/** Maximum connected ISO retransmission value */
71+
#define BT_ISO_CONNECTED_RTN_MAX 0xFF
72+
/** Maximum broadcast ISO retransmission value */
73+
#define BT_ISO_BROADCAST_RTN_MAX 0x1E
74+
/** Broadcast code size */
75+
#define BT_ISO_BROADCAST_CODE_SIZE 16
3976

4077
struct bt_iso_chan;
4178

@@ -70,13 +107,13 @@ struct bt_iso_chan {
70107

71108
/** @brief ISO Channel IO QoS structure. */
72109
struct bt_iso_chan_io_qos {
73-
/** Channel SDU. Value range 0x0000 - 0x0FFF. */
110+
/** Channel SDU. Maximum value is BT_ISO_MAX_SDU */
74111
uint16_t sdu;
75112
/** Channel PHY - See BT_GAP_LE_PHY for values.
76113
* Setting BT_GAP_LE_PHY_NONE is invalid.
77114
*/
78115
uint8_t phy;
79-
/** Channel Retransmission Number. Value range 0x00 - 0x0F. */
116+
/** Channel Retransmission Number. */
80117
uint8_t rtn;
81118
/** @brief Channel data path reference
82119
*
@@ -156,19 +193,29 @@ struct bt_iso_recv_info {
156193
struct bt_iso_cig;
157194

158195
struct bt_iso_cig_create_param {
159-
/** Array of pointers to CIS channels
196+
/** @brief Array of pointers to CIS channels
160197
*
161198
* This array shall remain valid for the duration of the CIG.
162199
*/
163200
struct bt_iso_chan **cis_channels;
164201

165-
/** Number channels in @p cis_channels */
202+
/** @brief Number channels in @p cis_channels
203+
*
204+
* Maximum number of channels in a single group is
205+
* BT_ISO_MAX_GROUP_ISO_COUNT
206+
*/
166207
uint8_t num_cis;
167208

168-
/** Channel interval in us. Value range 0x0000FF - 0xFFFFFF. */
209+
/** @brief Channel interval in us.
210+
*
211+
* Value range BT_ISO_INTERVAL_MIN - BT_ISO_INTERVAL_MAX.
212+
*/
169213
uint32_t interval;
170214

171-
/** Channel Latency in ms. Value range 0x0005 - 0x0FA0. */
215+
/** @brief Channel Latency in ms.
216+
*
217+
* Value range BT_ISO_LATENCY_MIN - BT_ISO_LATENCY_MAX.
218+
*/
172219
uint16_t latency;
173220

174221
/** @brief Channel peripherals sleep clock accuracy Only for CIS
@@ -180,10 +227,17 @@ struct bt_iso_cig_create_param {
180227
*/
181228
uint8_t sca;
182229

183-
/** Channel packing mode. 0 for unpacked, 1 for packed. */
230+
/** @brief Channel packing mode.
231+
*
232+
* BT_ISO_PACKING_SEQUENTIAL or BT_ISO_PACKING_INTERLEAVED
233+
*/
184234
uint8_t packing;
185235

186-
/** Channel framing mode. 0 for unframed, 1 for framed. */
236+
/** @brief Channel framing mode.
237+
*
238+
* BT_ISO_FRAMING_UNFRAMED for unframed and
239+
* BT_ISO_FRAMING_FRAMED for framed.
240+
*/
187241
uint8_t framing;
188242
};
189243

@@ -205,50 +259,78 @@ struct bt_iso_big_create_param {
205259
*/
206260
struct bt_iso_chan **bis_channels;
207261

208-
/** Number channels in @p bis_channels */
262+
/** @brief Number channels in @p bis_channels
263+
*
264+
* Maximum number of channels in a single group is
265+
* BT_ISO_MAX_GROUP_ISO_COUNT
266+
*/
209267
uint8_t num_bis;
210268

211-
/** Channel interval in us. Value range 0x0000FF - 0xFFFFFF. */
269+
/** @brief Channel interval in us.
270+
*
271+
* Value range BT_ISO_INTERVAL_MIN - BT_ISO_INTERVAL_MAX.
272+
*/
212273
uint32_t interval;
213274

214-
/** Channel Latency in ms. Value range 0x0005 - 0x0FA0. */
275+
/** @brief Channel Latency in ms.
276+
*
277+
* Value range BT_ISO_LATENCY_MIN - BT_ISO_LATENCY_MAX.
278+
*/
215279
uint16_t latency;
216280

217-
/** Channel packing mode. 0 for unpacked, 1 for packed. */
281+
/** @brief Channel packing mode.
282+
*
283+
* BT_ISO_PACKING_SEQUENTIAL or BT_ISO_PACKING_INTERLEAVED
284+
*/
218285
uint8_t packing;
219286

220-
/** Channel framing mode. 0 for unframed, 1 for framed. */
287+
/** @brief Channel framing mode.
288+
*
289+
* BT_ISO_FRAMING_UNFRAMED for unframed and
290+
* BT_ISO_FRAMING_FRAMED for framed.
291+
*/
221292
uint8_t framing;
222293

223294
/** Whether or not to encrypt the streams. */
224-
bool encryption;
295+
bool encryption;
225296

226297
/** @brief Broadcast code
227298
*
228299
* The code used to derive the session key that is used to encrypt and
229300
* decrypt BIS payloads.
230301
*/
231-
uint8_t bcode[16];
302+
uint8_t bcode[BT_ISO_BROADCAST_CODE_SIZE];
232303
};
233304

234305
struct bt_iso_big_sync_param {
235306
/** Array of pointers to BIS channels */
236307
struct bt_iso_chan **bis_channels;
237308

238-
/** Number channels in @p bis_channels */
309+
/** @brief Number channels in @p bis_channels
310+
*
311+
* Maximum number of channels in a single group is
312+
* BT_ISO_MAX_GROUP_ISO_COUNT
313+
*/
239314
uint8_t num_bis;
240315

241316
/** Bitfield of the BISes to sync to */
242317
uint32_t bis_bitfield;
243318

244319
/** @brief Maximum subevents
245320
*
246-
* The MSE (Maximum Subevents) parameter is the maximum number of subevents that a
247-
* Controller should use to receive data payloads in each interval for a BIS
321+
* The MSE (Maximum Subevents) parameter is the maximum number of
322+
* subevents that a Controller should use to receive data payloads
323+
* in each interval for a BIS.
324+
*
325+
* Value range is BT_ISO_SYNC_MSE_MIN to BT_ISO_SYNC_MSE_MAX, or
326+
* BT_ISO_SYNC_MSE_ANY to let the controller choose.
248327
*/
249328
uint32_t mse;
250329

251-
/** Synchronization timeout for the BIG (N * 10 MS) */
330+
/** @brief Synchronization timeout for the BIG (N * 10 MS)
331+
*
332+
* Value range is BT_ISO_SYNC_TIMEOUT_MIN to BT_ISO_SYNC_TIMEOUT_MAX.
333+
*/
252334
uint16_t sync_timeout;
253335

254336
/** Whether or not the streams of the BIG are encrypted */
@@ -259,7 +341,7 @@ struct bt_iso_big_sync_param {
259341
* The code used to derive the session key that is used to encrypt and
260342
* decrypt BIS payloads.
261343
*/
262-
uint8_t bcode[16];
344+
uint8_t bcode[BT_ISO_BROADCAST_CODE_SIZE];
263345
};
264346

265347
struct bt_iso_biginfo {

0 commit comments

Comments
 (0)