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