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