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