1 /*
2  * Copyright 2016-2023, Cypress Semiconductor Corporation or
3  * an affiliate of Cypress Semiconductor Corporation.  All rights reserved.
4  *
5  * This software, including source code, documentation and related
6  * materials ("Software") is owned by Cypress Semiconductor Corporation
7  * or one of its affiliates ("Cypress") and is protected by and subject to
8  * worldwide patent protection (United States and foreign),
9  * United States copyright laws and international treaty provisions.
10  * Therefore, you may use this Software only as provided in the license
11  * agreement accompanying the software package from which you
12  * obtained this Software ("EULA").
13  * If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
14  * non-transferable license to copy, modify, and compile the Software
15  * source code solely for use in connection with Cypress's
16  * integrated circuit products.  Any reproduction, modification, translation,
17  * compilation, or representation of this Software except as specified
18  * above is prohibited without the express written permission of Cypress.
19  *
20  * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
23  * reserves the right to make changes to the Software without notice. Cypress
24  * does not assume any liability arising out of the application or use of the
25  * Software or any product or circuit described in the Software. Cypress does
26  * not authorize its products for use in any products where a malfunction or
27  * failure of the Cypress product may reasonably be expected to result in
28  * significant property damage, injury or death ("High Risk Product"). By
29  * including Cypress's product in a High Risk Product, the manufacturer
30  * of such system or application assumes all risk of such use and in doing
31  * so agrees to indemnify Cypress against all liability.
32  */
33 
34 /** @file
35  *
36  * Bluetooth Management (BTM) Application Programming Interface
37  *
38  * The BTM consists of several management entities:
39  *      1. Device Control - controls the local device
40  *      2. Device Discovery - manages inquiries, discover database
41  *      3. ACL Channels - manages ACL connections (BR/EDR and LE)
42  *      4. SCO Channels - manages SCO connections
43  *      5. Security - manages all security functionality
44  *      6. Power Management - manages park, sniff, hold, etc.
45  *
46  */
47 
48 #pragma once
49 
50 #include "wiced_bt_types.h"
51 #include "wiced_result.h"
52 #include "hcidefs.h"
53 #include "wiced_bt_sco.h"
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /**
60  * This section consists of several management entities:
61  *      - Device Control - controls the local device
62  *      - Device Discovery - manages inquiries, discover database
63  * @if DUAL_MODE
64  *      - ACL Channels - manages ACL connections (BR/EDR and LE)
65  *      - SCO Channels - manages SCO connections
66  *      - Power Management - manages park, sniff, hold, etc.
67  * @else
68  *      - ACL Channels - manages BLE ACL connections
69  *      - Security - manages all security functionality
70  * @endif
71  *
72  * @addtogroup  wicedbt_DeviceManagement    Device Management
73  *
74  * @ingroup     wicedbt
75  *
76  * @{
77  */
78 /****************************************************************************/
79 
80 /** RSSI value not supplied (ignore it) */
81 #define BTM_INQ_RES_IGNORE_RSSI     0x7f
82 /** Passed to BTM_SetScanConfig() to ignore */
83 #define BTM_SCAN_PARAM_IGNORE       0
84 
85 /** TX Power Result   (in response to #wiced_bt_dev_read_tx_power) */
86 typedef struct
87 {
88     wiced_result_t                  status;             /**< Status of the operation */
89     uint8_t                         hci_status;         /**< Status from controller (Refer Spec 5.0 Vol 2 Part D Error Codes) */
90     int8_t                          tx_power;           /**< TX power in dB */
91     wiced_bt_device_address_t       rem_bda;            /**< Remote BD address */
92 } wiced_bt_tx_power_result_t;
93 
94 /** TX Power Result (in response to #wiced_bt_ble_set_adv_tx_power) */
95 typedef struct
96 {
97     uint16_t    un_used1;                     /**< Unused */
98     uint16_t    un_used2;                     /**< Unused */
99     uint8_t     *p_param_buf;                 /**< Command status, see list of HCI Error codes in core spec*/
100 } wiced_bt_set_adv_tx_power_result_t;
101 
102 /** Structure returned with Vendor Specific Command complete callback */
103 typedef struct
104 {
105     uint16_t    opcode;                     /**< Vendor specific command opcode */
106     uint16_t    param_len;                  /**< Return parameter length        */
107     uint8_t     *p_param_buf;               /**< Return parameter buffer (Contains Command Specific data) */
108 } wiced_bt_dev_vendor_specific_command_complete_params_t;
109 
110 /** @cond DUAL_MODE */
111 
112 /** Structure for local address extendend API
113  @note #wiced_bt_dev_read_local_addr_ext API function sets private_addr_type and private_addr only if BLE privacy is set to true */
114 typedef struct
115 {
116     wiced_bool_t                    is_static_rand_addr_used;   /**< True if static random address is used */
117     wiced_bool_t                    is_privacy_enabled;         /**< True BLE Privacy is enabled */
118     wiced_bt_ble_address_type_t     private_addr_type;          /**< Private address type*/
119     wiced_bt_device_address_t       private_addr;               /**< Private address */
120     wiced_bt_device_address_t       local_addr;                 /**< Local Bluetooth Address */
121 } wiced_bt_dev_local_addr_ext_t;
122 
123 /** Default Discovery Window (in 0.625 msec intervals) */
124 #define BTM_DEFAULT_DISC_WINDOW     0x0012
125 /** Default Discovery Interval (in 0.625 msec intervals) */
126 #define BTM_DEFAULT_DISC_INTERVAL   0x0800
127 
128 /** Default Connection Window  */
129 #define BTM_DEFAULT_CONN_WINDOW     0x0012
130 /** Default Connection Interval  */
131 #define BTM_DEFAULT_CONN_INTERVAL   0x0800
132 
133 /** BR-EDR Discoverable modes */
134 enum wiced_bt_discoverability_mode_e {
135     BTM_NON_DISCOVERABLE            = 0,        /**< Non discoverable */
136     BTM_LIMITED_DISCOVERABLE        = 1,        /**< Limited BR/EDR discoverable */
137     BTM_GENERAL_DISCOVERABLE        = 2         /**< General BR/EDR discoverable */
138 };
139 
140 /** BR/EDR Connectable modes */
141 enum wiced_bt_connectability_mode_e {
142     BTM_NON_CONNECTABLE             = 0,        /**< Not connectable */
143     BTM_CONNECTABLE                 = 1         /**< BR/EDR connectable */
144 };
145 
146 /** Inquiry modes
147   * @note These modes are associated with the inquiry active values */
148 enum wiced_bt_inquiry_mode_e {
149     BTM_INQUIRY_NONE                = 0,        /**< Stop inquiry */
150     BTM_GENERAL_INQUIRY             = 0x01,     /**< General inquiry */
151     BTM_LIMITED_INQUIRY             = 0x02,     /**< Limited inquiry */
152     BTM_BR_INQUIRY_MASK             = (BTM_GENERAL_INQUIRY | BTM_LIMITED_INQUIRY) /**< BR Inquiry Mask */
153 };
154 
155 /** Discoverable Mask */
156 #define BTM_DISCOVERABLE_MASK       (BTM_LIMITED_DISCOVERABLE|BTM_GENERAL_DISCOVERABLE)
157 /** Max Value for Discoverable */
158 #define BTM_MAX_DISCOVERABLE        BTM_GENERAL_DISCOVERABLE
159 /** Connectable Mask */
160 #define BTM_CONNECTABLE_MASK        (BTM_NON_CONNECTABLE | BTM_CONNECTABLE)
161 
162 /** Standard Scan Type : Device listens for the duration of the scan window*/
163 #define BTM_SCAN_TYPE_STANDARD      0
164 /** Interlaces Scan Type : Device performed two back to back scans */
165 #define BTM_SCAN_TYPE_INTERLACED    1
166 
167 /** Inquiry results  */
168 #define BTM_INQ_RESULT              0
169 /** Inquiry results with RSSI  */
170 #define BTM_INQ_RESULT_WITH_RSSI    1
171 /** Extended Inquiry results */
172 #define BTM_INQ_RESULT_EXTENDED     2
173 
174 /** Inquiry Filter Condition types (see wiced_bt_dev_inq_parms_t) */
175 enum wiced_bt_dev_filter_cond_e {
176     BTM_CLR_INQUIRY_FILTER          = 0,                            /**< No inquiry filter */
177     BTM_FILTER_COND_DEVICE_CLASS    = HCI_FILTER_COND_DEVICE_CLASS, /**< Filter on device class */
178     BTM_FILTER_COND_BD_ADDR         = HCI_FILTER_COND_BD_ADDR,      /**< Filter on device addr */
179 };
180 
181 /** BTM service definitions (used for storing EIR data to bit mask refer eir_uuid_mask in #wiced_bt_dev_inquiry_scan_result_t) */
182 enum
183 {
184     BTM_EIR_UUID_SERVCLASS_SERIAL_PORT,         /**< Serial Port Service Index */
185     BTM_EIR_UUID_SERVCLASS_DIALUP_NETWORKING,   /**< Dialup Networking Service Index */
186     BTM_EIR_UUID_SERVCLASS_IRMC_SYNC,           /**< IRMC SYNC Service Index */
187     BTM_EIR_UUID_SERVCLASS_OBEX_OBJECT_PUSH,    /**< OBEX Object Push Service Index */
188     BTM_EIR_UUID_SERVCLASS_OBEX_FILE_TRANSFER,  /**< OBEX File Transfer Service Index */
189     BTM_EIR_UUID_SERVCLASS_IRMC_SYNC_COMMAND,   /**< IRMC SYNC Command Service Index */
190     BTM_EIR_UUID_SERVCLASS_HEADSET,             /**< Headset Service Index */
191     BTM_EIR_UUID_SERVCLASS_AUDIO_SOURCE,        /**< Audio Source Service Index */
192     BTM_EIR_UUID_SERVCLASS_AUDIO_SINK,          /**< Audio Sink Service Index */
193     BTM_EIR_UUID_SERVCLASS_AV_REM_CTRL_TARGET,  /**< AVRCP TG Service Index */
194     BTM_EIR_UUID_SERVCLASS_AV_REMOTE_CONTROL,   /**< AVRCP CT Service Index */
195     BTM_EIR_UUID_SERVCLASS_HEADSET_AUDIO_GATEWAY,   /**< Headset AG Service Index */
196     BTM_EIR_UUID_SERVCLASS_DIRECT_PRINTING,     /**< Direct Printing Service Index */
197     BTM_EIR_UUID_SERVCLASS_HF_HANDSFREE,        /**< HF Handsfree Service Index */
198     BTM_EIR_UUID_SERVCLASS_AG_HANDSFREE,        /**< AG Handsfree Service Index */
199     BTM_EIR_UUID_SERVCLASS_HUMAN_INTERFACE,     /**< Human Interface Service Index */
200     BTM_EIR_UUID_SERVCLASS_SAP,                 /**< SAP Service Index */
201     BTM_EIR_UUID_SERVCLASS_PBAP_PCE,            /**< PBAP PCE Service Index */
202     BTM_EIR_UUID_SERVCLASS_PBAP_PSE,            /**< PBAP PSE Service Index */
203     BTM_EIR_UUID_SERVCLASS_PHONE_ACCESS,        /**< Phone Access Service Index */
204     BTM_EIR_UUID_SERVCLASS_HEADSET_HS,          /**< Headset HS Service Index */
205     BTM_EIR_UUID_SERVCLASS_PNP_INFORMATION,     /**< PNP Information Service Index */
206     BTM_EIR_UUID_SERVCLASS_MESSAGE_ACCESS,      /**< Message Access Service Index */
207     BTM_EIR_UUID_SERVCLASS_MESSAGE_NOTIFICATION,    /**< Message Notification Service Index */
208     BTM_EIR_UUID_SERVCLASS_HDP_SOURCE,          /**<HDP Source Service Index */
209     BTM_EIR_UUID_SERVCLASS_HDP_SINK,            /**< HDP Sink Service Index */
210     BTM_EIR_MAX_SERVICES                        /**< Max Service Index */
211 };
212 
213 /** HCI role definitions */
214 #define HCI_ROLE_CENTRAL 0x00 /**< device role central */
215 #define HCI_ROLE_PERIPHERAL 0x01 /**< device role peripheral */
216 #define HCI_ROLE_UNKNOWN    0xff  /**< device role unknown */
217 typedef uint8_t wiced_bt_dev_role_t; /**< device role for the connection */
218 
219 /***************************
220  *  Device Discovery Types
221  ****************************/
222 /** Class of Device inquiry filter */
223 typedef struct
224 {
225     wiced_bt_dev_class_t            dev_class;          /**< class of device */
226     wiced_bt_dev_class_t            dev_class_mask;     /**< class of device filter mask */
227 } wiced_bt_dev_cod_cond_t;
228 
229 /** Inquiry filter */
230 typedef union
231 {
232     wiced_bt_device_address_t       bdaddr_cond;        /**< bluetooth address filter */
233     wiced_bt_dev_cod_cond_t         cod_cond;           /**< class of device filter */
234 } wiced_bt_dev_inq_filt_cond_t;
235 
236 /** Inquiry Parameters */
237 typedef struct
238 {
239     uint8_t                         mode;               /**< Inquiry mode (see #wiced_bt_inquiry_mode_e) */
240     uint8_t                         duration;           /**< Inquiry duration (1.28 sec increments) */
241     uint8_t                         filter_cond_type;   /**< Inquiry filter type  (see #wiced_bt_dev_filter_cond_e) */
242     wiced_bt_dev_inq_filt_cond_t    filter_cond;        /**< Inquiry filter */
243 } wiced_bt_dev_inq_parms_t;
244 
245 /** Inquiry Results */
246 typedef struct
247 {
248     uint16_t                        clock_offset;                           /**< Clock offset */
249     wiced_bt_device_address_t       remote_bd_addr;                         /**< Device address */
250     wiced_bt_dev_class_t            dev_class;                              /**< Class of device */
251     uint8_t                         page_scan_rep_mode;                     /**< Page scan repetition mode */
252     uint8_t                         page_scan_per_mode;                     /**< Page scan per mode */
253     uint8_t                         page_scan_mode;                         /**< Page scan mode */
254     int8_t                          rssi;                                   /**< Receive signal strength index (#BTM_INQ_RES_IGNORE_RSSI, if not available) */
255     uint32_t                        eir_uuid_mask;          /**< Bit mask of EIR UUIDs */
256     wiced_bool_t                    eir_complete_list;                      /**< TRUE if EIR array is complete */
257 } wiced_bt_dev_inquiry_scan_result_t;
258 
259 /** RSSI Result  (in response to #wiced_bt_dev_read_rssi)  */
260 typedef struct
261 {
262     wiced_result_t                  status;             /**< Status of the operation */
263     uint8_t                         hci_status;         /**< Status from controller (Refer Spec 5.0 Vol 2 Part D Error Codes) */
264     int8_t                          rssi;               /**< RSSI in dB */
265     wiced_bt_device_address_t       rem_bda;            /**< Remote BD address */
266 } wiced_bt_dev_rssi_result_t;
267 
268 /** Structure returned with remote name request */
269 typedef struct
270 {
271     uint16_t                        status;             /**< Status of the operation. BTM_SUCCESS for success otherwise BTM_BAD_VALUE_RET*/
272     wiced_bt_device_address_t       bd_addr;            /**< Remote BD address */
273     uint16_t                        length;             /**< Device name Length */
274     wiced_bt_remote_name_t          remote_bd_name;     /**< Remote device name */
275 }wiced_bt_dev_remote_name_result_t;
276 
277 /** Structure returned with switch role request */
278 typedef struct
279 {
280     uint8_t                         status;             /**< Status of the operation. (Refer Spec 5.0 Vol 2 Part D Error Codes) */
281     wiced_bt_dev_role_t             role;               /**< HCI_ROLE_CENTRAL or HCI_ROLE_PERIPHERAL */
282     wiced_bt_device_address_t       bd_addr;            /**< Remote BD address involved with the switch */
283 } wiced_bt_dev_switch_role_result_t;
284 /** @endcond */
285 
286 /*****************************************************************************
287  *  SECURITY MANAGEMENT
288  *****************************************************************************/
289 
290 /** security flags for current BR/EDR link */
291 enum wiced_bt_sec_flags_e
292 {
293     BTM_SEC_LINK_ENCRYPTED                       = 0x01,                 /**< Link encrypted */
294     BTM_SEC_LINK_PAIRED_WITHOUT_MITM             = 0x02,                 /**< Paired without man-in-the-middle protection */
295     BTM_SEC_LINK_PAIRED_WITH_MITM                = 0x04                  /**< Link with man-in-the-middle protection */
296 };
297 
298 /** Variable Pin Type */
299 #define BTM_PIN_TYPE_VARIABLE       HCI_PIN_TYPE_VARIABLE
300 /** Fix Length Pin Type */
301 #define BTM_PIN_TYPE_FIXED          HCI_PIN_TYPE_FIXED
302 
303 /** Security key data length (used by wiced_bt_device_link_keys_t structure) */
304 #ifndef BTM_SECURITY_KEY_DATA_LEN
305 #define BTM_SECURITY_KEY_DATA_LEN       132
306 #endif
307 
308 /** Local security key data length (used by wiced_bt_local_identity_keys_t structure) */
309 #ifndef BTM_SECURITY_LOCAL_KEY_DATA_LEN
310 #define BTM_SECURITY_LOCAL_KEY_DATA_LEN 65
311 #endif
312 
313 /** Pairing IO Capabilities */
314 enum wiced_bt_dev_io_cap_e {
315     BTM_IO_CAPABILITIES_DISPLAY_ONLY                   = 0,  /**< Display Only        */
316     BTM_IO_CAPABILITIES_DISPLAY_AND_YES_NO_INPUT       = 1,  /**< Display Yes/No      */
317     BTM_IO_CAPABILITIES_KEYBOARD_ONLY                  = 2,  /**< Keyboard Only       */
318     BTM_IO_CAPABILITIES_NONE                           = 3,  /**< No Input, No Output */
319     BTM_IO_CAPABILITIES_BLE_DISPLAY_AND_KEYBOARD_INPUT = 4,  /**< Keyboard display (For BLE SMP) */
320     BTM_IO_CAPABILITIES_MAX                            = 5,  /**< Max value for IO capability */
321 };
322 
323 typedef uint8_t wiced_bt_dev_io_cap_t;          /**< IO capabilities */
324 
325 /** BR/EDR Authentication requirement */
326 enum wiced_bt_dev_auth_req_e {
327     BTM_AUTH_SINGLE_PROFILE_NO = 0,                     /**< MITM Protection Not Required - Single Profile/non-bonding. Numeric comparison with automatic accept allowed */
328     BTM_AUTH_SINGLE_PROFILE_YES = 1,                    /**< MITM Protection Required - Single Profile/non-bonding. Use IO Capabilities to determine authentication procedure */
329     BTM_AUTH_ALL_PROFILES_NO = 2,                       /**< MITM Protection Not Required - All Profiles/dedicated bonding. Numeric comparison with automatic accept allowed */
330     BTM_AUTH_ALL_PROFILES_YES = 3,                      /**< MITM Protection Required - All Profiles/dedicated bonding. Use IO Capabilities to determine authentication procedure */
331     BTM_AUTH_SINGLE_PROFILE_GENERAL_BONDING_NO = 4,     /**< MITM Protection Not Required - Single Profiles/general bonding. Numeric comparison with automatic accept allowed */
332     BTM_AUTH_SINGLE_PROFILE_GENERAL_BONDING_YES = 5,    /**< MITM Protection Required - Single Profiles/general bonding. Use IO Capabilities to determine authentication procedure */
333 };
334 typedef uint8_t wiced_bt_dev_auth_req_t;                /**< BR/EDR authentication requirement (see #wiced_bt_dev_auth_req_e) */
335 
336 /** LE Authentication requirement */
337 enum wiced_bt_dev_le_auth_req_e {
338     BTM_LE_AUTH_REQ_NO_BOND =       0x00,                                               /**< Not required - No Bond */
339     BTM_LE_AUTH_REQ_BOND =          0x01,                                               /**< Required - General Bond */
340     BTM_LE_AUTH_REQ_MITM =          0x04,                                               /**< MITM required - Auth Y/N */
341     BTM_LE_AUTH_REQ_SC =            0x08,                                               /**< LE Secure Connection or legacy, no MITM, no Bonding */
342     BTM_LE_AUTH_REQ_KP =            0x10,                                               /**< Keypress supported Y/N */
343     BTM_LE_AUTH_REQ_H7 =            0x20,                                               /**< Key derivation function H7 supported Y/N */
344     BTM_LE_AUTH_REQ_SC_BOND =       (BTM_LE_AUTH_REQ_SC|BTM_LE_AUTH_REQ_BOND),          /**< LE Secure Connection or legacy, no MITM, Bonding */
345     BTM_LE_AUTH_REQ_SC_MITM =       (BTM_LE_AUTH_REQ_SC|BTM_LE_AUTH_REQ_MITM),          /**< LE Secure Connection or legacy, MITM, no Bonding */
346     BTM_LE_AUTH_REQ_SC_MITM_BOND =  (BTM_LE_AUTH_REQ_SC|BTM_LE_AUTH_REQ_MITM|BTM_LE_AUTH_REQ_BOND),    /**< LE Secure Connection or legacy , MITM, Bonding */
347     BTM_LE_AUTH_REQ_MASK =          0x3D                                                /**< Auth Request Mask */
348 };
349 typedef uint8_t wiced_bt_dev_le_auth_req_t;             /**< BLE authentication requirement (see #wiced_bt_dev_le_auth_req_e) */
350 
351 /** LE Security key level */
352 #define SMP_SEC_NONE                 0            /**< Security Key Level: None */
353 #define SMP_SEC_UNAUTHENTICATE      (1 << 0)      /**< Security Key Level: key not authenticated */
354 #define SMP_SEC_AUTHENTICATED       (1 << 2)      /**< Security Key Level: key authenticated */
355 typedef uint8_t wiced_bt_smp_sec_level_t;    /**< LE Security key level */
356 
357 /** Public key */
358 typedef struct
359 {
360     BT_OCTET32  x;              /**< X cordinate value */
361     BT_OCTET32  y;              /**< Y cordinate value */
362 } wiced_bt_public_key_t;
363 
364  /** OOB Data status */
365 #ifndef BTM_OOB_STATE
366 #define BTM_OOB_STATE
367 /** OOB Data status */
368 enum wiced_bt_dev_oob_data_e
369 {
370     BTM_OOB_NONE,                                       /**< No OOB data */
371     BTM_OOB_PRESENT_192,                                /**< OOB data present (from the P-192 public key) */
372     BTM_OOB_PRESENT_256,                                /**< OOB data present (from the P-256 public key) */
373     BTM_OOB_PRESENT_192_256,                            /**< OOB data present (from the P-192 and P-256 public keys) */
374     BTM_OOB_UNKNOWN                                     /**< OOB data unknown */
375 };
376 #endif
377 typedef uint8_t wiced_bt_dev_oob_data_t;                /**< OOB data (see #wiced_bt_dev_oob_data_e) */
378 
379 /** Data for BTM_SMP_SC_LOCAL_OOB_DATA_NOTIFICATION_EVT */
380 typedef struct
381 {
382     wiced_bool_t                present;                /**< TRUE if local oob is present */
383     BT_OCTET16                  randomizer;             /**< randomizer */
384     BT_OCTET16                  commitment;             /**< commitment */
385 
386     wiced_bt_ble_address_t      addr_sent_to;           /**< peer address sent to */
387     BT_OCTET32                  private_key_used;       /**< private key */
388     wiced_bt_public_key_t       public_key_used;        /**< public key */
389 } wiced_bt_smp_sc_local_oob_t;
390 
391 /** @cond DUAL_MODE */
392 
393 /** Data type for IO capabalities response (BTM_PAIRING_IO_CAPABILITIES_BR_EDR_RESPONSE_EVT) */
394 typedef struct
395 {
396     wiced_bt_device_address_t   bd_addr;                /**< Peer address */
397     wiced_bt_dev_io_cap_t       io_cap;                 /**< Peer IO capabilities */
398     wiced_bt_dev_oob_data_t     oob_data;               /**< OOB data present at peer device for the local device */
399     wiced_bt_dev_auth_req_t     auth_req;               /**< Authentication required for peer device */
400 } wiced_bt_dev_bredr_io_caps_rsp_t;
401 
402 /** Pairing user passkey request  (BTM_USER_PASSKEY_REQUEST_EVT event data type) */
403 typedef struct
404 {
405     wiced_bt_device_address_t   bd_addr;            /**< peer address       */
406 } wiced_bt_dev_user_key_req_t;
407 
408 /** Pairing keypress types */
409 enum wiced_bt_dev_passkey_entry_type_e
410 {
411     BTM_PASSKEY_ENTRY_STARTED,          /**< passkey entry started */
412     BTM_PASSKEY_DIGIT_ENTERED,          /**< passkey digit entered */
413     BTM_PASSKEY_DIGIT_ERASED,           /**< passkey digit erased */
414     BTM_PASSKEY_DIGIT_CLEARED,          /**< passkey cleared */
415     BTM_PASSKEY_ENTRY_COMPLETED         /**< passkey entry completed */
416 };
417 typedef uint8_t wiced_bt_dev_passkey_entry_type_t;  /**< Bluetooth pairing keypress value (see #wiced_bt_dev_passkey_entry_type_e)  */
418 
419 /** Data associated with the information received from the peer via OOB interface */
420 typedef struct
421 {
422     wiced_bool_t                present;                /**< TRUE if local oob is present */
423     BT_OCTET16                  randomizer;             /**< randomizer */
424     BT_OCTET16                  commitment;             /**< commitment */
425     wiced_bt_ble_address_t      addr_received_from;     /**< peer address */
426 } wiced_bt_smp_sc_peer_oob_data_t;
427 
428 /** Data for wiced_bt_smp_sc_oob_reply */
429 typedef struct
430 {
431     wiced_bt_smp_sc_local_oob_t     local_oob_data;     /**< My OOB  sent to peer out of band */
432     wiced_bt_smp_sc_peer_oob_data_t peer_oob_data;      /**< Peer OOB received out of band */
433 }wiced_bt_smp_sc_oob_data_t;
434 
435 /** SCO link type */
436 #define BTM_LINK_TYPE_SCO           HCI_LINK_TYPE_SCO       /**< Link type SCO */
437 #define BTM_LINK_TYPE_ESCO          HCI_LINK_TYPE_ESCO      /**< Link type eSCO */
438 /** SCO link type */
439 typedef uint8_t wiced_bt_sco_type_t;
440 
441 /** SCO connected event related data */
442 typedef struct {
443     uint16_t    sco_index;                  /**< SCO index */
444 } wiced_bt_sco_connected_t;
445 
446 /** SCO disconnected event related data */
447 typedef struct {
448     uint16_t    sco_index;                  /**< SCO index */
449 } wiced_bt_sco_disconnected_t;
450 
451 /**  SCO connect request event related data */
452 typedef struct {
453     uint16_t                    sco_index;      /**< SCO index */
454     wiced_bt_device_address_t   bd_addr;        /**< Peer bd address */
455     wiced_bt_dev_class_t        dev_class;      /**< Peer device class */
456     wiced_bt_sco_type_t         link_type;      /**< SCO link type */
457 } wiced_bt_sco_connection_request_t;
458 
459 /** SCO connection change event related data */
460 typedef struct {
461     uint16_t                    sco_index;          /**< SCO index */
462     uint16_t                    rx_pkt_len;         /**< RX packet length */
463     uint16_t                    tx_pkt_len;         /**< TX packet length */
464     wiced_bt_device_address_t   bd_addr;            /**< Peer bd address */
465     uint8_t                     hci_status;         /**< HCI status */
466     uint8_t                     tx_interval;        /**< TX interval */
467     uint8_t                     retrans_windows;    /**< Retransmission windows */
468 } wiced_bt_sco_connection_change_t;
469 
470 /** @endcond */
471 
472 /** Type of OOB data required  */
473 #ifndef BTM_OOB_REQ_TYPE
474 #define BTM_OOB_REQ_TYPE
475 /** Type of OOB data required  */
476 enum wiced_bt_dev_oob_data_req_type_e
477 {
478     BTM_OOB_INVALID_TYPE,                               /**< Invalid OOB Type */
479     BTM_OOB_PEER,                                       /**< Peer OOB data requested */
480     BTM_OOB_LOCAL,                                      /**< Local OOB data requested */
481     BTM_OOB_BOTH                                        /**< Both local and peer OOB data requested */
482 };
483 #endif
484 typedef uint8_t wiced_bt_dev_oob_data_req_type_t;         /**< OOB data type requested (see #wiced_bt_dev_oob_data_req_type_t) */
485 
486 
487 /** data type for BTM_SMP_REMOTE_OOB_DATA_REQUEST_EVT */
488 typedef struct
489 {
490     wiced_bt_device_address_t           bd_addr;        /**< peer address */
491 } wiced_bt_smp_remote_oob_req_t;
492 
493 /** data type for BTM_SMP_SC_REMOTE_OOB_DATA_REQUEST_EVT */
494 typedef struct
495 {
496     wiced_bt_device_address_t           bd_addr;        /**< peer address */
497     wiced_bt_dev_oob_data_req_type_t    oob_type;       /**< requested oob data types (BTM_OOB_PEER, BTM_OOB_LOCAL, or BTM_OOB_BOTH) */
498 } wiced_bt_smp_sc_remote_oob_req_t;
499 
500 /** Pairing keypress notification (BTM_USER_KEYPRESS_NOTIFICATION_EVT event data type) */
501 typedef struct
502 {
503     wiced_bt_device_address_t           bd_addr;        /**< peer address       */
504     wiced_bt_dev_passkey_entry_type_t   keypress_type;  /**< type of keypress   */
505 } wiced_bt_dev_user_keypress_t;
506 
507 /** Data for pairing passkey notification (BTM_USER_PASSKEY_NOTIFICATION_EVT event data type) */
508 typedef struct
509 {
510     wiced_bt_device_address_t   bd_addr;            /**< peer address       */
511     uint32_t                    passkey;            /**< passkey            */
512 } wiced_bt_dev_user_key_notif_t;
513 
514 
515 /** BR/EDR pairing complete infomation */
516 typedef struct
517 {
518     uint8_t         status;                 /**< status of the simple pairing process (see defintions for HCI status codes) */
519 } wiced_bt_dev_br_edr_pairing_info_t;
520 
521 /** Data for pairing confirmation request (BTM_USER_CONFIRMATION_REQUEST_EVT event data type) */
522 typedef struct
523 {
524     wiced_bt_device_address_t   bd_addr;                            /**< peer address */
525     uint32_t                    numeric_value;                      /**< numeric value for comparison (if "just_works", do not show this number to UI) */
526     wiced_bool_t                just_works;                         /**< TRUE, if using "just works" association model */
527     wiced_bt_dev_auth_req_t     local_authentication_requirements;  /**< Authentication requirement for local device */
528     wiced_bt_dev_auth_req_t     remote_authentication_requirements; /**< Authentication requirement for peer device */
529 } wiced_bt_dev_user_cfm_req_t;
530 
531 /** BLE pairing complete infomation */
532 typedef struct
533 {
534     wiced_result_t                    status;                 /**< status of the simple pairing process   */
535     uint8_t                           reason;                 /**< failure reason (see #wiced_bt_smp_status_t) */
536     wiced_bt_smp_sec_level_t          sec_level;              /**< 0 - None, 1- Unauthenticated Key, 4-Authenticated Key  */
537     wiced_bool_t                      is_pair_cancel;         /**< True if cancelled, else False   */
538     wiced_bt_device_address_t         resolved_bd_addr;       /**< Resolved address (if remote device using private address) */
539     wiced_bt_ble_address_type_t       resolved_bd_addr_type;  /**< Resolved addr type of bonded device */
540 } wiced_bt_dev_ble_pairing_info_t;
541 
542 
543 /** Transport dependent pairing complete infomation */
544 typedef union
545 {
546     wiced_bt_dev_br_edr_pairing_info_t  br_edr;         /**< BR/EDR pairing complete infomation */
547     wiced_bt_dev_ble_pairing_info_t     ble;            /**< BLE pairing complete infomation */
548 } wiced_bt_dev_pairing_info_t;
549 
550 /** Pairing complete notification (BTM_PAIRING_COMPLETE_EVT event data type) */
551 typedef struct
552 {
553     uint8_t                     *bd_addr;               /**< peer address           */
554     wiced_bt_transport_t        transport;              /**< BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE */
555     wiced_bt_dev_pairing_info_t pairing_complete_info;  /**< Transport dependent pairing complete infomation */
556 } wiced_bt_dev_pairing_cplt_t;
557 
558 /** Security/authentication failure status  (used by BTM_SECURITY_FAILED_EVT notication) */
559 typedef struct
560 {
561     wiced_bt_device_address_t   bd_addr;                /**< [in]  Peer address */
562     wiced_result_t              status;                 /**< Status of the operation */
563     uint8_t                     hci_status;             /**< Status from controller */
564 } wiced_bt_dev_security_failed_t;
565 
566 /** Security request (BTM_SECURITY_REQUEST_EVT event data type) */
567 typedef struct
568 {
569     wiced_bt_device_address_t      bd_addr;             /**< peer address           */
570 } wiced_bt_dev_security_request_t;
571 
572 /** LE Key type */
573 #ifndef BTM_LE_KEY_TYPES
574 #define BTM_LE_KEY_TYPES
575 /** LE Key type */
576 enum wiced_bt_dev_le_key_type_e
577 {
578     BTM_LE_KEY_PENC =   (1 << 0),                       /**< encryption information of peer device */
579     BTM_LE_KEY_PID =    (1 << 1),                       /**< identity key of the peer device */
580     BTM_LE_KEY_PCSRK =  (1 << 2),                       /**< peer SRK */
581     BTM_LE_KEY_PLK =    (1 << 3),                       /**< peer link key */
582     BTM_LE_KEY_LENC =   (1 << 4),                       /**< Central role security information:div */
583     BTM_LE_KEY_LID =    (1 << 5),                       /**< Central device ID key */
584     BTM_LE_KEY_LCSRK =  (1 << 6),                       /**< local CSRK has been deliver to peer */
585     BTM_LE_KEY_LLK =    (1 << 7),                       /**< Local link key */
586 };
587 #endif  /* BTM_LE_KEY_TYPES */
588 typedef uint8_t wiced_bt_dev_le_key_type_t;             /**< LE key type (see #wiced_bt_dev_le_key_type_e) */
589 
590 /** Scan duty cycle (used for BTM_BLE_SCAN_STATE_CHANGED_EVT and wiced_bt_dev_create_connection) */
591 #ifndef BTM_BLE_SCAN_TYPE
592 #define BTM_BLE_SCAN_TYPE
593 /** Scan duty cycle (used for BTM_BLE_SCAN_STATE_CHANGED_EVT and wiced_bt_dev_create_connection) */
594 enum wiced_bt_ble_scan_type_e
595 {
596     BTM_BLE_SCAN_TYPE_NONE,                 /**< Stop scanning */
597     BTM_BLE_SCAN_TYPE_HIGH_DUTY,            /**< General inquiry high duty cycle scan */
598     BTM_BLE_SCAN_TYPE_LOW_DUTY,             /**< General inquiry low duty cycle scan */
599     BTM_BLE_SCAN_TYPE_LIMITED_HIGH_DUTY,    /**< Limited inquiry high duty cycle scan */
600     BTM_BLE_SCAN_TYPE_LIMITED_LOW_DUTY      /**< Limited inquiry low duty cycle scan */
601 };
602 #endif
603 typedef uint8_t wiced_bt_ble_scan_type_t;   /**< scan type (see #wiced_bt_ble_scan_type_e) */
604 
605 
606 /** SMP Pairing status codes */
607 enum wiced_bt_smp_status_e
608 {
609     SMP_SUCCESS                 = 0,                    /**< Success */
610     SMP_PASSKEY_ENTRY_FAIL      = 0x01,                 /**< Passkey entry failed */
611     SMP_OOB_FAIL                = 0x02,                 /**< OOB failed */
612     SMP_PAIR_AUTH_FAIL          = 0x03,                 /**< Authentication failed */
613     SMP_CONFIRM_VALUE_ERR       = 0x04,                 /**< Value confirmation failed */
614     SMP_PAIR_NOT_SUPPORT        = 0x05,                 /**< Not supported */
615     SMP_ENC_KEY_SIZE            = 0x06,                 /**< Encryption key size failure */
616     SMP_INVALID_CMD             = 0x07,                 /**< Invalid command */
617     SMP_PAIR_FAIL_UNKNOWN       = 0x08,                 /**< Unknown failure */
618     SMP_REPEATED_ATTEMPTS       = 0x09,                 /**< Repeated attempts */
619     SMP_INVALID_PARAMETERS      = 0x0A,                 /**< Invalid parameters  */
620     SMP_DHKEY_CHK_FAIL          = 0x0B,                 /**< DH Key check failed */
621     SMP_NUMERIC_COMPAR_FAIL     = 0x0C,                 /**< Numeric comparison failed */
622     SMP_BR_PAIRING_IN_PROGR     = 0x0D,                 /**< BR paIring in progress */
623     SMP_XTRANS_DERIVE_NOT_ALLOW = 0x0E,                 /**< Cross transport key derivation not allowed */
624     SMP_MAX_FAIL_RSN_PER_SPEC   = SMP_XTRANS_DERIVE_NOT_ALLOW, /**< SMP Max Fail Reason as per spec */
625 
626     /* bte smp status codes */
627     SMP_PAIR_INTERNAL_ERR       = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x01), /**< Internal error */
628     SMP_UNKNOWN_IO_CAP          = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x02), /**< unknown IO capability, unable to decide associatino model */
629     SMP_INIT_FAIL               = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x03), /**< Initialization failed */
630     SMP_CONFIRM_FAIL            = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x04), /**< Confirmation failed */
631     SMP_BUSY                    = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x05), /**< Busy */
632     SMP_ENC_FAIL                = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x06), /**< Encryption failed */
633     SMP_STARTED                 = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x07), /**< Started */
634     SMP_RSP_TIMEOUT             = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x08), /**< Response timeout */
635     SMP_FAIL                    = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x09), /**< Generic failure */
636     SMP_CONN_TOUT               = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x0A), /**< Connection timeout */
637 };
638 /** SMP Pairing status (see #wiced_bt_smp_status_e) */
639 typedef uint8_t wiced_bt_smp_status_t;
640 
641 /** LE keys */
642 typedef struct
643 {
644     BT_OCTET16       ir;   /**< IR Key */
645     BT_OCTET16       irk;  /**< IRK Key  */
646     BT_OCTET16       dhk;  /**< DHK Key */
647 }wiced_bt_local_id_keys;
648 
649 
650 /** LE identity key for local device (used by BTM_LE_LOCAL_IDENTITY_KEYS_UPDATE_EVT and BTM_LE_LOCAL_KEYS_REQUEST_EVT notification) */
651 typedef struct {
652     uint8_t            key_type_mask;  /**< The type of the key (BTM_BLE_KEY_TYPE_ID or BTM_BLE_KEY_TYPE_ER) */
653     wiced_bt_local_id_keys id_keys;  /**< Local ID Keys    */
654     BT_OCTET16       er;             /**< BLE encryption key  */
655 } wiced_bt_local_identity_keys_t;
656 
657 /* Key types that may be set in the key_type_mask field */
658 #define BTM_BLE_KEY_TYPE_ID         1       /**< Identity resolving key */
659 #define BTM_BLE_KEY_TYPE_ER         2       /**< Encryption root key    */
660 
661 
662 
663 /** BLE connection parameter update event related data */
664 typedef struct
665 {
666     uint8_t                     status;             /**< connection parameters update status */
667     wiced_bt_device_address_t   bd_addr;            /**< peer bd address */
668     uint16_t                    conn_interval;      /**< updated connection interval ( in 0.625msec ) */
669     uint16_t                    conn_latency;       /**< updated connection latency */
670     uint16_t                    supervision_timeout;/**< updated supervision timeout */
671 } wiced_bt_ble_connection_param_update_t;
672 
673 /** BLE Physical link update event related data */
674 typedef struct
675 {
676     uint8_t                      status;      /**< LE Phy update status */
677     wiced_bt_device_address_t    bd_address;  /**< peer BD address*/
678     uint8_t                      tx_phy;      /**< Transmitter PHY, values: 1=1M, 2=2M, 3=LE coded */
679     uint8_t                      rx_phy;      /**< Receiver PHY, values: 1=1M, 2=2M, 3=LE coded */
680 } wiced_bt_ble_phy_update_t;
681 
682 /** BLE data length update event related data */
683 typedef struct
684 {
685     wiced_bt_device_address_t bd_address; /**< peer BD address*/
686     uint16_t max_tx_octets; /**< Max number of bytes to be sent in an LLData PDU */
687     uint16_t max_tx_time;   /**< Max time that the local controller will take to send a LL packet in a LLData PDU */
688     uint16_t max_rx_octets; /**< Max number of bytes to be received in an LLData PDU */
689     uint16_t max_rx_time;   /**< Max time that the local controller expects to receive a LL packet in a LLData PDU */
690 } wiced_bt_ble_phy_data_length_update_t;
691 
692 /** BLE Multi adv opcodes returned */
693 typedef enum
694 {
695     SET_ADVT_PARAM_MULTI     = 1,            /**< Opcode as a result of calling wiced_set_multi_advertisement_params*/
696     SET_ADVT_DATA_MULTI      = 2,            /**< Opcode as a result of calling wiced_set_multi_advertisement_data*/
697     SET_SCAN_RESP_DATA_MULTI = 3,            /**< Opcode as a result of calling wiced_set_multi_advertisement_scan_response_data*/
698     SET_RANDOM_ADDR_MULTI    = 4,            /**< Opcode as a result of calling wiced_set_multi_advertisements_random_address*/
699     SET_ADVT_ENABLE_MULTI    = 5             /**< Opcode as a result of calling wiced_start_multi_advertisements*/
700 } wiced_bt_multi_adv_opcodes_t;
701 
702 /** BLE Multi adv VSC response data */
703 typedef struct
704 {
705     wiced_bt_multi_adv_opcodes_t    opcode;      /**< Multi adv vendor specifiv opcode */
706     uint8_t                         status;      /**< status of the operation received from controller, 0 - Success. Check the HCI error codes Vol 1, Part F, Table 1.1 Error codes */
707 } wiced_bt_ble_multi_adv_response_t;
708 
709 /** Power Management status codes */
710 #ifndef BTM_PM_STATUS_CODES
711 #define BTM_PM_STATUS_CODES
712 /** Power Management status */
713 enum wiced_bt_dev_power_mgmt_status_e
714 {
715     BTM_PM_STS_ACTIVE = HCI_MODE_ACTIVE,    /**< Active */
716     BTM_PM_STS_HOLD   = HCI_MODE_HOLD,      /**< Hold */
717     BTM_PM_STS_SNIFF  = HCI_MODE_SNIFF,     /**< Sniff */
718     BTM_PM_STS_PARK   = HCI_MODE_PARK,      /**< Park */
719     BTM_PM_STS_SSR,                         /**< Sniff subrating notification */
720     BTM_PM_STS_PENDING,                     /**< Pending (waiting for status from controller) */
721     BTM_PM_STS_ERROR                        /**< Error (controller returned error) */
722 };
723 #endif
724 
725 /** Power Management state */
726 #define WICED_POWER_STATE_ACTIVE                BTM_PM_STS_ACTIVE       /**< Active */
727 #define WICED_POWER_STATE_SNIFF                 BTM_PM_STS_SNIFF        /**< Sniff */
728 #define WICED_POWER_STATE_SSR                   BTM_PM_STS_SSR          /**< Sniff subrating notification */
729 #define WICED_POWER_STATE_PENDING               BTM_PM_STS_PENDING      /**< Pending (waiting for status from controller) */
730 #define WICED_POWER_STATE_ERROR                 BTM_PM_STS_ERROR        /**< Error (controller returned error) */
731 
732 typedef uint8_t wiced_bt_dev_power_mgmt_status_t;   /**< Power management status (see #wiced_bt_dev_power_mgmt_status_e) */
733 
734 /*BR channel map*/
735 #define BTM_AFH_CHNL_MAP_SIZE    HCI_AFH_CHANNEL_MAP_LEN        /**< Channel Map Length */
736 
737 typedef uint8_t wiced_bt_br_chnl_map_t[BTM_AFH_CHNL_MAP_SIZE];  /**< Array of Channel Map Length */
738 
739 /** Bluetooth Management event */
740 #ifndef BTM_MANAGEMENT_EVT
741 #define BTM_MANAGEMENT_EVT
742 /** Bluetooth Management events used in #wiced_bt_management_cback_t.
743   * @note Some of the events are BR/EDR events which are available only in dual mode (BR/EDR+BLE) operation
744   * @note Return values of the management events
745   * Return values of notification and status events are typically not checked, unless explicitly mentioned.
746   * Return values of events requesting information from app should be WICED_BT_ERROR for cases where the app
747   * does not handle the events. For the request events which are handled by the app, indicate WICED_BT_SUCCESS
748   * as per the specific requirements of the event as documented below.
749   *
750   */
751 enum wiced_bt_management_evt_e {
752     /* Bluetooth status events */
753     /**
754      * Event notifies Bluetooth controller and host stack is enabled.
755      * Event data: \ref wiced_bt_management_evt_data_t.enabled
756      * Indicates the stack is up. Application can now start calling bluetooth wiced bt APIs
757      */
758     BTM_ENABLED_EVT,                    /*0, 0x0 */
759 
760     /**
761      * Event notifies Bluetooth controller and host stack disabled.
762      * Event data: NULL
763      */
764     BTM_DISABLED_EVT,                   /* 1, 0x1 */
765 
766     /**
767      * Event notifies Power management status change.
768      * Event data: \ref wiced_bt_management_evt_data_t.power_mgmt_notification
769      */
770     BTM_POWER_MANAGEMENT_STATUS_EVT,    /* 2, 0x2 */
771 
772     /**
773      * Event notifies Bluetooth controller and host stack re-enabled.
774      * Event data: \ref wiced_bt_management_evt_data_t.enabled
775      * @note : Not used
776      */
777     BTM_RE_START_EVT,                   /* 3, 0x3 */
778 
779     /* Security events */
780     /**
781      * Event requests app for the PIN to be used for pairing (legacy pairing only).
782      * Event data: \ref wiced_bt_management_evt_data_t.pin_request
783      */
784     BTM_PIN_REQUEST_EVT,                /* 4, 0x4 */
785 
786     /**
787      * Event requests user confirmation for the numeric value to continue the
788      * App is expected to respond with using #wiced_bt_dev_confirm_req_reply typically
789      * by confirming via a display to the user
790      * Event data: \ref wiced_bt_management_evt_data_t.user_confirmation_request
791      */
792     BTM_USER_CONFIRMATION_REQUEST_EVT,  /* 5, 0x5 */
793 
794     /**
795      * Event notifies user passkey app
796      * App is expected to display the passkey to the user
797      * Event data: \ref wiced_bt_management_evt_data_t.user_passkey_notification
798      */
799     BTM_PASSKEY_NOTIFICATION_EVT,       /* 6, 0x6 */
800 
801     /**
802      * Event requests user passkey from app
803      * @cond DUAL_MODE (respond using #wiced_bt_dev_pass_key_req_reply).@endcond
804      * Application is expected to respond with the passkey for pairing
805      * with #wiced_bt_dev_pass_key_req_reply
806      * Event data: \ref wiced_bt_management_evt_data_t.user_passkey_request
807      */
808     BTM_PASSKEY_REQUEST_EVT,            /* 7, 0x7 */
809 
810     /**
811      * Event notifies keypress notification event to app
812      * Event data: \ref wiced_bt_management_evt_data_t.user_keypress_notification
813      */
814     BTM_KEYPRESS_NOTIFICATION_EVT,      /* 8, 0x8 */
815 
816     /**
817      * Event requests BR/EDR IO capabilities for BR/EDR pairing from app
818      * Event data: \ref wiced_bt_management_evt_data_t.pairing_io_capabilities_br_edr_request
819      * App is expected to fill in it's BR/EDR IO capabilities into the incoming
820      * \ref wiced_bt_management_evt_data_t.pairing_io_capabilities_br_edr_request structure member
821      * @note  BR/EDR Only
822      */
823     BTM_PAIRING_IO_CAPABILITIES_BR_EDR_REQUEST_EVT, /* 9, 0x9 */
824 
825     /**
826      * Event notifies received IO capabilities response for BR/EDR pairing.
827      * Event data: \ref wiced_bt_management_evt_data_t.pairing_io_capabilities_br_edr_response
828      * @note  BR/EDR Only
829      */
830     BTM_PAIRING_IO_CAPABILITIES_BR_EDR_RESPONSE_EVT,/* 10, 0xA */
831 
832     /**
833      * Event requests BLE IO capabilities for BLE pairing from app.
834      * Peripheral can check peer io capabilities in event data before updating with local io capabilities.
835      * Event data: \ref wiced_bt_management_evt_data_t.pairing_io_capabilities_ble_request
836      */
837     BTM_PAIRING_IO_CAPABILITIES_BLE_REQUEST_EVT,    /* 11, 0xB */
838 
839     /**
840      * Event notifies simple pairing complete to app
841      * Event data: \ref wiced_bt_management_evt_data_t.pairing_complete
842      */
843     BTM_PAIRING_COMPLETE_EVT,                       /* 12, 0xC */
844 
845     /**
846      * Event notifies encryption status change to app
847      * Event data: \ref wiced_bt_management_evt_data_t.encryption_status
848      */
849     BTM_ENCRYPTION_STATUS_EVT,                      /* 13, 0xD */
850 
851     /**
852      * Event requests app to allow stack to continue Security procedures/pairing to continue with
853      * the peer. App needs to respond with #wiced_bt_ble_security_grant
854      * App is expected to either allow or deny the incoming pairing request based on it's state
855      * Event data: \ref wiced_bt_management_evt_data_t.security_request
856      */
857     BTM_SECURITY_REQUEST_EVT,                       /* 14, 0xE */
858 
859     /**
860      * Event notifies Security procedure/authentication failed to app
861      * Event data:  \ref wiced_bt_management_evt_data_t.security_failed
862      */
863     BTM_SECURITY_FAILED_EVT,                        /* 15, 0xF */
864 
865     /**
866      * Event notifies security procedure aborted locally, or unexpected link drop.
867      * Event data: \ref wiced_bt_management_evt_data_t.security_aborted
868      */
869     BTM_SECURITY_ABORTED_EVT,                       /* 16, 0x10 */
870 
871     /**
872      * Event notifies result of reading local OOB data from the controller
873      * Event data: \ref wiced_bt_management_evt_data_t.read_local_oob_data_complete
874      * @note  BR/EDR Only
875      */
876     BTM_READ_LOCAL_OOB_DATA_COMPLETE_EVT,           /* 17, 0x11 */
877 
878     /**
879      * Event requests OOB data of the remote device from app
880      * Event data: \ref wiced_bt_management_evt_data_t.remote_oob_data_request
881      * @note  BR/EDR Only
882      */
883     BTM_REMOTE_OOB_DATA_REQUEST_EVT,                /* 18, 0x12 */
884 
885     /**
886      * Event notifies app with the updated remote device link keys in this event.
887      * App is expected to store device_link_keys to  NV memory.
888      * This is the place to verify that the correct link key has been generated.
889      * Event data: \ref wiced_bt_management_evt_data_t.paired_device_link_keys_update
890      */
891     BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT,         /* 19, 0x13 */
892 
893     /**
894      * Event requests for stored remote device link keys from app (restore device_link_keys from NV memory).
895      * If available then fill the stored keys into \p wiced_bt_management_evt_data_t.paired_device_link_keys_request
896      * and return WICED_BT_SUCCESS else WICED_BT_ERROR
897      * Event data: \ref wiced_bt_management_evt_data_t.paired_device_link_keys_request
898      */
899     BTM_PAIRED_DEVICE_LINK_KEYS_REQUEST_EVT,        /* 20, 0x14 */
900 
901     /**
902      * Event notifies updated local identity key to the app (stored local_identity_keys NV memory).
903      * App is expected to store the identity key to  NV memory.
904      * Event data: \ref wiced_bt_management_evt_data_t.local_identity_keys_update
905      */
906     BTM_LOCAL_IDENTITY_KEYS_UPDATE_EVT,             /* 21, 0x15 */
907 
908     /**
909      * Event requests local identity key from app (get local_identity_keys from NV memory).
910      * If available then fill the local key into \p wiced_bt_management_evt_data_t.local_identity_keys_request
911      * and return WICED_BT_SUCCESS else WICED_BT_ERROR.
912      * Event data: \ref wiced_bt_management_evt_data_t.local_identity_keys_request
913      */
914     BTM_LOCAL_IDENTITY_KEYS_REQUEST_EVT,            /* 22, 0x16 */
915 
916     /**
917      * Event notifies BLE scan state change to app
918      * Event data: \ref wiced_bt_management_evt_data_t.ble_scan_state_changed
919      */
920     BTM_BLE_SCAN_STATE_CHANGED_EVT,                 /* 23, 0x17 */
921 
922     /**
923      * Event notifies BLE advertisement state change to app
924      * Event data: \ref wiced_bt_management_evt_data_t.ble_advert_state_changed
925      */
926     BTM_BLE_ADVERT_STATE_CHANGED_EVT,               /* 24, 0x18 */
927 
928     /* BLE Secure Connection events */
929     /**
930      * Event requests SMP remote oob data. Reply using wiced_bt_smp_oob_data_reply.
931      * Event data: \ref wiced_bt_management_evt_data_t.smp_remote_oob_data_request
932      */
933     BTM_SMP_REMOTE_OOB_DATA_REQUEST_EVT,            /* 25, 0x19 */
934 
935     /**
936      * Event requests LE secure connection remote oob data request. Reply using wiced_bt_smp_sc_oob_reply.
937      * Event data: \ref wiced_bt_management_evt_data_t.smp_sc_remote_oob_data_request
938      */
939     BTM_SMP_SC_REMOTE_OOB_DATA_REQUEST_EVT,         /* 26, 0x1A */
940 
941     /**
942      * Event notifies LE secure connection local OOB data (wiced_bt_smp_create_local_sc_oob_data) returned by the stack
943      * The app is expected to copy the data into it's memory and share out of band with the peer
944      * To build the data to be shared, app can use #wiced_bt_dev_build_oob_data
945      * Event data: \ref wiced_bt_management_evt_data_t.p_smp_sc_local_oob_data
946      */
947     BTM_SMP_SC_LOCAL_OOB_DATA_NOTIFICATION_EVT,     /* 27, 0x1B */
948 
949     /**
950      * Event notfies SCO connected to app
951      * Event data: \ref wiced_bt_management_evt_data_t.sco_connected
952      * @note  BR/EDR Only
953      */
954     BTM_SCO_CONNECTED_EVT,                          /* 28, 0x1C */
955 
956     /**
957      * Event notifies SCO disconnected event to app
958      * Event data: \ref wiced_bt_management_evt_data_t.sco_disconnected
959      * @note  BR/EDR Only
960      */
961     BTM_SCO_DISCONNECTED_EVT,                       /* 29, 0x1D */
962 
963     /**
964      * Event notifies SCO connection request to app
965      * App is expected to reply with @cond DUAL_MODE #wiced_bt_sco_accept_connection @endcond
966      * Event data: \ref wiced_bt_management_evt_data_t.sco_connection_request
967      * @note  BR/EDR Only
968      */
969     BTM_SCO_CONNECTION_REQUEST_EVT,                 /* 30, 0x1E */
970 
971     /**
972      * Event notifies SCO connection change to app
973      * Event data: \ref wiced_bt_management_evt_data_t.sco_connection_change
974      * @note  BR/EDR Only
975      */
976     BTM_SCO_CONNECTION_CHANGE_EVT,                  /* 31, 0x1F */
977 
978 
979     /**
980      * Event notifies BLE connection parameter update to app
981      * Event data: \ref wiced_bt_management_evt_data_t.ble_connection_param_update
982      */
983     BTM_BLE_CONNECTION_PARAM_UPDATE,                /* 32, 0x20 */
984 
985     /**
986      * Event notifies BLE Physical link update to app
987      * Event data: \ref wiced_bt_management_evt_data_t.ble_phy_update_event
988      */
989     BTM_BLE_PHY_UPDATE_EVT,                         /* 33, 0x21 */
990 
991     /**
992      * Event notifies BT device wake has been deasserted. Used for Host Stack Use Case.
993      */
994     BTM_LPM_STATE_LOW_POWER,                        /* 34, 0x22 */
995 
996     /**
997      * Event notifies Multi adv command status event used for the status of the command sent
998      * Event data: \ref wiced_bt_management_evt_data_t.ble_multi_adv_response_event
999      */
1000     BTM_MULTI_ADVERT_RESP_EVENT,                    /* 35, 0x23 */
1001 
1002     /**
1003      * Event to notify change in the data length and timeout configured for Rx and Tx on the
1004      * BLE link
1005      * Event data: \ref wiced_bt_management_evt_data_t.ble_data_length_update_event
1006      */
1007     BTM_BLE_DATA_LENGTH_UPDATE_EVENT,               /* 36, 0x24 */
1008 
1009 #if SMP_CATB_CONFORMANCE_TESTER == TRUE
1010     /**
1011      * The Secure Connections support information of the peer device.
1012      */
1013     BTM_SMP_SC_PEER_INFO_EVT                        /* 37, 0x25 */
1014 #endif
1015 
1016 };
1017 #endif
1018 typedef uint8_t wiced_bt_management_evt_t;          /**< Bluetooth management events (see #wiced_bt_management_evt_e) */
1019 
1020 /** Device enabled (used by BTM_ENABLED_EVT) */
1021 typedef struct {
1022     wiced_result_t          status;                     /**< Status */
1023 } wiced_bt_dev_enabled_t;
1024 
1025 /** Device disabled (used by BTM_DISABLED_EVT) */
1026 typedef struct {
1027     uint8_t          reason;                     /**< Reason for BTM Disable */
1028 }wiced_bt_dev_disabled_t;
1029 
1030 /** Remote device information (used by BTM_PIN_REQUEST_EVT, BTM_SECURITY_ABORTED_EVT) */
1031 typedef struct {
1032     wiced_bt_device_address_t  *bd_addr;                /**< BD Address of remote */
1033     wiced_bt_dev_class_t       *dev_class;                 /**< peer class of device   */
1034     uint8_t                    *bd_name;                   /**< BD Name of remote */
1035 } wiced_bt_dev_name_and_class_t;
1036 
1037 /** Change in power management status  (used by BTM_POWER_MANAGEMENT_STATUS_EVT notication) */
1038 typedef struct {
1039     wiced_bt_device_address_t           bd_addr;        /**< BD Address of remote */
1040     wiced_bt_dev_power_mgmt_status_t    status;         /**< PM status */
1041     uint16_t                            value;          /**< Additional mode data */
1042     uint8_t                             hci_status;     /**< HCI status */
1043 } wiced_bt_power_mgmt_notification_t;
1044 
1045 /** Encryption status change (used by BTM_ENCRYPTION_STATUS_EVT) */
1046 typedef struct {
1047     uint8_t                 *bd_addr;                   /**< BD Address of remote */
1048     wiced_bt_transport_t    transport;                  /**< BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE */
1049     void                    *p_ref_data;                /**< Optional data passed in by wiced_bt_dev_set_encryption */
1050     wiced_result_t          result;                     /**< Result of the operation */
1051 } wiced_bt_dev_encryption_status_t;
1052 
1053 /** Local OOB data BTM_READ_LOCAL_OOB_DATA_COMPLETE_EVT */
1054 typedef struct {
1055     wiced_result_t          status;                     /**< Status */
1056     wiced_bool_t            is_extended_oob_data;       /**< TRUE if extended OOB data */
1057 
1058     BT_OCTET16              c_192;                      /**< Simple Pairing Hash C derived from the P-192 public key */
1059     BT_OCTET16              r_192;                      /**< Simple Pairing Randomnizer R associated with the P-192 public key */
1060     BT_OCTET16              c_256;                      /**< Simple Pairing Hash C derived from the P-256 public key (valid only if is_extended_oob_data=TRUE) */
1061     BT_OCTET16              r_256;                      /**< Simple Pairing Randomnizer R associated with the P-256 public key (valid only if is_extended_oob_data=TRUE) */
1062 } wiced_bt_dev_local_oob_t;
1063 
1064 /** BTM_REMOTE_OOB_DATA_REQUEST_EVT */
1065 typedef struct {
1066     wiced_bt_device_address_t   bd_addr;                /**< BD Address of remote */
1067     wiced_bool_t                extended_oob_data;      /**< TRUE if requesting extended OOB (P-256) */
1068 } wiced_bt_dev_remote_oob_t;
1069 
1070 /** BR/EDR Pairing IO Capabilities (to be filled by application callback on BTM_PAIRING_IO_CAPABILITIES_BR_EDR_REQUEST_EVT) */
1071 typedef struct
1072 {
1073     wiced_bt_device_address_t   bd_addr;     /**< [in] BD Address of remote   */
1074     wiced_bt_dev_io_cap_t       local_io_cap;/**< local IO capabilities (to be filled by app) */
1075     wiced_bt_dev_oob_data_t     oob_data;    /**< OOB data present at peer device for the local device (to be filled by app)  */
1076     wiced_bt_dev_auth_req_t     auth_req;    /**< Authentication required for peer device (to be filled by app) */
1077     wiced_bool_t                is_orig;     /**< [in] TRUE, if local device initiated the pairing process    */
1078 } wiced_bt_dev_bredr_io_caps_req_t;
1079 
1080 /** BLE Pairing IO Capabilities (to be filled by application callback on BTM_PAIRING_IO_CAPABILITIES_BLE_REQUEST_EVT) */
1081 typedef struct
1082 {
1083     wiced_bt_device_address_t   bd_addr;                /**< [in] BD Address of remote   */
1084     wiced_bt_dev_io_cap_t       local_io_cap;           /**< local IO capabilities (to be filled by application callback) */
1085     uint8_t                     oob_data;               /**< OOB data present (locally) for the peer device                             */
1086     wiced_bt_dev_le_auth_req_t  auth_req;               /**< Authentication request (for local device) contain bonding and MITM info    */
1087     uint8_t                     max_key_size;           /**< Max encryption key size                                                    */
1088     wiced_bt_dev_le_key_type_t  init_keys;              /**< Keys to be distributed, bit mask                                           */
1089     wiced_bt_dev_le_key_type_t  resp_keys;              /**< keys to be distributed, bit mask                                           */
1090 } wiced_bt_dev_ble_io_caps_req_t;
1091 
1092 /** Paired device BLE Keys  */
1093 typedef struct wiced_bt_ble_keys_s
1094 {
1095     BT_OCTET16               irk;            /**< peer diverified identity root */
1096     BT_OCTET16               pltk;           /**< peer long term key */
1097     BT_OCTET16               pcsrk;          /**< peer SRK peer device used to secured sign local data  */
1098 
1099     BT_OCTET16               lltk;           /**< local long term key */
1100     BT_OCTET16               lcsrk;          /**< local SRK peer device used to secured sign local data  */
1101 
1102     BT_OCTET8                rand;           /**< random vector for LTK generation */
1103     uint16_t                 ediv;           /**< LTK diversifier of this Peripheral device */
1104     uint16_t                 div;            /**< local DIV  to generate local LTK=d1(ER,DIV,0) and CSRK=d1(ER,DIV,1)  */
1105     wiced_bt_smp_sec_level_t sec_level;      /**< local pairing security level */
1106     uint8_t                  key_size;       /**< key size of the LTK delivered to peer device */
1107     uint8_t                  srk_sec_level;  /**< security property of peer SRK for this device */
1108     uint8_t                  local_csrk_sec_level;  /**< security property of local CSRK for this device */
1109 
1110     uint32_t                 counter;        /**< peer sign counter for verifying rcv signed cmd */
1111     uint32_t                 local_counter;  /**< local sign counter for sending signed write cmd*/
1112 }wiced_bt_ble_keys_t;
1113 
1114 /** Paired Device Link key data */
1115 typedef struct wiced_bt_device_sec_keys_s
1116 {
1117     /* BR/EDR key */
1118     uint8_t                           br_edr_key_type;        /**<  BR/EDR Link Key type */
1119     wiced_bt_link_key_t               br_edr_key;             /**<  BR/EDR Link Key */
1120 
1121     /* LE Keys */
1122     wiced_bt_dev_le_key_type_t        le_keys_available_mask; /**<  Mask of available BLE keys */
1123     wiced_bt_ble_address_type_t       ble_addr_type;          /**<  LE address type: public or random address */
1124     wiced_bt_ble_keys_t               le_keys;                /**<  LE keys */
1125 } wiced_bt_device_sec_keys_t;
1126 
1127 /** Paired device link key notification (used by BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT notication) */
1128 typedef struct wiced_bt_device_link_keys_s
1129 {
1130     wiced_bt_device_address_t   bd_addr;         /**< [in] BD Address of remote
1131                                                  @note For BLE devices address type of the device is in
1132                                                  \ref wiced_bt_device_sec_keys_t.ble_addr_type
1133                                                  */
1134 
1135     wiced_bt_device_sec_keys_t  key_data;        /**< [in/out] Key data */
1136     wiced_bt_device_address_t   conn_addr;       /**< [in] BD Address remote used to originate connection */
1137 } wiced_bt_device_link_keys_t;
1138 
1139 /** BR packets statistics details */
1140 typedef struct
1141 {
1142     uint16_t    null_count;        /**< No.of NULL packets received/transmitted */
1143     uint16_t    pool_count;        /**< No.of POLL packets received/transmitted */
1144     uint16_t    dm1_count;         /**< No.of DM1 packets received/transmitted  */
1145     uint16_t    dh1_count;         /**< No.of DH1 packets received/transmitted  */
1146     uint16_t    dv_count;          /**< No.of DV packets received/transmitted   */
1147     uint16_t    aux1_count;        /**< No.of AUX1 packets received/transmitted */
1148     uint16_t    dm3_count;         /**< No.of DM3 packets received/transmitted  */
1149     uint16_t    dh3_count;         /**< No.of DH3 packets received/transmitted  */
1150     uint16_t    dm5_count;         /**< No.of DM5 packets received/transmitted  */
1151     uint16_t    dh5_count;         /**< No.of DH5 packets received/transmitted  */
1152 } wiced_bt_device_br_packet_types_t;
1153 
1154 /** EDR packets statistics types details */
1155 typedef struct edr_packet_types_s
1156 {
1157     uint16_t    null_count;        /**< No.of NULL packets received/transmitted  */
1158     uint16_t    pool_count;        /**< No.of POLL packets received/transmitted  */
1159     uint16_t    dm1_count;         /**< No.of DM1 packets received/transmitted   */
1160     uint16_t    _2_dh1_count;      /**< No.of 2DH1 packets received/transmitted  */
1161     uint16_t    _3_dh1_count;      /**< No.of 3DH1 packets received/transmitted  */
1162     uint16_t    _2_dh3_count;      /**< No.of 2DH3 packets received/transmitted  */
1163     uint16_t    _3_dh3_count;      /**< No.of 3DH3 packets received/transmitted  */
1164     uint16_t    _2_dh5_count;      /**< No.of 2DH5 packets received/transmitted  */
1165     uint16_t    _3_dh5_count;      /**< No.of 3DH5 packets received/transmitted  */
1166     uint16_t    not_used;          /**< Not Used */
1167 }wiced_bt_device_edr_packet_types_t;
1168 
1169 /** BR/EDR packet types detail statistics */
1170 typedef union wiced_bt_br_edr_pkt_type_stats_s
1171 {
1172     uint16_t  array[10];               /**< Statistic Arrary */
1173     /** BR packets statistics details */
1174     wiced_bt_device_br_packet_types_t   br_packet_types;      /**< BR packet statastics  */
1175     wiced_bt_device_edr_packet_types_t  edr_packet_types;     /**< EDR packet statastics  */
1176 } wiced_bt_br_edr_pkt_type_stats;
1177 
1178 /** BR/EDR link statistics */
1179 typedef struct wiced_bt_lq_br_edr_stats_s
1180 {
1181     wiced_bt_br_edr_pkt_type_stats rxPkts;  /**< Received packets details */
1182     wiced_bt_br_edr_pkt_type_stats txPkts;  /**< Transmitted packets details */
1183     uint32_t rxAclBytes;        /**< Total Received ACL bytes */
1184     uint32_t txAclBytes;        /**< Total Transmitted ACL bytes */
1185     uint16_t hecErrs;           /**< hecErrs packet count */
1186     uint16_t crcErrs;           /**< crcErrs packet count */
1187     uint16_t seqnRepeat;        /**< seqnRepeat packet count */
1188 }wiced_bt_lq_br_edr_stats;
1189 
1190 /** LE link statistics */
1191 typedef struct wiced_bt_lq_le_stats_s
1192 {
1193     uint32_t  tx_pkt_cnt;           /**< transmit packet count */
1194     uint32_t  tx_acked_cnt;         /**< transmit packet acknowledged count */
1195     uint32_t  rx_good_pkt_cnt;      /**< received good packet count */
1196     uint32_t  rx_good_bytes;        /**< received good byte count */
1197     uint32_t  rx_all_pkt_sync_to;   /**< all received packet sync timeout count */
1198     uint32_t  rx_all_pkt_crc_err;   /**< all received packet crc error count */
1199 }wiced_bt_lq_le_stats;
1200 
1201 /** LQ Quality Result (in response to wiced_bt_dev_lq_stats) */
1202 typedef struct wiced_bt_lq_stats_result_s
1203 {
1204     uint8_t   status;             /**< event status */
1205     uint16_t  conn_handle;        /**< connection handle of link quality stats */
1206     uint8_t   action;             /**< see wiced_bt_dev_link_quality_stats_param for options */
1207     /** LQ Quality Statistics */
1208     union
1209     {
1210         wiced_bt_lq_br_edr_stats br_edr_stats; /**< br edr statistics */
1211         wiced_bt_lq_le_stats     le_stats;     /**< le statistics */
1212     }wiced_bt_lq_stats;
1213 } wiced_bt_lq_stats_result_t;
1214 
1215 /** Link Quality statistics action type */
1216 enum wiced_bt_dev_link_quality_stats_param_e
1217 {
1218     WICED_CLEAR_LINK_QUALITY_STATS            = 0,                  /**< clear link quality stats */
1219     WICED_READ_LINK_QUALITY_STATS             = 1,                  /**< read link quality stats */
1220     WICED_READ_THEN_CLEAR_LINK_QUALITY_STATS  = 2,                  /**< read then clear link quality stats */
1221 };
1222 typedef uint8_t wiced_bt_link_quality_stats_param_t;   /**< Link Quality Statistic Action (see #wiced_bt_dev_link_quality_stats_param_e) */
1223 
1224 /**
1225  * .Enumeration of known link policy settings value assignments of the \ref wiced_bt_link_policy_settings_t
1226  */
1227 enum  wiced_bt_link_policy_settings_values_e
1228 {
1229     WICED_ENABLE_ROLE_SWITCH  = 0x01,       /**< Enable Role Switch */
1230     WICED_ENABLE_HOLD_MODE    = 0x02,       /**< Enable Hold mode */
1231     WICED_ENABLE_SNIFF_MODE   = 0x04        /**<Enable Sniff mode */
1232 };
1233 
1234 /** Link Policy Settings type (see #wiced_bt_link_policy_settings_values_e) */
1235 typedef uint16_t wiced_bt_link_policy_settings_t[1];
1236 
1237 /** advertisement type (used when calling wiced_bt_start_advertisements) */
1238 #ifndef BTM_BLE_ADVERT_MODE
1239 #define BTM_BLE_ADVERT_MODE
1240 /** advertisement type (used when calling wiced_bt_start_advertisements) */
1241 enum wiced_bt_ble_advert_mode_e
1242 {
1243     BTM_BLE_ADVERT_OFF,                 /**< Stop advertising */
1244     BTM_BLE_ADVERT_DIRECTED_HIGH,       /**< Directed advertisement (high duty cycle) */
1245     BTM_BLE_ADVERT_DIRECTED_LOW,        /**< Directed advertisement (low duty cycle) */
1246     BTM_BLE_ADVERT_UNDIRECTED_HIGH,     /**< Undirected advertisement (high duty cycle) */
1247     BTM_BLE_ADVERT_UNDIRECTED_LOW,      /**< Undirected advertisement (low duty cycle) */
1248     BTM_BLE_ADVERT_NONCONN_HIGH,        /**< Non-connectable advertisement (high duty cycle) */
1249     BTM_BLE_ADVERT_NONCONN_LOW,         /**< Non-connectable advertisement (low duty cycle) */
1250     BTM_BLE_ADVERT_DISCOVERABLE_HIGH,   /**< discoverable advertisement (high duty cycle) */
1251     BTM_BLE_ADVERT_DISCOVERABLE_LOW     /**< discoverable advertisement (low duty cycle) */
1252 };
1253 #endif
1254 typedef uint8_t wiced_bt_ble_advert_mode_t;   /**< Advertisement type (see #wiced_bt_ble_advert_mode_e) */
1255 
1256 /** scan mode used in initiating */
1257 #ifndef BTM_BLE_CONN_MODE
1258 #define BTM_BLE_CONN_MODE
1259 /** scan mode used in initiating */
1260 enum wiced_bt_ble_conn_mode_e
1261 {
1262     BLE_CONN_MODE_OFF,                  /**< Stop initiating */
1263     BLE_CONN_MODE_LOW_DUTY,             /**< slow connection scan parameter */
1264     BLE_CONN_MODE_HIGH_DUTY             /**< fast connection scan parameter */
1265 };
1266 #endif
1267 typedef uint8_t wiced_bt_ble_conn_mode_t;       /**< Conn mode (see #wiced_bt_ble_conn_mode_e) */
1268 
1269 #if SMP_CATB_CONFORMANCE_TESTER == TRUE
1270 typedef struct
1271 {
1272     wiced_bool_t             peer_sc_is_set;     /* Secure Connection    */
1273     wiced_bool_t             peer_kp_n_is_set;   /* KeyPress Notification */
1274 } wiced_bt_ble_sc_peer_info;
1275 #endif
1276 
1277 /** HCI trace types  */
1278 typedef enum
1279 {
1280     HCI_TRACE_EVENT, /**< HCI event data from controller to the host */
1281     HCI_TRACE_COMMAND, /**< HCI command data from host to controller */
1282     HCI_TRACE_INCOMING_ACL_DATA,/**< HCI incoming acl data */
1283     HCI_TRACE_OUTGOING_ACL_DATA,/**< HCI outgoing acl data */
1284     HCI_TRACE_INCOMING_ISO_DATA,/**< HCI incoming ISO data */
1285     HCI_TRACE_OUTGOING_ISO_DATA,/**< HCI outgoing ISO data */
1286     HCI_TRACE_INCOMING_SCO_DATA,/**< HCI incoming sco data */
1287     HCI_TRACE_OUTGOING_SCO_DATA /**< HCI outgoing sco data */
1288 }wiced_bt_hci_trace_type_t;
1289 
1290 /** Structure definitions for Bluetooth Management (wiced_bt_management_cback_t) event notifications */
1291 typedef union
1292 {
1293     /* Bluetooth status event data types*/
1294     wiced_bt_dev_enabled_t                  enabled;                            /**< Data for BTM_ENABLED_EVT */
1295     wiced_bt_dev_disabled_t                 disabled;                           /**< Data for BTM_DISABLED_EVT */
1296     wiced_bt_power_mgmt_notification_t      power_mgmt_notification;            /**< Data for BTM_POWER_MANAGEMENT_STATUS_EVT */
1297 
1298     /* Security event data types */
1299     wiced_bt_dev_name_and_class_t           pin_request;                        /**< Data for BTM_PIN_REQUEST_EVT */
1300     wiced_bt_dev_user_cfm_req_t             user_confirmation_request;          /**< Data for BTM_USER_CONFIRMATION_REQUEST_EVT */
1301     wiced_bt_dev_user_key_notif_t           user_passkey_notification;          /**< Data for BTM_USER_PASSKEY_NOTIFICATION_EVT */
1302     wiced_bt_dev_user_key_req_t             user_passkey_request;               /**< Data for BTM_USER_PASSKEY_REQUEST_EVT */
1303     wiced_bt_dev_user_keypress_t            user_keypress_notification;         /**< Data for BTM_USER_KEYPRESS_NOTIFICATION_EVT - See #wiced_bt_dev_user_keypress_t */
1304     wiced_bt_dev_bredr_io_caps_req_t        pairing_io_capabilities_br_edr_request; /**< Data for BTM_PAIRING_IO_CAPABILITIES_BR_EDR_REQUEST_EVT */
1305     wiced_bt_dev_bredr_io_caps_rsp_t        pairing_io_capabilities_br_edr_response;/**< Data for BTM_PAIRING_IO_CAPABILITIES_BR_EDR_RESPONSE_EVT */
1306     wiced_bt_dev_ble_io_caps_req_t          pairing_io_capabilities_ble_request;    /**< Data for BTM_PAIRING_IO_CAPABILITIES_BLE_REQUEST_EVT */
1307     wiced_bt_dev_pairing_cplt_t             pairing_complete;                   /**< Data for BTM_PAIRING_COMPLETE_EVT */
1308     wiced_bt_dev_encryption_status_t        encryption_status;                  /**< Data for BTM_ENCRYPTION_STATUS_EVT */
1309     wiced_bt_dev_security_request_t         security_request;                   /**< Data for BTM_SECURITY_REQUEST_EVT */
1310     wiced_bt_dev_security_failed_t          security_failed;                    /**< Data for BTM_SECURITY_FAILED_EVT See #wiced_bt_dev_security_failed_t */
1311     wiced_bt_dev_name_and_class_t           security_aborted;                   /**< Data for BTM_SECURITY_ABORTED_EVT */
1312 
1313     wiced_bt_dev_local_oob_t                read_local_oob_data_complete;       /**< Data for BTM_READ_LOCAL_OOB_DATA_COMPLETE_EVT */
1314     wiced_bt_dev_remote_oob_t               remote_oob_data_request;            /**< Data for BTM_REMOTE_OOB_DATA_REQUEST_EVT */
1315 
1316     wiced_bt_device_link_keys_t             paired_device_link_keys_update;     /**< Data for BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT */
1317     wiced_bt_device_link_keys_t             paired_device_link_keys_request;    /**< Data for BTM_PAIRED_DEVICE_LINK_KEYS_REQUEST_EVT */
1318     wiced_bt_local_identity_keys_t          local_identity_keys_update;         /**< Data for BTM_LOCAL_IDENTITY_KEYS_UPDATE_EVT */
1319     wiced_bt_local_identity_keys_t          local_identity_keys_request;        /**< Data for BTM_LOCAL_IDENTITY_KEYS_REQUEST_EVT */
1320 
1321     wiced_bt_ble_scan_type_t                ble_scan_state_changed;             /**< Data for BTM_BLE_SCAN_STATE_CHANGED_EVT */
1322     wiced_bt_ble_advert_mode_t              ble_advert_state_changed;           /**< Data for BTM_BLE_ADVERT_STATE_CHANGED_EVT */
1323 
1324     wiced_bt_smp_remote_oob_req_t           smp_remote_oob_data_request;        /**< Data for BTM_SMP_REMOTE_OOB_DATA_REQUEST_EVT */
1325     wiced_bt_smp_sc_remote_oob_req_t        smp_sc_remote_oob_data_request;     /**< Data for BTM_SMP_SC_REMOTE_OOB_DATA_REQUEST_EVT */
1326     wiced_bt_smp_sc_local_oob_t             *p_smp_sc_local_oob_data;           /**< Data for BTM_SMP_SC_LOCAL_OOB_DATA_NOTIFICATION_EVT */
1327 
1328     wiced_bt_sco_connected_t                sco_connected;                      /**< Data for BTM_SCO_CONNECTED_EVT */
1329     wiced_bt_sco_disconnected_t             sco_disconnected;                   /**< Data for BTM_SCO_DISCONNECTED_EVT */
1330     wiced_bt_sco_connection_request_t       sco_connection_request;             /**< Data for BTM_SCO_CONNECTION_REQUEST_EVT */
1331     wiced_bt_sco_connection_change_t        sco_connection_change;              /**< Data for BTM_SCO_CONNECTION_CHANGE_EVT */
1332     wiced_bt_ble_connection_param_update_t  ble_connection_param_update;        /**< Data for BTM_BLE_CONNECTION_PARAM_UPDATE */
1333     wiced_bt_ble_phy_update_t               ble_phy_update_event;               /**< Data for BTM_BLE_PHY_UPDATE_EVT */
1334     wiced_bt_ble_multi_adv_response_t       ble_multi_adv_response_event;       /**< Response status update event for the multiadv command BTM_MULTI_ADV_VSC_RESP_EVENT*/
1335     wiced_bt_ble_phy_data_length_update_t   ble_data_length_update_event;       /**< Data for BTM_BLE_DATA_LENGTH_UPDATE_EVENT*/
1336 #if SMP_CATB_CONFORMANCE_TESTER == TRUE
1337     wiced_bt_ble_sc_peer_info               smp_sc_peer_info;                   /* Data for BTM_SMP_SC_PEER_INFO_EVT */
1338 #endif
1339 
1340 } wiced_bt_management_evt_data_t;
1341 
1342 /**
1343  * Bluetooth Management callback
1344  *
1345  * Callback for Bluetooth Management event notifications.
1346  * Registered using wiced_bt_stack_init()
1347  *
1348  * @param event             : Event ID
1349  * @param p_event_data      : Event data
1350  *
1351  * @return Status of event handling
1352  */
1353 typedef wiced_result_t (wiced_bt_management_cback_t) (wiced_bt_management_evt_t event, wiced_bt_management_evt_data_t *p_event_data);
1354 
1355 /**
1356  * Connection status change callback.
1357  * Callback for Bluetooth Management event notifications.
1358  * Registered using wiced_bt_register_connection_status_change()
1359  *
1360  * @param[in] bd_addr       : BD Address of remote
1361  * @if DUAL_MODE
1362  * @param[in] p_features    : BR/EDR Peer feature
1363  * @else
1364  * @param[in] p_features    : unused (NULL)
1365  * @endif
1366  * @param[in] is_connected  : TRUE if connected
1367  * @param[in] handle        : Connection handle
1368  * @param[in] transport     : BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE
1369  * @param[in] reason        : status for acl connection change \n
1370  * <b>  HCI_SUCCESS \n
1371  * HCI_ERR_PAGE_TIMEOUT \n
1372  * HCI_ERR_MEMORY_FULL \n
1373  * HCI_ERR_CONNECTION_TOUT \n
1374  * HCI_ERR_PEER_USER \n
1375  * HCI_ERR_CONN_CAUSE_LOCAL_HOST \n
1376  * HCI_ERR_LMP_RESPONSE_TIMEOUT \n
1377  * HCI_ERR_CONN_FAILED_ESTABLISHMENT </b>
1378  *
1379  */
1380 typedef void (wiced_bt_connection_status_change_cback_t) (wiced_bt_device_address_t bd_addr, uint8_t *p_features, wiced_bool_t is_connected, uint16_t handle, wiced_bt_transport_t transport, uint8_t reason);  /**<   connection status change callback */
1381 
1382 /**
1383  * Inquiry result callback.
1384  *
1385  * @param p_inquiry_result  : Inquiry result data (NULL if inquiry is complete)
1386  * @param p_eir_data        : Extended inquiry response data
1387  *
1388  */
1389 typedef void (wiced_bt_inquiry_result_cback_t) (wiced_bt_dev_inquiry_scan_result_t *p_inquiry_result, uint8_t *p_eir_data); /**<   inquiry result callback */
1390 
1391 /**
1392  * Asynchronous operation complete callback.
1393  *
1394  * @param p_data            : Operation dependent data
1395  *
1396  * @return void
1397  */
1398 typedef void (wiced_bt_dev_cmpl_cback_t) (void *p_data);
1399 
1400 /**
1401  * Vendor specific command complete.
1402  *
1403  * @param p_command_complete_params : Command complete parameters.
1404  *
1405  * @return void
1406  */
1407 typedef void (wiced_bt_dev_vendor_specific_command_complete_cback_t) (wiced_bt_dev_vendor_specific_command_complete_params_t *p_command_complete_params);
1408 
1409 /**
1410  * Remote name result callback.
1411  *
1412  * @param p_remote_name_result          : Remote name result data
1413  *
1414  * @return void
1415  */
1416 typedef void (wiced_bt_remote_name_cback_t) (wiced_bt_dev_remote_name_result_t *p_remote_name_result); /**<   remote name result callback */
1417 
1418 /**
1419  * Vendor event handler callback
1420  *
1421  * @param len               : input data length
1422  * @param p                 : input data
1423  */
1424 typedef void (wiced_bt_dev_vse_callback_t)(uint8_t len, uint8_t *p);
1425 
1426 /**
1427  * HCI trace callback
1428  *
1429  * Callback for HCI traces
1430  * Registered using wiced_bt_dev_register_hci_trace()
1431  *
1432  * @param[in] type       : Trace type
1433  * @param[in] length : Length of the trace data
1434  * @param[in] p_data  : Pointer to the data
1435  *
1436  * @return void
1437  */
1438 typedef void (wiced_bt_hci_trace_cback_t)(wiced_bt_hci_trace_type_t type, uint16_t length, uint8_t* p_data);
1439 
1440 /**@} wicedbt */
1441 
1442 /******************************************************
1443  *               Function Declarations
1444  ******************************************************/
1445 /****************************************************************************/
1446 
1447 /****************************************************************************/
1448 /**
1449  * @cond DUAL_MODE
1450  * BR/EDR (Bluetooth Basic Rate / Enhanced Data Rate) Functions.
1451  * This module provids different set of BR/EDR API for discovery, inquiry
1452  * ACL & SCO Connection, Data transfer, BR/EDR Security etc.
1453 
1454  *
1455  * @addtogroup  wicedbt_bredr    BR/EDR (Bluetooth Basic Rate / Enhanced Data Rate)
1456  * @ingroup     wicedbt_DeviceManagement
1457  *
1458  * @{
1459  */
1460 /****************************************************************************/
1461 
1462 /****************************************************************************/
1463 /**
1464  * This module provided various Bluetooth security functionality such as authorisation, authentication and encryption
1465  *
1466  * @addtogroup  wiced_bredr_api    Bluetooth BR/EDR API
1467  * @ingroup     wicedbt_bredr
1468  *
1469  * @{
1470  */
1471 /****************************************************************************/
1472 
1473 /**
1474  * Begin BR/EDR inquiry for peer devices.
1475  *
1476  * @param[in]       p_inqparms              : inquiry parameters
1477  * @param[in]       p_inquiry_result_cback  : inquiry results callback
1478  *
1479  * @return          wiced_result_t
1480  *
1481  * <b> WICED_BT_PENDING </b>        : if successfully initiated \n
1482  * <b> WICED_BT_BUSY </b>           : if already in progress \n
1483  * <b> WICED_BT_ILLEGAL_VALUE </b>  : if parameter(s) are out of range \n
1484  * <b> WICED_BT_NO_RESOURCES </b>   : if could not allocate resources to start the command \n
1485  * <b> WICED_BT_WRONG_MODE </b>     : if the device is not up
1486  */
1487 wiced_result_t  wiced_bt_start_inquiry (wiced_bt_dev_inq_parms_t *p_inqparms, wiced_bt_inquiry_result_cback_t *p_inquiry_result_cback);
1488 
1489 /**
1490  *
1491  * Cancel inquiry
1492  *
1493  * @return
1494  *
1495  * <b> WICED_BT_SUCCESS </b>       : if successful \n
1496  * <b> WICED_BT_NO_RESOURCES </b>  : if could not allocate a message buffer \n
1497  * <b> WICED_BT_WRONG_MODE </b>    : if the device is not up.
1498  */
1499 wiced_result_t wiced_bt_cancel_inquiry(void);
1500 
1501 /**
1502  * Read the local device address
1503  *
1504  * @param[out]      bd_addr        : Local bd address
1505  *
1506  * @return          void
1507  *
1508  */
1509 void wiced_bt_dev_read_local_addr (wiced_bt_device_address_t bd_addr);
1510 
1511 /**
1512  * Read the extended local device address information
1513  *
1514  * @param[out]      data        : data pointer in which stack will populate the address information.(refer #wiced_bt_dev_local_addr_ext_t )
1515  *
1516  * @return          void
1517  *
1518  */
1519 void wiced_bt_dev_read_local_addr_ext(wiced_bt_dev_local_addr_ext_t *data);
1520 
1521 
1522 /**
1523  *
1524  * Set advanced connection parameters for subsequent BR/EDR connections
1525  * (remote clock offset, page scan mode,  and other information obtained during inquiry)
1526  *
1527  * If not called, then default connection parameters will be used.
1528  *
1529  * @param[in]       p_inquiry_scan_result : Inquiry scan result (from #wiced_bt_dev_inquiry_scan_result_t)
1530  *
1531  * @return          wiced_result_t
1532  *
1533  * <b> WICED_BT_SUCCESS </b> : on success; \n
1534  * <b> WICED_BT_FAILED  </b> : if an error occurred
1535  */
1536 wiced_result_t wiced_bt_dev_set_advanced_connection_params (wiced_bt_dev_inquiry_scan_result_t *p_inquiry_scan_result);
1537 
1538 /**
1539  *
1540  * Send a vendor specific HCI command to the controller.
1541  *
1542  * @param[in]       opcode              : Opcode of vendor specific command
1543  * @param[in]       param_len           : Length of parameter buffer
1544  * @param[in]       p_param_buf         : Parameters
1545  * @param[in]       p_cback             : Callback for command complete
1546  *
1547  * @return
1548  *
1549  * <b> WICED_BT_SUCCESS </b>   : Command sent. Does not expect command complete event. (command complete callback param is NULL) \n
1550  * <b> WICED_BT_PENDING </b>   : Command sent. Waiting for command complete event. \n
1551  * <b> WICED_BT_BUSY    </b>   : Command not sent. Waiting for command complete event for prior command.
1552  *
1553  */
1554 wiced_result_t wiced_bt_dev_vendor_specific_command (uint16_t opcode, uint8_t param_len, uint8_t *p_param_buf,
1555                                 wiced_bt_dev_vendor_specific_command_complete_cback_t *p_cback);
1556 
1557 /**
1558  * Set discoverability for BR/EDR devices
1559  *
1560  * @note            The duration must be less than or equal to the interval.
1561  *
1562  * @param[in]       inq_mode        : Discoverability mode (see #wiced_bt_discoverability_mode_e )
1563  * @param[in]       duration        : Duration (in 0.625 msec intervals). <b>BTM_DEFAULT_DISC_WINDOW</b>, or range: <b>0x0012 ~ 0x1000 </b> (11.25 ~ 2560 msecs)
1564  * @param[in]       interval        : Interval (in 0.625 msec intervals). <b>BTM_DEFAULT_DISC_INTERVAL</b>, or range: <b>0x0012 ~ 0x1000 </b> (11.25 ~ 2560 msecs)
1565  *
1566  * @return
1567  *
1568  * <b> WICED_BT_SUCCESS </b>       : If successful \n
1569  * <b> WICED_BT_BUSY </b>          : If a setting of the filter is already in progress \n
1570  * <b> WICED_BT_NO_RESOURCES </b>  : If couldn't get a memory pool buffer \n
1571  * <b> WICED_BT_ILLEGAL_VALUE </b> : If a bad parameter was detected \n
1572  * <b> WICED_BT_WRONG_MODE </b>    : If the device is not up
1573  */
1574 wiced_result_t  wiced_bt_dev_set_discoverability (uint8_t inq_mode, uint16_t duration,
1575                                                     uint16_t interval);
1576 
1577 /**
1578  *
1579  * Set connectablilty for BR/EDR devices
1580  *
1581  * @note            The duration (window parameter) must be less than or equal to the interval.
1582  *
1583  * @param[in]       page_mode       : Connectability mode (see #wiced_bt_connectability_mode_e )
1584  * @param[in]       window          : Duration (in 0.625 msec intervals). <b>BTM_DEFAULT_CONN_WINDOW</b>, or range: <b>0x0012 ~ 0x1000 </b> (11.25 ~ 2560 msecs)
1585  * @param[in]       interval        : Interval (in 0.625 msec intervals). <b>BTM_DEFAULT_CONN_INTERVAL</b>, or range: <b>0x0012 ~ 0x1000 </b> (11.25 ~ 2560 msecs)
1586  *
1587  * @return
1588  *
1589  * <b> WICED_BT_SUCCESS </b>       :  If successful \n
1590  * <b> WICED_BT_ILLEGAL_VALUE </b> :  If a bad parameter is detected \n
1591  * <b> WICED_BT_NO_RESOURCES </b>  :  If could not allocate a message buffer \n
1592  * <b> WICED_BT_WRONG_MODE </b>    :  If the device is not up
1593  */
1594 wiced_result_t wiced_bt_dev_set_connectability (uint8_t page_mode, uint16_t window,
1595                                                       uint16_t interval);
1596 /**
1597  *
1598  * Register callback for connection status change
1599  *
1600  *
1601  * @param[in]       p_wiced_bt_connection_status_change_cback - Callback for connection status change
1602  *
1603  * @return          wiced_result_t
1604  *
1605  * <b> WICED_BT_SUCCESS </b>  : on success; \n
1606  * <b> WICED_BT_FAILED </b>   : if an error occurred
1607  */
1608 wiced_result_t wiced_bt_dev_register_connection_status_change(wiced_bt_connection_status_change_cback_t *p_wiced_bt_connection_status_change_cback);
1609 
1610 /**
1611  *
1612  * Set a connection into sniff mode.
1613  *
1614  * @param[in]       remote_bda      : Link for which to put into sniff mode
1615  * @param[in]       min_period      : Minimum sniff period (range 0x0006 to 0x0540) (in 0.625 msec)
1616  * @param[in]       max_period      : Maximum sniff period (range 0x0006 to 0x0540) (in 0.625 msec)
1617  * @param[in]       attempt         : Number of attempts for switching to sniff mode (range 0x0001 – 0x7FFF) (in 0.625 msec)
1618  * @param[in]       timeout         : Timeout for attempting to switch to sniff mode (range 0x0000 – 0x7FFF) (in 0.625 msec)
1619  *
1620  * @return          <b> WICED_BT_PENDING </b> if successfully initiated, otherwise error
1621  */
1622 wiced_result_t wiced_bt_dev_set_sniff_mode (wiced_bt_device_address_t remote_bda, uint16_t min_period,
1623                                              uint16_t max_period, uint16_t attempt,
1624                                              uint16_t timeout);
1625 
1626 
1627 /**
1628  * Take a connection out of sniff mode.
1629  * A check is made if the connection is already in sniff mode,
1630  * and if not, the cancel sniff mode is ignored.
1631  *
1632  * @return          <b> WICED_BT_PENDING </b> if successfully initiated, otherwise error
1633  *
1634  */
1635 wiced_result_t wiced_bt_dev_cancel_sniff_mode (wiced_bt_device_address_t remote_bda);
1636 
1637 
1638 /**
1639  *
1640  * Set sniff subrating parameters for an active connection
1641  *
1642  * @param[in]       remote_bda          : device address of desired ACL connection
1643  * @param[in]       max_latency         : maximum latency (in 0.625ms units) (range: 0x0002-0xFFFE)
1644  * @param[in]       min_remote_timeout  : minimum remote timeout (in 0.625ms units) (range: 0x0000 – 0xFFFE)
1645  * @param[in]       min_local_timeout   : minimum local timeout (in 0.625ms units) (range: 0x0000 – 0xFFFE)
1646  *
1647  * @return
1648  *
1649  * <b> WICED_BT_SUCCESS </b>        : on success; \n
1650  * <b> WICED_BT_ILLEGAL_ACTION </b> : if an error occurred
1651  */
1652 wiced_result_t wiced_bt_dev_set_sniff_subrating (wiced_bt_device_address_t remote_bda, uint16_t max_latency,
1653                               uint16_t min_remote_timeout, uint16_t min_local_timeout);
1654 
1655 /**
1656  *
1657  * Get Receive Signal Strenth Index (RSSI) for the requested link
1658  *
1659  * @param[in]       remote_bda      : BD address of connection to read rssi
1660  * @param[in]       transport       : Transport type
1661  * @param[in]       p_cback         : Result callback (wiced_bt_dev_rssi_result_t will be passed to the callback)
1662  *
1663  * @return
1664  *
1665  * <b> WICED_BT_PENDING </b>      : if command issued to controller. \n
1666  * <b> WICED_BT_NO_RESOURCES </b> : if couldn't allocate memory to issue command \n
1667  * <b> WICED_BT_UNKNOWN_ADDR </b> : if no active link with bd addr specified \n
1668  * <b> WICED_BT_BUSY </b>         : if command is already in progress
1669  *
1670  */
1671 wiced_result_t wiced_bt_dev_read_rssi (wiced_bt_device_address_t remote_bda, wiced_bt_transport_t transport, wiced_bt_dev_cmpl_cback_t *p_cback);
1672 
1673 /**
1674  *
1675  * Write EIR data to controller.
1676  *
1677  * @param[in]       p_buff   : EIR data as per the spec (Spec 5.0 Vol 3 Part C, Section 8 )
1678  * @param[in]       len      : Total Length of EIR data being passed
1679  *
1680  * @return
1681  * <b> WICED_BT_SUCCESS </b>      : if successful \n
1682  * <b> WICED_BT_NO_RESOURCES </b> : if couldn't allocate memory to issue command \n
1683  * <b> WICED_BT_UNSUPPORTED </b>  : if local device cannot support request \n
1684  *
1685  */
1686 wiced_result_t wiced_bt_dev_write_eir (uint8_t *p_buff, uint16_t len);
1687 
1688 /**
1689  *
1690  * This function is called to switch the role between Central and
1691  * Peripheral.  If role is already set it will do nothing. If the
1692  * command was initiated, the callback function is called upon
1693  * completion.
1694  *
1695  * @param[in]       remote_bd_addr      : BD address of remote device
1696  * @param[in]       new_role            : New role (HCI_ROLE_CENTRAL or HCI_ROLE_PERIPHERAL)
1697  * @param[in]       p_cback             : Result callback (wiced_bt_dev_switch_role_result_t will be passed to the callback)
1698  *
1699  * @return      wiced_result_t
1700  *
1701  */
1702 wiced_result_t wiced_bt_dev_switch_role( wiced_bt_device_address_t remote_bd_addr, wiced_bt_dev_role_t new_role, wiced_bt_dev_cmpl_cback_t *p_cback );
1703 
1704 /**
1705 *
1706 * This function is called to send HCI_SET_AFH_CHANNELS command
1707 * to BR/EDR controller.
1708 *
1709 * Channel n is bad = 0.
1710 * Channel n is unknown = 1.
1711 * The most significant bit is reserved and shall be set to 0.
1712 * At least 20 channels shall be marked as unknown.
1713 *
1714 * @param  afh_channel_map     : AFH Host Channel Classification array
1715 *
1716 * @return
1717 * <b> WICED_BT_UNSUPPORTED </b>  : if feature does not supported \n
1718 * <b> WICED_BT_WRONG_MODE </b>   : if device is in wrong mode \n
1719 * <b> WICED_BT_NO_RESOURCES </b> : if device does not have buffers to process the request
1720 *
1721 */
1722 wiced_bt_dev_status_t wiced_bt_dev_set_afh_channel_classification(const wiced_bt_br_chnl_map_t afh_channel_map);
1723 
1724 /**
1725 *
1726 * Get BT Friendly name from remote device.
1727 *
1728 * @param[in]       bd_addr  : Peer bd address
1729 * @param[in]       p_remote_name_result_cback  : remote name result callback
1730 *
1731 * @return          wiced_result_t
1732 *
1733 * <b> WICED_BT_PENDING </b>      : if successfully initiated \n
1734 * <b> WICED_BT_BUSY </b>         : if already in progress \n
1735 * <b> WICED_BT_ILLEGAL_VALUE </b>: if parameter(s) are out of range \n
1736 * <b> WICED_BT_NO_RESOURCES </b> : if could not allocate resources to start the command \n
1737 * <b> WICED_BT_WRONG_MODE </b>   : if the device is not up.
1738 **/
1739 wiced_result_t  wiced_bt_dev_get_remote_name (wiced_bt_device_address_t bd_addr, wiced_bt_remote_name_cback_t *p_remote_name_result_cback);
1740 
1741 /**
1742  * This function is called to set the Link Policy for remote device
1743  *
1744  * @param[in]       remote_bda      : remote device's address
1745  * @param[in]       settings        : the policy setting value(from #wiced_bt_link_policy_settings_values_e)
1746  *
1747  * @return          wiced_result_t
1748 */
1749 wiced_result_t wiced_bt_dev_set_link_policy(wiced_bt_device_address_t remote_bda,
1750         wiced_bt_link_policy_settings_t settings);
1751 
1752 /**
1753 *
1754 * Application can invoke this function to enable the coex functionality
1755 *
1756 * @param[in]       seci_baud_rate       : SECI baud rate. Ensure to set a valid baud rate which will be used
1757 *                                         for the SECI communication between BT and WLAN chip. Maximum supported
1758 *                                         value is up to 4M
1759 *
1760 * @return          wiced_result_t
1761 *
1762 **/
1763 wiced_result_t wiced_bt_coex_enable( uint32_t seci_baud_rate );
1764 
1765 /**
1766  *
1767  * Application can invoke this function to disable the coex functionality
1768  *
1769  * @return         void
1770  *
1771  */
1772 void wiced_bt_coex_disable( void );
1773 
1774 /**
1775 *
1776 * This function is called to set the channel assessment mode on or off
1777 *
1778 * @param[in]       enable_or_disable :  Enable or disable AFH channel assessment
1779 *
1780 * @return          wiced_result_t
1781 *
1782 **/
1783 wiced_result_t wiced_bt_dev_set_afh_channel_assessment(wiced_bool_t enable_or_disable);
1784 
1785 /**
1786  *
1787  * This function is called to set the packet types used for
1788  * a specific SCO connection and for all connections.
1789  *
1790  * @param[in]       sco_inx: Specific connection and -1 for all connections.
1791  * @param[in]       pkt_types: One or more of the following \n
1792  * <b> BTM_SCO_PKT_TYPES_MASK_HV1 \n
1793  *  BTM_SCO_PKT_TYPES_MASK_HV2 \n
1794  *  BTM_SCO_PKT_TYPES_MASK_HV3 \n
1795  *  BTM_SCO_PKT_TYPES_MASK_EV3 \n
1796  *  BTM_SCO_PKT_TYPES_MASK_EV4 \n
1797  *  BTM_SCO_PKT_TYPES_MASK_EV5 \n
1798  *  BTM_SCO_PKT_TYPES_MASK_NO_2_EV3 \n
1799  *  BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 \n
1800  *  BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 \n
1801  *  BTM_SCO_PKT_TYPES_MASK_NO_3_EV5 \n
1802  *  BTM_SCO_LINK_ALL_MASK </b>   - enables all supported types
1803  *
1804  * @return          wiced_bt_dev_status_t
1805  */
1806 wiced_bt_dev_status_t wiced_bt_sco_setPacketTypes(int16_t sco_inx, uint16_t pkt_types);
1807 
1808 /**
1809  * This function is set the ACL packet types that
1810  * the device supports for specific connection and all connections if bd address with all zeros.
1811  *
1812  * @param[in]     remote_bda: BD Address for specific conection and for all connections it should be all 0's.
1813  * @param[in]     pkt_types: Packet types supported by the device.
1814  *                           One or more of the following (bitmask): \n
1815  * <b> BTM_ACL_PKT_TYPES_MASK_DM1 \n
1816  * BTM_ACL_PKT_TYPES_MASK_DH1 \n
1817  * BTM_ACL_PKT_TYPES_MASK_DM3 \n
1818  * BTM_ACL_PKT_TYPES_MASK_DH3 \n
1819  * BTM_ACL_PKT_TYPES_MASK_DM5 \n
1820  * BTM_ACL_PKT_TYPES_MASK_DH5 \n
1821  * BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 \n
1822  * BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 \n
1823  * BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 \n
1824  * BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 \n
1825  * BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 </b>
1826  *
1827  * @return          wiced_result_t
1828  */
1829 wiced_result_t wiced_bt_dev_setAclPacketTypes(wiced_bt_device_address_t remote_bda, uint16_t pkt_types);
1830 
1831 /**
1832 * @}
1833 */
1834 
1835 /**
1836  *
1837  * This module provided various Bluetooth BR/EDR security functionality such as authorisation, authentication and encryption.
1838  *
1839  * @addtogroup  br_edr_sec_api_functions        BR/EDR Security Function
1840  * @ingroup     wicedbt_bredr
1841  *
1842  * @note General Security APIs are listed in \ref ble_common_sec_api_functions section.
1843  * @{
1844  */
1845 
1846 /**
1847  * PIN code reply (use in response to <b>BTM_PIN_REQUEST_EVT </b> in #wiced_bt_management_cback_t)
1848  *
1849  *  @param[in]      bd_addr     : Address of the device for which PIN was requested
1850  *  @param[in]      res         : result of the operation WICED_BT_SUCCESS if success
1851  *  @param[in]      pin_len     : length in bytes of the PIN Code
1852  *  @param[in]      p_pin       : pointer to array with the PIN Code
1853  *
1854  * @return          void
1855  * @note            BR/EDR Only
1856  */
1857 void wiced_bt_dev_pin_code_reply (wiced_bt_device_address_t bd_addr, wiced_result_t res, uint8_t pin_len, uint8_t *p_pin);
1858 
1859 /**
1860  *
1861  * Provide the pairing passkey (in response to <b>BTM_PASSKEY_REQUEST_EVT </b> of #wiced_bt_management_cback_t)
1862  *
1863  * @param[in]       res           : result of the operation WICED_BT_SUCCESS if success
1864  * @param[in]       bd_addr       : Address of the peer device
1865  * @param[in]       passkey       : numeric value in the range of 0 - 999999(0xF423F).
1866  *
1867  * @return          void
1868  * @note            BR/EDR only
1869  */
1870 void wiced_bt_dev_pass_key_req_reply(wiced_result_t res, wiced_bt_device_address_t bd_addr, uint32_t passkey);
1871 
1872 /**
1873  *
1874  * Read the local OOB data from controller (for sending
1875  * to peer device over oob message). When
1876  * operation is completed, local OOB data will be
1877  * provided via BTM_READ_LOCAL_OOB_DATA_COMPLETE_EVT.
1878  *
1879  * @note            BR/EDR Only
1880  */
1881 wiced_result_t wiced_bt_dev_read_local_oob_data(void);
1882 
1883 /**
1884  *
1885  * Provide the remote OOB extended data for Simple Pairing
1886  * in response to BTM_REMOTE_OOB_DATA_REQUEST_EVT
1887  *
1888  * @param[in]       res                     : response reply
1889  * @param[in]       bd_addr                 : Address of the peer device
1890  * @param[in]       is_extended_oob_data    : TRUE if extended OOB data (set according to BTM_REMOTE_OOB_DATA_REQUEST_EVT request)
1891  * @param[in]       c_192                   : simple pairing Hash C derived from the P-192 public key.
1892  * @param[in]       r_192                   : simple pairing Randomizer R associated with the P-192 public key.
1893  * @param[in]       c_256                   : simple pairing Hash C derived from the P-256 public key (if is_extended_oob_data=TRUE)
1894  * @param[in]       r_256                   : simple pairing Randomizer R associated with the P-256 public key (if is_extended_oob_data=TRUE)
1895  *
1896  * @note            BR/EDR Only
1897  */
1898 void wiced_bt_dev_remote_oob_data_reply (wiced_result_t res, wiced_bt_device_address_t bd_addr,
1899                                               wiced_bool_t is_extended_oob_data,
1900                                               BT_OCTET16 c_192, BT_OCTET16 r_192,
1901                                               BT_OCTET16 c_256, BT_OCTET16 r_256);
1902 
1903 /**
1904  * Build the OOB data block to be used to send OOB extended
1905  * data over OOB (non-Bluetooth) link.
1906  *
1907  * @param[out]      p_data                  : OOB data block location
1908  * @param[in]       max_len                 : OOB data block size
1909  * @param[in]       is_extended_oob_data    : TRUE if extended OOB data (for Secure Connections)
1910  * @param[in]       c_192                   : simple pairing Hash C derived from the P-192 public key.
1911  * @param[in]       r_192                   : simple pairing Randomizer R associated with the P-192 public key.
1912  * @param[in]       c_256                   : simple pairing Hash C derived from the P-256 public key (if is_extended_oob_data=TRUE)
1913  * @param[in]       r_256                   : simple pairing Randomizer R associated with the P-256 public key (if is_extended_oob_data=TRUE)
1914  *
1915  * @return          Number of bytes put into OOB data block.
1916  *
1917  * @note            BR/EDR Only
1918  */
1919 uint16_t wiced_bt_dev_build_oob_data(uint8_t *p_data, uint16_t max_len,
1920                                           wiced_bool_t is_extended_oob_data,
1921                                           BT_OCTET16 c_192, BT_OCTET16 r_192,
1922                                           BT_OCTET16 c_256, BT_OCTET16 r_256);
1923 
1924 /**
1925  *
1926  * This function is called to provide the OOB data for
1927  * SMP in response to BTM_SMP_REMOTE_OOB_DATA_REQUEST_EVT
1928  *
1929  *  @param[in]      bd_addr     - Address of the peer device
1930  *  @param[in]      res         - result of the operation WICED_BT_SUCCESS if success
1931  *  @param[in]      len         - oob data length
1932  *  @param[in]      p_data      - oob data
1933  *
1934  * @note            BR/EDR Only
1935  */
1936 void wiced_bt_smp_oob_data_reply(wiced_bt_device_address_t bd_addr, wiced_result_t res, uint8_t len, uint8_t *p_data);
1937 
1938 /**
1939  *
1940  * Create local BLE SC (secure connection) OOB data. When
1941  * operation is completed, local OOB data will be
1942  * provided via BTM_SMP_SC_LOCAL_OOB_DATA_NOTIFICATION_EVT.
1943  *
1944  * @param[in]       bd_addr         : remote device address for the OOB data
1945  * @param[in]       bd_addr_type    : device address type of address \p bd_addr
1946  *
1947  * @return          TRUE: creation of local SC OOB data set started.
1948  *
1949  */
1950 wiced_bool_t wiced_bt_smp_create_local_sc_oob_data (wiced_bt_device_address_t bd_addr, wiced_bt_ble_address_type_t bd_addr_type);
1951 
1952 /**
1953  *
1954  * Provide the SC OOB data for SMP in response to
1955  * BTM_SMP_SC_REMOTE_OOB_DATA_REQUEST_EVT
1956  *
1957  * @param[in]       p_oob_data  : oob data
1958  *
1959  */
1960 void wiced_bt_smp_sc_oob_reply (wiced_bt_smp_sc_oob_data_t *p_oob_data);
1961 
1962 /**
1963  *
1964  * This function is called to parse the OOB data payload
1965  * received over OOB (non-Bluetooth) link
1966  *
1967  * @param[in]       p_data  : oob data
1968  * @param[in]       eir_tag : EIR Data type( version5.0, Volume 3, Part C Section 5.2.2.7 )
1969  * @param[out]      p_len   : the length of the data with the given EIR Data type
1970  *
1971  * @return          The beginning of the data with the given EIR Data type.
1972  *                  NULL, if the tag is not found.
1973  * @note            BR/EDR Only
1974  */
1975 uint8_t* wiced_bt_dev_read_oob_data(uint8_t *p_data, uint8_t eir_tag, uint8_t *p_len);
1976 
1977 /**
1978  *
1979  * Disable BT secure connection
1980  *
1981  * @note This utility is used for LRAC application to disable the BT secure connection only.
1982  *       If the interference issue is fixed, this utility may be removed
1983  *        This utility shall be called before the bt stack is initialized
1984  *        (by calling app_bt_init()).
1985  */
1986 void wiced_bt_dev_lrac_disable_secure_connection(void);
1987 
1988 /**
1989  *@}
1990  *@}
1991  *@}
1992  */
1993 /* @endcond*/
1994 
1995 /****************************************************************************/
1996 /**
1997  * This sections provides Bluetooth utilities functions related to trace, local bda, tx power etc.
1998  *
1999  * @addtogroup  wicedbt_utility    Utilities
2000  * @ingroup     wicedbt_DeviceManagement
2001  *
2002  * @{
2003  */
2004 /****************************************************************************/
2005 
2006 /**
2007  *
2008  * Register to get the hci traces
2009  *
2010  * @param[in]      p_cback        : Callback for hci traces
2011  *
2012  * @return          void
2013  *
2014  */
2015 void wiced_bt_dev_register_hci_trace( wiced_bt_hci_trace_cback_t* p_cback );
2016 
2017 /**
2018  *
2019  * Update the hci trace mode
2020  *
2021  * @param[in]      enable    : TRUE to enable HCI traces, FALSE to disable
2022  *
2023  * @return          void
2024  *
2025  */
2026 void wiced_bt_dev_update_hci_trace_mode(wiced_bool_t enable);
2027 
2028 /**
2029  *
2030  * Update the debug trace mode
2031  *
2032  * @param[in]      enable    : TRUE to enable debug traces, FALSE to disable
2033  *
2034  * @return          void
2035  *
2036  */
2037 void wiced_bt_dev_update_debug_trace_mode(wiced_bool_t enable);
2038 
2039 /**
2040  *
2041  * Set Local Bluetooth Device Address.
2042  * The application has to set a valid address (Static/Random) by calling this function.\n
2043  * If this function is not called, the default address is typically a controller assigned address(BT device part number),
2044  * which is same for perticular device type.For example, all CYW43012 devcies will
2045  * typically have the same default address.
2046  *
2047  * The application can set a static random address by setting the addr_type to \ref BLE_ADDR_RANDOM.
2048  * For static random addresses the top two bits of the bd_addr are required to be set,
2049  * the stack will override these bits if not set. The remaining 46 bits will be taken from the value provided for bd_addr, \n
2050  * which cannot be all 0's.
2051  *
2052  * @param[in]       bd_addr    : device address to use
2053  * @param[in]       addr_type  : device address type , should be BLE_ADDR_RANDOM or BLE_ADDR_PUBLIC \n
2054  *                               BLE_ADDR_RANDOM should be only for single BLE mode, not for BR-EDR or Dual Mode.
2055  *
2056  * @return          wiced_result_t
2057  *
2058  * WICED_BT_ILLEGAL_VALUE : if invalid device address specified \n
2059  * WICED_BT_NO_RESOURCES  : if couldn't allocate memory to issue command \n
2060  * WICED_BT_SUCCESS       : if local bdaddr is set successfully \n
2061  *
2062  * @note            BD_Address must be in Big Endian format
2063  *
2064  * Example:
2065  * <PRE>    Data         | AB | CD | EF | 01 | 23 | 45 | </PRE>
2066  * <PRE>    Address      | 0  | 1  | 2  | 3  | 4  | 5  | </PRE>
2067  *                       For above example it will set AB:CD:EF:01:23:45 bd address
2068  */
2069 wiced_result_t wiced_bt_set_local_bdaddr( wiced_bt_device_address_t  bd_addr , wiced_bt_ble_address_type_t addr_type);
2070 
2071 /**
2072  *
2073  * This function is called to get the role of the local device
2074  * for the ACL connection with the specified remote device
2075  *
2076  * @param[in]       remote_bd_addr      : BD address of remote device
2077  * @param[in]       transport               : BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE
2078  *
2079  * @param[out]     p_role       : Role of the local device
2080  *
2081  * @return      WICED_BT_UNKNOWN_ADDR if no active link with bd addr specified
2082  *
2083  */
2084 wiced_result_t wiced_bt_dev_get_role(wiced_bt_device_address_t remote_bd_addr,
2085                                      wiced_bt_dev_role_t      *p_role,
2086                                      wiced_bt_transport_t      transport);
2087 
2088 /**
2089  *  Command to set the tx power on link
2090  *  This command will adjust the transmit power attenuation on a per connection basis.
2091  *
2092  * @param[in]       bd_addr       : peer address
2093  *                                  To set Adv Tx power keep bd_addr NULL
2094  * @param[in]       power          :  power value in db
2095  * @param[in]       p_cb           :  Result callback (wiced_bt_set_adv_tx_power_result_t will be passed to the callback)
2096  *
2097  * @return          wiced_result_t
2098  *
2099  **/
2100 wiced_result_t wiced_bt_set_tx_power ( wiced_bt_device_address_t bd_addr , int8_t power, wiced_bt_dev_vendor_specific_command_complete_cback_t *p_cb );
2101 
2102 /**
2103  * Read the transmit power for the requested link
2104  *
2105  * @param[in]       remote_bda      : BD address of connection to read tx power
2106  * @param[in]       transport       : Transport type
2107  * @param[in]       p_cback         : Result callback (wiced_bt_tx_power_result_t will be passed to the callback)
2108  *
2109  * @return
2110  *
2111  * <b> WICED_BT_PENDING </b>      : if command issued to controller. \n
2112  * <b> WICED_BT_NO_RESOURCES </b> : if couldn't allocate memory to issue command \n
2113  * <b> WICED_BT_UNKNOWN_ADDR </b> : if no active link with bd addr specified \n
2114  * <b> WICED_BT_BUSY </b>         : if command is already in progress
2115  *
2116  */
2117 wiced_result_t wiced_bt_dev_read_tx_power (wiced_bt_device_address_t remote_bda, wiced_bt_transport_t transport,
2118                                             wiced_bt_dev_cmpl_cback_t *p_cback);
2119 
2120 /**
2121 *
2122 * Enable or disable pairing
2123 *
2124 * @param[in]       allow_pairing        : (TRUE or FALSE) whether or not the device allows pairing.
2125 * @param[in]       connect_only_paired   : (TRUE or FALSE) whether or not to only allow paired devices to connect.
2126 *                                         <b> Applicable only for BR/EDR </b>
2127 *
2128 * @return          void
2129 *
2130 */
2131 void wiced_bt_set_pairable_mode(uint8_t allow_pairing, uint8_t connect_only_paired);
2132 
2133 /**
2134  *
2135  * Application can register Vendor-Specific HCI event callback
2136  *
2137  * @param[in]      cb       : callback function to register
2138  *
2139  * @return         WICED_SUCCESS
2140  *                 WICED_ERROR if out of usage
2141  */
2142 wiced_result_t wiced_bt_dev_register_vse_callback(wiced_bt_dev_vse_callback_t cb);
2143 
2144 /**
2145  *
2146  * Application can deregister Vendor-Specific HCI event callback
2147  *
2148  * @param[in]      cb       : callback function to deregister
2149  *
2150  * @return         WICED_SUCCESS
2151  *                 WICED_ERROR if the input callback function was not registered yet
2152  */
2153 wiced_result_t wiced_bt_dev_deregister_vse_callback(wiced_bt_dev_vse_callback_t cb);
2154 
2155 /**
2156  *
2157  * This API is called to get the statistics for an ACL link
2158  *
2159  * Limitation       This API works when there is only one ACL connection
2160  *
2161  * @param[in]       bda               : bluetooth device address of desired link quality statistics
2162  * @param[in]       transport         : Tranport type LE/BR-EDR
2163  * @param[in]       action            : WICED_CLEAR_LINK_QUALITY_STATS = reset the link quality statistics to 0,
2164  *                                                  WICED_READ_LINK_QUALITY_STATS = read link quality statistics,
2165  *                                                  WICED_READ_THEN_CLEAR_LINK_QUALITY_STATS = read link quality statistics, then clear it
2166  * @param[in]       p_cback           : Result callback (wiced_bt_dev_cmpl_cback_t will be passed to the callback)
2167  *
2168  * @return
2169  *
2170  * <b> WICED_BT_SUCCESS </b>      : If successful \n
2171  * <b> WICED_BT_PENDING </b>      : If command succesfully sent down \n
2172  * <b> WICED_BT_BUSY </b>         : If already in progress \n
2173  * <b> WICED_BT_NO_RESORCES </b>  : If no memory/buffers available to sent down to controller \n
2174  * <b> WICED_BT_UNKNOWN_ADDR </b> : If given BD_ADDRESS is invalid \n
2175  *
2176  * @note   Callback function argument is a pointer of type wiced_bt_lq_stats_result_t
2177  *
2178  *
2179  */
2180 wiced_bt_dev_status_t wiced_bt_dev_link_quality_stats(wiced_bt_device_address_t bda, wiced_bt_transport_t transport,
2181                 uint8_t action, wiced_bt_dev_cmpl_cback_t *p_cback);
2182 
2183 #ifdef USE_WICED_HCI
2184 /**
2185  * MCU host push all the saved NVRAM informatoin mainly paired device Info
2186  *
2187  * @param[in]       paired_device_info : Remote device address, Link key
2188  *
2189  * @return          WICED_BT_SUCCESS if successful
2190  *
2191  */
2192 wiced_result_t wiced_bt_dev_push_nvram_data(wiced_bt_device_link_keys_t *paired_device_info);
2193 #endif
2194 
2195 /**@} wicedbt_utility */
2196 
2197 /**
2198  * @if DUAL_MODE
2199  * Bluetooth generic security API.
2200  *
2201  * @addtogroup  ble_common_sec_api_functions        Generic Security API
2202  * @ingroup     br_edr_sec_api_functions
2203  * @ingroup     btm_ble_sec_api_functions
2204  * @else
2205  * Bluetooth BLE Security Functions.
2206  * @ingroup  btm_ble_sec_api_functions
2207  * @endif
2208  * @{
2209  */
2210 
2211 /**
2212  *
2213  * Bond with peer device. If the connection is already up, but not secure, pairing is attempted.
2214  *
2215  *  @note           PIN parameters are only needed when bonding with legacy devices (pre-2.1 Core Spec)
2216  *
2217  *  @param[in]      bd_addr         : Peer device bd address to pair with.
2218  *  @param[in]      bd_addr_type    : BLE_ADDR_PUBLIC or BLE_ADDR_RANDOM (applies to LE devices only)
2219  *  @param[in]      transport       : BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE
2220  *  @param[in]      pin_len         : Length of input parameter p_pin (0 if not used).
2221  *  @param[in]      p_pin           : Pointer to Pin Code to use (NULL if not used).
2222  *
2223  *  @return
2224  *
2225  * <b> WICED_BT_PENDING </b> : if successfully initiated, \n
2226  * <b> WICED_BT_SUCCESS </b> : if already paired to the device, else error code
2227  */
2228 wiced_result_t wiced_bt_dev_sec_bond (wiced_bt_device_address_t bd_addr, wiced_bt_ble_address_type_t bd_addr_type, wiced_bt_transport_t transport, uint8_t pin_len, uint8_t *p_pin);
2229 
2230 /**
2231  *
2232  * Pair with peer device(dont store the keys). If the connection is already up, but not secure, pairing is attempted.
2233  *
2234  *  @note           PIN parameters are only needed when bonding with legacy devices (pre-2.1 Core Spec)
2235  *
2236  *  @param[in]      bd_addr         : Peer device bd address to pair with.
2237  *  @param[in]      bd_addr_type    : BLE_ADDR_PUBLIC or BLE_ADDR_RANDOM (applies to LE devices only)
2238  *  @param[in]      transport       : BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE
2239  *  @param[in]      pin_len         : Length of input parameter p_pin (0 if not used).
2240  *  @param[in]      p_pin           : Pointer to Pin Code to use (NULL if not used).
2241  *
2242  *  @return
2243  *
2244  * <b> WICED_BT_PENDING </b> : if successfully initiated, \n
2245  * <b> WICED_BT_SUCCESS </b> : if already paired to the device, else error code
2246  */
2247 wiced_result_t wiced_bt_dev_sec_pair_without_bonding(wiced_bt_device_address_t bd_addr,
2248                                                      wiced_bt_ble_address_type_t bd_addr_type,
2249                                                      wiced_bt_transport_t transport,
2250                                                      uint8_t pin_len,
2251                                                      uint8_t *p_pin);
2252 
2253 /**
2254  *
2255  * Cancel an ongoing bonding process with peer device.
2256  *
2257  *  @param[in]      bd_addr         : Peer device bd address to pair with.
2258  *
2259  *  @return
2260  *
2261  * <b> WICED_BT_PENDING </b> : if cancel initiated, \n
2262  * <b> WICED_BT_SUCCESS </b> : if cancel has completed already, else error code.
2263  */
2264 wiced_result_t wiced_bt_dev_sec_bond_cancel (wiced_bt_device_address_t bd_addr);
2265 
2266 
2267 /**
2268  *
2269  * Encrypt the specified connection.
2270  * Status is notified using <b>BTM_ENCRYPTION_STATUS_EVT </b> of #wiced_bt_management_cback_t.
2271  *
2272  *  @param[in]      bd_addr         : Address of peer device
2273  *  @param[in]      transport       : BT_TRANSPORT_BR_EDR or BT_TRANSPORT_LE
2274  *  @param[in]      p_ref_data      : Encryption type #wiced_bt_ble_sec_action_type_t
2275  *
2276  * @return
2277  *
2278  * <b> WICED_BT_SUCCESS </b>     : already encrypted \n
2279  * <b> WICED_BT_PENDING </b>     : command will be returned in the callback \n
2280  * <b> WICED_BT_WRONG_MODE </b>  : connection not up. \n
2281  * <b> WICED_BT_BUSY </b>        : security procedures are currently active
2282  */
2283 wiced_result_t wiced_bt_dev_set_encryption (wiced_bt_device_address_t bd_addr, wiced_bt_transport_t transport, void *p_ref_data);
2284 
2285 
2286 /**
2287  *
2288  * Confirm the numeric value for pairing (in response to <b>BTM_USER_CONFIRMATION_REQUEST_EVT </b> of #wiced_bt_management_cback_t)
2289  *
2290  * @param[in]       res           : result of the operation WICED_BT_SUCCESS if success
2291  * @param[in]       bd_addr       : Address of the peer device
2292  *
2293  * @return          void
2294  */
2295 void wiced_bt_dev_confirm_req_reply(wiced_result_t res, wiced_bt_device_address_t bd_addr);
2296 
2297 /**
2298  *
2299  * Inform remote device of keypress during pairing.
2300  *
2301  * Used during the passkey entry by a device with KeyboardOnly IO capabilities
2302  * (typically a HID keyboard device).
2303  *
2304  * @param[in]       bd_addr : Address of the peer device
2305  * @param[in]       type    : notification type
2306  *
2307  */
2308 void wiced_bt_dev_send_key_press_notif(wiced_bt_device_address_t bd_addr, wiced_bt_dev_passkey_entry_type_t type);
2309 
2310 /**
2311  *
2312  * remove bonding with remote device with assigned bd_addr
2313  * Note: This API cannot be used while being connected to the remote bd_addr
2314  *
2315  * @param[in]      bd_addr :   bd_addr of remote device to be removed from bonding list
2316  *
2317  *
2318  * @return          wiced_result_t
2319  *
2320  */
2321 wiced_result_t wiced_bt_dev_delete_bonded_device(wiced_bt_device_address_t bd_addr);
2322 
2323 /**
2324  *
2325  * Get security flags for the device
2326  *
2327  * @param[in]       bd_addr         : peer address
2328  * @param[out]      p_sec_flags  : security flags (see #wiced_bt_sec_flags_e)
2329  *
2330  * @return          TRUE if successful
2331  *
2332  */
2333 wiced_bool_t wiced_bt_dev_get_security_state(wiced_bt_device_address_t bd_addr, uint8_t *p_sec_flags);
2334 
2335 /**
2336 * @}
2337 */
2338 
2339 /**
2340  * @addtogroup  btm_ble_sec_api_functions        BLE Security
2341  * @if DUAL_MODE
2342  * @ingroup     btm_ble_api_functions
2343  *
2344  * Bluetooth LE security API (authorisation, authentication and encryption)
2345  *
2346  * @note General Security APIs are listed in \ref ble_common_sec_api_functions section.
2347  * @else
2348  * BLE Security API.
2349  * @ingroup   wicedbt_DeviceManagement
2350  * @endif
2351  * @{
2352  */
2353 
2354 /**
2355  *
2356  * get le key mask from stored key information of nv ram
2357  *
2358  * @param[in]      bd_addr    : remote bd address
2359  * @param[out]      p_key_mask    : ble key mask stored
2360  *
2361  * @return          wiced_result_t
2362  *
2363  */
2364 wiced_result_t wiced_bt_dev_get_ble_keys(wiced_bt_device_address_t bd_addr, wiced_bt_dev_le_key_type_t *p_key_mask);
2365 
2366 /**
2367  *
2368  * add link key information to internal address resolution db
2369  *
2370  * @param[in]      p_link_keys    : link keys information stored in application side
2371  *
2372  * @return          wiced_result_t
2373  *
2374  */
2375 wiced_result_t wiced_bt_dev_add_device_to_address_resolution_db(wiced_bt_device_link_keys_t *p_link_keys);
2376 
2377 
2378 /**
2379  *
2380  * remove link key information from internal address resolution db
2381  *
2382  * @param[in]      p_link_keys    : link keys information stored in application side
2383  *
2384  * @return          wiced_result_t
2385  *
2386  */
2387 wiced_result_t wiced_bt_dev_remove_device_from_address_resolution_db(wiced_bt_device_link_keys_t *p_link_keys);
2388 
2389 /**
2390  * get the acl connection handle for bdaddr
2391  *
2392  * @param[in] bdaddr: device identity address
2393  * @param[in] transport: connection transport
2394  *
2395  * @return : acl connection handle
2396  */
2397 uint16_t wiced_bt_dev_get_acl_conn_handle(wiced_bt_device_address_t bdaddr, wiced_bt_transport_t transport);
2398 
2399 /**@} btm_ble_sec_api_functions */
2400 
2401 
2402 #ifdef __cplusplus
2403 }
2404 #endif
2405