1 /*
2  * Copyright 2021-2023, Cypress Semiconductor Corporation or
3  * an affiliate of Cypress Semiconductor Corporation.  All rights reserved.
4  *
5  * This software, including source code, documentation and related
6  * materials ("Software") is owned by Cypress Semiconductor Corporation
7  * or one of its affiliates ("Cypress") and is protected by and subject to
8  * worldwide patent protection (United States and foreign),
9  * United States copyright laws and international treaty provisions.
10  * Therefore, you may use this Software only as provided in the license
11  * agreement accompanying the software package from which you
12  * obtained this Software ("EULA").
13  * If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
14  * non-transferable license to copy, modify, and compile the Software
15  * source code solely for use in connection with Cypress's
16  * integrated circuit products.  Any reproduction, modification, translation,
17  * compilation, or representation of this Software except as specified
18  * above is prohibited without the express written permission of Cypress.
19  *
20  * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
23  * reserves the right to make changes to the Software without notice. Cypress
24  * does not assume any liability arising out of the application or use of the
25  * Software or any product or circuit described in the Software. Cypress does
26  * not authorize its products for use in any products where a malfunction or
27  * failure of the Cypress product may reasonably be expected to result in
28  * significant property damage, injury or death ("High Risk Product"). By
29  * including Cypress's product in a High Risk Product, the manufacturer
30  * of such system or application assumes all risk of such use and in doing
31  * so agrees to indemnify Cypress against all liability.
32  */
33 
34 /** @file
35  *
36  * WICED Bluetooth Low Energy (BLE) Ischoronous function
37  *
38  *  Some Acronyms and Abbreviations :
39  *      CIS   -  Connected Isochronous Stream
40  *      CIG   -  Connected Isochronous Group
41  *      BIS   -  Broadcast Isochronous Stream
42  *      BIG   -  Broadcast Isochronous Group
43  *      ISO   -  Isochronous
44  *      ISOAL -  Isochronous Adaption Layer
45  */
46 #pragma once
47 
48 #include "wiced_bt_types.h"
49 #include "wiced_result.h"
50 
51 /**
52  * @defgroup  wicedbt_isoc        Ischoronous (ISOC)
53  *
54  * This section describes the API's to use ISOC functionality.
55  *
56 */
57 
58 /**
59  * @addtogroup  wicedbt_isoc_defs         ISOC data types and macros
60  * @ingroup     wicedbt_isoc
61  *
62  * @{
63 */
64 /*****************************************************************************
65 **  constants
66 *****************************************************************************/
67 
68 #define WICED_BLE_ISOC_MIN_TRANSPORT_LATENCY      0x0005     /**< ISOC Minimum Latency */
69 #define WICED_BLE_ISOC_MAX_TRANSPORT_LATENCY      0x0FA0     /**< ISOC Maximum Latency */
70 
71 typedef enum
72 {
73     WICED_BLE_ISOC_DPD_INPUT = 0,     // ISO driver is source (Input data path (Host to Controller))
74     WICED_BLE_ISOC_DPD_OUTPUT,        // ISO driver is sink (Output data path (Controller to Host))
75     WICED_BLE_ISOC_DPD_MAX_DIRECTIONS // must be last
76 } wiced_bt_isoc_data_path_direction_t;
77 
78 typedef enum
79 {
80     WICED_BLE_ISOC_DPD_UNUSED = 0,
81     WICED_BLE_ISOC_DPD_INPUT_BIT = 1,
82     WICED_BLE_ISOC_DPD_OUTPUT_BIT = 2,
83     WICED_BLE_ISOC_DPD_INPUT_OUTPUT_BIT = WICED_BLE_ISOC_DPD_INPUT_BIT & WICED_BLE_ISOC_DPD_OUTPUT_BIT,
84     WICED_BLE_ISOC_DPD_RESERVED
85 } wiced_bt_isoc_data_path_bit_t;
86 
87 #define ISOC_SET_DATA_PATH_DIR(var, dir) (var |= (1 << dir))
88 #define ISOC_GET_DATA_PATH_DIR(var, dir) (var & (1 << dir))
89 #define ISOC_CLEAR_DATA_PATH_DIR(var, dir) (var &= ~(1 << dir))
90 
91 typedef enum
92 {
93     WICED_BLE_ISOC_DPID_HCI = 0,
94     WICED_BLE_ISOC_DPID_DIABLED = 0xFF
95 } wiced_bt_isoc_data_path_id_t;
96 
97 /** ISOC packing methods */
98 enum wiced_bt_isoc_packing_e
99 {
100     WICED_BLE_ISOC_SEQUENTIAL_PACKING = 0,
101     WICED_BLE_ISOC_INTERLEAVED_PACKING = 1
102 };
103 typedef uint8_t wiced_bt_isoc_packing_t; /**< ISOC packing methods (see #wiced_bt_isoc_packing_e) */
104 
105 /** ISOC Framing types */
106 enum wiced_bt_isoc_framing_e
107 {
108     WICED_BLE_ISOC_UNFRAMED = 0,
109     WICED_BLE_ISOC_FRAMED   = 1
110 };
111 typedef uint8_t wiced_bt_isoc_framing_t; /**< ISOC Framing types (see #wiced_bt_isoc_framing_e) */
112 
113 /** ISOC LE PHY */
114 enum wiced_bt_isoc_phy_e
115 {
116     WICED_BLE_ISOC_LE_1M_PHY = 1,
117     WICED_BLE_ISOC_LE_2M_PHY = 2,
118     WICED_BLE_ISOC_LE_CODED  = 4,
119 };
120 typedef uint8_t wiced_bt_isoc_phy_t; /**< ISOC LE PHY (see #wiced_bt_isoc_phy_e) */
121 
122 /** Broadcast ISOC Encryption */
123 enum wiced_bt_isoc_encryption_e
124 {
125     WICED_BLE_ISOC_UNENCRYPTED = 0,
126     WICED_BLE_ISOC_ENCRYPTED   = 1,
127 };
128 typedef uint8_t wiced_bt_isoc_encryption_t; /**< ISOC Encryption (see #wiced_bt_isoc_encryption_e) */
129 
130 /** ISOC Events */
131 enum wiced_bt_isoc_event_e
132 {
133     WICED_BLE_ISOC_SET_CIG_CMD_COMPLETE,  /**< CIG Command Response */
134     WICED_BLE_ISOC_CIS_REQUEST,           /**< CIS connection Requested */
135     WICED_BLE_ISOC_CIS_ESTABLISHED,       /**< CIS connection established */
136     WICED_BLE_ISOC_SLAVE_CLOCK_ACCURACY,  /**< Slave Clock Accuracy */
137     WICED_BLE_ISOC_CIS_DISCONNECTED,      /**< CIS disconnected */
138     WICED_BLE_ISOC_DATA_PATH_SETUP,       /**< CIS Data path status */
139     WICED_BLE_ISOC_DATA_PATH_REMOVED,     /**< CIS Data path status */
140     WICED_BLE_ISOC_BIG_CREATED,           /**< BIG Connected */
141     WICED_BLE_ISOC_BIG_SYNC_ESTABLISHED,  /**< BIG Sync Established */
142     WICED_BLE_ISOC_BIG_TERMINATED,        /**< BIG Terminated */
143     WICED_BLE_ISOC_BIG_SYNC_LOST,         /**< BIG Sync Lost */
144 };
145 typedef uint8_t wiced_bt_isoc_event_t; /**< ISOC Events (see #wiced_bt_isoc_event_e) */
146 
147 /** ISOC CIS Request Event Data */
148 typedef struct
149 {
150     uint16_t    cis_conn_handle;        /**< CIS Connection Handle */
151     uint16_t    acl_handle;             /**< ACL Connection Handle */
152     uint8_t     cig_id;                 /**< CIG ID */
153     uint8_t     cis_id;                 /**< CIS ID */
154 }wiced_bt_isoc_cis_request_data_t;
155 
156 /** ISOC CIS Disconnect Event Data */
157 typedef struct
158 {
159     uint16_t    cis_conn_handle;        /**< CIS Connection Handle */
160     uint8_t     cis_id;                 /**< CIS ID */
161     uint8_t     cig_id;                 /**< CIG ID */
162     uint8_t     reason;                 /**< Disconnection Reason */
163 }wiced_bt_isoc_cis_disconnect_data_t;
164 
165 /** ISOC CIS Established Event Data */
166 typedef struct
167 {
168     uint8_t                     status;                 /**< CIG Establishment Status  (0 = Success). Refer Core Spec v5.2 [Vol 1] Part F, Controller Error Codes */
169     uint16_t                    cis_conn_handle;        /**< CIS Connection Handle */
170     uint8_t                     cig_id;                 /**< CIG ID */
171     uint8_t                     cis_id;                 /**< CIS ID */
172     uint32_t                    cig_sync_delay;         /**< CIG Sync Delay in microseconds */
173     uint32_t                    cis_sync_delay;         /**< CIS Sync Delay in microseconds */
174     uint32_t                    latency_c_to_p;         /**< Maximum time, in microseconds, for an SDU to be transported from the master Controller to slave Controller */
175     uint32_t                    latency_p_to_c;         /**< Maximum time, in microseconds, for an SDU to be transported from the slave Controller to master Controller */
176     wiced_bt_isoc_phy_t     phy_c_to_p;             /**< The transmitter PHY of packets from the master */
177     wiced_bt_isoc_phy_t     phy_p_to_c;             /**< The transmitter PHY of packets from the slave */
178     uint8_t                     nse;                    /**< Maximum Number of Subevent in each isochronous event */
179     uint8_t                     bn_c_to_p;              /**< Burst number for master to slave transmission */
180     uint8_t                     bn_p_to_c;              /**< Burst number for slave to master transmission */
181     uint8_t                     ft_c_to_p;              /**< Flush timeout, in multiples of the ISO_Interval for master to slave transmission */
182     uint8_t                     ft_p_to_c;              /**< Flush timeout, in multiples of the ISO_Interval for slave to master transmission */
183     uint16_t                    max_pdu_c_to_p;         /**< Maximum size, in bytes, of an SDU from the master’s Host */
184     uint16_t                    max_pdu_p_to_c;         /**< Maximum size, in octets, of an SDU from the slave’s Host */
185     uint16_t                    iso_interval;           /**< Time between two consecutive CIS anchor points */
186 }wiced_bt_isoc_cis_established_data_t;
187 
188 /** ISOC CIG Command Status data */
189 typedef struct
190 {
191     uint8_t        status;                       /**< CIG Establishment Status  (0 = Success). Refer Core Spec v5.2 [Vol 1] Part F, Controller Error Codes */
192     uint8_t        cig_id;                       /**< CIG ID */
193     uint8_t        cis_count;                    /**< CIS Count */
194     uint16_t       *cis_connection_handle_list;  /**< CIS Connection Handle List */
195     void           *ctx;                         /**< upper layer context */
196 }wiced_bt_isoc_cig_status_data_t;
197 
198 /** ISOC Peer Slave Clock Accuracy data */
199 typedef struct
200 {
201     uint8_t        status;                       /**< SCA Status (0 = Success). Refer Core Spec v5.2 [Vol 1] Part F, Controller Error Codes*/
202     uint16_t       acl_handle;                   /**< ACL Connection Handle */
203     wiced_bt_device_address_t peer_bda;          /**< Peer Bluetooth Address */
204     uint8_t        sca;                          /**< Slave Clock Accuracy value */
205 }wiced_bt_isoc_sca_t;
206 
207 typedef struct
208 {
209     uint8_t status; /**< Data path Status  (0 = Success). Refer Core Spec v5.2 [Vol 1] Part F, Controller Error Codes */
210     uint16_t conn_hdl;                                 /**< CIS/BIS Connection Handle  */
211     wiced_bt_isoc_data_path_direction_t data_path_dir; /**< data path direction (valid for data path setup only) */
212 } wiced_bt_isoc_data_path_status_t;
213 
214 /** ISOC BIG Terminate/Sync_Lost Event Data */
215 typedef struct
216 {
217     uint8_t        big_handle;                   /**< BIG Handle */
218     uint8_t        reason;                       /**< Reason for termination. Refer Core Spec v5.2 [Vol 1] Part F, Controller Error Codes */
219 }wiced_bt_isoc_terminated_data_t;
220 
221 /** ISOC BIG Sync Establishment data */
222 typedef struct
223 {
224     uint8_t        status;                       /**< Create BIG Status (0 = Success). Refer Core Spec v5.2 [Vol 1] Part F, Controller Error Codes */
225     uint8_t        big_handle;                   /**< BIG Handle */
226     uint32_t       trans_latency;                /**< The maximum delay time, in microseconds, for transmission of SDUs of all BISes in a BIG event */
227     uint8_t        number_of_subevents;          /**< The number of subevents in each BIS event in the BIG */
228     uint8_t        burst_number;                 /**< The number of new payloads in each BIS event */
229     uint8_t        pretransmission_offset;       /**< Offset used for pre-transmissions */
230     uint8_t        immediate_repetition_count;   /**< The number of times a payload is transmitted in a BIS event */
231     uint16_t       max_pdu;                      /**< Maximum size, in octets, of the payload */
232     uint16_t       iso_interval;                 /**< The time between two consecutive BIG anchor points. Time = N * 1.25 ms */
233     uint8_t        num_bis;                      /**< Total number of BISes in the BIG */
234     uint16_t       *bis_conn_hdl_list;           /**< The connection handles of the BISes */
235 }wiced_bt_isoc_big_sync_established_t;
236 
237 /** ISOC BIG Command Status data */
238 typedef struct
239 {
240     wiced_bt_isoc_big_sync_established_t sync_data; /**< BIG Sync Data */
241     uint32_t sync_delay;                            /**< BIG Sync Delay in microseconds */
242     wiced_bt_isoc_phy_t phy;                    /**< The transmitter PHY of packets */
243 } wiced_bt_isoc_create_big_complete_t;
244 
245 /** ISOC Event Data */
246 typedef union
247 {
248     wiced_bt_isoc_cig_status_data_t cig_status_data;           /**< CIG Command Status */
249     wiced_bt_isoc_cis_established_data_t cis_established_data; /**< CIS Established */
250     wiced_bt_isoc_cis_request_data_t cis_request;              /**< CIS Request     */
251     wiced_bt_isoc_sca_t sca_data;                              /**< Slave Clock Accuracy */
252     wiced_bt_isoc_cis_disconnect_data_t cis_disconnect;        /**< CIS Disconnect  */
253     wiced_bt_isoc_data_path_status_t datapath;                 /**< Data Path Status (setup/remove) */
254     wiced_bt_isoc_create_big_complete_t create_big;            /**< Create BIG Command Status */
255     wiced_bt_isoc_terminated_data_t terminate_big;             /**< Terminate BIG Command Status */
256     wiced_bt_isoc_big_sync_established_t big_sync_established; /**< BIG Sync Established data */
257     wiced_bt_isoc_terminated_data_t big_sync_lost;             /**< BIG Sync Lost Data */
258 } wiced_bt_isoc_event_data_t;
259 
260 /** ISOC CIS Configuration */
261 typedef struct
262 {
263     uint8_t                     cis_id;           /**< CIS Id : ZERO if not created*/
264     uint16_t                    max_sdu_c_to_p;   /**< Maximum size, in bytes, of an SDU from the master’s Host
265                                                        Valid Range 0x000 to 0xFFF*/
266     uint16_t                    max_sdu_p_to_c;   /**< Maximum size, in octets, of an SDU from the slave’s Host
267                                                        Valid Range 0x000 to 0xFFF*/
268     wiced_bt_isoc_phy_t     phy_c_to_p;       /**< The transmitter PHY of packets from the master */
269     wiced_bt_isoc_phy_t     phy_p_to_c;       /**< The transmitter PHY of packets from the slave */
270     uint8_t                     rtn_c_to_p;       /**< Maximum number of times every CIS Data PDU should be retransmitted from the master to slave */
271     uint8_t                     rtn_p_to_c;       /**< Maximum number of times every CIS Data PDU should be retransmitted from the slave to master */
272 }wiced_bt_ble_cis_config_t;
273 
274 /** ISOC CIG Configuration */
275 typedef struct
276 {
277     uint8_t                     cig_id;                     /**< CIG ID if known */
278     uint32_t                    sdu_interval_c_to_p;        /**< Time interval in microseconds between the start of consecutive SDUs from the master’s Host for all the CISes in the CIG */
279     uint32_t                    sdu_interval_p_to_c;        /**< Time interval in microseconds between the start of consecutive SDUs from the slave’s Host for all the CISes in the CIG. */
280     uint8_t                     peripheral_clock_accuracy;       /**< Slave Clock Accuracy */
281     uint16_t                    max_trans_latency_c_to_p;   /**< Maximum time, in microseconds, for an SDU to be transported from the master Controller to slave Controller */
282     uint16_t                    max_trans_latency_p_to_c;   /**< Maximum time, in microseconds, for an SDU to be transported from the slave Controller to master Controller */
283     wiced_bt_isoc_packing_t packing;                    /**< Packing method  */
284     wiced_bt_isoc_framing_t framing;                    /**< Framing parameter */
285     uint8_t                     cis_count;                  /**< Total number of CISes in the CIG being added or modified
286                                                                   Valid Range 0x00 to 0x10 */
287     wiced_bt_ble_cis_config_t   *p_cis_config_list;           /**< CIS configurations */
288 }wiced_bt_ble_cig_param_t;
289 
290 typedef struct
291 {
292     uint8_t cis_id;                     /**< CIS Id : ZERO if not created*/
293     uint8_t nse;                        /**< Maximum number of subevents in each CIS event */
294     uint16_t max_sdu_c_to_p;            /**< Maximum size, in bytes, of an SDU from the master’s Host Valid Range 0x000 to 0xFFF*/
295     uint16_t max_sdu_p_to_c;            /**< Maximum size, in octets, of an SDU from the slave’s Host Valid Range 0x000 to 0xFFF*/
296     uint16_t max_pdu_c_to_p;            /**< Maximum size, in bytes, of an SDU from the master’s Host Valid Range 0x000 to 0xFFF*/
297     uint16_t max_pdu_p_to_c;            /**< Maximum size, in octets, of an SDU from the slave’s Host Valid Range 0x000 to 0xFFF*/
298     wiced_bt_isoc_phy_t phy_c_to_p; /**< The transmitter PHY of packets from the master */
299     wiced_bt_isoc_phy_t phy_p_to_c; /**< The transmitter PHY of packets from the slave */
300     uint8_t bn_c_to_p;                  /**< Maximum number of times every CIS Data PDU should be retransmitted from the master to slave */
301     uint8_t bn_p_to_c;                  /**< Maximum number of times every CIS Data PDU should be retransmitted from the slave to master */
302 } wiced_bt_ble_cis_config_test_t;
303 
304 typedef struct
305 {
306     uint8_t cig_id;               /**< CIG ID if known */
307     uint32_t sdu_interval_c_to_p; /**< Time interval in microseconds between the start of consecutive SDUs from the master’s Host for all the CISes in the CIG */
308     uint32_t sdu_interval_p_to_c; /**< Time interval in microseconds between the start of consecutive SDUs from the slave’s Host for all the CISes in the CIG. */
309     uint8_t ft_c_to_p;            /**< The flush timeout in multiples of ISO_Interval for each payload sent from the master to slave. */
310     uint8_t ft_p_to_c;            /**< The flush timeout in multiples of ISO_Interval for each payload sent from the slave to master. */
311     uint16_t iso_interval;        /**< Time between consecutive CIS anchor points */
312     uint8_t peripheral_clock_accuracy;               /**< Slave Clock Accuracy */
313     wiced_bt_isoc_packing_t packing;        /**< Packing method  */
314     wiced_bt_isoc_framing_t framing;        /**< Framing parameter */
315     uint8_t cis_count;                          /**< Total number of CISes in the CIG being added or modified Valid Range 0x00 to 0x10 */
316     wiced_bt_ble_cis_config_test_t *p_cis_config_list; /**< CIS configurations */
317 } wiced_bt_ble_cig_param_test_t;
318 
319 typedef struct
320 {
321     uint8_t cis_count;
322     uint16_t *cis_handle_list;
323     uint16_t *acl_handle_list;
324 } wiced_bt_isoc_create_cis_param_t;
325 
326 typedef struct
327 {
328     uint8_t big_handle;
329     uint8_t adv_handle;
330     uint8_t num_bis;
331     uint32_t sdu_interval;
332     uint16_t max_sdu;
333     uint16_t max_trans_latency;
334     uint8_t rtn;
335     uint8_t phy;
336     uint8_t packing;
337     uint8_t framing;
338     uint8_t encrypt;
339     uint8_t broadcast_code[16];
340 } wiced_bt_isoc_create_big_param_t;
341 
342 typedef struct
343 {
344     uint8_t big_handle;
345     uint16_t sync_handle;
346     uint8_t encrypt;
347     uint8_t *broadcast_code;
348     uint8_t max_sub_events;
349     uint16_t big_sync_timeout;
350     uint8_t num_bis;
351     uint8_t *bis_idx_list;
352 } wiced_bt_isoc_big_create_sync_t;
353 
354 typedef void (*wiced_bt_iso_rx_cb_t)(uint8_t *p_data, uint32_t length);
355 typedef void (*wiced_bt_iso_num_complete_cb_t)(uint8_t *p_buf);
356 
357 extern wiced_bt_iso_rx_cb_t g_iso_rx_data_cb;
358 extern wiced_bt_iso_num_complete_cb_t g_iso_num_complete_cb;
359 
360 /******************************************************
361  *               Function Declarations
362  *
363  ******************************************************/
364 #ifdef __cplusplus
365 extern "C" {
366 #endif
367 
368 
369 /**
370  * ISOC event callback
371  *
372  * Callback for ISOC event notifications
373  * Registered using #wiced_bt_isoc_register_cb
374  *
375  * @param event             : Event ID
376  * @param p_event_data      : Event data
377  *
378  * @return Status of event handling
379 */
380 typedef void wiced_bt_isoc_cback_t(wiced_bt_isoc_event_t event, wiced_bt_isoc_event_data_t *p_event_data);
381 
382 /** @} wicedbt_isoc_defs         */
383 
384 /**
385  * @addtogroup  wicedbt_isoc_functions   Ischoronous (ISOC) functions
386  * @ingroup     wicedbt_isoc
387  *
388  * Ischoronous(ISOC) Functions.
389  *
390  * @{
391  */
392 
393 /**
394  *
395  * Function         wiced_bt_isoc_register_cb
396  *
397  *                  ISOC Register event callback handler
398  *
399  * @param[in]       isoc_cb  : ISOC event callback
400  *
401  * @return      None
402  *
403  */
404 void wiced_bt_isoc_register_cb(wiced_bt_isoc_cback_t isoc_cb);
405 
406 /**
407  * @brief Register ISO data event callbacks
408  *
409  * @param rx_data_cb Callback upon receiving ISO data
410  * @param num_complete_cb Callback after transmitting ISO data
411  */
412 void wiced_bt_isoc_register_data_cb(wiced_bt_iso_rx_cb_t rx_data_cb, wiced_bt_iso_num_complete_cb_t num_complete_cb);
413 
414 /**
415  *
416  * Function         wiced_bt_isoc_central_set_cig_param
417  *
418  * Used by a master’s Host to set the parameters of one or more CISes that are
419  * associated with a CIG in the Controller. If none of the CISes in that CIG
420  * have been created, this command may also be used to modify or add CIS(s)
421  * to that CIG.
422  *
423  * @param[in]       cig_params  : CIG parameter (@ref wiced_bt_ble_cig_param_t)
424  * @param[in]       ctx         : pointer to application data that will be given back
425  *                                to application through the WICED_BLE_ISOC_SET_CIG_CMD_COMPLETE event
426  *
427  * @return      status
428  *
429  */
430 wiced_result_t wiced_bt_isoc_central_set_cig_param(wiced_bt_ble_cig_param_t *cig_params, void *ctx);
431 
432 /**
433  *
434  * Function         wiced_bt_isoc_central_set_cig_param_test
435  *
436  * Command should only be used for testing purposes only.
437  *
438  * Used by a master’s Host to set the parameters of one or more CISes that are
439  * associated with a CIG in the Controller. If none of the CISes in that CIG
440  * have been created, this command may also be used to modify or add CIS(s)
441  * to that CIG.
442  *
443  * @param[in]       cig_params  : CIG parameter (@ref wiced_bt_ble_cig_param_t)
444  * @param[in]       ctx         : pointer to application data that will be given back
445  *                                to application through the WICED_BLE_ISOC_SET_CIG_CMD_COMPLETE event
446  *
447  * @return      status
448  *
449  */
450 wiced_result_t wiced_bt_isoc_central_set_cig_param_test(wiced_bt_ble_cig_param_test_t *cig_params, void *ctx);
451 
452 /**
453  *
454  * Function         wiced_bt_isoc_central_create_cis
455  *
456  *                  This API is invoked to create one or more CIS channels
457  *
458  * @param[in]       cis_count        : Number of elements in CIS handle list and ACL handle list.
459  *                                     These lists must be of the same length
460  * @param[in]       cis_handle_list  : List of connection handles of the cis to be established
461  * @param[in]       acl_handle_list  : ACL connection handle associated with the cis handles.
462  *                                     The ith acl handle corresponds to the ith cis handle, etc.
463  *
464  * @return      status
465  *
466  *  Note : Once CIS is establish WICED_BLE_ISOC_CIS_ESTABLISHED event will be received in registered application callback.
467  */
468 wiced_result_t wiced_bt_isoc_central_create_cis(wiced_bt_isoc_create_cis_param_t *create_cis_param);
469 
470 /**
471  *
472  * Function         wiced_bt_isoc_create_cis_by_bda
473  *
474  *                  Create CIS (Connected Isochronous Stream) connection
475  *
476  * @param[in]       cis_count         : Number of elements in Peer BDA list and CIS handle list.
477  * @param[in]       peer_bda_list   : Peer Bluetooth Address List
478  * @param[in]       cis_handle_list : CIS handles List
479  *
480  * @return      status
481  *
482  *  Note : Once CIS is establish WICED_BLE_ISOC_CIS_ESTABLISHED event will be received in registered application callback.
483  */
484 wiced_result_t wiced_bt_isoc_create_cis_by_bda(uint8_t cis_count, uint8_t *peer_bda_list, uint16_t *cis_handle_list);
485 
486 /**
487  *
488  * Function         wiced_bt_isoc_peripheral_accept_cis
489  *
490  *                  Accept CIS (Connected Isochronous Stream) connection request
491  *                  Slave should call this API on receiving WICED_BLE_ISOC_CIS_REQUEST event in registered application callback
492  *
493  * @param[in]       cis_handle  : CIS handle
494  *
495  * @return      status
496  *
497  *  Note : Once CIS is establish WICED_BLE_ISOC_CIS_ESTABLISHED event will be received in registered application callback.
498  */
499 wiced_result_t wiced_bt_isoc_peripheral_accept_cis(
500     uint8_t cig_id, uint8_t cis_id, uint16_t cis_conn_handle, uint8_t src_ase_id, uint8_t sink_ase_id);
501 
502 /**
503  *
504  * Function         wiced_bt_isoc_peripheral_reject_cis
505  *
506  *                  Reject CIS (Connected Isochronous Stream) connection request
507  *                  Slave should call this API on receiving WICED_BLE_ISOC_CIS_REQUEST event in registered application callback
508  *
509  * @param[in]       cis_handle  : CIS handle
510  * @param[in]       reason      : Reject Reason
511  *
512  * @return      status
513  *
514  */
515 wiced_result_t wiced_bt_isoc_peripheral_reject_cis(uint16_t cis_handle, uint8_t reason);
516 
517 /**
518  *
519  * Function         wiced_bt_isoc_peripheral_remove_cig
520  *
521  *                  Remove CIG (Connected Isochronous Group)
522  *                  Slave should call this API on receiving WICED_BLE_ISOC_CIS_DISCONNECTED event in registered application callback and if ASCS State is Releasing
523  *
524  * @param[in]       cig_id  : CIG ID
525  *
526  * @return      status
527  *
528  */
529 wiced_result_t wiced_bt_isoc_peripheral_remove_cig(uint8_t cig_id);
530 
531 /**
532  *
533  * Function         wiced_bt_isoc_disconnect_cis
534  *
535  *                  Disconnect CIS (Connected Isochronous Stream) connection
536  *
537  * @param[in]       cis_handle  : CIS handle
538  *
539  * @return      status
540  *
541  *  Note : Once CIS is disconnected WICED_BLE_ISOC_CIS_DISCONNECTED event will be received in registered application callback.
542  */
543 wiced_result_t wiced_bt_isoc_disconnect_cis(uint16_t cis_handle);
544 
545 /**
546  * @brief Get CIS connection status
547  *
548  * @param cig_id CIG identifier
549  * @param cis_id CIS identifier
550  * @return wiced_bool_t TRUE if CIS connection exists
551  */
552 wiced_bool_t wiced_bt_isoc_is_cis_connected(uint8_t cig_id, uint8_t cis_id);
553 
554 /**
555  * @brief Get CIS connection status by CIS conn id
556  *
557  * @param cis_conn_id CIS conn id
558  * @return wiced_bool_t TRUE if CIS connection exists
559  */
560 wiced_bool_t wiced_bt_isoc_is_cis_connected_by_conn_id(uint16_t cis_conn_id);
561 
562 /**
563  *
564  * Function         wiced_bt_isoc_central_request_peer_sca
565  *
566  *                  Request for Slave Clock Accuracy
567  *
568  * @param[in]       peer_bda  : Peer Bluetooth Address
569  *
570  * @return      status
571  *
572  *  Note : WICED_BLE_ISOC_SLAVE_CLOCK_ACCURACY event will be received in registered application callback.
573  */
574 wiced_result_t wiced_bt_isoc_central_request_peer_sca(wiced_bt_device_address_t peer_bda);
575 
576 /**
577  *
578  * Function         wiced_bt_isoc_central_remove_cig
579  *
580  *                  Remove given CIG
581  *
582  * @param[in]       cig_id  : CIG ID
583  *
584  * @return      status
585  */
586 wiced_result_t wiced_bt_isoc_central_remove_cig(uint8_t cig_id);
587 
588 /**
589  * wiced_bt_isoc_central_get_psn_by_cis_handle
590  *
591  * @param[in]       handle  : CIS handle
592  * @return      packet sequence number
593  */
594 uint16_t wiced_bt_isoc_central_get_psn_by_cis_handle(uint16_t handle);
595 
596 /**
597  * wiced_bt_isoc_get_psn_by_bis_handle
598  *
599  * @param[in]       handle  : BIS handle
600  * @return      packet sequence number
601  **/
602 uint16_t wiced_bt_isoc_get_psn_by_bis_handle(uint16_t handle);
603 
604 /**
605  * wiced_bt_isoc_is_bis_created
606  *
607  * @param[in]       handle  : BIS Connection handle
608  * @return     TRUE if BIG exists
609  */
610 wiced_bool_t wiced_bt_isoc_is_bis_created(uint16_t bis_conn_handle);
611 
612 /**
613  * @brief Create BIG with provided parameters
614  *
615  * @param p_big_param Number of BIS, SDU Interval, Packing, Framing
616  * @return WICED_SUCCESS if successful
617  */
618 wiced_result_t wiced_bt_isoc_central_create_big(wiced_bt_isoc_create_big_param_t *p_big_param);
619 
620 /**
621  * @brief terminate a BIG identified by the BIG_Handle
622  *
623  * @param big_handle Used to identify the BIG
624  * @param reason Reason the BIG is terminated.
625  * @return wiced_result_t WICED_SUCCESS if successful
626  */
627 wiced_result_t wiced_bt_isoc_central_terminate_big(uint8_t big_handle, uint8_t reason);
628 
629 /**
630  * @brief Sync to the BIS stream described by wiced_bt_isoc_big_create_sync_t
631  *
632  * @param p_create_sync sync_handle, list of BIS indices
633  * @return wiced_bool_t TRUE if successful
634  */
635 wiced_bool_t wiced_bt_isoc_peripheral_big_create_sync(wiced_bt_isoc_big_create_sync_t *p_create_sync);
636 
637 /**
638  * @brief Stop synchronizing or cancel the process of synchronizing to
639  * the BIG identified by the BIG_Handle
640  *
641  * @param big_handle Used to identify the BIG
642  * @return wiced_result_t wiced_result_t WICED_SUCCESS if successful
643  */
644 wiced_result_t wiced_bt_isoc_peripheral_big_terminate_sync(uint8_t big_handle);
645 
646 /**
647  * @brief Remove data path setup for a CIS/BIS
648  *
649  * @param conn_hdl CIS/BIS Connection handle
650  * @param is_cis TRUE if CIS connection handle is provided
651  * @param data_path_dir_bitfield see #wiced_bt_isoc_data_path_bit_t
652  *                               bit 0: Remove Input data path
653  *                               bit 1: Remove output data path
654  * @return wiced_bool_t TRUE if successful in sending the command
655  */
656 wiced_bool_t wiced_bt_isoc_remove_data_path(uint16_t conn_hdl,
657                                             wiced_bool_t is_cis,
658                                             wiced_bt_isoc_data_path_bit_t data_path_dir_bitfield);
659 
660 /**
661  * @brief Get status of the ISO CIS/BIS data path
662  *
663  * @param cig_id CIG identifier
664  * @param cis_id CIS identifier
665  * @param data_path_dir INPUT/OUTPUT see #wiced_bt_isoc_data_path_direction_t
666  * @return wiced_bool_t
667  */
668 wiced_bool_t wiced_bt_isoc_is_data_path_active(uint8_t cig_id,
669                                                uint8_t cis_id,
670                                                wiced_bt_isoc_data_path_direction_t data_path_dir);
671 
672 /**
673  * @brief
674  *
675  * @param cig_id CIG identifier
676  * @param cis_id CIS identifier
677  * @return cis_conn_handle CIS connection handle
678  */
679 void wiced_bt_isoc_update_cis_conn_handle(uint8_t cig_id, uint8_t cis_id, uint16_t cis_conn_handle);
680 
681 /**
682  * @brief
683  *
684  * @param cig_id CIG identifier
685  * @param cis_id CIS identifier
686  * @return uint16_t CIS connection handle
687  */
688 uint16_t wiced_bt_isoc_get_cis_conn_handle(uint8_t cig_id, uint8_t cis_id);
689 
690 /**
691  * @brief Can be invoked twice per connection handle (once per direction)
692  * Supports only HCI for datapath and Does not support configuring codec in the controller
693  *
694  * @param conn_hdl CIS/BIS Connection handle
695  * @param is_cis TRUE if CIS connection handle is provided
696  * @param data_path_dir see #wiced_bt_isoc_data_path_direction_t
697  * @param data_path_id see #wiced_bt_isoc_data_path_id_t
698  * @param controller_delay select a suitable Controller_Delay value from the range of values
699  *                         provided by the HCI_Read_Local_Supported_Controller_Delay command
700  * @return wiced_bool_t TRUE if successful in sending the command
701  */
702 wiced_bool_t wiced_bt_isoc_setup_data_path(uint16_t conn_hdl,
703                                            wiced_bool_t is_cis,
704                                            wiced_bt_isoc_data_path_direction_t data_path_dir,
705                                            wiced_bt_isoc_data_path_id_t data_path_id,
706                                            uint32_t controller_delay);
707 
708 /**
709   * This function writes ISO buffer to the lower layer (or controller in the Hosted Stack)
710   *
711   * Called by application to send the isoc data.
712   *
713   * @param[in] p_data    : Pointer to the buffer
714   * @param[in] len       : Length of data at p_data
715   *
716   * @return : wiced_bool_t TRUE if successful otherwise FALSE
717   */
718 
719  wiced_bool_t wiced_bt_write_iso_data_to_lower(uint8_t* p_data, uint16_t len);
720 
721 /** This function returns ISOC buffer size */
722 
723  uint16_t wiced_bt_isoc_get_max_data_pkt_len(void);
724 
725 
726 /**@} wicedbt_isoc_functions */
727 
728 #ifdef __cplusplus
729 }
730 
731 #endif
732