• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 1999-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 file contains the Bluetooth Manager (BTM) API function external
22  *  definitions.
23  *
24  ******************************************************************************/
25 #ifndef BTM_BLE_API_H
26 #define BTM_BLE_API_H
27 
28 #include "btm_api.h"
29 
30 #define CHNL_MAP_LEN    5
31 typedef UINT8 tBTM_BLE_CHNL_MAP[CHNL_MAP_LEN];
32 
33 #define BTM_BLE_CONNECT_EVT     0x00
34 #define BTM_BLE_CONNECT_DIR_EVT 0x01
35 #define BTM_BLE_DISCOVER_EVT    0x02
36 #define BTM_BLE_NON_CONNECT_EVT 0x03
37 #define BTM_BLE_SCAN_RSP_EVT    0x04
38 #define BTM_BLE_SCAN_REQ_EVT    0x06
39 #define BTM_BLE_UNKNOWN_EVT     0xff
40 
41 #define BTM_BLE_UNKNOWN_EVT     0xff
42 
43 #define BTM_BLE_SCAN_MODE_PASS      0
44 #define BTM_BLE_SCAN_MODE_ACTI      1
45 #define BTM_BLE_SCAN_MODE_NONE      0xff
46 typedef UINT8 tBTM_BLE_SCAN_MODE;
47 
48 /* advertising channel map */
49 #define BTM_BLE_ADV_CHNL_37    (0x01 << 0)
50 #define BTM_BLE_ADV_CHNL_38    (0x01 << 1)
51 #define BTM_BLE_ADV_CHNL_39    (0x01 << 2)
52 typedef UINT8 tBTM_BLE_ADV_CHNL_MAP;
53 
54 /*d efault advertising channel map */
55 #ifndef BTM_BLE_DEFAULT_ADV_CHNL_MAP
56 #define BTM_BLE_DEFAULT_ADV_CHNL_MAP   (BTM_BLE_ADV_CHNL_37| BTM_BLE_ADV_CHNL_38| BTM_BLE_ADV_CHNL_39)
57 #endif
58 
59 /* advertising filter policy */
60 #define AP_SCAN_CONN_ALL           0x00        /* default */
61 #define AP_SCAN_WL_CONN_ALL        0x01
62 #define AP_SCAN_ALL_CONN_WL        0x02
63 #define AP_SCAN_CONN_WL            0x03
64 #define AP_SCAN_CONN_POLICY_MAX    0x04
65 typedef UINT8   tBTM_BLE_AFP;
66 
67 /* default advertising filter policy */
68 #ifndef BTM_BLE_DEFAULT_AFP
69 #define BTM_BLE_DEFAULT_AFP   AP_SCAN_CONN_ALL
70 #endif
71 
72 /* scanning filter policy */
73 #define SP_ADV_ALL     0x00     /* accept adv pakt from all, directed adv pkt not directed to me is ignored */
74 #define SP_ADV_WL      0x01     /* accept adv pakt from device in white list, directed adv pkt not directed to me is ignored */
75 typedef UINT8   tBTM_BLE_SFP;
76 
77 #ifndef BTM_BLE_DEFAULT_SFP
78 #define BTM_BLE_DEFAULT_SFP   SP_ADV_ALL
79 #endif
80 
81 /* adv parameter boundary values */
82 #define BTM_BLE_ADV_INT_MIN            0x0020
83 #define BTM_BLE_ADV_INT_MAX            0x4000
84 
85 /* connection parameter boundary values */
86 #define BTM_BLE_SCAN_INT_MIN            0x0004
87 #define BTM_BLE_SCAN_INT_MAX            0x4000
88 #define BTM_BLE_SCAN_WIN_MIN            0x0004
89 #define BTM_BLE_SCAN_WIN_MAX            0x4000
90 #define BTM_BLE_CONN_INT_MIN            0x0006
91 #define BTM_BLE_CONN_INT_MAX            0x0C80
92 #define BTM_BLE_CONN_LATENCY_MAX        500
93 #define BTM_BLE_CONN_SUP_TOUT_MIN       0x000A
94 #define BTM_BLE_CONN_SUP_TOUT_MAX       0x0C80
95 #define BTM_BLE_CONN_PARAM_UNDEF        0xffff      /* use this value when a specific value not to be overwritten */
96 #define BTM_BLE_CONN_SUP_TOUT_DEF       700
97 
98 /* default connection parameters if not configured, use GAP recommend value for auto/selective connection */
99 /* default scan interval */
100 #ifndef BTM_BLE_SCAN_FAST_INT
101 #define BTM_BLE_SCAN_FAST_INT    96    /* 30 ~ 60 ms (use 60)  = 96 *0.625 */
102 #endif
103 /* default scan window for background connection, applicable for auto connection or selective conenction */
104 #ifndef BTM_BLE_SCAN_FAST_WIN
105 #define BTM_BLE_SCAN_FAST_WIN   48      /* 30 ms = 48 *0.625 */
106 #endif
107 
108 /* default scan paramter used in reduced power cycle (background scanning) */
109 #ifndef BTM_BLE_SCAN_SLOW_INT_1
110 #define BTM_BLE_SCAN_SLOW_INT_1    2048    /* 1.28 s   = 2048 *0.625 */
111 #endif
112 #ifndef BTM_BLE_SCAN_SLOW_WIN_1
113 #define BTM_BLE_SCAN_SLOW_WIN_1   18      /* 11.25 ms = 18 *0.625 */
114 #endif
115 
116 /* default scan paramter used in reduced power cycle (background scanning) */
117 #ifndef BTM_BLE_SCAN_SLOW_INT_2
118 #define BTM_BLE_SCAN_SLOW_INT_2    4096    /* 2.56 s   = 4096 *0.625 */
119 #endif
120 #ifndef BTM_BLE_SCAN_SLOW_WIN_2
121 #define BTM_BLE_SCAN_SLOW_WIN_2   36      /* 22.5 ms = 36 *0.625 */
122 #endif
123 
124 /* default connection interval min */
125 #ifndef BTM_BLE_CONN_INT_MIN_DEF
126 #define BTM_BLE_CONN_INT_MIN_DEF     24      /* recommended min: 30ms  = 24 * 1.25 */
127 #endif
128 /* default connectino interval max */
129 #ifndef BTM_BLE_CONN_INT_MAX_DEF
130 #define BTM_BLE_CONN_INT_MAX_DEF     40      /* recommended max: 50 ms = 56 * 1.25 */
131 #endif
132 /* default slave latency */
133 #ifndef BTM_BLE_CONN_SLAVE_LATENCY_DEF
134 #define BTM_BLE_CONN_SLAVE_LATENCY_DEF  0      /* 0 */
135 #endif
136 /* default supervision timeout */
137 #ifndef BTM_BLE_CONN_TIMEOUT_DEF
138 #define BTM_BLE_CONN_TIMEOUT_DEF    2000
139 #endif
140 
141 #define BTM_BLE_DIR_CONN_FALLBACK_UNDIR         1
142 #define BTM_BLE_DIR_CONN_FALLBACK_NO_ADV        2
143 
144 #ifndef BTM_BLE_DIR_CONN_FALLBACK
145 #define BTM_BLE_DIR_CONN_FALLBACK   BTM_BLE_DIR_CONN_FALLBACK_UNDIR
146 #endif
147 
148 #define BTM_CMAC_TLEN_SIZE          8                   /* 64 bits */
149 #define BTM_BLE_AUTH_SIGN_LEN       12                   /* BLE data signature length 8 Bytes + 4 bytes counter*/
150 typedef UINT8 BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN];         /* Device address */
151 
152 #ifndef BTM_BLE_HOST_SUPPORT
153 #define BTM_BLE_HOST_SUPPORT		0x01
154 #endif
155 
156 #ifndef BTM_BLE_SIMULTANEOUS_HOST
157 #define BTM_BLE_SIMULTANEOUS_HOST	0x01
158 #endif
159 
160 /* Structure returned with Rand/Encrypt complete callback */
161 typedef struct
162 {
163     UINT8   status;
164     UINT8   param_len;
165     UINT16  opcode;
166     UINT8   param_buf[BT_OCTET16_LEN];
167 } tBTM_RAND_ENC;
168 
169 /* General callback function for notifying an application that a synchronous
170 ** BTM function is complete. The pointer contains the address of any returned data.
171 */
172 typedef void (tBTM_RAND_ENC_CB) (tBTM_RAND_ENC *p1);
173 
174 #define BTM_BLE_FILTER_TARGET_SCANNER       0x01
175 #define BTM_BLE_FILTER_TARGET_ADVR          0x00
176 
177 #define BTM_BLE_POLICY_BLACK_ALL            0x00    /* relevant to both */
178 #define BTM_BLE_POLICY_ALLOW_SCAN           0x01    /* relevant to advertiser */
179 #define BTM_BLE_POLICY_ALLOW_CONN           0x02    /* relevant to advertiser */
180 #define BTM_BLE_POLICY_WHITE_ALL            0x03    /* relevant to both */
181 
182 typedef struct
183 {
184     UINT8               adv_int_min;
185     UINT8               adv_int_max;
186     tBTM_BLE_CHNL_MAP   chnl_map;
187 
188 }tBTM_BLE_ADV_PARAMS;
189 
190 /* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */
191 #define BTM_BLE_LIMIT_DISC_FLAG         (0x01 << 0)
192 #define BTM_BLE_GEN_DISC_FLAG           (0x01 << 1)
193 #define BTM_BLE_BREDR_NOT_SPT           (0x01 << 2)
194 #define BTM_BLE_NON_LIMIT_DISC_FLAG     (0x00 )         /* lowest bit unset */
195 #define BTM_BLE_ADV_FLAG_MASK           (BTM_BLE_LIMIT_DISC_FLAG | BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG)
196 #define BTM_BLE_LIMIT_DISC_MASK         (BTM_BLE_LIMIT_DISC_FLAG )
197 
198 #define BTM_BLE_AD_BIT_DEV_NAME        (0x0001 << 0)
199 #define BTM_BLE_AD_BIT_FLAGS           (0x0001 << 1)
200 #define BTM_BLE_AD_BIT_MANU            (0x0001 << 2)
201 #define BTM_BLE_AD_BIT_TX_PWR          (0x0001 << 3)
202 #define BTM_BLE_AD_BIT_INT_RANGE       (0x0001 << 5)
203 #define BTM_BLE_AD_BIT_SERVICE         (0x0001 << 6)
204 #define BTM_BLE_AD_BIT_SERVICE_SOL     (0x0001 << 7)
205 #define BTM_BLE_AD_BIT_SERVICE_DATA    (0x0001 << 8)
206 #define BTM_BLE_AD_BIT_SIGN_DATA       (0x0001 << 9)
207 #define BTM_BLE_AD_BIT_SERVICE_128SOL  (0x0001 << 10)
208 #define BTM_BLE_AD_BIT_APPEARANCE      (0x0001 << 11)
209 #define BTM_BLE_AD_BIT_PUBLIC_ADDR      (0x0001 << 12)
210 #define BTM_BLE_AD_BIT_RANDOM_ADDR      (0x0001 << 13)
211 
212 #define BTM_BLE_AD_BIT_PROPRIETARY     (0x0001 << 15)
213 
214 typedef  UINT16  tBTM_BLE_AD_MASK;
215 
216 #define BTM_BLE_AD_TYPE_FLAG            HCI_EIR_FLAGS_TYPE                  /* 0x01 */
217 #define BTM_BLE_AD_TYPE_16SRV_PART      HCI_EIR_MORE_16BITS_UUID_TYPE       /* 0x02 */
218 #define BTM_BLE_AD_TYPE_16SRV_CMPL      HCI_EIR_COMPLETE_16BITS_UUID_TYPE   /* 0x03 */
219 #define BTM_BLE_AD_TYPE_32SRV_PART      HCI_EIR_MORE_32BITS_UUID_TYPE       /* 0x04 */
220 #define BTM_BLE_AD_TYPE_32SRV_CMPL      HCI_EIR_COMPLETE_32BITS_UUID_TYPE   /* 0x05 */
221 #define BTM_BLE_AD_TYPE_128SRV_PART     HCI_EIR_MORE_128BITS_UUID_TYPE       /* 0x06 */
222 #define BTM_BLE_AD_TYPE_128SRV_CMPL     HCI_EIR_COMPLETE_128BITS_UUID_TYPE   /* 0x07 */
223 #define BTM_BLE_AD_TYPE_NAME_SHORT      HCI_EIR_SHORTENED_LOCAL_NAME_TYPE       /* 0x08 */
224 #define BTM_BLE_AD_TYPE_NAME_CMPL       HCI_EIR_COMPLETE_LOCAL_NAME_TYPE        /* 0x09 */
225 #define BTM_BLE_AD_TYPE_TX_PWR          HCI_EIR_TX_POWER_LEVEL_TYPE             /* 0x0A */
226 #define BTM_BLE_AD_TYPE_DEV_CLASS       0x0D
227 #define BTM_BLE_AD_TYPE_SM_TK           0x10
228 #define BTM_BLE_AD_TYPE_SM_OOB_FLAG     0x11
229 #define BTM_BLE_AD_TYPE_INT_RANGE       0x12
230 #define BTM_BLE_AD_TYPE_SOL_SRV_UUID    0x14
231 #define BTM_BLE_AD_TYPE_128SOL_SRV_UUID 0x15
232 #define BTM_BLE_AD_TYPE_SERVICE_DATA    0x16
233 #define BTM_BLE_AD_TYPE_PUBLIC_TARGET   0x17
234 #define BTM_BLE_AD_TYPE_RANDOM_TARGET   0x18
235 #define BTM_BLE_AD_TYPE_APPEARANCE      0x19
236 #define BTM_BLE_AD_TYPE_MANU            HCI_EIR_MANUFACTURER_SPECIFIC_TYPE      /* 0xff */
237 typedef UINT8   tBTM_BLE_AD_TYPE;
238 
239 /* slave preferred connection interval range */
240 typedef struct
241 {
242     UINT16  low;
243     UINT16  hi;
244 
245 }tBTM_BLE_INT_RANGE;
246 
247 /* Service tag supported in the device */
248 typedef struct
249 {
250     UINT8       num_service;
251     BOOLEAN     list_cmpl;
252     UINT16      *p_uuid;
253 }tBTM_BLE_SERVICE;
254 
255 typedef struct
256 {
257     UINT8       len;
258     UINT8      *p_val;
259 }tBTM_BLE_MANU;
260 
261 typedef struct
262 {
263     UINT8       adv_type;
264     UINT8       len;
265     UINT8       *p_val;     /* number of len byte */
266 }tBTM_BLE_PROP_ELEM;
267 
268 typedef struct
269 {
270     UINT8                   num_elem;
271     tBTM_BLE_PROP_ELEM      *p_elem;
272 }tBTM_BLE_PROPRIETARY;
273 
274 typedef struct
275 {
276     tBTM_BLE_MANU           manu;			/* manufactuer data */
277     tBTM_BLE_INT_RANGE      int_range;      /* slave prefered conn interval range */
278     tBTM_BLE_SERVICE        services;       /* services */
279     UINT8                   flag;
280     UINT16                  appearance;
281     tBTM_BLE_PROPRIETARY    *p_proprietary;
282 }tBTM_BLE_ADV_DATA;
283 
284 /* These are the fields returned in each device adv packet.  It
285 ** is returned in the results callback if registered.
286 */
287 typedef struct
288 {
289     UINT8               conn_mode;
290     tBTM_BLE_AD_MASK    ad_mask;        /* mask of the valid adv data field */
291     UINT8               flag;
292     UINT8               tx_power_level;
293     UINT8               remote_name_len;
294     UINT8               *p_remote_name;
295     tBTM_BLE_SERVICE    service;
296 } tBTM_BLE_INQ_DATA;
297 
298 enum
299 {
300     BTM_BLE_CONN_NONE,
301     BTM_BLE_CONN_AUTO,
302     BTM_BLE_CONN_SELECTIVE
303 };
304 typedef UINT8   tBTM_BLE_CONN_TYPE;
305 
306 typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda,     UINT8 *p_remote_name);
307 
308 /* callback function for SMP signing algorithm, signed data in little endian order with tlen bits long */
309 typedef void (tBTM_BLE_SIGN_CBACK)(void *p_ref_data, UINT8 *p_signing_data);
310 typedef void (tBTM_BLE_VERIFY_CBACK)(void *p_ref_data, BOOLEAN match);
311 /* random address set complete callback */
312 typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda);
313 
314 typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt);
315 
316 /*****************************************************************************
317 **  EXTERNAL FUNCTION DECLARATIONS
318 *****************************************************************************/
319 #ifdef __cplusplus
320 extern "C" {
321 #endif
322 /*******************************************************************************
323 **
324 ** Function         BTM_SecAddBleDevice
325 **
326 ** Description      Add/modify device.  This function will be normally called
327 **                  during host startup to restore all required information
328 **                  for a LE device stored in the NVRAM.
329 **
330 ** Parameters:      bd_addr          - BD address of the peer
331 **                  bd_name          - Name of the peer device.  NULL if unknown.
332 **                  dev_type         - Remote device's device type.
333 **                  addr_type        - LE device address type.
334 **
335 ** Returns          TRUE if added OK, else FALSE
336 **
337 *******************************************************************************/
338 BTM_API extern BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name,
339                                            tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type);
340 
341 /*******************************************************************************
342 **
343 ** Function         BTM_SecAddBleKey
344 **
345 ** Description      Add/modify LE device information.  This function will be
346 **                  normally called during host startup to restore all required
347 **                  information stored in the NVRAM.
348 **
349 ** Parameters:      bd_addr          - BD address of the peer
350 **                  p_le_key         - LE key values.
351 **                  key_type         - LE SMP key type.
352 *
353 ** Returns          TRUE if added OK, else FALSE
354 **
355 *******************************************************************************/
356 BTM_API extern BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key,
357                                          tBTM_LE_KEY_TYPE key_type);
358 
359 /*******************************************************************************
360 **
361 ** Function         BTM_BleSetAdvParams
362 **
363 ** Description      This function is called to set advertising parameters.
364 **
365 ** Parameters:       None.
366 **
367 ** Returns          void
368 **
369 *******************************************************************************/
370 BTM_API extern tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
371                                 tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map);
372 
373 /*******************************************************************************
374 **
375 ** Function         BTM_BleWriteAdvData
376 **
377 ** Description      This function is called to write advertising data.
378 **
379 ** Parameters:       None.
380 **
381 ** Returns          void
382 **
383 *******************************************************************************/
384 BTM_API extern tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK  data_mask,
385                                                tBTM_BLE_ADV_DATA *p_data);
386 
387 /*******************************************************************************
388 **
389 ** Function         BTM_BleSetAdvParams
390 **
391 ** Description      This function is called to set advertising parameters.
392 **
393 ** Parameters       adv_int_min: minimum advertising interval
394 **                  adv_int_max: maximum advertising interval
395 **                  p_dir_bda: connectable direct initiator's LE device address
396 **                  chnl_map: advertising channel map.
397 **
398 ** Returns          void
399 **
400 *******************************************************************************/
401 BTM_API extern void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max,
402                             tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map);
403 
404 
405 /*******************************************************************************
406 **
407 ** Function         BTM_BleSetScanParams
408 **
409 ** Description      This function is called to set Scan parameters.
410 **
411 ** Parameters       adv_int_min: minimum advertising interval
412 **                  adv_int_max: maximum advertising interval
413 **                  scan_type: scan mode.
414 **
415 ** Returns          void
416 **
417 *******************************************************************************/
418 BTM_API extern void BTM_BleSetScanParams(UINT16 scan_interval, UINT16 scan_window,
419                                          tBTM_BLE_SCAN_MODE scan_type);
420 
421 /*******************************************************************************
422 **
423 ** Function         BTM_BleWriteScanRsp
424 **
425 ** Description      This function is called to write LE scan response.
426 **
427 ** Parameters:      p_scan_rsp: scan response.
428 **
429 ** Returns          status
430 **
431 *******************************************************************************/
432 BTM_API extern tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
433                                                tBTM_BLE_ADV_DATA *p_data);
434 
435 /*******************************************************************************
436 **
437 ** Function         BTM_BleReset
438 **
439 ** Description      This function is called to reset ULP controller.
440 **
441 ** Parameters       None.
442 **
443 ** Returns          void
444 **
445 *******************************************************************************/
446 BTM_API extern void BTM_BleReset(void);
447 
448 /*******************************************************************************
449 **
450 ** Function         BTM_BleObserve
451 **
452 ** Description      This procedure keep the device listening for advertising
453 **                  events from a broadcast device.
454 **
455 ** Parameters       start: start or stop observe.
456 **
457 ** Returns          void
458 **
459 *******************************************************************************/
460 BTM_API extern tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration,
461                            tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb);
462 
463 
464 /*******************************************************************************
465 **
466 ** Function         BTM_GetDeviceIDRoot
467 **
468 ** Description      This function is called to read the local device identity
469 **                  root.
470 **
471 ** Returns          void
472 **                  the local device ER is copied into er
473 **
474 *******************************************************************************/
475 BTM_API extern void BTM_GetDeviceIDRoot (BT_OCTET16 ir);
476 
477 /*******************************************************************************
478 **
479 ** Function         BTM_GetDeviceEncRoot
480 **
481 ** Description      This function is called to read the local device encryption
482 **                  root.
483 **
484 ** Returns          void
485 **                  the local device ER is copied into er
486 **
487 *******************************************************************************/
488 BTM_API extern void BTM_GetDeviceEncRoot (BT_OCTET16 er);
489 
490 /*******************************************************************************
491 **
492 ** Function         BTM_GetDeviceDHK
493 **
494 ** Description      This function is called to read the local device DHK.
495 **
496 ** Returns          void
497 **                  the local device DHK is copied into dhk
498 **
499 *******************************************************************************/
500 BTM_API extern void BTM_GetDeviceDHK (BT_OCTET16 dhk);
501 
502 /*******************************************************************************
503 **
504 ** Function         BTM_SecurityGrant
505 **
506 ** Description      This function is called to grant security process.
507 **
508 ** Parameters       bd_addr - peer device bd address.
509 **                  res     - result of the operation BTM_SUCCESS if success.
510 **                            Otherwise, BTM_REPEATED_ATTEMPTS is too many attempts.
511 **
512 ** Returns          None
513 **
514 *******************************************************************************/
515 BTM_API extern void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res);
516 
517 /*******************************************************************************
518 **
519 ** Function         BTM_BlePasskeyReply
520 **
521 ** Description      This function is called after Security Manager submitted
522 **                  passkey request to the application.
523 **
524 ** Parameters:      bd_addr      - Address of the device for which passkey was requested
525 **                  res          - result of the operation SMP_SUCCESS if success
526 **                  passkey - numeric value in the range of
527 **                  BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
528 **
529 *******************************************************************************/
530 BTM_API extern void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey);
531 
532 /*******************************************************************************
533 **
534 ** Function         BTM_LeOobDataReply
535 **
536 ** Description      This function is called to provide the OOB data for
537 **                  SMP in response to BTM_LE_OOB_REQ_EVT
538 **
539 ** Parameters:      bd_addr     - Address of the peer device
540 **                  res         - result of the operation SMP_SUCCESS if success
541 **                  p_data      - simple pairing Randomizer  C.
542 **
543 *******************************************************************************/
544 BTM_API extern void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data);
545 
546 
547 /*******************************************************************************
548 **
549 ** Function         BTM_BleDataSignature
550 **
551 ** Description      This function is called to sign the data using AES128 CMAC
552 **                  algorith.
553 **
554 ** Parameter        bd_addr: target device the data to be signed for.
555 **                  p_text: singing data
556 **                  len: length of the signing data
557 **                  signature: output parameter where data signature is going to
558 **                             be stored.
559 **
560 ** Returns          TRUE if signing sucessul, otherwise FALSE.
561 **
562 *******************************************************************************/
563 BTM_API extern BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len,
564                                              BLE_SIGNATURE signature);
565 
566 /*******************************************************************************
567 **
568 ** Function         BTM_BleVerifySignature
569 **
570 ** Description      This function is called to verify the data signature
571 **
572 ** Parameter        bd_addr: target device the data to be signed for.
573 **                  p_orig:  original data before signature.
574 **                  len: length of the signing data
575 **                  counter: counter used when doing data signing
576 **                  p_comp: signature to be compared against.
577 
578 ** Returns          TRUE if signature verified correctly; otherwise FALSE.
579 **
580 *******************************************************************************/
581 BTM_API extern BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig,
582                                             UINT16 len, UINT32 counter,
583                                             UINT8 *p_comp);
584 
585 /*******************************************************************************
586 **
587 ** Function         BTM_ReadConnectionAddr
588 **
589 ** Description      This function is called to set the local device random address
590 **                  .
591 **
592 ** Returns          void
593 **
594 *******************************************************************************/
595 BTM_API extern void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr,
596                                             tBLE_ADDR_TYPE *p_addr_type);
597 
598 
599 
600 /*******************************************************************************
601 **
602 ** Function         BTM_ReadRemoteConnectionAddr
603 **
604 ** Description      This function is read the remote device address currently used
605 **                  .
606 **
607 ** Returns          void
608 **
609 *******************************************************************************/
610 BTM_API extern BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr,
611                                                     BD_ADDR conn_addr,
612                                                     tBLE_ADDR_TYPE *p_addr_type);
613 
614 /*******************************************************************************
615 **
616 ** Function         BTM_BleLoadLocalKeys
617 **
618 ** Description      Local local identity key, encryption root or sign counter.
619 **
620 ** Parameters:      key_type: type of key, can be BTM_BLE_KEY_TYPE_ID, BTM_BLE_KEY_TYPE_ER
621 **                            or BTM_BLE_KEY_TYPE_COUNTER.
622 **                  p_key: pointer to the key.
623 *
624 ** Returns          non2.
625 **
626 *******************************************************************************/
627 BTM_API extern void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
628 
629 
630 /*******************************************************************************
631 **
632 ** Function         BTM_BleSetBgConnType
633 **
634 ** Description      This function is called to set BLE background connection
635 **                  procedure type. It can be auto connection, or selective connection.
636 **
637 ** Parameters       conn_type: it can be auto connection, or selective connection.
638 **                  p_select_cback: callback function when selective connection procedure
639 **                              is being used.
640 **
641 ** Returns          void
642 **
643 *******************************************************************************/
644 BTM_API extern BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE   conn_type,
645                                     tBTM_BLE_SEL_CBACK   *p_select_cback);
646 
647 /*******************************************************************************
648 **
649 ** Function         BTM_BleUpdateBgConnDev
650 **
651 ** Description      This function is called to add or remove a device into/from
652 **                  background connection procedure. The background connection
653 *                   procedure is decided by the background connection type, it can be
654 *                   auto connection, or selective connection.
655 **
656 ** Parameters       add_remove: TRUE to add; FALSE to remove.
657 **                  remote_bda: device address to add/remove.
658 **
659 ** Returns          void
660 **
661 *******************************************************************************/
662 BTM_API extern BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR   remote_bda);
663 
664 
665 /********************************************************
666 **
667 ** Function         BTM_BleSetPrefConnParams
668 **
669 ** Description      Set a peripheral's preferred connection parameters. When
670 **                  any of the value does not want to be updated while others
671 **                  do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to
672 **                  leave untouched.
673 **
674 ** Parameters:      bd_addr          - BD address of the peripheral
675 **                  min_conn_int     - minimum preferred connection interval
676 **                  max_conn_int     - maximum preferred connection interval
677 **                  slave_latency    - preferred slave latency
678 **                  supervision_tout - preferred supervision timeout
679 **
680 ** Returns          void
681 **
682 *******************************************************************************/
683 BTM_API extern  void BTM_BleSetPrefConnParams (BD_ADDR bd_addr,
684                                                UINT16 min_conn_int,  UINT16 max_conn_int,
685                                                UINT16 slave_latency, UINT16 supervision_tout);
686 
687 /******************************************************************************
688 **
689 ** Function         BTM_BleSetConnScanParams
690 **
691 ** Description      Set scan parameters used in BLE connection request
692 **
693 ** Parameters:      scan_interval    - scan interval
694 **                  scan_window      - scan window
695 **
696 ** Returns          void
697 **
698 *******************************************************************************/
699 BTM_API extern  void BTM_BleSetConnScanParams (UINT16 scan_interval, UINT16 scan_window);
700 
701 /*******************************************************************************
702 **
703 ** Function         BTM_CheckAdvData
704 **
705 ** Description      This function is called to get ADV data for a specific type.
706 **
707 ** Parameters       p_adv - pointer of ADV data
708 **                  type   - finding ADV data type
709 **                  p_length - return the length of ADV data not including type
710 **
711 ** Returns          pointer of ADV data
712 **
713 *******************************************************************************/
714 BTM_API extern  UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length);
715 
716 /*******************************************************************************
717 **
718 ** Function         BTM_ReadDevInfo
719 **
720 ** Description      This function is called to read the device/address type
721 **                  of BD address.
722 **
723 ** Parameter        remote_bda: remote device address
724 **                  p_dev_type: output parameter to read the device type.
725 **                  p_addr_type: output parameter to read the address type.
726 **
727 *******************************************************************************/
728 BTM_API extern void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type,
729                                      tBLE_ADDR_TYPE *p_addr_type);
730 
731 /*******************************************************************************
732 **
733 ** Function         BTM_BleBroadcast
734 **
735 ** Description      This function is to start or stop broadcasting.
736 **
737 ** Parameters       start: start or stop broadcasting.
738 **
739 ** Returns          status.
740 **
741 *******************************************************************************/
742 BTM_API extern tBTM_STATUS BTM_BleBroadcast(BOOLEAN start);
743 
744 /*******************************************************************************
745 **
746 ** Function         BTM_RegisterScanReqEvt
747 **
748 ** Description      This function is called to register a scan request callback
749 **                  on the advertiser.
750 **
751 ** Parameters       p_scan_req_cback: scan request callback.  If NULL, remove the
752 **                                    registration.
753 **
754 ** Returns          void
755 **
756 *******************************************************************************/
757 BTM_API extern void BTM_RegisterScanReqEvt(tBTM_BLE_SCAN_REQ_CBACK *p_scan_req_cback);
758 
759 /*******************************************************************************
760 **
761 ** Function         BTM_BleConfigPrivacy
762 **
763 ** Description      This function is called to enable or disable the privacy in
764 **                  the local device.
765 **
766 ** Parameters       enable: TRUE to enable it; FALSE to disable it.
767 **
768 ** Returns          void
769 **
770 *******************************************************************************/
771 BTM_API extern void BTM_BleConfigPrivacy(BOOLEAN enable);
772 
773 /*******************************************************************************
774 **
775 ** Function         BTM_BleSetConnMode
776 **
777 ** Description      This function is called to set BLE connectable mode for a
778 **                  peripheral device.
779 **
780 ** Parameters       directed: is directed connectable mode, or non-directed.
781 **                  p_dir_bda: connectable direct initiator's LE device address
782 **
783 ** Returns          void
784 **
785 *******************************************************************************/
786 BTM_API extern tBTM_STATUS BTM_BleSetConnMode(BOOLEAN directed);
787 
788 /*******************************************************************************
789 **
790 ** Function         BTM_BleTurnOnPrivacyOnRemote
791 **
792 ** Description      This function is called to enable or disable the privacy on the
793 **                  remote device.
794 **
795 ** Parameters       bd_addr: remote device address.
796 **                  privacy_on: TRUE to enable it; FALSE to disable it.
797 **
798 ** Returns          void
799 **
800 *******************************************************************************/
801 BTM_API extern void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr,
802                                                  BOOLEAN privacy_on);
803 
804 
805 /*******************************************************************************
806 **
807 ** Function         BTM_BleUpdateAdvWhitelist
808 **
809 ** Description      Add or remove device from advertising white list
810 **
811 ** Returns          void
812 **
813 *******************************************************************************/
814 BTM_API extern BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda);
815 
816 /*******************************************************************************
817 **
818 ** Function         BTM_BleUpdateAdvFilterPolicy
819 **
820 ** Description      This function update the filter policy of advertiser.
821 **
822 ** Parameter        adv_policy: advertising filter policy
823 **
824 ** Return           void
825 *******************************************************************************/
826 BTM_API extern void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy);
827 
828 /*******************************************************************************
829 **
830 ** Function         BTM_BleReceiverTest
831 **
832 ** Description      This function is called to start the LE Receiver test
833 **
834 ** Parameter       rx_freq - Frequency Range
835 **               p_cmd_cmpl_cback - Command Complete callback
836 **
837 *******************************************************************************/
838 void BTM_BleReceiverTest(UINT8 rx_freq, tBTM_CMPL_CB *p_cmd_cmpl_cback);
839 
840 
841 /*******************************************************************************
842 **
843 ** Function         BTM_BleTransmitterTest
844 **
845 ** Description      This function is called to start the LE Transmitter test
846 **
847 ** Parameter       tx_freq - Frequency Range
848 **                       test_data_len - Length in bytes of payload data in each packet
849 **                       packet_payload - Pattern to use in the payload
850 **                       p_cmd_cmpl_cback - Command Complete callback
851 **
852 *******************************************************************************/
853 void BTM_BleTransmitterTest(UINT8 tx_freq, UINT8 test_data_len,
854                                  UINT8 packet_payload, tBTM_CMPL_CB *p_cmd_cmpl_cback);
855 
856 /*******************************************************************************
857 **
858 ** Function         BTM_BleTestEnd
859 **
860 ** Description      This function is called to stop the in-progress TX or RX test
861 **
862 ** Parameter       p_cmd_cmpl_cback - Command complete callback
863 **
864 *******************************************************************************/
865 void BTM_BleTestEnd(tBTM_CMPL_CB *p_cmd_cmpl_cback);
866 #ifdef __cplusplus
867 }
868 #endif
869 
870 #endif
871