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 #ifdef __cplusplus
25 #include <string>
26 #endif  // __cplusplus
27 
28 /* READ WELL !!
29  *
30  * This section defines global events. These are events that cross layers.
31  * Any event that passes between layers MUST be one of these events. Tasks
32  * can use their own events internally, but a FUNDAMENTAL design issue is
33  * that global events MUST be one of these events defined below.
34  *
35  * The convention used is the the event name contains the layer that the
36  * event is going to.
37  */
38 #define BT_EVT_MASK 0xFF00
39 #define BT_SUB_EVT_MASK 0x00FF
40 /* To Bluetooth Upper Layers        */
41 /************************************/
42 /* HCI Event                        */
43 #define BT_EVT_TO_BTU_HCI_EVT 0x1000
44 /* ACL Data from HCI                */
45 #define BT_EVT_TO_BTU_HCI_ACL 0x1100
46 /* SCO Data from HCI                */
47 #define BT_EVT_TO_BTU_HCI_SCO 0x1200
48 /* HCI Transport Error              */
49 #define BT_EVT_TO_BTU_HCIT_ERR 0x1300
50 
51 /* Serial Port Data                 */
52 #define BT_EVT_TO_BTU_SP_DATA 0x1500
53 
54 /* HCI command from upper layer     */
55 #define BT_EVT_TO_BTU_HCI_CMD 0x1600
56 
57 /* ISO Data from HCI                */
58 #define BT_EVT_TO_BTU_HCI_ISO 0x1700
59 
60 /* L2CAP segment(s) transmitted     */
61 #define BT_EVT_TO_BTU_L2C_SEG_XMIT 0x1900
62 
63 /* To LM                            */
64 /************************************/
65 /* HCI Command                      */
66 #define BT_EVT_TO_LM_HCI_CMD 0x2000
67 /* HCI ACL Data                     */
68 #define BT_EVT_TO_LM_HCI_ACL 0x2100
69 /* HCI SCO Data                     */
70 #define BT_EVT_TO_LM_HCI_SCO 0x2200
71 /* HCI ISO Data                     */
72 #define BT_EVT_TO_LM_HCI_ISO 0x2d00
73 
74 #define BT_EVT_HCISU 0x5000
75 
76 /* BTIF Events */
77 #define BT_EVT_BTIF 0xA000
78 #define BT_EVT_CONTEXT_SWITCH_EVT (0x0001 | BT_EVT_BTIF)
79 
80 /* ISO Layer specific */
81 #define BT_ISO_HDR_CONTAINS_TS (0x0001)
82 #define BT_ISO_HDR_OFFSET_POINTS_DATA (0x0002)
83 
84 /* Define the header of each buffer used in the Bluetooth stack.
85  */
86 typedef struct {
87   uint16_t event;
88   uint16_t len;
89   uint16_t offset;
90   uint16_t layer_specific;
91   uint8_t data[];
92 } BT_HDR;
93 
94 typedef struct {
95   uint16_t event;
96   uint16_t len;
97   uint16_t offset;
98   uint16_t layer_specific;
99   // Note: Removal of flexible array member with no specified size.
100   // This struct may be embedded in any position within other structs
101   // and will not trigger various flexible member compilation issues.
102 } BT_HDR_RIGID;
103 
104 #ifdef __cplusplus
105 template <typename T>
106 T* ToPacketData(BT_HDR* bt_hdr, size_t offset = 0) {
107   return reinterpret_cast<T*>(bt_hdr->data + bt_hdr->offset + offset);
108 }
109 template <typename T>
110 const T* ToPacketData(const BT_HDR* bt_hdr, size_t offset = 0) {
111   return reinterpret_cast<const T*>(bt_hdr->data + bt_hdr->offset + offset);
112 }
113 #endif  // __cplusplus
114 
115 #define BT_HDR_SIZE (sizeof(BT_HDR))
116 
117 enum {
118   BT_PSM_SDP = 0x0001,
119   BT_PSM_RFCOMM = 0x0003,
120   BT_PSM_TCS = 0x0005,
121   BT_PSM_CTP = 0x0007,
122   BT_PSM_BNEP = 0x000F,
123   BT_PSM_HIDC = 0x0011,
124   HID_PSM_CONTROL = 0x0011,
125   BT_PSM_HIDI = 0x0013,
126   HID_PSM_INTERRUPT = 0x0013,
127   BT_PSM_UPNP = 0x0015,
128   BT_PSM_AVCTP = 0x0017,
129   BT_PSM_AVDTP = 0x0019,
130   BT_PSM_AVCTP_13 = 0x001B, /* Advanced Control - Browsing */
131   BT_PSM_UDI_CP =
132       0x001D,          /* Unrestricted Digital Information Profile C-Plane  */
133   BT_PSM_ATT = 0x001F, /* Attribute Protocol  */
134   BT_PSM_EATT = 0x0027,
135   /* We will not allocate a PSM in the reserved range to 3rd party apps
136    */
137   BRCM_RESERVED_PSM_START = 0x5AE1,
138   BRCM_RESERVED_PSM_END = 0x5AFF,
139 };
140 
141 /*******************************************************************************
142  * Macros to get and put bytes to and from a stream (Little Endian format).
143  */
144 #define UINT64_TO_BE_STREAM(p, u64)  \
145   {                                  \
146     *(p)++ = (uint8_t)((u64) >> 56); \
147     *(p)++ = (uint8_t)((u64) >> 48); \
148     *(p)++ = (uint8_t)((u64) >> 40); \
149     *(p)++ = (uint8_t)((u64) >> 32); \
150     *(p)++ = (uint8_t)((u64) >> 24); \
151     *(p)++ = (uint8_t)((u64) >> 16); \
152     *(p)++ = (uint8_t)((u64) >> 8);  \
153     *(p)++ = (uint8_t)(u64);         \
154   }
155 #define UINT32_TO_STREAM(p, u32)     \
156   {                                  \
157     *(p)++ = (uint8_t)(u32);         \
158     *(p)++ = (uint8_t)((u32) >> 8);  \
159     *(p)++ = (uint8_t)((u32) >> 16); \
160     *(p)++ = (uint8_t)((u32) >> 24); \
161   }
162 #define UINT24_TO_STREAM(p, u24)     \
163   {                                  \
164     *(p)++ = (uint8_t)(u24);         \
165     *(p)++ = (uint8_t)((u24) >> 8);  \
166     *(p)++ = (uint8_t)((u24) >> 16); \
167   }
168 #define UINT16_TO_STREAM(p, u16)    \
169   {                                 \
170     *(p)++ = (uint8_t)(u16);        \
171     *(p)++ = (uint8_t)((u16) >> 8); \
172   }
173 #define UINT8_TO_STREAM(p, u8) \
174   { *(p)++ = (uint8_t)(u8); }
175 #define INT8_TO_STREAM(p, u8) \
176   { *(p)++ = (int8_t)(u8); }
177 #define ARRAY32_TO_STREAM(p, a)                                     \
178   {                                                                 \
179     int ijk;                                                        \
180     for (ijk = 0; ijk < 32; ijk++) *(p)++ = (uint8_t)(a)[31 - ijk]; \
181   }
182 #define ARRAY16_TO_STREAM(p, a)                                     \
183   {                                                                 \
184     int ijk;                                                        \
185     for (ijk = 0; ijk < 16; ijk++) *(p)++ = (uint8_t)(a)[15 - ijk]; \
186   }
187 #define ARRAY8_TO_STREAM(p, a)                                    \
188   {                                                               \
189     int ijk;                                                      \
190     for (ijk = 0; ijk < 8; ijk++) *(p)++ = (uint8_t)(a)[7 - ijk]; \
191   }
192 #define LAP_TO_STREAM(p, a)                     \
193   {                                             \
194     int ijk;                                    \
195     for (ijk = 0; ijk < LAP_LEN; ijk++)         \
196       *(p)++ = (uint8_t)(a)[LAP_LEN - 1 - ijk]; \
197   }
198 #define DEVCLASS_TO_STREAM(p, a)                      \
199   {                                                   \
200     int ijk;                                          \
201     for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++)         \
202       *(p)++ = (uint8_t)(a)[DEV_CLASS_LEN - 1 - ijk]; \
203   }
204 #define ARRAY_TO_STREAM(p, a, len)                                \
205   {                                                               \
206     int ijk;                                                      \
207     for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[ijk]; \
208   }
209 #define REVERSE_ARRAY_TO_STREAM(p, a, len)                                  \
210   {                                                                         \
211     int ijk;                                                                \
212     for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[(len)-1 - ijk]; \
213   }
214 
215 #define STREAM_TO_INT8(u8, p)   \
216   {                             \
217     (u8) = (*((int8_t*)(p)));   \
218     (p) += 1;                   \
219   }
220 #define STREAM_TO_UINT8(u8, p) \
221   {                            \
222     (u8) = (uint8_t)(*(p));    \
223     (p) += 1;                  \
224   }
225 #define STREAM_TO_UINT16(u16, p)                                  \
226   {                                                               \
227     (u16) = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); \
228     (p) += 2;                                                     \
229   }
230 #define STREAM_TO_UINT24(u32, p)                                      \
231   {                                                                   \
232     (u32) = (((uint32_t)(*(p))) + ((((uint32_t)(*((p) + 1)))) << 8) + \
233              ((((uint32_t)(*((p) + 2)))) << 16));                     \
234     (p) += 3;                                                         \
235   }
236 #define STREAM_TO_UINT32(u32, p)                                      \
237   {                                                                   \
238     (u32) = (((uint32_t)(*(p))) + ((((uint32_t)(*((p) + 1)))) << 8) + \
239              ((((uint32_t)(*((p) + 2)))) << 16) +                     \
240              ((((uint32_t)(*((p) + 3)))) << 24));                     \
241     (p) += 4;                                                         \
242   }
243 #define STREAM_TO_UINT64(u64, p)                                      \
244   {                                                                   \
245     (u64) = (((uint64_t)(*(p))) + ((((uint64_t)(*((p) + 1)))) << 8) + \
246              ((((uint64_t)(*((p) + 2)))) << 16) +                     \
247              ((((uint64_t)(*((p) + 3)))) << 24) +                     \
248              ((((uint64_t)(*((p) + 4)))) << 32) +                     \
249              ((((uint64_t)(*((p) + 5)))) << 40) +                     \
250              ((((uint64_t)(*((p) + 6)))) << 48) +                     \
251              ((((uint64_t)(*((p) + 7)))) << 56));                     \
252     (p) += 8;                                                         \
253   }
254 #define STREAM_TO_ARRAY32(a, p)                     \
255   {                                                 \
256     int ijk;                                        \
257     uint8_t* _pa = (uint8_t*)(a) + 31;              \
258     for (ijk = 0; ijk < 32; ijk++) *_pa-- = *(p)++; \
259   }
260 #define STREAM_TO_ARRAY16(a, p)                     \
261   {                                                 \
262     int ijk;                                        \
263     uint8_t* _pa = (uint8_t*)(a) + 15;              \
264     for (ijk = 0; ijk < 16; ijk++) *_pa-- = *(p)++; \
265   }
266 #define STREAM_TO_ARRAY8(a, p)                     \
267   {                                                \
268     int ijk;                                       \
269     uint8_t* _pa = (uint8_t*)(a) + 7;              \
270     for (ijk = 0; ijk < 8; ijk++) *_pa-- = *(p)++; \
271   }
272 #define STREAM_TO_DEVCLASS(a, p)                               \
273   {                                                            \
274     int ijk;                                                   \
275     uint8_t* _pa = (uint8_t*)(a) + DEV_CLASS_LEN - 1;          \
276     for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) *_pa-- = *(p)++; \
277   }
278 #define STREAM_TO_LAP(a, p)                               \
279   {                                                       \
280     int ijk;                                              \
281     uint8_t* plap = (uint8_t*)(a) + LAP_LEN - 1;          \
282     for (ijk = 0; ijk < LAP_LEN; ijk++) *plap-- = *(p)++; \
283   }
284 #define STREAM_TO_ARRAY(a, p, len)                                   \
285   {                                                                  \
286     int ijk;                                                         \
287     for (ijk = 0; ijk < (len); ijk++) ((uint8_t*)(a))[ijk] = *(p)++; \
288   }
289 #define REVERSE_STREAM_TO_ARRAY(a, p, len)             \
290   {                                                    \
291     int ijk;                                           \
292     uint8_t* _pa = (uint8_t*)(a) + (len)-1;            \
293     for (ijk = 0; ijk < (len); ijk++) *_pa-- = *(p)++; \
294   }
295 
296 #define STREAM_SKIP_UINT8(p) \
297   do {                       \
298     (p) += 1;                \
299   } while (0)
300 #define STREAM_SKIP_UINT16(p) \
301   do {                        \
302     (p) += 2;                 \
303   } while (0)
304 #define STREAM_SKIP_UINT32(p) \
305   do {                        \
306     (p) += 4;                 \
307   } while (0)
308 
309 /*******************************************************************************
310  * Macros to get and put bytes to and from a field (Little Endian format).
311  * These are the same as to stream, except the pointer is not incremented.
312  */
313 #define UINT32_TO_FIELD(p, u32)                    \
314   {                                                \
315     *(uint8_t*)(p) = (uint8_t)(u32);               \
316     *((uint8_t*)(p) + 1) = (uint8_t)((u32) >> 8);  \
317     *((uint8_t*)(p) + 2) = (uint8_t)((u32) >> 16); \
318     *((uint8_t*)(p) + 3) = (uint8_t)((u32) >> 24); \
319   }
320 #define UINT24_TO_FIELD(p, u24)                    \
321   {                                                \
322     *(uint8_t*)(p) = (uint8_t)(u24);               \
323     *((uint8_t*)(p) + 1) = (uint8_t)((u24) >> 8);  \
324     *((uint8_t*)(p) + 2) = (uint8_t)((u24) >> 16); \
325   }
326 #define UINT16_TO_FIELD(p, u16)                   \
327   {                                               \
328     *(uint8_t*)(p) = (uint8_t)(u16);              \
329     *((uint8_t*)(p) + 1) = (uint8_t)((u16) >> 8); \
330   }
331 #define UINT8_TO_FIELD(p, u8) \
332   { *(uint8_t*)(p) = (uint8_t)(u8); }
333 
334 /*******************************************************************************
335  * Macros to get and put bytes to and from a stream (Big Endian format)
336  */
337 #define UINT32_TO_BE_STREAM(p, u32)  \
338   {                                  \
339     *(p)++ = (uint8_t)((u32) >> 24); \
340     *(p)++ = (uint8_t)((u32) >> 16); \
341     *(p)++ = (uint8_t)((u32) >> 8);  \
342     *(p)++ = (uint8_t)(u32);         \
343   }
344 #define UINT24_TO_BE_STREAM(p, u24)  \
345   {                                  \
346     *(p)++ = (uint8_t)((u24) >> 16); \
347     *(p)++ = (uint8_t)((u24) >> 8);  \
348     *(p)++ = (uint8_t)(u24);         \
349   }
350 #define UINT16_TO_BE_STREAM(p, u16) \
351   {                                 \
352     *(p)++ = (uint8_t)((u16) >> 8); \
353     *(p)++ = (uint8_t)(u16);        \
354   }
355 #define UINT8_TO_BE_STREAM(p, u8) \
356   { *(p)++ = (uint8_t)(u8); }
357 #define ARRAY_TO_BE_STREAM(p, a, len)                             \
358   {                                                               \
359     int ijk;                                                      \
360     for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[ijk]; \
361   }
362 #define ARRAY_TO_BE_STREAM_REVERSE(p, a, len)                               \
363   {                                                                         \
364     int ijk;                                                                \
365     for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[(len)-ijk - 1]; \
366   }
367 
368 #define BE_STREAM_TO_UINT8(u8, p) \
369   {                               \
370     (u8) = (uint8_t)(*(p));       \
371     (p) += 1;                     \
372   }
373 #define BE_STREAM_TO_UINT16(u16, p)                                       \
374   {                                                                       \
375     (u16) = (uint16_t)(((uint16_t)(*(p)) << 8) + (uint16_t)(*((p) + 1))); \
376     (p) += 2;                                                             \
377   }
378 #define BE_STREAM_TO_UINT24(u32, p)                                     \
379   {                                                                     \
380     (u32) = (((uint32_t)(*((p) + 2))) + ((uint32_t)(*((p) + 1)) << 8) + \
381              ((uint32_t)(*(p)) << 16));                                 \
382     (p) += 3;                                                           \
383   }
384 #define BE_STREAM_TO_UINT32(u32, p)                                      \
385   {                                                                      \
386     (u32) = ((uint32_t)(*((p) + 3)) + ((uint32_t)(*((p) + 2)) << 8) +    \
387              ((uint32_t)(*((p) + 1)) << 16) + ((uint32_t)(*(p)) << 24)); \
388     (p) += 4;                                                            \
389   }
390 #define BE_STREAM_TO_UINT64(u64, p)                                            \
391   {                                                                            \
392     (u64) = ((uint64_t)(*((p) + 7)) + ((uint64_t)(*((p) + 6)) << 8) +          \
393              ((uint64_t)(*((p) + 5)) << 16) + ((uint64_t)(*((p) + 4)) << 24) + \
394              ((uint64_t)(*((p) + 3)) << 32) + ((uint64_t)(*((p) + 2)) << 40) + \
395              ((uint64_t)(*((p) + 1)) << 48) + ((uint64_t)(*(p)) << 56));       \
396     (p) += 8;                                                                  \
397   }
398 #define BE_STREAM_TO_ARRAY(p, a, len)                                \
399   {                                                                  \
400     int ijk;                                                         \
401     for (ijk = 0; ijk < (len); ijk++) ((uint8_t*)(a))[ijk] = *(p)++; \
402   }
403 
404 /*******************************************************************************
405  * Macros to get and put bytes to and from a field (Big Endian format).
406  * These are the same as to stream, except the pointer is not incremented.
407  */
408 #define UINT32_TO_BE_FIELD(p, u32)                 \
409   {                                                \
410     *(uint8_t*)(p) = (uint8_t)((u32) >> 24);       \
411     *((uint8_t*)(p) + 1) = (uint8_t)((u32) >> 16); \
412     *((uint8_t*)(p) + 2) = (uint8_t)((u32) >> 8);  \
413     *((uint8_t*)(p) + 3) = (uint8_t)(u32);         \
414   }
415 #define UINT24_TO_BE_FIELD(p, u24)                \
416   {                                               \
417     *(uint8_t*)(p) = (uint8_t)((u24) >> 16);      \
418     *((uint8_t*)(p) + 1) = (uint8_t)((u24) >> 8); \
419     *((uint8_t*)(p) + 2) = (uint8_t)(u24);        \
420   }
421 #define UINT16_TO_BE_FIELD(p, u16)          \
422   {                                         \
423     *(uint8_t*)(p) = (uint8_t)((u16) >> 8); \
424     *((uint8_t*)(p) + 1) = (uint8_t)(u16);  \
425   }
426 #define UINT8_TO_BE_FIELD(p, u8) \
427   { *(uint8_t*)(p) = (uint8_t)(u8); }
428 
429 /* Common Bluetooth field definitions */
430 #define BD_ADDR_LEN 6 /* Device address length */
431 
432 #ifdef __cplusplus
433 #include <bluetooth/uuid.h>
434 #include <include/hardware/bluetooth.h>
435 
BDADDR_TO_STREAM(uint8_t * & p,const RawAddress & a)436 inline void BDADDR_TO_STREAM(uint8_t*& p, const RawAddress& a) {
437   for (int ijk = 0; ijk < BD_ADDR_LEN; ijk++)
438     *(p)++ = (uint8_t)(a.address)[BD_ADDR_LEN - 1 - ijk];
439 }
440 
STREAM_TO_BDADDR(RawAddress & a,uint8_t * & p)441 inline void STREAM_TO_BDADDR(RawAddress& a, uint8_t*& p) {
442   uint8_t* pbda = (uint8_t*)(a.address) + BD_ADDR_LEN - 1;
443   for (int ijk = 0; ijk < BD_ADDR_LEN; ijk++) *pbda-- = *(p)++;
444 }
445 
446 #endif
447 
448 #define BT_OCTET8_LEN 8
449 typedef uint8_t BT_OCTET8[BT_OCTET8_LEN]; /* octet array: size 16 */
450 
451 /* Some C files include this header file */
452 #ifdef __cplusplus
453 
454 #include <array>
455 
456 constexpr int OCTET16_LEN = 16;
457 typedef std::array<uint8_t, OCTET16_LEN> Octet16;
458 
459 constexpr int LINK_KEY_LEN = OCTET16_LEN;
460 typedef Octet16 LinkKey; /* Link Key */
461 
462 /* Sample LTK from BT Spec 5.1 | Vol 6, Part C 1
463  * 0x4C68384139F574D836BCF34E9DFB01BF */
464 constexpr Octet16 SAMPLE_LTK = {0xbf, 0x01, 0xfb, 0x9d, 0x4e, 0xf3, 0xbc, 0x36,
465                                 0xd8, 0x74, 0xf5, 0x39, 0x41, 0x38, 0x68, 0x4c};
is_sample_ltk(const Octet16 & ltk)466 inline bool is_sample_ltk(const Octet16& ltk) { return ltk == SAMPLE_LTK; }
467 
468 #endif
469 
470 #define PIN_CODE_LEN 16
471 typedef uint8_t PIN_CODE[PIN_CODE_LEN]; /* Pin Code (upto 128 bits) MSB is 0 */
472 
473 #define BT_OCTET32_LEN 32
474 typedef uint8_t BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */
475 
476 #define DEV_CLASS_LEN 3
477 typedef uint8_t DEV_CLASS[DEV_CLASS_LEN]; /* Device class */
478 
479 #define EXT_INQ_RESP_LEN 3
480 typedef uint8_t EXT_INQ_RESP[EXT_INQ_RESP_LEN]; /* Extended Inquiry Response */
481 
482 #define BD_NAME_LEN 248
483 typedef uint8_t BD_NAME[BD_NAME_LEN + 1]; /* Device name */
484 
485 #define BD_FEATURES_LEN 8
486 typedef uint8_t
487     BD_FEATURES[BD_FEATURES_LEN]; /* LMP features supported by device */
488 
489 #ifdef __cplusplus
490 // Bit order [0]:0-7 [1]:8-15 ... [7]:56-63
bd_features_text(const BD_FEATURES & features)491 inline std::string bd_features_text(const BD_FEATURES& features) {
492   uint8_t len = BD_FEATURES_LEN;
493   char buf[255];
494   char* pbuf = buf;
495   const uint8_t* b = features;
496   while (len--) {
497     pbuf += sprintf(pbuf, "0x%02x ", *b++);
498   }
499   return std::string(buf);
500 }
501 #endif  // __cplusplus
502 
503 #define BT_EVENT_MASK_LEN 8
504 typedef uint8_t BT_EVENT_MASK[BT_EVENT_MASK_LEN]; /* Event Mask */
505 
506 #define LAP_LEN 3
507 typedef uint8_t LAP[LAP_LEN];     /* IAC as passed to Inquiry (LAP) */
508 typedef uint8_t INQ_LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
509 
510 #define COF_LEN 12
511 typedef uint8_t COF[COF_LEN]; /* ciphering offset number */
512 
513 #define BT_1SEC_TIMEOUT_MS (1 * 1000) /* 1 second */
514 
515 #define BT_EIR_FLAGS_TYPE 0x01
516 #define BT_EIR_MORE_16BITS_UUID_TYPE 0x02
517 #define BT_EIR_COMPLETE_16BITS_UUID_TYPE 0x03
518 #define BT_EIR_MORE_32BITS_UUID_TYPE 0x04
519 #define BT_EIR_COMPLETE_32BITS_UUID_TYPE 0x05
520 #define BT_EIR_MORE_128BITS_UUID_TYPE 0x06
521 #define BT_EIR_COMPLETE_128BITS_UUID_TYPE 0x07
522 #define BT_EIR_SHORTENED_LOCAL_NAME_TYPE 0x08
523 #define BT_EIR_COMPLETE_LOCAL_NAME_TYPE 0x09
524 #define BT_EIR_TX_POWER_LEVEL_TYPE 0x0A
525 #define BT_EIR_OOB_BD_ADDR_TYPE 0x0C
526 #define BT_EIR_OOB_COD_TYPE 0x0D
527 #define BT_EIR_OOB_SSP_HASH_C_TYPE 0x0E
528 #define BT_EIR_OOB_SSP_RAND_R_TYPE 0x0F
529 #define BT_EIR_SERVICE_DATA_TYPE 0x16
530 #define BT_EIR_SERVICE_DATA_16BITS_UUID_TYPE 0x16
531 #define BT_EIR_SERVICE_DATA_32BITS_UUID_TYPE 0x20
532 #define BT_EIR_SERVICE_DATA_128BITS_UUID_TYPE 0x21
533 #define BT_EIR_MANUFACTURER_SPECIFIC_TYPE 0xFF
534 
535 /* Device Types
536  */
537 enum {
538   BT_DEVICE_TYPE_BREDR = (1 << 0),
539   BT_DEVICE_TYPE_BLE = (1 << 1),
540   BT_DEVICE_TYPE_DUMO = BT_DEVICE_TYPE_BREDR | BT_DEVICE_TYPE_BLE,
541 };
542 typedef uint8_t tBT_DEVICE_TYPE;
543 #ifdef __cplusplus
DeviceTypeText(tBT_DEVICE_TYPE type)544 inline std::string DeviceTypeText(tBT_DEVICE_TYPE type) {
545   switch (type) {
546     case BT_DEVICE_TYPE_BREDR:
547       return std::string("BR_EDR");
548     case BT_DEVICE_TYPE_BLE:
549       return std::string("BLE");
550     case BT_DEVICE_TYPE_DUMO:
551       return std::string("DUAL");
552     default:
553       return std::string("Unknown");
554   }
555 }
556 #endif  // __cplusplus
557 
558 #endif
559