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 <cstdint>
21 
22 #include "hcimsgs.h"
23 #include "stack/include/bt_hdr.h"
24 
25 namespace bluetooth {
26 namespace hci {
27 constexpr uint8_t kIsoCodingFormatTransparent = 0x03;
28 constexpr uint8_t kIsoCodingFormatLc3 = 0x06;
29 constexpr uint8_t kIsoCodingFormatVendorSpecific = 0xFF;
30 
31 constexpr uint8_t kIsoCigPackingSequential = 0x00;
32 constexpr uint8_t kIsoCigPackingInterleaved = 0x01;
33 
34 constexpr uint8_t kIsoCigFramingUnframed = 0x00;
35 constexpr uint8_t kIsoCigFramingFramed = 0x01;
36 
37 constexpr uint8_t kIsoCigPhy1M = 0x01;
38 constexpr uint8_t kIsoCigPhy2M = 0x02;
39 constexpr uint8_t kIsoCigPhyC = 0x04;
40 
41 namespace iso_manager {
42 
43 constexpr uint8_t kIsoDataPathDirectionIn = 0x00;
44 constexpr uint8_t kIsoDataPathDirectionOut = 0x01;
45 
46 constexpr uint8_t kRemoveIsoDataPathDirectionInput = 0x01;
47 constexpr uint8_t kRemoveIsoDataPathDirectionOutput = 0x02;
48 
49 constexpr uint8_t kIsoDataPathHci = 0x00;
50 constexpr uint8_t kIsoDataPathPlatformDefault = 0x01;
51 constexpr uint8_t kIsoDataPathDisabled = 0xFF;
52 
53 constexpr uint8_t kIsoSca251To500Ppm = 0x00;
54 constexpr uint8_t kIsoSca151To250Ppm = 0x01;
55 constexpr uint8_t kIsoSca101To150Ppm = 0x02;
56 constexpr uint8_t kIsoSca76To100Ppm = 0x03;
57 constexpr uint8_t kIsoSca51To75Ppm = 0x04;
58 constexpr uint8_t kIsoSca31To50Ppm = 0x05;
59 constexpr uint8_t kIsoSca21To30Ppm = 0x06;
60 constexpr uint8_t kIsoSca0To20Ppm = 0x07;
61 
62 constexpr uint8_t kIsoEventCisDataAvailable = 0x00;
63 constexpr uint8_t kIsoEventCisEstablishCmpl = 0x01;
64 constexpr uint8_t kIsoEventCisDisconnected = 0x02;
65 
66 constexpr uint8_t kIsoEventCigOnCreateCmpl = 0x00;
67 constexpr uint8_t kIsoEventCigOnReconfigureCmpl = 0x01;
68 constexpr uint8_t kIsoEventCigOnRemoveCmpl = 0x02;
69 
70 constexpr uint8_t kIsoEventBigOnCreateCmpl = 0x00;
71 constexpr uint8_t kIsoEventBigOnTerminateCmpl = 0x01;
72 
73 struct cig_create_params {
74   uint32_t sdu_itv_mtos;
75   uint32_t sdu_itv_stom;
76   uint8_t sca;
77   uint8_t packing;
78   uint8_t framing;
79   uint16_t max_trans_lat_stom;
80   uint16_t max_trans_lat_mtos;
81   std::vector<EXT_CIS_CFG> cis_cfgs;
82 };
83 
84 struct cig_remove_cmpl_evt {
85   uint8_t status;
86   uint8_t cig_id;
87 };
88 
89 struct cig_create_cmpl_evt {
90   uint8_t status;
91   uint8_t cig_id;
92   std::vector<uint16_t> conn_handles;
93 };
94 
95 struct cis_data_evt {
96   uint8_t cig_id;
97   uint16_t cis_conn_hdl;
98   uint32_t ts;
99   uint16_t evt_lost;
100   uint16_t seq_nb;
101   BT_HDR* p_msg;
102 };
103 
104 struct cis_establish_params {
105   std::vector<EXT_CIS_CREATE_CFG> conn_pairs;
106 };
107 
108 struct cis_establish_cmpl_evt {
109   uint8_t status;
110   uint8_t cig_id;
111   uint16_t cis_conn_hdl;
112   uint32_t cig_sync_delay;
113   uint32_t cis_sync_delay;
114   uint32_t trans_lat_mtos;
115   uint32_t trans_lat_stom;
116   uint8_t phy_mtos;
117   uint8_t phy_stom;
118   uint8_t nse;
119   uint8_t bn_mtos;
120   uint8_t bn_stom;
121   uint8_t ft_mtos;
122   uint8_t ft_stom;
123   uint16_t max_pdu_mtos;
124   uint16_t max_pdu_stom;
125   uint16_t iso_itv;
126 };
127 
128 struct cis_disconnected_evt {
129   uint8_t reason;
130   uint8_t cig_id;
131   uint16_t cis_conn_hdl;
132 };
133 
134 struct big_create_params {
135   uint8_t adv_handle;
136   uint8_t num_bis;
137   uint32_t sdu_itv;
138   uint16_t max_sdu_size;
139   uint16_t max_transport_latency;
140   uint8_t rtn;
141   uint8_t phy;
142   uint8_t packing;
143   uint8_t framing;
144   uint8_t enc;
145   std::array<uint8_t, 16> enc_code;
146 };
147 
148 struct big_create_cmpl_evt {
149   uint8_t status;
150   uint8_t big_id;
151   uint32_t big_sync_delay;
152   uint32_t transport_latency_big;
153   uint8_t phy;
154   uint8_t nse;
155   uint8_t bn;
156   uint8_t pto;
157   uint8_t irc;
158   uint16_t max_pdu;
159   uint16_t iso_interval;
160   std::vector<uint16_t> conn_handles;
161 };
162 
163 struct big_terminate_cmpl_evt {
164   uint8_t big_id;
165   uint8_t reason;
166 };
167 
168 struct iso_data_path_params {
169   uint8_t data_path_dir;
170   uint8_t data_path_id;
171   uint8_t codec_id_format;
172   uint16_t codec_id_company;
173   uint16_t codec_id_vendor;
174   uint32_t controller_delay;
175   std::vector<uint8_t> codec_conf;
176 };
177 
178 }  // namespace iso_manager
179 }  // namespace hci
180 }  // namespace bluetooth
181