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