• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2003-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 /******************************************************************************
20  *
21  *  This is the private interface file for the BTA device manager.
22  *
23  ******************************************************************************/
24 #ifndef BTA_DM_INT_H
25 #define BTA_DM_INT_H
26 
27 #include "bt_target.h"
28 
29 #if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
30     #include "bta_gatt_api.h"
31 #endif
32 
33 
34 
35 /*****************************************************************************
36 **  Constants and data types
37 *****************************************************************************/
38 
39 
40 #define BTA_COPY_DEVICE_CLASS(coddst, codsrc)   {((UINT8 *)(coddst))[0] = ((UINT8 *)(codsrc))[0]; \
41                                                  ((UINT8 *)(coddst))[1] = ((UINT8 *)(codsrc))[1];  \
42                                                  ((UINT8 *)(coddst))[2] = ((UINT8 *)(codsrc))[2];}
43 
44 
45 #define BTA_DM_MSG_LEN 50
46 
47 #define BTA_SERVICE_ID_TO_SERVICE_MASK(id)       (1 << (id))
48 
49 /* DM events */
50 enum
51 {
52     /* device manager local device API events */
53     BTA_DM_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_DM),
54     BTA_DM_API_DISABLE_EVT,
55     BTA_DM_API_SET_NAME_EVT,
56     BTA_DM_API_SET_VISIBILITY_EVT,
57     BTA_DM_API_SET_AFH_CHANNELS_EVT,
58     BTA_API_DM_SIG_STRENGTH_EVT,
59     BTA_DM_API_VENDOR_SPECIFIC_COMMAND_EVT,
60     BTA_DM_API_TX_INQPWR_EVT,
61     BTA_DM_ACL_CHANGE_EVT,
62     BTA_DM_API_ADD_DEVICE_EVT,
63     BTA_DM_API_REMOVE_ACL_EVT,
64 
65     /* security API events */
66     BTA_DM_API_BOND_EVT,
67     BTA_DM_API_BOND_CANCEL_EVT,
68     BTA_DM_API_PIN_REPLY_EVT,
69     BTA_DM_API_LINK_POLICY_EVT,
70     BTA_DM_API_AUTH_REPLY_EVT,
71 
72     /* power manger events */
73     BTA_DM_PM_BTM_STATUS_EVT,
74     BTA_DM_PM_TIMER_EVT,
75 
76     /* simple pairing events */
77     BTA_DM_API_CONFIRM_EVT,
78 
79     BTA_DM_API_SET_ENCRYPTION_EVT,
80 
81 
82 #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
83     BTA_DM_API_PASKY_CANCEL_EVT,
84 #endif
85 #if (BTM_OOB_INCLUDED == TRUE)
86     BTA_DM_API_LOC_OOB_EVT,
87     BTA_DM_CI_IO_REQ_EVT,
88     BTA_DM_CI_RMT_OOB_EVT,
89 #endif /* BTM_OOB_INCLUDED */
90 
91     BTA_DM_API_REMOVE_DEVICE_EVT,
92 
93 #if BLE_INCLUDED == TRUE
94     BTA_DM_API_ADD_BLEKEY_EVT,
95     BTA_DM_API_ADD_BLEDEVICE_EVT,
96     BTA_DM_API_BLE_PASSKEY_REPLY_EVT,
97     BTA_DM_API_BLE_SEC_GRANT_EVT,
98     BTA_DM_API_BLE_SET_BG_CONN_TYPE,
99     BTA_DM_API_BLE_CONN_PARAM_EVT,
100     BTA_DM_API_BLE_SCAN_PARAM_EVT,
101     BTA_DM_API_BLE_OBSERVE_EVT,
102     BTA_DM_API_BLE_ADV_PARAM_EVT,
103     BTA_DM_API_BLE_SET_ADV_CONFIG_EVT,
104     BTA_DM_API_BLE_SET_SCAN_RSP_EVT,
105     BTA_DM_API_BLE_BROADCAST_EVT,
106 #endif
107 
108 #if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
109     BTA_DM_API_UPDATE_EIR_UUID_EVT,
110 #endif
111 #if (BTM_EIR_SERVER_INCLUDED == TRUE)
112     BTA_DM_API_SET_EIR_CONFIG_EVT,
113 #endif
114 
115     BTA_DM_API_ENABLE_TEST_MODE_EVT,
116     BTA_DM_API_DISABLE_TEST_MODE_EVT,
117     BTA_DM_API_EXECUTE_CBACK_EVT,
118     BTA_DM_API_SET_AFH_CHANNEL_ASSESMENT_EVT,
119     BTA_DM_MAX_EVT
120 };
121 
122 
123 /* DM search events */
124 enum
125 {
126     /* DM search API events */
127     BTA_DM_API_SEARCH_EVT = BTA_SYS_EVT_START(BTA_ID_DM_SEARCH),
128     BTA_DM_API_SEARCH_CANCEL_EVT,
129     BTA_DM_API_DISCOVER_EVT,
130     BTA_DM_INQUIRY_CMPL_EVT,
131     BTA_DM_REMT_NAME_EVT,
132     BTA_DM_SDP_RESULT_EVT,
133     BTA_DM_SEARCH_CMPL_EVT,
134     BTA_DM_DISCOVERY_RESULT_EVT,
135     BTA_DM_API_DI_DISCOVER_EVT,
136     BTA_DM_DISC_CLOSE_TOUT_EVT
137 };
138 
139 /* data type for BTA_DM_API_ENABLE_EVT */
140 typedef struct
141 {
142     BT_HDR              hdr;
143     tBTA_DM_SEC_CBACK *p_sec_cback;
144 } tBTA_DM_API_ENABLE;
145 
146 /* data type for BTA_DM_API_SET_NAME_EVT */
147 typedef struct
148 {
149     BT_HDR              hdr;
150     BD_NAME             name; /* max 248 bytes name, plus must be Null terminated */
151 } tBTA_DM_API_SET_NAME;
152 
153 /* data type for BTA_DM_API_SET_VISIBILITY_EVT */
154 typedef struct
155 {
156     BT_HDR              hdr;
157     tBTA_DM_DISC    disc_mode;
158     tBTA_DM_CONN    conn_mode;
159     UINT8           pair_mode;
160     UINT8           conn_paired_only;
161 } tBTA_DM_API_SET_VISIBILITY;
162 
163 /* data type for BTA_DM_API_SET_AFH_CHANNELS_EVT */
164 typedef struct
165 {
166     BT_HDR              hdr;
167     UINT8           first;
168     UINT8           last;
169 } tBTA_DM_API_SET_AFH_CHANNELS_EVT;
170 
171 /* data type for BTA_DM_API_VENDOR_SPECIFIC_COMMAND_EVT */
172 typedef struct
173 {
174     BT_HDR              hdr;
175     UINT16              opcode;
176     UINT8               param_len;
177     UINT8               *p_param_buf;
178     tBTA_VENDOR_CMPL_CBACK *p_cback;
179 
180 } tBTA_DM_API_VENDOR_SPECIFIC_COMMAND;
181 
182 enum
183 {
184     BTA_DM_RS_NONE,     /* straight API call */
185     BTA_DM_RS_OK,       /* the role switch result - successful */
186     BTA_DM_RS_FAIL      /* the role switch result - failed */
187 };
188 typedef UINT8 tBTA_DM_RS_RES;
189 
190 /* data type for BTA_DM_API_SEARCH_EVT */
191 typedef struct
192 {
193     BT_HDR      hdr;
194     tBTA_DM_INQ inq_params;
195     tBTA_SERVICE_MASK services;
196     tBTA_DM_SEARCH_CBACK * p_cback;
197     tBTA_DM_RS_RES  rs_res;
198 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
199     UINT8           num_uuid;
200     tBT_UUID        *p_uuid;
201 #endif
202 } tBTA_DM_API_SEARCH;
203 
204 /* data type for BTA_DM_API_DISCOVER_EVT */
205 typedef struct
206 {
207     BT_HDR      hdr;
208     BD_ADDR bd_addr;
209     tBTA_SERVICE_MASK services;
210     tBTA_DM_SEARCH_CBACK * p_cback;
211     BOOLEAN         sdp_search;
212 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
213     UINT8           num_uuid;
214     tBT_UUID        *p_uuid;
215 #endif
216     tSDP_UUID    uuid;
217 } tBTA_DM_API_DISCOVER;
218 
219 /* data type for BTA_DM_API_DI_DISC_EVT */
220 typedef struct
221 {
222     BT_HDR              hdr;
223     BD_ADDR             bd_addr;
224     tBTA_DISCOVERY_DB   *p_sdp_db;
225     UINT32              len;
226     tBTA_DM_SEARCH_CBACK * p_cback;
227 }tBTA_DM_API_DI_DISC;
228 
229 /* data type for BTA_DM_API_BOND_EVT */
230 typedef struct
231 {
232     BT_HDR      hdr;
233     BD_ADDR bd_addr;
234 } tBTA_DM_API_BOND;
235 
236 /* data type for BTA_DM_API_BOND_CANCEL_EVT */
237 typedef struct
238 {
239     BT_HDR          hdr;
240     BD_ADDR         bd_addr;
241 } tBTA_DM_API_BOND_CANCEL;
242 
243 /* data type for BTA_DM_API_PIN_REPLY_EVT */
244 typedef struct
245 {
246     BT_HDR      hdr;
247     BD_ADDR bd_addr;
248     BOOLEAN accept;
249     UINT8 pin_len;
250     UINT8 p_pin[PIN_CODE_LEN];
251 } tBTA_DM_API_PIN_REPLY;
252 
253 /* data type for BTA_DM_API_LINK_POLICY_EVT */
254 typedef struct
255 {
256     BT_HDR      hdr;
257     BD_ADDR     bd_addr;
258     UINT16      policy_mask;
259     BOOLEAN     set;
260 } tBTA_DM_API_LINK_POLICY;
261 
262 /* data type for BTA_DM_API_AUTH_REPLY_EVT */
263 typedef struct
264 {
265     BT_HDR      hdr;
266     BD_ADDR bd_addr;
267     tBTA_SERVICE_ID service;
268     tBTA_AUTH_RESP response;
269 } tBTA_DM_API_AUTH_REPLY;
270 
271 /* data type for BTA_DM_API_LOC_OOB_EVT */
272 typedef struct
273 {
274     BT_HDR      hdr;
275 } tBTA_DM_API_LOC_OOB;
276 
277 /* data type for BTA_DM_API_CONFIRM_EVT */
278 typedef struct
279 {
280     BT_HDR      hdr;
281     BD_ADDR     bd_addr;
282     BOOLEAN     accept;
283 } tBTA_DM_API_CONFIRM;
284 
285 /* data type for BTA_DM_API_PASKY_CANCEL_EVT*/
286 typedef struct
287 {
288     BT_HDR      hdr;
289     BD_ADDR     bd_addr;
290 } tBTA_DM_API_PASKY_CANCEL;
291 
292 /* data type for BTA_DM_CI_IO_REQ_EVT */
293 typedef struct
294 {
295     BT_HDR          hdr;
296     BD_ADDR         bd_addr;
297     tBTA_IO_CAP     io_cap;
298     tBTA_OOB_DATA   oob_data;
299     tBTA_AUTH_REQ   auth_req;
300 } tBTA_DM_CI_IO_REQ;
301 
302 /* data type for BTA_DM_CI_RMT_OOB_EVT */
303 typedef struct
304 {
305     BT_HDR      hdr;
306     BD_ADDR     bd_addr;
307     BT_OCTET16  c;
308     BT_OCTET16  r;
309     BOOLEAN     accept;
310 } tBTA_DM_CI_RMT_OOB;
311 
312 /* data type for BTA_DM_REMT_NAME_EVT */
313 typedef struct
314 {
315     BT_HDR      hdr;
316     tBTA_DM_SEARCH  result;
317 } tBTA_DM_REM_NAME;
318 
319 /* data type for tBTA_DM_DISC_RESULT */
320 typedef struct
321 {
322     BT_HDR      hdr;
323     tBTA_DM_SEARCH  result;
324 } tBTA_DM_DISC_RESULT;
325 
326 
327 /* data type for BTA_DM_INQUIRY_CMPL_EVT */
328 typedef struct
329 {
330     BT_HDR      hdr;
331     UINT8       num;
332 } tBTA_DM_INQUIRY_CMPL;
333 
334 /* data type for BTA_DM_SDP_RESULT_EVT */
335 typedef struct
336 {
337     BT_HDR      hdr;
338     UINT16 sdp_result;
339 } tBTA_DM_SDP_RESULT;
340 
341 /* data type for BTA_API_DM_SIG_STRENGTH_EVT */
342 typedef struct
343 {
344     BT_HDR      hdr;
345     tBTA_SIG_STRENGTH_MASK mask;
346     UINT16 period;
347     BOOLEAN start;
348 } tBTA_API_DM_SIG_STRENGTH;
349 
350 /* data type for tBTA_API_DM_TX_INQPWR */
351 typedef struct
352 {
353     BT_HDR      hdr;
354     INT8        tx_power;
355 }tBTA_API_DM_TX_INQPWR;
356 
357 /* data type for BTA_DM_ACL_CHANGE_EVT */
358 typedef struct
359 {
360     BT_HDR          hdr;
361     tBTM_BL_EVENT   event;
362     UINT8           busy_level;
363     UINT8           busy_level_flags;
364     BOOLEAN         is_new;
365     UINT8           new_role;
366     BD_ADDR         bd_addr;
367     UINT8           hci_status;
368 } tBTA_DM_ACL_CHANGE;
369 
370 /* data type for BTA_DM_PM_BTM_STATUS_EVT */
371 typedef struct
372 {
373 
374     BT_HDR          hdr;
375     BD_ADDR         bd_addr;
376     tBTM_PM_STATUS  status;
377     UINT16          value;
378     UINT8           hci_status;
379 
380 } tBTA_DM_PM_BTM_STATUS;
381 
382 /* data type for BTA_DM_PM_TIMER_EVT */
383 typedef struct
384 {
385     BT_HDR          hdr;
386     BD_ADDR         bd_addr;
387 
388 } tBTA_DM_PM_TIMER;
389 
390 
391 /* data type for BTA_DM_API_ADD_DEVICE_EVT */
392 typedef struct
393 {
394     BT_HDR              hdr;
395     BD_ADDR             bd_addr;
396     DEV_CLASS           dc;
397     LINK_KEY            link_key;
398     tBTA_SERVICE_MASK   tm;
399     BOOLEAN             is_trusted;
400     UINT8               key_type;
401     tBTA_IO_CAP         io_cap;
402     BOOLEAN             link_key_known;
403     BOOLEAN             dc_known;
404     BD_NAME             bd_name;
405     UINT8               features[BTA_FEATURE_BYTES_PER_PAGE * (BTA_EXT_FEATURES_PAGE_MAX + 1)];
406 } tBTA_DM_API_ADD_DEVICE;
407 
408 /* data type for BTA_DM_API_REMOVE_ACL_EVT */
409 typedef struct
410 {
411     BT_HDR              hdr;
412     BD_ADDR             bd_addr;
413 } tBTA_DM_API_REMOVE_DEVICE;
414 
415 /* data type for BTA_DM_API_EXECUTE_CBACK_EVT */
416 typedef struct
417 {
418     BT_HDR               hdr;
419     void *               p_param;
420     tBTA_DM_EXEC_CBACK  *p_exec_cback;
421 } tBTA_DM_API_EXECUTE_CBACK;
422 
423 /* data type for tBTA_DM_API_SET_ENCRYPTION */
424 typedef struct
425 {
426     BT_HDR                    hdr;
427     tBTA_DM_ENCRYPT_CBACK     *p_callback;
428     tBTA_DM_BLE_SEC_ACT       sec_act;
429     BD_ADDR                   bd_addr;
430 } tBTA_DM_API_SET_ENCRYPTION;
431 
432 #if BLE_INCLUDED == TRUE
433 typedef struct
434 {
435     BT_HDR                  hdr;
436     BD_ADDR                 bd_addr;
437     tBTA_LE_KEY_VALUE       blekey;
438     tBTA_LE_KEY_TYPE        key_type;
439 
440 }tBTA_DM_API_ADD_BLEKEY;
441 
442 typedef struct
443 {
444     BT_HDR                  hdr;
445     BD_ADDR                 bd_addr;
446     tBT_DEVICE_TYPE         dev_type ;
447     tBLE_ADDR_TYPE          addr_type;
448 
449 }tBTA_DM_API_ADD_BLE_DEVICE;
450 
451 typedef struct
452 {
453     BT_HDR                  hdr;
454     BD_ADDR                 bd_addr;
455     BOOLEAN                 accept;
456     UINT32                  passkey;
457 }tBTA_DM_API_PASSKEY_REPLY;
458 
459 typedef struct
460 {
461     BT_HDR                  hdr;
462     BD_ADDR                 bd_addr;
463     tBTA_DM_BLE_SEC_GRANT   res;
464 }tBTA_DM_API_BLE_SEC_GRANT;
465 
466 
467 typedef struct
468 {
469     BT_HDR                  hdr;
470     tBTA_DM_BLE_CONN_TYPE   bg_conn_type;
471     tBTA_DM_BLE_SEL_CBACK   *p_select_cback;
472 }tBTA_DM_API_BLE_SET_BG_CONN_TYPE;
473 
474 /* set prefered BLE connection parameters for a device */
475 typedef struct
476 {
477     BT_HDR                  hdr;
478     BD_ADDR                 peer_bda;
479     UINT16                  conn_int_min;
480     UINT16                  conn_int_max;
481     UINT16                  supervision_tout;
482     UINT16                  slave_latency;
483 
484 }tBTA_DM_API_BLE_CONN_PARAMS;
485 
486 typedef struct
487 {
488     BT_HDR                  hdr;
489     BD_ADDR                 peer_bda;
490     BOOLEAN                 privacy_enable;
491 
492 }tBTA_DM_API_ENABLE_PRIVACY;
493 
494 typedef struct
495 {
496     BT_HDR                  hdr;
497     BOOLEAN                 privacy_enable;
498 }tBTA_DM_API_LOCAL_PRIVACY;
499 
500 /* set scan parameter for BLE connections */
501 typedef struct
502 {
503     BT_HDR                  hdr;
504     UINT16                  scan_int;
505     UINT16                  scan_window;
506 }tBTA_DM_API_BLE_SCAN_PARAMS;
507 
508 /* Data type for start/stop observe */
509 typedef struct
510 {
511     BT_HDR                  hdr;
512     BOOLEAN                 start;
513     UINT16                  duration;
514     tBTA_DM_SEARCH_CBACK * p_cback;
515 }tBTA_DM_API_BLE_OBSERVE;
516 
517 /* set adv parameter for BLE advertising */
518 typedef struct
519 {
520     BT_HDR                  hdr;
521     UINT16                  adv_int_min;
522     UINT16                  adv_int_max;
523     tBLE_BD_ADDR            *p_dir_bda;
524 }tBTA_DM_API_BLE_ADV_PARAMS;
525 
526 typedef struct
527 {
528     BT_HDR                  hdr;
529     UINT16                  data_mask;
530     tBTA_BLE_ADV_DATA       *p_adv_cfg;
531 }tBTA_DM_API_SET_ADV_CONFIG;
532 
533 #endif
534 
535 typedef struct
536 {
537     BT_HDR                  hdr;
538     BOOLEAN                 enable_or_disable;
539 }tBTA_DM_API_SET_AFH_CHANNEL_ASSESSMENT;
540 
541 #if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
542 /* data type for BTA_DM_API_UPDATE_EIR_UUID_EVT */
543 typedef struct
544 {
545     BT_HDR          hdr;
546     BOOLEAN         is_add;
547     tBT_UUID        uuid;
548 }tBTA_DM_API_UPDATE_EIR_UUID;
549 #endif
550 
551 #if (BTM_EIR_SERVER_INCLUDED == TRUE)
552 /* data type for BTA_DM_API_SET_EIR_CONFIG_EVT */
553 typedef struct
554 {
555     BT_HDR              hdr;
556     tBTA_DM_EIR_CONF    *p_eir_cfg;
557 }tBTA_DM_API_SET_EIR_CONFIG;
558 #endif
559 
560 /* data type for BTA_DM_API_REMOVE_ACL_EVT */
561 typedef struct
562 {
563     BT_HDR      hdr;
564     BD_ADDR     bd_addr;
565     BOOLEAN     remove_dev;
566 }tBTA_DM_API_REMOVE_ACL;
567 
568 /* union of all data types */
569 typedef union
570 {
571     /* GKI event buffer header */
572     BT_HDR              hdr;
573     tBTA_DM_API_ENABLE  enable;
574 
575     tBTA_DM_API_SET_NAME set_name;
576 
577     tBTA_DM_API_SET_VISIBILITY set_visibility;
578 
579     tBTA_DM_API_SET_AFH_CHANNELS_EVT set_afhchannels;
580 
581     tBTA_DM_API_VENDOR_SPECIFIC_COMMAND vendor_command;
582 
583     tBTA_DM_API_ADD_DEVICE  add_dev;
584 
585     tBTA_DM_API_REMOVE_DEVICE remove_dev;
586 
587     tBTA_DM_API_SEARCH search;
588 
589     tBTA_DM_API_DISCOVER discover;
590 
591     tBTA_DM_API_BOND bond;
592 
593     tBTA_DM_API_BOND_CANCEL bond_cancel;
594 
595     tBTA_DM_API_PIN_REPLY pin_reply;
596     tBTA_DM_API_LINK_POLICY link_policy;
597 
598     tBTA_DM_API_LOC_OOB     loc_oob;
599     tBTA_DM_API_CONFIRM     confirm;
600     tBTA_DM_API_PASKY_CANCEL passkey_cancel;
601     tBTA_DM_CI_IO_REQ       ci_io_req;
602     tBTA_DM_CI_RMT_OOB      ci_rmt_oob;
603 
604     tBTA_DM_API_AUTH_REPLY auth_reply;
605 
606     tBTA_DM_REM_NAME rem_name;
607 
608     tBTA_DM_DISC_RESULT disc_result;
609 
610     tBTA_DM_INQUIRY_CMPL inq_cmpl;
611 
612     tBTA_DM_SDP_RESULT sdp_event;
613 
614     tBTA_API_DM_SIG_STRENGTH sig_strength;
615 
616     tBTA_API_DM_TX_INQPWR   tx_inq_pwr;
617 
618     tBTA_DM_ACL_CHANGE  acl_change;
619 
620     tBTA_DM_PM_BTM_STATUS pm_status;
621 
622     tBTA_DM_PM_TIMER pm_timer;
623 
624     tBTA_DM_API_DI_DISC     di_disc;
625 
626     tBTA_DM_API_EXECUTE_CBACK exec_cback;
627 
628     tBTA_DM_API_SET_ENCRYPTION     set_encryption;
629 
630 #if BLE_INCLUDED == TRUE
631     tBTA_DM_API_ADD_BLEKEY              add_ble_key;
632     tBTA_DM_API_ADD_BLE_DEVICE          add_ble_device;
633     tBTA_DM_API_PASSKEY_REPLY           ble_passkey_reply;
634     tBTA_DM_API_BLE_SEC_GRANT           ble_sec_grant;
635     tBTA_DM_API_BLE_SET_BG_CONN_TYPE    ble_set_bd_conn_type;
636     tBTA_DM_API_BLE_CONN_PARAMS         ble_set_conn_params;
637     tBTA_DM_API_BLE_SCAN_PARAMS         ble_set_scan_params;
638     tBTA_DM_API_BLE_OBSERVE             ble_observe;
639     tBTA_DM_API_ENABLE_PRIVACY          ble_remote_privacy;
640     tBTA_DM_API_LOCAL_PRIVACY           ble_local_privacy;
641     tBTA_DM_API_BLE_ADV_PARAMS          ble_set_adv_params;
642     tBTA_DM_API_SET_ADV_CONFIG          ble_set_adv_data;
643 #endif
644 
645     tBTA_DM_API_SET_AFH_CHANNEL_ASSESSMENT set_afh_channel_assessment;
646 
647 #if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
648     tBTA_DM_API_UPDATE_EIR_UUID     update_eir_uuid;
649 #endif
650 #if (BTM_EIR_SERVER_INCLUDED == TRUE)
651     tBTA_DM_API_SET_EIR_CONFIG          set_eir_cfg;
652 #endif
653     tBTA_DM_API_REMOVE_ACL              remove_acl;
654 
655 } tBTA_DM_MSG;
656 
657 
658 #define BTA_DM_NUM_PEER_DEVICE 7
659 
660 #define BTA_DM_NOT_CONNECTED  0
661 #define BTA_DM_CONNECTED      1
662 #define BTA_DM_UNPAIRING      2
663 typedef UINT8 tBTA_DM_CONN_STATE;
664 
665 
666 #define BTA_DM_DI_NONE          0x00       /* nothing special */
667 #define BTA_DM_DI_USE_SSR       0x10       /* set this bit if ssr is supported for this link */
668 #define BTA_DM_DI_AV_ACTIVE     0x20       /* set this bit if AV is active for this link */
669 #define BTA_DM_DI_SET_SNIFF     0x01       /* set this bit if call BTM_SetPowerMode(sniff) */
670 #define BTA_DM_DI_INT_SNIFF     0x02       /* set this bit if call BTM_SetPowerMode(sniff) & enter sniff mode */
671 #define BTA_DM_DI_ACP_SNIFF     0x04       /* set this bit if peer init sniff */
672 typedef UINT8 tBTA_DM_DEV_INFO;
673 
674 typedef struct
675 {
676     BD_ADDR                     peer_bdaddr;
677     UINT16                      link_policy;
678     tBTA_DM_CONN_STATE          conn_state;
679     tBTA_PREF_ROLES             pref_role;
680     BOOLEAN                     in_use;
681     tBTA_DM_DEV_INFO            info;
682 #if (BTM_SSR_INCLUDED == TRUE)
683     tBTM_PM_STATUS              prev_low;   /* previous low power mode used */
684 #endif
685     tBTA_DM_PM_ACTTION          pm_mode_attempted;
686     tBTA_DM_PM_ACTTION          pm_mode_failed;
687     BOOLEAN                     remove_dev_pending;
688 
689 } tBTA_DM_PEER_DEVICE;
690 
691 
692 
693 /* structure to store list of
694   active connections */
695 typedef struct
696 {
697     tBTA_DM_PEER_DEVICE    peer_device[BTA_DM_NUM_PEER_DEVICE];
698     UINT8                  count;
699 
700 } tBTA_DM_ACTIVE_LINK;
701 
702 
703 typedef struct
704 {
705     BD_ADDR                 peer_bdaddr;
706     tBTA_SYS_ID             id;
707     UINT8                   app_id;
708     tBTA_SYS_CONN_STATUS    state;
709 
710 
711 } tBTA_DM_SRVCS;
712 
713 #define BTA_DM_NUM_CONN_SRVS   5
714 
715 typedef struct
716 {
717 
718     UINT8 count;
719     tBTA_DM_SRVCS  conn_srvc[BTA_DM_NUM_CONN_SRVS];
720 
721 }  tBTA_DM_CONNECTED_SRVCS;
722 
723 typedef struct
724 {
725     TIMER_LIST_ENT          timer;
726     BD_ADDR                 peer_bdaddr;
727     BOOLEAN                 in_use;
728 
729 } tBTA_PM_TIMER;
730 
731 extern tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
732 
733 #define BTA_DM_NUM_PM_TIMER 3
734 
735 /* DM control block */
736 typedef struct
737 {
738     BOOLEAN                     is_bta_dm_active;
739     tBTA_DM_ACTIVE_LINK         device_list;
740     tBTA_DM_SEC_CBACK           *p_sec_cback;
741     TIMER_LIST_ENT              signal_strength_timer;
742     tBTA_SIG_STRENGTH_MASK      signal_strength_mask;
743     UINT16                      state;
744     UINT16                      signal_strength_period;
745     BOOLEAN                     disabling;
746     TIMER_LIST_ENT              disable_timer;
747     UINT32                      wbt_sdp_handle;          /* WIDCOMM Extensions SDP record handle */
748     UINT8                       wbt_scn;                 /* WIDCOMM Extensions SCN */
749     UINT8                       num_master_only;
750     UINT8                       pm_id;
751     tBTA_PM_TIMER               pm_timer[BTA_DM_NUM_PM_TIMER];
752     UINT32                      role_policy_mask;   /* the bits set indicates the modules that wants to remove role switch from the default link policy */
753     UINT16                      cur_policy;         /* current default link policy */
754     UINT16                      rs_event;           /* the event waiting for role switch */
755     UINT8                       cur_av_count;       /* current AV connecions */
756     BOOLEAN                     disable_pair_mode;          /* disable pair mode or not */
757     BOOLEAN                     conn_paired_only;   /* allow connectable to paired device only or not */
758     tBTA_DM_API_SEARCH          search_msg;
759     UINT16                      page_scan_interval;
760     UINT16                      page_scan_window;
761     UINT16                      inquiry_scan_interval;
762     UINT16                      inquiry_scan_window;
763 
764     /* Storage for pin code request parameters */
765     BD_ADDR                     pin_bd_addr;
766     DEV_CLASS                   pin_dev_class;
767     tBTA_DM_SEC_EVT             pin_evt;
768     UINT32          num_val;        /* the numeric value for comparison. If just_works, do not show this number to UI */
769     BOOLEAN         just_works;     /* TRUE, if "Just Works" association model */
770 #if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )
771     /* store UUID list for EIR */
772     TIMER_LIST_ENT              app_ready_timer;
773     UINT32                      eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE];
774 #if (BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
775     tBT_UUID                    custom_uuid[BTA_EIR_SERVER_NUM_CUSTOM_UUID];
776 #endif
777 
778 #endif
779 
780     tBTA_DM_ENCRYPT_CBACK      *p_encrypt_cback;
781     tBTA_DM_BLE_SEC_ACT         sec_act;
782     TIMER_LIST_ENT              switch_delay_timer;
783 
784 } tBTA_DM_CB;
785 
786 #ifndef BTA_DM_SDP_DB_SIZE
787 #define BTA_DM_SDP_DB_SIZE 250
788 #endif
789 
790 /* DM search control block */
791 typedef struct
792 {
793 
794     tBTA_DM_SEARCH_CBACK * p_search_cback;
795     tBTM_INQ_INFO        * p_btm_inq_info;
796     tBTA_SERVICE_MASK      services;
797     tBTA_SERVICE_MASK      services_to_search;
798     tBTA_SERVICE_MASK      services_found;
799     tSDP_DISCOVERY_DB    * p_sdp_db;
800     UINT16                 state;
801     BD_ADDR                peer_bdaddr;
802     BOOLEAN                name_discover_done;
803     BD_NAME                peer_name;
804     TIMER_LIST_ENT         search_timer;
805     UINT8                  service_index;
806     tBTA_DM_MSG          * p_search_queue;   /* search or discover commands during search cancel stored here */
807     BOOLEAN                wait_disc;
808     BOOLEAN                sdp_results;
809     tSDP_UUID              uuid;
810     UINT8                  peer_scn;
811     BOOLEAN                sdp_search;
812 
813 #if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
814     tBTA_DM_SEARCH_CBACK * p_scan_cback;
815 #if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
816     tBTA_GATTC_IF          client_if;
817     UINT8                  num_uuid;
818     tBT_UUID               *p_srvc_uuid;
819     UINT8                  uuid_to_search;
820     BOOLEAN                gatt_disc_active;
821     UINT16                 conn_id;
822     UINT8 *                 p_ble_rawdata;
823     UINT32                 ble_raw_size;
824     UINT32                 ble_raw_used;
825     TIMER_LIST_ENT         gatt_close_timer;
826     BD_ADDR                pending_close_bda;
827 #endif
828 #endif
829 
830 
831 } tBTA_DM_SEARCH_CB;
832 
833 /* DI control block */
834 typedef struct
835 {
836     tSDP_DISCOVERY_DB    * p_di_db;     /* pointer to the DI discovery database */
837     UINT8               di_num;         /* total local DI record number */
838     UINT32              di_handle[BTA_DI_NUM_MAX];  /* local DI record handle, the first one is primary record */
839 }tBTA_DM_DI_CB;
840 
841 /* DM search state */
842 enum
843 {
844 
845     BTA_DM_SEARCH_IDLE,
846     BTA_DM_SEARCH_ACTIVE,
847     BTA_DM_SEARCH_CANCELLING,
848     BTA_DM_DISCOVER_ACTIVE
849 
850 };
851 
852 
853 
854 typedef struct
855 {
856     DEV_CLASS      dev_class;          /* local device class */
857     UINT16         policy_settings;    /* link policy setting hold, sniff, park, MS switch */
858     UINT16         page_timeout;       /* timeout for page in slots */
859     UINT16         link_timeout;       /* link supervision timeout in slots */
860     BOOLEAN        avoid_scatter;      /* TRUE to avoid scatternet when av is streaming (be the master) */
861 
862 } tBTA_DM_CFG;
863 
864 extern const UINT32 bta_service_id_to_btm_srv_id_lkup_tbl[];
865 
866 extern const tBTA_DM_CFG bta_dm_cfg;
867 
868 
869 typedef struct
870 {
871     UINT8   id;
872     UINT8   app_id;
873     UINT8   cfg;
874 
875 } tBTA_DM_RM ;
876 
877 extern tBTA_DM_CFG *p_bta_dm_cfg;
878 extern tBTA_DM_RM *p_bta_dm_rm_cfg;
879 
880 typedef struct
881 {
882 
883   UINT8  id;
884   UINT8  app_id;
885   UINT8  spec_idx;  /* index of spec table to use */
886 
887 } tBTA_DM_PM_CFG;
888 
889 
890 typedef struct
891 {
892 
893   tBTA_DM_PM_ACTTION  power_mode;
894   UINT16              timeout;
895 
896 } tBTA_DM_PM_ACTN;
897 
898 typedef struct
899 {
900 
901   UINT8  allow_mask;         /* mask of sniff/hold/park modes to allow */
902 #if (BTM_SSR_INCLUDED == TRUE)
903   UINT8  ssr;                /* set SSR on conn open/unpark */
904 #endif
905   tBTA_DM_PM_ACTN actn_tbl [BTA_DM_PM_NUM_EVTS][2];
906 
907 } tBTA_DM_PM_SPEC;
908 
909 typedef struct
910 {
911     UINT16      max_lat;
912     UINT16      min_rmt_to;
913     UINT16      min_loc_to;
914 } tBTA_DM_SSR_SPEC;
915 
916 typedef struct
917 {
918    UINT16 manufacturer;
919    UINT16 lmp_sub_version;
920    UINT8 lmp_version;
921 }tBTA_DM_LMP_VER_INFO;
922 
923 extern tBTA_DM_PM_CFG *p_bta_dm_pm_cfg;
924 extern tBTA_DM_PM_SPEC *p_bta_dm_pm_spec;
925 extern tBTM_PM_PWR_MD *p_bta_dm_pm_md;
926 #if (BTM_SSR_INCLUDED == TRUE)
927 extern tBTA_DM_SSR_SPEC *p_bta_dm_ssr_spec;
928 #endif
929 
930 #if ( BTM_EIR_SERVER_INCLUDED == TRUE )
931 /* update dynamic BRCM Aware EIR data */
932 extern const tBTA_DM_EIR_CONF bta_dm_eir_cfg;
933 extern tBTA_DM_EIR_CONF *p_bta_dm_eir_cfg;
934 #endif
935 
936 /* DM control block */
937 #if BTA_DYNAMIC_MEMORY == FALSE
938 extern tBTA_DM_CB  bta_dm_cb;
939 #else
940 extern tBTA_DM_CB *bta_dm_cb_ptr;
941 #define bta_dm_cb (*bta_dm_cb_ptr)
942 #endif
943 
944 /* DM search control block */
945 #if BTA_DYNAMIC_MEMORY == FALSE
946 extern tBTA_DM_SEARCH_CB  bta_dm_search_cb;
947 #else
948 extern tBTA_DM_SEARCH_CB *bta_dm_search_cb_ptr;
949 #define bta_dm_search_cb (*bta_dm_search_cb_ptr)
950 #endif
951 
952 /* DI control block */
953 #if BTA_DYNAMIC_MEMORY == FALSE
954 extern tBTA_DM_DI_CB  bta_dm_di_cb;
955 #else
956 extern tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
957 #define bta_dm_di_cb (*bta_dm_di_cb_ptr)
958 #endif
959 
960 extern BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg);
961 extern void bta_dm_sm_disable( void );
962 extern BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg);
963 extern void bta_dm_search_sm_disable( void );
964 
965 
966 extern void bta_dm_enable (tBTA_DM_MSG *p_data);
967 extern void bta_dm_disable (tBTA_DM_MSG *p_data);
968 extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data);
969 extern void bta_dm_set_visibility (tBTA_DM_MSG *p_data);
970 extern void bta_dm_set_afhchannels (tBTA_DM_MSG *p_data);
971 extern void bta_dm_vendor_spec_command(tBTA_DM_MSG *p_data);
972 extern void bta_dm_bond (tBTA_DM_MSG *p_data);
973 extern void bta_dm_bond_cancel (tBTA_DM_MSG *p_data);
974 extern void bta_dm_pin_reply (tBTA_DM_MSG *p_data);
975 extern void bta_dm_link_policy (tBTA_DM_MSG *p_data);
976 extern void bta_dm_auth_reply (tBTA_DM_MSG *p_data);
977 extern void bta_dm_signal_strength(tBTA_DM_MSG *p_data);
978 extern void bta_dm_tx_inqpower(tBTA_DM_MSG *p_data);
979 extern void bta_dm_acl_change(tBTA_DM_MSG *p_data);
980 extern void bta_dm_add_device (tBTA_DM_MSG *p_data);
981 extern void bta_dm_remove_device (tBTA_DM_MSG *p_data);
982 extern void bta_dm_close_acl(tBTA_DM_MSG *p_data);
983 
984 
985 extern void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data);
986 extern void bta_dm_pm_timer(tBTA_DM_MSG *p_data);
987 extern void bta_dm_add_ampkey (tBTA_DM_MSG *p_data);
988 
989 #if BLE_INCLUDED == TRUE
990 extern void bta_dm_add_blekey (tBTA_DM_MSG *p_data);
991 extern void bta_dm_add_ble_device (tBTA_DM_MSG *p_data);
992 extern void bta_dm_ble_passkey_reply (tBTA_DM_MSG *p_data);
993 extern void bta_dm_security_grant (tBTA_DM_MSG *p_data);
994 extern void bta_dm_ble_set_bg_conn_type (tBTA_DM_MSG *p_data);
995 extern void bta_dm_ble_set_conn_params (tBTA_DM_MSG *p_data);
996 extern void bta_dm_ble_set_scan_params (tBTA_DM_MSG *p_data);
997 extern void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data);
998 extern void bta_dm_ble_observe (tBTA_DM_MSG *p_data);
999 extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data);
1000 extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
1001 extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data);
1002 extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data);
1003 
1004 #endif
1005 extern void bta_dm_set_encryption(tBTA_DM_MSG *p_data);
1006 extern void bta_dm_confirm(tBTA_DM_MSG *p_data);
1007 extern void bta_dm_passkey_cancel(tBTA_DM_MSG *p_data);
1008 #if (BTM_OOB_INCLUDED == TRUE)
1009 extern void bta_dm_loc_oob(tBTA_DM_MSG *p_data);
1010 extern void bta_dm_ci_io_req_act(tBTA_DM_MSG *p_data);
1011 extern void bta_dm_ci_rmt_oob_act(tBTA_DM_MSG *p_data);
1012 #endif /* BTM_OOB_INCLUDED */
1013 
1014 extern void bta_dm_init_pm(void);
1015 extern void bta_dm_disable_pm(void);
1016 
1017 extern void bta_dm_search_start (tBTA_DM_MSG *p_data);
1018 extern void bta_dm_search_cancel (tBTA_DM_MSG *p_data);
1019 extern void bta_dm_discover (tBTA_DM_MSG *p_data);
1020 extern void bta_dm_di_disc (tBTA_DM_MSG *p_data);
1021 extern void bta_dm_inq_cmpl (tBTA_DM_MSG *p_data);
1022 extern void bta_dm_rmt_name (tBTA_DM_MSG *p_data);
1023 extern void bta_dm_sdp_result (tBTA_DM_MSG *p_data);
1024 extern void bta_dm_search_cmpl (tBTA_DM_MSG *p_data);
1025 extern void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data);
1026 extern void bta_dm_disc_result (tBTA_DM_MSG *p_data);
1027 extern void bta_dm_search_result (tBTA_DM_MSG *p_data);
1028 extern void bta_dm_discovery_cmpl (tBTA_DM_MSG *p_data);
1029 extern void bta_dm_queue_search (tBTA_DM_MSG *p_data);
1030 extern void bta_dm_queue_disc (tBTA_DM_MSG *p_data);
1031 extern void bta_dm_search_clear_queue (tBTA_DM_MSG *p_data);
1032 extern void bta_dm_search_cancel_cmpl (tBTA_DM_MSG *p_data);
1033 extern void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data);
1034 extern void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data);
1035 extern void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data);
1036 extern tBTA_DM_PEER_DEVICE * bta_dm_find_peer_device(BD_ADDR peer_addr);
1037 
1038 extern void bta_dm_pm_active(BD_ADDR peer_addr);
1039 
1040 #if ( BTM_EIR_SERVER_INCLUDED == TRUE )
1041 void bta_dm_eir_update_uuid(UINT16 uuid16, BOOLEAN adding);
1042 #else
1043 #define bta_dm_eir_update_uuid(x, y)
1044 #endif
1045 
1046 #if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
1047 extern void bta_dm_update_eir_uuid (tBTA_DM_MSG *p_data);
1048 #endif
1049 #if (BTM_EIR_SERVER_INCLUDED == TRUE)
1050 extern void bta_dm_set_eir_config (tBTA_DM_MSG *p_data);
1051 #endif
1052 extern void bta_dm_enable_test_mode(tBTA_DM_MSG *p_data);
1053 extern void bta_dm_disable_test_mode(tBTA_DM_MSG *p_data);
1054 extern void bta_dm_execute_callback(tBTA_DM_MSG *p_data);
1055 
1056 extern void bta_dm_set_afh_channel_assesment(tBTA_DM_MSG *p_data);
1057 
1058 #endif /* BTA_DM_INT_H */
1059 
1060