Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2009-2013 Broadcom Corporation
      4  *
      5  *  Licensed under the Apache License, Version 2.0 (the "License");
      6  *  you may not use this file except in compliance with the License.
      7  *  You may obtain a copy of the License at:
      8  *
      9  *  http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  ******************************************************************************/
     18 
     19 #ifndef GAP_API_H
     20 #define GAP_API_H
     21 
     22 #include "profiles_api.h"
     23 #include "btm_api.h"
     24 #include "l2c_api.h"
     25 
     26 /*****************************************************************************
     27 **  Constants
     28 *****************************************************************************/
     29 
     30 /*** GAP Error and Status Codes ***/
     31 #define GAP_UNSUPPORTED     (GAP_ERR_GRP + 0x01)    /* Unsupported call */
     32 #define GAP_EOINQDB         (GAP_ERR_GRP + 0x02)    /* End of inquiry database marker */
     33 #define GAP_ERR_BUSY        (GAP_ERR_GRP + 0x03)    /* The requested function was busy */
     34 #define GAP_ERR_NO_CTRL_BLK (GAP_ERR_GRP + 0x04)    /* No control blocks available */
     35 #define GAP_ERR_STARTING_CMD (GAP_ERR_GRP + 0x05)   /* Error occurred while initiating the command */
     36 #define GAP_NO_BDADDR_REC   (GAP_ERR_GRP + 0x06)    /* No Inquiry DB record for BD_ADDR */
     37 #define GAP_ERR_ILL_MODE    (GAP_ERR_GRP + 0x07)    /* An illegal mode parameter was detected */
     38 #define GAP_ERR_ILL_INQ_TIME (GAP_ERR_GRP + 0x08)   /* An illegal time parameter was detected */
     39 #define GAP_ERR_ILL_PARM     (GAP_ERR_GRP + 0x09)   /* An illegal parameter was detected */
     40 #define GAP_ERR_REM_NAME    (GAP_ERR_GRP + 0x0a)    /* Error starting the remote device name request */
     41 #define GAP_CMD_INITIATED   (GAP_ERR_GRP + 0x0b)    /* The GAP command was started (result pending) */
     42 #define GAP_DEVICE_NOT_UP   (GAP_ERR_GRP + 0x0c)    /* The device was not up; the request was not executed */
     43 #define GAP_BAD_BD_ADDR     (GAP_ERR_GRP + 0x0d)    /* The bd addr passed in was not found or invalid */
     44 
     45 #define GAP_ERR_BAD_HANDLE  (GAP_ERR_GRP + 0x0e)    /* Bad GAP handle                       */
     46 #define GAP_ERR_BUF_OFFSET  (GAP_ERR_GRP + 0x0f)    /* Buffer offset invalid                */
     47 #define GAP_ERR_BAD_STATE   (GAP_ERR_GRP + 0x10)    /* Connection is in invalid state       */
     48 #define GAP_NO_DATA_AVAIL   (GAP_ERR_GRP + 0x11)    /* No data available                    */
     49 #define GAP_ERR_CONGESTED   (GAP_ERR_GRP + 0x12)    /* BT stack is congested                */
     50 #define GAP_ERR_SECURITY    (GAP_ERR_GRP + 0x13)    /* Security failed                      */
     51 
     52 #define GAP_ERR_PROCESSING  (GAP_ERR_GRP + 0x14)    /* General error processing BTM request */
     53 #define GAP_ERR_TIMEOUT     (GAP_ERR_GRP + 0x15)    /* Timeout occurred while processing cmd */
     54 
     55 /** GAP Events - definitions of GAP return events ***/
     56 #define GAP_EVT_INQUIRY_RESULTS     0x0001
     57 #define GAP_EVT_INQUIRY_COMPLETE    0x0002
     58 #define GAP_EVT_DISCOVERY_COMPLETE  0x0003
     59 #define GAP_EVT_REM_NAME_COMPLETE   0x0004
     60 #define GAP_EVT_FIND_ADDR_COMPLETE  0x0005
     61 
     62 #define GAP_EVT_CONN_OPENED         0x0100
     63 #define GAP_EVT_CONN_CLOSED         0x0101
     64 #define GAP_EVT_CONN_DATA_AVAIL     0x0102
     65 #define GAP_EVT_CONN_CONGESTED      0x0103
     66 #define GAP_EVT_CONN_UNCONGESTED    0x0104
     67 
     68 /* Values for 'chan_mode_mask' field */
     69 /* GAP_ConnOpen() - optional channels to negotiate */
     70 #define GAP_FCR_CHAN_OPT_BASIC      L2CAP_FCR_CHAN_OPT_BASIC
     71 #define GAP_FCR_CHAN_OPT_ERTM       L2CAP_FCR_CHAN_OPT_ERTM
     72 #define GAP_FCR_CHAN_OPT_STREAM     L2CAP_FCR_CHAN_OPT_STREAM
     73 
     74 /*** discovery of devices ***/
     75 #define GAP_INQUIRY_NONE            BTM_INQUIRY_NONE
     76 #define GAP_GENERAL_INQUIRY         BTM_GENERAL_INQUIRY
     77 #define GAP_LIMITED_INQUIRY         BTM_LIMITED_INQUIRY
     78 
     79 #if BLE_INCLUDED == TRUE
     80 #define GAP_BLE_INQUIRY_NONE        BTM_BLE_INQUIRY_NONE
     81 #define GAP_BLE_GENERAL_INQUIRY     BTM_BLE_GENERAL_INQUIRY
     82 #define GAP_BLE_LIMITED_INQUIRY     BTM_BLE_LIMITED_INQUIRY
     83 #endif
     84 
     85 /*** discoverable modes ***/
     86 #define GAP_NON_DISCOVERABLE        BTM_NON_DISCOVERABLE
     87 #define GAP_LIMITED_DISCOVERABLE    BTM_LIMITED_DISCOVERABLE
     88 #define GAP_GENERAL_DISCOVERABLE    BTM_GENERAL_DISCOVERABLE
     89 
     90 /*** Inquiry Filter Condition types  (The values are defined in btm_api.h) ***/
     91 #define GAP_CLR_INQUIRY_FILTER      BTM_CLR_INQUIRY_FILTER          /* Inquiry Filtering is turned off */
     92 #define GAP_FILTER_COND_DEVICE_CLASS BTM_FILTER_COND_DEVICE_CLASS    /* Filter on device class */
     93 #define GAP_FILTER_COND_BD_ADDR     BTM_FILTER_COND_BD_ADDR         /* Filter on device addr */
     94 
     95 /*** connectability ***/
     96 #define GAP_NON_CONNECTABLE         BTM_NON_CONNECTABLE
     97 #define GAP_CONNECTABLE             BTM_CONNECTABLE
     98 
     99 /*** security features ***/
    100 #define GAP_DISALLOW_PAIRING        0
    101 #define GAP_ALLOW_PAIRING           1
    102 
    103 /*** class of device settings ***/
    104 #define GAP_SET_COD_MAJOR_MINOR     0x01
    105 #define GAP_SET_COD_SERVICE_CLASS   0x02 /* only set the bits in the input */
    106 #define GAP_CLR_COD_SERVICE_CLASS   0x04
    107 #define GAP_SET_COD_ALL             0x08 /* take service class as the input (may clear some set bits!!) */
    108 #define GAP_INIT_COD                0x0a
    109 
    110 /*** used in connection variables and functions ***/
    111 #define GAP_INVALID_HANDLE      0xFFFF
    112 
    113 /* This is used to change the criteria for AMP  */
    114 #define GAP_PROTOCOL_ID         (UUID_PROTOCOL_UDP)
    115 
    116 /* slave preferred parameter, minimum connection interval */
    117 #ifndef GAP_SL_CONN_INT_MIN
    118 #define GAP_SL_CONN_INT_MIN     6
    119 #endif
    120 /* slave preferred parameter, maximum connection interval */
    121 #ifndef GAP_SL_CONN_INT_MAX
    122 #define GAP_SL_CONN_INT_MAX     20
    123 #endif
    124 /* slave preferred parameter */
    125 #ifndef GAP_SL_LATENCY
    126 #define GAP_SL_LATENCY     2
    127 #endif
    128 
    129 #ifndef GAP_BLE_PRIVACY_RECONN_ADDR_PERM
    130 #define GAP_BLE_PRIVACY_RECONN_ADDR_PERM        (GATT_PERM_READ|GATT_PERM_WRITE)
    131 #endif
    132 
    133 #ifndef  GAP_PREFER_CONN_INT_MAX
    134 #define  GAP_PREFER_CONN_INT_MAX         BTM_BLE_CONN_INT_MIN
    135 #endif
    136 
    137 #ifndef  GAP_PREFER_CONN_INT_MIN
    138 #define  GAP_PREFER_CONN_INT_MIN         BTM_BLE_CONN_INT_MIN
    139 #endif
    140 
    141 #ifndef  GAP_PREFER_CONN_LATENCY
    142 #define  GAP_PREFER_CONN_LATENCY         0
    143 #endif
    144 
    145 #ifndef  GAP_PREFER_CONN_SP_TOUT
    146 #define  GAP_PREFER_CONN_SP_TOUT         2000
    147 #endif
    148 
    149 #if BLE_INCLUDED == TRUE
    150 #ifndef GAP_TRANSPORT_SUPPORTED
    151 #define GAP_TRANSPORT_SUPPORTED GATT_TRANSPORT_LE_BR_EDR
    152 #endif
    153 #endif
    154 /*****************************************************************************
    155 **  Type Definitions
    156 *****************************************************************************/
    157 /*
    158 ** Callback function for connection services
    159 */
    160 typedef void (tGAP_CONN_CALLBACK) (UINT16 gap_handle, UINT16 event);
    161 
    162 /*
    163 ** Define the callback function prototypes.  Parameters are specific
    164 ** to each event and are described below
    165 */
    166 typedef void (tGAP_CALLBACK) (UINT16 event, void *p_data);
    167 
    168 typedef tBTM_REMOTE_DEV_NAME    tGAP_REMOTE_DEV_NAME;   /* see btm_api.h */
    169 typedef tBTM_INQ_PARMS          tGAP_INQ_PARMS;         /* see btm_api.h */
    170 typedef tBTM_INQ_RESULTS        tGAP_INQ_RESULTS;       /* see btm_api.h */
    171 
    172 /* Inquiry results structure */
    173 typedef struct
    174 {
    175     UINT16  status;
    176     UINT8   num_results;
    177 } tGAP_INQ_CMPL;
    178 
    179 /* Definition of the GAP_FindAddrByName results structure */
    180 typedef struct
    181 {
    182     UINT16       status;
    183     BD_ADDR      bd_addr;
    184     tBTM_BD_NAME devname;
    185 } tGAP_FINDADDR_RESULTS;
    186 
    187 /** for GAP_SetDeviceClass() **/
    188 /* Define Class of Device related values
    189  *
    190  * >>> changes to this type need to also be made to tHSP_COD in hsp2_int.h
    191  */
    192 typedef struct
    193 {
    194     UINT8       minor;
    195     UINT8       major;
    196     UINT16      service;
    197 } tGAP_COD;
    198 
    199 /*** Constants and functions for device features ***/
    200 typedef struct
    201 {
    202     UINT8   lmp_version;
    203     UINT16  mfc_name;
    204     UINT16  lmp_subversion;
    205 } tGAP_LMP_VERSION;
    206 
    207 typedef struct
    208 {
    209     UINT8   lmp_features[8];
    210 } tGAP_LMP_FEATURES;
    211 
    212 typedef struct
    213 {
    214     UINT16      int_min;
    215     UINT16      int_max;
    216     UINT16      latency;
    217     UINT16      sp_tout;
    218 }tGAP_BLE_PREF_PARAM;
    219 
    220 typedef union
    221 {
    222     tGAP_BLE_PREF_PARAM     conn_param;
    223     BD_ADDR                 reconn_bda;
    224     UINT16                  icon;
    225     UINT8                   *p_dev_name;
    226     UINT8                   privacy;
    227 
    228 }tGAP_BLE_ATTR_VALUE;
    229 
    230 typedef void (tGAP_BLE_DEV_NAME_CBACK)(BOOLEAN status, BD_ADDR addr, UINT16 length, char *p_name);
    231 
    232 typedef void (tGAP_BLE_RECONN_ADDR_CBACK)(BOOLEAN status, BD_ADDR addr, BD_ADDR reconn_bda);
    233 
    234 /*****************************************************************************
    235 **  External Function Declarations
    236 *****************************************************************************/
    237 #ifdef __cplusplus
    238 extern "C"
    239 {
    240 #endif
    241 
    242 /*******************************************************************************
    243 **
    244 ** Function         GAP_SetDiscoverableMode
    245 **
    246 ** Description      This function is called to allow or disallow a service to
    247 **                  discovered (Inquiry Scans).
    248 **
    249 ** Returns          BT_PASS (0) if successful,
    250 **                  GAP_ERR_ILL_PARM if a bad parameter is detected,
    251 **                  GAP_DEVICE_NOT_UP if the device is not active,
    252 **                  GAP_ERR_PROCESSING if not enough resources to carry out request
    253 **
    254 *******************************************************************************/
    255 GAP_API extern UINT16 GAP_SetDiscoverableMode (UINT16 mode, UINT16 duration,
    256                                                UINT16 interval);
    257 
    258 /*******************************************************************************
    259 **
    260 ** Function         GAP_ReadDiscoverableMode
    261 **
    262 ** Description      This function is called to retrieve the current discoverable
    263 **                  mode for the local device.
    264 **
    265 ** Returns          GAP_NON_DISCOVERABLE, GAP_LIMITED_DISCOVERABLE, or
    266 **                  GAP_GENERAL_DISCOVERABLE
    267 **
    268 *******************************************************************************/
    269 GAP_API extern UINT16 GAP_ReadDiscoverableMode (UINT16 *duration, UINT16 *interval);
    270 
    271 /*******************************************************************************
    272 **
    273 ** Function         GAP_StartInquiry
    274 **
    275 ** Description      This function initiates a single inquiry.
    276 **
    277 ** Returns          BT_PASS (0) if successful,
    278 **                  GAP_ERR_ILL_MODE if a bad mode parameter was passed
    279 **                  GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed
    280 **                  GAP_ERR_NO_CTRL_BLK if out of control blocks
    281 **                  GAP_ERR_ILL_PARM if a bad parameter was detected in BTM
    282 **                  GAP_ERR_BUSY if the device already has an iquiry active
    283 **                  GAP_DEVICE_NOT_UP if the device is not initialized yet
    284 **                  GAP_ERR_PROCESSING if any other BTM error was returned
    285 **
    286 *******************************************************************************/
    287 GAP_API extern UINT16 GAP_StartInquiry (tGAP_INQ_PARMS *p_inq_parms,
    288                                         tGAP_CALLBACK *p_results_cb,
    289                                         tGAP_CALLBACK *p_cmpl_cb);
    290 
    291 /*******************************************************************************
    292 **
    293 ** Function         GAP_StartPeriodicInquiry
    294 **
    295 ** Description      This function initiates a periodic inquiry.
    296 **
    297 ** Returns          BT_PASS (0) if successful,
    298 **                  GAP_ERR_ILL_MODE if a bad mode parameter was passed
    299 **                  GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed
    300 **                  GAP_ERR_NO_CTRL_BLK if out of control blocks
    301 **                  GAP_ERR_ILL_PARM if a bad parameter was detected in BTM
    302 **                  GAP_ERR_BUSY if the device already has an iquiry active
    303 **                  GAP_DEVICE_NOT_UP if the device is not initialized yet
    304 **                  GAP_ERR_PROCESSING if any other BTM error was returned
    305 **
    306 *******************************************************************************/
    307 GAP_API extern UINT16 GAP_StartPeriodicInquiry (tGAP_INQ_PARMS *p_inq_parms,
    308                                                 UINT16 min_time,
    309                                                 UINT16 max_time,
    310                                                 tGAP_CALLBACK *p_results_cb);
    311 
    312 /*******************************************************************************
    313 **
    314 ** Function         GAP_CancelInquiry
    315 **
    316 ** Description      This function cancels a single inquiry (if in progress)
    317 **
    318 ** Returns          BOOLEAN (TRUE if successful, otherwise FALSE)
    319 **
    320 *******************************************************************************/
    321 GAP_API extern UINT16 GAP_CancelInquiry(void);
    322 
    323 /*******************************************************************************
    324 **
    325 ** Function         GAP_CancelPeriodicInquiry
    326 **
    327 ** Description      This function cancels a periodic inquiry (if in progress)
    328 **
    329 ** Returns          BOOLEAN: (TRUE if successful, otherwise FALSE)
    330 **
    331 *******************************************************************************/
    332 GAP_API extern UINT16 GAP_CancelPeriodicInquiry(void);
    333 
    334 /*******************************************************************************
    335 **
    336 ** Function         GAP_GetFirstInquiryResult
    337 **
    338 ** Description      This function retrieves the first valid inquiry result.
    339 **
    340 ** Returns          BT_PASS (0) if successful, or a non-zero error code
    341 **                  GAP_EOINQDB if no more entries in the database.
    342 **
    343 *******************************************************************************/
    344 GAP_API extern UINT16 GAP_GetFirstInquiryResult(tGAP_INQ_RESULTS *p_results);
    345 
    346 /*******************************************************************************
    347 **
    348 ** Function         GAP_GetNextInquiryResult
    349 **
    350 ** Description      This function retrieves the next valid inquiry result.
    351 **
    352 ** Returns          BT_PASS (0) if successful, or a non-zero status code
    353 **                  GAP_EOINQDB if no more entries in the database.
    354 **
    355 *******************************************************************************/
    356 GAP_API extern UINT16 GAP_GetNextInquiryResult(tGAP_INQ_RESULTS *p_results);
    357 
    358 /*******************************************************************************
    359 **
    360 ** Function         GAP_FindAddrByName
    361 **
    362 ** Description      This function is called to retrieve a device address given
    363 **                  a device name.  It first looks in the current local inquiry
    364 **                  database for the device with the specified name.  If not found
    365 **                  it initiates a general inquiry.  Upon completion, it retrieves
    366 **                  the name for each device until a match is found or all devices
    367 **                  have been checked.  Note:  This process can take a while to
    368 **                  complete.
    369 **
    370 ** Returns          BT_PASS if the name was immediately available. (BD_ADDR is returned)
    371 **                  GAP_CMD_INITIATED if an inquiry has been initiated
    372 **
    373 *******************************************************************************/
    374 GAP_API extern UINT16 GAP_FindAddrByName (BD_NAME devname,
    375                                           tGAP_INQ_PARMS *p_inq_parms,
    376                                           tGAP_CALLBACK *p_addr_cb,
    377                                           BD_ADDR bd_addr);
    378 
    379 /*******************************************************************************
    380 **
    381 ** Function         GAP_SetConnectableMode
    382 **
    383 ** Description      This function is called to allow or disallow a
    384 **                  connections on the local device.
    385 **
    386 ** Returns          BT_PASS (0) if successful,
    387 **                  GAP_ERR_ILL_PARM if a bad parameter is detected,
    388 **                  GAP_DEVICE_NOT_UP if the device is not active,
    389 **                  GAP_ERR_PROCESSING if not enough resources to carry out request
    390 **
    391 *******************************************************************************/
    392 GAP_API extern UINT16 GAP_SetConnectableMode (UINT16 mode, UINT16 duration,
    393                                               UINT16 interval);
    394 
    395 /*******************************************************************************
    396 **
    397 ** Function         GAP_ReadConnectableMode
    398 **
    399 ** Description      This function is called to retrieve the current connectability
    400 **                  mode for the local device.
    401 **
    402 ** Returns          GAP_NON_CONNECTABLE, GAP_CONNECTABLE
    403 **
    404 *******************************************************************************/
    405 GAP_API extern UINT16 GAP_ReadConnectableMode (UINT16 *duration, UINT16 *interval);
    406 
    407 /*******************************************************************************
    408 **
    409 ** Function         GAP_SetSecurityMode
    410 **
    411 ** Description      Set security mode for the device (Service or Link level)
    412 **
    413 ** Returns          void
    414 **
    415 *******************************************************************************/
    416 GAP_API extern void GAP_SetSecurityMode (UINT8 sec_mode);
    417 
    418 /*******************************************************************************
    419 **
    420 ** Function         GAP_SecRegister
    421 **
    422 ** Description      Application calls this function to register for
    423 **                  security services.
    424 **
    425 ** Returns          TRUE if registered OK, else FALSE
    426 **
    427 *******************************************************************************/
    428 GAP_API extern BOOLEAN GAP_SecRegister (tBTM_APPL_INFO *p_cb_info);
    429 
    430 /*******************************************************************************
    431 **
    432 ** Function         GAP_SetPairableMode
    433 **
    434 ** Description      This function is called to allow or disallow pairing
    435 **                  on the local device.
    436 **
    437 ** Returns          BT_PASS (0) if successful, or a non-zero error code
    438 **
    439 *******************************************************************************/
    440 GAP_API extern UINT16 GAP_SetPairableMode (UINT16 mode, BOOLEAN connect_only_paired);
    441 
    442 /*******************************************************************************
    443 **
    444 ** Function         GAP_Bond
    445 **
    446 ** Description      This function is called to initiate bonding with peer device
    447 **
    448 ** Returns          tBTM_STATUS - BTM_CMD_STARTED of successfully initiated
    449 **
    450 *******************************************************************************/
    451 GAP_API extern UINT8 GAP_Bond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]);
    452 
    453 /*******************************************************************************
    454 **
    455 ** Function         GAP_PinRsp
    456 **
    457 ** Description      This function is called from UI after Security Manager submitted
    458 **                  PIN code request.
    459 **
    460 ** Returns          void
    461 **
    462 *******************************************************************************/
    463 GAP_API extern void GAP_PinRsp (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len,
    464                                 UINT8 *p_pin, UINT32 trusted_mask[]);
    465 
    466 /*******************************************************************************
    467 **
    468 ** Function         GAP_AuthorizeRsp
    469 **
    470 ** Description      This function is called from UI after Security Manager submitted
    471 **                  an authorization request.
    472 **
    473 ** Returns          void
    474 **
    475 *******************************************************************************/
    476 GAP_API extern void GAP_AuthorizeRsp (BD_ADDR bd_addr, UINT8 res,
    477                                       UINT32 trusted_mask[]);
    478 
    479 /*******************************************************************************
    480 **
    481 ** Function         GAP_SetDeviceClass
    482 **
    483 ** Description      This function updates the local Device Class.
    484 **
    485 ** Returns          BT_PASS (0) if successful,
    486 **                  GAP_ERR_BUSY if a discovery is already in progress
    487 **                  GAP_ERR_ILL_PARM if an illegal parameter was detected
    488 **                  GAP_ERR_PROCESSING if any other BTM error has been returned
    489 **
    490 *******************************************************************************/
    491 GAP_API extern UINT16 GAP_SetDeviceClass(tGAP_COD *p_cod, UINT8 cmd);
    492 
    493 /*******************************************************************************
    494 **
    495 ** Function         GAP_ReadDeviceClass
    496 **
    497 ** Description      This function reads the current local Device Class setting.
    498 **
    499 ** Returns          BT_PASS
    500 **
    501 *******************************************************************************/
    502 GAP_API extern UINT16 GAP_ReadDeviceClass(tGAP_COD *p_cod);
    503 
    504 /*******************************************************************************
    505 **
    506 ** Function         GAP_ReadLocalDeviceInfo
    507 **
    508 ** Description      This function retrieves local device information to the caller.
    509 **                  NOTE:  Return parameters that are set to NULL are not retrieved.
    510 **
    511 ** Returns          BT_PASS (0) if successful, or a non-zero error code
    512 **
    513 *******************************************************************************/
    514 GAP_API extern UINT16 GAP_ReadLocalDeviceInfo(  UINT8 *name, BD_ADDR *addr,
    515                                                 tGAP_LMP_VERSION *verinfo,
    516                                                 tGAP_LMP_FEATURES *features);
    517 
    518 
    519 /*******************************************************************************
    520 **
    521 ** Function         GAP_GetRemoteDeviceName
    522 **
    523 ** Description      The remote name is retrieved from the specified remote device.  If
    524 **                  GAP_CMD_INITIATED is returned by the function, the command was
    525 **                  successfully sent to the controller.  The GAP_EVT_NAME_RESP event
    526 **                  is passed in the callback when the remote device name has been retrieved.
    527 **
    528 ** Returns
    529 **                  GAP_CMD_INITIATED if remote search successfully initiated
    530 **                  GAP_ERR_BUSY if a remote name request is already in progress,
    531 **                  GAP_ERR_NO_CTRL_BLK if out of control blocks (too many commands pending)
    532 **                  GAP_BAD_BD_ADDR if the device address is bad,
    533 **                  GAP_DEVICE_NOT_UP if the device has not been initialized yet
    534 **                  GAP_ERR_PROCESSING if any other BTM error has been returned
    535 **
    536 *******************************************************************************/
    537 GAP_API extern UINT16 GAP_GetRemoteDeviceName (BD_ADDR addr, tGAP_CALLBACK *callback);
    538 
    539 /*** Functions for L2CAP connection interface ***/
    540 /*******************************************************************************
    541 **
    542 ** Function         GAP_ConnOpen
    543 **
    544 ** Description      This function is called to open a generic L2CAP connection.
    545 **
    546 ** Returns          handle of the connection if successful, else GAP_INVALID_HANDLE
    547 **
    548 *******************************************************************************/
    549 GAP_API extern UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server,
    550                                     BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg,
    551                                     UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb);
    552 
    553 /*******************************************************************************
    554 **
    555 ** Function         GAP_ConnClose
    556 **
    557 ** Description      This function is called to close a connection.
    558 **
    559 ** Returns          BT_PASS             - closed OK
    560 **                  GAP_ERR_BAD_HANDLE  - invalid handle
    561 **
    562 *******************************************************************************/
    563 GAP_API extern UINT16 GAP_ConnClose (UINT16 gap_handle);
    564 
    565 /*******************************************************************************
    566 **
    567 ** Function         GAP_ConnReadData
    568 **
    569 ** Description      GKI buffer unaware application will call this function
    570 **                  after receiving GAP_EVT_RXDATA event. A data copy is made
    571 **                  into the receive buffer parameter.
    572 **
    573 ** Returns          BT_PASS             - data read
    574 **                  GAP_ERR_BAD_HANDLE  - invalid handle
    575 **                  GAP_NO_DATA_AVAIL   - no data available
    576 **
    577 *******************************************************************************/
    578 GAP_API extern UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data,
    579                                         UINT16 max_len, UINT16 *p_len);
    580 
    581 /*******************************************************************************
    582 **
    583 ** Function         GAP_GetRxQueueCnt
    584 **
    585 ** Description      This function return number of bytes on the rx queue.
    586 **
    587 ** Parameters:      handle     - Handle returned in the GAP_ConnOpen
    588 **                  p_rx_queue_count - Pointer to return queue count in.
    589 **
    590 **
    591 *******************************************************************************/
    592 GAP_API extern int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count);
    593 
    594 /*******************************************************************************
    595 **
    596 ** Function         GAP_ConnBTRead
    597 **
    598 ** Description      GKI buffer aware applications will call this function after
    599 **                  receiving an GAP_EVT_RXDATA event to process the incoming
    600 **                  data buffer.
    601 **
    602 ** Returns          BT_PASS             - data read
    603 **                  GAP_ERR_BAD_HANDLE  - invalid handle
    604 **                  GAP_NO_DATA_AVAIL   - no data available
    605 **
    606 *******************************************************************************/
    607 GAP_API extern UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf);
    608 
    609 /*******************************************************************************
    610 **
    611 ** Function         GAP_ConnBTWrite
    612 **
    613 ** Description      GKI buffer aware applications can call this function to write data
    614 **                  by passing a pointer to the GKI buffer of data.
    615 **
    616 ** Returns          BT_PASS                 - data read
    617 **                  GAP_ERR_BAD_HANDLE      - invalid handle
    618 **                  GAP_ERR_BAD_STATE       - connection not established
    619 **                  GAP_INVALID_BUF_OFFSET  - buffer offset is invalid
    620 *******************************************************************************/
    621 GAP_API extern UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf);
    622 
    623 /*******************************************************************************
    624 **
    625 ** Function         GAP_ConnWriteData
    626 **
    627 ** Description      GKI buffer unaware application will call this function
    628 **                  to send data to the connection. A data copy is made into a GKI
    629 **                  buffer.
    630 **
    631 ** Returns          BT_PASS                 - data read
    632 **                  GAP_ERR_BAD_HANDLE      - invalid handle
    633 **                  GAP_ERR_BAD_STATE       - connection not established
    634 **                  GAP_CONGESTION          - system is congested
    635 **
    636 *******************************************************************************/
    637 GAP_API extern UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data,
    638                                          UINT16 max_len, UINT16 *p_len);
    639 
    640 /*******************************************************************************
    641 **
    642 ** Function         GAP_ConnReconfig
    643 **
    644 ** Description      Applications can call this function to reconfigure the connection.
    645 **
    646 ** Returns          BT_PASS                 - config process started
    647 **                  GAP_ERR_BAD_HANDLE      - invalid handle
    648 **
    649 *******************************************************************************/
    650 GAP_API extern UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg);
    651 
    652 /*******************************************************************************
    653 **
    654 ** Function         GAP_ConnSetIdleTimeout
    655 **
    656 ** Description      Higher layers call this function to set the idle timeout for
    657 **                  a connection, or for all future connections. The "idle timeout"
    658 **                  is the amount of time that a connection can remain up with
    659 **                  no L2CAP channels on it. A timeout of zero means that the
    660 **                  connection will be torn down immediately when the last channel
    661 **                  is removed. A timeout of 0xFFFF means no timeout. Values are
    662 **                  in seconds.
    663 **
    664 ** Returns          BT_PASS                 - config process started
    665 **                  GAP_ERR_BAD_HANDLE      - invalid handle
    666 **
    667 *******************************************************************************/
    668 GAP_API extern UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout);
    669 
    670 /*******************************************************************************
    671 **
    672 ** Function         GAP_ConnGetRemoteAddr
    673 **
    674 ** Description      This function is called to get the remote BD address
    675 **                  of a connection.
    676 **
    677 ** Returns          BT_PASS             - closed OK
    678 **                  GAP_ERR_BAD_HANDLE  - invalid handle
    679 **
    680 *******************************************************************************/
    681 GAP_API extern UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle);
    682 
    683 /*******************************************************************************
    684 **
    685 ** Function         GAP_ConnGetRemMtuSize
    686 **
    687 ** Description      Returns the remote device's MTU size.
    688 **
    689 ** Returns          UINT16 - maximum size buffer that can be transmitted to the peer
    690 **
    691 *******************************************************************************/
    692 GAP_API extern UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle);
    693 
    694 /*******************************************************************************
    695 **
    696 ** Function         GAP_ConnGetL2CAPCid
    697 **
    698 ** Description      Returns the L2CAP channel id
    699 **
    700 ** Parameters:      handle      - Handle of the connection
    701 **
    702 ** Returns          UINT16      - The L2CAP channel id
    703 **                  0, if error
    704 **
    705 *******************************************************************************/
    706 GAP_API extern UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle);
    707 
    708 /*******************************************************************************
    709 **
    710 ** Function         GAP_SetTraceLevel
    711 **
    712 ** Description      This function sets the trace level for GAP.  If called with
    713 **                  a value of 0xFF, it simply returns the current trace level.
    714 **
    715 ** Returns          The new or current trace level
    716 **
    717 *******************************************************************************/
    718 GAP_API extern UINT8 GAP_SetTraceLevel (UINT8 new_level);
    719 
    720 /*******************************************************************************
    721 **
    722 ** Function         GAP_Init
    723 **
    724 ** Description      Initializes the control blocks used by GAP.
    725 **                  This routine should not be called except once per
    726 **                      stack invocation.
    727 **
    728 ** Returns          Nothing
    729 **
    730 *******************************************************************************/
    731 GAP_API extern void GAP_Init(void);
    732 
    733 #if (BLE_INCLUDED == TRUE)
    734 /*******************************************************************************
    735 **
    736 ** Function         GAP_BleAttrDBUpdate
    737 **
    738 ** Description      update GAP local BLE attribute database.
    739 **
    740 ** Returns          Nothing
    741 **
    742 *******************************************************************************/
    743 GAP_API extern void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value);
    744 
    745 
    746 /*******************************************************************************
    747 **
    748 ** Function         GAP_BleReadPeerPrefConnParams
    749 **
    750 ** Description      Start a process to read a connected peripheral's preferred
    751 **                  connection parameters
    752 **
    753 ** Returns          TRUE if read started, else FALSE if GAP is busy
    754 **
    755 *******************************************************************************/
    756 GAP_API extern BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda);
    757 
    758 /*******************************************************************************
    759 **
    760 ** Function         GAP_BleReadPeerDevName
    761 **
    762 ** Description      Start a process to read a connected peripheral's device name.
    763 **
    764 ** Returns          TRUE if request accepted
    765 **
    766 *******************************************************************************/
    767 GAP_API extern BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_DEV_NAME_CBACK *p_cback);
    768 
    769 
    770 /*******************************************************************************
    771 **
    772 ** Function         GAP_BleCancelReadPeerDevName
    773 **
    774 ** Description      Cancel reading a peripheral's device name.
    775 **
    776 ** Returns          TRUE if request accepted
    777 **
    778 *******************************************************************************/
    779 GAP_API extern BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda);
    780 
    781 /*******************************************************************************
    782 **
    783 ** Function         GAP_BleUpdateReconnectAddr
    784 **
    785 ** Description      Start a process to udpate the reconnect address if remote devive
    786 **                  has privacy enabled.
    787 **
    788 ** Returns          TRUE if read started, else FALSE if GAP is busy
    789 **
    790 *******************************************************************************/
    791 GAP_API extern BOOLEAN GAP_BleUpdateReconnectAddr (BD_ADDR peer_bda,
    792                                                    BD_ADDR reconn_addr,
    793                                                    tGAP_BLE_RECONN_ADDR_CBACK *p_cback);
    794 
    795 #endif
    796 
    797 #ifdef __cplusplus
    798 }
    799 #endif
    800 
    801 #endif  /* GAP_API_H */
    802 
    803