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 "common/bt_defs.h"
29 #include "stack/btm_api.h"
30 #include "common/bt_common_types.h"
31 
32 #define CHANNEL_MAP_LEN    5
33 typedef UINT8 tBTM_BLE_CHNL_MAP[CHANNEL_MAP_LEN];
34 
35 /* 0x00-0x04 only used for set advertising parameter command */
36 #define BTM_BLE_CONNECT_EVT     0x00   /* 0x00-0x04 only used for set advertising
37                                             parameter command */
38 #define BTM_BLE_CONNECT_DIR_EVT 0x01   /* Connectable directed advertising */
39 #define BTM_BLE_DISCOVER_EVT    0x02  /* Scannable undirected advertising */
40 #define BTM_BLE_NON_CONNECT_EVT 0x03  /* Non connectable undirected advertising */
41 #define BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 0x04        /* Connectable low duty
42                                                        cycle directed advertising  */
43 /* 0x00 - 0x05 can be received on adv event type */
44 #define BTM_BLE_SCAN_RSP_EVT    0x04
45 #define BTM_BLE_SCAN_REQ_EVT    0x05
46 #define BTM_BLE_UNKNOWN_EVT     0xff
47 
48 #define BTM_BLE_UNKNOWN_EVT     0xff
49 
50 typedef UINT8 tBTM_BLE_EVT;
51 typedef UINT8 tBTM_BLE_CONN_MODE;
52 
53 typedef UINT32 tBTM_BLE_REF_VALUE;
54 
55 #define BTM_BLE_SCAN_MODE_PASS      0
56 #define BTM_BLE_SCAN_MODE_ACTI      1
57 #define BTM_BLE_SCAN_MODE_NONE      0xff
58 typedef UINT8 tBLE_SCAN_MODE;
59 
60 #define BTM_BLE_BATCH_SCAN_MODE_DISABLE 0
61 #define BTM_BLE_BATCH_SCAN_MODE_PASS  1
62 #define BTM_BLE_BATCH_SCAN_MODE_ACTI  2
63 #define BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI 3
64 
65 typedef UINT8 tBTM_BLE_BATCH_SCAN_MODE;
66 
67 /* advertising channel map */
68 #define BTM_BLE_ADV_CHNL_37    (0x01 << 0)
69 #define BTM_BLE_ADV_CHNL_38    (0x01 << 1)
70 #define BTM_BLE_ADV_CHNL_39    (0x01 << 2)
71 typedef UINT8 tBTM_BLE_ADV_CHNL_MAP;
72 
73 /*d efault advertising channel map */
74 #ifndef BTM_BLE_DEFAULT_ADV_CHNL_MAP
75 #define BTM_BLE_DEFAULT_ADV_CHNL_MAP   (BTM_BLE_ADV_CHNL_37| BTM_BLE_ADV_CHNL_38| BTM_BLE_ADV_CHNL_39)
76 #endif
77 
78 /* advertising filter policy */
79 #define AP_SCAN_CONN_ALL           0x00        /* default */
80 #define AP_SCAN_WL_CONN_ALL        0x01
81 #define AP_SCAN_ALL_CONN_WL        0x02
82 #define AP_SCAN_CONN_WL            0x03
83 #define AP_SCAN_CONN_POLICY_MAX    0x04
84 typedef UINT8   tBTM_BLE_AFP;
85 
86 /* default advertising filter policy */
87 #ifndef BTM_BLE_DEFAULT_AFP
88 #define BTM_BLE_DEFAULT_AFP   AP_SCAN_CONN_ALL
89 #endif
90 
91 /* scanning filter policy */
92 #define SP_ADV_ALL     0x00     /* 0: accept adv packet from all, directed adv pkt not directed */
93 /* to local device is ignored */
94 #define SP_ADV_WL      0x01     /* 1: accept adv packet from device in white list, directed adv */
95 /* packet not directed to local device is ignored */
96 #define SP_ADV_ALL_RPA_DIR_ADV 0x02  /* 2: accept adv packet from all, directed adv pkt */
97 /* not directed to me is ignored except direct adv with RPA */
98 #define SP_ADV_WL_RPA_DIR_ADV  0x03  /* 3: accept adv packet from device in white list, directed */
99 /* adv pkt not directed to me is ignored except direct adv */
100 /* with RPA */
101 typedef UINT8   tBTM_BLE_SFP;
102 
103 #ifndef BTM_BLE_DEFAULT_SFP
104 #define BTM_BLE_DEFAULT_SFP   SP_ADV_ALL
105 #endif
106 
107 /* adv parameter boundary values */
108 #define BTM_BLE_ADV_INT_MIN            0x0020
109 #define BTM_BLE_ADV_INT_MAX            0x4000
110 
111 /* Full scan boundary values */
112 #define BTM_BLE_ADV_SCAN_FULL_MIN      0x00
113 #define BTM_BLE_ADV_SCAN_FULL_MAX      0x64
114 
115 /* Partial scan boundary values */
116 #define BTM_BLE_ADV_SCAN_TRUNC_MIN      BTM_BLE_ADV_SCAN_FULL_MIN
117 #define BTM_BLE_ADV_SCAN_TRUNC_MAX      BTM_BLE_ADV_SCAN_FULL_MAX
118 
119 /* Threshold values */
120 #define BTM_BLE_ADV_SCAN_THR_MIN        BTM_BLE_ADV_SCAN_FULL_MIN
121 #define BTM_BLE_ADV_SCAN_THR_MAX        BTM_BLE_ADV_SCAN_FULL_MAX
122 
123 /* connection parameter boundary values */
124 #define BTM_BLE_SCAN_INT_MIN            0x0004
125 #define BTM_BLE_SCAN_INT_MAX            0x4000
126 #define BTM_BLE_SCAN_WIN_MIN            0x0004
127 #define BTM_BLE_SCAN_WIN_MAX            0x4000
128 #define BTM_BLE_EXT_SCAN_INT_MAX        0x00FFFFFF
129 #define BTM_BLE_EXT_SCAN_WIN_MAX        0xFFFF
130 #define BTM_BLE_CONN_INT_MIN            0x0006
131 #define BTM_BLE_CONN_INT_MAX            0x0C80
132 #define BTM_BLE_CONN_LATENCY_MAX        499
133 #define BTM_BLE_CONN_SUP_TOUT_MIN       0x000A
134 #define BTM_BLE_CONN_SUP_TOUT_MAX       0x0C80
135 #define BTM_BLE_CONN_PARAM_UNDEF        0xffff      /* use this value when a specific value not to be overwritten */
136 #define BTM_BLE_SCAN_PARAM_UNDEF        0xffffffff
137 
138 /* default connection parameters if not configured, use GAP recommend value for auto/selective connection */
139 /* default scan interval */
140 #ifndef BTM_BLE_SCAN_FAST_INT
141 #define BTM_BLE_SCAN_FAST_INT    96    /* 30 ~ 60 ms (use 60)  = 96 *0.625 */
142 #endif
143 /* default scan window for background connection, applicable for auto connection or selective conenction */
144 #ifndef BTM_BLE_SCAN_FAST_WIN
145 #define BTM_BLE_SCAN_FAST_WIN   48      /* 30 ms = 48 *0.625 */
146 #endif
147 
148 /* default scan paramter used in reduced power cycle (background scanning) */
149 #ifndef BTM_BLE_SCAN_SLOW_INT_1
150 #define BTM_BLE_SCAN_SLOW_INT_1    2048    /* 1.28 s   = 2048 *0.625 */
151 #endif
152 #ifndef BTM_BLE_SCAN_SLOW_WIN_1
153 #define BTM_BLE_SCAN_SLOW_WIN_1   48      /* 30 ms = 48 *0.625 */
154 #endif
155 
156 /* default scan paramter used in reduced power cycle (background scanning) */
157 #ifndef BTM_BLE_SCAN_SLOW_INT_2
158 #define BTM_BLE_SCAN_SLOW_INT_2    4096    /* 2.56 s   = 4096 *0.625 */
159 #endif
160 #ifndef BTM_BLE_SCAN_SLOW_WIN_2
161 #define BTM_BLE_SCAN_SLOW_WIN_2   36      /* 22.5 ms = 36 *0.625 */
162 #endif
163 
164 /* default connection interval min */
165 #ifndef BTM_BLE_CONN_INT_MIN_DEF
166 #define BTM_BLE_CONN_INT_MIN_DEF     10      /* recommended min: 12.5 ms  = 10 * 1.25 */
167 #endif
168 
169 /* default connection interval max */
170 #ifndef BTM_BLE_CONN_INT_MAX_DEF
171 #define BTM_BLE_CONN_INT_MAX_DEF     12      /* recommended max: 15 ms = 12 * 1.25 */
172 #endif
173 
174 /* default slave latency */
175 #ifndef BTM_BLE_CONN_SLAVE_LATENCY_DEF
176 #define BTM_BLE_CONN_SLAVE_LATENCY_DEF  0      /* 0 */
177 #endif
178 
179 /* default supervision timeout */
180 #ifndef BTM_BLE_CONN_TIMEOUT_DEF
181 #define BTM_BLE_CONN_TIMEOUT_DEF    600
182 #endif
183 
184 /* minimum acceptable connection interval */
185 #ifndef BTM_BLE_CONN_INT_MIN_LIMIT
186 #define BTM_BLE_CONN_INT_MIN_LIMIT     0x0009
187 #endif
188 
189 #define BTM_BLE_DIR_CONN_FALLBACK_UNDIR         1
190 #define BTM_BLE_DIR_CONN_FALLBACK_NO_ADV        2
191 
192 #ifndef BTM_BLE_DIR_CONN_FALLBACK
193 #define BTM_BLE_DIR_CONN_FALLBACK   BTM_BLE_DIR_CONN_FALLBACK_UNDIR
194 #endif
195 
196 #define BTM_CMAC_TLEN_SIZE          8                   /* 64 bits */
197 #define BTM_BLE_AUTH_SIGN_LEN       12                   /* BLE data signature length 8 Bytes + 4 bytes counter*/
198 typedef UINT8 BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN];         /* Device address */
199 
200 #ifndef BTM_BLE_HOST_SUPPORT
201 #define BTM_BLE_HOST_SUPPORT        0x01
202 #endif
203 
204 #ifndef BTM_BLE_SIMULTANEOUS_HOST
205 #define BTM_BLE_SIMULTANEOUS_HOST   0x01
206 #endif
207 
208 /* Appearance Values Reported with BTM_BLE_AD_TYPE_APPEARANCE */
209 #define BTM_BLE_APPEARANCE_UNKNOWN                 0x0000
210 #define BTM_BLE_APPEARANCE_GENERIC_PHONE           0x0040
211 #define BTM_BLE_APPEARANCE_GENERIC_COMPUTER        0x0080
212 #define BTM_BLE_APPEARANCE_GENERIC_WATCH           0x00C0
213 #define BTM_BLE_APPEARANCE_SPORTS_WATCH            0x00C1
214 #define BTM_BLE_APPEARANCE_GENERIC_CLOCK           0x0100
215 #define BTM_BLE_APPEARANCE_GENERIC_DISPLAY         0x0140
216 #define BTM_BLE_APPEARANCE_GENERIC_REMOTE          0x0180
217 #define BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES      0x01C0
218 #define BTM_BLE_APPEARANCE_GENERIC_TAG             0x0200
219 #define BTM_BLE_APPEARANCE_GENERIC_KEYRING         0x0240
220 #define BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER    0x0280
221 #define BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0
222 #define BTM_BLE_APPEARANCE_GENERIC_THERMOMETER     0x0300
223 #define BTM_BLE_APPEARANCE_THERMOMETER_EAR         0x0301
224 #define BTM_BLE_APPEARANCE_GENERIC_HEART_RATE      0x0340
225 #define BTM_BLE_APPEARANCE_HEART_RATE_BELT         0x0341
226 #define BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE  0x0380
227 #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM      0x0381
228 #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST    0x0382
229 #define BTM_BLE_APPEARANCE_GENERIC_HID             0x03C0
230 #define BTM_BLE_APPEARANCE_HID_KEYBOARD            0x03C1
231 #define BTM_BLE_APPEARANCE_HID_MOUSE               0x03C2
232 #define BTM_BLE_APPEARANCE_HID_JOYSTICK            0x03C3
233 #define BTM_BLE_APPEARANCE_HID_GAMEPAD             0x03C4
234 #define BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET    0x03C5
235 #define BTM_BLE_APPEARANCE_HID_CARD_READER         0x03C6
236 #define BTM_BLE_APPEARANCE_HID_DIGITAL_PEN         0x03C7
237 #define BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER     0x03C8
238 #define BTM_BLE_APPEARANCE_GENERIC_GLUCOSE         0x0400
239 #define BTM_BLE_APPEARANCE_GENERIC_WALKING         0x0440
240 #define BTM_BLE_APPEARANCE_WALKING_IN_SHOE         0x0441
241 #define BTM_BLE_APPEARANCE_WALKING_ON_SHOE         0x0442
242 #define BTM_BLE_APPEARANCE_WALKING_ON_HIP          0x0443
243 #define BTM_BLE_APPEARANCE_GENERIC_CYCLING         0x0480
244 #define BTM_BLE_APPEARANCE_CYCLING_COMPUTER        0x0481
245 #define BTM_BLE_APPEARANCE_CYCLING_SPEED           0x0482
246 #define BTM_BLE_APPEARANCE_CYCLING_CADENCE         0x0483
247 #define BTM_BLE_APPEARANCE_CYCLING_POWER           0x0484
248 #define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE   0x0485
249 #define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER  0x0C40
250 #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41
251 #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST    0x0C42
252 #define BTM_BLE_APPEARANCE_GENERIC_WEIGHT          0x0C80
253 #define BTM_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE    0x0CC0
254 #define BTM_BLE_APPEARANCE_POWERED_WHEELCHAIR                  0x0CC1
255 #define BTM_BLE_APPEARANCE_MOBILITY_SCOOTER                    0x0CC2
256 #define BTM_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR  0x0D00
257 #define BTM_BLE_APPEARANCE_GENERIC_INSULIN_PUMP                0x0D40
258 #define BTM_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP           0x0D41
259 #define BTM_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP             0x0D44
260 #define BTM_BLE_APPEARANCE_INSULIN_PEN                         0x0D48
261 #define BTM_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY         0x0D80
262 #define BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS  0x1440
263 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441
264 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV     0x1442
265 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD         0x1443
266 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444
267 
268 
269 /* Structure returned with Rand/Encrypt complete callback */
270 typedef struct {
271     UINT8   status;
272     UINT8   param_len;
273     UINT16  opcode;
274     UINT8   param_buf[BT_OCTET16_LEN];
275 } tBTM_RAND_ENC;
276 
277 /* General callback function for notifying an application that a synchronous
278 ** BTM function is complete. The pointer contains the address of any returned data.
279 */
280 typedef void (tBTM_RAND_ENC_CB) (tBTM_RAND_ENC *p1);
281 
282 #define BTM_BLE_FILTER_TARGET_SCANNER       0x01
283 #define BTM_BLE_FILTER_TARGET_ADVR          0x00
284 
285 #define BTM_BLE_POLICY_BLACK_ALL            0x00    /* relevant to both */
286 #define BTM_BLE_POLICY_ALLOW_SCAN           0x01    /* relevant to advertiser */
287 #define BTM_BLE_POLICY_ALLOW_CONN           0x02    /* relevant to advertiser */
288 #define BTM_BLE_POLICY_WHITE_ALL            0x03    /* relevant to both */
289 
290 /* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */
291 #define BTM_BLE_LIMIT_DISC_FLAG         (0x01 << 0)
292 #define BTM_BLE_GEN_DISC_FLAG           (0x01 << 1)
293 #define BTM_BLE_BREDR_NOT_SPT           (0x01 << 2)
294 /* 4.1 spec adv flag for simultaneous BR/EDR+LE connection support */
295 #define BTM_BLE_DMT_CONTROLLER_SPT      (0x01 << 3)
296 #define BTM_BLE_DMT_HOST_SPT            (0x01 << 4)
297 #define BTM_BLE_NON_LIMIT_DISC_FLAG     (0x00 )         /* lowest bit unset */
298 #define BTM_BLE_ADV_FLAG_MASK           (BTM_BLE_LIMIT_DISC_FLAG | BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG)
299 #define BTM_BLE_LIMIT_DISC_MASK         (BTM_BLE_LIMIT_DISC_FLAG )
300 
301 #define BTM_BLE_AD_BIT_DEV_NAME        (0x00000001 << 0)
302 #define BTM_BLE_AD_BIT_FLAGS           (0x00000001 << 1)
303 #define BTM_BLE_AD_BIT_MANU            (0x00000001 << 2)
304 #define BTM_BLE_AD_BIT_TX_PWR          (0x00000001 << 3)
305 #define BTM_BLE_AD_BIT_INT_RANGE       (0x00000001 << 5)
306 #define BTM_BLE_AD_BIT_SERVICE         (0x00000001 << 6)
307 #define BTM_BLE_AD_BIT_SERVICE_SOL     (0x00000001 << 7)
308 #define BTM_BLE_AD_BIT_SERVICE_DATA    (0x00000001 << 8)
309 #define BTM_BLE_AD_BIT_SIGN_DATA       (0x00000001 << 9)
310 #define BTM_BLE_AD_BIT_SERVICE_128SOL  (0x00000001 << 10)
311 #define BTM_BLE_AD_BIT_APPEARANCE      (0x00000001 << 11)
312 #define BTM_BLE_AD_BIT_PUBLIC_ADDR      (0x00000001 << 12)
313 #define BTM_BLE_AD_BIT_RANDOM_ADDR       (0x00000001 << 13)
314 #define BTM_BLE_AD_BIT_SERVICE_32        (0x00000001 << 4)
315 #define BTM_BLE_AD_BIT_SERVICE_32SOL     (0x00000001 << 14)
316 #define BTM_BLE_AD_BIT_PROPRIETARY     (0x00000001 << 15)
317 #define BTM_BLE_AD_BIT_SERVICE_128      (0x00000001 << 16)      /*128-bit Service UUIDs*/
318 
319 typedef  UINT32  tBTM_BLE_AD_MASK;
320 
321 /* relate to ESP_BLE_AD_TYPE_xxx in esp_gap_ble_api.h */
322 #define BTM_BLE_AD_TYPE_FLAG                HCI_EIR_FLAGS_TYPE                  /* 0x01 */
323 #define BTM_BLE_AD_TYPE_16SRV_PART          HCI_EIR_MORE_16BITS_UUID_TYPE       /* 0x02 */
324 #define BTM_BLE_AD_TYPE_16SRV_CMPL          HCI_EIR_COMPLETE_16BITS_UUID_TYPE   /* 0x03 */
325 #define BTM_BLE_AD_TYPE_32SRV_PART          HCI_EIR_MORE_32BITS_UUID_TYPE       /* 0x04 */
326 #define BTM_BLE_AD_TYPE_32SRV_CMPL          HCI_EIR_COMPLETE_32BITS_UUID_TYPE   /* 0x05 */
327 #define BTM_BLE_AD_TYPE_128SRV_PART         HCI_EIR_MORE_128BITS_UUID_TYPE       /* 0x06 */
328 #define BTM_BLE_AD_TYPE_128SRV_CMPL         HCI_EIR_COMPLETE_128BITS_UUID_TYPE   /* 0x07 */
329 #define BTM_BLE_AD_TYPE_NAME_SHORT          HCI_EIR_SHORTENED_LOCAL_NAME_TYPE       /* 0x08 */
330 #define BTM_BLE_AD_TYPE_NAME_CMPL           HCI_EIR_COMPLETE_LOCAL_NAME_TYPE        /* 0x09 */
331 #define BTM_BLE_AD_TYPE_TX_PWR              HCI_EIR_TX_POWER_LEVEL_TYPE             /* 0x0A */
332 #define BTM_BLE_AD_TYPE_DEV_CLASS           0x0D
333 #define BTM_BLE_AD_TYPE_SM_TK               0x10
334 #define BTM_BLE_AD_TYPE_SM_OOB_FLAG         0x11
335 #define BTM_BLE_AD_TYPE_INT_RANGE           0x12
336 #define BTM_BLE_AD_TYPE_SOL_SRV_UUID        0x14
337 #define BTM_BLE_AD_TYPE_128SOL_SRV_UUID     0x15
338 #define BTM_BLE_AD_TYPE_SERVICE_DATA        0x16
339 #define BTM_BLE_AD_TYPE_PUBLIC_TARGET       0x17
340 #define BTM_BLE_AD_TYPE_RANDOM_TARGET       0x18
341 #define BTM_BLE_AD_TYPE_APPEARANCE          0x19
342 #define BTM_BLE_AD_TYPE_ADV_INT             0x1a
343 #define BTM_BLE_AD_TYPE_LE_DEV_ADDR         0x1b
344 #define BTM_BLE_AD_TYPE_LE_ROLE             0x1c
345 #define BTM_BLE_AD_TYPE_SPAIR_C256          0x1d
346 #define BTM_BLE_AD_TYPE_SPAIR_R256          0x1e
347 #define BTM_BLE_AD_TYPE_32SOL_SRV_UUID      0x1f
348 #define BTM_BLE_AD_TYPE_32SERVICE_DATA      0x20
349 #define BTM_BLE_AD_TYPE_128SERVICE_DATA     0x21
350 #define BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM   0x22
351 #define BTM_BLE_AD_TYPE_LE_SECURE_RANDOM    0x23
352 #define BTM_BLE_AD_TYPE_URI                 0x24
353 #define BTM_BLE_AD_TYPE_INDOOR_POSITION     0x25
354 #define BTM_BLE_AD_TYPE_TRANS_DISC_DATA     0x26
355 #define BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE  0x27
356 #define BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE     0x28
357 
358 #define BTM_BLE_AD_TYPE_MANU            HCI_EIR_MANUFACTURER_SPECIFIC_TYPE      /* 0xff */
359 typedef UINT8   tBTM_BLE_AD_TYPE;
360 
361 #define BTM_BLE_LONG_ADV_MAX_LEN  249
362 
363 /*  Security settings used with L2CAP LE COC */
364 #define BTM_SEC_LE_LINK_ENCRYPTED           0x01
365 #define BTM_SEC_LE_LINK_PAIRED_WITHOUT_MITM 0x02
366 #define BTM_SEC_LE_LINK_PAIRED_WITH_MITM    0x04
367 
368 /*  Min/max Preferred  number of payload octets that the local Controller
369     should include in a single Link Layer Data Channel PDU. */
370 #define BTM_BLE_DATA_SIZE_MAX     0x00fb
371 #define BTM_BLE_DATA_SIZE_MIN     0x001b
372 
373 /*  Preferred maximum number of microseconds that the local Controller
374     should use to transmit a single Link Layer Data Channel PDU. */
375 #define BTM_BLE_DATA_TX_TIME_MIN     0x0148
376 #if (BLE_50_FEATURE_SUPPORT == TRUE)
377 #define BTM_BLE_DATA_TX_TIME_MAX     0x04290 // define by spec v5.0
378 #else
379 #define BTM_BLE_DATA_TX_TIME_MAX     0x0848
380 #endif
381 
382 /* adv tx power level */
383 #define BTM_BLE_ADV_TX_POWER_MIN        0           /* minimum tx power */
384 #define BTM_BLE_ADV_TX_POWER_MAX        7           /* maximum tx power */
385 typedef UINT8 tBTM_BLE_ADV_TX_POWER;
386 
387 /* adv tx power in dBm */
388 typedef struct {
389     UINT8 adv_inst_max;         /* max adv instance supported in controller */
390     UINT8 rpa_offloading;
391     UINT16 tot_scan_results_strg;
392     UINT8 max_irk_list_sz;
393     UINT8 filter_support;
394     UINT8 max_filter;
395     UINT8 energy_support;
396     BOOLEAN values_read;
397     UINT16 version_supported;
398     UINT16 total_trackable_advertisers;
399     UINT8 extended_scan_support;
400     UINT8 debug_logging_supported;
401 } tBTM_BLE_VSC_CB;
402 
403 /* slave preferred connection interval range */
404 typedef struct {
405     UINT16  low;
406     UINT16  hi;
407 
408 } tBTM_BLE_INT_RANGE;
409 
410 /* Service tag supported in the device */
411 typedef struct {
412     UINT8       num_service;
413     BOOLEAN     list_cmpl;
414     UINT16      *p_uuid;
415 } tBTM_BLE_SERVICE;
416 
417 /* 32 bits Service supported in the device */
418 typedef struct {
419     UINT8       num_service;
420     BOOLEAN     list_cmpl;
421     UINT32      *p_uuid;
422 } tBTM_BLE_32SERVICE;
423 
424 /* 128 bits Service supported in the device */
425 typedef struct {
426     BOOLEAN     list_cmpl;
427     UINT8       uuid128[MAX_UUID_SIZE];
428 } tBTM_BLE_128SERVICE;
429 
430 typedef struct {
431     UINT8       len;
432     UINT8      *p_val;
433 } tBTM_BLE_MANU;
434 
435 
436 typedef struct {
437     tBT_UUID    service_uuid;
438     UINT8       len;
439     UINT8      *p_val;
440 } tBTM_BLE_SERVICE_DATA;
441 
442 typedef struct {
443     UINT8       adv_type;
444     UINT8       len;
445     UINT8       *p_val;     /* number of len byte */
446 } tBTM_BLE_PROP_ELEM;
447 
448 typedef struct {
449     UINT8                   num_elem;
450     tBTM_BLE_PROP_ELEM      *p_elem;
451 } tBTM_BLE_PROPRIETARY;
452 
453 typedef struct {
454     tBTM_BLE_INT_RANGE      int_range;      /* slave prefered conn interval range */
455     tBTM_BLE_MANU           *p_manu;           /* manufacturer data */
456     tBTM_BLE_SERVICE        *p_services;       /* services */
457     tBTM_BLE_128SERVICE     *p_services_128b;  /* 128 bits service */
458     tBTM_BLE_32SERVICE      *p_service_32b;     /* 32 bits Service UUID */
459     tBTM_BLE_SERVICE        *p_sol_services;    /* 16 bits services Solicitation UUIDs */
460     tBTM_BLE_32SERVICE      *p_sol_service_32b;    /* List of 32 bit Service Solicitation UUIDs */
461     tBTM_BLE_128SERVICE     *p_sol_service_128b;    /* List of 128 bit Service Solicitation UUIDs */
462     tBTM_BLE_PROPRIETARY    *p_proprietary;
463     tBTM_BLE_SERVICE_DATA   *p_service_data;    /* service data */
464     UINT16                  appearance;
465     UINT8                   flag;
466     UINT8                   tx_power;
467 } tBTM_BLE_ADV_DATA;
468 
469 #ifndef BTM_BLE_MULTI_ADV_MAX
470 #define BTM_BLE_MULTI_ADV_MAX   16 /* controller returned adv_inst_max should be less
471                                       than this number */
472 #endif
473 
474 #define BTM_BLE_MULTI_ADV_INVALID   0
475 
476 #define BTM_BLE_MULTI_ADV_ENB_EVT           1
477 #define BTM_BLE_MULTI_ADV_DISABLE_EVT       2
478 #define BTM_BLE_MULTI_ADV_PARAM_EVT         3
479 #define BTM_BLE_MULTI_ADV_DATA_EVT          4
480 typedef UINT8 tBTM_BLE_MULTI_ADV_EVT;
481 
482 #define BTM_BLE_MULTI_ADV_DEFAULT_STD 0
483 
484 typedef struct {
485     UINT16          adv_int_min;
486     UINT16          adv_int_max;
487     UINT8           adv_type;
488     tBTM_BLE_ADV_CHNL_MAP channel_map;
489     tBTM_BLE_AFP    adv_filter_policy;
490     tBTM_BLE_ADV_TX_POWER tx_power;
491 } tBTM_BLE_ADV_PARAMS;
492 
493 typedef struct {
494     UINT8   *p_sub_code; /* dynamic array to store sub code */
495     UINT8   *p_inst_id;  /* dynamic array to store instance id */
496     UINT8   pending_idx;
497     UINT8   next_idx;
498 } tBTM_BLE_MULTI_ADV_OPQ;
499 
500 typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, UINT8 inst_id,
501                                         void *p_ref, tBTM_STATUS status);
502 
503 typedef struct {
504     UINT8                       inst_id;
505     BOOLEAN                     in_use;
506     UINT8                       adv_evt;
507     BD_ADDR                     rpa;
508     TIMER_LIST_ENT              raddr_timer_ent;
509     tBTM_BLE_MULTI_ADV_CBACK    *p_cback;
510     void                        *p_ref;
511     UINT8                       index;
512 } tBTM_BLE_MULTI_ADV_INST;
513 
514 typedef struct {
515     UINT8 inst_index_queue[BTM_BLE_MULTI_ADV_MAX];
516     int front;
517     int rear;
518 } tBTM_BLE_MULTI_ADV_INST_IDX_Q;
519 
520 typedef struct {
521     tBTM_BLE_MULTI_ADV_INST *p_adv_inst; /* dynamic array to store adv instance */
522     tBTM_BLE_MULTI_ADV_OPQ  op_q;
523 } tBTM_BLE_MULTI_ADV_CB;
524 
525 typedef UINT8 tGATT_IF;
526 
527 typedef void (tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value);
528 typedef void (tBTM_BLE_SCAN_REP_CBACK)(tBTM_BLE_REF_VALUE ref_value, UINT8 report_format,
529                                        UINT8 num_records, UINT16 total_len,
530                                        UINT8 *p_rep_data, UINT8 status);
531 typedef void (tBTM_BLE_SCAN_SETUP_CBACK)(UINT8 evt, tBTM_BLE_REF_VALUE ref_value, UINT8 status);
532 
533 #ifndef BTM_BLE_BATCH_SCAN_MAX
534 #define BTM_BLE_BATCH_SCAN_MAX   5
535 #endif
536 
537 #ifndef BTM_BLE_BATCH_REP_MAIN_Q_SIZE
538 #define BTM_BLE_BATCH_REP_MAIN_Q_SIZE  2
539 #endif
540 
541 typedef enum {
542     BTM_BLE_SCAN_INVALID_STATE = 0,
543     BTM_BLE_SCAN_ENABLE_CALLED = 1,
544     BTM_BLE_SCAN_ENABLED_STATE = 2,
545     BTM_BLE_SCAN_DISABLE_CALLED = 3,
546     BTM_BLE_SCAN_DISABLED_STATE = 4
547 } tBTM_BLE_BATCH_SCAN_STATE;
548 
549 enum {
550     BTM_BLE_DISCARD_OLD_ITEMS,
551     BTM_BLE_DISCARD_LOWER_RSSI_ITEMS
552 };
553 typedef UINT8 tBTM_BLE_DISCARD_RULE;
554 
555 typedef struct {
556     UINT8   sub_code[BTM_BLE_BATCH_SCAN_MAX];
557     tBTM_BLE_BATCH_SCAN_STATE cur_state[BTM_BLE_BATCH_SCAN_MAX];
558     tBTM_BLE_REF_VALUE        ref_value[BTM_BLE_BATCH_SCAN_MAX];
559     UINT8   pending_idx;
560     UINT8   next_idx;
561 } tBTM_BLE_BATCH_SCAN_OPQ;
562 
563 typedef struct {
564     UINT8   rep_mode[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
565     tBTM_BLE_REF_VALUE  ref_value[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
566     UINT8   num_records[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
567     UINT16  data_len[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
568     UINT8   *p_data[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
569     UINT8   pending_idx;
570     UINT8   next_idx;
571 } tBTM_BLE_BATCH_SCAN_REP_Q;
572 
573 typedef struct {
574     tBTM_BLE_BATCH_SCAN_STATE      cur_state;
575     tBTM_BLE_BATCH_SCAN_MODE scan_mode;
576     UINT32                  scan_interval;
577     UINT32                  scan_window;
578     tBLE_ADDR_TYPE          addr_type;
579     tBTM_BLE_DISCARD_RULE   discard_rule;
580     tBTM_BLE_BATCH_SCAN_OPQ  op_q;
581     tBTM_BLE_BATCH_SCAN_REP_Q main_rep_q;
582     tBTM_BLE_SCAN_SETUP_CBACK     *p_setup_cback;
583     tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback;
584     tBTM_BLE_SCAN_REP_CBACK       *p_scan_rep_cback;
585     tBTM_BLE_REF_VALUE             ref_value;
586 } tBTM_BLE_BATCH_SCAN_CB;
587 
588 /// Ble scan duplicate type
589 enum {
590     BTM_BLE_SCAN_DUPLICATE_DISABLE           = 0x0,  /*!< the Link Layer should generate advertising reports to the host for each packet received */
591     BTM_BLE_SCAN_DUPLICATE_ENABLE            = 0x1,  /*!< the Link Layer should filter out duplicate advertising reports to the Host */
592     BTM_BLE_SCAN_DUPLICATE_MAX               = 0x2,  /*!< 0x02 – 0xFF, Reserved for future use */
593 };
594 /* filter selection bit index  */
595 #define BTM_BLE_PF_ADDR_FILTER          0
596 #define BTM_BLE_PF_SRVC_DATA            1
597 #define BTM_BLE_PF_SRVC_UUID            2
598 #define BTM_BLE_PF_SRVC_SOL_UUID        3
599 #define BTM_BLE_PF_LOCAL_NAME           4
600 #define BTM_BLE_PF_MANU_DATA            5
601 #define BTM_BLE_PF_SRVC_DATA_PATTERN    6
602 #define BTM_BLE_PF_TYPE_ALL             7  /* when passed in payload filter type all, only clear action is applicable */
603 #define BTM_BLE_PF_TYPE_MAX             8
604 
605 /* max number of filter spot for different filter type */
606 #ifndef BTM_BLE_MAX_UUID_FILTER
607 #define BTM_BLE_MAX_UUID_FILTER     8
608 #endif
609 #ifndef BTM_BLE_MAX_ADDR_FILTER
610 #define BTM_BLE_MAX_ADDR_FILTER     8
611 #endif
612 #ifndef BTM_BLE_PF_STR_COND_MAX
613 #define BTM_BLE_PF_STR_COND_MAX     4   /* apply to manu data , or local name */
614 #endif
615 #ifndef BTM_BLE_PF_STR_LEN_MAX
616 #define BTM_BLE_PF_STR_LEN_MAX      29  /* match for first 29 bytes */
617 #endif
618 
619 typedef UINT8   tBTM_BLE_PF_COND_TYPE;
620 
621 #define BTM_BLE_PF_LOGIC_OR              0
622 #define BTM_BLE_PF_LOGIC_AND             1
623 typedef UINT8 tBTM_BLE_PF_LOGIC_TYPE;
624 
625 #define BTM_BLE_PF_ENABLE       1
626 #define BTM_BLE_PF_CONFIG       2
627 typedef UINT8 tBTM_BLE_PF_ACTION;
628 
629 typedef UINT8 tBTM_BLE_PF_FILT_INDEX;
630 
631 typedef UINT8 tBTM_BLE_PF_AVBL_SPACE;
632 
633 #define BTM_BLE_PF_BRDCAST_ADDR_FILT  1
634 #define BTM_BLE_PF_SERV_DATA_CHG_FILT 2
635 #define BTM_BLE_PF_SERV_UUID          4
636 #define BTM_BLE_PF_SERV_SOLC_UUID     8
637 #define BTM_BLE_PF_LOC_NAME_CHECK    16
638 #define BTM_BLE_PF_MANUF_NAME_CHECK  32
639 #define BTM_BLE_PF_SERV_DATA_CHECK   64
640 typedef UINT16 tBTM_BLE_PF_FEAT_SEL;
641 
642 #define BTM_BLE_PF_LIST_LOGIC_OR   1
643 #define BTM_BLE_PF_LIST_LOGIC_AND  2
644 typedef UINT16 tBTM_BLE_PF_LIST_LOGIC_TYPE;
645 
646 #define BTM_BLE_PF_FILT_LOGIC_OR   0
647 #define BTM_BLE_PF_FILT_LOGIC_AND  1
648 typedef UINT16 tBTM_BLE_PF_FILT_LOGIC_TYPE;
649 
650 typedef UINT8  tBTM_BLE_PF_RSSI_THRESHOLD;
651 typedef UINT8  tBTM_BLE_PF_DELIVERY_MODE;
652 typedef UINT16 tBTM_BLE_PF_TIMEOUT;
653 typedef UINT8  tBTM_BLE_PF_TIMEOUT_CNT;
654 typedef UINT16 tBTM_BLE_PF_ADV_TRACK_ENTRIES;
655 
656 typedef struct {
657     tBTM_BLE_PF_FEAT_SEL feat_seln;
658     tBTM_BLE_PF_LIST_LOGIC_TYPE logic_type;
659     tBTM_BLE_PF_FILT_LOGIC_TYPE filt_logic_type;
660     tBTM_BLE_PF_RSSI_THRESHOLD  rssi_high_thres;
661     tBTM_BLE_PF_RSSI_THRESHOLD  rssi_low_thres;
662     tBTM_BLE_PF_DELIVERY_MODE dely_mode;
663     tBTM_BLE_PF_TIMEOUT found_timeout;
664     tBTM_BLE_PF_TIMEOUT lost_timeout;
665     tBTM_BLE_PF_TIMEOUT_CNT found_timeout_cnt;
666     tBTM_BLE_PF_ADV_TRACK_ENTRIES num_of_tracking_entries;
667 } tBTM_BLE_PF_FILT_PARAMS;
668 
669 enum {
670     BTM_BLE_SCAN_COND_ADD,
671     BTM_BLE_SCAN_COND_DELETE,
672     BTM_BLE_SCAN_COND_CLEAR = 2
673 };
674 typedef UINT8 tBTM_BLE_SCAN_COND_OP;
675 
676 enum {
677     BTM_BLE_FILT_ENABLE_DISABLE = 1,
678     BTM_BLE_FILT_CFG            = 2,
679     BTM_BLE_FILT_ADV_PARAM      = 3
680 };
681 
682 typedef UINT8 tBTM_BLE_FILT_CB_EVT;
683 
684 /* BLE adv payload filtering config complete callback */
685 typedef void (tBTM_BLE_PF_CFG_CBACK)(tBTM_BLE_PF_ACTION action, tBTM_BLE_SCAN_COND_OP cfg_op,
686                                      tBTM_BLE_PF_AVBL_SPACE avbl_space, tBTM_STATUS status,
687                                      tBTM_BLE_REF_VALUE ref_value);
688 
689 typedef void (tBTM_BLE_PF_CMPL_CBACK) (tBTM_BLE_PF_CFG_CBACK);
690 
691 /* BLE adv payload filtering status setup complete callback */
692 typedef void (tBTM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTM_STATUS status,
693         tBTM_BLE_REF_VALUE ref_value);
694 
695 /* BLE adv payload filtering param setup complete callback */
696 typedef void (tBTM_BLE_PF_PARAM_CBACK) (tBTM_BLE_PF_ACTION action_type,
697                                         tBTM_BLE_PF_AVBL_SPACE avbl_space,
698                                         tBTM_BLE_REF_VALUE ref_value, tBTM_STATUS status);
699 #if (BLE_50_FEATURE_SUPPORT == TRUE)
700 #define MAX_BLE_ADV_INSTANCE 10
701 typedef struct {
702     UINT8                       inst_id;
703     BOOLEAN                     configured;
704     BOOLEAN                     legacy_pdu;
705 
706 
707     BOOLEAN                     directed;
708     BOOLEAN                     scannable;
709     BOOLEAN                     connetable;
710 } tBTM_BLE_EXTENDED_INST;
711 
712 typedef struct {
713     tBTM_BLE_EXTENDED_INST inst[MAX_BLE_ADV_INSTANCE]; /* dynamic array to store adv instance */
714     UINT8  scan_duplicate;
715 } tBTM_BLE_EXTENDED_CB;
716 
717 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE       (1 << 0)
718 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE         (1 << 1)
719 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED          (1 << 2)
720 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED       (1 << 3)
721 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY            (1 << 4)
722 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_ANON_ADV          (1 << 5)
723 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_INCLUDE_TX_PWR    (1 << 6)
724 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_MASK              (0x7F)
725 
726 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND        (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
727                                                      ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
728                                                      ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
729 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_LD_DIR     (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
730                                                      ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
731                                                      ESP_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED)
732 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_HD_DIR     (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
733                                                      ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
734                                                      ESP_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED)
735 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_SCAN       (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
736                                                      ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
737 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_NONCONN    (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY)
738 typedef UINT16 tBTM_BLE_EXT_ADV_TYPE_MASK;
739 
740 #define BTM_BLE_GAP_PHY_1M                             1
741 #define BTM_BLE_GAP_PHY_2M                             2
742 #define BTM_BLE_GAP_PHY_CODED                          3
743 typedef UINT8 tBTM_BLE_GAP_PHY;
744 
745 #define BTM_BLE_GAP_PHY_NO_TX_PREF_MASK                (0x01)
746 #define BTM_BLE_GAP_PHY_NO_RX_PREF_MASK                (0x02)
747 #define BTM_BLE_GAP_PHY_1M_PREF_MASK                   (0x03)
748 #define BTM_BLE_GAP_PHY_2M_PREF_MASK                   (0x04)
749 #define BTM_BLE_GAP_PHY_CODED_PREF_MASK                (0x05)
750 typedef UINT8 tBTM_BLE_GAP_PHY_MASK;
751 
752 #define BTM_BLE_GAP_EXT_SCAN_UNCODE_MASK               0x01
753 #define BTM_BLE_GAP_EXT_SCAN_CODE_MASK                 0x02
754 typedef UINT8 tBTM_BLE_EXT_SCAN_CFG_MASK;
755 
756 typedef struct {
757     tBTM_BLE_EXT_ADV_TYPE_MASK type;
758     UINT32 interval_min;
759     UINT32 interval_max;
760     tBTM_BLE_ADV_CHNL_MAP channel_map;
761     tBLE_ADDR_TYPE own_addr_type;
762     tBLE_ADDR_TYPE peer_addr_type;
763     BD_ADDR peer_addr;
764     tBTM_BLE_AFP filter_policy;
765     UINT8 tx_power;
766     tBTM_BLE_GAP_PHY primary_phy;
767     UINT8 max_skip;
768     tBTM_BLE_GAP_PHY secondary_phy;
769     UINT8 sid;
770     BOOLEAN scan_req_notif;
771 } tBTM_BLE_GAP_EXT_ADV_PARAMS;
772 
773 typedef struct {
774     UINT8 instance;
775     int duration;
776     int max_events;
777 } tBTM_BLE_EXT_ADV;
778 
779 
780 typedef struct {
781     tBLE_SCAN_MODE scan_type;
782     UINT16 scan_interval;
783     UINT16 scan_window;
784 } tBTM_BLE_EXT_SCAN_CFG;
785 
786 typedef struct {
787     tBLE_ADDR_TYPE own_addr_type;
788     UINT8 filter_policy;
789     UINT8  scan_duplicate;
790     tBTM_BLE_EXT_SCAN_CFG_MASK cfg_mask;
791     tBTM_BLE_EXT_SCAN_CFG uncoded_cfg;
792     tBTM_BLE_EXT_SCAN_CFG coded_cfg;
793 } tBTM_BLE_EXT_SCAN_PARAMS;
794 
795 typedef struct {
796     UINT16 interval_min;
797     UINT16 interval_max;
798     UINT8  properties;
799 } tBTM_BLE_Periodic_Adv_Params;
800 
801 typedef struct {
802     UINT8 filter_policy;
803     UINT8 sid;
804     tBLE_ADDR_TYPE addr_type;
805     BD_ADDR addr;
806     UINT16 skip;
807     UINT16 sync_timeout;
808 } tBTM_BLE_Periodic_Sync_Params;
809 
810 typedef struct {
811     uint8_t status;
812     uint16_t conn_idx;
813     uint8_t tx_phy;
814     uint8_t rx_phy;
815 } tBTM_BLE_UPDATE_PHY;
816 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
817 typedef union {
818     UINT16              uuid16_mask;
819     UINT32              uuid32_mask;
820     UINT8               uuid128_mask[LEN_UUID_128];
821 } tBTM_BLE_PF_COND_MASK;
822 
823 typedef struct {
824     tBLE_BD_ADDR            *p_target_addr;     /* target address, if NULL, generic UUID filter */
825     tBT_UUID                uuid;           /* UUID condition */
826     tBTM_BLE_PF_LOGIC_TYPE  cond_logic;    /* AND/OR */
827     tBTM_BLE_PF_COND_MASK   *p_uuid_mask;           /* UUID mask */
828 } tBTM_BLE_PF_UUID_COND;
829 
830 typedef struct {
831     UINT8                   data_len;       /* <= 20 bytes */
832     UINT8                   *p_data;
833 } tBTM_BLE_PF_LOCAL_NAME_COND;
834 
835 typedef struct {
836     UINT16                  company_id;     /* company ID */
837     UINT8                   data_len;       /* <= 20 bytes */
838     UINT8                   *p_pattern;
839     UINT16                  company_id_mask; /* UUID value mask */
840     UINT8                   *p_pattern_mask; /* Manufacturer data matching mask,
841                                                 same length as data pattern,
842                                                 set to all 0xff, match exact data */
843 } tBTM_BLE_PF_MANU_COND;
844 
845 typedef struct {
846     UINT16                  uuid;     /* service ID */
847     UINT8                   data_len;       /* <= 20 bytes */
848     UINT8                   *p_pattern;
849     UINT8                   *p_pattern_mask; /* Service data matching mask, same length as data pattern,
850                                                 set to all 0xff, match exact data */
851 } tBTM_BLE_PF_SRVC_PATTERN_COND;
852 
853 
854 typedef union {
855     tBLE_BD_ADDR                            target_addr;
856     tBTM_BLE_PF_LOCAL_NAME_COND             local_name; /* local name filtering */
857     tBTM_BLE_PF_MANU_COND                   manu_data;  /* manufacturer data filtering */
858     tBTM_BLE_PF_UUID_COND                   srvc_uuid;  /* service UUID filtering */
859     tBTM_BLE_PF_UUID_COND                   solicitate_uuid;   /* solicited service UUID filtering */
860     tBTM_BLE_PF_SRVC_PATTERN_COND           srvc_data;      /* service data pattern */
861 } tBTM_BLE_PF_COND_PARAM;
862 
863 typedef struct {
864     UINT8   action_ocf[BTM_BLE_PF_TYPE_MAX];
865     tBTM_BLE_REF_VALUE  ref_value[BTM_BLE_PF_TYPE_MAX];
866     tBTM_BLE_PF_PARAM_CBACK  *p_filt_param_cback[BTM_BLE_PF_TYPE_MAX];
867     tBTM_BLE_PF_CFG_CBACK *p_scan_cfg_cback[BTM_BLE_PF_TYPE_MAX];
868     UINT8   cb_evt[BTM_BLE_PF_TYPE_MAX];
869     UINT8   pending_idx;
870     UINT8   next_idx;
871 } tBTM_BLE_ADV_FILTER_ADV_OPQ;
872 
873 #define BTM_BLE_MAX_FILTER_COUNTER  (BTM_BLE_MAX_ADDR_FILTER + 1) /* per device filter + one generic filter indexed by 0 */
874 
875 #ifndef BTM_CS_IRK_LIST_MAX
876 #define BTM_CS_IRK_LIST_MAX 0x20
877 #endif
878 
879 typedef struct {
880     BOOLEAN    in_use;
881     BD_ADDR    bd_addr;
882     UINT8      pf_counter[BTM_BLE_PF_TYPE_MAX]; /* number of filter indexed by tBTM_BLE_PF_COND_TYPE */
883 } tBTM_BLE_PF_COUNT;
884 
885 typedef struct {
886     BOOLEAN             enable;
887     UINT8               op_type;
888     tBTM_BLE_PF_COUNT   *p_addr_filter_count; /* per BDA filter array */
889     tBLE_BD_ADDR        cur_filter_target;
890     tBTM_BLE_PF_STATUS_CBACK *p_filt_stat_cback;
891     tBTM_BLE_ADV_FILTER_ADV_OPQ  op_q;
892 } tBTM_BLE_ADV_FILTER_CB;
893 
894 /* Sub codes */
895 #define BTM_BLE_META_PF_ENABLE          0x00
896 #define BTM_BLE_META_PF_FEAT_SEL        0x01
897 #define BTM_BLE_META_PF_ADDR            0x02
898 #define BTM_BLE_META_PF_UUID            0x03
899 #define BTM_BLE_META_PF_SOL_UUID        0x04
900 #define BTM_BLE_META_PF_LOCAL_NAME      0x05
901 #define BTM_BLE_META_PF_MANU_DATA       0x06
902 #define BTM_BLE_META_PF_SRVC_DATA       0x07
903 #define BTM_BLE_META_PF_ALL             0x08
904 
905 typedef UINT8 BTM_BLE_ADV_STATE;
906 typedef UINT8 BTM_BLE_ADV_INFO_PRESENT;
907 typedef UINT8 BTM_BLE_RSSI_VALUE;
908 typedef UINT16 BTM_BLE_ADV_INFO_TIMESTAMP;
909 
910 /* These are the fields returned in each device adv packet.  It
911 ** is returned in the results callback if registered.
912 */
913 typedef struct {
914     UINT8               conn_mode;
915     tBTM_BLE_AD_MASK    ad_mask;        /* mask of the valid adv data field */
916     UINT8               flag;
917     UINT8               tx_power_level;
918     UINT8               remote_name_len;
919     UINT8               *p_remote_name;
920     tBTM_BLE_SERVICE    service;
921 } tBTM_BLE_INQ_DATA;
922 
923 enum {
924     BTM_BLE_CONN_NONE,
925     BTM_BLE_CONN_AUTO,
926     BTM_BLE_CONN_SELECTIVE
927 };
928 typedef UINT8   tBTM_BLE_CONN_TYPE;
929 
930 #define ADV_INFO_PRESENT        0x00
931 #define NO_ADV_INFO_PRESENT     0x01
932 
933 typedef btgatt_track_adv_info_t tBTM_BLE_TRACK_ADV_DATA;
934 
935 typedef void (tBTM_BLE_TRACK_ADV_CBACK)(tBTM_BLE_TRACK_ADV_DATA *p_track_adv_data);
936 
937 typedef UINT8 tBTM_BLE_TRACK_ADV_EVT;
938 
939 typedef struct {
940     tBTM_BLE_REF_VALUE             ref_value;
941     tBTM_BLE_TRACK_ADV_CBACK *p_track_cback;
942 } tBTM_BLE_ADV_TRACK_CB;
943 
944 enum {
945     BTM_BLE_TRACK_ADV_ADD,
946     BTM_BLE_TRACK_ADV_REMOVE
947 };
948 
949 typedef UINT8 tBTM_BLE_TRACK_ADV_ACTION;
950 
951 #define BTM_BLE_MULTI_ADV_INVALID   0
952 
953 #define BTM_BLE_BATCH_SCAN_ENABLE_EVT     1
954 #define BTM_BLE_BATCH_SCAN_CFG_STRG_EVT   2
955 #define BTM_BLE_BATCH_SCAN_READ_REPTS_EVT 3
956 #define BTM_BLE_BATCH_SCAN_THR_EVT        4
957 #define BTM_BLE_BATCH_SCAN_PARAM_EVT      5
958 #define BTM_BLE_BATCH_SCAN_DISABLE_EVT    6
959 
960 typedef UINT8 tBTM_BLE_BATCH_SCAN_EVT;
961 
962 typedef UINT32 tBTM_BLE_TX_TIME_MS;
963 typedef UINT32 tBTM_BLE_RX_TIME_MS;
964 typedef UINT32 tBTM_BLE_IDLE_TIME_MS;
965 typedef UINT32 tBTM_BLE_ENERGY_USED;
966 
967 typedef void (tBTM_BLE_ENERGY_INFO_CBACK)(tBTM_BLE_TX_TIME_MS tx_time, tBTM_BLE_RX_TIME_MS rx_time,
968         tBTM_BLE_IDLE_TIME_MS idle_time,
969         tBTM_BLE_ENERGY_USED  energy_used,
970         tBTM_STATUS status);
971 
972 typedef struct {
973     tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback;
974 } tBTM_BLE_ENERGY_INFO_CB;
975 
976 typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda,     UINT8 *p_remote_name);
977 typedef void (tBTM_BLE_CTRL_FEATURES_CBACK)(tBTM_STATUS status);
978 
979 /* callback function for SMP signing algorithm, signed data in little endian order with tlen bits long */
980 typedef void (tBTM_BLE_SIGN_CBACK)(void *p_ref_data, UINT8 *p_signing_data);
981 typedef void (tBTM_BLE_VERIFY_CBACK)(void *p_ref_data, BOOLEAN match);
982 /* random address set complete callback */
983 typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda);
984 
985 typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt);
986 typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS status);
987 
988 tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb;
989 
990 typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status);
991 typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status);
992 
993 typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info);
994 #if (BLE_50_FEATURE_SUPPORT == TRUE)
995 #define    BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT                     1
996 #define    BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT     2
997 #define    BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT             3
998 #define    BTM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT        4
999 #define    BTM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT           5
1000 #define    BTM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT             6
1001 #define    BTM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT        7
1002 #define    BTM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT                8
1003 #define    BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT                 9
1004 #define    BTM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT           10
1005 #define    BTM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT            11
1006 #define    BTM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT      12
1007 #define    BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT        13
1008 #define    BTM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT           14
1009 #define    BTM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT            15
1010 #define    BTM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT     16
1011 #define    BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT     17
1012 #define    BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT  18
1013 #define    BTM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT         19
1014 #define    BTM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT      20
1015 #define    BTM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT       21
1016 #define    BTM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT          22
1017 #define    BTM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT               23
1018 #define    BTM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT                24
1019 #define    BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT   25
1020 #define    BTM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT                   26
1021 #define    BTM_BLE_5_GAP_EXT_ADV_REPORT_EVT                        27
1022 #define    BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT                          28
1023 #define    BTM_BLE_5_GAP_ADV_TERMINATED_EVT                        29
1024 #define    BTM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT                     30
1025 #define    BTM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT              31
1026 #define    BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT                   32
1027 #define    BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT                33
1028 #define    BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT               34
1029 #define    BTM_BLE_5_GAP_UNKNOWN_EVT                               35
1030 typedef UINT8 tBTM_BLE_5_GAP_EVENT;
1031 
1032 #define BTM_BLE_EXT_ADV_DATA_COMPLETE          0x00
1033 #define BTM_BLE_EXT_ADV_DATA_INCOMPLETE        0x01
1034 #define BTM_BLE_EXT_ADV_DATA_TRUNCATED         0x02
1035 typedef UINT8 tBTM_BLE_EXT_ADV_DATA_STATUS;
1036 
1037 #define BTM_BLE_ADV_DATA_COMPLETE_MASK         (0x0000)
1038 #define BTM_BLE_ADV_DATA_INCOMPLETE_MASK       (0x0020)
1039 #define BTM_BLE_ADV_DATA_TRUNCATED_MASK        (0x0040)
1040 #define BTM_BLE_ADV_DATA_STATUS_MASK           (0x0060)
1041 
1042 
1043 //#define BTM_BLE_ADV_CONN_MASK                  (0x0001)
1044 //#define BTM_BLE_ADV_SCAN_MASK                  (0x0002)
1045 //#define BTM_BLE_ADV_DIRECT_MASK                (0x0004)
1046 //#define BTM_BLE_SCAN_RSP_MASK                  (0x0008)
1047 #define BTM_BLE_ADV_LEGACY_MASK                (0x0010)
1048 typedef UINT8 tBTM_BLE_ADV_MASK;
1049 
1050 // /* Advertising report */
1051 // #define BTM_BLE_ADV_REPORT_ADV_IND                (0)
1052 // #define BTM_BLE_ADV_REPORT_DIR_IND                (1)
1053 // #define BTM_BLE_ADV_REPORT_SCAN_IND               (2)
1054 // #define BTM_BLE_ADV_REPORT_NONCONN_IND            (3)
1055 // #define BTM_BLE_ADV_REPORT_SCAN_RSP               (4)
1056 
1057 // /* Bluetooth 5.0, Vol 2, Part E, 7.7.65.13 */
1058 // #define BTM_BLE_LEGACY_ADV_TYPE_IND                   (0x13)
1059 // #define BTM_BLE_LEGACY_ADV_TYPE_DIRECT_IND            (0x15)
1060 // #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_IND              (0x12)
1061 // #define BTM_BLE_LEGACY_ADV_TYPE_NONCON_IND            (0x10)
1062 // #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_IND      (0x1b)
1063 // #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_SCAN_IND (0x1a)
1064 
1065 typedef struct {
1066     UINT8 status;
1067     BD_ADDR addr;
1068     UINT8 tx_phy;
1069     UINT8 rx_phy;
1070 } tBTM_BLE_READ_PHY_CMPL;
1071 
1072 typedef struct {
1073     UINT8 status;
1074 } tBTM_BLE_SET_PREF_DEF_PHY_CMPL;
1075 
1076 typedef struct {
1077     UINT8 status;
1078 } tBTM_BLE_SET_PERF_PHY_CMPL;
1079 
1080 typedef struct {
1081     UINT8 status;
1082 } tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL;
1083 
1084 typedef struct {
1085     UINT8 status;
1086 } tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL;
1087 
1088 typedef struct {
1089     UINT8 status;
1090 } tBTM_BLE_EXT_ADV_DATA_SET_CMPL;
1091 
1092 typedef struct {
1093     UINT8 status;
1094 } tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL;
1095 
1096 typedef struct {
1097     UINT8 status;
1098 } tBTM_BLE_EXT_ADV_START_CMPL;
1099 
1100 typedef struct {
1101     UINT8 status;
1102 } tBTM_BLE_EXT_ADV_STOP_CMPL;
1103 
1104 typedef struct {
1105     UINT8 status;
1106 } tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL;
1107 
1108 typedef struct {
1109     UINT8 status;
1110 } tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL;
1111 
1112 typedef struct {
1113     UINT8 status;
1114 } tBTM_BLE_PERIOD_ADV_START_CMPL;
1115 
1116 typedef struct {
1117     UINT8 status;
1118 } tBTM_BLE_PERIOD_ADV_STOP_CMPL;
1119 
1120 typedef struct {
1121     UINT8 status;
1122 } tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL;
1123 
1124 typedef struct {
1125     UINT8 status;
1126 } tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL;
1127 
1128 typedef struct {
1129     UINT8 status;
1130 } tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL;
1131 
1132 typedef struct {
1133     UINT8 status;
1134 } tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL;
1135 
1136 typedef struct {
1137     UINT8 status;
1138 } tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL;
1139 
1140 typedef struct {
1141     UINT8 status;
1142 } tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL;
1143 
1144 typedef struct {
1145     UINT8 status;
1146 } tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL;
1147 
1148 typedef struct {
1149     UINT8 status;
1150 } tBTM_BLE_EXT_SCAN_START_CMPL;
1151 
1152 typedef struct {
1153     UINT8 status;
1154 } tBTM_BLE_EXT_SCAN_STOP_CMPL;
1155 
1156 typedef struct {
1157     UINT8 status;
1158 } tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL;
1159 
1160 typedef struct {
1161     uint8_t status;
1162     BD_ADDR addr;
1163     uint8_t tx_phy;
1164     uint8_t rx_phy;
1165 } tBTM_BLE_PHY_UPDATE_CMPL;
1166 
1167 typedef struct {
1168     // UINT8 props;
1169     // UINT8 legacy_event_type;
1170     UINT8 event_type;
1171     tBLE_ADDR_TYPE addr_type;
1172     BD_ADDR addr;
1173     UINT8 primary_phy;
1174     UINT8 secondry_phy;
1175     UINT8 sid;
1176     UINT8 tx_power;
1177     UINT8 rssi;
1178     UINT16 per_adv_interval;
1179     tBLE_ADDR_TYPE dir_addr_type;
1180     BD_ADDR dir_addr;
1181     tBTM_BLE_EXT_ADV_DATA_STATUS data_status;
1182     UINT8 adv_data_len;
1183     UINT8 *adv_data;
1184 } tBTM_BLE_EXT_ADV_REPORT;
1185 
1186 typedef struct {
1187     UINT8 status;
1188     UINT8 adv_handle;
1189     UINT16 conn_handle;
1190     UINT8 completed_event;
1191 } tBTM_BLE_ADV_TERMINAT;
1192 
1193 typedef struct {
1194     UINT8 adv_handle;
1195     tBLE_ADDR_TYPE scan_addr_type;
1196     BD_ADDR scan_addr;
1197 } tBTM_BLE_SCAN_REQ_RECEIVED;
1198 
1199 typedef struct {
1200     UINT16 conn_handle;
1201     UINT8 channel_sel_alg;
1202 } tBTM_BLE_CHANNEL_SEL_ALG;
1203 
1204 typedef struct {
1205     UINT16 sync_handle;
1206     UINT8 tx_power;
1207     INT8 rssi;
1208     tBTM_BLE_EXT_ADV_DATA_STATUS data_status;
1209     UINT8 data_length;
1210     UINT8 *data;
1211 } tBTM_PERIOD_ADV_REPORT;
1212 
1213 typedef struct {
1214     UINT16 sync_handle;
1215 } tBTM_BLE_PERIOD_ADV_SYNC_LOST;
1216 
1217 typedef struct {
1218     UINT8 status;
1219     UINT16 sync_handle;
1220     UINT8 sid;
1221     tBLE_ADDR_TYPE adv_addr_type;
1222     BD_ADDR adv_addr;
1223     UINT8 adv_phy;
1224     UINT16 period_adv_interval;
1225     UINT8 adv_clk_accuracy;
1226 } tBTM_BLE_PERIOD_ADV_SYNC_ESTAB;
1227 
1228 typedef struct {
1229     UINT16 scan_interval;
1230     UINT16 scan_window;
1231     UINT16 interval_min;
1232     UINT16 interval_max;
1233     UINT16 latency;
1234     UINT16 supervision_timeout;
1235     UINT16 min_ce_len;
1236     UINT16 max_ce_len;
1237 } tBTM_BLE_CONN_PARAMS;
1238 
1239 
1240 typedef union {
1241     UINT8 status;
1242     tBTM_BLE_READ_PHY_CMPL read_phy;
1243     tBTM_BLE_SET_PREF_DEF_PHY_CMPL set_perf_def_phy;
1244     tBTM_BLE_SET_PERF_PHY_CMPL set_perf_phy;
1245     tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL set_ext_rand_addr;
1246     tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL set_params;
1247     tBTM_BLE_EXT_ADV_DATA_SET_CMPL adv_data_set;
1248     tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL scan_rsp_data_set;
1249     tBTM_BLE_EXT_ADV_START_CMPL adv_start;
1250     tBTM_BLE_EXT_ADV_STOP_CMPL adv_stop;
1251     tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL per_adv_set_params;
1252     tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL per_adv_data_set;
1253     tBTM_BLE_PERIOD_ADV_START_CMPL per_adv_start;
1254     tBTM_BLE_PERIOD_ADV_STOP_CMPL per_adv_stop;
1255     tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL per_adv_sync_create;
1256     tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL per_adv_sync_cancel;
1257     tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL per_adv_sync_term;
1258     tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL per_adv_add_dev;
1259     tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL per_adv_remove_dev;
1260     tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL per_adv_clear_dev;
1261     tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL ext_scan;
1262     tBTM_BLE_EXT_SCAN_START_CMPL scan_start;
1263     tBTM_BLE_EXT_SCAN_STOP_CMPL scan_stop;
1264     tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL ext_conn_set_params;
1265     tBTM_BLE_PHY_UPDATE_CMPL phy_update;
1266     tBTM_BLE_EXT_ADV_REPORT ext_adv_report;
1267     tBTM_BLE_ADV_TERMINAT adv_term;
1268     tBTM_BLE_SCAN_REQ_RECEIVED scan_req;
1269     tBTM_BLE_CHANNEL_SEL_ALG channel_sel;
1270     tBTM_PERIOD_ADV_REPORT period_adv_report;
1271     tBTM_BLE_PERIOD_ADV_SYNC_LOST sync_lost;
1272     tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab;
1273 } tBTM_BLE_5_GAP_CB_PARAMS;
1274 
1275 typedef struct {
1276     UINT8                           phy_mask;
1277     tBTM_BLE_CONN_PARAMS            phy_1m_conn_params;
1278     tBTM_BLE_CONN_PARAMS            phy_2m_conn_params;
1279     tBTM_BLE_CONN_PARAMS            phy_coded_conn_params;
1280 } tBTM_EXT_CONN_PARAMS;
1281 
1282 typedef void (*tBTM_BLE_5_HCI_CBACK)(tBTM_BLE_5_GAP_EVENT event, tBTM_BLE_5_GAP_CB_PARAMS *params);
1283 
1284 #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
1285 
1286 /*****************************************************************************
1287 **  EXTERNAL FUNCTION DECLARATIONS
1288 *****************************************************************************/
1289 /*
1290 #ifdef __cplusplus
1291 extern "C" {
1292 #endif
1293 */
1294 
1295 /*******************************************************************************
1296 **
1297 ** Function         BTM_BleRegiseterConnParamCallback
1298 **
1299 ** Description      register connection parameters update callback func
1300 **
1301 ** Parameters:      update_conn_param_cb
1302 **
1303 ** Returns          void
1304 **
1305 *******************************************************************************/
1306 void BTM_BleRegiseterConnParamCallback(tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb);
1307 
1308 /*******************************************************************************
1309 **
1310 ** Function         BTM_SecAddBleDevice
1311 **
1312 ** Description      Add/modify device.  This function will be normally called
1313 **                  during host startup to restore all required information
1314 **                  for a LE device stored in the NVRAM.
1315 **
1316 ** Parameters:      bd_addr          - BD address of the peer
1317 **                  bd_name          - Name of the peer device.  NULL if unknown.
1318 **                  dev_type         - Remote device's device type.
1319 **                  addr_type        - LE device address type.
1320 **                  auth_mode        - auth mode
1321 **
1322 ** Returns          TRUE if added OK, else FALSE
1323 **
1324 *******************************************************************************/
1325 //extern
1326 BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name,
1327                              tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type, UINT32 auth_mode);
1328 
1329 /*******************************************************************************
1330 **
1331 ** Function         BTM_SecAddBleKey
1332 **
1333 ** Description      Add/modify LE device information.  This function will be
1334 **                  normally called during host startup to restore all required
1335 **                  information stored in the NVRAM.
1336 **
1337 ** Parameters:      bd_addr          - BD address of the peer
1338 **                  p_le_key         - LE key values.
1339 **                  key_type         - LE SMP key type.
1340 *
1341 ** Returns          TRUE if added OK, else FALSE
1342 **
1343 *******************************************************************************/
1344 //extern
1345 BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key,
1346                           tBTM_LE_KEY_TYPE key_type);
1347 
1348 /*******************************************************************************
1349 **
1350 ** Function         BTM_BleSetAdvParams
1351 **
1352 ** Description      This function is called to set advertising parameters.
1353 **
1354 ** Parameters:       None.
1355 **
1356 ** Returns          void
1357 **
1358 *******************************************************************************/
1359 //extern
1360 tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
1361                                 tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map);
1362 
1363 
1364 
1365 /*******************************************************************************
1366 **
1367 ** Function         BTM_BleSetAdvParamsAll
1368 **
1369 ** Description      This function is called to set all of the advertising parameters.
1370 **
1371 ** Parameters:       None.
1372 **
1373 ** Returns          void
1374 **
1375 *******************************************************************************/
1376 tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
1377                                         tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
1378                                         tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp, tBTM_START_ADV_CMPL_CBACK *adv_cb);
1379 
1380 /*******************************************************************************
1381 **
1382 ** Function         BTM_BleStartAdv
1383 **
1384 ** Description      This function is called to start adv.
1385 **
1386 ** Parameters:       None.
1387 **
1388 ** Returns          status
1389 **
1390 *******************************************************************************/
1391 tBTM_STATUS BTM_BleStartAdv(void);
1392 
1393 
1394 /*******************************************************************************
1395 **
1396 ** Function         BTM_BleWriteAdvData
1397 **
1398 ** Description      This function is called to write advertising data.
1399 **
1400 ** Parameters:       None.
1401 **
1402 ** Returns          void
1403 **
1404 *******************************************************************************/
1405 //extern
1406 tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK  data_mask,
1407                                 tBTM_BLE_ADV_DATA *p_data);
1408 
1409 /*******************************************************************************
1410 **
1411 ** Function         BTM_BleWriteLongAdvData
1412 **
1413 ** Description      This function is called to write long advertising data.
1414 **
1415 ** Parameters:      adv_data: long advertising data
1416 **                  adv_data_len: the length of long advertising data
1417 **
1418 ** Returns          void
1419 **
1420 *******************************************************************************/
1421 tBTM_STATUS BTM_BleWriteLongAdvData(uint8_t *adv_data, uint8_t adv_data_len);
1422 
1423 /*******************************************************************************
1424 **
1425 ** Function         BTM_BleWriteAdvDataRaw
1426 **
1427 ** Description      This function is called to write raw advertising data.
1428 **
1429 ** Parameters:      p_raw_adv : point to raw advertising data
1430 **                  raw_adv_len : raw advertising data
1431 **
1432 ** Returns          BTM_SUCCESS means success.
1433 **
1434 *******************************************************************************/
1435 //extern
1436 tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len);
1437 
1438 
1439 tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr);
1440 
1441 void BTM_BleClearRandAddress(void);
1442 
1443 
1444 /*******************************************************************************
1445 **
1446 ** Function         BTM_BleSetAdvParams
1447 **
1448 ** Description      This function is called to set advertising parameters.
1449 **
1450 ** Parameters       adv_int_min: minimum advertising interval
1451 **                  adv_int_max: maximum advertising interval
1452 **                  p_dir_bda: connectable direct initiator's LE device address
1453 **                  chnl_map: advertising channel map.
1454 **
1455 ** Returns          void
1456 **
1457 *******************************************************************************/
1458 //extern
1459 void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max,
1460                            tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map);
1461 
1462 /*******************************************************************************
1463 **
1464 ** Function         BTM_BleObtainVendorCapabilities
1465 **
1466 ** Description      This function is called to obtain vendor capabilities
1467 **
1468 ** Parameters       p_cmn_vsc_cb - Returns the vendor capabilities
1469 **
1470 ** Returns          void
1471 **
1472 *******************************************************************************/
1473 //extern
1474 void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
1475 
1476 /*******************************************************************************
1477 **
1478 ** Function         BTM_BleSetScanParams
1479 **
1480 ** Description      This function is called to set Scan parameters.
1481 **
1482 ** Parameters       client_if - Client IF value
1483 **                  scan_interval - Scan interval
1484 **                  scan_window - Scan window
1485 **                  scan_type - Scan type
1486 **                  scan_setup_status_cback - Scan setup status callback
1487 **
1488 ** Returns          void
1489 **
1490 *******************************************************************************/
1491 //extern
1492 void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval,
1493                           UINT32 scan_window, tBLE_SCAN_MODE scan_type,
1494                           tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
1495 
1496 
1497 
1498 /*******************************************************************************
1499 **
1500 ** Function         BTM_BleSetScanFilterParams
1501 **
1502 ** Description      This function is called to set Scan Filter & parameters.
1503 **
1504 ** Parameters       client_if - Client IF value
1505 **                  scan_interval - Scan interval
1506 **                  scan_window - Scan window
1507 **                  scan_type - Scan type
1508 **                  addr_type_own - owner address type
1509 **                  scan_duplicate_filter - scan duplicate filter
1510 **                  scan_filter_policy - scan filter policy
1511 **                  scan_setup_status_cback - Scan setup status callback
1512 **
1513 ** Returns          void
1514 **
1515 *******************************************************************************/
1516 tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window,
1517                                     tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBTM_BLE_SFP scan_filter_policy,
1518                                     tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
1519 
1520 
1521 /*******************************************************************************
1522 **
1523 ** Function         BTM_BleGetVendorCapabilities
1524 **
1525 ** Description      This function reads local LE features
1526 **
1527 ** Parameters       p_cmn_vsc_cb : Locala LE capability structure
1528 **
1529 ** Returns          void
1530 **
1531 *******************************************************************************/
1532 //extern
1533 void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
1534 /*******************************************************************************
1535 **
1536 ** Function         BTM_BleSetStorageConfig
1537 **
1538 ** Description      This function is called to setup storage configuration and setup callbacks.
1539 **
1540 ** Parameters       UINT8 batch_scan_full_max -Batch scan full maximum
1541                     UINT8 batch_scan_trunc_max - Batch scan truncated value maximum
1542                     UINT8 batch_scan_notify_threshold - Threshold value
1543                     tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback - Setup callback
1544                     tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback -Threshold callback
1545                     void *p_ref - Reference value
1546 **
1547 ** Returns          tBTM_STATUS
1548 **
1549 *******************************************************************************/
1550 //extern
1551 tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max,
1552                                     UINT8 batch_scan_trunc_max,
1553                                     UINT8 batch_scan_notify_threshold,
1554                                     tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback,
1555                                     tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
1556                                     tBTM_BLE_SCAN_REP_CBACK *p_cback,
1557                                     tBTM_BLE_REF_VALUE ref_value);
1558 
1559 /*******************************************************************************
1560 **
1561 ** Function         BTM_BleEnableBatchScan
1562 **
1563 ** Description      This function is called to enable batch scan
1564 **
1565 ** Parameters       tBTM_BLE_BATCH_SCAN_MODE scan_mode - Batch scan mode
1566                     UINT32 scan_interval -Scan interval
1567                     UINT32 scan_window - Scan window value
1568                     tBLE_ADDR_TYPE addr_type - Address type
1569                     tBTM_BLE_DISCARD_RULE discard_rule - Data discard rules
1570 **
1571 ** Returns          tBTM_STATUS
1572 **
1573 *******************************************************************************/
1574 //extern
1575 tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
1576                                    UINT32 scan_interval, UINT32 scan_window,
1577                                    tBTM_BLE_DISCARD_RULE discard_rule,
1578                                    tBLE_ADDR_TYPE addr_type,
1579                                    tBTM_BLE_REF_VALUE ref_value);
1580 
1581 /*******************************************************************************
1582 **
1583 ** Function         BTM_BleDisableBatchScan
1584 **
1585 ** Description      This function is called to disable batch scanning
1586 **
1587 ** Parameters       void
1588 **
1589 ** Returns          void
1590 **
1591 *******************************************************************************/
1592 //extern
1593 tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value);
1594 
1595 /*******************************************************************************
1596 **
1597 ** Function         BTM_BleReadScanReports
1598 **
1599 ** Description      This function is called to read batch scan reports
1600 **
1601 ** Parameters       tBLE_SCAN_MODE scan_mode - Scan mode report to be read out
1602                     tBTM_BLE_SCAN_REP_CBACK* p_cback - Reports callback
1603 **
1604 ** Returns          tBTM_STATUS
1605 **
1606 *******************************************************************************/
1607 //extern
1608 tBTM_STATUS BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode,
1609                                    tBTM_BLE_REF_VALUE ref_value);
1610 
1611 /*******************************************************************************
1612 **
1613 ** Function         BTM_BleTrackAdvertiser
1614 **
1615 ** Description      This function is called to read batch scan reports
1616 **
1617 ** Parameters       p_track_cback - Tracking callback
1618 **                  ref_value - Reference value
1619 **
1620 ** Returns          tBTM_STATUS
1621 **
1622 *******************************************************************************/
1623 //extern
1624 tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback,
1625                                    tBTM_BLE_REF_VALUE ref_value);
1626 
1627 /*******************************************************************************
1628 **
1629 ** Function         BTM_BleWriteScanRsp
1630 **
1631 ** Description      This function is called to write LE scan response.
1632 **
1633 ** Parameters:      p_scan_rsp: scan response.
1634 **
1635 ** Returns          status
1636 **
1637 *******************************************************************************/
1638 //extern
1639 tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
1640                                 tBTM_BLE_ADV_DATA *p_data);
1641 
1642 /*******************************************************************************
1643 **
1644 ** Function         BTM_BleWriteScanRspRaw
1645 **
1646 ** Description      This function is called to write raw scan response data
1647 **
1648 ** Parameters:      None.
1649 **
1650 ** Returns          void
1651 **
1652 *******************************************************************************/
1653 //extern
1654 tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len);
1655 
1656 /*******************************************************************************
1657 **
1658 ** Function         BTM_BleObserve
1659 **
1660 ** Description      This procedure keep the device listening for advertising
1661 **                  events from a broadcast device.
1662 **
1663 ** Parameters       start: start or stop observe.
1664 **
1665 ** Returns          void
1666 **
1667 *******************************************************************************/
1668 //extern
1669 tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
1670                            tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb);
1671 
1672 /*******************************************************************************
1673 **
1674 ** Function         BTM_BleScan
1675 **
1676 ** Description      This procedure keep the device listening for advertising
1677 **                  events from a broadcast device.
1678 **
1679 ** Parameters       start: start or stop scan.
1680 **
1681 ** Returns          void
1682 **
1683 *******************************************************************************/
1684 //extern
1685 tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
1686                            tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb, tBTM_INQ_DIS_CB *p_discard_cb);
1687 
1688 
1689 /*******************************************************************************
1690 **
1691 ** Function         BTM_GetDeviceIDRoot
1692 **
1693 ** Description      This function is called to read the local device identity
1694 **                  root.
1695 **
1696 ** Returns          void
1697 **                  the local device ER is copied into er
1698 **
1699 *******************************************************************************/
1700 //extern
1701 void BTM_GetDeviceIDRoot (BT_OCTET16 ir);
1702 
1703 /*******************************************************************************
1704 **
1705 ** Function         BTM_GetDeviceEncRoot
1706 **
1707 ** Description      This function is called to read the local device encryption
1708 **                  root.
1709 **
1710 ** Returns          void
1711 **                  the local device ER is copied into er
1712 **
1713 *******************************************************************************/
1714 //extern
1715 void BTM_GetDeviceEncRoot (BT_OCTET16 er);
1716 
1717 /*******************************************************************************
1718 **
1719 ** Function         BTM_GetDeviceDHK
1720 **
1721 ** Description      This function is called to read the local device DHK.
1722 **
1723 ** Returns          void
1724 **                  the local device DHK is copied into dhk
1725 **
1726 *******************************************************************************/
1727 //extern
1728 void BTM_GetDeviceDHK (BT_OCTET16 dhk);
1729 
1730 /*******************************************************************************
1731 **
1732 ** Function         BTM_SecurityGrant
1733 **
1734 ** Description      This function is called to grant security process.
1735 **
1736 ** Parameters       bd_addr - peer device bd address.
1737 **                  res     - result of the operation BTM_SUCCESS if success.
1738 **                            Otherwise, BTM_REPEATED_ATTEMPTS is too many attempts.
1739 **
1740 ** Returns          None
1741 **
1742 *******************************************************************************/
1743 //extern
1744 void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res);
1745 
1746 /*******************************************************************************
1747 **
1748 ** Function         BTM_BlePasskeyReply
1749 **
1750 ** Description      This function is called after Security Manager submitted
1751 **                  passkey request to the application.
1752 **
1753 ** Parameters:      bd_addr      - Address of the device for which passkey was requested
1754 **                  res          - result of the operation SMP_SUCCESS if success
1755 **                  passkey - numeric value in the range of
1756 **                  BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
1757 **
1758 *******************************************************************************/
1759 //extern
1760 void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey);
1761 
1762 /*******************************************************************************
1763 **
1764 ** Function         BTM_BleSetStaticPasskey
1765 **
1766 ** Description      This function is called to set static passkey
1767 **
1768 **
1769 ** Parameters:      add          - set static passkey when add is TRUE
1770 **                                 clear static passkey when add is FALSE
1771 **                  passkey      - static passkey
1772 **
1773 **
1774 *******************************************************************************/
1775 void BTM_BleSetStaticPasskey(BOOLEAN add, UINT32 passkey);
1776 
1777 /*******************************************************************************
1778 **
1779 ** Function         BTM_BleConfirmReply
1780 **
1781 ** Description      This function is called after Security Manager submitted
1782 **                  numeric comparison request to the application.
1783 **
1784 ** Parameters:      bd_addr      - Address of the device with which numeric
1785 **                                 comparison was requested
1786 **                  res          - comparison result BTM_SUCCESS if success
1787 **
1788 *******************************************************************************/
1789 //extern
1790 void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res);
1791 
1792 /*******************************************************************************
1793 **
1794 ** Function         BTM_LeOobDataReply
1795 **
1796 ** Description      This function is called to provide the OOB data for
1797 **                  SMP in response to BTM_LE_OOB_REQ_EVT
1798 **
1799 ** Parameters:      bd_addr     - Address of the peer device
1800 **                  res         - result of the operation SMP_SUCCESS if success
1801 **                  p_data      - simple pairing Randomizer  C.
1802 **
1803 *******************************************************************************/
1804 //extern
1805 void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data);
1806 
1807 
1808 /*******************************************************************************
1809 **
1810 ** Function         BTM_BleDataSignature
1811 **
1812 ** Description      This function is called to sign the data using AES128 CMAC
1813 **                  algorith.
1814 **
1815 ** Parameter        bd_addr: target device the data to be signed for.
1816 **                  p_text: singing data
1817 **                  len: length of the signing data
1818 **                  signature: output parameter where data signature is going to
1819 **                             be stored.
1820 **
1821 ** Returns          TRUE if signing sucessul, otherwise FALSE.
1822 **
1823 *******************************************************************************/
1824 //extern
1825 BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len,
1826                               BLE_SIGNATURE signature);
1827 
1828 /*******************************************************************************
1829 **
1830 ** Function         BTM_BleVerifySignature
1831 **
1832 ** Description      This function is called to verify the data signature
1833 **
1834 ** Parameter        bd_addr: target device the data to be signed for.
1835 **                  p_orig:  original data before signature.
1836 **                  len: length of the signing data
1837 **                  counter: counter used when doing data signing
1838 **                  p_comp: signature to be compared against.
1839 
1840 ** Returns          TRUE if signature verified correctly; otherwise FALSE.
1841 **
1842 *******************************************************************************/
1843 //extern
1844 BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig,
1845                                 UINT16 len, UINT32 counter,
1846                                 UINT8 *p_comp);
1847 
1848 /*******************************************************************************
1849 **
1850 ** Function         BTM_ReadConnectionAddr
1851 **
1852 ** Description      This function is called to set the local device random address
1853 **                  .
1854 **
1855 ** Returns          void
1856 **
1857 *******************************************************************************/
1858 //extern
1859 void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr,
1860                              tBLE_ADDR_TYPE *p_addr_type);
1861 
1862 
1863 
1864 /*******************************************************************************
1865 **
1866 ** Function         BTM_ReadRemoteConnectionAddr
1867 **
1868 ** Description      This function is read the remote device address currently used
1869 **                  .
1870 **
1871 ** Returns          void
1872 **
1873 *******************************************************************************/
1874 //extern
1875 BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr,
1876                                      BD_ADDR conn_addr,
1877                                      tBLE_ADDR_TYPE *p_addr_type);
1878 
1879 /*******************************************************************************
1880 **
1881 ** Function         BTM_BleLoadLocalKeys
1882 **
1883 ** Description      Local local identity key, encryption root or sign counter.
1884 **
1885 ** Parameters:      key_type: type of key, can be BTM_BLE_KEY_TYPE_ID, BTM_BLE_KEY_TYPE_ER
1886 **                            or BTM_BLE_KEY_TYPE_COUNTER.
1887 **                  p_key: pointer to the key.
1888 *
1889 ** Returns          non2.
1890 **
1891 *******************************************************************************/
1892 //extern
1893 void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
1894 
1895 
1896 /*******************************************************************************
1897 **
1898 ** Function         BTM_BleSetBgConnType
1899 **
1900 ** Description      This function is called to set BLE background connection
1901 **                  procedure type. It can be auto connection, or selective connection.
1902 **
1903 ** Parameters       conn_type: it can be auto connection, or selective connection.
1904 **                  p_select_cback: callback function when selective connection procedure
1905 **                              is being used.
1906 **
1907 ** Returns          void
1908 **
1909 *******************************************************************************/
1910 //extern
1911 BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE   conn_type,
1912                              tBTM_BLE_SEL_CBACK   *p_select_cback);
1913 
1914 /*******************************************************************************
1915 **
1916 ** Function         BTM_BleUpdateBgConnDev
1917 **
1918 ** Description      This function is called to add or remove a device into/from
1919 **                  background connection procedure. The background connection
1920 *                   procedure is decided by the background connection type, it can be
1921 *                   auto connection, or selective connection.
1922 **
1923 ** Parameters       add_remove: TRUE to add; FALSE to remove.
1924 **                  remote_bda: device address to add/remove.
1925 **
1926 ** Returns          void
1927 **
1928 *******************************************************************************/
1929 //extern
1930 BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR   remote_bda);
1931 
1932 /*******************************************************************************
1933 **
1934 ** Function         BTM_BleClearBgConnDev
1935 **
1936 ** Description      This function is called to clear the whitelist,
1937 **                  end any pending whitelist connections,
1938 *                   and reset the local bg device list.
1939 **
1940 ** Parameters       void
1941 **
1942 ** Returns          void
1943 **
1944 *******************************************************************************/
1945 //extern
1946 void BTM_BleClearBgConnDev(void);
1947 
1948 /********************************************************
1949 **
1950 ** Function         BTM_BleSetPrefConnParams
1951 **
1952 ** Description      Set a peripheral's preferred connection parameters. When
1953 **                  any of the value does not want to be updated while others
1954 **                  do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to
1955 **                  leave untouched.
1956 **
1957 ** Parameters:      bd_addr          - BD address of the peripheral
1958 **                  min_conn_int     - minimum preferred connection interval
1959 **                  max_conn_int     - maximum preferred connection interval
1960 **                  slave_latency    - preferred slave latency
1961 **                  supervision_tout - preferred supervision timeout
1962 **
1963 ** Returns          void
1964 **
1965 *******************************************************************************/
1966 //extern
1967 void BTM_BleSetPrefConnParams (BD_ADDR bd_addr,
1968                                UINT16 min_conn_int,  UINT16 max_conn_int,
1969                                UINT16 slave_latency, UINT16 supervision_tout);
1970 
1971 /******************************************************************************
1972 **
1973 ** Function         BTM_BleSetConnScanParams
1974 **
1975 ** Description      Set scan parameters used in BLE connection request
1976 **
1977 ** Parameters:      scan_interval    - scan interval
1978 **                  scan_window      - scan window
1979 **
1980 ** Returns          void
1981 **
1982 *******************************************************************************/
1983 //extern
1984 void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window);
1985 
1986 /******************************************************************************
1987 **
1988 ** Function         BTM_BleReadControllerFeatures
1989 **
1990 ** Description      Reads BLE specific controller features
1991 **
1992 ** Parameters:      tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when features are read
1993 **
1994 ** Returns          void
1995 **
1996 *******************************************************************************/
1997 //extern
1998 void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK  *p_vsc_cback);
1999 
2000 /*******************************************************************************
2001 **
2002 ** Function         BTM_CheckAdvData
2003 **
2004 ** Description      This function is called to get ADV data for a specific type.
2005 **
2006 ** Parameters       p_adv - pointer of ADV data
2007 **                  type   - finding ADV data type
2008 **                  p_length - return the length of ADV data not including type
2009 **
2010 ** Returns          pointer of ADV data
2011 **
2012 *******************************************************************************/
2013 //extern
2014 UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length);
2015 
2016 /*******************************************************************************
2017 **
2018 ** Function         BTM_BleGetCurrentAddress
2019 **
2020 ** Description      This function is called to get local used BLE address.
2021 **
2022 ** Parameters:       None.
2023 **
2024 ** Returns          success or fail
2025 **
2026 *******************************************************************************/
2027 BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type);
2028 
2029 /*******************************************************************************
2030 **
2031 ** Function         BTM__BLEReadDiscoverability
2032 **
2033 ** Description      This function is called to read the current LE discoverability
2034 **                  mode of the device.
2035 **
2036 ** Returns          BTM_BLE_NON_DISCOVERABLE ,BTM_BLE_LIMITED_DISCOVERABLE or
2037 **                     BTM_BLE_GENRAL_DISCOVERABLE
2038 **
2039 *******************************************************************************/
2040 UINT16 BTM_BleReadDiscoverability(void);
2041 
2042 /*******************************************************************************
2043 **
2044 ** Function         BTM__BLEReadConnectability
2045 **
2046 ** Description      This function is called to read the current LE connectibility
2047 **                  mode of the device.
2048 **
2049 ** Returns          BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE
2050 **
2051 *******************************************************************************/
2052 //extern
2053 UINT16 BTM_BleReadConnectability (void);
2054 
2055 void BTM_Recovery_Pre_State(void);
2056 
2057 /*******************************************************************************
2058 **
2059 ** Function         BTM_ReadDevInfo
2060 **
2061 ** Description      This function is called to read the device/address type
2062 **                  of BD address.
2063 **
2064 ** Parameter        remote_bda: remote device address
2065 **                  p_dev_type: output parameter to read the device type.
2066 **                  p_addr_type: output parameter to read the address type.
2067 **
2068 *******************************************************************************/
2069 //extern
2070 void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type,
2071                       tBLE_ADDR_TYPE *p_addr_type);
2072 
2073 
2074 /*******************************************************************************
2075 **
2076 ** Function         BTM_ReadConnectedTransportAddress
2077 **
2078 ** Description      This function is called to read the paired device/address type of other device paired
2079 **                  corresponding to the BD_address
2080 **
2081 ** Parameter        remote_bda: remote device address, carry out the transport address
2082 **                  transport: active transport
2083 **
2084 ** Return           TRUE if an active link is identified; FALSE otherwise
2085 **
2086 *******************************************************************************/
2087 //extern
2088 BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda,
2089         tBT_TRANSPORT transport);
2090 
2091 /*******************************************************************************
2092 **
2093 ** Function         BTM_BleBroadcast
2094 **
2095 ** Description      This function is to start or stop broadcasting.
2096 **
2097 ** Parameters       start: start or stop broadcasting.
2098 **
2099 ** Returns          status.
2100 **
2101 *******************************************************************************/
2102 //extern
2103 tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback);
2104 
2105 /*******************************************************************************
2106 **
2107 ** Function         BTM_BleConfigPrivacy
2108 **
2109 ** Description      This function is called to enable or disable the privacy in
2110 **                  the local device.
2111 **
2112 ** Parameters       enable: TRUE to enable it; FALSE to disable it.
2113 **
2114 ** Returns          BOOLEAN privacy mode set success; otherwise failed.
2115 **
2116 *******************************************************************************/
2117 //extern
2118 BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck);
2119 
2120 /*******************************************************************************
2121 **
2122 ** Function         BTM_BleConfigLocalIcon
2123 **
2124 ** Description      This function is called to set local icon
2125 **
2126 ** Parameters       icon: appearance value.
2127 **
2128 **
2129 *******************************************************************************/
2130 void BTM_BleConfigLocalIcon(uint16_t icon);
2131 
2132 /*******************************************************************************
2133 **
2134 ** Function         BTM_BleConfigConnParams
2135 **
2136 ** Description      This function is called to set the connection parameters
2137 **
2138 ** Parameters       int_min:  minimum connection interval
2139 **                  int_max:  maximum connection interval
2140 **                  latency:  slave latency
2141 **                  timeout:  supervision timeout
2142 **
2143 *******************************************************************************/
2144 void BTM_BleConfigConnParams(uint16_t int_min, uint16_t int_max, uint16_t latency, uint16_t timeout);
2145 
2146 /*******************************************************************************
2147 **
2148 ** Function         BTM_BleLocalPrivacyEnabled
2149 **
2150 ** Description        Checks if local device supports private address
2151 **
2152 ** Returns          Return TRUE if local privacy is enabled else FALSE
2153 **
2154 *******************************************************************************/
2155 //extern
2156 BOOLEAN BTM_BleLocalPrivacyEnabled(void);
2157 
2158 /*******************************************************************************
2159 **
2160 ** Function         BTM_BleEnableMixedPrivacyMode
2161 **
2162 ** Description      This function is called to enabled Mixed mode if privacy 1.2
2163 **                  is applicable in controller.
2164 **
2165 ** Parameters       mixed_on:  mixed mode to be used or not.
2166 **
2167 ** Returns          void
2168 **
2169 *******************************************************************************/
2170 //extern
2171 void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on);
2172 
2173 /*******************************************************************************
2174 **
2175 ** Function          BTM_BleMaxMultiAdvInstanceCount
2176 **
2177 ** Description        Returns max number of multi adv instances  supported by controller
2178 **
2179 ** Returns          Max multi adv instance count
2180 **
2181 *******************************************************************************/
2182 //extern
2183 UINT8  BTM_BleMaxMultiAdvInstanceCount(void);
2184 
2185 /*******************************************************************************
2186 **
2187 ** Function         BTM_BleSetConnectableMode
2188 **
2189 ** Description      This function is called to set BLE connectable mode for a
2190 **                  peripheral device.
2191 **
2192 ** Parameters       connectable_mode:  directed connectable mode, or non-directed.It can
2193 **                              be BTM_BLE_CONNECT_EVT, BTM_BLE_CONNECT_DIR_EVT or
2194 **                              BTM_BLE_CONNECT_LO_DUTY_DIR_EVT
2195 **
2196 ** Returns          BTM_ILLEGAL_VALUE if controller does not support BLE.
2197 **                  BTM_SUCCESS is status set successfully; otherwise failure.
2198 **
2199 *******************************************************************************/
2200 //extern
2201 tBTM_STATUS BTM_BleSetConnectableMode(tBTM_BLE_CONN_MODE connectable_mode);
2202 
2203 /*******************************************************************************
2204 **
2205 ** Function         BTM_BleTurnOnPrivacyOnRemote
2206 **
2207 ** Description      This function is called to enable or disable the privacy on the
2208 **                  remote device.
2209 **
2210 ** Parameters       bd_addr: remote device address.
2211 **                  privacy_on: TRUE to enable it; FALSE to disable it.
2212 **
2213 ** Returns          void
2214 **
2215 *******************************************************************************/
2216 //extern
2217 void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr,
2218                                   BOOLEAN privacy_on);
2219 
2220 /*******************************************************************************
2221 **
2222 ** Function         BTM_BleUpdateAdvWhitelist
2223 **
2224 ** Description      Add or remove device from advertising white list
2225 **
2226 ** Returns          void
2227 **
2228 *******************************************************************************/
2229 //extern
2230 BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_ADDR_TYPE addr_type, tBTM_ADD_WHITELIST_CBACK *add_wl_cb);
2231 
2232 /*******************************************************************************
2233 **
2234 ** Function         BTM_BleClearWhitelist
2235 **
2236 ** Description      Clear all white list
2237 **
2238 ** Returns          void
2239 **
2240 *******************************************************************************/
2241 void BTM_BleClearWhitelist(void);
2242 
2243 /*******************************************************************************
2244 **
2245 ** Function         BTM_BleUpdateAdvFilterPolicy
2246 **
2247 ** Description      This function update the filter policy of advertiser.
2248 **
2249 ** Parameter        adv_policy: advertising filter policy
2250 **
2251 ** Return           void
2252 *******************************************************************************/
2253 //extern
2254 void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy);
2255 
2256 /*******************************************************************************
2257 **
2258 ** Function         BTM_BleReceiverTest
2259 **
2260 ** Description      This function is called to start the LE Receiver test
2261 **
2262 ** Parameter       rx_freq - Frequency Range
2263 **               p_cmd_cmpl_cback - Command Complete callback
2264 **
2265 *******************************************************************************/
2266 void BTM_BleReceiverTest(UINT8 rx_freq, tBTM_CMPL_CB *p_cmd_cmpl_cback);
2267 
2268 
2269 /*******************************************************************************
2270 **
2271 ** Function         BTM_BleTransmitterTest
2272 **
2273 ** Description      This function is called to start the LE Transmitter test
2274 **
2275 ** Parameter       tx_freq - Frequency Range
2276 **                       test_data_len - Length in bytes of payload data in each packet
2277 **                       packet_payload - Pattern to use in the payload
2278 **                       p_cmd_cmpl_cback - Command Complete callback
2279 **
2280 *******************************************************************************/
2281 void BTM_BleTransmitterTest(UINT8 tx_freq, UINT8 test_data_len,
2282                             UINT8 packet_payload, tBTM_CMPL_CB *p_cmd_cmpl_cback);
2283 
2284 /*******************************************************************************
2285 **
2286 ** Function         BTM_BleTestEnd
2287 **
2288 ** Description      This function is called to stop the in-progress TX or RX test
2289 **
2290 ** Parameter       p_cmd_cmpl_cback - Command complete callback
2291 **
2292 *******************************************************************************/
2293 void BTM_BleTestEnd(tBTM_CMPL_CB *p_cmd_cmpl_cback);
2294 
2295 /*******************************************************************************
2296 **
2297 ** Function         BTM_UseLeLink
2298 **
2299 ** Description      This function is to select the underneath physical link to use.
2300 **
2301 ** Returns          TRUE to use LE, FALSE use BR/EDR.
2302 **
2303 *******************************************************************************/
2304 //extern
2305 BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr);
2306 
2307 /*******************************************************************************
2308 **
2309 ** Function         BTM_BleStackEnable
2310 **
2311 ** Description      Enable/Disable BLE functionality on stack regarless controller
2312 **                  capability.
2313 **
2314 ** Parameters:      enable: TRUE to enable, FALSE to disable.
2315 **
2316 ** Returns          TRUE if added OK, else FALSE
2317 **
2318 *******************************************************************************/
2319 //extern
2320 tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable);
2321 
2322 /*******************************************************************************
2323 **
2324 ** Function         BTM_GetLeSecurityState
2325 **
2326 ** Description      This function is called to get security mode 1 flags and
2327 **                  encryption key size for LE peer.
2328 **
2329 ** Returns          BOOLEAN TRUE if LE device is found, FALSE otherwise.
2330 **
2331 *******************************************************************************/
2332 //extern
2333 BOOLEAN BTM_GetLeSecurityState (BD_ADDR bd_addr,
2334                                 UINT8 *p_le_dev_sec_flags,
2335                                 UINT8 *p_le_key_size);
2336 
2337 /*******************************************************************************
2338 **
2339 ** Function         BTM_BleSecurityProcedureIsRunning
2340 **
2341 ** Description      This function indicates if LE security procedure is
2342 **                  currently running with the peer.
2343 **
2344 ** Returns          BOOLEAN TRUE if security procedure is running, FALSE otherwise.
2345 **
2346 *******************************************************************************/
2347 //extern
2348 BOOLEAN BTM_BleSecurityProcedureIsRunning (BD_ADDR bd_addr);
2349 
2350 /*******************************************************************************
2351 **
2352 ** Function         BTM_BleGetSupportedKeySize
2353 **
2354 ** Description      This function gets the maximum encryption key size in bytes
2355 **                  the local device can suport.
2356 **                  record.
2357 **
2358 ** Returns          the key size or 0 if the size can't be retrieved.
2359 **
2360 *******************************************************************************/
2361 //extern
2362 UINT8 BTM_BleGetSupportedKeySize (BD_ADDR bd_addr);
2363 
2364 /*******************************************************************************/
2365 /*                          Multi ADV API                                      */
2366 /*******************************************************************************
2367 **
2368 ** Function         BTM_BleEnableAdvInstance
2369 **
2370 ** Description      This function enable a Multi-ADV instance with the specified
2371 **                  adv parameters
2372 **
2373 ** Parameters       p_params: pointer to the adv parameter structure, set as default
2374 **                            adv parameter when the instance is enabled.
2375 **                  p_cback: callback function for the adv instance.
2376 **                  p_ref:  reference data attach to the adv instance to be enabled.
2377 **
2378 ** Returns          status
2379 **
2380 *******************************************************************************/
2381 //extern
2382 tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params,
2383                                       tBTM_BLE_MULTI_ADV_CBACK *p_cback,
2384                                       void *p_ref);
2385 
2386 /*******************************************************************************
2387 **
2388 ** Function         BTM_BleUpdateAdvInstParam
2389 **
2390 ** Description      This function update a Multi-ADV instance with the specififed
2391 **                  adv parameters.
2392 **
2393 ** Parameters       inst_id: adv instance ID
2394 **                  p_params: pointer to the adv parameter structure.
2395 **
2396 ** Returns          status
2397 **
2398 *******************************************************************************/
2399 //extern
2400 tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params);
2401 
2402 /*******************************************************************************
2403 **
2404 ** Function         BTM_BleCfgAdvInstData
2405 **
2406 ** Description      This function configure a Multi-ADV instance with the specified
2407 **                  adv data or scan response data.
2408 **
2409 ** Parameters       inst_id: adv instance ID
2410 **                  is_scan_rsp: is this scacn response, if no set as adv data.
2411 **                  data_mask: adv data mask.
2412 **                  p_data: pointer to the adv data structure.
2413 **
2414 ** Returns          status
2415 **
2416 *******************************************************************************/
2417 //extern
2418 tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
2419                                    tBTM_BLE_AD_MASK data_mask,
2420                                    tBTM_BLE_ADV_DATA *p_data);
2421 
2422 /*******************************************************************************
2423 **
2424 ** Function         BTM_BleDisableAdvInstance
2425 **
2426 ** Description      This function disable a Multi-ADV instance.
2427 **
2428 ** Parameters       inst_id: adv instance ID
2429 **
2430 ** Returns          status
2431 **
2432 *******************************************************************************/
2433 //extern
2434 tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id);
2435 
2436 /*******************************************************************************
2437 **
2438 ** Function         BTM_BleAdvFilterParamSetup
2439 **
2440 ** Description      This function is called to setup the adv data payload filter
2441 **                  condition.
2442 **
2443 ** Parameters       p_target: enabble the filter condition on a target device; if NULL
2444 **                            enable the generic scan condition.
2445 **                  enable: enable or disable the filter condition
2446 **
2447 ** Returns          void
2448 **
2449 *******************************************************************************/
2450 //extern
2451 tBTM_STATUS BTM_BleAdvFilterParamSetup(int action,
2452                                        tBTM_BLE_PF_FILT_INDEX filt_index,
2453                                        tBTM_BLE_PF_FILT_PARAMS *p_filt_params,
2454                                        tBLE_BD_ADDR *p_target, tBTM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
2455                                        tBTM_BLE_REF_VALUE ref_value);
2456 
2457 /*******************************************************************************
2458 **
2459 ** Function         BTM_BleCfgFilterCondition
2460 **
2461 ** Description      This function is called to configure the adv data payload filter
2462 **                  condition.
2463 **
2464 ** Parameters       action: to read/write/clear
2465 **                  cond_type: filter condition type.
2466 **                  p_cond: filter condition paramter
2467 **
2468 ** Returns          tBTM_STATUS
2469 **
2470 *******************************************************************************/
2471 //extern
2472 tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP action,
2473                                       tBTM_BLE_PF_COND_TYPE cond_type,
2474                                       tBTM_BLE_PF_FILT_INDEX filt_index,
2475                                       tBTM_BLE_PF_COND_PARAM *p_cond,
2476                                       tBTM_BLE_PF_CFG_CBACK *p_cmpl_cback,
2477                                       tBTM_BLE_REF_VALUE ref_value);
2478 
2479 /*******************************************************************************
2480 **
2481 ** Function         BTM_BleEnableDisableFilterFeature
2482 **
2483 ** Description      This function is called to enable or disable the APCF feature
2484 **
2485 ** Parameters       enable - TRUE - enables the APCF, FALSE - disables the APCF
2486 **                       ref_value - Ref value
2487 **
2488 ** Returns          tBTM_STATUS
2489 **
2490 *******************************************************************************/
2491 //extern
2492 tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable,
2493         tBTM_BLE_PF_STATUS_CBACK *p_stat_cback,
2494         tBTM_BLE_REF_VALUE ref_value);
2495 
2496 /*******************************************************************************
2497 **
2498 ** Function         BTM_BleGetEnergyInfo
2499 **
2500 ** Description      This function obtains the energy info
2501 **
2502 ** Parameters       p_ener_cback - Callback pointer
2503 **
2504 ** Returns          status
2505 **
2506 *******************************************************************************/
2507 //extern
2508 tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback);
2509 
2510 /*******************************************************************************
2511 **
2512 ** Function         BTM_SetBleDataLength
2513 **
2514 ** Description      This function is called to set maximum BLE transmission packet size
2515 **
2516 ** Returns          BTM_SUCCESS if success; otherwise failed.
2517 **
2518 *******************************************************************************/
2519 //extern
2520 tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length);
2521 
2522 /*******************************************************************************
2523 **
2524 ** Function         BTM_UpdateBleDuplicateExceptionalList
2525 **
2526 ** Description      This function is called to update duplicate scan exceptional list.
2527 **
2528 ** Parameters:      subcode: add, remove or clean duplicate scan exceptional list.
2529 **                  type: device info type
2530 **                  device_info: device information
2531 **                  update_exceptional_list_cmp_cb: complete callback
2532 **
2533 ** Returns          status
2534 **
2535 *******************************************************************************/
2536 
2537 tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info, tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb);
2538 
2539 /*******************************************************************************
2540 **
2541 ** Function         BTM_GetCurrentConnParams
2542 **
2543 ** Description      This function is called to read the current connection parameters
2544 **                  of the device
2545 **
2546 ** Returns          TRUE or FALSE
2547 **
2548 *******************************************************************************/
2549 
2550 BOOLEAN BTM_GetCurrentConnParams(BD_ADDR bda, uint16_t *interval, uint16_t *latency, uint16_t *timeout);
2551 
2552 /*******************************************************************************
2553 **
2554 ** Function         BTM_Ble_Authorization
2555 **
2556 ** Description      This function is used to authorize a specified device
2557 **
2558 ** Returns          TRUE or FALSE
2559 **
2560 *******************************************************************************/
2561 BOOLEAN BTM_Ble_Authorization(BD_ADDR bd_addr, BOOLEAN authorize);
2562 /*
2563 #ifdef __cplusplus
2564 }
2565 #endif
2566 */
2567 #if (BLE_50_FEATURE_SUPPORT == TRUE)
2568 void BTM_BleGapRegisterCallback(tBTM_BLE_5_HCI_CBACK cb);
2569 
2570 tBTM_STATUS BTM_BleReadPhy(BD_ADDR bd_addr, UINT8 *tx_phy, UINT8 *rx_phy);
2571 
2572 tBTM_STATUS BTM_BleSetPreferDefaultPhy(UINT8 tx_phy_mask, UINT8 rx_phy_mask);
2573 
2574 tBTM_STATUS BTM_BleSetPreferPhy(BD_ADDR bd_addr, UINT8 all_phys, UINT8 tx_phy_mask,
2575                                            UINT8 rx_phy_mask, UINT16 phy_options);
2576 
2577 tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr);
2578 
2579 tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PARAMS *params);
2580 
2581 tBTM_STATUS BTM_BleConfigExtendedAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 len, UINT8 *data);
2582 
2583 tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_adv);
2584 
2585 tBTM_STATUS BTM_BleExtAdvSetRemove(UINT8 instance);
2586 
2587 tBTM_STATUS BTM_BleExtAdvSetClear(void);
2588 
2589 tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Params *params);
2590 
2591 tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data);
2592 
2593 tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, BOOLEAN enable);
2594 
2595 tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params);
2596 
2597 tBTM_STATUS BTM_BlePeriodicAdvSyncCancel(void);
2598 
2599 tBTM_STATUS BTM_BlePeriodicAdvSyncTerm(UINT16 sync_handle);
2600 
2601 tBTM_STATUS BTM_BlePeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid);
2602 
2603 tBTM_STATUS BTM_BlePeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid);
2604 
2605 tBTM_STATUS BTM_BlePeriodicAdvClearDev(void);
2606 
2607 tBTM_STATUS BTM_BleSetExtendedScanParams(tBTM_BLE_EXT_SCAN_PARAMS *params);
2608 
2609 tBTM_STATUS BTM_BleExtendedScan(BOOLEAN enable, UINT16 duration, UINT16 period);
2610 
2611 void BTM_BleSetPreferExtenedConnParams(BD_ADDR bd_addr, tBTM_EXT_CONN_PARAMS *params);
2612 
2613 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
2614 
2615 #endif
2616