1 /******************************************************************************
2  *
3  *  Copyright 1999-2012 Broadcom Corporation
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 
19 #ifndef BT_TYPES_H
20 #define BT_TYPES_H
21 
22 #include <stdbool.h>
23 #include <stdint.h>
24 
25 #ifndef FALSE
26 #define FALSE false
27 #endif
28 
29 #ifndef TRUE
30 #define TRUE true
31 #endif
32 
33 #ifdef __arm
34 #define PACKED __packed
35 #define INLINE __inline
36 #else
37 #define PACKED
38 #define INLINE
39 #endif
40 
41 /* READ WELL !!
42  *
43  * This section defines global events. These are events that cross layers.
44  * Any event that passes between layers MUST be one of these events. Tasks
45  * can use their own events internally, but a FUNDAMENTAL design issue is
46  * that global events MUST be one of these events defined below.
47  *
48  * The convention used is the the event name contains the layer that the
49  * event is going to.
50  */
51 #define BT_EVT_MASK 0xFF00
52 #define BT_SUB_EVT_MASK 0x00FF
53 /* To Bluetooth Upper Layers        */
54 /************************************/
55 /* L2CAP event */
56 #define BT_EVT_TO_BTU_L2C_EVT 0x0900
57 /* HCI Event                        */
58 #define BT_EVT_TO_BTU_HCI_EVT 0x1000
59 /* event from BR/EDR controller */
60 #define BT_EVT_TO_BTU_HCI_BR_EDR_EVT (0x0000 | BT_EVT_TO_BTU_HCI_EVT)
61 /* event from local AMP 1 controller */
62 #define BT_EVT_TO_BTU_HCI_AMP1_EVT (0x0001 | BT_EVT_TO_BTU_HCI_EVT)
63 /* event from local AMP 2 controller */
64 #define BT_EVT_TO_BTU_HCI_AMP2_EVT (0x0002 | BT_EVT_TO_BTU_HCI_EVT)
65 /* event from local AMP 3 controller */
66 #define BT_EVT_TO_BTU_HCI_AMP3_EVT (0x0003 | BT_EVT_TO_BTU_HCI_EVT)
67 
68 /* ACL Data from HCI                */
69 #define BT_EVT_TO_BTU_HCI_ACL 0x1100
70 /* SCO Data from HCI                */
71 #define BT_EVT_TO_BTU_HCI_SCO 0x1200
72 /* HCI Transport Error              */
73 #define BT_EVT_TO_BTU_HCIT_ERR 0x1300
74 
75 /* Serial Port Event                */
76 #define BT_EVT_TO_BTU_SP_EVT 0x1400
77 /* Serial Port Data                 */
78 #define BT_EVT_TO_BTU_SP_DATA 0x1500
79 
80 /* HCI command from upper layer     */
81 #define BT_EVT_TO_BTU_HCI_CMD 0x1600
82 
83 /* ISO Data from HCI                */
84 #define BT_EVT_TO_BTU_HCI_ISO 0x1700
85 
86 /* L2CAP segment(s) transmitted     */
87 #define BT_EVT_TO_BTU_L2C_SEG_XMIT 0x1900
88 
89 /* BlueStackTester event: incoming message from target */
90 #define BT_EVT_PROXY_INCOMING_MSG 0x1A00
91 
92 /* Insight BTSIM event */
93 #define BT_EVT_BTSIM 0x1B00
94 /* Insight Script Engine event */
95 #define BT_EVT_BTISE 0x1C00
96 
97 /* To LM                            */
98 /************************************/
99 /* HCI Command                      */
100 #define BT_EVT_TO_LM_HCI_CMD 0x2000
101 /* HCI ACL Data                     */
102 #define BT_EVT_TO_LM_HCI_ACL 0x2100
103 /* HCI SCO Data                     */
104 #define BT_EVT_TO_LM_HCI_SCO 0x2200
105 /* HCI Transport Error              */
106 #define BT_EVT_TO_LM_HCIT_ERR 0x2300
107 /* LC event                         */
108 #define BT_EVT_TO_LM_LC_EVT 0x2400
109 /* LC Received LMP command frame    */
110 #define BT_EVT_TO_LM_LC_LMP 0x2500
111 /* LC Received ACL data             */
112 #define BT_EVT_TO_LM_LC_ACL 0x2600
113 /* LC Received SCO data  (not used) */
114 #define BT_EVT_TO_LM_LC_SCO 0x2700
115 /* LMP data transmit complete       */
116 #define BT_EVT_TO_LM_LC_ACL_TX 0x2800
117 /* LMP Command transmit complete    */
118 #define BT_EVT_TO_LM_LC_LMPC_TX 0x2900
119 /* Data to be locally loopbacked    */
120 #define BT_EVT_TO_LM_LOCAL_ACL_LB 0x2a00
121 /* HCI ACL Data ack      (not used) */
122 #define BT_EVT_TO_LM_HCI_ACL_ACK 0x2b00
123 /* LM Diagnostics commands          */
124 #define BT_EVT_TO_LM_DIAG 0x2c00
125 /* HCI ISO Data                     */
126 #define BT_EVT_TO_LM_HCI_ISO 0x2d00
127 
128 #define BT_EVT_TO_BTM_CMDS 0x2f00
129 #define BT_EVT_TO_BTM_PM_MDCHG_EVT (0x0001 | BT_EVT_TO_BTM_CMDS)
130 
131 #define BT_EVT_TO_TCS_CMDS 0x3000
132 
133 #define BT_EVT_TO_CTP_CMDS 0x3300
134 
135 /* ftp events */
136 #define BT_EVT_TO_FTP_SRVR_CMDS 0x3600
137 #define BT_EVT_TO_FTP_CLNT_CMDS 0x3700
138 
139 /* SIM Access Profile events */
140 #define BT_EVT_TO_BTU_SAP 0x3800
141 
142 /* opp events */
143 #define BT_EVT_TO_OPP_SRVR_CMDS 0x3900
144 #define BT_EVT_TO_OPP_CLNT_CMDS 0x3a00
145 
146 /* for NFC                          */
147 /************************************/
148 /* NCI Command, Notification or Data*/
149 #define BT_EVT_TO_NFC_NCI 0x4000
150 /* Initialization message */
151 #define BT_EVT_TO_NFC_INIT 0x4100
152 /* Low power */
153 #define BT_EVT_TO_NCI_LP 0x4200
154 /* Error notification to NFC Task */
155 #define BT_EVT_TO_NFC_ERR 0x4300
156 
157 /* events to NFCC simulation (NCI packets) */
158 #define BT_EVT_TO_NFCCSIM_NCI 0x4a00
159 
160 /* HCISU Events */
161 
162 #define BT_EVT_HCISU 0x5000
163 
164 #define BT_EVT_TO_HCISU_RECONFIG_EVT (0x0001 | BT_EVT_HCISU)
165 #define BT_EVT_TO_HCISU_UPDATE_BAUDRATE_EVT (0x0002 | BT_EVT_HCISU)
166 #define BT_EVT_TO_HCISU_LP_ENABLE_EVT (0x0003 | BT_EVT_HCISU)
167 #define BT_EVT_TO_HCISU_LP_DISABLE_EVT (0x0004 | BT_EVT_HCISU)
168 #define BT_EVT_TO_HCISU_LP_APP_SLEEPING_EVT (0x0005 | BT_EVT_HCISU)
169 #define BT_EVT_TO_HCISU_LP_ALLOW_BT_SLEEP_EVT (0x0006 | BT_EVT_HCISU)
170 #define BT_EVT_TO_HCISU_LP_WAKEUP_HOST_EVT (0x0007 | BT_EVT_HCISU)
171 #define BT_EVT_TO_HCISU_LP_RCV_H4IBSS_EVT (0x0008 | BT_EVT_HCISU)
172 #define BT_EVT_TO_HCISU_H5_RESET_EVT (0x0009 | BT_EVT_HCISU)
173 #define BT_EVT_HCISU_START_QUICK_TIMER (0x000a | BT_EVT_HCISU)
174 
175 #define BT_EVT_DATA_TO_AMP_1 0x5100
176 #define BT_EVT_DATA_TO_AMP_15 0x5f00
177 
178 /* HSP Events */
179 
180 #define BT_EVT_BTU_HSP2 0x6000
181 
182 #define BT_EVT_TO_BTU_HSP2_EVT (0x0001 | BT_EVT_BTU_HSP2)
183 
184 /* BPP Events */
185 #define BT_EVT_TO_BPP_PR_CMDS 0x6100  /* Printer Events */
186 #define BT_EVT_TO_BPP_SND_CMDS 0x6200 /* BPP Sender Events */
187 
188 /* BIP Events */
189 #define BT_EVT_TO_BIP_CMDS 0x6300
190 
191 /* HCRP Events */
192 
193 #define BT_EVT_BTU_HCRP 0x7000
194 
195 #define BT_EVT_TO_BTU_HCRP_EVT (0x0001 | BT_EVT_BTU_HCRP)
196 #define BT_EVT_TO_BTU_HCRPM_EVT (0x0002 | BT_EVT_BTU_HCRP)
197 
198 #define BT_EVT_BTU_HFP 0x8000
199 #define BT_EVT_TO_BTU_HFP_EVT (0x0001 | BT_EVT_BTU_HFP)
200 
201 #define BT_EVT_BTU_IPC_EVT 0x9000
202 #define BT_EVT_BTU_IPC_LOGMSG_EVT (0x0000 | BT_EVT_BTU_IPC_EVT)
203 #define BT_EVT_BTU_IPC_ACL_EVT (0x0001 | BT_EVT_BTU_IPC_EVT)
204 #define BT_EVT_BTU_IPC_BTU_EVT (0x0002 | BT_EVT_BTU_IPC_EVT)
205 #define BT_EVT_BTU_IPC_L2C_EVT (0x0003 | BT_EVT_BTU_IPC_EVT)
206 #define BT_EVT_BTU_IPC_L2C_MSG_EVT (0x0004 | BT_EVT_BTU_IPC_EVT)
207 #define BT_EVT_BTU_IPC_BTM_EVT (0x0005 | BT_EVT_BTU_IPC_EVT)
208 #define BT_EVT_BTU_IPC_AVDT_EVT (0x0006 | BT_EVT_BTU_IPC_EVT)
209 #define BT_EVT_BTU_IPC_SLIP_EVT (0x0007 | BT_EVT_BTU_IPC_EVT)
210 #define BT_EVT_BTU_IPC_MGMT_EVT (0x0008 | BT_EVT_BTU_IPC_EVT)
211 #define BT_EVT_BTU_IPC_BTTRC_EVT (0x0009 | BT_EVT_BTU_IPC_EVT)
212 #define BT_EVT_BTU_IPC_BURST_EVT (0x000A | BT_EVT_BTU_IPC_EVT)
213 
214 /* BTIF Events */
215 #define BT_EVT_BTIF 0xA000
216 #define BT_EVT_CONTEXT_SWITCH_EVT (0x0001 | BT_EVT_BTIF)
217 
218 /* Define the header of each buffer used in the Bluetooth stack.
219  */
220 typedef struct {
221   uint16_t event;
222   uint16_t len;
223   uint16_t offset;
224   uint16_t layer_specific;
225   uint8_t data[];
226 } BT_HDR;
227 
228 #define BT_HDR_SIZE (sizeof(BT_HDR))
229 
230 #define BT_PSM_SDP 0x0001
231 #define BT_PSM_RFCOMM 0x0003
232 #define BT_PSM_TCS 0x0005
233 #define BT_PSM_CTP 0x0007
234 #define BT_PSM_BNEP 0x000F
235 #define BT_PSM_HIDC 0x0011
236 #define BT_PSM_HIDI 0x0013
237 #define BT_PSM_UPNP 0x0015
238 #define BT_PSM_AVCTP 0x0017
239 #define BT_PSM_AVDTP 0x0019
240 #define BT_PSM_AVCTP_13 0x001B /* Advanced Control - Browsing */
241 #define BT_PSM_UDI_CP \
242   0x001D /* Unrestricted Digital Information Profile C-Plane  */
243 #define BT_PSM_ATT 0x001F /* Attribute Protocol  */
244 
245 /* These macros extract the HCI opcodes from a buffer
246  */
247 #define HCI_GET_CMD_HDR_OPCODE(p)                    \
248   (uint16_t)((*((uint8_t*)((p) + 1) + (p)->offset) + \
249               (*((uint8_t*)((p) + 1) + (p)->offset + 1) << 8)))
250 #define HCI_GET_CMD_HDR_PARAM_LEN(p) \
251   (uint8_t)(*((uint8_t*)((p) + 1) + (p)->offset + 2))
252 
253 #define HCI_GET_EVT_HDR_OPCODE(p) \
254   (uint8_t)(*((uint8_t*)((p) + 1) + (p)->offset))
255 #define HCI_GET_EVT_HDR_PARAM_LEN(p) \
256   (uint8_t)(*((uint8_t*)((p) + 1) + (p)->offset + 1))
257 
258 /*******************************************************************************
259  * Macros to get and put bytes to and from a stream (Little Endian format).
260  */
261 #define UINT64_TO_BE_STREAM(p, u64)  \
262   {                                  \
263     *(p)++ = (uint8_t)((u64) >> 56); \
264     *(p)++ = (uint8_t)((u64) >> 48); \
265     *(p)++ = (uint8_t)((u64) >> 40); \
266     *(p)++ = (uint8_t)((u64) >> 32); \
267     *(p)++ = (uint8_t)((u64) >> 24); \
268     *(p)++ = (uint8_t)((u64) >> 16); \
269     *(p)++ = (uint8_t)((u64) >> 8);  \
270     *(p)++ = (uint8_t)(u64);         \
271   }
272 #define UINT32_TO_STREAM(p, u32)     \
273   {                                  \
274     *(p)++ = (uint8_t)(u32);         \
275     *(p)++ = (uint8_t)((u32) >> 8);  \
276     *(p)++ = (uint8_t)((u32) >> 16); \
277     *(p)++ = (uint8_t)((u32) >> 24); \
278   }
279 #define UINT24_TO_STREAM(p, u24)     \
280   {                                  \
281     *(p)++ = (uint8_t)(u24);         \
282     *(p)++ = (uint8_t)((u24) >> 8);  \
283     *(p)++ = (uint8_t)((u24) >> 16); \
284   }
285 #define UINT16_TO_STREAM(p, u16)    \
286   {                                 \
287     *(p)++ = (uint8_t)(u16);        \
288     *(p)++ = (uint8_t)((u16) >> 8); \
289   }
290 #define UINT8_TO_STREAM(p, u8) \
291   { *(p)++ = (uint8_t)(u8); }
292 #define INT8_TO_STREAM(p, u8) \
293   { *(p)++ = (int8_t)(u8); }
294 #define ARRAY32_TO_STREAM(p, a)                                     \
295   {                                                                 \
296     int ijk;                                                        \
297     for (ijk = 0; ijk < 32; ijk++) *(p)++ = (uint8_t)(a)[31 - ijk]; \
298   }
299 #define ARRAY16_TO_STREAM(p, a)                                     \
300   {                                                                 \
301     int ijk;                                                        \
302     for (ijk = 0; ijk < 16; ijk++) *(p)++ = (uint8_t)(a)[15 - ijk]; \
303   }
304 #define ARRAY8_TO_STREAM(p, a)                                    \
305   {                                                               \
306     int ijk;                                                      \
307     for (ijk = 0; ijk < 8; ijk++) *(p)++ = (uint8_t)(a)[7 - ijk]; \
308   }
309 #define LAP_TO_STREAM(p, a)                     \
310   {                                             \
311     int ijk;                                    \
312     for (ijk = 0; ijk < LAP_LEN; ijk++)         \
313       *(p)++ = (uint8_t)(a)[LAP_LEN - 1 - ijk]; \
314   }
315 #define DEVCLASS_TO_STREAM(p, a)                      \
316   {                                                   \
317     int ijk;                                          \
318     for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++)         \
319       *(p)++ = (uint8_t)(a)[DEV_CLASS_LEN - 1 - ijk]; \
320   }
321 #define ARRAY_TO_STREAM(p, a, len)                                \
322   {                                                               \
323     int ijk;                                                      \
324     for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[ijk]; \
325   }
326 #define REVERSE_ARRAY_TO_STREAM(p, a, len)                                  \
327   {                                                                         \
328     int ijk;                                                                \
329     for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[(len)-1 - ijk]; \
330   }
331 
332 #define STREAM_TO_INT8(u8, p)   \
333   {                             \
334     (u8) = (*((int8_t*)(p)));   \
335     (p) += 1;                   \
336   }
337 #define STREAM_TO_UINT8(u8, p) \
338   {                            \
339     (u8) = (uint8_t)(*(p));    \
340     (p) += 1;                  \
341   }
342 #define STREAM_TO_UINT16(u16, p)                                  \
343   {                                                               \
344     (u16) = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); \
345     (p) += 2;                                                     \
346   }
347 #define STREAM_TO_UINT24(u32, p)                                      \
348   {                                                                   \
349     (u32) = (((uint32_t)(*(p))) + ((((uint32_t)(*((p) + 1)))) << 8) + \
350              ((((uint32_t)(*((p) + 2)))) << 16));                     \
351     (p) += 3;                                                         \
352   }
353 #define STREAM_TO_UINT32(u32, p)                                      \
354   {                                                                   \
355     (u32) = (((uint32_t)(*(p))) + ((((uint32_t)(*((p) + 1)))) << 8) + \
356              ((((uint32_t)(*((p) + 2)))) << 16) +                     \
357              ((((uint32_t)(*((p) + 3)))) << 24));                     \
358     (p) += 4;                                                         \
359   }
360 #define STREAM_TO_UINT64(u64, p)                                      \
361   {                                                                   \
362     (u64) = (((uint64_t)(*(p))) + ((((uint64_t)(*((p) + 1)))) << 8) + \
363              ((((uint64_t)(*((p) + 2)))) << 16) +                     \
364              ((((uint64_t)(*((p) + 3)))) << 24) +                     \
365              ((((uint64_t)(*((p) + 4)))) << 32) +                     \
366              ((((uint64_t)(*((p) + 5)))) << 40) +                     \
367              ((((uint64_t)(*((p) + 6)))) << 48) +                     \
368              ((((uint64_t)(*((p) + 7)))) << 56));                     \
369     (p) += 8;                                                         \
370   }
371 #define STREAM_TO_ARRAY32(a, p)                     \
372   {                                                 \
373     int ijk;                                        \
374     uint8_t* _pa = (uint8_t*)(a) + 31;              \
375     for (ijk = 0; ijk < 32; ijk++) *_pa-- = *(p)++; \
376   }
377 #define STREAM_TO_ARRAY16(a, p)                     \
378   {                                                 \
379     int ijk;                                        \
380     uint8_t* _pa = (uint8_t*)(a) + 15;              \
381     for (ijk = 0; ijk < 16; ijk++) *_pa-- = *(p)++; \
382   }
383 #define STREAM_TO_ARRAY8(a, p)                     \
384   {                                                \
385     int ijk;                                       \
386     uint8_t* _pa = (uint8_t*)(a) + 7;              \
387     for (ijk = 0; ijk < 8; ijk++) *_pa-- = *(p)++; \
388   }
389 #define STREAM_TO_DEVCLASS(a, p)                               \
390   {                                                            \
391     int ijk;                                                   \
392     uint8_t* _pa = (uint8_t*)(a) + DEV_CLASS_LEN - 1;          \
393     for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) *_pa-- = *(p)++; \
394   }
395 #define STREAM_TO_LAP(a, p)                               \
396   {                                                       \
397     int ijk;                                              \
398     uint8_t* plap = (uint8_t*)(a) + LAP_LEN - 1;          \
399     for (ijk = 0; ijk < LAP_LEN; ijk++) *plap-- = *(p)++; \
400   }
401 #define STREAM_TO_ARRAY(a, p, len)                                   \
402   {                                                                  \
403     int ijk;                                                         \
404     for (ijk = 0; ijk < (len); ijk++) ((uint8_t*)(a))[ijk] = *(p)++; \
405   }
406 #define REVERSE_STREAM_TO_ARRAY(a, p, len)             \
407   {                                                    \
408     int ijk;                                           \
409     uint8_t* _pa = (uint8_t*)(a) + (len)-1;            \
410     for (ijk = 0; ijk < (len); ijk++) *_pa-- = *(p)++; \
411   }
412 
413 #define STREAM_SKIP_UINT8(p) \
414   do {                       \
415     (p) += 1;                \
416   } while (0)
417 #define STREAM_SKIP_UINT16(p) \
418   do {                        \
419     (p) += 2;                 \
420   } while (0)
421 
422 /*******************************************************************************
423  * Macros to get and put bytes to and from a field (Little Endian format).
424  * These are the same as to stream, except the pointer is not incremented.
425  */
426 #define UINT32_TO_FIELD(p, u32)                    \
427   {                                                \
428     *(uint8_t*)(p) = (uint8_t)(u32);               \
429     *((uint8_t*)(p) + 1) = (uint8_t)((u32) >> 8);  \
430     *((uint8_t*)(p) + 2) = (uint8_t)((u32) >> 16); \
431     *((uint8_t*)(p) + 3) = (uint8_t)((u32) >> 24); \
432   }
433 #define UINT24_TO_FIELD(p, u24)                    \
434   {                                                \
435     *(uint8_t*)(p) = (uint8_t)(u24);               \
436     *((uint8_t*)(p) + 1) = (uint8_t)((u24) >> 8);  \
437     *((uint8_t*)(p) + 2) = (uint8_t)((u24) >> 16); \
438   }
439 #define UINT16_TO_FIELD(p, u16)                   \
440   {                                               \
441     *(uint8_t*)(p) = (uint8_t)(u16);              \
442     *((uint8_t*)(p) + 1) = (uint8_t)((u16) >> 8); \
443   }
444 #define UINT8_TO_FIELD(p, u8) \
445   { *(uint8_t*)(p) = (uint8_t)(u8); }
446 
447 /*******************************************************************************
448  * Macros to get and put bytes to and from a stream (Big Endian format)
449  */
450 #define UINT32_TO_BE_STREAM(p, u32)  \
451   {                                  \
452     *(p)++ = (uint8_t)((u32) >> 24); \
453     *(p)++ = (uint8_t)((u32) >> 16); \
454     *(p)++ = (uint8_t)((u32) >> 8);  \
455     *(p)++ = (uint8_t)(u32);         \
456   }
457 #define UINT24_TO_BE_STREAM(p, u24)  \
458   {                                  \
459     *(p)++ = (uint8_t)((u24) >> 16); \
460     *(p)++ = (uint8_t)((u24) >> 8);  \
461     *(p)++ = (uint8_t)(u24);         \
462   }
463 #define UINT16_TO_BE_STREAM(p, u16) \
464   {                                 \
465     *(p)++ = (uint8_t)((u16) >> 8); \
466     *(p)++ = (uint8_t)(u16);        \
467   }
468 #define UINT8_TO_BE_STREAM(p, u8) \
469   { *(p)++ = (uint8_t)(u8); }
470 #define ARRAY_TO_BE_STREAM(p, a, len)                             \
471   {                                                               \
472     int ijk;                                                      \
473     for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[ijk]; \
474   }
475 #define ARRAY_TO_BE_STREAM_REVERSE(p, a, len)                               \
476   {                                                                         \
477     int ijk;                                                                \
478     for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[(len)-ijk - 1]; \
479   }
480 
481 #define BE_STREAM_TO_UINT8(u8, p) \
482   {                               \
483     (u8) = (uint8_t)(*(p));       \
484     (p) += 1;                     \
485   }
486 #define BE_STREAM_TO_UINT16(u16, p)                                       \
487   {                                                                       \
488     (u16) = (uint16_t)(((uint16_t)(*(p)) << 8) + (uint16_t)(*((p) + 1))); \
489     (p) += 2;                                                             \
490   }
491 #define BE_STREAM_TO_UINT24(u32, p)                                     \
492   {                                                                     \
493     (u32) = (((uint32_t)(*((p) + 2))) + ((uint32_t)(*((p) + 1)) << 8) + \
494              ((uint32_t)(*(p)) << 16));                                 \
495     (p) += 3;                                                           \
496   }
497 #define BE_STREAM_TO_UINT32(u32, p)                                      \
498   {                                                                      \
499     (u32) = ((uint32_t)(*((p) + 3)) + ((uint32_t)(*((p) + 2)) << 8) +    \
500              ((uint32_t)(*((p) + 1)) << 16) + ((uint32_t)(*(p)) << 24)); \
501     (p) += 4;                                                            \
502   }
503 #define BE_STREAM_TO_UINT64(u64, p)                                            \
504   {                                                                            \
505     (u64) = ((uint64_t)(*((p) + 7)) + ((uint64_t)(*((p) + 6)) << 8) +          \
506              ((uint64_t)(*((p) + 5)) << 16) + ((uint64_t)(*((p) + 4)) << 24) + \
507              ((uint64_t)(*((p) + 3)) << 32) + ((uint64_t)(*((p) + 2)) << 40) + \
508              ((uint64_t)(*((p) + 1)) << 48) + ((uint64_t)(*(p)) << 56));       \
509     (p) += 8;                                                                  \
510   }
511 #define BE_STREAM_TO_ARRAY(p, a, len)                                \
512   {                                                                  \
513     int ijk;                                                         \
514     for (ijk = 0; ijk < (len); ijk++) ((uint8_t*)(a))[ijk] = *(p)++; \
515   }
516 
517 /*******************************************************************************
518  * Macros to get and put bytes to and from a field (Big Endian format).
519  * These are the same as to stream, except the pointer is not incremented.
520  */
521 #define UINT32_TO_BE_FIELD(p, u32)                 \
522   {                                                \
523     *(uint8_t*)(p) = (uint8_t)((u32) >> 24);       \
524     *((uint8_t*)(p) + 1) = (uint8_t)((u32) >> 16); \
525     *((uint8_t*)(p) + 2) = (uint8_t)((u32) >> 8);  \
526     *((uint8_t*)(p) + 3) = (uint8_t)(u32);         \
527   }
528 #define UINT24_TO_BE_FIELD(p, u24)                \
529   {                                               \
530     *(uint8_t*)(p) = (uint8_t)((u24) >> 16);      \
531     *((uint8_t*)(p) + 1) = (uint8_t)((u24) >> 8); \
532     *((uint8_t*)(p) + 2) = (uint8_t)(u24);        \
533   }
534 #define UINT16_TO_BE_FIELD(p, u16)          \
535   {                                         \
536     *(uint8_t*)(p) = (uint8_t)((u16) >> 8); \
537     *((uint8_t*)(p) + 1) = (uint8_t)(u16);  \
538   }
539 #define UINT8_TO_BE_FIELD(p, u8) \
540   { *(uint8_t*)(p) = (uint8_t)(u8); }
541 
542 /* Common Bluetooth field definitions */
543 #define BD_ADDR_LEN 6 /* Device address length */
544 
545 #ifdef __cplusplus
546 #include <bluetooth/uuid.h>
547 #include <include/hardware/bluetooth.h>
548 
BDADDR_TO_STREAM(uint8_t * & p,const RawAddress & a)549 inline void BDADDR_TO_STREAM(uint8_t*& p, const RawAddress& a) {
550   for (int ijk = 0; ijk < BD_ADDR_LEN; ijk++)
551     *(p)++ = (uint8_t)(a.address)[BD_ADDR_LEN - 1 - ijk];
552 }
553 
STREAM_TO_BDADDR(RawAddress & a,uint8_t * & p)554 inline void STREAM_TO_BDADDR(RawAddress& a, uint8_t*& p) {
555   uint8_t* pbda = (uint8_t*)(a.address) + BD_ADDR_LEN - 1;
556   for (int ijk = 0; ijk < BD_ADDR_LEN; ijk++) *pbda-- = *(p)++;
557 }
558 
559 #endif
560 
561 #define AMP_KEY_TYPE_GAMP 0
562 #define AMP_KEY_TYPE_WIFI 1
563 #define AMP_KEY_TYPE_UWB 2
564 typedef uint8_t tAMP_KEY_TYPE;
565 
566 #define BT_OCTET8_LEN 8
567 typedef uint8_t BT_OCTET8[BT_OCTET8_LEN]; /* octet array: size 16 */
568 
569 #define AMP_LINK_KEY_LEN 32
570 typedef uint8_t
571     AMP_LINK_KEY[AMP_LINK_KEY_LEN]; /* Dedicated AMP and GAMP Link Keys */
572 
573 /* Some C files include this header file */
574 #ifdef __cplusplus
575 
576 #include <array>
577 
578 constexpr int OCTET16_LEN = 16;
579 typedef std::array<uint8_t, OCTET16_LEN> Octet16;
580 
581 constexpr int LINK_KEY_LEN = OCTET16_LEN;
582 typedef Octet16 LinkKey; /* Link Key */
583 
584 /* Sample LTK from BT Spec 5.1 | Vol 6, Part C 1
585  * 0x4C68384139F574D836BCF34E9DFB01BF */
586 constexpr Octet16 SAMPLE_LTK = {0xbf, 0x01, 0xfb, 0x9d, 0x4e, 0xf3, 0xbc, 0x36,
587                                 0xd8, 0x74, 0xf5, 0x39, 0x41, 0x38, 0x68, 0x4c};
is_sample_ltk(const Octet16 & ltk)588 inline bool is_sample_ltk(const Octet16& ltk) {
589   return ltk == SAMPLE_LTK;
590 }
591 
592 #endif
593 
594 #define PIN_CODE_LEN 16
595 typedef uint8_t PIN_CODE[PIN_CODE_LEN]; /* Pin Code (upto 128 bits) MSB is 0 */
596 typedef uint8_t* PIN_CODE_PTR;          /* Pointer to Pin Code */
597 
598 #define BT_OCTET32_LEN 32
599 typedef uint8_t BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */
600 
601 #define DEV_CLASS_LEN 3
602 typedef uint8_t DEV_CLASS[DEV_CLASS_LEN]; /* Device class */
603 typedef uint8_t* DEV_CLASS_PTR;           /* Pointer to Device class */
604 
605 #define EXT_INQ_RESP_LEN 3
606 typedef uint8_t EXT_INQ_RESP[EXT_INQ_RESP_LEN]; /* Extended Inquiry Response */
607 typedef uint8_t* EXT_INQ_RESP_PTR; /* Pointer to Extended Inquiry Response */
608 
609 #define BD_NAME_LEN 248
610 typedef uint8_t BD_NAME[BD_NAME_LEN + 1]; /* Device name */
611 typedef uint8_t* BD_NAME_PTR;             /* Pointer to Device name */
612 
613 #define BD_FEATURES_LEN 8
614 typedef uint8_t
615     BD_FEATURES[BD_FEATURES_LEN]; /* LMP features supported by device */
616 
617 #define BT_EVENT_MASK_LEN 8
618 typedef uint8_t BT_EVENT_MASK[BT_EVENT_MASK_LEN]; /* Event Mask */
619 
620 #define LAP_LEN 3
621 typedef uint8_t LAP[LAP_LEN];     /* IAC as passed to Inquiry (LAP) */
622 typedef uint8_t INQ_LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
623 
624 #define RAND_NUM_LEN 16
625 typedef uint8_t RAND_NUM[RAND_NUM_LEN];
626 
627 #define ACO_LEN 12
628 typedef uint8_t ACO[ACO_LEN]; /* Authenticated ciphering offset */
629 
630 #define COF_LEN 12
631 typedef uint8_t COF[COF_LEN]; /* ciphering offset number */
632 
633 typedef struct {
634   uint8_t qos_flags;          /* TBD */
635   uint8_t service_type;       /* see below */
636   uint32_t token_rate;        /* bytes/second */
637   uint32_t token_bucket_size; /* bytes */
638   uint32_t peak_bandwidth;    /* bytes/second */
639   uint32_t latency;           /* microseconds */
640   uint32_t delay_variation;   /* microseconds */
641 } FLOW_SPEC;
642 
643 /* Values for service_type */
644 #define SVC_TYPE_NO_TRAFFIC 0
645 #define SVC_TYPE_BEST_EFFORT 1
646 #define SVC_TYPE_GUARANTEED 2
647 
648 /* Service class of the CoD */
649 #define SERV_CLASS_NETWORKING (1 << 1)
650 #define SERV_CLASS_RENDERING (1 << 2)
651 #define SERV_CLASS_CAPTURING (1 << 3)
652 #define SERV_CLASS_OBJECT_TRANSFER (1 << 4)
653 #define SERV_CLASS_OBJECT_AUDIO (1 << 5)
654 #define SERV_CLASS_OBJECT_TELEPHONY (1 << 6)
655 #define SERV_CLASS_OBJECT_INFORMATION (1 << 7)
656 
657 /* Second byte */
658 #define SERV_CLASS_LIMITED_DISC_MODE (0x20)
659 
660 /* Field size definitions. Note that byte lengths are rounded up. */
661 #define ACCESS_CODE_BIT_LEN 72
662 #define ACCESS_CODE_BYTE_LEN 9
663 #define SHORTENED_ACCESS_CODE_BIT_LEN 68
664 
665 typedef uint8_t ACCESS_CODE[ACCESS_CODE_BYTE_LEN];
666 
667 #define SYNTH_TX 1 /* want synth code to TRANSMIT at this freq */
668 #define SYNTH_RX 2 /* want synth code to RECEIVE at this freq */
669 
670 #define SYNC_REPS 1 /* repeats of sync word transmitted to start of burst */
671 
672 #define BT_1SEC_TIMEOUT_MS (1 * 1000) /* 1 second */
673 
674 #define BT_EIR_FLAGS_TYPE 0x01
675 #define BT_EIR_MORE_16BITS_UUID_TYPE 0x02
676 #define BT_EIR_COMPLETE_16BITS_UUID_TYPE 0x03
677 #define BT_EIR_MORE_32BITS_UUID_TYPE 0x04
678 #define BT_EIR_COMPLETE_32BITS_UUID_TYPE 0x05
679 #define BT_EIR_MORE_128BITS_UUID_TYPE 0x06
680 #define BT_EIR_COMPLETE_128BITS_UUID_TYPE 0x07
681 #define BT_EIR_SHORTENED_LOCAL_NAME_TYPE 0x08
682 #define BT_EIR_COMPLETE_LOCAL_NAME_TYPE 0x09
683 #define BT_EIR_TX_POWER_LEVEL_TYPE 0x0A
684 #define BT_EIR_OOB_BD_ADDR_TYPE 0x0C
685 #define BT_EIR_OOB_COD_TYPE 0x0D
686 #define BT_EIR_OOB_SSP_HASH_C_TYPE 0x0E
687 #define BT_EIR_OOB_SSP_RAND_R_TYPE 0x0F
688 #define BT_EIR_SERVICE_DATA_TYPE 0x16
689 #define BT_EIR_SERVICE_DATA_16BITS_UUID_TYPE 0x16
690 #define BT_EIR_SERVICE_DATA_32BITS_UUID_TYPE 0x20
691 #define BT_EIR_SERVICE_DATA_128BITS_UUID_TYPE 0x21
692 #define BT_EIR_MANUFACTURER_SPECIFIC_TYPE 0xFF
693 
694 #define BT_OOB_COD_SIZE 3
695 #define BT_OOB_HASH_C_SIZE 16
696 #define BT_OOB_RAND_R_SIZE 16
697 
698 /* Broadcom proprietary UUIDs and reserved PSMs
699  *
700  * The lowest 4 bytes byte of the UUID or GUID depend on the feature. Typically,
701  * the value of those bytes will be the PSM or SCN.
702  */
703 #define BRCM_PROPRIETARY_UUID_BASE \
704   0xDA, 0x23, 0x41, 0x02, 0xA3, 0xBB, 0xC1, 0x71, 0xBA, 0x09, 0x6f, 0x21
705 #define BRCM_PROPRIETARY_GUID_BASE \
706   0xda23, 0x4102, 0xa3, 0xbb, 0xc1, 0x71, 0xba, 0x09, 0x6f, 0x21
707 
708 /* We will not allocate a PSM in the reserved range to 3rd party apps
709  */
710 #define BRCM_RESERVED_PSM_START 0x5AE1
711 #define BRCM_RESERVED_PSM_END 0x5AFF
712 
713 #define BRCM_UTILITY_SERVICE_PSM 0x5AE1
714 #define BRCM_MATCHER_PSM 0x5AE3
715 
716 /* Connection statistics
717  */
718 
719 /* Structure to hold connection stats */
720 #ifndef BT_CONN_STATS_DEFINED
721 #define BT_CONN_STATS_DEFINED
722 
723 /* These bits are used in the bIsConnected field */
724 #define BT_CONNECTED_USING_BREDR 1
725 #define BT_CONNECTED_USING_AMP 2
726 
727 typedef struct {
728   uint32_t is_connected;
729   int32_t rssi;
730   uint32_t bytes_sent;
731   uint32_t bytes_rcvd;
732   uint32_t duration;
733 } tBT_CONN_STATS;
734 
735 #endif
736 
737 /*****************************************************************************
738  *                          Low Energy definitions
739  *
740  * Address types
741  */
742 #define BLE_ADDR_PUBLIC 0x00
743 #define BLE_ADDR_RANDOM 0x01
744 #define BLE_ADDR_PUBLIC_ID 0x02
745 #define BLE_ADDR_RANDOM_ID 0x03
746 #define BLE_ADDR_ANONYMOUS 0xFF
747 typedef uint8_t tBLE_ADDR_TYPE;
748 #define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC)
749 
750 #define BT_TRANSPORT_INVALID 0
751 #define BT_TRANSPORT_BR_EDR 1
752 #define BT_TRANSPORT_LE 2
753 typedef uint8_t tBT_TRANSPORT;
754 
755 #define PHY_LE_1M_MASK 1
756 #define PHY_LE_2M_MASK 2
757 #define PHY_LE_CODED_MASK 4
758 
759 #define BLE_ADDR_IS_STATIC(x) (((x)[0] & 0xC0) == 0xC0)
760 
761 #ifdef __cplusplus
762 struct tBLE_BD_ADDR {
763   tBLE_ADDR_TYPE type;
764   RawAddress bda;
765 };
766 #endif
767 
768 /* Device Types
769  */
770 #define BT_DEVICE_TYPE_BREDR 0x01
771 #define BT_DEVICE_TYPE_BLE 0x02
772 #define BT_DEVICE_TYPE_DUMO 0x03
773 typedef uint8_t tBT_DEVICE_TYPE;
774 /*****************************************************************************/
775 
776 /* Define trace levels */
777 #define BT_TRACE_LEVEL_NONE 0    /* No trace messages to be generated    */
778 #define BT_TRACE_LEVEL_ERROR 1   /* Error condition trace messages       */
779 #define BT_TRACE_LEVEL_WARNING 2 /* Warning condition trace messages     */
780 #define BT_TRACE_LEVEL_API 3     /* API traces                           */
781 #define BT_TRACE_LEVEL_EVENT 4   /* Debug messages for events            */
782 #define BT_TRACE_LEVEL_DEBUG 5   /* Full debug messages                  */
783 #define BT_TRACE_LEVEL_VERBOSE 6 /* Verbose debug messages               */
784 
785 #define MAX_TRACE_LEVEL 6
786 
787 /* Define New Trace Type Definition */
788 /* TRACE_CTRL_TYPE                  0x^^000000*/
789 #define TRACE_CTRL_MASK 0xff000000
790 #define TRACE_GET_CTRL(x) ((((uint32_t)(x)) & TRACE_CTRL_MASK) >> 24)
791 
792 #define TRACE_CTRL_GENERAL 0x00000000
793 #define TRACE_CTRL_STR_RESOURCE 0x01000000
794 #define TRACE_CTRL_SEQ_FLOW 0x02000000
795 #define TRACE_CTRL_MAX_NUM 3
796 
797 /* LAYER SPECIFIC                   0x00^^0000*/
798 #define TRACE_LAYER_MASK 0x00ff0000
799 #define TRACE_GET_LAYER(x) ((((uint32_t)(x)) & TRACE_LAYER_MASK) >> 16)
800 
801 #define TRACE_LAYER_NONE 0x00000000
802 #define TRACE_LAYER_USB 0x00010000
803 #define TRACE_LAYER_SERIAL 0x00020000
804 #define TRACE_LAYER_SOCKET 0x00030000
805 #define TRACE_LAYER_RS232 0x00040000
806 #define TRACE_LAYER_TRANS_MAX_NUM 5
807 #define TRACE_LAYER_TRANS_ALL 0x007f0000
808 #define TRACE_LAYER_LC 0x00050000
809 #define TRACE_LAYER_LM 0x00060000
810 #define TRACE_LAYER_HCI 0x00070000
811 #define TRACE_LAYER_L2CAP 0x00080000
812 #define TRACE_LAYER_RFCOMM 0x00090000
813 #define TRACE_LAYER_SDP 0x000a0000
814 #define TRACE_LAYER_TCS 0x000b0000
815 #define TRACE_LAYER_OBEX 0x000c0000
816 #define TRACE_LAYER_BTM 0x000d0000
817 #define TRACE_LAYER_ICP 0x00110000
818 #define TRACE_LAYER_HSP2 0x00120000
819 #define TRACE_LAYER_SPP 0x00130000
820 #define TRACE_LAYER_CTP 0x00140000
821 #define TRACE_LAYER_BPP 0x00150000
822 #define TRACE_LAYER_HCRP 0x00160000
823 #define TRACE_LAYER_FTP 0x00170000
824 #define TRACE_LAYER_OPP 0x00180000
825 #define TRACE_LAYER_BTU 0x00190000
826 #define TRACE_LAYER_GKI 0x001a0000 /* OBSOLETED */
827 #define TRACE_LAYER_BNEP 0x001b0000
828 #define TRACE_LAYER_PAN 0x001c0000
829 #define TRACE_LAYER_HFP 0x001d0000
830 #define TRACE_LAYER_HID 0x001e0000
831 #define TRACE_LAYER_BIP 0x001f0000
832 #define TRACE_LAYER_AVP 0x00200000
833 #define TRACE_LAYER_A2DP 0x00210000
834 #define TRACE_LAYER_SAP 0x00220000
835 #define TRACE_LAYER_AMP 0x00230000
836 #define TRACE_LAYER_MCA 0x00240000 /* OBSOLETED */
837 #define TRACE_LAYER_ATT 0x00250000
838 #define TRACE_LAYER_SMP 0x00260000
839 #define TRACE_LAYER_NFC 0x00270000
840 #define TRACE_LAYER_NCI 0x00280000
841 #define TRACE_LAYER_LLCP 0x00290000
842 #define TRACE_LAYER_NDEF 0x002a0000
843 #define TRACE_LAYER_RW 0x002b0000
844 #define TRACE_LAYER_CE 0x002c0000
845 #define TRACE_LAYER_P2P 0x002d0000
846 #define TRACE_LAYER_SNEP 0x002e0000
847 #define TRACE_LAYER_CHO 0x002f0000
848 #define TRACE_LAYER_NFA 0x00300000
849 
850 #define TRACE_LAYER_MAX_NUM 0x0031
851 
852 /* TRACE_ORIGINATOR                 0x0000^^00*/
853 #define TRACE_ORG_MASK 0x0000ff00
854 #define TRACE_GET_ORG(x) ((((uint32_t)(x)) & TRACE_ORG_MASK) >> 8)
855 
856 #define TRACE_ORG_STACK 0x00000000
857 #define TRACE_ORG_HCI_TRANS 0x00000100
858 #define TRACE_ORG_PROTO_DISP 0x00000200
859 #define TRACE_ORG_RPC 0x00000300
860 #define TRACE_ORG_GKI 0x00000400 /* OBSOLETED */
861 #define TRACE_ORG_APPL 0x00000500
862 #define TRACE_ORG_SCR_WRAPPER 0x00000600
863 #define TRACE_ORG_SCR_ENGINE 0x00000700
864 #define TRACE_ORG_USER_SCR 0x00000800
865 #define TRACE_ORG_TESTER 0x00000900
866 #define TRACE_ORG_MAX_NUM 10 /* 32-bit mask; must be < 32 */
867 #define TRACE_LITE_ORG_MAX_NUM 6
868 #define TRACE_ORG_ALL 0x03ff
869 #define TRACE_ORG_RPC_TRANS 0x04
870 
871 #define TRACE_ORG_REG 0x00000909
872 #define TRACE_ORG_REG_SUCCESS 0x0000090a
873 
874 /* TRACE_TYPE                       0x000000^^*/
875 #define TRACE_TYPE_MASK 0x000000ff
876 #define TRACE_GET_TYPE(x) (((uint32_t)(x)) & TRACE_TYPE_MASK)
877 
878 #define TRACE_TYPE_ERROR 0x00000000
879 #define TRACE_TYPE_WARNING 0x00000001
880 #define TRACE_TYPE_API 0x00000002
881 #define TRACE_TYPE_EVENT 0x00000003
882 #define TRACE_TYPE_DEBUG 0x00000004
883 #define TRACE_TYPE_STACK_ONLY_MAX TRACE_TYPE_DEBUG
884 #define TRACE_TYPE_TX 0x00000005
885 #define TRACE_TYPE_RX 0x00000006
886 #define TRACE_TYPE_DEBUG_ASSERT 0x00000007
887 #define TRACE_TYPE_GENERIC 0x00000008
888 #define TRACE_TYPE_REG 0x00000009
889 #define TRACE_TYPE_REG_SUCCESS 0x0000000a
890 #define TRACE_TYPE_CMD_TX 0x0000000b
891 #define TRACE_TYPE_EVT_TX 0x0000000c
892 #define TRACE_TYPE_ACL_TX 0x0000000d
893 #define TRACE_TYPE_CMD_RX 0x0000000e
894 #define TRACE_TYPE_EVT_RX 0x0000000f
895 #define TRACE_TYPE_ACL_RX 0x00000010
896 #define TRACE_TYPE_TARGET_TRACE 0x00000011
897 #define TRACE_TYPE_SCO_TX 0x00000012
898 #define TRACE_TYPE_SCO_RX 0x00000013
899 
900 #define TRACE_TYPE_MAX_NUM 20
901 #define TRACE_TYPE_ALL 0xffff
902 
903 /* Define color for script type */
904 #define SCR_COLOR_DEFAULT 0
905 #define SCR_COLOR_TYPE_COMMENT 1
906 #define SCR_COLOR_TYPE_COMMAND 2
907 #define SCR_COLOR_TYPE_EVENT 3
908 #define SCR_COLOR_TYPE_SELECT 4
909 
910 /* Define protocol trace flag values */
911 #define SCR_PROTO_TRACE_HCI_SUMMARY 0x00000001
912 #define SCR_PROTO_TRACE_HCI_DATA 0x00000002
913 #define SCR_PROTO_TRACE_L2CAP 0x00000004
914 #define SCR_PROTO_TRACE_RFCOMM 0x00000008
915 #define SCR_PROTO_TRACE_SDP 0x00000010
916 #define SCR_PROTO_TRACE_TCS 0x00000020
917 #define SCR_PROTO_TRACE_OBEX 0x00000040
918 #define SCR_PROTO_TRACE_OAPP 0x00000080 /* OBEX Application Profile */
919 #define SCR_PROTO_TRACE_AMP 0x00000100
920 #define SCR_PROTO_TRACE_BNEP 0x00000200
921 #define SCR_PROTO_TRACE_AVP 0x00000400
922 #define SCR_PROTO_TRACE_MCA 0x00000800
923 #define SCR_PROTO_TRACE_ATT 0x00001000
924 #define SCR_PROTO_TRACE_SMP 0x00002000
925 #define SCR_PROTO_TRACE_NCI 0x00004000
926 #define SCR_PROTO_TRACE_LLCP 0x00008000
927 #define SCR_PROTO_TRACE_NDEF 0x00010000
928 #define SCR_PROTO_TRACE_RW 0x00020000
929 #define SCR_PROTO_TRACE_CE 0x00040000
930 #define SCR_PROTO_TRACE_SNEP 0x00080000
931 #define SCR_PROTO_TRACE_CHO 0x00100000
932 #define SCR_PROTO_TRACE_ALL 0x001fffff
933 #define SCR_PROTO_TRACE_HCI_LOGGING_VSE \
934   0x0800 /* Brcm vs event for logmsg and protocol traces */
935 
936 #define MAX_SCRIPT_TYPE 5
937 
938 #define TCS_PSM_INTERCOM 5
939 #define TCS_PSM_CORDLESS 7
940 #define BT_PSM_BNEP 0x000F
941 /* Define PSMs HID uses */
942 #define HID_PSM_CONTROL 0x0011
943 #define HID_PSM_INTERRUPT 0x0013
944 
945 /* Define a function for logging */
946 typedef void(BT_LOG_FUNC)(int trace_type, const char* fmt_str, ...);
947 
948 #endif
949