Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 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 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 149 | /***************************************************************************** |
| 150 | ** Type Definitions |
| 151 | *****************************************************************************/ |
| 152 | /* |
| 153 | ** Callback function for connection services |
| 154 | */ |
| 155 | typedef void (tGAP_CONN_CALLBACK) (UINT16 gap_handle, UINT16 event); |
| 156 | |
| 157 | /* |
| 158 | ** Define the callback function prototypes. Parameters are specific |
| 159 | ** to each event and are described below |
| 160 | */ |
| 161 | typedef void (tGAP_CALLBACK) (UINT16 event, void *p_data); |
| 162 | |
| 163 | typedef tBTM_REMOTE_DEV_NAME tGAP_REMOTE_DEV_NAME; /* see btm_api.h */ |
| 164 | typedef tBTM_INQ_PARMS tGAP_INQ_PARMS; /* see btm_api.h */ |
| 165 | typedef tBTM_INQ_RESULTS tGAP_INQ_RESULTS; /* see btm_api.h */ |
| 166 | |
| 167 | /* Inquiry results structure */ |
| 168 | typedef struct |
| 169 | { |
| 170 | UINT16 status; |
| 171 | UINT8 num_results; |
| 172 | } tGAP_INQ_CMPL; |
| 173 | |
| 174 | /* Definition of the GAP_FindAddrByName results structure */ |
| 175 | typedef struct |
| 176 | { |
| 177 | UINT16 status; |
| 178 | BD_ADDR bd_addr; |
| 179 | tBTM_BD_NAME devname; |
| 180 | } tGAP_FINDADDR_RESULTS; |
| 181 | |
| 182 | /** for GAP_SetDeviceClass() **/ |
| 183 | /* Define Class of Device related values |
| 184 | * |
| 185 | * >>> changes to this type need to also be made to tHSP_COD in hsp2_int.h |
| 186 | */ |
| 187 | typedef struct |
| 188 | { |
| 189 | UINT8 minor; |
| 190 | UINT8 major; |
| 191 | UINT16 service; |
| 192 | } tGAP_COD; |
| 193 | |
| 194 | /*** Constants and functions for device features ***/ |
| 195 | typedef struct |
| 196 | { |
| 197 | UINT8 lmp_version; |
| 198 | UINT16 mfc_name; |
| 199 | UINT16 lmp_subversion; |
| 200 | } tGAP_LMP_VERSION; |
| 201 | |
| 202 | typedef struct |
| 203 | { |
| 204 | UINT8 lmp_features[8]; |
| 205 | } tGAP_LMP_FEATURES; |
| 206 | |
| 207 | typedef struct |
| 208 | { |
| 209 | UINT16 int_min; |
| 210 | UINT16 int_max; |
| 211 | UINT16 latency; |
| 212 | UINT16 sp_tout; |
| 213 | }tGAP_BLE_PREF_PARAM; |
| 214 | |
| 215 | typedef union |
| 216 | { |
| 217 | tGAP_BLE_PREF_PARAM conn_param; |
| 218 | BD_ADDR reconn_bda; |
| 219 | UINT16 icon; |
| 220 | UINT8 *p_dev_name; |
| 221 | UINT8 privacy; |
| 222 | |
| 223 | }tGAP_BLE_ATTR_VALUE; |
| 224 | |
| 225 | typedef void (tGAP_BLE_DEV_NAME_CBACK)(BOOLEAN status, BD_ADDR addr, UINT16 length, char *p_name); |
| 226 | |
| 227 | typedef void (tGAP_BLE_RECONN_ADDR_CBACK)(BOOLEAN status, BD_ADDR addr, BD_ADDR reconn_bda); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 228 | #if BLE_PRIVACY_SPT == TRUE |
| 229 | typedef void (tGAP_BLE_PRIVACY_CBACK)(BOOLEAN status, BD_ADDR addr, BOOLEAN privacy_enabled); |
| 230 | #endif |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 231 | |
| 232 | /***************************************************************************** |
| 233 | ** External Function Declarations |
| 234 | *****************************************************************************/ |
| 235 | #ifdef __cplusplus |
| 236 | extern "C" |
| 237 | { |
| 238 | #endif |
| 239 | |
| 240 | /******************************************************************************* |
| 241 | ** |
| 242 | ** Function GAP_SetDiscoverableMode |
| 243 | ** |
| 244 | ** Description This function is called to allow or disallow a service to |
| 245 | ** discovered (Inquiry Scans). |
| 246 | ** |
| 247 | ** Returns BT_PASS (0) if successful, |
| 248 | ** GAP_ERR_ILL_PARM if a bad parameter is detected, |
| 249 | ** GAP_DEVICE_NOT_UP if the device is not active, |
| 250 | ** GAP_ERR_PROCESSING if not enough resources to carry out request |
| 251 | ** |
| 252 | *******************************************************************************/ |
| 253 | GAP_API extern UINT16 GAP_SetDiscoverableMode (UINT16 mode, UINT16 duration, |
| 254 | UINT16 interval); |
| 255 | |
| 256 | /******************************************************************************* |
| 257 | ** |
| 258 | ** Function GAP_ReadDiscoverableMode |
| 259 | ** |
| 260 | ** Description This function is called to retrieve the current discoverable |
| 261 | ** mode for the local device. |
| 262 | ** |
| 263 | ** Returns GAP_NON_DISCOVERABLE, GAP_LIMITED_DISCOVERABLE, or |
| 264 | ** GAP_GENERAL_DISCOVERABLE |
| 265 | ** |
| 266 | *******************************************************************************/ |
| 267 | GAP_API extern UINT16 GAP_ReadDiscoverableMode (UINT16 *duration, UINT16 *interval); |
| 268 | |
| 269 | /******************************************************************************* |
| 270 | ** |
| 271 | ** Function GAP_StartInquiry |
| 272 | ** |
| 273 | ** Description This function initiates a single inquiry. |
| 274 | ** |
| 275 | ** Returns BT_PASS (0) if successful, |
| 276 | ** GAP_ERR_ILL_MODE if a bad mode parameter was passed |
| 277 | ** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed |
| 278 | ** GAP_ERR_NO_CTRL_BLK if out of control blocks |
| 279 | ** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM |
| 280 | ** GAP_ERR_BUSY if the device already has an iquiry active |
| 281 | ** GAP_DEVICE_NOT_UP if the device is not initialized yet |
| 282 | ** GAP_ERR_PROCESSING if any other BTM error was returned |
| 283 | ** |
| 284 | *******************************************************************************/ |
| 285 | GAP_API extern UINT16 GAP_StartInquiry (tGAP_INQ_PARMS *p_inq_parms, |
| 286 | tGAP_CALLBACK *p_results_cb, |
| 287 | tGAP_CALLBACK *p_cmpl_cb); |
| 288 | |
| 289 | /******************************************************************************* |
| 290 | ** |
| 291 | ** Function GAP_StartPeriodicInquiry |
| 292 | ** |
| 293 | ** Description This function initiates a periodic inquiry. |
| 294 | ** |
| 295 | ** Returns BT_PASS (0) if successful, |
| 296 | ** GAP_ERR_ILL_MODE if a bad mode parameter was passed |
| 297 | ** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed |
| 298 | ** GAP_ERR_NO_CTRL_BLK if out of control blocks |
| 299 | ** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM |
| 300 | ** GAP_ERR_BUSY if the device already has an iquiry active |
| 301 | ** GAP_DEVICE_NOT_UP if the device is not initialized yet |
| 302 | ** GAP_ERR_PROCESSING if any other BTM error was returned |
| 303 | ** |
| 304 | *******************************************************************************/ |
| 305 | GAP_API extern UINT16 GAP_StartPeriodicInquiry (tGAP_INQ_PARMS *p_inq_parms, |
| 306 | UINT16 min_time, |
| 307 | UINT16 max_time, |
| 308 | tGAP_CALLBACK *p_results_cb); |
| 309 | |
| 310 | /******************************************************************************* |
| 311 | ** |
| 312 | ** Function GAP_CancelInquiry |
| 313 | ** |
| 314 | ** Description This function cancels a single inquiry (if in progress) |
| 315 | ** |
| 316 | ** Returns BOOLEAN (TRUE if successful, otherwise FALSE) |
| 317 | ** |
| 318 | *******************************************************************************/ |
| 319 | GAP_API extern UINT16 GAP_CancelInquiry(void); |
| 320 | |
| 321 | /******************************************************************************* |
| 322 | ** |
| 323 | ** Function GAP_CancelPeriodicInquiry |
| 324 | ** |
| 325 | ** Description This function cancels a periodic inquiry (if in progress) |
| 326 | ** |
| 327 | ** Returns BOOLEAN: (TRUE if successful, otherwise FALSE) |
| 328 | ** |
| 329 | *******************************************************************************/ |
| 330 | GAP_API extern UINT16 GAP_CancelPeriodicInquiry(void); |
| 331 | |
| 332 | /******************************************************************************* |
| 333 | ** |
| 334 | ** Function GAP_GetFirstInquiryResult |
| 335 | ** |
| 336 | ** Description This function retrieves the first valid inquiry result. |
| 337 | ** |
| 338 | ** Returns BT_PASS (0) if successful, or a non-zero error code |
| 339 | ** GAP_EOINQDB if no more entries in the database. |
| 340 | ** |
| 341 | *******************************************************************************/ |
| 342 | GAP_API extern UINT16 GAP_GetFirstInquiryResult(tGAP_INQ_RESULTS *p_results); |
| 343 | |
| 344 | /******************************************************************************* |
| 345 | ** |
| 346 | ** Function GAP_GetNextInquiryResult |
| 347 | ** |
| 348 | ** Description This function retrieves the next valid inquiry result. |
| 349 | ** |
| 350 | ** Returns BT_PASS (0) if successful, or a non-zero status code |
| 351 | ** GAP_EOINQDB if no more entries in the database. |
| 352 | ** |
| 353 | *******************************************************************************/ |
| 354 | GAP_API extern UINT16 GAP_GetNextInquiryResult(tGAP_INQ_RESULTS *p_results); |
| 355 | |
| 356 | /******************************************************************************* |
| 357 | ** |
| 358 | ** Function GAP_FindAddrByName |
| 359 | ** |
| 360 | ** Description This function is called to retrieve a device address given |
| 361 | ** a device name. It first looks in the current local inquiry |
| 362 | ** database for the device with the specified name. If not found |
| 363 | ** it initiates a general inquiry. Upon completion, it retrieves |
| 364 | ** the name for each device until a match is found or all devices |
| 365 | ** have been checked. Note: This process can take a while to |
| 366 | ** complete. |
| 367 | ** |
| 368 | ** Returns BT_PASS if the name was immediately available. (BD_ADDR is returned) |
| 369 | ** GAP_CMD_INITIATED if an inquiry has been initiated |
| 370 | ** |
| 371 | *******************************************************************************/ |
| 372 | GAP_API extern UINT16 GAP_FindAddrByName (BD_NAME devname, |
| 373 | tGAP_INQ_PARMS *p_inq_parms, |
| 374 | tGAP_CALLBACK *p_addr_cb, |
| 375 | BD_ADDR bd_addr); |
| 376 | |
| 377 | /******************************************************************************* |
| 378 | ** |
| 379 | ** Function GAP_SetConnectableMode |
| 380 | ** |
| 381 | ** Description This function is called to allow or disallow a |
| 382 | ** connections on the local device. |
| 383 | ** |
| 384 | ** Returns BT_PASS (0) if successful, |
| 385 | ** GAP_ERR_ILL_PARM if a bad parameter is detected, |
| 386 | ** GAP_DEVICE_NOT_UP if the device is not active, |
| 387 | ** GAP_ERR_PROCESSING if not enough resources to carry out request |
| 388 | ** |
| 389 | *******************************************************************************/ |
| 390 | GAP_API extern UINT16 GAP_SetConnectableMode (UINT16 mode, UINT16 duration, |
| 391 | UINT16 interval); |
| 392 | |
| 393 | /******************************************************************************* |
| 394 | ** |
| 395 | ** Function GAP_ReadConnectableMode |
| 396 | ** |
| 397 | ** Description This function is called to retrieve the current connectability |
| 398 | ** mode for the local device. |
| 399 | ** |
| 400 | ** Returns GAP_NON_CONNECTABLE, GAP_CONNECTABLE |
| 401 | ** |
| 402 | *******************************************************************************/ |
| 403 | GAP_API extern UINT16 GAP_ReadConnectableMode (UINT16 *duration, UINT16 *interval); |
| 404 | |
| 405 | /******************************************************************************* |
| 406 | ** |
| 407 | ** Function GAP_SetSecurityMode |
| 408 | ** |
| 409 | ** Description Set security mode for the device (Service or Link level) |
| 410 | ** |
| 411 | ** Returns void |
| 412 | ** |
| 413 | *******************************************************************************/ |
| 414 | GAP_API extern void GAP_SetSecurityMode (UINT8 sec_mode); |
| 415 | |
| 416 | /******************************************************************************* |
| 417 | ** |
| 418 | ** Function GAP_SecRegister |
| 419 | ** |
| 420 | ** Description Application calls this function to register for |
| 421 | ** security services. |
| 422 | ** |
| 423 | ** Returns TRUE if registered OK, else FALSE |
| 424 | ** |
| 425 | *******************************************************************************/ |
| 426 | GAP_API extern BOOLEAN GAP_SecRegister (tBTM_APPL_INFO *p_cb_info); |
| 427 | |
| 428 | /******************************************************************************* |
| 429 | ** |
| 430 | ** Function GAP_SetPairableMode |
| 431 | ** |
| 432 | ** Description This function is called to allow or disallow pairing |
| 433 | ** on the local device. |
| 434 | ** |
| 435 | ** Returns BT_PASS (0) if successful, or a non-zero error code |
| 436 | ** |
| 437 | *******************************************************************************/ |
| 438 | GAP_API extern UINT16 GAP_SetPairableMode (UINT16 mode, BOOLEAN connect_only_paired); |
| 439 | |
| 440 | /******************************************************************************* |
| 441 | ** |
| 442 | ** Function GAP_Bond |
| 443 | ** |
| 444 | ** Description This function is called to initiate bonding with peer device |
| 445 | ** |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 446 | ** Parameters: bd_addr - Address of the device to bond |
| 447 | ** pin_len - length in bytes of the PIN Code |
| 448 | ** p_pin - pointer to array with the PIN Code |
| 449 | ** trusted_mask - bitwise OR of trusted services (array of UINT32) |
| 450 | ** |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 451 | ** Returns tBTM_STATUS - BTM_CMD_STARTED of successfully initiated |
| 452 | ** |
| 453 | *******************************************************************************/ |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 454 | GAP_API extern UINT8 GAP_Bond (BD_ADDR bd_addr, UINT8 pin_len, |
| 455 | UINT8 *p_pin, UINT32 trusted_mask[]); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 456 | |
| 457 | /******************************************************************************* |
| 458 | ** |
| 459 | ** Function GAP_PinRsp |
| 460 | ** |
| 461 | ** Description This function is called from UI after Security Manager submitted |
| 462 | ** PIN code request. |
| 463 | ** |
| 464 | ** Returns void |
| 465 | ** |
| 466 | *******************************************************************************/ |
| 467 | GAP_API extern void GAP_PinRsp (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, |
| 468 | UINT8 *p_pin, UINT32 trusted_mask[]); |
| 469 | |
| 470 | /******************************************************************************* |
| 471 | ** |
| 472 | ** Function GAP_AuthorizeRsp |
| 473 | ** |
| 474 | ** Description This function is called from UI after Security Manager submitted |
| 475 | ** an authorization request. |
| 476 | ** |
| 477 | ** Returns void |
| 478 | ** |
| 479 | *******************************************************************************/ |
| 480 | GAP_API extern void GAP_AuthorizeRsp (BD_ADDR bd_addr, UINT8 res, |
| 481 | UINT32 trusted_mask[]); |
| 482 | |
| 483 | /******************************************************************************* |
| 484 | ** |
| 485 | ** Function GAP_SetDeviceClass |
| 486 | ** |
| 487 | ** Description This function updates the local Device Class. |
| 488 | ** |
| 489 | ** Returns BT_PASS (0) if successful, |
| 490 | ** GAP_ERR_BUSY if a discovery is already in progress |
| 491 | ** GAP_ERR_ILL_PARM if an illegal parameter was detected |
| 492 | ** GAP_ERR_PROCESSING if any other BTM error has been returned |
| 493 | ** |
| 494 | *******************************************************************************/ |
| 495 | GAP_API extern UINT16 GAP_SetDeviceClass(tGAP_COD *p_cod, UINT8 cmd); |
| 496 | |
| 497 | /******************************************************************************* |
| 498 | ** |
| 499 | ** Function GAP_ReadDeviceClass |
| 500 | ** |
| 501 | ** Description This function reads the current local Device Class setting. |
| 502 | ** |
| 503 | ** Returns BT_PASS |
| 504 | ** |
| 505 | *******************************************************************************/ |
| 506 | GAP_API extern UINT16 GAP_ReadDeviceClass(tGAP_COD *p_cod); |
| 507 | |
| 508 | /******************************************************************************* |
| 509 | ** |
| 510 | ** Function GAP_ReadLocalDeviceInfo |
| 511 | ** |
| 512 | ** Description This function retrieves local device information to the caller. |
| 513 | ** NOTE: Return parameters that are set to NULL are not retrieved. |
| 514 | ** |
| 515 | ** Returns BT_PASS (0) if successful, or a non-zero error code |
| 516 | ** |
| 517 | *******************************************************************************/ |
| 518 | GAP_API extern UINT16 GAP_ReadLocalDeviceInfo( UINT8 *name, BD_ADDR *addr, |
| 519 | tGAP_LMP_VERSION *verinfo, |
| 520 | tGAP_LMP_FEATURES *features); |
| 521 | |
| 522 | |
| 523 | /******************************************************************************* |
| 524 | ** |
| 525 | ** Function GAP_GetRemoteDeviceName |
| 526 | ** |
| 527 | ** Description The remote name is retrieved from the specified remote device. If |
| 528 | ** GAP_CMD_INITIATED is returned by the function, the command was |
| 529 | ** successfully sent to the controller. The GAP_EVT_NAME_RESP event |
| 530 | ** is passed in the callback when the remote device name has been retrieved. |
| 531 | ** |
| 532 | ** Returns |
| 533 | ** GAP_CMD_INITIATED if remote search successfully initiated |
| 534 | ** GAP_ERR_BUSY if a remote name request is already in progress, |
| 535 | ** GAP_ERR_NO_CTRL_BLK if out of control blocks (too many commands pending) |
| 536 | ** GAP_BAD_BD_ADDR if the device address is bad, |
| 537 | ** GAP_DEVICE_NOT_UP if the device has not been initialized yet |
| 538 | ** GAP_ERR_PROCESSING if any other BTM error has been returned |
| 539 | ** |
| 540 | *******************************************************************************/ |
| 541 | GAP_API extern UINT16 GAP_GetRemoteDeviceName (BD_ADDR addr, tGAP_CALLBACK *callback); |
| 542 | |
| 543 | /*** Functions for L2CAP connection interface ***/ |
| 544 | /******************************************************************************* |
| 545 | ** |
| 546 | ** Function GAP_ConnOpen |
| 547 | ** |
| 548 | ** Description This function is called to open a generic L2CAP connection. |
| 549 | ** |
| 550 | ** Returns handle of the connection if successful, else GAP_INVALID_HANDLE |
| 551 | ** |
| 552 | *******************************************************************************/ |
| 553 | GAP_API extern UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server, |
| 554 | BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg, |
| 555 | UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb); |
| 556 | |
| 557 | /******************************************************************************* |
| 558 | ** |
| 559 | ** Function GAP_ConnClose |
| 560 | ** |
| 561 | ** Description This function is called to close a connection. |
| 562 | ** |
| 563 | ** Returns BT_PASS - closed OK |
| 564 | ** GAP_ERR_BAD_HANDLE - invalid handle |
| 565 | ** |
| 566 | *******************************************************************************/ |
| 567 | GAP_API extern UINT16 GAP_ConnClose (UINT16 gap_handle); |
| 568 | |
| 569 | /******************************************************************************* |
| 570 | ** |
| 571 | ** Function GAP_ConnReadData |
| 572 | ** |
| 573 | ** Description GKI buffer unaware application will call this function |
| 574 | ** after receiving GAP_EVT_RXDATA event. A data copy is made |
| 575 | ** into the receive buffer parameter. |
| 576 | ** |
| 577 | ** Returns BT_PASS - data read |
| 578 | ** GAP_ERR_BAD_HANDLE - invalid handle |
| 579 | ** GAP_NO_DATA_AVAIL - no data available |
| 580 | ** |
| 581 | *******************************************************************************/ |
| 582 | GAP_API extern UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data, |
| 583 | UINT16 max_len, UINT16 *p_len); |
| 584 | |
| 585 | /******************************************************************************* |
| 586 | ** |
| 587 | ** Function GAP_GetRxQueueCnt |
| 588 | ** |
| 589 | ** Description This function return number of bytes on the rx queue. |
| 590 | ** |
| 591 | ** Parameters: handle - Handle returned in the GAP_ConnOpen |
| 592 | ** p_rx_queue_count - Pointer to return queue count in. |
| 593 | ** |
| 594 | ** |
| 595 | *******************************************************************************/ |
| 596 | GAP_API extern int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count); |
| 597 | |
| 598 | /******************************************************************************* |
| 599 | ** |
| 600 | ** Function GAP_ConnBTRead |
| 601 | ** |
| 602 | ** Description GKI buffer aware applications will call this function after |
| 603 | ** receiving an GAP_EVT_RXDATA event to process the incoming |
| 604 | ** data buffer. |
| 605 | ** |
| 606 | ** Returns BT_PASS - data read |
| 607 | ** GAP_ERR_BAD_HANDLE - invalid handle |
| 608 | ** GAP_NO_DATA_AVAIL - no data available |
| 609 | ** |
| 610 | *******************************************************************************/ |
| 611 | GAP_API extern UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf); |
| 612 | |
| 613 | /******************************************************************************* |
| 614 | ** |
| 615 | ** Function GAP_ConnBTWrite |
| 616 | ** |
| 617 | ** Description GKI buffer aware applications can call this function to write data |
| 618 | ** by passing a pointer to the GKI buffer of data. |
| 619 | ** |
| 620 | ** Returns BT_PASS - data read |
| 621 | ** GAP_ERR_BAD_HANDLE - invalid handle |
| 622 | ** GAP_ERR_BAD_STATE - connection not established |
| 623 | ** GAP_INVALID_BUF_OFFSET - buffer offset is invalid |
| 624 | *******************************************************************************/ |
| 625 | GAP_API extern UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf); |
| 626 | |
| 627 | /******************************************************************************* |
| 628 | ** |
| 629 | ** Function GAP_ConnWriteData |
| 630 | ** |
| 631 | ** Description GKI buffer unaware application will call this function |
| 632 | ** to send data to the connection. A data copy is made into a GKI |
| 633 | ** buffer. |
| 634 | ** |
| 635 | ** Returns BT_PASS - data read |
| 636 | ** GAP_ERR_BAD_HANDLE - invalid handle |
| 637 | ** GAP_ERR_BAD_STATE - connection not established |
| 638 | ** GAP_CONGESTION - system is congested |
| 639 | ** |
| 640 | *******************************************************************************/ |
| 641 | GAP_API extern UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data, |
| 642 | UINT16 max_len, UINT16 *p_len); |
| 643 | |
| 644 | /******************************************************************************* |
| 645 | ** |
| 646 | ** Function GAP_ConnReconfig |
| 647 | ** |
| 648 | ** Description Applications can call this function to reconfigure the connection. |
| 649 | ** |
| 650 | ** Returns BT_PASS - config process started |
| 651 | ** GAP_ERR_BAD_HANDLE - invalid handle |
| 652 | ** |
| 653 | *******************************************************************************/ |
| 654 | GAP_API extern UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg); |
| 655 | |
| 656 | /******************************************************************************* |
| 657 | ** |
| 658 | ** Function GAP_ConnSetIdleTimeout |
| 659 | ** |
| 660 | ** Description Higher layers call this function to set the idle timeout for |
| 661 | ** a connection, or for all future connections. The "idle timeout" |
| 662 | ** is the amount of time that a connection can remain up with |
| 663 | ** no L2CAP channels on it. A timeout of zero means that the |
| 664 | ** connection will be torn down immediately when the last channel |
| 665 | ** is removed. A timeout of 0xFFFF means no timeout. Values are |
| 666 | ** in seconds. |
| 667 | ** |
| 668 | ** Returns BT_PASS - config process started |
| 669 | ** GAP_ERR_BAD_HANDLE - invalid handle |
| 670 | ** |
| 671 | *******************************************************************************/ |
| 672 | GAP_API extern UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout); |
| 673 | |
| 674 | /******************************************************************************* |
| 675 | ** |
| 676 | ** Function GAP_ConnGetRemoteAddr |
| 677 | ** |
| 678 | ** Description This function is called to get the remote BD address |
| 679 | ** of a connection. |
| 680 | ** |
| 681 | ** Returns BT_PASS - closed OK |
| 682 | ** GAP_ERR_BAD_HANDLE - invalid handle |
| 683 | ** |
| 684 | *******************************************************************************/ |
| 685 | GAP_API extern UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle); |
| 686 | |
| 687 | /******************************************************************************* |
| 688 | ** |
| 689 | ** Function GAP_ConnGetRemMtuSize |
| 690 | ** |
| 691 | ** Description Returns the remote device's MTU size. |
| 692 | ** |
| 693 | ** Returns UINT16 - maximum size buffer that can be transmitted to the peer |
| 694 | ** |
| 695 | *******************************************************************************/ |
| 696 | GAP_API extern UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle); |
| 697 | |
| 698 | /******************************************************************************* |
| 699 | ** |
| 700 | ** Function GAP_ConnGetL2CAPCid |
| 701 | ** |
| 702 | ** Description Returns the L2CAP channel id |
| 703 | ** |
| 704 | ** Parameters: handle - Handle of the connection |
| 705 | ** |
| 706 | ** Returns UINT16 - The L2CAP channel id |
| 707 | ** 0, if error |
| 708 | ** |
| 709 | *******************************************************************************/ |
| 710 | GAP_API extern UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle); |
| 711 | |
| 712 | /******************************************************************************* |
| 713 | ** |
| 714 | ** Function GAP_SetTraceLevel |
| 715 | ** |
| 716 | ** Description This function sets the trace level for GAP. If called with |
| 717 | ** a value of 0xFF, it simply returns the current trace level. |
| 718 | ** |
| 719 | ** Returns The new or current trace level |
| 720 | ** |
| 721 | *******************************************************************************/ |
| 722 | GAP_API extern UINT8 GAP_SetTraceLevel (UINT8 new_level); |
| 723 | |
| 724 | /******************************************************************************* |
| 725 | ** |
| 726 | ** Function GAP_Init |
| 727 | ** |
| 728 | ** Description Initializes the control blocks used by GAP. |
| 729 | ** This routine should not be called except once per |
| 730 | ** stack invocation. |
| 731 | ** |
| 732 | ** Returns Nothing |
| 733 | ** |
| 734 | *******************************************************************************/ |
| 735 | GAP_API extern void GAP_Init(void); |
| 736 | |
| 737 | #if (BLE_INCLUDED == TRUE) |
| 738 | /******************************************************************************* |
| 739 | ** |
| 740 | ** Function GAP_BleAttrDBUpdate |
| 741 | ** |
| 742 | ** Description update GAP local BLE attribute database. |
| 743 | ** |
| 744 | ** Returns Nothing |
| 745 | ** |
| 746 | *******************************************************************************/ |
| 747 | GAP_API extern void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value); |
| 748 | |
| 749 | |
| 750 | /******************************************************************************* |
| 751 | ** |
| 752 | ** Function GAP_BleReadPeerPrefConnParams |
| 753 | ** |
| 754 | ** Description Start a process to read a connected peripheral's preferred |
| 755 | ** connection parameters |
| 756 | ** |
| 757 | ** Returns TRUE if read started, else FALSE if GAP is busy |
| 758 | ** |
| 759 | *******************************************************************************/ |
| 760 | GAP_API extern BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda); |
| 761 | |
| 762 | /******************************************************************************* |
| 763 | ** |
| 764 | ** Function GAP_BleReadPeerDevName |
| 765 | ** |
| 766 | ** Description Start a process to read a connected peripheral's device name. |
| 767 | ** |
| 768 | ** Returns TRUE if request accepted |
| 769 | ** |
| 770 | *******************************************************************************/ |
| 771 | GAP_API extern BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_DEV_NAME_CBACK *p_cback); |
| 772 | |
| 773 | |
| 774 | /******************************************************************************* |
| 775 | ** |
| 776 | ** Function GAP_BleCancelReadPeerDevName |
| 777 | ** |
| 778 | ** Description Cancel reading a peripheral's device name. |
| 779 | ** |
| 780 | ** Returns TRUE if request accepted |
| 781 | ** |
| 782 | *******************************************************************************/ |
| 783 | GAP_API extern BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda); |
| 784 | |
| 785 | /******************************************************************************* |
| 786 | ** |
| 787 | ** Function GAP_BleUpdateReconnectAddr |
| 788 | ** |
| 789 | ** Description Start a process to udpate the reconnect address if remote devive |
| 790 | ** has privacy enabled. |
| 791 | ** |
| 792 | ** Returns TRUE if read started, else FALSE if GAP is busy |
| 793 | ** |
| 794 | *******************************************************************************/ |
| 795 | GAP_API extern BOOLEAN GAP_BleUpdateReconnectAddr (BD_ADDR peer_bda, |
| 796 | BD_ADDR reconn_addr, |
| 797 | tGAP_BLE_RECONN_ADDR_CBACK *p_cback); |
| 798 | |
| 799 | #endif |
| 800 | |
| 801 | #ifdef __cplusplus |
| 802 | } |
| 803 | #endif |
| 804 | |
| 805 | #endif /* GAP_API_H */ |
| 806 | |