1 /*
2  * Copyright 2020 HIMSA II K/S - www.himsa.com.
3  * Represented by EHIMA - www.ehima.com
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include "bt_types.h"
21 #include "hcimsgs.h"
22 
23 namespace bluetooth {
24 namespace hci {
25 namespace iso_manager {
26 
27 constexpr uint8_t kIsoDataPathDirectionIn = 0x00;
28 constexpr uint8_t kIsoDataPathDirectionOut = 0x01;
29 
30 constexpr uint8_t kIsoDataPathHci = 0x00;
31 constexpr uint8_t kIsoDataPathDisabled = 0xFF;
32 
33 constexpr uint8_t kIsoSca251To500Ppm = 0x00;
34 constexpr uint8_t kIsoSca151To250Ppm = 0x01;
35 constexpr uint8_t kIsoSca101To150Ppm = 0x02;
36 constexpr uint8_t kIsoSca76To100Ppm = 0x03;
37 constexpr uint8_t kIsoSca51To75Ppm = 0x04;
38 constexpr uint8_t kIsoSca31To50Ppm = 0x05;
39 constexpr uint8_t kIsoSca21To30Ppm = 0x06;
40 constexpr uint8_t kIsoSca0To20Ppm = 0x07;
41 
42 constexpr uint8_t kIsoEventCisDataAvailable = 0x00;
43 constexpr uint8_t kIsoEventCisEstablishCmpl = 0x01;
44 constexpr uint8_t kIsoEventCisDisconnected = 0x02;
45 
46 constexpr uint8_t kIsoEventCigOnCreateCmpl = 0x00;
47 constexpr uint8_t kIsoEventCigOnReconfigureCmpl = 0x01;
48 constexpr uint8_t kIsoEventCigOnRemoveCmpl = 0x02;
49 
50 constexpr uint8_t kIsoEventBigOnCreateCmpl = 0x00;
51 constexpr uint8_t kIsoEventBigOnTerminateCmpl = 0x01;
52 
53 struct cig_create_params {
54   uint32_t sdu_itv_mtos;
55   uint32_t sdu_itv_stom;
56   uint8_t sca;
57   uint8_t packing;
58   uint8_t framing;
59   uint16_t max_trans_lat_stom;
60   uint16_t max_trans_lat_mtos;
61   std::vector<EXT_CIS_CFG> cis_cfgs;
62 };
63 
64 struct cig_remove_cmpl_evt {
65   uint8_t status;
66   uint8_t cig_id;
67 };
68 
69 struct cig_create_cmpl_evt {
70   uint8_t status;
71   uint8_t cig_id;
72   std::vector<uint16_t> conn_handles;
73 };
74 
75 struct cis_data_evt {
76   uint8_t cig_id;
77   uint16_t cis_conn_hdl;
78   uint32_t ts;
79   uint16_t evt_lost;
80   BT_HDR* p_msg;
81 };
82 
83 struct cis_establish_params {
84   std::vector<EXT_CIS_CREATE_CFG> conn_pairs;
85 };
86 
87 struct cis_establish_cmpl_evt {
88   uint8_t status;
89   uint8_t cig_id;
90   uint16_t cis_conn_hdl;
91   uint32_t cig_sync_delay;
92   uint32_t cis_sync_delay;
93   uint32_t trans_lat_mtos;
94   uint32_t trans_lat_stom;
95   uint8_t phy_mtos;
96   uint8_t phy_stom;
97   uint8_t nse;
98   uint8_t bn_mtos;
99   uint8_t bn_stom;
100   uint8_t ft_mtos;
101   uint8_t ft_stom;
102   uint16_t max_pdu_mtos;
103   uint16_t max_pdu_stom;
104   uint16_t iso_itv;
105 };
106 
107 struct cis_disconnected_evt {
108   uint8_t reason;
109   uint8_t cig_id;
110   uint16_t cis_conn_hdl;
111 };
112 
113 struct big_create_params {
114   uint8_t adv_handle;
115   uint8_t num_bis;
116   uint32_t sdu_itv;
117   uint16_t max_sdu_size;
118   uint16_t max_transport_latency;
119   uint8_t rtn;
120   uint8_t phy;
121   uint8_t packing;
122   uint8_t framing;
123   uint8_t enc;
124   std::array<uint8_t, 16> enc_code;
125 };
126 
127 struct big_create_cmpl_evt {
128   uint8_t status;
129   uint8_t big_id;
130   uint32_t big_sync_delay;
131   uint32_t transport_latency_big;
132   uint8_t phy;
133   uint8_t nse;
134   uint8_t bn;
135   uint8_t pto;
136   uint8_t irc;
137   uint16_t max_pdu;
138   uint16_t iso_interval;
139   std::vector<uint16_t> conn_handles;
140 };
141 
142 struct big_terminate_cmpl_evt {
143   uint8_t big_id;
144   uint8_t reason;
145 };
146 
147 struct iso_data_path_params {
148   uint8_t data_path_dir;
149   uint8_t data_path_id;
150   uint8_t codec_id_format;
151   uint16_t codec_id_company;
152   uint16_t codec_id_vendor;
153   uint32_t controller_delay;
154   std::vector<uint8_t> codec_conf;
155 };
156 
157 }  // namespace iso_manager
158 }  // namespace hci
159 }  // namespace bluetooth
160