summaryrefslogtreecommitdiff
path: root/lib/bt/host/bluedroid/stack/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-03-28 14:32:49 +1100
committerjacqueline <me@jacqueline.id.au>2024-03-28 14:32:49 +1100
commitee29c25b29eaa4fac4e897442634b69ecc8d8125 (patch)
tree8c5f1a140463f20f104316fa3492984e191154e9 /lib/bt/host/bluedroid/stack/include
parent239e6d89507a24c849385f4bfa93ac4ad58e5de5 (diff)
downloadtangara-fw-ee29c25b29eaa4fac4e897442634b69ecc8d8125.tar.gz
Fork ESP-IDF's bluetooth component
i want better sbc encoding, and no cla will stop me
Diffstat (limited to 'lib/bt/host/bluedroid/stack/include')
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/a2d_api.h295
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/a2d_sbc.h193
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/acl_hci_link_interface.h15
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/avct_api.h279
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/avdt_api.h1016
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/avdtc_api.h230
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/avrc_api.h655
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/avrc_defs.h1360
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/bt_types.h781
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/btm_api.h4363
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/btm_ble_api.h2724
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/btu.h311
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/dyn_mem.h234
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/gap_api.h403
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/gatt_api.h1298
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/gattdefs.h128
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/hcidefs.h2730
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/hcimsgs.h1065
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/hidd_api.h273
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/hiddefs.h163
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/hidh_api.h258
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/l2c_api.h1270
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/l2cap_client.h80
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/l2cap_hci_link_interface.h15
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/l2cdefs.h336
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/port_api.h710
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/port_ext.h31
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/profiles_api.h69
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/rfcdefs.h248
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/sdp_api.h726
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/sdpdefs.h325
-rw-r--r--lib/bt/host/bluedroid/stack/include/stack/smp_api.h508
32 files changed, 23092 insertions, 0 deletions
diff --git a/lib/bt/host/bluedroid/stack/include/stack/a2d_api.h b/lib/bt/host/bluedroid/stack/include/stack/a2d_api.h
new file mode 100644
index 00000000..980b4fe4
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/a2d_api.h
@@ -0,0 +1,295 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2000-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * nterface to A2DP Application Programming Interface
+ *
+ ******************************************************************************/
+#ifndef A2D_API_H
+#define A2D_API_H
+#include "common/bt_defs.h"
+#include "stack/sdp_api.h"
+#if (A2D_INCLUDED == TRUE)
+/*****************************************************************************
+** constants
+*****************************************************************************/
+#define A2D_VERSION 0x0102
+#define A2D_VERSION_1_3 0x0103
+#define A2D_VERSION_1_4 0x0104
+
+/* Profile supported features */
+#define A2D_SUPF_PLAYER 0x0001
+#define A2D_SUPF_MIC 0x0002
+#define A2D_SUPF_TUNER 0x0004
+#define A2D_SUPF_MIXER 0x0008
+
+#define A2D_SUPF_HEADPHONE 0x0001
+#define A2D_SUPF_SPEAKER 0x0002
+#define A2D_SUPF_RECORDER 0x0004
+#define A2D_SUPF_AMP 0x0008
+
+/* AV Media Types */
+#define A2D_MEDIA_TYPE_AUDIO 0x00 /* audio media type + RFA */
+#define A2D_MEDIA_TYPE_VIDEO 0x10 /* video media type + RFA */
+#define A2D_MEDIA_TYPE_MULTI 0x20 /* multimedia media type + RFA */
+
+/* AV Media Codec Type (Audio Codec ID) */
+#define A2D_MEDIA_CT_SBC 0x00 /* SBC media codec type */
+#define A2D_MEDIA_CT_M12 0x01 /* MPEG-1, 2 Audio media codec type */
+#define A2D_MEDIA_CT_M24 0x02 /* MPEG-2, 4 AAC media codec type */
+#define A2D_MEDIA_CT_ATRAC 0x04 /* ATRAC family media codec type */
+
+#define A2D_SUCCESS 0 /* Success */
+#define A2D_FAIL 0x0A /* Failed */
+#define A2D_BUSY 0x0B /* A2D_FindService is already in progress */
+#define A2D_INVALID_PARAMS 0x0C /* bad parameters */
+#define A2D_WRONG_CODEC 0x0D /* wrong codec info */
+#define A2D_BAD_CODEC_TYPE 0xC1 /* Media Codec Type is not valid */
+#define A2D_NS_CODEC_TYPE 0xC2 /* Media Codec Type is not supported */
+#define A2D_BAD_SAMP_FREQ 0xC3 /* Sampling Frequency is not valid or multiple values have been selected */
+#define A2D_NS_SAMP_FREQ 0xC4 /* Sampling Frequency is not supported */
+#define A2D_BAD_CH_MODE 0xC5 /* Channel Mode is not valid or multiple values have been selected */
+#define A2D_NS_CH_MODE 0xC6 /* Channel Mode is not supported */
+#define A2D_BAD_SUBBANDS 0xC7 /* None or multiple values have been selected for Number of Subbands */
+#define A2D_NS_SUBBANDS 0xC8 /* Number of Subbands is not supported */
+#define A2D_BAD_ALLOC_MTHD 0xC9 /* None or multiple values have been selected for Allocation Method */
+#define A2D_NS_ALLOC_MTHD 0xCA /* Allocation Method is not supported */
+#define A2D_BAD_MIN_BITPOOL 0xCB /* Minimum Bitpool Value is not valid */
+#define A2D_NS_MIN_BITPOOL 0xCC /* Minimum Bitpool Value is not supported */
+#define A2D_BAD_MAX_BITPOOL 0xCD /* Maximum Bitpool Value is not valid */
+#define A2D_NS_MAX_BITPOOL 0xCE /* Maximum Bitpool Value is not supported */
+#define A2D_BAD_LAYER 0xCF /* None or multiple values have been selected for Layer */
+#define A2D_NS_LAYER 0xD0 /* Layer is not supported */
+#define A2D_NS_CRC 0xD1 /* CRC is not supported */
+#define A2D_NS_MPF 0xD2 /* MPF-2 is not supported */
+#define A2D_NS_VBR 0xD3 /* VBR is not supported */
+#define A2D_BAD_BIT_RATE 0xD4 /* None or multiple values have been selected for Bit Rate */
+#define A2D_NS_BIT_RATE 0xD5 /* Bit Rate is not supported */
+#define A2D_BAD_OBJ_TYPE 0xD6 /* Either 1) Object type is not valid (b3-b0) or 2) None or multiple values have been selected for Object Type */
+#define A2D_NS_OBJ_TYPE 0xD7 /* Object type is not supported */
+#define A2D_BAD_CHANNEL 0xD8 /* None or multiple values have been selected for Channels */
+#define A2D_NS_CHANNEL 0xD9 /* Channels is not supported */
+#define A2D_BAD_BLOCK_LEN 0xDD /* None or multiple values have been selected for Block Length */
+#define A2D_BAD_CP_TYPE 0xE0 /* The requested CP Type is not supported. */
+#define A2D_BAD_CP_FORMAT 0xE1 /* The format of Content Protection Service Capability/Content Protection Scheme Dependent Data is not correct. */
+
+typedef UINT8 tA2D_STATUS;
+
+/* the return values from A2D_BitsSet() */
+#define A2D_SET_ONE_BIT 1 /* one and only one bit is set */
+#define A2D_SET_ZERO_BIT 0 /* all bits clear */
+#define A2D_SET_MULTL_BIT 2 /* multiple bits are set */
+
+/*****************************************************************************
+** type definitions
+*****************************************************************************/
+
+/* This data type is used in A2D_FindService() to initialize the SDP database
+ * to hold the result service search. */
+typedef struct {
+ UINT32 db_len; /* Length, in bytes, of the discovery database */
+ UINT16 num_attr;/* The number of attributes in p_attrs */
+ tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */
+ UINT16 *p_attrs; /* The attributes filter. If NULL, A2DP API sets the attribute filter
+ * to be ATTR_ID_SERVICE_CLASS_ID_LIST, ATTR_ID_BT_PROFILE_DESC_LIST,
+ * ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME and ATTR_ID_PROVIDER_NAME.
+ * If not NULL, the input is taken as the filter. */
+} tA2D_SDP_DB_PARAMS;
+
+/* This data type is used in tA2D_FIND_CBACK to report the result of the SDP discovery process. */
+typedef struct {
+ UINT16 service_len; /* Length, in bytes, of the service name */
+ UINT16 provider_len; /* Length, in bytes, of the provider name */
+ char *p_service_name; /* Pointer the service name. This character string may not be null terminated.
+ * Use the service_len parameter to safely copy this string */
+ char *p_provider_name;/* Pointer the provider name. This character string may not be null terminated.
+ * Use the provider_len parameter to safely copy this string */
+ UINT16 features; /* Profile supported features */
+ UINT16 avdt_version; /* AVDTP protocol version */
+} tA2D_Service;
+
+/* This is the callback to notify the result of the SDP discovery process. */
+typedef void (tA2D_FIND_CBACK)(BOOLEAN found, tA2D_Service *p_service);
+
+
+/*****************************************************************************
+** external function declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/******************************************************************************
+**
+** Function A2D_AddRecord
+**
+** Description This function is called by a server application to add
+** SRC or SNK information to an SDP record. Prior to
+** calling this function the application must call
+** SDP_CreateRecord() to create an SDP record.
+**
+** Input Parameters:
+** service_uuid: Indicates SRC or SNK.
+**
+** p_service_name: Pointer to a null-terminated character
+** string containing the service name.
+**
+** p_provider_name: Pointer to a null-terminated character
+** string containing the provider name.
+**
+** features: Profile supported features.
+**
+** sdp_handle: SDP handle returned by SDP_CreateRecord().
+**
+** Output Parameters:
+** None.
+**
+** Returns A2D_SUCCESS if function execution succeeded,
+** A2D_INVALID_PARAMS if bad parameters are given.
+** A2D_FAIL if function execution failed.
+**
+******************************************************************************/
+extern tA2D_STATUS A2D_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_provider_name,
+ UINT16 features, UINT32 sdp_handle);
+
+/******************************************************************************
+**
+** Function A2D_FindService
+**
+** Description This function is called by a client application to
+** perform service discovery and retrieve SRC or SNK SDP
+** record information from a server. Information is
+** returned for the first service record found on the
+** server that matches the service UUID. The callback
+** function will be executed when service discovery is
+** complete. There can only be one outstanding call to
+** A2D_FindService() at a time; the application must wait
+** for the callback before it makes another call to
+** the function.
+**
+** Input Parameters:
+** service_uuid: Indicates SRC or SNK.
+**
+** bd_addr: BD address of the peer device.
+**
+** p_db: Pointer to the information to initialize
+** the discovery database.
+**
+** p_cback: Pointer to the A2D_FindService()
+** callback function.
+**
+** Output Parameters:
+** None.
+**
+** Returns A2D_SUCCESS if function execution succeeded,
+** A2D_INVALID_PARAMS if bad parameters are given.
+** A2D_BUSY if discovery is already in progress.
+** A2D_FAIL if function execution failed.
+**
+******************************************************************************/
+extern tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
+ tA2D_SDP_DB_PARAMS *p_db, tA2D_FIND_CBACK *p_cback);
+
+/******************************************************************************
+**
+** Function A2D_SetTraceLevel
+**
+** Description Sets the trace level for A2D. If 0xff is passed, the
+** current trace level is returned.
+**
+** Input Parameters:
+** new_level: The level to set the A2D tracing to:
+** 0xff-returns the current setting.
+** 0-turns off tracing.
+** >= 1-Errors.
+** >= 2-Warnings.
+** >= 3-APIs.
+** >= 4-Events.
+** >= 5-Debug.
+**
+** Returns The new trace level or current trace level if
+** the input parameter is 0xff.
+**
+******************************************************************************/
+extern UINT8 A2D_SetTraceLevel (UINT8 new_level);
+
+/******************************************************************************
+** Function A2D_BitsSet
+**
+** Description Check the given num for the number of bits set
+** Returns A2D_SET_ONE_BIT, if one and only one bit is set
+** A2D_SET_ZERO_BIT, if all bits clear
+** A2D_SET_MULTL_BIT, if multiple bits are set
+******************************************************************************/
+extern UINT8 A2D_BitsSet(UINT8 num);
+
+/*******************************************************************************
+**
+** Function A2D_Init
+**
+** Description This function is called at stack startup to allocate the
+** control block (if using dynamic memory), and initializes the
+** control block and tracing level.
+**
+** Returns void
+**
+*******************************************************************************/
+extern bt_status_t A2D_Init(void);
+
+/*******************************************************************************
+**
+** Function A2D_Deinit
+**
+** Description This function is called at stack startup to free the
+** control block (if using dynamic memory), and free the
+** control block and tracing level.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void A2D_Deinit(void);
+
+/*******************************************************************************
+**
+** Function a2d_set_avdt_sdp_ver
+**
+** Description Used for change version of avdtp
+**
+** Returns void
+**
+*******************************************************************************/
+extern void a2d_set_avdt_sdp_ver(UINT16 avdt_sdp_ver);
+
+/*******************************************************************************
+**
+** Function a2d_set_a2dp_sdp_ver
+**
+** Description Used for change version of a2dp
+**
+** Returns void
+**
+*******************************************************************************/
+extern void a2d_set_a2dp_sdp_ver(UINT16 a2dp_sdp_ver);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif ///A2D_INCLUDED
+#endif /* A2D_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/a2d_sbc.h b/lib/bt/host/bluedroid/stack/include/stack/a2d_sbc.h
new file mode 100644
index 00000000..065f264f
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/a2d_sbc.h
@@ -0,0 +1,193 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2000-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * nterface to low complexity subband codec (SBC)
+ *
+ ******************************************************************************/
+#ifndef A2D_SBC_H
+#define A2D_SBC_H
+#if (A2D_INCLUDED == TRUE)
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+/* the length of the SBC Media Payload header. */
+#define A2D_SBC_MPL_HDR_LEN 1
+
+/* the LOSC of SBC media codec capabilitiy */
+#define A2D_SBC_INFO_LEN 6
+
+/* for Codec Specific Information Element */
+#define A2D_SBC_IE_SAMP_FREQ_MSK 0xF0 /* b7-b4 sampling frequency */
+#define A2D_SBC_IE_SAMP_FREQ_16 0x80 /* b7:16 kHz */
+#define A2D_SBC_IE_SAMP_FREQ_32 0x40 /* b6:32 kHz */
+#define A2D_SBC_IE_SAMP_FREQ_44 0x20 /* b5:44.1kHz */
+#define A2D_SBC_IE_SAMP_FREQ_48 0x10 /* b4:48 kHz */
+
+#define A2D_SBC_IE_CH_MD_MSK 0x0F /* b3-b0 channel mode */
+#define A2D_SBC_IE_CH_MD_MONO 0x08 /* b3: mono */
+#define A2D_SBC_IE_CH_MD_DUAL 0x04 /* b2: dual */
+#define A2D_SBC_IE_CH_MD_STEREO 0x02 /* b1: stereo */
+#define A2D_SBC_IE_CH_MD_JOINT 0x01 /* b0: joint stereo */
+
+#define A2D_SBC_IE_BLOCKS_MSK 0xF0 /* b7-b4 number of blocks */
+#define A2D_SBC_IE_BLOCKS_4 0x80 /* 4 blocks */
+#define A2D_SBC_IE_BLOCKS_8 0x40 /* 8 blocks */
+#define A2D_SBC_IE_BLOCKS_12 0x20 /* 12blocks */
+#define A2D_SBC_IE_BLOCKS_16 0x10 /* 16blocks */
+
+#define A2D_SBC_IE_SUBBAND_MSK 0x0C /* b3-b2 number of subbands */
+#define A2D_SBC_IE_SUBBAND_4 0x08 /* b3: 4 */
+#define A2D_SBC_IE_SUBBAND_8 0x04 /* b2: 8 */
+
+#define A2D_SBC_IE_ALLOC_MD_MSK 0x03 /* b1-b0 allocation mode */
+#define A2D_SBC_IE_ALLOC_MD_S 0x02 /* b1: SNR */
+#define A2D_SBC_IE_ALLOC_MD_L 0x01 /* b0: loundess */
+
+#define A2D_SBC_IE_MIN_BITPOOL 2
+#define A2D_SBC_IE_MAX_BITPOOL 250
+
+/* for media payload header */
+#define A2D_SBC_HDR_F_MSK 0x80
+#define A2D_SBC_HDR_S_MSK 0x40
+#define A2D_SBC_HDR_L_MSK 0x20
+#define A2D_SBC_HDR_NUM_MSK 0x0F
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+/* data type for the SBC Codec Information Element*/
+typedef struct {
+ UINT8 samp_freq; /* Sampling frequency */
+ UINT8 ch_mode; /* Channel mode */
+ UINT8 block_len; /* Block length */
+ UINT8 num_subbands; /* Number of subbands */
+ UINT8 alloc_mthd; /* Allocation method */
+ UINT8 max_bitpool; /* Maximum bitpool */
+ UINT8 min_bitpool; /* Minimum bitpool */
+} tA2D_SBC_CIE;
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/******************************************************************************
+**
+** Function A2D_BldSbcInfo
+**
+** Description This function is called by an application to build
+** the SBC Media Codec Capabilities byte sequence
+** beginning from the LOSC octet.
+** Input Parameters:
+** media_type: Indicates Audio, or Multimedia.
+**
+** p_ie: The SBC Codec Information Element information.
+**
+** Output Parameters:
+** p_result: the resulting codec info byte sequence.
+**
+** Returns A2D_SUCCESS if function execution succeeded.
+** Error status code, otherwise.
+******************************************************************************/
+extern tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie,
+ UINT8 *p_result);
+
+/******************************************************************************
+**
+** Function A2D_ParsSbcInfo
+**
+** Description This function is called by an application to parse
+** the SBC Media Codec Capabilities byte sequence
+** beginning from the LOSC octet.
+** Input Parameters:
+** p_info: the byte sequence to parse.
+**
+** for_caps: TRUE, if the byte sequence is for get capabilities response.
+**
+** Output Parameters:
+** p_ie: The SBC Codec Information Element information.
+**
+** Returns A2D_SUCCESS if function execution succeeded.
+** Error status code, otherwise.
+******************************************************************************/
+extern tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info,
+ BOOLEAN for_caps);
+
+/******************************************************************************
+**
+** Function A2D_BldSbcMplHdr
+**
+** Description This function is called by an application to parse
+** the SBC Media Payload header.
+** Input Parameters:
+** frag: 1, if fragmented. 0, otherwise.
+**
+** start: 1, if the starting packet of a fragmented frame.
+**
+** last: 1, if the last packet of a fragmented frame.
+**
+** num: If frag is 1, this is the number of remaining fragments
+** (including this fragment) of this frame.
+** If frag is 0, this is the number of frames in this packet.
+**
+** Output Parameters:
+** p_dst: the resulting media payload header byte sequence.
+**
+** Returns void.
+******************************************************************************/
+extern void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start,
+ BOOLEAN last, UINT8 num);
+
+/******************************************************************************
+**
+** Function A2D_ParsSbcMplHdr
+**
+** Description This function is called by an application to parse
+** the SBC Media Payload header.
+** Input Parameters:
+** p_src: the byte sequence to parse..
+**
+** Output Parameters:
+** frag: 1, if fragmented. 0, otherwise.
+**
+** start: 1, if the starting packet of a fragmented frame.
+**
+** last: 1, if the last packet of a fragmented frame.
+**
+** num: If frag is 1, this is the number of remaining fragments
+** (including this fragment) of this frame.
+** If frag is 0, this is the number of frames in this packet.
+**
+** Returns void.
+******************************************************************************/
+extern void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag,
+ BOOLEAN *p_start, BOOLEAN *p_last,
+ UINT8 *p_num);
+#ifdef __cplusplus
+}
+#endif
+
+#endif ///A2D_INCLUDED == TRUE
+
+#endif /* A2D_SBC_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/acl_hci_link_interface.h b/lib/bt/host/bluedroid/stack/include/stack/acl_hci_link_interface.h
new file mode 100644
index 00000000..f62c654f
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/acl_hci_link_interface.h
@@ -0,0 +1,15 @@
+/*
+ * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef ACL_HCI_LINK_INTERFACE_H
+#define ACL_HCI_LINK_INTERFACE_H
+
+#include "bt_common.h"
+
+void btm_acl_connected(BD_ADDR bda, UINT16 handle, UINT8 link_type, UINT8 enc_mode, UINT8 status);
+void btm_acl_disconnected(UINT16 handle, UINT8 reason);
+
+#endif /* ACL_HCI_LINK_INTERFACE_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/avct_api.h b/lib/bt/host/bluedroid/stack/include/stack/avct_api.h
new file mode 100644
index 00000000..3d59df66
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/avct_api.h
@@ -0,0 +1,279 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This interface file contains the interface to the Audio Video Control
+ * Transport Protocol (AVCTP).
+ *
+ ******************************************************************************/
+#ifndef AVCT_API_H
+#define AVCT_API_H
+
+#include "stack/bt_types.h"
+#include "common/bt_target.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+/* API function return value result codes. */
+#define AVCT_SUCCESS 0 /* Function successful */
+#define AVCT_NO_RESOURCES 1 /* Not enough resources */
+#define AVCT_BAD_HANDLE 2 /* Bad handle */
+#define AVCT_PID_IN_USE 3 /* PID already in use */
+#define AVCT_NOT_OPEN 4 /* Connection not open */
+
+/* PSM for AVCT. */
+#define AVCT_PSM 0x0017
+#define AVCT_BR_PSM 0x001B
+
+/* Protocol revision numbers */
+#define AVCT_REV_1_0 0x0100
+#define AVCT_REV_1_2 0x0102
+#define AVCT_REV_1_3 0x0103
+#define AVCT_REV_1_4 0x0104
+
+/* the layer_specific settings */
+#define AVCT_DATA_CTRL 0x0001 /* for the control channel */
+#define AVCT_DATA_BROWSE 0x0002 /* for the browsing channel */
+#define AVCT_DATA_PARTIAL 0x0100 /* Only have room for a partial message */
+
+#define AVCT_MIN_CONTROL_MTU 48 /* Per the AVRC spec, minimum MTU for the control channel */
+#define AVCT_MIN_BROWSE_MTU 335 /* Per the AVRC spec, minimum MTU for the browsing channel */
+
+/* Message offset. The number of bytes needed by the protocol stack for the
+** protocol headers of an AVCTP message packet.
+*/
+#define AVCT_MSG_OFFSET 15
+#define AVCT_BROWSE_OFFSET 17 /* the default offset for browsing channel */
+
+/* Connection role. */
+#define AVCT_INT 0 /* Initiator connection */
+#define AVCT_ACP 1 /* Acceptor connection */
+
+/* Control role. */
+#define AVCT_TARGET 1 /* target */
+#define AVCT_CONTROL 2 /* controller */
+#define AVCT_PASSIVE 4 /* If conflict, allow the other side to succeed */
+
+/* Command/Response indicator. */
+#define AVCT_CMD 0 /* Command message */
+#define AVCT_RSP 2 /* Response message */
+#define AVCT_REJ 3 /* Message rejected */
+
+/* Control callback events. */
+#define AVCT_CONNECT_CFM_EVT 0 /* Connection confirm */
+#define AVCT_CONNECT_IND_EVT 1 /* Connection indication */
+#define AVCT_DISCONNECT_CFM_EVT 2 /* Disconnect confirm */
+#define AVCT_DISCONNECT_IND_EVT 3 /* Disconnect indication */
+#define AVCT_CONG_IND_EVT 4 /* Congestion indication */
+#define AVCT_UNCONG_IND_EVT 5 /* Uncongestion indication */
+#define AVCT_BROWSE_CONN_CFM_EVT 6 /* Browse Connection confirm */
+#define AVCT_BROWSE_CONN_IND_EVT 7 /* Browse Connection indication */
+#define AVCT_BROWSE_DISCONN_CFM_EVT 8 /* Browse Disconnect confirm */
+#define AVCT_BROWSE_DISCONN_IND_EVT 9 /* Browse Disconnect indication */
+#define AVCT_BROWSE_CONG_IND_EVT 10 /* Congestion indication */
+#define AVCT_BROWSE_UNCONG_IND_EVT 11 /* Uncongestion indication */
+
+
+/* General purpose failure result code for callback events. */
+#define AVCT_RESULT_FAIL 5
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+/* Control callback function. */
+typedef void (tAVCT_CTRL_CBACK)(UINT8 handle, UINT8 event, UINT16 result,
+ BD_ADDR peer_addr);
+
+/* Message callback function */
+/* p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE */
+typedef void (tAVCT_MSG_CBACK)(UINT8 handle, UINT8 label, UINT8 cr,
+ BT_HDR *p_pkt);
+
+/* Structure used by AVCT_CreateConn. */
+typedef struct {
+ tAVCT_CTRL_CBACK *p_ctrl_cback; /* Control callback */
+ tAVCT_MSG_CBACK *p_msg_cback; /* Message callback */
+ UINT16 pid; /* Profile ID */
+ UINT8 role; /* Initiator/acceptor role */
+ UINT8 control; /* Control role (Control/Target) */
+} tAVCT_CC;
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function AVCT_Register
+**
+** Description This is the system level registration function for the
+** AVCTP protocol. This function initializes AVCTP and
+** prepares the protocol stack for its use. This function
+** must be called once by the system or platform using AVCTP
+** before the other functions of the API an be used.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask);
+
+/*******************************************************************************
+**
+** Function AVCT_Deregister
+**
+** Description This function is called to deregister use AVCTP protocol.
+** It is called when AVCTP is no longer being used by any
+** application in the system. Before this function can be
+** called, all connections must be removed with
+** AVCT_RemoveConn().
+**
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVCT_Deregister(void);
+
+/*******************************************************************************
+**
+** Function AVCT_CreateConn
+**
+** Description Create an AVCTP connection. There are two types of
+** connections, initiator and acceptor, as determined by
+** the p_cc->role parameter. When this function is called to
+** create an initiator connection, an AVCTP connection to
+** the peer device is initiated if one does not already exist.
+** If an acceptor connection is created, the connection waits
+** passively for an incoming AVCTP connection from a peer device.
+**
+**
+** Returns AVCT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVCT_CreateConn(UINT8 *p_handle, tAVCT_CC *p_cc,
+ BD_ADDR peer_addr);
+
+/*******************************************************************************
+**
+** Function AVCT_RemoveConn
+**
+** Description Remove an AVCTP connection. This function is called when
+** the application is no longer using a connection. If this
+** is the last connection to a peer the L2CAP channel for AVCTP
+** will be closed.
+**
+**
+** Returns AVCT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVCT_RemoveConn(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVCT_CreateBrowse
+**
+** Description Create an AVCTP connection. There are two types of
+** connections, initiator and acceptor, as determined by
+** the p_cc->role parameter. When this function is called to
+** create an initiator connection, an AVCTP connection to
+** the peer device is initiated if one does not already exist.
+** If an acceptor connection is created, the connection waits
+** passively for an incoming AVCTP connection from a peer device.
+**
+**
+** Returns AVCT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVCT_CreateBrowse(UINT8 handle, UINT8 role);
+
+/*******************************************************************************
+**
+** Function AVCT_RemoveBrowse
+**
+** Description Remove an AVCTP connection. This function is called when
+** the application is no longer using a connection. If this
+** is the last connection to a peer the L2CAP channel for AVCTP
+** will be closed.
+**
+**
+** Returns AVCT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVCT_RemoveBrowse(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVCT_GetBrowseMtu
+**
+** Description Get the peer_mtu for the AVCTP Browse channel of the given
+** connection.
+**
+** Returns the peer browsing channel MTU.
+**
+*******************************************************************************/
+extern UINT16 AVCT_GetBrowseMtu (UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVCT_GetPeerMtu
+**
+** Description Get the peer_mtu for the AVCTP channel of the given
+** connection.
+**
+** Returns the peer MTU size.
+**
+*******************************************************************************/
+extern UINT16 AVCT_GetPeerMtu (UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVCT_MsgReq
+**
+** Description Send an AVCTP message to a peer device. In calling
+** AVCT_MsgReq(), the application should keep track of the
+** congestion state of AVCTP as communicated with events
+** AVCT_CONG_IND_EVT and AVCT_UNCONG_IND_EVT. If the
+** application calls AVCT_MsgReq() when AVCTP is congested
+** the message may be discarded. The application may make its
+** first call to AVCT_MsgReq() after it receives an
+** AVCT_CONNECT_CFM_EVT or AVCT_CONNECT_IND_EVT on control channel or
+** AVCT_BROWSE_CONN_CFM_EVT or AVCT_BROWSE_CONN_IND_EVT on browsing channel.
+**
+** p_msg->layer_specific must be set to
+** AVCT_DATA_CTRL for control channel traffic;
+** AVCT_DATA_BROWSE for for browse channel traffic.
+**
+** Returns AVCT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* AVCT_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/avdt_api.h b/lib/bt/host/bluedroid/stack/include/stack/avdt_api.h
new file mode 100644
index 00000000..42a1f855
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/avdt_api.h
@@ -0,0 +1,1016 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2002-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This interface file contains the interface to the Audio Video
+ * Distribution Transport Protocol (AVDTP).
+ *
+ ******************************************************************************/
+#ifndef AVDT_API_H
+#define AVDT_API_H
+
+#include "stack/bt_types.h"
+#include "common/bt_target.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+#ifndef AVDT_VERSION
+#define AVDT_VERSION 0x0102
+#endif
+#define AVDT_VERSION_SYNC 0x0103
+
+/* API function return value result codes. */
+#define AVDT_SUCCESS 0 /* Function successful */
+#define AVDT_BAD_PARAMS 1 /* Invalid parameters */
+#define AVDT_NO_RESOURCES 2 /* Not enough resources */
+#define AVDT_BAD_HANDLE 3 /* Bad handle */
+#define AVDT_BUSY 4 /* A procedure is already in progress */
+#define AVDT_WRITE_FAIL 5 /* Write failed */
+
+/* The index to access the codec type in codec_info[]. */
+#define AVDT_CODEC_TYPE_INDEX 2
+
+/* The size in bytes of a Adaptation Layer header. */
+#define AVDT_AL_HDR_SIZE 3
+
+/* The size in bytes of a media packet header. */
+#define AVDT_MEDIA_HDR_SIZE 12
+
+/* AVDTP 7.5.3 Adaptation Layer Fragmentation
+ * original length of the un-fragmented transport packet should be specified by
+ * two bytes length field of Adaptation Layer Header */
+#define AVDT_MAX_MEDIA_SIZE (0xFFFF - AVDT_MEDIA_HDR_SIZE)
+
+/* The handle is used when reporting MULTI_AV specific events */
+#define AVDT_MULTI_AV_HANDLE 0xFF
+
+/* The number of bytes needed by the protocol stack for the protocol headers
+** of a media packet. This is the size of the media packet header, the
+** L2CAP packet header and HCI header.
+*/
+#define AVDT_MEDIA_OFFSET 23
+
+/* The marker bit is used by the application to mark significant events such
+** as frame boundaries in the data stream. This constant is used to check or
+** set the marker bit in the m_pt parameter of an AVDT_WriteReq()
+** or AVDT_DATA_IND_EVT.
+*/
+#define AVDT_MARKER_SET 0x80
+
+/* SEP Type. This indicates the stream endpoint type. */
+#define AVDT_TSEP_SRC 0 /* Source SEP */
+#define AVDT_TSEP_SNK 1 /* Sink SEP */
+
+/* initiator/acceptor role for adaption */
+#define AVDT_INT 0 /* initiator */
+#define AVDT_ACP 1 /* acceptor */
+
+/* Media Type. This indicates the media type of the stream endpoint. */
+#define AVDT_MEDIA_AUDIO 0 /* Audio SEP */
+#define AVDT_MEDIA_VIDEO 1 /* Video SEP */
+#define AVDT_MEDIA_MULTI 2 /* Multimedia SEP */
+
+/* for reporting packets */
+#define AVDT_RTCP_PT_SR 200 /* the packet type - SR (Sender Report) */
+#define AVDT_RTCP_PT_RR 201 /* the packet type - RR (Receiver Report) */
+#define AVDT_RTCP_PT_SDES 202 /* the packet type - SDES (Source Description) */
+typedef UINT8 AVDT_REPORT_TYPE;
+
+#define AVDT_RTCP_SDES_CNAME 1 /* SDES item CNAME */
+#ifndef AVDT_MAX_CNAME_SIZE
+#define AVDT_MAX_CNAME_SIZE 28
+#endif
+
+/* Protocol service capabilities. This indicates the protocol service
+** capabilities of a stream endpoint. This value is a mask.
+** Multiple values can be combined with a bitwise OR.
+*/
+#define AVDT_PSC_TRANS (1<<1) /* Media transport */
+#define AVDT_PSC_REPORT (1<<2) /* Reporting */
+#define AVDT_PSC_RECOV (1<<3) /* Recovery */
+#define AVDT_PSC_HDRCMP (1<<5) /* Header compression */
+#define AVDT_PSC_MUX (1<<6) /* Multiplexing */
+#define AVDT_PSC_DELAY_RPT (1<<8) /* Delay Report */
+
+/* Max audio per 3-DH5 EDR packet: 23.2ms
+** jitter buffer: 5(JITTER_BUFFER_WATER_LEVEL)
+*/
+#define AVDT_DELAY_RPT_DFT_VALUE 1200 /* 120 ms */
+#define AVDT_DELAY_RPT_TIMER_TICK_MS 2000 /* 2000 ms */
+
+/* Recovery type. This indicates the recovery type. */
+#define AVDT_RECOV_RFC2733 1 /* RFC2733 recovery */
+
+/* Header compression capabilities. This indicates the header compression
+** capabilities. This value is a mask. Multiple values can be combined
+** with a bitwise OR.
+*/
+#define AVDT_HDRCMP_MEDIA (1<<5) /* Available for media packets */
+#define AVDT_HDRCMP_RECOV (1<<6) /* Available for recovery packets */
+#define AVDT_HDRCMP_BACKCH (1<<7) /* Back channel supported */
+
+/* Multiplexing capabilities mask. */
+#define AVDT_MUX_FRAG (1<<7) /* Allow Adaptation Layer Fragmentation */
+
+/* Application service category. This indicates the application
+** service category.
+*/
+#define AVDT_ASC_PROTECT 4 /* Content protection */
+#define AVDT_ASC_CODEC 7 /* Codec */
+
+/* Error codes. The following are error codes defined in the AVDTP and GAVDP
+** specifications. These error codes communicate protocol errors between
+** AVDTP and the application. More detailed descriptions of the error codes
+** and their appropriate use can be found in the AVDTP and GAVDP specifications.
+** These error codes are unrelated to the result values returned by the
+** AVDTP API functions.
+*/
+#define AVDT_ERR_HEADER 0x01 /* Bad packet header format */
+#define AVDT_ERR_LENGTH 0x11 /* Bad packet length */
+#define AVDT_ERR_SEID 0x12 /* Invalid SEID */
+#define AVDT_ERR_IN_USE 0x13 /* The SEP is in use */
+#define AVDT_ERR_NOT_IN_USE 0x14 /* The SEP is not in use */
+#define AVDT_ERR_CATEGORY 0x17 /* Bad service category */
+#define AVDT_ERR_PAYLOAD 0x18 /* Bad payload format */
+#define AVDT_ERR_NSC 0x19 /* Requested command not supported */
+#define AVDT_ERR_INVALID_CAP 0x1A /* Reconfigure attempted invalid capabilities */
+#define AVDT_ERR_RECOV_TYPE 0x22 /* Requested recovery type not defined */
+#define AVDT_ERR_MEDIA_TRANS 0x23 /* Media transport capability not correct */
+#define AVDT_ERR_RECOV_FMT 0x25 /* Recovery service capability not correct */
+#define AVDT_ERR_ROHC_FMT 0x26 /* Header compression service capability not correct */
+#define AVDT_ERR_CP_FMT 0x27 /* Content protection service capability not correct */
+#define AVDT_ERR_MUX_FMT 0x28 /* Multiplexing service capability not correct */
+#define AVDT_ERR_UNSUP_CFG 0x29 /* Configuration not supported */
+#define AVDT_ERR_BAD_STATE 0x31 /* Message cannot be processed in this state */
+#define AVDT_ERR_REPORT_FMT 0x65 /* Report service capability not correct */
+#define AVDT_ERR_SERVICE 0x80 /* Invalid service category */
+#define AVDT_ERR_RESOURCE 0x81 /* Insufficient resources */
+#define AVDT_ERR_INVALID_MCT 0xC1 /* Invalid Media Codec Type */
+#define AVDT_ERR_UNSUP_MCT 0xC2 /* Unsupported Media Codec Type */
+#define AVDT_ERR_INVALID_LEVEL 0xC3 /* Invalid Level */
+#define AVDT_ERR_UNSUP_LEVEL 0xC4 /* Unsupported Level */
+#define AVDT_ERR_INVALID_CP 0xE0 /* Invalid Content Protection Type */
+#define AVDT_ERR_INVALID_FORMAT 0xE1 /* Invalid Content Protection format */
+
+/* Additional error codes. This indicates error codes used by AVDTP
+** in addition to the ones defined in the specifications.
+*/
+#define AVDT_ERR_CONNECT 0x07 /* Connection failed. */
+#define AVDT_ERR_TIMEOUT 0x08 /* Response timeout. */
+
+/* Control callback events. */
+#define AVDT_DISCOVER_CFM_EVT 0 /* Discover confirm */
+#define AVDT_GETCAP_CFM_EVT 1 /* Get capabilities confirm */
+#define AVDT_OPEN_CFM_EVT 2 /* Open confirm */
+#define AVDT_OPEN_IND_EVT 3 /* Open indication */
+#define AVDT_CONFIG_IND_EVT 4 /* Configuration indication */
+#define AVDT_START_CFM_EVT 5 /* Start confirm */
+#define AVDT_START_IND_EVT 6 /* Start indication */
+#define AVDT_SUSPEND_CFM_EVT 7 /* Suspend confirm */
+#define AVDT_SUSPEND_IND_EVT 8 /* Suspend indication */
+#define AVDT_CLOSE_CFM_EVT 9 /* Close confirm */
+#define AVDT_CLOSE_IND_EVT 10 /* Close indication */
+#define AVDT_RECONFIG_CFM_EVT 11 /* Reconfiguration confirm */
+#define AVDT_RECONFIG_IND_EVT 12 /* Reconfiguration indication */
+#define AVDT_SECURITY_CFM_EVT 13 /* Security confirm */
+#define AVDT_SECURITY_IND_EVT 14 /* Security indication */
+#define AVDT_WRITE_CFM_EVT 15 /* Write confirm */
+#define AVDT_CONNECT_IND_EVT 16 /* Signaling channel connected */
+#define AVDT_DISCONNECT_IND_EVT 17 /* Signaling channel disconnected */
+#define AVDT_REPORT_CONN_EVT 18 /* Reporting channel connected */
+#define AVDT_REPORT_DISCONN_EVT 19 /* Reporting channel disconnected */
+#define AVDT_DELAY_REPORT_EVT 20 /* Delay report received */
+#define AVDT_DELAY_REPORT_CFM_EVT 21 /* Delay report response received */
+
+#define AVDT_MAX_EVT (AVDT_DELAY_REPORT_CFM_EVT)
+
+/* PSM for AVDT */
+#define AVDT_PSM 0x0019
+
+/* Nonsupported protocol command messages. This value is used in tAVDT_CS */
+#define AVDT_NSC_SUSPEND 0x01 /* Suspend command not supported */
+#define AVDT_NSC_RECONFIG 0x02 /* Reconfigure command not supported */
+#define AVDT_NSC_SECURITY 0x04 /* Security command not supported */
+
+/* AVDT disconnection reason */
+#define AVDT_DISC_RSN_NORMAL 0
+#define AVDT_DISC_RSN_ABNORMAL (0xce) /* unintentional disconnection */
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+typedef struct {
+ UINT32 ntp_sec; /* NTP time: seconds relative to 0h UTC on 1 January 1900 */
+ UINT32 ntp_frac; /* NTP time: the fractional part */
+ UINT32 rtp_time; /* timestamp in RTP header */
+ UINT32 pkt_count; /* sender's packet count: since starting transmission
+ * up until the time this SR packet was generated. */
+ UINT32 octet_count; /* sender's octet count: same comment */
+} tAVDT_SENDER_INFO;
+
+typedef struct {
+ UINT8 frag_lost; /* fraction lost since last RR */
+ UINT32 packet_lost; /* cumulative number of packets lost since the beginning */
+ UINT32 seq_num_rcvd; /* extended highest sequence number received */
+ UINT32 jitter; /* interarrival jitter */
+ UINT32 lsr; /* last SR timestamp */
+ UINT32 dlsr; /* delay since last SR */
+} tAVDT_REPORT_BLK;
+
+typedef union {
+ tAVDT_SENDER_INFO sr;
+ tAVDT_REPORT_BLK rr;
+ UINT8 cname[AVDT_MAX_CNAME_SIZE + 1];
+} tAVDT_REPORT_DATA;
+
+/* This structure contains parameters which are set at registration. */
+typedef struct {
+ UINT16 ctrl_mtu; /* L2CAP MTU of the AVDTP signaling channel */
+ UINT8 ret_tout; /* AVDTP signaling retransmission timeout */
+ UINT8 sig_tout; /* AVDTP signaling message timeout */
+ UINT8 idle_tout; /* AVDTP idle signaling channel timeout */
+ UINT8 sec_mask; /* Security mask for BTM_SetSecurityLevel() */
+} tAVDT_REG;
+
+/* This structure contains the SEP information. This information is
+** transferred during the discovery procedure.
+*/
+typedef struct {
+ BOOLEAN in_use; /* TRUE if stream is currently in use */
+ UINT8 seid; /* Stream endpoint identifier */
+ UINT8 media_type; /* Media type */
+ UINT8 tsep; /* SEP type */
+} tAVDT_SEP_INFO;
+
+/* This structure contains the SEP configuration. */
+typedef struct {
+ UINT8 codec_info[AVDT_CODEC_SIZE]; /* Codec capabilities array */
+ UINT8 protect_info[AVDT_PROTECT_SIZE]; /* Content protection capabilities */
+ UINT8 num_codec; /* Number of media codec information elements */
+ UINT8 num_protect; /* Number of content protection information elements */
+ UINT16 psc_mask; /* Protocol service capabilities mask */
+ UINT8 recov_type; /* Recovery type */
+ UINT8 recov_mrws; /* Maximum recovery window size */
+ UINT8 recov_mnmp; /* Recovery maximum number of media packets */
+ UINT8 hdrcmp_mask; /* Header compression capabilities */
+#if AVDT_MULTIPLEXING == TRUE
+ UINT8 mux_mask; /* Multiplexing capabilities. AVDT_MUX_XXX bits can be combined with a bitwise OR */
+ UINT8 mux_tsid_media; /* TSID for media transport session */
+ UINT8 mux_tcid_media; /* TCID for media transport session */
+ UINT8 mux_tsid_report; /* TSID for reporting transport session */
+ UINT8 mux_tcid_report; /* TCID for reporting transport session */
+ UINT8 mux_tsid_recov; /* TSID for recovery transport session */
+ UINT8 mux_tcid_recov; /* TCID for recovery transport session */
+#endif
+} tAVDT_CFG;
+
+/* Header structure for callback event parameters. */
+typedef struct {
+ UINT8 err_code; /* Zero if operation succeeded; nonzero if operation failed */
+ UINT8 err_param; /* Error parameter included for some events */
+ UINT8 label; /* Transaction label */
+ UINT8 seid; /* For internal use only */
+ UINT8 sig_id; /* For internal use only */
+ UINT8 ccb_idx; /* For internal use only */
+} tAVDT_EVT_HDR;
+
+/* This data structure is associated with the AVDT_GETCAP_CFM_EVT,
+** AVDT_RECONFIG_IND_EVT, and AVDT_RECONFIG_CFM_EVT.
+*/
+typedef struct {
+ tAVDT_EVT_HDR hdr; /* Event header */
+ tAVDT_CFG *p_cfg; /* Pointer to configuration for this SEP */
+} tAVDT_CONFIG;
+
+/* This data structure is associated with the AVDT_CONFIG_IND_EVT. */
+typedef struct {
+ tAVDT_EVT_HDR hdr; /* Event header */
+ tAVDT_CFG *p_cfg; /* Pointer to configuration for this SEP */
+ UINT8 int_seid; /* Stream endpoint ID of stream initiating the operation */
+} tAVDT_SETCONFIG;
+
+/* This data structure is associated with the AVDT_OPEN_IND_EVT and AVDT_OPEN_CFM_EVT. */
+typedef struct {
+ tAVDT_EVT_HDR hdr; /* Event header */
+ UINT16 peer_mtu; /* Transport channel L2CAP MTU of the peer */
+ UINT16 lcid; /* L2CAP LCID for media channel */
+} tAVDT_OPEN;
+
+/* This data structure is associated with the AVDT_SECURITY_IND_EVT
+** and AVDT_SECURITY_CFM_EVT.
+*/
+typedef struct {
+ tAVDT_EVT_HDR hdr; /* Event header */
+ UINT8 *p_data; /* Pointer to security data */
+ UINT16 len; /* Length in bytes of the security data */
+} tAVDT_SECURITY;
+
+/* This data structure is associated with the AVDT_DISCOVER_CFM_EVT. */
+typedef struct {
+ tAVDT_EVT_HDR hdr; /* Event header */
+ tAVDT_SEP_INFO *p_sep_info; /* Pointer to SEP information */
+ UINT8 num_seps; /* Number of stream endpoints */
+} tAVDT_DISCOVER;
+
+/* This data structure is associated with the AVDT_DELAY_REPORT_EVT. */
+typedef struct {
+ tAVDT_EVT_HDR hdr; /* Event header */
+ UINT16 delay; /* Delay value */
+} tAVDT_DELAY_RPT;
+
+/* Union of all control callback event data structures */
+typedef union {
+ tAVDT_EVT_HDR hdr;
+ tAVDT_DISCOVER discover_cfm;
+ tAVDT_CONFIG getcap_cfm;
+ tAVDT_OPEN open_cfm;
+ tAVDT_OPEN open_ind;
+ tAVDT_SETCONFIG config_ind;
+ tAVDT_EVT_HDR start_cfm;
+ tAVDT_EVT_HDR suspend_cfm;
+ tAVDT_EVT_HDR close_cfm;
+ tAVDT_CONFIG reconfig_cfm;
+ tAVDT_CONFIG reconfig_ind;
+ tAVDT_SECURITY security_cfm;
+ tAVDT_SECURITY security_ind;
+ tAVDT_EVT_HDR connect_ind;
+ tAVDT_EVT_HDR disconnect_ind;
+ tAVDT_EVT_HDR report_conn;
+ tAVDT_DELAY_RPT delay_rpt_cmd;
+} tAVDT_CTRL;
+
+/* This is the control callback function. This function passes control events
+** to the application. This function is required for all registered stream
+** endpoints and for the AVDT_DiscoverReq() and AVDT_GetCapReq() functions.
+**
+*/
+typedef void (tAVDT_CTRL_CBACK)(UINT8 handle, BD_ADDR bd_addr, UINT8 event,
+ tAVDT_CTRL *p_data);
+
+/* This is the data callback function. It is executed when AVDTP has a media
+** packet ready for the application. This function is required for SNK
+** endpoints and not applicable for SRC endpoints.
+*/
+typedef void (tAVDT_DATA_CBACK)(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
+ UINT8 m_pt);
+
+#if AVDT_MULTIPLEXING == TRUE
+/* This is the second version of the data callback function. This version uses
+** application buffer assigned by AVDT_SetMediaBuf. Caller can assign different
+** buffer during callback or can leave the current buffer for further using.
+** This callback is called when AVDTP has a media packet ready for the application.
+** This function is required for SNK endpoints and not applicable for SRC endpoints.
+*/
+typedef void (tAVDT_MEDIA_CBACK)(UINT8 handle, UINT8 *p_payload, UINT32 payload_len,
+ UINT32 time_stamp, UINT16 seq_num, UINT8 m_pt, UINT8 marker);
+#endif
+
+#if AVDT_REPORTING == TRUE
+/* This is the report callback function. It is executed when AVDTP has a reporting
+** packet ready for the application. This function is required for streams
+** created with AVDT_PSC_REPORT.
+*/
+typedef void (tAVDT_REPORT_CBACK)(UINT8 handle, AVDT_REPORT_TYPE type,
+ tAVDT_REPORT_DATA *p_data);
+#endif
+
+typedef UINT16 (tAVDT_GETCAP_REQ) (BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, tAVDT_CTRL_CBACK *p_cback);
+
+/* This structure contains information required when a stream is created.
+** It is passed to the AVDT_CreateStream() function.
+*/
+typedef struct {
+ tAVDT_CFG cfg; /* SEP configuration */
+ tAVDT_CTRL_CBACK *p_ctrl_cback; /* Control callback function */
+ tAVDT_DATA_CBACK *p_data_cback; /* Data callback function */
+#if AVDT_MULTIPLEXING == TRUE
+ tAVDT_MEDIA_CBACK *p_media_cback; /* Media callback function. It will be called only if p_data_cback is NULL */
+#endif
+#if AVDT_REPORTING == TRUE
+ tAVDT_REPORT_CBACK *p_report_cback;/* Report callback function. */
+#endif
+ UINT16 mtu; /* The L2CAP MTU of the transport channel */
+ UINT16 flush_to; /* The L2CAP flush timeout of the transport channel */
+ UINT8 tsep; /* SEP type */
+ UINT8 media_type; /* Media type */
+ UINT16 nsc_mask; /* Nonsupported protocol command messages */
+} tAVDT_CS;
+
+/* AVDT data option mask is used in the write request */
+#define AVDT_DATA_OPT_NONE 0x00 /* No option still add RTP header */
+#define AVDT_DATA_OPT_NO_RTP (0x01 << 0) /* Skip adding RTP header */
+
+typedef UINT8 tAVDT_DATA_OPT_MASK;
+
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function AVDT_Register
+**
+** Description This is the system level registration function for the
+** AVDTP protocol. This function initializes AVDTP and
+** prepares the protocol stack for its use. This function
+** must be called once by the system or platform using AVDTP
+** before the other functions of the API an be used.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function AVDT_Deregister
+**
+** Description This function is called to deregister use AVDTP protocol.
+** It is called when AVDTP is no longer being used by any
+** application in the system. Before this function can be
+** called, all streams must be removed with AVDT_RemoveStream().
+**
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDT_Deregister(void);
+
+
+/*******************************************************************************
+**
+** Function AVDT_SINK_Activate
+**
+** Description Activate SEP of A2DP Sink. In Use parameter is adjusted.
+** In Use will be made false in case of activation. A2DP SRC
+** will receive in_use as false and can open A2DP Sink
+** connection
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDT_SINK_Activate(void);
+
+/*******************************************************************************
+**
+** Function AVDT_SINK_Deactivate
+**
+** Description Deactivate SEP of A2DP Sink. In Use parameter is adjusted.
+** In Use will be made TRUE in case of activation. A2DP SRC
+** will receive in_use as true and will not open A2DP Sink
+** connection
+**
+** Returns void.
+**
+*******************************************************************************/
+extern void AVDT_SINK_Deactivate(void);
+
+/*******************************************************************************
+**
+** Function AVDT_AbortReq
+**
+** Description Trigger Abort request to pass AVDTP Abort related mandatory
+** PTS Test case.
+**
+** Returns void.
+**
+*******************************************************************************/
+extern void AVDT_AbortReq(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDT_CreateStream
+**
+** Description Create a stream endpoint. After a stream endpoint is
+** created an application can initiate a connection between
+** this endpoint and an endpoint on a peer device. In
+** addition, a peer device can discover, get the capabilities,
+** and connect to this endpoint.
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs);
+
+/*******************************************************************************
+**
+** Function AVDT_RemoveStream
+**
+** Description Remove a stream endpoint. This function is called when
+** the application is no longer using a stream endpoint.
+** If this function is called when the endpoint is connected
+** the connection is closed and then the stream endpoint
+** is removed.
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_RemoveStream(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDT_DiscoverReq
+**
+** Description This function initiates a connection to the AVDTP service
+** on the peer device, if not already present, and discovers
+** the stream endpoints on the peer device. (Please note
+** that AVDTP discovery is unrelated to SDP discovery).
+** This function can be called at any time regardless of whether
+** there is an AVDTP connection to the peer device.
+**
+** When discovery is complete, an AVDT_DISCOVER_CFM_EVT
+** is sent to the application via its callback function.
+** The application must not call AVDT_GetCapReq() or
+** AVDT_DiscoverReq() again to the same device until
+** discovery is complete.
+**
+** The memory addressed by sep_info is allocated by the
+** application. This memory is written to by AVDTP as part
+** of the discovery procedure. This memory must remain
+** accessible until the application receives the
+** AVDT_DISCOVER_CFM_EVT.
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info,
+ UINT8 max_seps, tAVDT_CTRL_CBACK *p_cback);
+
+
+/*******************************************************************************
+**
+** Function AVDT_GetCapReq
+**
+** Description This function initiates a connection to the AVDTP service
+** on the peer device, if not already present, and gets the
+** capabilities of a stream endpoint on the peer device.
+** This function can be called at any time regardless of
+** whether there is an AVDTP connection to the peer device.
+**
+** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is
+** sent to the application via its callback function. The
+** application must not call AVDT_GetCapReq() or
+** AVDT_DiscoverReq() again until the procedure is complete.
+**
+** The memory pointed to by p_cfg is allocated by the
+** application. This memory is written to by AVDTP as part
+** of the get capabilities procedure. This memory must
+** remain accessible until the application receives
+** the AVDT_GETCAP_CFM_EVT.
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg,
+ tAVDT_CTRL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function AVDT_GetAllCapReq
+**
+** Description This function initiates a connection to the AVDTP service
+** on the peer device, if not already present, and gets the
+** capabilities of a stream endpoint on the peer device.
+** This function can be called at any time regardless of
+** whether there is an AVDTP connection to the peer device.
+**
+** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is
+** sent to the application via its callback function. The
+** application must not call AVDT_GetCapReq() or
+** AVDT_DiscoverReq() again until the procedure is complete.
+**
+** The memory pointed to by p_cfg is allocated by the
+** application. This memory is written to by AVDTP as part
+** of the get capabilities procedure. This memory must
+** remain accessible until the application receives
+** the AVDT_GETCAP_CFM_EVT.
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg,
+ tAVDT_CTRL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function AVDT_DelayReport
+**
+** Description This functions sends a Delay Report to the peer device
+** that is associated with a particular SEID.
+** This function is called by SNK device.
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay);
+
+/*******************************************************************************
+**
+** Function AVDT_OpenReq
+**
+** Description This function initiates a connection to the AVDTP service
+** on the peer device, if not already present, and connects
+** to a stream endpoint on a peer device. When the connection
+** is completed, an AVDT_OPEN_CFM_EVT is sent to the
+** application via the control callback function for this handle.
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid,
+ tAVDT_CFG *p_cfg);
+
+
+/*******************************************************************************
+**
+** Function AVDT_ConfigRsp
+**
+** Description Respond to a configure request from the peer device. This
+** function must be called if the application receives an
+** AVDT_CONFIG_IND_EVT through its control callback.
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code,
+ UINT8 category);
+
+/*******************************************************************************
+**
+** Function AVDT_StartReq
+**
+** Description Start one or more stream endpoints. This initiates the
+** transfer of media packets for the streams. All stream
+** endpoints must previously be opened. When the streams
+** are started, an AVDT_START_CFM_EVT is sent to the
+** application via the control callback function for each stream.
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles);
+
+/*******************************************************************************
+**
+** Function AVDT_SuspendReq
+**
+** Description Suspend one or more stream endpoints. This suspends the
+** transfer of media packets for the streams. All stream
+** endpoints must previously be open and started. When the
+** streams are suspended, an AVDT_SUSPEND_CFM_EVT is sent to
+** the application via the control callback function for
+** each stream.
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles);
+
+/*******************************************************************************
+**
+** Function AVDT_CloseReq
+**
+** Description Close a stream endpoint. This stops the transfer of media
+** packets and closes the transport channel associated with
+** this stream endpoint. When the stream is closed, an
+** AVDT_CLOSE_CFM_EVT is sent to the application via the
+** control callback function for this handle.
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_CloseReq(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDT_ReconfigReq
+**
+** Description Reconfigure a stream endpoint. This allows the application
+** to change the codec or content protection capabilities of
+** a stream endpoint after it has been opened. This function
+** can only be called if the stream is opened but not started
+** or if the stream has been suspended. When the procedure
+** is completed, an AVDT_RECONFIG_CFM_EVT is sent to the
+** application via the control callback function for this handle.
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg);
+
+/*******************************************************************************
+**
+** Function AVDT_ReconfigRsp
+**
+** Description Respond to a reconfigure request from the peer device.
+** This function must be called if the application receives
+** an AVDT_RECONFIG_IND_EVT through its control callback.
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code,
+ UINT8 category);
+
+/*******************************************************************************
+**
+** Function AVDT_SecurityReq
+**
+** Description Send a security request to the peer device. When the
+** security procedure is completed, an AVDT_SECURITY_CFM_EVT
+** is sent to the application via the control callback function
+** for this handle. (Please note that AVDTP security procedures
+** are unrelated to Bluetooth link level security.)
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len);
+
+/*******************************************************************************
+**
+** Function AVDT_SecurityRsp
+**
+** Description Respond to a security request from the peer device.
+** This function must be called if the application receives
+** an AVDT_SECURITY_IND_EVT through its control callback.
+** (Please note that AVDTP security procedures are unrelated
+** to Bluetooth link level security.)
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code,
+ UINT8 *p_data, UINT16 len);
+
+/*******************************************************************************
+**
+** Function AVDT_WriteReq
+**
+** Description Send a media packet to the peer device. The stream must
+** be started before this function is called. Also, this
+** function can only be called if the stream is a SRC.
+**
+** When AVDTP has sent the media packet and is ready for the
+** next packet, an AVDT_WRITE_CFM_EVT is sent to the
+** application via the control callback. The application must
+** wait for the AVDT_WRITE_CFM_EVT before it makes the next
+** call to AVDT_WriteReq(). If the applications calls
+** AVDT_WriteReq() before it receives the event the packet
+** will not be sent. The application may make its first call
+** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT
+** or AVDT_START_IND_EVT.
+**
+** The application passes the packet using the BT_HDR structure.
+** This structure is described in section 2.1. The offset
+** field must be equal to or greater than AVDT_MEDIA_OFFSET.
+** This allows enough space in the buffer for the L2CAP and
+** AVDTP headers.
+**
+** The memory pointed to by p_pkt must be a GKI buffer
+** allocated by the application. This buffer will be freed
+** by the protocol stack; the application must not free
+** this buffer.
+**
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
+ UINT8 m_pt);
+/*******************************************************************************
+**
+** Function AVDT_WriteReqOpt
+**
+** Description Send a media packet to the peer device. The stream must
+** be started before this function is called. Also, this
+** function can only be called if the stream is a SRC
+**
+** When AVDTP has sent the media packet and is ready for the
+** next packet, an AVDT_WRITE_CFM_EVT is sent to the
+** application via the control callback. The application must
+** wait for the AVDT_WRITE_CFM_EVT before it makes the next
+** call to AVDT_WriteReq(). If the applications calls
+** AVDT_WriteReq() before it receives the event the packet
+** will not be sent. The application may make its first call
+** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT
+** or AVDT_START_IND_EVT.
+**
+** The application passes the packet using the BT_HDR structure
+** This structure is described in section 2.1. The offset
+** field must be equal to or greater than AVDT_MEDIA_OFFSET
+** (if NO_RTP is specified, L2CAP_MIN_OFFSET can be used)
+** This allows enough space in the buffer for the L2CAP and
+** AVDTP headers.
+**
+** The memory pointed to by p_pkt must be a GKI buffer
+** allocated by the application. This buffer will be freed
+** by the protocol stack; the application must not free
+** this buffer.
+**
+** The opt parameter allows passing specific options like:
+** - NO_RTP : do not add the RTP header to buffer
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
+ UINT8 m_pt, tAVDT_DATA_OPT_MASK opt);
+
+/*******************************************************************************
+**
+** Function AVDT_ConnectReq
+**
+** Description This function initiates an AVDTP signaling connection
+** to the peer device. When the connection is completed, an
+** AVDT_CONNECT_IND_EVT is sent to the application via its
+** control callback function. If the connection attempt fails
+** an AVDT_DISCONNECT_IND_EVT is sent. The security mask
+** parameter overrides the outgoing security mask set in
+** AVDT_Register().
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask,
+ tAVDT_CTRL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function AVDT_DisconnectReq
+**
+** Description This function disconnect an AVDTP signaling connection
+** to the peer device. When disconnected an
+** AVDT_DISCONNECT_IND_EVT is sent to the application via its
+** control callback function.
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function AVDT_GetL2CapChannel
+**
+** Description Get the L2CAP CID used by the handle.
+**
+** Returns CID if successful, otherwise 0.
+**
+*******************************************************************************/
+extern UINT16 AVDT_GetL2CapChannel(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDT_GetSignalChannel
+**
+** Description Get the L2CAP CID used by the signal channel of the given handle.
+**
+** Returns CID if successful, otherwise 0.
+**
+*******************************************************************************/
+extern UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function AVDT_WriteDataReq
+**
+** Description Send a media packet to the peer device. The stream must
+** be started before this function is called. Also, this
+** function can only be called if the stream is a SRC.
+**
+** When AVDTP has sent the media packet and is ready for the
+** next packet, an AVDT_WRITE_CFM_EVT is sent to the
+** application via the control callback. The application must
+** wait for the AVDT_WRITE_CFM_EVT before it makes the next
+** call to AVDT_WriteDataReq(). If the applications calls
+** AVDT_WriteDataReq() before it receives the event the packet
+** will not be sent. The application may make its first call
+** to AVDT_WriteDataReq() after it receives an
+** AVDT_START_CFM_EVT or AVDT_START_IND_EVT.
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
+ UINT32 time_stamp, UINT8 m_pt, UINT8 marker);
+
+/*******************************************************************************
+**
+** Function AVDT_SetMediaBuf
+**
+** Description Assigns buffer for media packets or forbids using of assigned
+** buffer if argument p_buf is NULL. This function can only
+** be called if the stream is a SNK.
+**
+** AVDTP uses this buffer to reassemble fragmented media packets.
+** When AVDTP receives a complete media packet, it calls the
+** p_media_cback assigned by AVDT_CreateStream().
+** This function can be called during callback to assign a
+** different buffer for next media packet or can leave the current
+** buffer for next packet.
+**
+** Returns AVDT_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len);
+
+/*******************************************************************************
+**
+** Function AVDT_SendReport
+**
+** Description
+**
+**
+**
+** Returns
+**
+*******************************************************************************/
+extern UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
+ tAVDT_REPORT_DATA *p_data);
+
+/******************************************************************************
+**
+** Function AVDT_SetTraceLevel
+**
+** Description Sets the trace level for AVDT. If 0xff is passed, the
+** current trace level is returned.
+**
+** Input Parameters:
+** new_level: The level to set the AVDT tracing to:
+** 0xff-returns the current setting.
+** 0-turns off tracing.
+** >= 1-Errors.
+** >= 2-Warnings.
+** >= 3-APIs.
+** >= 4-Events.
+** >= 5-Debug.
+**
+** Returns The new trace level or current trace level if
+** the input parameter is 0xff.
+**
+******************************************************************************/
+extern UINT8 AVDT_SetTraceLevel (UINT8 new_level);
+
+/*******************************************************************************
+**
+** Function AVDT_SetDelayValue
+**
+** Description Set delay reporting value.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDT_SetDelayValue(UINT16 delay_value);
+
+/*******************************************************************************
+**
+** Function AVDT_GetDelayValue
+**
+** Description Get delay reporting value.
+**
+** Returns delay value
+**
+*******************************************************************************/
+extern UINT16 AVDT_GetDelayValue(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* AVDT_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/avdtc_api.h b/lib/bt/host/bluedroid/stack/include/stack/avdtc_api.h
new file mode 100644
index 00000000..083b0b1c
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/avdtc_api.h
@@ -0,0 +1,230 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2002-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This interface file contains the interface AVDTP conformance API. These
+ * additional API functions and callback events are provided for
+ * conformance testing purposes only. They are not intended to be used by
+ * an application.
+ *
+ ******************************************************************************/
+#ifndef AVDT_CAPI_H
+#define AVDT_CAPI_H
+
+#include "stack/avdt_api.h"
+
+/* start AVDTC events here to distinguish from AVDT events */
+#define AVDTC_EVT_BEGIN 0x80
+
+#define AVDTC_DISCOVER_IND_EVT (0 + AVDTC_EVT_BEGIN) /* Discover indication */
+#define AVDTC_GETCAP_IND_EVT (1 + AVDTC_EVT_BEGIN) /* Get capabilities indication */
+#define AVDTC_SETCONFIG_CFM_EVT (2 + AVDTC_EVT_BEGIN) /* Set configuration confirm */
+#define AVDTC_GETCONFIG_IND_EVT (3 + AVDTC_EVT_BEGIN) /* Get configuration indication */
+#define AVDTC_GETCONFIG_CFM_EVT (4 + AVDTC_EVT_BEGIN) /* Get configuration confirm */
+#define AVDTC_OPEN_IND_EVT (5 + AVDTC_EVT_BEGIN) /* Open indication */
+#define AVDTC_START_IND_EVT (6 + AVDTC_EVT_BEGIN) /* Start indication */
+#define AVDTC_CLOSE_IND_EVT (7 + AVDTC_EVT_BEGIN) /* Close indication */
+#define AVDTC_SUSPEND_IND_EVT (8 + AVDTC_EVT_BEGIN) /* Suspend indication */
+#define AVDTC_ABORT_IND_EVT (9 + AVDTC_EVT_BEGIN) /* Abort indication */
+#define AVDTC_ABORT_CFM_EVT (10 + AVDTC_EVT_BEGIN) /* Abort confirm */
+
+typedef struct {
+ tAVDT_EVT_HDR hdr; /* Event header */
+ UINT8 seid_list[AVDT_NUM_SEPS]; /* Array of SEID values */
+ UINT8 num_seps; /* Number of values in array */
+} tAVDT_MULTI;
+
+/* Union of all control callback event data structures */
+typedef union {
+ tAVDT_EVT_HDR hdr;
+ tAVDT_CONFIG getconfig_cfm;
+ tAVDT_MULTI start_ind;
+ tAVDT_MULTI suspend_ind;
+} tAVDTC_CTRL;
+
+typedef void tAVDTC_CTRL_CBACK(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDTC_CTRL *p_data);
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function AVDTC_Init
+**
+** Description This function is called to begin using the conformance API.
+** It must be called after AVDT_Register() and before any
+** other API or conformance API functions are called.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_Init(tAVDTC_CTRL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function AVDTC_DiscoverRsp
+**
+** Description Send a discover response.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_DiscoverRsp(BD_ADDR bd_addr, UINT8 label,
+ tAVDT_SEP_INFO sep_info[], UINT8 num_seps);
+
+/*******************************************************************************
+**
+** Function AVDTC_GetCapRsp
+**
+** Description Send a get capabilities response.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_GetCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap);
+
+/*******************************************************************************
+**
+** Function AVDTC_GetAllCapRsp
+**
+** Description Send a get all capabilities response.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_GetAllCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap);
+
+/*******************************************************************************
+**
+** Function AVDTC_GetConfigReq
+**
+** Description Send a get configuration request.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_GetConfigReq(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDTC_GetConfigRsp
+**
+** Description Send a get configuration response.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_GetConfigRsp(UINT8 handle, UINT8 label, tAVDT_CFG *p_cfg);
+
+/*******************************************************************************
+**
+** Function AVDTC_OpenReq
+**
+** Description Send an open request.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_OpenReq(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDTC_OpenRsp
+**
+** Description Send an open response.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_OpenRsp(UINT8 handle, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_StartRsp
+**
+** Description Send a start response.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_StartRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_CloseRsp
+**
+** Description Send a close response.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_CloseRsp(UINT8 handle, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_SuspendRsp
+**
+** Description Send a suspend response.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_SuspendRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_AbortReq
+**
+** Description Send an abort request.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_AbortReq(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDTC_AbortRsp
+**
+** Description Send an abort response.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_AbortRsp(UINT8 handle, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_Rej
+**
+** Description Send a reject message.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVDTC_Rej(UINT8 handle, BD_ADDR bd_addr, UINT8 cmd, UINT8 label,
+ UINT8 err_code, UINT8 err_param);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AVDT_CAPI_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/avrc_api.h b/lib/bt/host/bluedroid/stack/include/stack/avrc_api.h
new file mode 100644
index 00000000..21f4bee5
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/avrc_api.h
@@ -0,0 +1,655 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2006-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * nterface to AVRCP Application Programming Interface
+ *
+ ******************************************************************************/
+#ifndef AVRC_API_H
+#define AVRC_API_H
+#include "common/bt_target.h"
+#include "common/bt_defs.h"
+#include "stack/avct_api.h"
+#include "stack/sdp_api.h"
+#include "stack/avrc_defs.h"
+#if (AVRC_INCLUDED == TRUE)
+/*****************************************************************************
+** constants
+*****************************************************************************/
+
+/* API function return value result codes. */
+#define AVRC_SUCCESS AVCT_SUCCESS /* 0 Function successful */
+#define AVRC_NO_RESOURCES AVCT_NO_RESOURCES /* 1 Not enough resources */
+#define AVRC_BAD_HANDLE AVCT_BAD_HANDLE /* 2 Bad handle */
+#define AVRC_PID_IN_USE AVCT_PID_IN_USE /* 3 PID already in use */
+#define AVRC_NOT_OPEN AVCT_NOT_OPEN /* 4 Connection not open */
+#define AVRC_MSG_TOO_BIG 5 /* 5 the message length exceed the MTU of the browsing channel */
+#define AVRC_FAIL 0x10 /* 0x10 generic failure */
+#define AVRC_BAD_PARAM 0x11 /* 0x11 bad parameter */
+
+/* Control role - same as AVCT_TARGET/AVCT_CONTROL */
+#define AVRC_CT_TARGET 1 /* target */
+#define AVRC_CT_CONTROL 2 /* controller */
+#define AVRC_CT_PASSIVE 4 /* If conflict, allow the other side to succeed */
+
+/* Connection role */
+#define AVRC_CONN_INT AVCT_INT /* initiator */
+#define AVRC_CONN_ACP AVCT_ACP /* Acceptor */
+
+
+/* AVRC CTRL events */
+/* AVRC_OPEN_IND_EVT event is sent when the connection is successfully opened.
+ * This eventis sent in response to an AVRC_Open(). */
+#define AVRC_OPEN_IND_EVT 0
+
+/* AVRC_CLOSE_IND_EVT event is sent when a connection is closed.
+ * This event can result from a call to AVRC_Close() or when the peer closes
+ * the connection. It is also sent when a connection attempted through
+ * AVRC_Open() fails. */
+#define AVRC_CLOSE_IND_EVT 1
+
+/* AVRC_CONG_IND_EVT event indicates that AVCTP is congested and cannot send
+ * any more messages. */
+#define AVRC_CONG_IND_EVT 2
+
+/* AVRC_UNCONG_IND_EVT event indicates that AVCTP is uncongested and ready to
+ * send messages. */
+#define AVRC_UNCONG_IND_EVT 3
+
+/* AVRC_BROWSE_OPEN_IND_EVT event is sent when the browse channel is successfully opened.
+* This eventis sent in response to an AVRC_Open() or AVRC_OpenBrowse() . */
+#define AVRC_BROWSE_OPEN_IND_EVT 4
+
+/* AVRC_BROWSE_CLOSE_IND_EVT event is sent when a browse channel is closed.
+ * This event can result from a call to AVRC_Close(), AVRC_CloseBrowse() or when the peer closes
+ * the connection. It is also sent when a connection attempted through
+ * AVRC_OpenBrowse() fails. */
+#define AVRC_BROWSE_CLOSE_IND_EVT 5
+
+/* AVRC_BROWSE_CONG_IND_EVT event indicates that AVCTP browse channel is congested and cannot send
+ * any more messages. */
+#define AVRC_BROWSE_CONG_IND_EVT 6
+
+/* AVRC_BROWSE_UNCONG_IND_EVT event indicates that AVCTP browse channel is uncongested and ready to
+ * send messages. */
+#define AVRC_BROWSE_UNCONG_IND_EVT 7
+
+/* AVRC_CMD_TIMEOUT_EVT event indicates timeout waiting for AVRC command response from the peer */
+#define AVRC_CMD_TIMEOUT_EVT 8
+
+/* Supported categories */
+#define AVRC_SUPF_CT_CAT1 0x0001 /* Category 1 */
+#define AVRC_SUPF_CT_CAT2 0x0002 /* Category 2 */
+#define AVRC_SUPF_CT_CAT3 0x0004 /* Category 3 */
+#define AVRC_SUPF_CT_CAT4 0x0008 /* Category 4 */
+#define AVRC_SUPF_CT_BROWSE 0x0040 /* Browsing */
+
+#define AVRC_SUPF_TG_CAT1 0x0001 /* Category 1 */
+#define AVRC_SUPF_TG_CAT2 0x0002 /* Category 2 */
+#define AVRC_SUPF_TG_CAT3 0x0004 /* Category 3 */
+#define AVRC_SUPF_TG_CAT4 0x0008 /* Category 4 */
+#define AVRC_SUPF_TG_APP_SETTINGS 0x0010 /* Player Application Settings */
+#define AVRC_SUPF_TG_GROUP_NAVI 0x0020 /* Group Navigation */
+#define AVRC_SUPF_TG_BROWSE 0x0040 /* Browsing */
+#define AVRC_SUPF_TG_MULTI_PLAYER 0x0080 /* Muliple Media Player */
+
+#define AVRC_META_SUCCESS AVRC_SUCCESS
+#define AVRC_META_FAIL AVRC_FAIL
+#define AVRC_METADATA_CMD 0x0000
+#define AVRC_METADATA_RESP 0x0001
+
+
+
+/*****************************************************************************
+** data type definitions
+*****************************************************************************/
+
+/* This data type is used in AVRC_FindService() to initialize the SDP database
+ * to hold the result service search. */
+typedef struct {
+ UINT32 db_len; /* Length, in bytes, of the discovery database */
+ tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */
+ UINT16 num_attr;/* The number of attributes in p_attrs */
+ UINT16 *p_attrs; /* The attributes filter. If NULL, AVRCP API sets the attribute filter
+ * to be ATTR_ID_SERVICE_CLASS_ID_LIST, ATTR_ID_BT_PROFILE_DESC_LIST,
+ * ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME and ATTR_ID_PROVIDER_NAME.
+ * If not NULL, the input is taken as the filter. */
+} tAVRC_SDP_DB_PARAMS;
+
+/* This callback function returns service discovery information to the
+ * application after the AVRC_FindService() API function is called. The
+ * implementation of this callback function must copy the p_service_name
+ * and p_provider_name parameters passed to it as they are not guaranteed
+ * to remain after the callback function exits. */
+typedef void (tAVRC_FIND_CBACK) (UINT16 status);
+
+
+/* This is the control callback function. This function passes events
+ * listed in Table 20 to the application. */
+typedef void (tAVRC_CTRL_CBACK) (UINT8 handle, UINT8 event, UINT16 result,
+ BD_ADDR peer_addr);
+
+
+/* This is the message callback function. It is executed when AVCTP has
+ * a message packet ready for the application. The implementation of this
+ * callback function must copy the tAVRC_MSG structure passed to it as it
+ * is not guaranteed to remain after the callback function exits. */
+typedef void (tAVRC_MSG_CBACK) (UINT8 handle, UINT8 label, UINT8 opcode,
+ tAVRC_MSG *p_msg);
+
+typedef struct {
+ tAVRC_CTRL_CBACK *p_ctrl_cback; /* pointer to application control callback */
+ tAVRC_MSG_CBACK *p_msg_cback; /* pointer to application message callback */
+ UINT32 company_id; /* the company ID */
+ UINT8 conn; /* Connection role (Initiator/acceptor) */
+ UINT8 control; /* Control role (Control/Target) */
+} tAVRC_CONN_CB;
+
+
+
+/*****************************************************************************
+** external function declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/******************************************************************************
+**
+** Function AVRC_AddRecord
+**
+** Description This function is called to build an AVRCP SDP record.
+** Prior to calling this function the application must
+** call SDP_CreateRecord() to create an SDP record.
+**
+** Input Parameters:
+** service_uuid: Indicates TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
+** or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
+**
+** p_service_name: Pointer to a null-terminated character
+** string containing the service name.
+** If service name is not used set this to NULL.
+**
+** p_provider_name: Pointer to a null-terminated character
+** string containing the provider name.
+** If provider name is not used set this to NULL.
+**
+** categories: Supported categories.
+**
+** sdp_handle: SDP handle returned by SDP_CreateRecord().
+**
+** browsing_en: Supported browsing
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_NO_RESOURCES if not enough resources to build the SDP record.
+**
+******************************************************************************/
+extern UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_provider_name,
+ UINT16 categories, UINT32 sdp_handle, BOOLEAN browsing_en);
+
+/******************************************************************************
+**
+** Function AVRC_FindService
+**
+** Description This function is called by the application to perform service
+** discovery and retrieve AVRCP SDP record information from a
+** peer device. Information is returned for the first service
+** record found on the server that matches the service UUID.
+** The callback function will be executed when service discovery
+** is complete. There can only be one outstanding call to
+** AVRC_FindService() at a time; the application must wait for
+** the callback before it makes another call to the function.
+** The application is responsible for allocating memory for the
+** discovery database. It is recommended that the size of the
+** discovery database be at least 300 bytes. The application
+** can deallocate the memory after the callback function has
+** executed.
+**
+** Input Parameters:
+** service_uuid: Indicates TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
+** or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
+**
+** bd_addr: BD address of the peer device.
+**
+** p_db: SDP discovery database parameters.
+**
+** p_cback: Pointer to the callback function.
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_PARAMS if discovery database parameters are invalid.
+** AVRC_NO_RESOURCES if there are not enough resources to
+** perform the service search.
+**
+******************************************************************************/
+extern UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
+ tAVRC_SDP_DB_PARAMS *p_db, tAVRC_FIND_CBACK *p_cback);
+
+/******************************************************************************
+**
+** Function AVRC_Open
+**
+** Description This function is called to open a connection to AVCTP.
+** The connection can be either an initiator or acceptor, as
+** determined by the p_ccb->stream parameter.
+** The connection can be a target, a controller or for both role,
+** as determined by the p_ccb->control parameter.
+** By definition, a target connection is an acceptor connection
+** that waits for an incoming AVCTP connection from the peer.
+** The connection remains available to the application until
+** the application closes it by calling AVRC_Close(). The
+** application does not need to reopen the connection after an
+** AVRC_CLOSE_IND_EVT is received.
+**
+** Input Parameters:
+** p_ccb->company_id: Company Identifier.
+**
+** p_ccb->p_ctrl_cback: Pointer to control callback function.
+**
+** p_ccb->p_msg_cback: Pointer to message callback function.
+**
+** p_ccb->conn: AVCTP connection role. This is set to
+** AVCTP_INT for initiator connections and AVCTP_ACP
+** for acceptor connections.
+**
+** p_ccb->control: Control role. This is set to
+** AVRC_CT_TARGET for target connections, AVRC_CT_CONTROL
+** for control connections or (AVRC_CT_TARGET|AVRC_CT_CONTROL)
+** for connections that support both roles.
+**
+** peer_addr: BD address of peer device. This value is
+** only used for initiator connections; for acceptor
+** connections it can be set to NULL.
+**
+** Output Parameters:
+** p_handle: Pointer to handle. This parameter is only
+** valid if AVRC_SUCCESS is returned.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_NO_RESOURCES if there are not enough resources to open
+** the connection.
+**
+******************************************************************************/
+extern UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb,
+ BD_ADDR_PTR peer_addr);
+
+/******************************************************************************
+**
+** Function AVRC_Close
+**
+** Description Close a connection opened with AVRC_Open().
+** This function is called when the
+** application is no longer using a connection.
+**
+** Input Parameters:
+** handle: Handle of this connection.
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_HANDLE if handle is invalid.
+**
+******************************************************************************/
+extern UINT16 AVRC_Close(UINT8 handle);
+
+/******************************************************************************
+**
+** Function AVRC_OpenBrowse
+**
+** Description This function is called to open a browsing connection to AVCTP.
+** The connection can be either an initiator or acceptor, as
+** determined by the conn_role.
+** The handle is returned by a previous call to AVRC_Open.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_NO_RESOURCES if there are not enough resources to open
+** the connection.
+**
+******************************************************************************/
+extern UINT16 AVRC_OpenBrowse(UINT8 handle, UINT8 conn_role);
+
+/******************************************************************************
+**
+** Function AVRC_CloseBrowse
+**
+** Description Close a connection opened with AVRC_OpenBrowse().
+** This function is called when the
+** application is no longer using a connection.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_HANDLE if handle is invalid.
+**
+******************************************************************************/
+extern UINT16 AVRC_CloseBrowse(UINT8 handle);
+
+/******************************************************************************
+**
+** Function AVRC_MsgReq
+**
+** Description This function is used to send the AVRCP byte stream in p_pkt
+** down to AVCTP.
+**
+** It is expected that p_pkt->offset is at least AVCT_MSG_OFFSET
+** p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE
+** p_pkt->event is AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or AVRC_OP_BROWSING
+** The above BT_HDR settings are set by the AVRC_Bld* functions.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_HANDLE if handle is invalid.
+**
+******************************************************************************/
+extern UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt);
+
+/******************************************************************************
+**
+** Function AVRC_UnitCmd
+**
+** Description Send a UNIT INFO command to the peer device. This
+** function can only be called for controller role connections.
+** Any response message from the peer is passed back through
+** the tAVRC_MSG_CBACK callback function.
+**
+** Input Parameters:
+** handle: Handle of this connection.
+**
+** label: Transaction label.
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_HANDLE if handle is invalid.
+**
+******************************************************************************/
+extern UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label);
+
+/******************************************************************************
+**
+** Function AVRC_SubCmd
+**
+** Description Send a SUBUNIT INFO command to the peer device. This
+** function can only be called for controller role connections.
+** Any response message from the peer is passed back through
+** the tAVRC_MSG_CBACK callback function.
+**
+** Input Parameters:
+** handle: Handle of this connection.
+**
+** label: Transaction label.
+**
+** page: Specifies which part of the subunit type table
+** is requested. For AVRCP it is typically zero.
+** Value range is 0-7.
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_HANDLE if handle is invalid.
+**
+******************************************************************************/
+extern UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page);
+
+
+/******************************************************************************
+**
+** Function AVRC_PassCmd
+**
+** Description Send a PASS THROUGH command to the peer device. This
+** function can only be called for controller role connections.
+** Any response message from the peer is passed back through
+** the tAVRC_MSG_CBACK callback function.
+**
+** Input Parameters:
+** handle: Handle of this connection.
+**
+** label: Transaction label.
+**
+** p_msg: Pointer to PASS THROUGH message structure.
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_HANDLE if handle is invalid.
+**
+******************************************************************************/
+extern UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg);
+
+/******************************************************************************
+**
+** Function AVRC_PassRsp
+**
+** Description Send a PASS THROUGH response to the peer device. This
+** function can only be called for target role connections.
+** This function must be called when a PASS THROUGH command
+** message is received from the peer through the
+** tAVRC_MSG_CBACK callback function.
+**
+** Input Parameters:
+** handle: Handle of this connection.
+**
+** label: Transaction label. Must be the same value as
+** passed with the command message in the callback function.
+**
+** p_msg: Pointer to PASS THROUGH message structure.
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_HANDLE if handle is invalid.
+**
+******************************************************************************/
+extern UINT16 AVRC_PassRsp(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg);
+
+
+/******************************************************************************
+**
+** Function AVRC_VendorCmd
+**
+** Description Send a VENDOR DEPENDENT command to the peer device. This
+** function can only be called for controller role connections.
+** Any response message from the peer is passed back through
+** the tAVRC_MSG_CBACK callback function.
+**
+** Input Parameters:
+** handle: Handle of this connection.
+**
+** label: Transaction label.
+**
+** p_msg: Pointer to VENDOR DEPENDENT message structure.
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_HANDLE if handle is invalid.
+**
+******************************************************************************/
+extern UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg);
+
+
+/******************************************************************************
+**
+** Function AVRC_VendorRsp
+**
+** Description Send a VENDOR DEPENDENT response to the peer device. This
+** function can only be called for target role connections.
+** This function must be called when a VENDOR DEPENDENT
+** command message is received from the peer through the
+** tAVRC_MSG_CBACK callback function.
+**
+** Input Parameters:
+** handle: Handle of this connection.
+**
+** label: Transaction label. Must be the same value as
+** passed with the command message in the callback function.
+**
+** p_msg: Pointer to VENDOR DEPENDENT message structure.
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_BAD_HANDLE if handle is invalid.
+**
+******************************************************************************/
+extern UINT16 AVRC_VendorRsp(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg);
+
+
+/******************************************************************************
+**
+** Function AVRC_SetTraceLevel
+**
+** Description Sets the trace level for AVRC. If 0xff is passed, the
+** current trace level is returned.
+**
+** Input Parameters:
+** new_level: The level to set the AVRC tracing to:
+** 0xff-returns the current setting.
+** 0-turns off tracing.
+** >= 1-Errors.
+** >= 2-Warnings.
+** >= 3-APIs.
+** >= 4-Events.
+** >= 5-Debug.
+**
+** Returns The new trace level or current trace level if
+** the input parameter is 0xff.
+**
+******************************************************************************/
+extern UINT8 AVRC_SetTraceLevel (UINT8 new_level);
+
+/*******************************************************************************
+**
+** Function AVRC_Init
+**
+** Description This function is called at stack startup to allocate the
+** control block (if using dynamic memory), and initializes the
+** control block and tracing level.
+**
+** Returns status
+**
+*******************************************************************************/
+extern bt_status_t AVRC_Init(void);
+
+/*******************************************************************************
+**
+** Function AVRC_Deinit
+**
+** Description This function is called at stack shotdown to free the
+** control block (if using dynamic memory), and deinitializes the
+** control block and tracing level.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void AVRC_Deinit(void);
+
+/*******************************************************************************
+**
+** Function AVRC_ParsCommand
+**
+** Description This function is used to parse the received command.
+**
+** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
+** Otherwise, the error code defined by AVRCP 1.4
+**
+*******************************************************************************/
+extern tAVRC_STS AVRC_ParsCommand (tAVRC_MSG *p_msg, tAVRC_COMMAND *p_result,
+ UINT8 *p_buf, UINT16 buf_len);
+
+/*******************************************************************************
+**
+** Function AVRC_ParsResponse
+**
+** Description This function is used to parse the received response.
+**
+** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
+** Otherwise, the error code defined by AVRCP 1.4
+**
+*******************************************************************************/
+extern tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result);
+
+/*******************************************************************************
+**
+** Function AVRC_BldCommand
+**
+** Description This function builds the given AVRCP command to the given
+** GKI buffer
+**
+** Returns AVRC_STS_NO_ERROR, if the command is built successfully
+** Otherwise, the error code.
+**
+*******************************************************************************/
+extern tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt);
+
+/*******************************************************************************
+**
+** Function AVRC_BldResponse
+**
+** Description This function builds the given AVRCP response to the given
+** GKI buffer
+**
+** Returns AVRC_STS_NO_ERROR, if the response is built successfully
+** Otherwise, the error code.
+**
+*******************************************************************************/
+extern tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt);
+
+/**************************************************************************
+**
+** Function AVRC_IsValidAvcType
+**
+** Description Check if correct AVC type is specified
+**
+** Returns returns TRUE if it is valid
+**
+**
+*******************************************************************************/
+extern BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type);
+
+/*******************************************************************************
+**
+** Function AVRC_IsValidPlayerAttr
+**
+** Description Check if the given attrib value is a valid one
+**
+**
+** Returns returns TRUE if it is valid
+**
+*******************************************************************************/
+extern BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif ///AVRC_INCLUDED == TRUE
+
+
+#endif /* AVRC_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/avrc_defs.h b/lib/bt/host/bluedroid/stack/include/stack/avrc_defs.h
new file mode 100644
index 00000000..c90fa6cf
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/avrc_defs.h
@@ -0,0 +1,1360 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2006-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * AVRCP definition and data types
+ *
+ ******************************************************************************/
+#ifndef _AVRC_DEFS_H
+#define _AVRC_DEFS_H
+#include "common/bt_target.h"
+
+#if (AVRC_INCLUDED == TRUE)
+/*****************************************************************************
+** constants
+*****************************************************************************/
+
+/* Profile revision numbers */
+#define AVRC_REV_1_0 0x0100
+#define AVRC_REV_1_3 0x0103
+#define AVRC_REV_1_4 0x0104
+#define AVRC_REV_1_5 0x0105
+
+#define AVRC_PACKET_LEN 512 /* Per the spec, you must support 512 byte RC packets */
+
+#define AVRC_MIN_CONTROL_MTU 48 /* Per the spec, minimum MTU for the control channel */
+#define AVRC_MIN_BROWSE_MTU 335 /* Per the spec, minimum MTU for the browsing channel */
+
+#define AVRC_META_PDU_OFFSET 4
+#define AVRC_SUB_TYPE_LEN 4
+#define AVRC_UID_SIZE 8
+#define AVRC_FEATURE_MASK_SIZE 16
+
+/* command type codes */
+#define AVRC_CMD_CTRL 0 /* Instruct a target to perform an operation */
+#define AVRC_CMD_STATUS 1 /* Check a device's current status */
+#define AVRC_CMD_SPEC_INQ 2 /* Check whether a target supports a particular control command; all operands are included */
+#define AVRC_CMD_NOTIF 3 /* Used for receiving notification of a change in a device's state */
+#define AVRC_CMD_GEN_INQ 4 /* Check whether a target supports a particular control command; operands are not included */
+
+/* response type codes */
+#define AVRC_RSP_NOT_IMPL 8 /* The target does not implement the command specified by the opcode and operand,
+ or doesn't implement the specified subunit */
+#define AVRC_RSP_ACCEPT 9 /* The target executed or is executing the command */
+#define AVRC_RSP_REJ 10 /* The target implements the command specified by the
+ opcode but cannot respond because the current state
+ of the target doesn't allow it */
+#define AVRC_RSP_IN_TRANS 11 /* The target implements the status command but it is
+ in a state of transition; the status command may
+ be retried at a future time */
+#define AVRC_RSP_IMPL_STBL 12 /* For specific inquiry or general inquiy commands,
+ the target implements the command; for status
+ commands, the target returns stable and includes
+ the status results */
+#define AVRC_RSP_CHANGED 13 /* The response frame contains a notification that the
+ target device's state has changed */
+#define AVRC_RSP_INTERIM 15 /* For control commands, the target has accepted the
+ request but cannot return information within 100
+ milliseconds; for notify commands, the target accepted
+ the command, and will notify the controller of a change
+ of target state at a future time */
+
+/* subunit type */
+#define AVRC_SUB_MONITOR 0x00 /* Monitor */
+#define AVRC_SUB_AUDIO 0x01 /* Audio */
+#define AVRC_SUB_PRINTER 0x02 /* Printer */
+#define AVRC_SUB_DISC 0x03 /* Disc */
+#define AVRC_SUB_TAPE 0x04 /* Tape recorder/player */
+#define AVRC_SUB_TUNER 0x05 /* Tuner */
+#define AVRC_SUB_CA 0x06 /* CA */
+#define AVRC_SUB_CAMERA 0x07 /* Camera */
+#define AVRC_SUB_PANEL 0x09 /* Panel */
+#define AVRC_SUB_BB 0x0A /* Bulletin Board */
+#define AVRC_SUB_CAM_STOR 0x0B /* Camera Storage */
+#define AVRC_SUB_VENDOR 0x1C /* Vendor unique */
+#define AVRC_SUB_EXT 0x1E /* Subunit type extended to next byte */
+#define AVRC_SUB_UNIT 0x1F /* Unit */
+
+/* opcodes - defined by 1394ta */
+#define AVRC_OP_UNIT_INFO 0x30 /* Report unit information */
+#define AVRC_OP_SUB_INFO 0x31 /* Report subunit information */
+#define AVRC_OP_VENDOR 0x00 /* Vendor-dependent commands */
+#define AVRC_OP_PASS_THRU 0x7C /* panel subunit opcode */
+/* opcodes 80-9F and E0-FF are not used by 1394ta.Sneak one for the browsing channel */
+#define AVRC_OP_BROWSE 0xFF /* Browsing */
+#define AVRC_OP_INVALID 0xFE /* invalid one */
+
+/* Company ID's
+*/
+#define AVRC_CO_BLUETOOTH_SIG 0x00FFFFFF
+#define AVRC_CO_WIDCOMM 0x00000361
+#define AVRC_CO_BROADCOM 0x00001018
+#define AVRC_CO_METADATA 0x00001958 /* Unique COMPANY ID for Metadata messages */
+
+/* State flag for Passthrough commands
+*/
+#define AVRC_STATE_PRESS 0
+#define AVRC_STATE_RELEASE 1
+
+/* Operation ID list for Passthrough commands
+*/
+#define AVRC_ID_SELECT 0x00 /* select */
+#define AVRC_ID_UP 0x01 /* up */
+#define AVRC_ID_DOWN 0x02 /* down */
+#define AVRC_ID_LEFT 0x03 /* left */
+#define AVRC_ID_RIGHT 0x04 /* right */
+#define AVRC_ID_RIGHT_UP 0x05 /* right-up */
+#define AVRC_ID_RIGHT_DOWN 0x06 /* right-down */
+#define AVRC_ID_LEFT_UP 0x07 /* left-up */
+#define AVRC_ID_LEFT_DOWN 0x08 /* left-down */
+#define AVRC_ID_ROOT_MENU 0x09 /* root menu */
+#define AVRC_ID_SETUP_MENU 0x0A /* setup menu */
+#define AVRC_ID_CONT_MENU 0x0B /* contents menu */
+#define AVRC_ID_FAV_MENU 0x0C /* favorite menu */
+#define AVRC_ID_EXIT 0x0D /* exit */
+#define AVRC_ID_0 0x20 /* 0 */
+#define AVRC_ID_1 0x21 /* 1 */
+#define AVRC_ID_2 0x22 /* 2 */
+#define AVRC_ID_3 0x23 /* 3 */
+#define AVRC_ID_4 0x24 /* 4 */
+#define AVRC_ID_5 0x25 /* 5 */
+#define AVRC_ID_6 0x26 /* 6 */
+#define AVRC_ID_7 0x27 /* 7 */
+#define AVRC_ID_8 0x28 /* 8 */
+#define AVRC_ID_9 0x29 /* 9 */
+#define AVRC_ID_DOT 0x2A /* dot */
+#define AVRC_ID_ENTER 0x2B /* enter */
+#define AVRC_ID_CLEAR 0x2C /* clear */
+#define AVRC_ID_CHAN_UP 0x30 /* channel up */
+#define AVRC_ID_CHAN_DOWN 0x31 /* channel down */
+#define AVRC_ID_PREV_CHAN 0x32 /* previous channel */
+#define AVRC_ID_SOUND_SEL 0x33 /* sound select */
+#define AVRC_ID_INPUT_SEL 0x34 /* input select */
+#define AVRC_ID_DISP_INFO 0x35 /* display information */
+#define AVRC_ID_HELP 0x36 /* help */
+#define AVRC_ID_PAGE_UP 0x37 /* page up */
+#define AVRC_ID_PAGE_DOWN 0x38 /* page down */
+#define AVRC_ID_POWER 0x40 /* power */
+#define AVRC_ID_VOL_UP 0x41 /* volume up */
+#define AVRC_ID_VOL_DOWN 0x42 /* volume down */
+#define AVRC_ID_MUTE 0x43 /* mute */
+#define AVRC_ID_PLAY 0x44 /* play */
+#define AVRC_ID_STOP 0x45 /* stop */
+#define AVRC_ID_PAUSE 0x46 /* pause */
+#define AVRC_ID_RECORD 0x47 /* record */
+#define AVRC_ID_REWIND 0x48 /* rewind */
+#define AVRC_ID_FAST_FOR 0x49 /* fast forward */
+#define AVRC_ID_EJECT 0x4A /* eject */
+#define AVRC_ID_FORWARD 0x4B /* forward */
+#define AVRC_ID_BACKWARD 0x4C /* backward */
+#define AVRC_ID_ANGLE 0x50 /* angle */
+#define AVRC_ID_SUBPICT 0x51 /* subpicture */
+#define AVRC_ID_F1 0x71 /* F1 */
+#define AVRC_ID_F2 0x72 /* F2 */
+#define AVRC_ID_F3 0x73 /* F3 */
+#define AVRC_ID_F4 0x74 /* F4 */
+#define AVRC_ID_F5 0x75 /* F5 */
+#define AVRC_ID_VENDOR 0x7E /* vendor unique */
+#define AVRC_KEYPRESSED_RELEASE 0x80
+
+/*****************************************************************************
+** Metadata transfer definitions
+*****************************************************************************/
+
+/* Define the Metadata Packet types
+*/
+#define AVRC_PKT_SINGLE 0
+#define AVRC_PKT_START 1
+#define AVRC_PKT_CONTINUE 2
+#define AVRC_PKT_END 3
+#define AVRC_PKT_TYPE_MASK 3
+
+/* Define the PDUs carried in the vendor dependant data
+*/
+#define AVRC_PDU_GET_CAPABILITIES 0x10
+#define AVRC_PDU_LIST_PLAYER_APP_ATTR 0x11
+#define AVRC_PDU_LIST_PLAYER_APP_VALUES 0x12
+#define AVRC_PDU_GET_CUR_PLAYER_APP_VALUE 0x13
+#define AVRC_PDU_SET_PLAYER_APP_VALUE 0x14
+#define AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT 0x15
+#define AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT 0x16
+#define AVRC_PDU_INFORM_DISPLAY_CHARSET 0x17
+#define AVRC_PDU_INFORM_BATTERY_STAT_OF_CT 0x18
+#define AVRC_PDU_GET_ELEMENT_ATTR 0x20
+#define AVRC_PDU_GET_PLAY_STATUS 0x30
+#define AVRC_PDU_REGISTER_NOTIFICATION 0x31
+#define AVRC_PDU_REQUEST_CONTINUATION_RSP 0x40
+#define AVRC_PDU_ABORT_CONTINUATION_RSP 0x41
+/* added in 1.4 */
+#define AVRC_PDU_SET_ABSOLUTE_VOLUME 0x50
+#define AVRC_PDU_SET_ADDRESSED_PLAYER 0x60
+#define AVRC_PDU_SET_BROWSED_PLAYER 0x70
+#define AVRC_PDU_GET_FOLDER_ITEMS 0x71
+#define AVRC_PDU_CHANGE_PATH 0x72
+#define AVRC_PDU_GET_ITEM_ATTRIBUTES 0x73
+#define AVRC_PDU_PLAY_ITEM 0x74
+#define AVRC_PDU_SEARCH 0x80
+#define AVRC_PDU_ADD_TO_NOW_PLAYING 0x90
+#define AVRC_PDU_GENERAL_REJECT 0xA0
+
+/* Define the vendor unique id carried in the pass through data
+*/
+#define AVRC_PDU_NEXT_GROUP 0x00
+#define AVRC_PDU_PREV_GROUP 0x01
+/* the only pass through vendor unique commands defined by AVRC is the group navigation commands
+ * The len for vendor unique data is 5 */
+#define AVRC_PASS_THRU_GROUP_LEN 5
+
+#define AVRC_PDU_INVALID 0xff
+/* 6.15.3 error status code for general reject */
+#define AVRC_STS_BAD_CMD 0x00 /* Invalid command, sent if TG received a PDU that it did not understand. */
+#define AVRC_STS_BAD_PARAM 0x01 /* Invalid parameter, sent if the TG received a PDU with a parameter ID that it did not understand. Sent if there is only one parameter ID in the PDU. */
+#define AVRC_STS_NOT_FOUND 0x02 /* Specified parameter not found., sent if the parameter ID is understood, but content is wrong or corrupted. */
+#define AVRC_STS_INTERNAL_ERR 0x03 /* Internal Error, sent if there are error conditions not covered by a more specific error code. */
+#define AVRC_STS_NO_ERROR 0x04 /* Operation completed without error. This is the status that should be returned if the operation was successful. */
+#define AVRC_STS_UID_CHANGED 0x05 /* UID Changed - The UIDs on the device have changed */
+/* #define AVRC_STS_GEN_ERROR 0x06 Unknown Error - this is changed to "reserved" */
+#define AVRC_STS_BAD_DIR 0x07 /* Invalid Direction - The Direction parameter is invalid - Change Path*/
+#define AVRC_STS_NOT_DIR 0x08 /* Not a Directory - The UID provided does not refer to a folder item Change Path*/
+#define AVRC_STS_NOT_EXIST 0x09 /* Does Not Exist - The UID provided does not refer to any item Change Path, PlayItem, AddToNowPlaying, GetItemAttributes*/
+#define AVRC_STS_BAD_SCOPE 0x0a /* Invalid Scope - The scope parameter is invalid GetFolderItems, PlayItem, AddToNowPlayer, GetItemAttributes, */
+#define AVRC_STS_BAD_RANGE 0x0b /* Range Out of Bounds - The start of range provided is not valid GetFolderItems*/
+#define AVRC_STS_UID_IS_DIR 0x0c /* UID is a Directory - The UID provided refers to a directory, which cannot be handled by this media player PlayItem, AddToNowPlaying */
+#define AVRC_STS_IN_USE 0x0d /* Media in Use - The media is not able to be used for this operation at this time PlayItem, AddToNowPlaying */
+#define AVRC_STS_NOW_LIST_FULL 0x0e /* Now Playing List Full - No more items can be added to the Now Playing List AddToNowPlaying*/
+#define AVRC_STS_SEARCH_NOT_SUP 0x0f /* Search Not Supported - The Browsed Media Player does not support search Search */
+#define AVRC_STS_SEARCH_BUSY 0x10 /* Search in Progress - A search operation is already in progress Search*/
+#define AVRC_STS_BAD_PLAYER_ID 0x11 /* Invalid Player Id - The specified Player Id does not refer to a valid player SetAddressedPlayer, SetBrowsedPlayer*/
+#define AVRC_STS_PLAYER_N_BR 0x12 /* Player Not Browsable - The Player Id supplied refers to a Media Player which does not support browsing. SetBrowsedPlayer */
+#define AVRC_STS_PLAYER_N_ADDR 0x13 /* Player Not Addressed. The Player Id supplied refers to a player which is not currently addressed, and the command is not able to be performed if the player is not set as addressed. Search, SetBrowsedPlayer*/
+#define AVRC_STS_BAD_SEARCH_RES 0x14 /* No valid Search Results - The Search result list does not contain valid entries, e.g. after being invalidated due to change of browsed player GetFolderItems */
+#define AVRC_STS_NO_AVAL_PLAYER 0x15 /* No available players ALL */
+#define AVRC_STS_ADDR_PLAYER_CHG 0x16 /* Addressed Player Changed - Register Notification */
+typedef UINT8 tAVRC_STS;
+
+
+/* Define the Capability IDs
+*/
+#define AVRC_CAP_COMPANY_ID 0x02
+#define AVRC_CAP_EVENTS_SUPPORTED 0x03
+#define AVRC_COMPANY_ID_LEN 3
+#define AVRC_CAPABILITY_OFFSET 2
+
+/* Define the Player Application Settings IDs
+*/
+#define AVRC_PLAYER_SETTING_EQUALIZER 0x01
+#define AVRC_PLAYER_SETTING_REPEAT 0x02
+#define AVRC_PLAYER_SETTING_SHUFFLE 0x03
+#define AVRC_PLAYER_SETTING_SCAN 0x04
+#define AVRC_PLAYER_SETTING_LOW_MENU_EXT 0x80
+#define AVRC_PLAYER_SETTING_HIGH_MENU_EXT 0xff
+
+/* Define the possible values of the Player Application Settings
+*/
+#define AVRC_PLAYER_VAL_OFF 0x01
+#define AVRC_PLAYER_VAL_ON 0x02
+#define AVRC_PLAYER_VAL_SINGLE_REPEAT 0x02
+#define AVRC_PLAYER_VAL_ALL_REPEAT 0x03
+#define AVRC_PLAYER_VAL_GROUP_REPEAT 0x04
+#define AVRC_PLAYER_VAL_ALL_SHUFFLE 0x02
+#define AVRC_PLAYER_VAL_GROUP_SHUFFLE 0x03
+#define AVRC_PLAYER_VAL_ALL_SCAN 0x02
+#define AVRC_PLAYER_VAL_GROUP_SCAN 0x03
+
+/* Define the possible values of Battery Status PDU
+*/
+#define AVRC_BATTERY_STATUS_NORMAL 0x00
+#define AVRC_BATTERY_STATUS_WARNING 0x01
+#define AVRC_BATTERY_STATUS_CRITICAL 0x02
+#define AVRC_BATTERY_STATUS_EXTERNAL 0x03
+#define AVRC_BATTERY_STATUS_FULL_CHARGE 0x04
+typedef UINT8 tAVRC_BATTERY_STATUS;
+
+/* Define character set */
+#define AVRC_CHAR_SET_SIZE 2
+
+/* Define the Media Attribute IDs
+*/
+#define AVRC_MEDIA_ATTR_ID_TITLE 0x00000001
+#define AVRC_MEDIA_ATTR_ID_ARTIST 0x00000002
+#define AVRC_MEDIA_ATTR_ID_ALBUM 0x00000003
+#define AVRC_MEDIA_ATTR_ID_TRACK_NUM 0x00000004
+#define AVRC_MEDIA_ATTR_ID_NUM_TRACKS 0x00000005
+#define AVRC_MEDIA_ATTR_ID_GENRE 0x00000006
+#define AVRC_MEDIA_ATTR_ID_PLAYING_TIME 0x00000007 /* in miliseconds */
+#define AVRC_MAX_NUM_MEDIA_ATTR_ID 7
+
+/* Define the possible values of play state
+*/
+#define AVRC_PLAYSTATE_RESP_MSG_SIZE 9
+#define AVRC_PLAYSTATE_STOPPED 0x00 /* Stopped */
+#define AVRC_PLAYSTATE_PLAYING 0x01 /* Playing */
+#define AVRC_PLAYSTATE_PAUSED 0x02 /* Paused */
+#define AVRC_PLAYSTATE_FWD_SEEK 0x03 /* Fwd Seek*/
+#define AVRC_PLAYSTATE_REV_SEEK 0x04 /* Rev Seek*/
+#define AVRC_PLAYSTATE_ERROR 0xFF /* Error */
+typedef UINT8 tAVRC_PLAYSTATE;
+
+/* Define the events that can be registered for notifications
+*/
+#define AVRC_EVT_PLAY_STATUS_CHANGE 0x01
+#define AVRC_EVT_TRACK_CHANGE 0x02
+#define AVRC_EVT_TRACK_REACHED_END 0x03
+#define AVRC_EVT_TRACK_REACHED_START 0x04
+#define AVRC_EVT_PLAY_POS_CHANGED 0x05
+#define AVRC_EVT_BATTERY_STATUS_CHANGE 0x06
+#define AVRC_EVT_SYSTEM_STATUS_CHANGE 0x07
+#define AVRC_EVT_APP_SETTING_CHANGE 0x08
+/* added in AVRCP 1.4 */
+#define AVRC_EVT_NOW_PLAYING_CHANGE 0x09
+#define AVRC_EVT_AVAL_PLAYERS_CHANGE 0x0a
+#define AVRC_EVT_ADDR_PLAYER_CHANGE 0x0b
+#define AVRC_EVT_UIDS_CHANGE 0x0c
+#define AVRC_EVT_VOLUME_CHANGE 0x0d
+
+/* the number of events that can be registered for notifications */
+#define AVRC_NUM_NOTIF_EVENTS 0x0d
+
+#define AVRC_EVT_MSG_LEN_1 0x01
+#define AVRC_EVT_MSG_LEN_2 0x02
+#define AVRC_EVT_MSG_LEN_5 0x05
+#define AVRC_EVT_MSG_LEN_9 0x09
+
+#define AVRC_MAX_VOLUME 0x7F
+
+/* Define the possible values of system status
+*/
+#define AVRC_SYSTEMSTATE_PWR_ON 0x00
+#define AVRC_SYSTEMSTATE_PWR_OFF 0x01
+#define AVRC_SYSTEMSTATE_PWR_UNPLUGGED 0x02
+typedef UINT8 tAVRC_SYSTEMSTATE;
+
+/* the frequently used character set ids */
+#define AVRC_CHARSET_ID_ASCII ((UINT16) 0x0003) /* ASCII */
+#define AVRC_CHARSET_ID_UTF8 ((UINT16) 0x006a) /* UTF-8 */
+#define AVRC_CHARSET_ID_UTF16 ((UINT16) 0x03f7) /* 1015 */
+#define AVRC_CHARSET_ID_UTF32 ((UINT16) 0x03f9) /* 1017 */
+
+/*****************************************************************************
+** Advanced Control
+*****************************************************************************/
+#define AVRC_ITEM_PLAYER 0x01
+#define AVRC_ITEM_FOLDER 0x02
+#define AVRC_ITEM_MEDIA 0x03
+
+#define AVRC_SCOPE_PLAYER_LIST 0x00 /* Media Player Item - Contains all available media players */
+#define AVRC_SCOPE_FILE_SYSTEM 0x01 /* Folder Item, Media Element Item
+ - The virtual filesystem containing the media content of the browsed player */
+#define AVRC_SCOPE_SEARCH 0x02 /* Media Element Item The results of a search operation on the browsed player */
+#define AVRC_SCOPE_NOW_PLAYING 0x03 /* Media Element Item The Now Playing list (or queue) of the addressed player */
+
+#define AVRC_FOLDER_ITEM_COUNT_NONE 0xFF
+
+/* folder type */
+#define AVRC_FOLDER_TYPE_MIXED 0x00
+#define AVRC_FOLDER_TYPE_TITLES 0x01
+#define AVRC_FOLDER_TYPE_ALNUMS 0x02
+#define AVRC_FOLDER_TYPE_ARTISTS 0x03
+#define AVRC_FOLDER_TYPE_GENRES 0x04
+#define AVRC_FOLDER_TYPE_PLAYLISTS 0x05
+#define AVRC_FOLDER_TYPE_YEARS 0x06
+
+/* major player type */
+#define AVRC_MJ_TYPE_AUDIO 0x01 /* Audio */
+#define AVRC_MJ_TYPE_VIDEO 0x02 /* Video */
+#define AVRC_MJ_TYPE_BC_AUDIO 0x04 /* Broadcasting Audio */
+#define AVRC_MJ_TYPE_BC_VIDEO 0x08 /* Broadcasting Video */
+#define AVRC_MJ_TYPE_INVALID 0xF0
+
+/* player sub type */
+#define AVRC_SUB_TYPE_NONE 0x00
+#define AVRC_SUB_TYPE_AUDIO_BOOK 0x01 /* Audio Book */
+#define AVRC_SUB_TYPE_PODCAST 0x02 /* Podcast */
+#define AVRC_SUB_TYPE_INVALID 0xFC
+
+/* media item - media type */
+#define AVRC_MEDIA_TYPE_AUDIO 0x00
+#define AVRC_MEDIA_TYPE_VIDEO 0x01
+
+#define AVRC_DIR_UP 0x00 /* Folder Up */
+#define AVRC_DIR_DOWN 0x01 /* Folder Down */
+
+#define AVRC_UID_SIZE 8
+typedef UINT8 tAVRC_UID[AVRC_UID_SIZE];
+
+/*****************************************************************************
+** player attribute - supported features
+*****************************************************************************/
+#define AVRC_PF_SELECT_BIT_NO 0
+#define AVRC_PF_SELECT_MASK 0x01
+#define AVRC_PF_SELECT_OFF 0
+#define AVRC_PF_SELECT_SUPPORTED(x) ((x)[AVRC_PF_SELECT_OFF] & AVRC_PF_SELECT_MASK)
+
+#define AVRC_PF_UP_BIT_NO 1
+#define AVRC_PF_UP_MASK 0x02
+#define AVRC_PF_UP_OFF 0
+#define AVRC_PF_UP_SUPPORTED(x) ((x)[AVRC_PF_UP_OFF] & AVRC_PF_UP_MASK)
+
+#define AVRC_PF_DOWN_BIT_NO 2
+#define AVRC_PF_DOWN_MASK 0x04
+#define AVRC_PF_DOWN_OFF 0
+#define AVRC_PF_DOWN_SUPPORTED(x) ((x)[AVRC_PF_DOWN_OFF] & AVRC_PF_DOWN_MASK)
+
+#define AVRC_PF_LEFT_BIT_NO 3
+#define AVRC_PF_LEFT_MASK 0x08
+#define AVRC_PF_LEFT_OFF 0
+#define AVRC_PF_LEFT_SUPPORTED(x) ((x)[AVRC_PF_LEFT_OFF] & AVRC_PF_LEFT_MASK)
+
+#define AVRC_PF_RIGHT_BIT_NO 4
+#define AVRC_PF_RIGHT_MASK 0x10
+#define AVRC_PF_RIGHT_OFF 0
+#define AVRC_PF_RIGHT_SUPPORTED(x) ((x)[AVRC_PF_RIGHT_OFF] & AVRC_PF_RIGHT_MASK)
+
+#define AVRC_PF_RIGHTUP_BIT_NO 5
+#define AVRC_PF_RIGHTUP_MASK 0x20
+#define AVRC_PF_RIGHTUP_OFF 0
+#define AVRC_PF_RIGHTUP_SUPPORTED(x) ((x)[AVRC_PF_RIGHTUP_OFF] & AVRC_PF_RIGHTUP_MASK)
+
+#define AVRC_PF_RIGHTDOWN_BIT_NO 6
+#define AVRC_PF_RIGHTDOWN_MASK 0x40
+#define AVRC_PF_RIGHTDOWN_OFF 0
+#define AVRC_PF_RIGHTDOWN_SUPPORTED(x) ((x)[AVRC_PF_RIGHTDOWN_OFF] & AVRC_PF_RIGHTDOWN_MASK)
+
+#define AVRC_PF_LEFTUP_BIT_NO 7
+#define AVRC_PF_LEFTUP_MASK 0x80
+#define AVRC_PF_LEFTUP_OFF 0
+#define AVRC_PF_LEFTUP_SUPPORTED(x) ((x)[AVRC_PF_LEFTUP_OFF] & AVRC_PF_LEFTUP_MASK)
+
+#define AVRC_PF_LEFTDOWN_BIT_NO 8
+#define AVRC_PF_LEFTDOWN_MASK 0x01
+#define AVRC_PF_LEFTDOWN_OFF 1
+#define AVRC_PF_LEFTDOWN_SUPPORTED(x) ((x)[AVRC_PF_LEFTDOWN_OFF] & AVRC_PF_LEFTDOWN_MASK)
+
+#define AVRC_PF_ROOT_MENU_BIT_NO 9
+#define AVRC_PF_ROOT_MENU_MASK 0x02
+#define AVRC_PF_ROOT_MENU_OFF 1
+#define AVRC_PF_ROOT_MENU_SUPPORTED(x) ((x)[AVRC_PF_ROOT_MENU_OFF] & AVRC_PF_ROOT_MENU_MASK)
+
+#define AVRC_PF_SETUP_MENU_BIT_NO 10
+#define AVRC_PF_SETUP_MENU_MASK 0x04
+#define AVRC_PF_SETUP_MENU_OFF 1
+#define AVRC_PF_SETUP_MENU_SUPPORTED(x) ((x)[AVRC_PF_SETUP_MENU_OFF] & AVRC_PF_SETUP_MENU_MASK)
+
+#define AVRC_PF_CONTENTS_MENU_BIT_NO 11
+#define AVRC_PF_CONTENTS_MENU_MASK 0x08
+#define AVRC_PF_CONTENTS_MENU_OFF 1
+#define AVRC_PF_CONTENTS_MENU_SUPPORTED(x) ((x)[AVRC_PF_CONTENTS_MENU_OFF] & AVRC_PF_CONTENTS_MENU_MASK)
+
+#define AVRC_PF_FAVORITE_MENU_BIT_NO 12
+#define AVRC_PF_FAVORITE_MENU_MASK 0x10
+#define AVRC_PF_FAVORITE_MENU_OFF 1
+#define AVRC_PF_FAVORITE_MENU_SUPPORTED(x) ((x)[AVRC_PF_FAVORITE_MENU_OFF] & AVRC_PF_FAVORITE_MENU_MASK)
+
+#define AVRC_PF_EXIT_BIT_NO 13
+#define AVRC_PF_EXIT_MASK 0x20
+#define AVRC_PF_EXIT_OFF 1
+#define AVRC_PF_EXIT_SUPPORTED(x) ((x)[AVRC_PF_EXIT_OFF] & AVRC_PF_EXIT_MASK)
+
+#define AVRC_PF_0_BIT_NO 14
+#define AVRC_PF_0_MASK 0x40
+#define AVRC_PF_0_OFF 1
+#define AVRC_PF_0_SUPPORTED(x) ((x)[AVRC_PF_0_OFF] & AVRC_PF_0_MASK)
+
+#define AVRC_PF_1_BIT_NO 15
+#define AVRC_PF_1_MASK 0x80
+#define AVRC_PF_1_OFF 1
+#define AVRC_PF_1_SUPPORTED(x) ((x)[AVRC_PF_1_OFF] & AVRC_PF_1_MASK)
+
+#define AVRC_PF_2_BIT_NO 16
+#define AVRC_PF_2_MASK 0x01
+#define AVRC_PF_2_OFF 2
+#define AVRC_PF_2_SUPPORTED(x) ((x)[AVRC_PF_2_OFF] & AVRC_PF_2_MASK)
+
+#define AVRC_PF_3_BIT_NO 17
+#define AVRC_PF_3_MASK 0x02
+#define AVRC_PF_3_OFF 2
+#define AVRC_PF_3_SUPPORTED(x) ((x)[AVRC_PF_3_OFF] & AVRC_PF_3_MASK)
+
+#define AVRC_PF_4_BIT_NO 18
+#define AVRC_PF_4_MASK 0x04
+#define AVRC_PF_4_OFF 2
+#define AVRC_PF_4_SUPPORTED(x) ((x)[AVRC_PF_4_OFF] & AVRC_PF_4_MASK)
+
+#define AVRC_PF_5_BIT_NO 19
+#define AVRC_PF_5_MASK 0x08
+#define AVRC_PF_5_OFF 2
+#define AVRC_PF_5_SUPPORTED(x) ((x)[AVRC_PF_5_OFF] & AVRC_PF_5_MASK)
+
+#define AVRC_PF_6_BIT_NO 20
+#define AVRC_PF_6_MASK 0x10
+#define AVRC_PF_6_OFF 2
+#define AVRC_PF_6_SUPPORTED(x) ((x)[AVRC_PF_6_OFF] & AVRC_PF_6_MASK)
+
+#define AVRC_PF_7_BIT_NO 21
+#define AVRC_PF_7_MASK 0x20
+#define AVRC_PF_7_OFF 2
+#define AVRC_PF_7_SUPPORTED(x) ((x)[AVRC_PF_7_OFF] & AVRC_PF_7_MASK)
+
+#define AVRC_PF_8_BIT_NO 22
+#define AVRC_PF_8_MASK 0x40
+#define AVRC_PF_8_OFF 2
+#define AVRC_PF_8_SUPPORTED(x) ((x)[AVRC_PF_8_OFF] & AVRC_PF_8_MASK)
+
+#define AVRC_PF_9_BIT_NO 23
+#define AVRC_PF_9_MASK 0x80
+#define AVRC_PF_9_OFF 2
+#define AVRC_PF_9_SUPPORTED(x) ((x)[AVRC_PF_9_OFF] & AVRC_PF_9_MASK)
+
+#define AVRC_PF_DOT_BIT_NO 24
+#define AVRC_PF_DOT_MASK 0x01
+#define AVRC_PF_DOT_OFF 3
+#define AVRC_PF_DOT_SUPPORTED(x) ((x)[AVRC_PF_DOT_OFF] & AVRC_PF_DOT_MASK)
+
+#define AVRC_PF_ENTER_BIT_NO 25
+#define AVRC_PF_ENTER_MASK 0x02
+#define AVRC_PF_ENTER_OFF 3
+#define AVRC_PF_ENTER_SUPPORTED(x) ((x)[AVRC_PF_ENTER_OFF] & AVRC_PF_ENTER_MASK)
+
+#define AVRC_PF_CLEAR_BIT_NO 26
+#define AVRC_PF_CLEAR_MASK 0x04
+#define AVRC_PF_CLEAR_OFF 3
+#define AVRC_PF_CLEAR_SUPPORTED(x) ((x)[AVRC_PF_CLEAR_OFF] & AVRC_PF_CLEAR_MASK)
+
+#define AVRC_PF_CHNL_UP_BIT_NO 27
+#define AVRC_PF_CHNL_UP_MASK 0x08
+#define AVRC_PF_CHNL_UP_OFF 3
+#define AVRC_PF_CHNL_UP_SUPPORTED(x) ((x)[AVRC_PF_CHNL_UP_OFF] & AVRC_PF_CHNL_UP_MASK)
+
+#define AVRC_PF_CHNL_DOWN_BIT_NO 28
+#define AVRC_PF_CHNL_DOWN_MASK 0x10
+#define AVRC_PF_CHNL_DOWN_OFF 3
+#define AVRC_PF_CHNL_DOWN_SUPPORTED(x) ((x)[AVRC_PF_CHNL_DOWN_OFF] & AVRC_PF_CHNL_DOWN_MASK)
+
+#define AVRC_PF_PREV_CHNL_BIT_NO 29
+#define AVRC_PF_PREV_CHNL_MASK 0x20
+#define AVRC_PF_PREV_CHNL_OFF 3
+#define AVRC_PF_PREV_CHNL_SUPPORTED(x) ((x)[AVRC_PF_PREV_CHNL_OFF] & AVRC_PF_PREV_CHNL_MASK)
+
+#define AVRC_PF_SOUND_SEL_BIT_NO 30
+#define AVRC_PF_SOUND_SEL_MASK 0x40
+#define AVRC_PF_SOUND_SEL_OFF 3
+#define AVRC_PF_SOUND_SEL_SUPPORTED(x) ((x)[AVRC_PF_SOUND_SEL_OFF] & AVRC_PF_SOUND_SEL_MASK)
+
+#define AVRC_PF_INPUT_SEL_BIT_NO 31
+#define AVRC_PF_INPUT_SEL_MASK 0x80
+#define AVRC_PF_INPUT_SEL_OFF 3
+#define AVRC_PF_INPUT_SEL_SUPPORTED(x) ((x)[AVRC_PF_INPUT_SEL_OFF] & AVRC_PF_INPUT_SEL_MASK)
+
+#define AVRC_PF_DISP_INFO_BIT_NO 32
+#define AVRC_PF_DISP_INFO_MASK 0x01
+#define AVRC_PF_DISP_INFO_OFF 4
+#define AVRC_PF_DISP_INFO_SUPPORTED(x) ((x)[AVRC_PF_DISP_INFO_OFF] & AVRC_PF_DISP_INFO_MASK)
+
+#define AVRC_PF_HELP_BIT_NO 33
+#define AVRC_PF_HELP_MASK 0x02
+#define AVRC_PF_HELP_OFF 4
+#define AVRC_PF_HELP_SUPPORTED(x) ((x)[AVRC_PF_HELP_OFF] & AVRC_PF_HELP_MASK)
+
+#define AVRC_PF_PAGE_UP_BIT_NO 34
+#define AVRC_PF_PAGE_UP_MASK 0x04
+#define AVRC_PF_PAGE_UP_OFF 4
+#define AVRC_PF_PAGE_UP_SUPPORTED(x) ((x)[AVRC_PF_PAGE_UP_OFF] & AVRC_PF_PAGE_UP_MASK)
+
+#define AVRC_PF_PAGE_DOWN_BIT_NO 35
+#define AVRC_PF_PAGE_DOWN_MASK 0x08
+#define AVRC_PF_PAGE_DOWN_OFF 4
+#define AVRC_PF_PAGE_DOWN_SUPPORTED(x) ((x)[AVRC_PF_PAGE_DOWN_OFF] & AVRC_PF_PAGE_DOWN_MASK)
+
+#define AVRC_PF_POWER_BIT_NO 36
+#define AVRC_PF_POWER_MASK 0x10
+#define AVRC_PF_POWER_OFF 4
+#define AVRC_PF_POWER_SUPPORTED(x) ((x)[AVRC_PF_POWER_OFF] & AVRC_PF_POWER_MASK)
+
+#define AVRC_PF_VOL_UP_BIT_NO 37
+#define AVRC_PF_VOL_UP_MASK 0x20
+#define AVRC_PF_VOL_UP_OFF 4
+#define AVRC_PF_VOL_UP_SUPPORTED(x) ((x)[AVRC_PF_VOL_UP_OFF] & AVRC_PF_VOL_UP_MASK)
+
+#define AVRC_PF_VOL_DOWN_BIT_NO 38
+#define AVRC_PF_VOL_DOWN_MASK 0x40
+#define AVRC_PF_VOL_DOWN_OFF 4
+#define AVRC_PF_VOL_DOWN_SUPPORTED(x) ((x)[AVRC_PF_VOL_DOWN_OFF] & AVRC_PF_VOL_DOWN_MASK)
+
+#define AVRC_PF_MUTE_BIT_NO 39
+#define AVRC_PF_MUTE_MASK 0x80
+#define AVRC_PF_MUTE_OFF 4
+#define AVRC_PF_MUTE_SUPPORTED(x) ((x)[AVRC_PF_MUTE_OFF] & AVRC_PF_MUTE_MASK)
+
+#define AVRC_PF_PLAY_BIT_NO 40
+#define AVRC_PF_PLAY_MASK 0x01
+#define AVRC_PF_PLAY_OFF 5
+#define AVRC_PF_PLAY_SUPPORTED(x) ((x)[AVRC_PF_PLAY_OFF] & AVRC_PF_PLAY_MASK)
+
+#define AVRC_PF_STOP_BIT_NO 41
+#define AVRC_PF_STOP_MASK 0x02
+#define AVRC_PF_STOP_OFF 5
+#define AVRC_PF_STOP_SUPPORTED(x) ((x)[AVRC_PF_STOP_OFF] & AVRC_PF_STOP_MASK)
+
+#define AVRC_PF_PAUSE_BIT_NO 42
+#define AVRC_PF_PAUSE_MASK 0x04
+#define AVRC_PF_PAUSE_OFF 5
+#define AVRC_PF_PAUSE_SUPPORTED(x) ((x)[AVRC_PF_PAUSE_OFF] & AVRC_PF_PAUSE_MASK)
+
+#define AVRC_PF_RECORD_BIT_NO 43
+#define AVRC_PF_RECORD_MASK 0x08
+#define AVRC_PF_RECORD_OFF 5
+#define AVRC_PF_RECORD_SUPPORTED(x) ((x)[AVRC_PF_RECORD_OFF] & AVRC_PF_RECORD_MASK)
+
+#define AVRC_PF_REWIND_BIT_NO 44
+#define AVRC_PF_REWIND_MASK 0x10
+#define AVRC_PF_REWIND_OFF 5
+#define AVRC_PF_REWIND_SUPPORTED(x) ((x)[AVRC_PF_REWIND_OFF] & AVRC_PF_REWIND_MASK)
+
+#define AVRC_PF_FAST_FWD_BIT_NO 45
+#define AVRC_PF_FAST_FWD_MASK 0x20
+#define AVRC_PF_FAST_FWD_OFF 5
+#define AVRC_PF_FAST_FWD_SUPPORTED(x) ((x)[AVRC_PF_FAST_FWD_OFF] & AVRC_PF_FAST_FWD_MASK)
+
+#define AVRC_PF_EJECT_BIT_NO 46
+#define AVRC_PF_EJECT_MASK 0x40
+#define AVRC_PF_EJECT_OFF 5
+#define AVRC_PF_EJECT_SUPPORTED(x) ((x)[AVRC_PF_EJECT_OFF] & AVRC_PF_EJECT_MASK)
+
+#define AVRC_PF_FORWARD_BIT_NO 47
+#define AVRC_PF_FORWARD_MASK 0x80
+#define AVRC_PF_FORWARD_OFF 5
+#define AVRC_PF_FORWARD_SUPPORTED(x) ((x)[AVRC_PF_FORWARD_OFF] & AVRC_PF_FORWARD_MASK)
+
+#define AVRC_PF_BACKWARD_BIT_NO 48
+#define AVRC_PF_BACKWARD_MASK 0x01
+#define AVRC_PF_BACKWARD_OFF 6
+#define AVRC_PF_BACKWARD_SUPPORTED(x) ((x)[AVRC_PF_BACKWARD_OFF] & AVRC_PF_BACKWARD_MASK)
+
+#define AVRC_PF_ANGLE_BIT_NO 49
+#define AVRC_PF_ANGLE_MASK 0x02
+#define AVRC_PF_ANGLE_OFF 6
+#define AVRC_PF_ANGLE_SUPPORTED(x) ((x)[AVRC_PF_ANGLE_OFF] & AVRC_PF_ANGLE_MASK)
+
+#define AVRC_PF_SUBPICTURE_BIT_NO 50
+#define AVRC_PF_SUBPICTURE_MASK 0x04
+#define AVRC_PF_SUBPICTURE_OFF 6
+#define AVRC_PF_SUBPICTURE_SUPPORTED(x) ((x)[AVRC_PF_SUBPICTURE_OFF] & AVRC_PF_SUBPICTURE_MASK)
+
+#define AVRC_PF_F1_BIT_NO 51
+#define AVRC_PF_F1_MASK 0x08
+#define AVRC_PF_F1_OFF 6
+#define AVRC_PF_F1_SUPPORTED(x) ((x)[AVRC_PF_F1_OFF] & AVRC_PF_F1_MASK)
+
+#define AVRC_PF_F2_BIT_NO 52
+#define AVRC_PF_F2_MASK 0x10
+#define AVRC_PF_F2_OFF 6
+#define AVRC_PF_F2_SUPPORTED(x) ((x)[AVRC_PF_F2_OFF] & AVRC_PF_F2_MASK)
+
+#define AVRC_PF_F3_BIT_NO 53
+#define AVRC_PF_F3_MASK 0x20
+#define AVRC_PF_F3_OFF 6
+#define AVRC_PF_F3_SUPPORTED(x) ((x)[AVRC_PF_F3_OFF] & AVRC_PF_F3_MASK)
+
+#define AVRC_PF_F4_BIT_NO 54
+#define AVRC_PF_F4_MASK 0x40
+#define AVRC_PF_F4_OFF 6
+#define AVRC_PF_F4_SUPPORTED(x) ((x)[AVRC_PF_F4_OFF] & AVRC_PF_F4_MASK)
+
+#define AVRC_PF_F5_BIT_NO 55
+#define AVRC_PF_F5_MASK 0x80
+#define AVRC_PF_F5_OFF 6
+#define AVRC_PF_F5_SUPPORTED(x) ((x)[AVRC_PF_F5_OFF] & AVRC_PF_F5_MASK)
+
+/* Vendor unique. This PASSTHROUGH command is supported. */
+#define AVRC_PF_VENDOR_BIT_NO 56
+#define AVRC_PF_VENDOR_MASK 0x01
+#define AVRC_PF_VENDOR_OFF 7
+#define AVRC_PF_VENDOR_SUPPORTED(x) ((x)[AVRC_PF_VENDOR_OFF] & AVRC_PF_VENDOR_MASK)
+
+/* Basic Group Navigation. This overrules the SDP entry as it is set per player.7 */
+#define AVRC_PF_GROUP_NAVI_BIT_NO 57
+#define AVRC_PF_GROUP_NAVI_MASK 0x02
+#define AVRC_PF_GROUP_NAVI_OFF 7
+#define AVRC_PF_GROUP_NAVI_SUPPORTED(x) ((x)[AVRC_PF_GROUP_NAVI_OFF] & AVRC_PF_GROUP_NAVI_MASK)
+
+/* Advanced Control Player. This bit is set if the player supports at least AVRCP 1.4. */
+#define AVRC_PF_ADV_CTRL_BIT_NO 58
+#define AVRC_PF_ADV_CTRL_MASK 0x04
+#define AVRC_PF_ADV_CTRL_OFF 7
+#define AVRC_PF_ADV_CTRL_SUPPORTED(x) ((x)[AVRC_PF_ADV_CTRL_OFF] & AVRC_PF_ADV_CTRL_MASK)
+
+/* Browsing. This bit is set if the player supports browsing. */
+#define AVRC_PF_BROWSE_BIT_NO 59
+#define AVRC_PF_BROWSE_MASK 0x08
+#define AVRC_PF_BROWSE_OFF 7
+#define AVRC_PF_BROWSE_SUPPORTED(x) ((x)[AVRC_PF_BROWSE_OFF] & AVRC_PF_BROWSE_MASK)
+
+/* Searching. This bit is set if the player supports searching. */
+#define AVRC_PF_SEARCH_BIT_NO 60
+#define AVRC_PF_SEARCH_MASK 0x10
+#define AVRC_PF_SEARCH_OFF 7
+#define AVRC_PF_SEARCH_SUPPORTED(x) ((x)[AVRC_PF_SEARCH_OFF] & AVRC_PF_SEARCH_MASK)
+
+/* AddToNowPlaying. This bit is set if the player supports the AddToNowPlaying command. */
+#define AVRC_PF_ADD2NOWPLAY_BIT_NO 61
+#define AVRC_PF_ADD2NOWPLAY_MASK 0x20
+#define AVRC_PF_ADD2NOWPLAY_OFF 7
+#define AVRC_PF_ADD2NOWPLAY_SUPPORTED(x) ((x)[AVRC_PF_ADD2NOWPLAY_OFF] & AVRC_PF_ADD2NOWPLAY_MASK)
+
+/* UIDs unique in player browse tree. This bit is set if the player is able to maintain unique UIDs across the player browse tree. */
+#define AVRC_PF_UID_UNIQUE_BIT_NO 62
+#define AVRC_PF_UID_UNIQUE_MASK 0x40
+#define AVRC_PF_UID_UNIQUE_OFF 7
+#define AVRC_PF_UID_UNIQUE_SUPPORTED(x) ((x)[AVRC_PF_UID_UNIQUE_OFF] & AVRC_PF_UID_UNIQUE_MASK)
+
+/* OnlyBrowsableWhenAddressed. This bit is set if the player is only able to be browsed when it is set as the Addressed Player. */
+#define AVRC_PF_BR_WH_ADDR_BIT_NO 63
+#define AVRC_PF_BR_WH_ADDR_MASK 0x80
+#define AVRC_PF_BR_WH_ADDR_OFF 7
+#define AVRC_PF_BR_WH_ADDR_SUPPORTED(x) ((x)[AVRC_PF_BR_WH_ADDR_OFF] & AVRC_PF_BR_WH_ADDR_MASK)
+
+/* OnlySearchableWhenAddressed. This bit is set if the player is only able to be searched when it is set as the Addressed player. */
+#define AVRC_PF_SEARCH_WH_ADDR_BIT_NO 64
+#define AVRC_PF_SEARCH_WH_ADDR_MASK 0x01
+#define AVRC_PF_SEARCH_WH_ADDR_OFF 8
+#define AVRC_PF_SEARCH_WH_ADDR_SUPPORTED(x) ((x)[AVRC_PF_SEARCH_WH_ADDR_OFF] & AVRC_PF_SEARCH_WH_ADDR_MASK)
+
+/* NowPlaying. This bit is set if the player supports the NowPlaying folder. Note that for all players that support browsing this bit shall be set */
+#define AVRC_PF_NOW_PLAY_BIT_NO 65
+#define AVRC_PF_NOW_PLAY_MASK 0x02
+#define AVRC_PF_NOW_PLAY_OFF 8
+#define AVRC_PF_NOW_PLAY_SUPPORTED(x) ((x)[AVRC_PF_NOW_PLAY_OFF] & AVRC_PF_NOW_PLAY_MASK)
+
+/* UIDPersistency. This bit is set if the Player is able to persist UID values between AVRCP Browse Reconnect */
+#define AVRC_PF_UID_PERSIST_BIT_NO 66
+#define AVRC_PF_UID_PERSIST_MASK 0x04
+#define AVRC_PF_UID_PERSIST_OFF 8
+#define AVRC_PF_UID_PERSIST_SUPPORTED(x) ((x)[AVRC_PF_UID_PERSIST_OFF] & AVRC_PF_UID_PERSIST_MASK)
+
+/*****************************************************************************
+** data type definitions
+*****************************************************************************/
+
+/*
+This structure contains the header parameters of an AV/C message.
+*/
+typedef struct {
+ UINT8 ctype; /* Command type. */
+ UINT8 subunit_type; /* Subunit type. */
+ UINT8 subunit_id; /* Subunit ID. This value is typically ignored in AVRCP,
+ * except for VENDOR DEPENDENT messages when the value is
+ * vendor-dependent. Value range is 0-7. */
+ UINT8 opcode; /* Op Code (passthrough, vendor, etc) */
+} tAVRC_HDR;
+
+/* This structure contains a UNIT INFO message. */
+typedef struct {
+ tAVRC_HDR hdr; /* Message header. */
+ UINT32 company_id; /* Company identifier. */
+ UINT8 unit_type; /* Unit type. Uses the same values as subunit type. */
+ UINT8 unit; /* This value is vendor dependent and typically zero. */
+} tAVRC_MSG_UNIT;
+
+/* This structure contains a SUBUNIT INFO message. */
+typedef struct {
+ tAVRC_HDR hdr; /* Message header. */
+ UINT8 subunit_type[AVRC_SUB_TYPE_LEN];
+ /* Array containing subunit type values. */
+ BOOLEAN panel; /* TRUE if the panel subunit type is in the
+ * subunit_type array, FALSE otherwise. */
+ UINT8 page; /* Specifies which part of the subunit type table is
+ * returned. For AVRCP it is typically zero.
+ * Value range is 0-7. */
+} tAVRC_MSG_SUB;
+
+/* This structure contains a VENDOR DEPENDENT message. */
+typedef struct {
+ tAVRC_HDR hdr; /* Message header. */
+ UINT32 company_id; /* Company identifier. */
+ UINT8 *p_vendor_data;/* Pointer to vendor dependent data. */
+ UINT16 vendor_len; /* Length in bytes of vendor dependent data. */
+} tAVRC_MSG_VENDOR;
+
+/* PASS THROUGH message structure */
+typedef struct {
+ tAVRC_HDR hdr; /* hdr.ctype Unused.
+ * hdr.subunit_type Unused.
+ * hdr.subunit_id Unused. */
+ UINT8 op_id; /* Operation ID. */
+ UINT8 state; /* Keypress state. */
+ UINT8 *p_pass_data;/* Pointer to data. This parameter is only valid
+ * when the op_id is AVRC_ID_VENDOR.*/
+ UINT8 pass_len; /* Length in bytes of data. This parameter is only
+ * valid when the op_id is AVRC_ID_VENDOR.*/
+} tAVRC_MSG_PASS;
+
+/* Command/Response indicator. */
+#define AVRC_CMD AVCT_CMD /* Command message */
+#define AVRC_RSP AVCT_RSP /* Response message */
+
+/* Browsing channel message structure */
+typedef struct {
+ tAVRC_HDR hdr; /* hdr.ctype AVRC_CMD or AVRC_RSP.
+ * hdr.subunit_type Unused.
+ * hdr.subunit_id Unused. */
+ UINT8 *p_browse_data; /* Pointer to data. */
+ UINT16 browse_len; /* Length in bytes of data. */
+ BT_HDR *p_browse_pkt; /* The GKI buffer received. Set to NULL, if the callback function wants to keep the buffer */
+} tAVRC_MSG_BROWSE;
+
+/* This is a union of all message type structures. */
+typedef union {
+ tAVRC_HDR hdr; /* Message header. */
+ tAVRC_MSG_UNIT unit; /* UNIT INFO message. */
+ tAVRC_MSG_SUB sub; /* SUBUNIT INFO message. */
+ tAVRC_MSG_VENDOR vendor; /* VENDOR DEPENDENT message. */
+ tAVRC_MSG_PASS pass; /* PASS THROUGH message. */
+ tAVRC_MSG_BROWSE browse; /* messages thru browsing channel */
+} tAVRC_MSG;
+
+/* macros */
+#define AVRC_IS_VALID_CAP_ID(a) (((a == AVRC_CAP_COMPANY_ID) || (a == AVRC_CAP_EVENTS_SUPPORTED)) ? TRUE : FALSE)
+
+#define AVRC_IS_VALID_EVENT_ID(a) (((a >= AVRC_EVT_PLAY_STATUS_CHANGE) && \
+ (a <= AVRC_EVT_VOLUME_CHANGE)) ? TRUE : FALSE)
+
+#define AVRC_IS_VALID_ATTRIBUTE(a) (((((a > 0) && a <= AVRC_PLAYER_SETTING_SCAN)) || \
+ (a >= AVRC_PLAYER_SETTING_LOW_MENU_EXT)) ? TRUE : FALSE)
+
+#define AVRC_IS_VALID_MEDIA_ATTRIBUTE(a) ((a >= AVRC_MEDIA_ATTR_ID_TITLE) && \
+ (a <= AVRC_MEDIA_ATTR_ID_PLAYING_TIME) ? TRUE : FALSE)
+
+#define AVRC_IS_VALID_BATTERY_STATUS(a) ((a <= AVRC_BATTERY_STATUS_FULL_CHARGE) ? TRUE : FALSE)
+
+#define AVRC_IS_VALID_SYSTEM_STATUS(a) ((a <= AVRC_SYSTEMSTATE_PWR_UNPLUGGED) ? TRUE : FALSE)
+
+#define AVRC_IS_VALID_GROUP(a) ((a <= AVRC_PDU_PREV_GROUP) ? TRUE : FALSE)
+
+/* Company ID is 24-bit integer We can not use the macros in stack/bt_types.h */
+#define AVRC_CO_ID_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
+#define AVRC_BE_STREAM_TO_CO_ID(u32, p) {u32 = (((UINT32)(*((p) + 2))) + (((UINT32)(*((p) + 1))) << 8) + (((UINT32)(*(p))) << 16)); (p) += 3;}
+
+/*****************************************************************************
+** data type definitions
+*****************************************************************************/
+#define AVRC_MAX_APP_ATTR_SIZE 16
+#define AVRC_MAX_CHARSET_SIZE 16
+#define AVRC_MAX_ELEM_ATTR_SIZE 8
+
+
+/*****************************************************************************
+** Metadata transfer Building/Parsing definitions
+*****************************************************************************/
+
+typedef struct {
+ UINT16 charset_id;
+ UINT16 str_len;
+ UINT8 *p_str;
+} tAVRC_FULL_NAME;
+
+typedef struct {
+ UINT16 str_len;
+ UINT8 *p_str;
+} tAVRC_NAME;
+
+
+#ifndef AVRC_CAP_MAX_NUM_COMP_ID
+#define AVRC_CAP_MAX_NUM_COMP_ID 4
+#endif
+
+#ifndef AVRC_CAP_MAX_NUM_EVT_ID
+#define AVRC_CAP_MAX_NUM_EVT_ID 16
+#endif
+
+typedef union {
+ UINT32 company_id[AVRC_CAP_MAX_NUM_COMP_ID];
+ UINT8 event_id[AVRC_CAP_MAX_NUM_EVT_ID];
+} tAVRC_CAPS_PARAM;
+
+typedef struct {
+ UINT8 attr_id;
+ UINT8 attr_val;
+} tAVRC_APP_SETTING;
+
+typedef struct {
+ UINT8 attr_id;
+ UINT16 charset_id;
+ UINT8 str_len;
+ UINT8 *p_str;
+} tAVRC_APP_SETTING_TEXT;
+
+typedef UINT8 tAVRC_FEATURE_MASK[AVRC_FEATURE_MASK_SIZE];
+
+typedef struct {
+ UINT16 player_id; /* A unique identifier for this media player.*/
+ UINT8 major_type; /* Use AVRC_MJ_TYPE_AUDIO, AVRC_MJ_TYPE_VIDEO, AVRC_MJ_TYPE_BC_AUDIO, or AVRC_MJ_TYPE_BC_VIDEO.*/
+ UINT32 sub_type; /* Use AVRC_SUB_TYPE_NONE, AVRC_SUB_TYPE_AUDIO_BOOK, or AVRC_SUB_TYPE_PODCAST*/
+ UINT8 play_status; /* Use AVRC_PLAYSTATE_STOPPED, AVRC_PLAYSTATE_PLAYING, AVRC_PLAYSTATE_PAUSED, AVRC_PLAYSTATE_FWD_SEEK,
+ AVRC_PLAYSTATE_REV_SEEK, or AVRC_PLAYSTATE_ERROR*/
+ tAVRC_FEATURE_MASK features; /* Supported feature bit mask*/
+ tAVRC_FULL_NAME name; /* The player name, name length and character set id.*/
+} tAVRC_ITEM_PLAYER;
+
+typedef struct {
+ tAVRC_UID uid; /* The uid of this folder */
+ UINT8 type; /* Use AVRC_FOLDER_TYPE_MIXED, AVRC_FOLDER_TYPE_TITLES,
+ AVRC_FOLDER_TYPE_ALNUMS, AVRC_FOLDER_TYPE_ARTISTS, AVRC_FOLDER_TYPE_GENRES,
+ AVRC_FOLDER_TYPE_PLAYLISTS, or AVRC_FOLDER_TYPE_YEARS.*/
+ BOOLEAN playable; /* TRUE, if the folder can be played. */
+ tAVRC_FULL_NAME name; /* The folder name, name length and character set id. */
+} tAVRC_ITEM_FOLDER;
+
+typedef struct {
+ UINT32 attr_id; /* Use AVRC_MEDIA_ATTR_ID_TITLE, AVRC_MEDIA_ATTR_ID_ARTIST, AVRC_MEDIA_ATTR_ID_ALBUM,
+ AVRC_MEDIA_ATTR_ID_TRACK_NUM, AVRC_MEDIA_ATTR_ID_NUM_TRACKS,
+ AVRC_MEDIA_ATTR_ID_GENRE, AVRC_MEDIA_ATTR_ID_PLAYING_TIME */
+ tAVRC_FULL_NAME name; /* The attribute value, value length and character set id. */
+} tAVRC_ATTR_ENTRY;
+
+typedef struct {
+ tAVRC_UID uid; /* The uid of this media element item */
+ UINT8 type; /* Use AVRC_MEDIA_TYPE_AUDIO or AVRC_MEDIA_TYPE_VIDEO. */
+ tAVRC_FULL_NAME name; /* The media name, name length and character set id. */
+ UINT8 attr_count; /* The number of attributes in p_attr_list */
+ tAVRC_ATTR_ENTRY *p_attr_list; /* Attribute entry list. */
+} tAVRC_ITEM_MEDIA;
+
+typedef struct {
+ UINT8 item_type; /* AVRC_ITEM_PLAYER, AVRC_ITEM_FOLDER, or AVRC_ITEM_MEDIA */
+ union {
+ tAVRC_ITEM_PLAYER player; /* The properties of a media player item.*/
+ tAVRC_ITEM_FOLDER folder; /* The properties of a folder item.*/
+ tAVRC_ITEM_MEDIA media; /* The properties of a media item.*/
+ } u;
+} tAVRC_ITEM;
+
+/* GetCapability */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 capability_id;
+} tAVRC_GET_CAPS_CMD;
+
+/* ListPlayerAppValues */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 attr_id;
+} tAVRC_LIST_APP_VALUES_CMD;
+
+/* GetCurAppValue */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 num_attr;
+ UINT8 attrs[AVRC_MAX_APP_ATTR_SIZE];
+} tAVRC_GET_CUR_APP_VALUE_CMD;
+
+/* SetAppValue */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 num_val;
+ tAVRC_APP_SETTING *p_vals;
+} tAVRC_SET_APP_VALUE_CMD;
+
+/* GetAppAttrTxt */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 num_attr;
+ UINT8 attrs[AVRC_MAX_APP_ATTR_SIZE];
+} tAVRC_GET_APP_ATTR_TXT_CMD;
+
+/* GetAppValueTxt */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 attr_id;
+ UINT8 num_val;
+ UINT8 vals[AVRC_MAX_APP_ATTR_SIZE];
+} tAVRC_GET_APP_VAL_TXT_CMD;
+
+/* InformCharset */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 num_id;
+ UINT16 charsets[AVRC_MAX_CHARSET_SIZE];
+} tAVRC_INFORM_CHARSET_CMD;
+
+/* InformBatteryStatus */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 battery_status;
+} tAVRC_BATTERY_STATUS_CMD;
+
+/* GetElemAttrs */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 num_attr;
+ UINT32 attrs[AVRC_MAX_ELEM_ATTR_SIZE];
+} tAVRC_GET_ELEM_ATTRS_CMD;
+
+/* RegNotify */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 event_id;
+ UINT32 param;
+} tAVRC_REG_NOTIF_CMD;
+
+/* SetAddrPlayer */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT16 player_id;
+} tAVRC_SET_ADDR_PLAYER_CMD;
+
+/* SetBrowsedPlayer */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT16 player_id;
+} tAVRC_SET_BR_PLAYER_CMD;
+
+/* SetAbsVolume */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 volume;
+} tAVRC_SET_VOLUME_CMD;
+
+/* GetFolderItems */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 scope;
+ UINT32 start_item;
+ UINT32 end_item;
+ UINT8 attr_count;
+ UINT32 *p_attr_list;
+} tAVRC_GET_ITEMS_CMD;
+
+/* ChangePath */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT16 uid_counter;
+ UINT8 direction;
+ tAVRC_UID folder_uid;
+} tAVRC_CHG_PATH_CMD;
+
+/* GetItemAttrs */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 scope;
+ tAVRC_UID uid;
+ UINT16 uid_counter;
+ UINT8 attr_count;
+ UINT32 *p_attr_list;
+} tAVRC_GET_ATTRS_CMD;
+
+/* Search */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ tAVRC_FULL_NAME string;
+} tAVRC_SEARCH_CMD;
+
+/* PlayItem */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 scope;
+ tAVRC_UID uid;
+ UINT16 uid_counter;
+} tAVRC_PLAY_ITEM_CMD;
+
+/* AddToNowPlaying */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 scope;
+ tAVRC_UID uid;
+ UINT16 uid_counter;
+} tAVRC_ADD_TO_PLAY_CMD;
+
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+} tAVRC_CMD;
+
+/* Continue and Abort */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (assigned by AVRC_BldCommand according to pdu) */
+ UINT8 target_pdu;
+} tAVRC_NEXT_CMD;
+
+typedef union {
+ UINT8 pdu;
+ tAVRC_CMD cmd;
+ tAVRC_GET_CAPS_CMD get_caps; /* GetCapability */
+ tAVRC_CMD list_app_attr; /* ListPlayerAppAttr */
+ tAVRC_LIST_APP_VALUES_CMD list_app_values; /* ListPlayerAppValues */
+ tAVRC_GET_CUR_APP_VALUE_CMD get_cur_app_val; /* GetCurAppValue */
+ tAVRC_SET_APP_VALUE_CMD set_app_val; /* SetAppValue */
+ tAVRC_GET_APP_ATTR_TXT_CMD get_app_attr_txt; /* GetAppAttrTxt */
+ tAVRC_GET_APP_VAL_TXT_CMD get_app_val_txt; /* GetAppValueTxt */
+ tAVRC_INFORM_CHARSET_CMD inform_charset; /* InformCharset */
+ tAVRC_BATTERY_STATUS_CMD inform_battery_status; /* InformBatteryStatus */
+ tAVRC_GET_ELEM_ATTRS_CMD get_elem_attrs; /* GetElemAttrs */
+ tAVRC_CMD get_play_status; /* GetPlayStatus */
+ tAVRC_REG_NOTIF_CMD reg_notif; /* RegNotify */
+ tAVRC_NEXT_CMD continu; /* Continue */
+ tAVRC_NEXT_CMD abort; /* Abort */
+
+ tAVRC_SET_ADDR_PLAYER_CMD addr_player; /* SetAddrPlayer */
+ tAVRC_SET_VOLUME_CMD volume; /* SetAbsVolume */
+ tAVRC_SET_BR_PLAYER_CMD br_player; /* SetBrowsedPlayer */
+ tAVRC_GET_ITEMS_CMD get_items; /* GetFolderItems */
+ tAVRC_CHG_PATH_CMD chg_path; /* ChangePath */
+ tAVRC_GET_ATTRS_CMD get_attrs; /* GetItemAttrs */
+ tAVRC_SEARCH_CMD search; /* Search */
+ tAVRC_PLAY_ITEM_CMD play_item; /* PlayItem */
+ tAVRC_ADD_TO_PLAY_CMD add_to_play; /* AddToNowPlaying */
+} tAVRC_COMMAND;
+
+/* GetCapability */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT8 capability_id;
+ UINT8 count;
+ tAVRC_CAPS_PARAM param;
+} tAVRC_GET_CAPS_RSP;
+
+/* ListPlayerAppAttr */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT8 num_attr;
+ UINT8 attrs[AVRC_MAX_APP_ATTR_SIZE];
+} tAVRC_LIST_APP_ATTR_RSP;
+
+/* ListPlayerAppValues */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT8 num_val;
+ UINT8 vals[AVRC_MAX_APP_ATTR_SIZE];
+} tAVRC_LIST_APP_VALUES_RSP;
+
+/* GetCurAppValue */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT8 num_val;
+ tAVRC_APP_SETTING *p_vals;
+} tAVRC_GET_CUR_APP_VALUE_RSP;
+
+/* GetAppAttrTxt */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT8 num_attr;
+ tAVRC_APP_SETTING_TEXT *p_attrs;
+} tAVRC_GET_APP_ATTR_TXT_RSP;
+
+/* GetElemAttrs */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT8 num_attr;
+ tAVRC_ATTR_ENTRY *p_attrs;
+} tAVRC_GET_ELEM_ATTRS_RSP;
+
+/* GetPlayStatus */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT32 song_len;
+ UINT32 song_pos;
+ UINT8 play_status;
+} tAVRC_GET_PLAY_STATUS_RSP;
+
+/* notification event parameter for AddressedPlayer change */
+typedef struct {
+ UINT16 player_id;
+ UINT16 uid_counter;
+} tAVRC_ADDR_PLAYER_PARAM;
+
+#ifndef AVRC_MAX_APP_SETTINGS
+#define AVRC_MAX_APP_SETTINGS 8
+#endif
+
+/* notification event parameter for Player Application setting change */
+typedef struct {
+ UINT8 num_attr;
+ UINT8 attr_id[AVRC_MAX_APP_SETTINGS];
+ UINT8 attr_value[AVRC_MAX_APP_SETTINGS];
+} tAVRC_PLAYER_APP_PARAM;
+
+typedef union {
+ tAVRC_PLAYSTATE play_status;
+ tAVRC_UID track;
+ UINT32 play_pos;
+ tAVRC_BATTERY_STATUS battery_status;
+ tAVRC_SYSTEMSTATE system_status;
+ tAVRC_PLAYER_APP_PARAM player_setting;
+ tAVRC_ADDR_PLAYER_PARAM addr_player;
+ UINT16 uid_counter;
+ UINT8 volume;
+} tAVRC_NOTIF_RSP_PARAM;
+
+/* RegNotify */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT8 event_id;
+ tAVRC_NOTIF_RSP_PARAM param;
+} tAVRC_REG_NOTIF_RSP;
+
+/* SetAbsVolume */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT8 volume;
+} tAVRC_SET_VOLUME_RSP;
+
+/* SetBrowsedPlayer */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT16 uid_counter;
+ UINT32 num_items;
+ UINT16 charset_id;
+ UINT8 folder_depth;
+ tAVRC_NAME *p_folders;
+} tAVRC_SET_BR_PLAYER_RSP;
+
+/* GetFolderItems */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT16 uid_counter;
+ UINT16 item_count;
+ tAVRC_ITEM *p_item_list;
+} tAVRC_GET_ITEMS_RSP;
+
+/* ChangePath */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT32 num_items;
+} tAVRC_CHG_PATH_RSP;
+
+/* GetItemAttrs */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT8 attr_count;
+ tAVRC_ATTR_ENTRY *p_attr_list;
+} tAVRC_GET_ATTRS_RSP;
+
+/* Search */
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+ UINT16 uid_counter;
+ UINT32 num_items;
+} tAVRC_SEARCH_RSP;
+
+
+typedef struct {
+ UINT8 pdu;
+ tAVRC_STS status;
+ UINT8 opcode; /* Op Code (copied from avrc_cmd.opcode by AVRC_BldResponse user. invalid one to generate according to pdu) */
+} tAVRC_RSP;
+
+typedef union {
+ UINT8 pdu;
+ tAVRC_RSP rsp;
+ tAVRC_GET_CAPS_RSP get_caps; /* GetCapability */
+ tAVRC_LIST_APP_ATTR_RSP list_app_attr; /* ListPlayerAppAttr */
+ tAVRC_LIST_APP_VALUES_RSP list_app_values; /* ListPlayerAppValues */
+ tAVRC_GET_CUR_APP_VALUE_RSP get_cur_app_val; /* GetCurAppValue */
+ tAVRC_RSP set_app_val; /* SetAppValue */
+ tAVRC_GET_APP_ATTR_TXT_RSP get_app_attr_txt; /* GetAppAttrTxt */
+ tAVRC_GET_APP_ATTR_TXT_RSP get_app_val_txt; /* GetAppValueTxt */
+ tAVRC_RSP inform_charset; /* InformCharset */
+ tAVRC_RSP inform_battery_status; /* InformBatteryStatus */
+ tAVRC_GET_ELEM_ATTRS_RSP get_elem_attrs; /* GetElemAttrs */
+ tAVRC_GET_PLAY_STATUS_RSP get_play_status; /* GetPlayStatus */
+ tAVRC_REG_NOTIF_RSP reg_notif; /* RegNotify */
+ tAVRC_RSP continu; /* Continue */
+ tAVRC_RSP abort; /* Abort */
+
+ tAVRC_RSP addr_player; /* SetAddrPlayer */
+ tAVRC_SET_VOLUME_RSP volume; /* SetAbsVolume */
+ tAVRC_SET_BR_PLAYER_RSP br_player; /* SetBrowsedPlayer */
+ tAVRC_GET_ITEMS_RSP get_items; /* GetFolderItems */
+ tAVRC_CHG_PATH_RSP chg_path; /* ChangePath */
+ tAVRC_GET_ATTRS_RSP get_attrs; /* GetItemAttrs */
+ tAVRC_SEARCH_RSP search; /* Search */
+ tAVRC_RSP play_item; /* PlayItem */
+ tAVRC_RSP add_to_play; /* AddToNowPlaying */
+} tAVRC_RESPONSE;
+
+#endif ///AVRC_INCLUDED == TRUE
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/bt_types.h b/lib/bt/host/bluedroid/stack/include/stack/bt_types.h
new file mode 100644
index 00000000..be803d50
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/bt_types.h
@@ -0,0 +1,781 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef BT_TYPES_H
+#define BT_TYPES_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "bt_common.h"
+#include "osi/semaphore.h"
+
+typedef int8_t INT8;
+typedef int16_t INT16;
+typedef int32_t INT32;
+
+#define PACKED __packed
+// #define INLINE __inline
+
+#define BCM_STRCPY_S(x1,x2) strcpy((x1),(x2))
+#define BCM_STRNCPY_S(x1,x2,x3) strncpy((x1),(x2),(x3))
+
+/* READ WELL !!
+**
+** This section defines global events. These are events that cross layers.
+** Any event that passes between layers MUST be one of these events. Tasks
+** can use their own events internally, but a FUNDAMENTAL design issue is
+** that global events MUST be one of these events defined below.
+**
+** The convention used is the the event name contains the layer that the
+** event is going to.
+*/
+#define BT_EVT_MASK 0xFF00
+#define BT_SUB_EVT_MASK 0x00FF
+#define BT_STATIC_RAND_ADDR_MASK 0xC0
+#define BT_NON_RPA_MASK 0x3F
+/* To Bluetooth Upper Layers */
+/************************************/
+#define BT_EVT_TO_BTU_L2C_EVT 0x0900 /* L2CAP event */
+#define BT_EVT_TO_BTU_HCI_EVT 0x1000 /* HCI Event */
+#define BT_EVT_TO_BTU_HCI_BR_EDR_EVT (0x0000 | BT_EVT_TO_BTU_HCI_EVT) /* event from BR/EDR controller */
+#define BT_EVT_TO_BTU_HCI_AMP1_EVT (0x0001 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 1 controller */
+#define BT_EVT_TO_BTU_HCI_AMP2_EVT (0x0002 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 2 controller */
+#define BT_EVT_TO_BTU_HCI_AMP3_EVT (0x0003 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 3 controller */
+
+#define BT_EVT_TO_BTU_HCI_ACL 0x1100 /* ACL Data from HCI */
+#define BT_EVT_TO_BTU_HCI_SCO 0x1200 /* SCO Data from HCI */
+#define BT_EVT_TO_BTU_HCIT_ERR 0x1300 /* HCI Transport Error */
+
+#define BT_EVT_TO_BTU_SP_EVT 0x1400 /* Serial Port Event */
+#define BT_EVT_TO_BTU_SP_DATA 0x1500 /* Serial Port Data */
+
+#define BT_EVT_TO_BTU_HCI_CMD 0x1600 /* HCI command from upper layer */
+
+
+#define BT_EVT_TO_BTU_L2C_SEG_XMIT 0x1900 /* L2CAP segment(s) transmitted */
+
+#define BT_EVT_PROXY_INCOMING_MSG 0x1A00 /* BlueStackTester event: incoming message from target */
+
+#define BT_EVT_BTSIM 0x1B00 /* Insight BTSIM event */
+#define BT_EVT_BTISE 0x1C00 /* Insight Script Engine event */
+
+/* To LM */
+/************************************/
+#define BT_EVT_TO_LM_HCI_CMD 0x2000 /* HCI Command */
+#define BT_EVT_TO_LM_HCI_ACL 0x2100 /* HCI ACL Data */
+#define BT_EVT_TO_LM_HCI_SCO 0x2200 /* HCI SCO Data */
+#define BT_EVT_TO_LM_HCIT_ERR 0x2300 /* HCI Transport Error */
+#define BT_EVT_TO_LM_LC_EVT 0x2400 /* LC event */
+#define BT_EVT_TO_LM_LC_LMP 0x2500 /* LC Received LMP command frame */
+#define BT_EVT_TO_LM_LC_ACL 0x2600 /* LC Received ACL data */
+#define BT_EVT_TO_LM_LC_SCO 0x2700 /* LC Received SCO data (not used) */
+#define BT_EVT_TO_LM_LC_ACL_TX 0x2800 /* LMP data transmit complete */
+#define BT_EVT_TO_LM_LC_LMPC_TX 0x2900 /* LMP Command transmit complete */
+#define BT_EVT_TO_LM_LOCAL_ACL_LB 0x2a00 /* Data to be locally loopbacked */
+#define BT_EVT_TO_LM_HCI_ACL_ACK 0x2b00 /* HCI ACL Data ack (not used) */
+#define BT_EVT_TO_LM_DIAG 0x2c00 /* LM Diagnostics commands */
+
+
+#define BT_EVT_TO_BTM_CMDS 0x2f00
+#define BT_EVT_TO_BTM_PM_MDCHG_EVT (0x0001 | BT_EVT_TO_BTM_CMDS)
+
+#define BT_EVT_TO_TCS_CMDS 0x3000
+
+#define BT_EVT_TO_CTP_CMDS 0x3300
+
+/* ftp events */
+#define BT_EVT_TO_FTP_SRVR_CMDS 0x3600
+#define BT_EVT_TO_FTP_CLNT_CMDS 0x3700
+
+#define BT_EVT_TO_BTU_SAP 0x3800 /* SIM Access Profile events */
+
+/* opp events */
+#define BT_EVT_TO_OPP_SRVR_CMDS 0x3900
+#define BT_EVT_TO_OPP_CLNT_CMDS 0x3a00
+
+/* gap events */
+#define BT_EVT_TO_GAP_MSG 0x3b00
+
+/* for NFC */
+/************************************/
+#define BT_EVT_TO_NFC_NCI 0x4000 /* NCI Command, Notification or Data*/
+#define BT_EVT_TO_NFC_INIT 0x4100 /* Initialization message */
+#define BT_EVT_TO_NCI_LP 0x4200 /* Low power */
+#define BT_EVT_TO_NFC_ERR 0x4300 /* Error notification to NFC Task */
+
+#define BT_EVT_TO_NFCCSIM_NCI 0x4a00 /* events to NFCC simulation (NCI packets) */
+
+/* HCISU Events */
+
+#define BT_EVT_HCISU 0x5000
+
+// btla-specific ++
+#define BT_EVT_TO_HCISU_RECONFIG_EVT (0x0001 | BT_EVT_HCISU)
+#define BT_EVT_TO_HCISU_UPDATE_BAUDRATE_EVT (0x0002 | BT_EVT_HCISU)
+#define BT_EVT_TO_HCISU_LP_ENABLE_EVT (0x0003 | BT_EVT_HCISU)
+#define BT_EVT_TO_HCISU_LP_DISABLE_EVT (0x0004 | BT_EVT_HCISU)
+// btla-specific --
+#define BT_EVT_TO_HCISU_LP_APP_SLEEPING_EVT (0x0005 | BT_EVT_HCISU)
+#define BT_EVT_TO_HCISU_LP_ALLOW_BT_SLEEP_EVT (0x0006 | BT_EVT_HCISU)
+#define BT_EVT_TO_HCISU_LP_WAKEUP_HOST_EVT (0x0007 | BT_EVT_HCISU)
+#define BT_EVT_TO_HCISU_LP_RCV_H4IBSS_EVT (0x0008 | BT_EVT_HCISU)
+#define BT_EVT_TO_HCISU_H5_RESET_EVT (0x0009 | BT_EVT_HCISU)
+#define BT_EVT_HCISU_START_QUICK_TIMER (0x000a | BT_EVT_HCISU)
+
+#define BT_EVT_DATA_TO_AMP_1 0x5100
+#define BT_EVT_DATA_TO_AMP_15 0x5f00
+
+/* HSP Events */
+
+#define BT_EVT_BTU_HSP2 0x6000
+
+#define BT_EVT_TO_BTU_HSP2_EVT (0x0001 | BT_EVT_BTU_HSP2)
+
+/* BPP Events */
+#define BT_EVT_TO_BPP_PR_CMDS 0x6100 /* Printer Events */
+#define BT_EVT_TO_BPP_SND_CMDS 0x6200 /* BPP Sender Events */
+
+/* BIP Events */
+#define BT_EVT_TO_BIP_CMDS 0x6300
+
+/* HCRP Events */
+
+#define BT_EVT_BTU_HCRP 0x7000
+
+#define BT_EVT_TO_BTU_HCRP_EVT (0x0001 | BT_EVT_BTU_HCRP)
+#define BT_EVT_TO_BTU_HCRPM_EVT (0x0002 | BT_EVT_BTU_HCRP)
+
+
+#define BT_EVT_BTU_HFP 0x8000
+#define BT_EVT_TO_BTU_HFP_EVT (0x0001 | BT_EVT_BTU_HFP)
+
+#define BT_EVT_BTU_IPC_EVT 0x9000
+#define BT_EVT_BTU_IPC_LOGMSG_EVT (0x0000 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_ACL_EVT (0x0001 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_BTU_EVT (0x0002 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_L2C_EVT (0x0003 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_L2C_MSG_EVT (0x0004 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_BTM_EVT (0x0005 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_AVDT_EVT (0x0006 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_SLIP_EVT (0x0007 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_MGMT_EVT (0x0008 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_BTTRC_EVT (0x0009 | BT_EVT_BTU_IPC_EVT)
+#define BT_EVT_BTU_IPC_BURST_EVT (0x000A | BT_EVT_BTU_IPC_EVT)
+
+
+/* BTIF Events */
+#define BT_EVT_BTIF 0xA000
+#define BT_EVT_CONTEXT_SWITCH_EVT (0x0001 | BT_EVT_BTIF)
+
+/* Define the header of each buffer used in the Bluetooth stack.
+*/
+typedef struct {
+ uint16_t event;
+ uint16_t len;
+ uint16_t offset;
+ uint16_t layer_specific;
+ uint8_t data[];
+} BT_HDR;
+
+typedef struct {
+ uint8_t status;
+ uint16_t opcode;
+ osi_sem_t sync_sem;
+} BlE_SYNC;
+
+
+#define BT_HDR_SIZE (sizeof (BT_HDR))
+
+#define BT_PSM_SDP 0x0001
+#define BT_PSM_RFCOMM 0x0003
+#define BT_PSM_TCS 0x0005
+#define BT_PSM_CTP 0x0007
+#define BT_PSM_BNEP 0x000F
+#define BT_PSM_HIDC 0x0011
+#define BT_PSM_HIDI 0x0013
+#define BT_PSM_UPNP 0x0015
+#define BT_PSM_AVCTP 0x0017
+#define BT_PSM_AVDTP 0x0019
+#define BT_PSM_AVCTP_13 0x001B /* Advanced Control - Browsing */
+#define BT_PSM_UDI_CP 0x001D /* Unrestricted Digital Information Profile C-Plane */
+#define BT_PSM_ATT 0x001F /* Attribute Protocol */
+
+
+/* These macros extract the HCI opcodes from a buffer
+*/
+#define HCI_GET_CMD_HDR_OPCODE(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset) + \
+ (*((UINT8 *)((p) + 1) + p->offset + 1) << 8)))
+#define HCI_GET_CMD_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 2))
+
+#define HCI_GET_EVT_HDR_OPCODE(p) (UINT8)(*((UINT8 *)((p) + 1) + p->offset))
+#define HCI_GET_EVT_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 1))
+
+
+/********************************************************************************
+** Macros to get and put bytes to and from a stream (Little Endian format).
+*/
+#define UINT32_TO_STREAM(p, u32) {*(p)++ = (UINT8)(u32); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 24);}
+#define UINT24_TO_STREAM(p, u24) {*(p)++ = (UINT8)(u24); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)((u24) >> 16);}
+#define UINT16_TO_STREAM(p, u16) {*(p)++ = (UINT8)(u16); *(p)++ = (UINT8)((u16) >> 8);}
+#define UINT8_TO_STREAM(p, u8) {*(p)++ = (UINT8)(u8);}
+#define INT8_TO_STREAM(p, u8) {*(p)++ = (INT8)(u8);}
+#define ARRAY32_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 32; ijk++) *(p)++ = (UINT8) a[31 - ijk];}
+#define ARRAY16_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 16; ijk++) *(p)++ = (UINT8) a[15 - ijk];}
+#define ARRAY8_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 8; ijk++) *(p)++ = (UINT8) a[7 - ijk];}
+#define BDADDR_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *(p)++ = (UINT8) a[BD_ADDR_LEN - 1 - ijk];}
+#define LAP_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < LAP_LEN; ijk++) *(p)++ = (UINT8) a[LAP_LEN - 1 - ijk];}
+#define DEVCLASS_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < DEV_CLASS_LEN;ijk++) *(p)++ = (UINT8) a[DEV_CLASS_LEN - 1 - ijk];}
+#define ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];}
+#define REVERSE_ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[len - 1 - ijk];}
+
+#define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
+#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
+#define STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) ); (p) += 3;}
+#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
+#define STREAM_TO_BDADDR(a, p) {register int ijk; register UINT8 *pbda = (UINT8 *)a + BD_ADDR_LEN - 1; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *pbda-- = *p++;}
+#define STREAM_TO_ARRAY32(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 31; for (ijk = 0; ijk < 32; ijk++) *_pa-- = *p++;}
+#define STREAM_TO_ARRAY16(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 15; for (ijk = 0; ijk < 16; ijk++) *_pa-- = *p++;}
+#define STREAM_TO_ARRAY8(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 7; for (ijk = 0; ijk < 8; ijk++) *_pa-- = *p++;}
+#define STREAM_TO_DEVCLASS(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + DEV_CLASS_LEN - 1; for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) *_pa-- = *p++;}
+#define STREAM_TO_LAP(a, p) {register int ijk; register UINT8 *plap = (UINT8 *)a + LAP_LEN - 1; for (ijk = 0; ijk < LAP_LEN; ijk++) *plap-- = *p++;}
+#define STREAM_TO_ARRAY(a, p, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;}
+#define REVERSE_STREAM_TO_ARRAY(a, p, len) {register int ijk; register UINT8 *_pa = (UINT8 *)a + len - 1; for (ijk = 0; ijk < len; ijk++) *_pa-- = *p++;}
+
+#define STREAM_SKIP_UINT8(p) do { (p) += 1; } while (0)
+#define STREAM_SKIP_UINT16(p) do { (p) += 2; } while (0)
+
+/********************************************************************************
+** Macros to get and put bytes to and from a field (Little Endian format).
+** These are the same as to stream, except the pointer is not incremented.
+*/
+#define UINT32_TO_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)(u32); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+3) = (UINT8)((u32) >> 24);}
+#define UINT24_TO_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)(u24); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u24) >> 16);}
+#define UINT16_TO_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)(u16); *((UINT8 *)(p)+1) = (UINT8)((u16) >> 8);}
+#define UINT8_TO_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);}
+
+
+/********************************************************************************
+** Macros to get and put bytes to and from a stream (Big Endian format)
+*/
+#define UINT64_TO_BE_STREAM(p, u64) {*(p)++ = (UINT8)((u64) >> 56); *(p)++ = (UINT8)((u64) >> 48); *(p)++ = (UINT8)((u64) >> 40); *(p)++ = (UINT8)((u64) >> 32); *(p)++ = (UINT8)((u64) >> 24); *(p)++ = (UINT8)((u64) >> 16); *(p)++ = (UINT8)((u64) >> 8); *(p)++ = (UINT8)(u64); }
+#define UINT32_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 24); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
+#define UINT24_TO_BE_STREAM(p, u24) {*(p)++ = (UINT8)((u24) >> 16); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)(u24);}
+#define UINT16_TO_BE_STREAM(p, u16) {*(p)++ = (UINT8)((u16) >> 8); *(p)++ = (UINT8)(u16);}
+#define UINT8_TO_BE_STREAM(p, u8) {*(p)++ = (UINT8)(u8);}
+#define ARRAY_TO_BE_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];}
+#define ARRAY_TO_BE_STREAM_REVERSE(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[len - ijk - 1];}
+
+#define BE_STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
+#define BE_STREAM_TO_UINT16(u16, p) {u16 = (UINT16)(((UINT16)(*(p)) << 8) + (UINT16)(*((p) + 1))); (p) += 2;}
+#define BE_STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*((p) + 2))) + ((UINT32)(*((p) + 1)) << 8) + ((UINT32)(*(p)) << 16)); (p) += 3;}
+#define BE_STREAM_TO_UINT32(u32, p) {u32 = ((UINT32)(*((p) + 3)) + ((UINT32)(*((p) + 2)) << 8) + ((UINT32)(*((p) + 1)) << 16) + ((UINT32)(*(p)) << 24)); (p) += 4;}
+#define BE_STREAM_TO_ARRAY(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;}
+
+
+/********************************************************************************
+** Macros to get and put bytes to and from a field (Big Endian format).
+** These are the same as to stream, except the pointer is not incremented.
+*/
+#define UINT32_TO_BE_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)((u32) >> 24); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+3) = (UINT8)(u32); }
+#define UINT24_TO_BE_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)((u24) >> 16); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)(u24);}
+#define UINT16_TO_BE_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)((u16) >> 8); *((UINT8 *)(p)+1) = (UINT8)(u16);}
+#define UINT8_TO_BE_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);}
+
+
+/* Common Bluetooth field definitions */
+typedef UINT8 *BD_ADDR_PTR; /* Pointer to Device Address */
+
+#define AMP_KEY_TYPE_GAMP 0
+#define AMP_KEY_TYPE_WIFI 1
+#define AMP_KEY_TYPE_UWB 2
+typedef UINT8 tAMP_KEY_TYPE;
+
+#define BT_OCTET8_LEN 8
+typedef UINT8 BT_OCTET8[BT_OCTET8_LEN]; /* octet array: size 16 */
+
+#define LINK_KEY_LEN 16
+typedef UINT8 LINK_KEY[LINK_KEY_LEN]; /* Link Key */
+
+#define AMP_LINK_KEY_LEN 32
+typedef UINT8 AMP_LINK_KEY[AMP_LINK_KEY_LEN]; /* Dedicated AMP and GAMP Link Keys */
+
+#define BT_OCTET16_LEN 16
+typedef UINT8 BT_OCTET16[BT_OCTET16_LEN]; /* octet array: size 16 */
+
+#define PIN_CODE_LEN 16
+typedef UINT8 PIN_CODE[PIN_CODE_LEN]; /* Pin Code (upto 128 bits) MSB is 0 */
+typedef UINT8 *PIN_CODE_PTR; /* Pointer to Pin Code */
+
+#define BT_OCTET32_LEN 32
+typedef UINT8 BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */
+
+#define DEV_CLASS_LEN 3
+typedef UINT8 DEV_CLASS[DEV_CLASS_LEN]; /* Device class */
+typedef UINT8 *DEV_CLASS_PTR; /* Pointer to Device class */
+
+#define EXT_INQ_RESP_LEN 3
+typedef UINT8 EXT_INQ_RESP[EXT_INQ_RESP_LEN];/* Extended Inquiry Response */
+typedef UINT8 *EXT_INQ_RESP_PTR; /* Pointer to Extended Inquiry Response */
+
+#define BD_NAME_LEN 248
+typedef UINT8 BD_NAME[BD_NAME_LEN + 1]; /* Device name */
+typedef UINT8 *BD_NAME_PTR; /* Pointer to Device name */
+
+#define BD_FEATURES_LEN 8
+typedef UINT8 BD_FEATURES[BD_FEATURES_LEN]; /* LMP features supported by device */
+
+#define BT_EVENT_MASK_LEN 8
+typedef UINT8 BT_EVENT_MASK[BT_EVENT_MASK_LEN]; /* Event Mask */
+
+#define LAP_LEN 3
+typedef UINT8 LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
+typedef UINT8 INQ_LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
+
+#define RAND_NUM_LEN 16
+typedef UINT8 RAND_NUM[RAND_NUM_LEN];
+
+#define ACO_LEN 12
+typedef UINT8 ACO[ACO_LEN]; /* Authenticated ciphering offset */
+
+#define COF_LEN 12
+typedef UINT8 COF[COF_LEN]; /* ciphering offset number */
+
+#define AFH_CHANNELS_LEN 10
+typedef UINT8 AFH_CHANNELS[AFH_CHANNELS_LEN];
+#define BLE_CHANNELS_LEN 5
+typedef UINT8 BLE_CHANNELS[BLE_CHANNELS_LEN];
+
+typedef struct {
+ UINT8 qos_flags; /* TBD */
+ UINT8 service_type; /* see below */
+ UINT32 token_rate; /* bytes/second */
+ UINT32 token_bucket_size; /* bytes */
+ UINT32 peak_bandwidth; /* bytes/second */
+ UINT32 latency; /* microseconds */
+ UINT32 delay_variation; /* microseconds */
+} FLOW_SPEC;
+
+/* Values for service_type */
+#define NO_TRAFFIC 0
+#define BEST_EFFORT 1
+#define GUARANTEED 2
+
+/* Service class of the CoD */
+#define SERV_CLASS_NETWORKING (1 << 1)
+#define SERV_CLASS_RENDERING (1 << 2)
+#define SERV_CLASS_CAPTURING (1 << 3)
+#define SERV_CLASS_OBJECT_TRANSFER (1 << 4)
+#define SERV_CLASS_OBJECT_AUDIO (1 << 5)
+#define SERV_CLASS_OBJECT_TELEPHONY (1 << 6)
+#define SERV_CLASS_OBJECT_INFORMATION (1 << 7)
+
+/* Second byte */
+#define SERV_CLASS_LIMITED_DISC_MODE (0x20)
+
+/* Field size definitions. Note that byte lengths are rounded up. */
+#define ACCESS_CODE_BIT_LEN 72
+#define ACCESS_CODE_BYTE_LEN 9
+#define SHORTENED_ACCESS_CODE_BIT_LEN 68
+
+typedef UINT8 ACCESS_CODE[ACCESS_CODE_BYTE_LEN];
+
+#define SYNTH_TX 1 /* want synth code to TRANSMIT at this freq */
+#define SYNTH_RX 2 /* want synth code to RECEIVE at this freq */
+
+#define SYNC_REPS 1 /* repeats of sync word transmitted to start of burst */
+
+/* Bluetooth CLK27 */
+#define BT_CLK27 (2 << 26)
+
+/* Bluetooth CLK12 is 1.28 sec */
+#define BT_CLK12_TO_MS(x) ((x) * 1280)
+#define BT_MS_TO_CLK12(x) ((x) / 1280)
+#define BT_CLK12_TO_SLOTS(x) ((x) << 11)
+
+/* Bluetooth CLK is 0.625 msec */
+#define BT_CLK_TO_MS(x) (((x) * 5 + 3) / 8)
+#define BT_MS_TO_CLK(x) (((x) * 8 + 2) / 5)
+
+#define BT_CLK_TO_MICROSECS(x) (((x) * 5000 + 3) / 8)
+#define BT_MICROSECS_TO_CLK(x) (((x) * 8 + 2499) / 5000)
+
+#define BT_EIR_FLAGS_TYPE 0x01
+#define BT_EIR_MORE_16BITS_UUID_TYPE 0x02
+#define BT_EIR_COMPLETE_16BITS_UUID_TYPE 0x03
+#define BT_EIR_MORE_32BITS_UUID_TYPE 0x04
+#define BT_EIR_COMPLETE_32BITS_UUID_TYPE 0x05
+#define BT_EIR_MORE_128BITS_UUID_TYPE 0x06
+#define BT_EIR_COMPLETE_128BITS_UUID_TYPE 0x07
+#define BT_EIR_SHORTENED_LOCAL_NAME_TYPE 0x08
+#define BT_EIR_COMPLETE_LOCAL_NAME_TYPE 0x09
+#define BT_EIR_TX_POWER_LEVEL_TYPE 0x0A
+#define BT_EIR_OOB_BD_ADDR_TYPE 0x0C
+#define BT_EIR_OOB_COD_TYPE 0x0D
+#define BT_EIR_OOB_SSP_HASH_C_TYPE 0x0E
+#define BT_EIR_OOB_SSP_RAND_R_TYPE 0x0F
+#define BT_EIR_URL_TYPE 0x24
+#define BT_EIR_MANUFACTURER_SPECIFIC_TYPE 0xFF
+
+#define BT_OOB_COD_SIZE 3
+#define BT_OOB_HASH_C_SIZE 16
+#define BT_OOB_RAND_R_SIZE 16
+
+/* Broadcom proprietary UUIDs and reserved PSMs
+**
+** The lowest 4 bytes byte of the UUID or GUID depends on the feature. Typically,
+** the value of those bytes will be the PSM or SCN, but it is up to the features.
+*/
+#define BRCM_PROPRIETARY_UUID_BASE 0xDA, 0x23, 0x41, 0x02, 0xA3, 0xBB, 0xC1, 0x71, 0xBA, 0x09, 0x6f, 0x21
+#define BRCM_PROPRIETARY_GUID_BASE 0xda23, 0x4102, 0xa3, 0xbb, 0xc1, 0x71, 0xba, 0x09, 0x6f, 0x21
+
+/* We will not allocate a PSM in the reserved range to 3rd party apps
+*/
+#define BRCM_RESERVED_PSM_START 0x5AE1
+#define BRCM_RESERVED_PSM_END 0x5AFF
+
+#define BRCM_UTILITY_SERVICE_PSM 0x5AE1
+#define BRCM_MATCHER_PSM 0x5AE3
+
+/* Connection statistics
+*/
+
+/* Structure to hold connection stats */
+#ifndef BT_CONN_STATS_DEFINED
+#define BT_CONN_STATS_DEFINED
+
+/* These bits are used in the bIsConnected field */
+#define BT_CONNECTED_USING_BREDR 1
+#define BT_CONNECTED_USING_AMP 2
+
+typedef struct {
+ UINT32 is_connected;
+ INT32 rssi;
+ UINT32 bytes_sent;
+ UINT32 bytes_rcvd;
+ UINT32 duration;
+} tBT_CONN_STATS;
+
+#endif
+
+
+/*****************************************************************************
+** Low Energy definitions
+**
+** Address types
+*/
+#define BLE_ADDR_PUBLIC 0x00
+#define BLE_ADDR_RANDOM 0x01
+#define BLE_ADDR_PUBLIC_ID 0x02
+#define BLE_ADDR_RANDOM_ID 0x03
+#define BLE_ADDR_TYPE_MAX BLE_ADDR_RANDOM_ID
+#define BLE_ADDR_UNKNOWN_TYPE 0XFF
+typedef UINT8 tBLE_ADDR_TYPE;
+#define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC)
+
+#define BT_TRANSPORT_INVALID 0
+#define BT_TRANSPORT_BR_EDR 1
+#define BT_TRANSPORT_LE 2
+typedef UINT8 tBT_TRANSPORT;
+
+#define BLE_ADDR_IS_STATIC(x) ((x[0] & 0xC0) == 0xC0)
+
+typedef struct {
+ tBLE_ADDR_TYPE type;
+ BD_ADDR bda;
+} tBLE_BD_ADDR;
+
+/* Device Types
+*/
+#define BT_DEVICE_TYPE_BREDR 0x01
+#define BT_DEVICE_TYPE_BLE 0x02
+#define BT_DEVICE_TYPE_DUMO 0x03
+typedef UINT8 tBT_DEVICE_TYPE;
+/*****************************************************************************/
+
+/* Define New Trace Type Definition */
+/* TRACE_CTRL_TYPE 0x^^000000*/
+#define TRACE_CTRL_MASK 0xff000000
+#define TRACE_GET_CTRL(x) ((((UINT32)(x)) & TRACE_CTRL_MASK) >> 24)
+
+#define TRACE_CTRL_GENERAL 0x00000000
+#define TRACE_CTRL_STR_RESOURCE 0x01000000
+#define TRACE_CTRL_SEQ_FLOW 0x02000000
+#define TRACE_CTRL_MAX_NUM 3
+
+/* LAYER SPECIFIC 0x00^^0000*/
+#define TRACE_LAYER_MASK 0x00ff0000
+#define TRACE_GET_LAYER(x) ((((UINT32)(x)) & TRACE_LAYER_MASK) >> 16)
+
+#define TRACE_LAYER_NONE 0x00000000
+#define TRACE_LAYER_USB 0x00010000
+#define TRACE_LAYER_SERIAL 0x00020000
+#define TRACE_LAYER_SOCKET 0x00030000
+#define TRACE_LAYER_RS232 0x00040000
+#define TRACE_LAYER_TRANS_MAX_NUM 5
+#define TRACE_LAYER_TRANS_ALL 0x007f0000
+#define TRACE_LAYER_LC 0x00050000
+#define TRACE_LAYER_LM 0x00060000
+#define TRACE_LAYER_HCI 0x00070000
+#define TRACE_LAYER_L2CAP 0x00080000
+#define TRACE_LAYER_RFCOMM 0x00090000
+#define TRACE_LAYER_SDP 0x000a0000
+#define TRACE_LAYER_TCS 0x000b0000
+#define TRACE_LAYER_OBEX 0x000c0000
+#define TRACE_LAYER_BTM 0x000d0000
+#define TRACE_LAYER_GAP 0x000e0000
+#define TRACE_LAYER_ICP 0x00110000
+#define TRACE_LAYER_HSP2 0x00120000
+#define TRACE_LAYER_SPP 0x00130000
+#define TRACE_LAYER_CTP 0x00140000
+#define TRACE_LAYER_BPP 0x00150000
+#define TRACE_LAYER_HCRP 0x00160000
+#define TRACE_LAYER_FTP 0x00170000
+#define TRACE_LAYER_OPP 0x00180000
+#define TRACE_LAYER_BTU 0x00190000
+#define TRACE_LAYER_GKI 0x001a0000
+#define TRACE_LAYER_BNEP 0x001b0000
+#define TRACE_LAYER_PAN 0x001c0000
+#define TRACE_LAYER_HFP 0x001d0000
+#define TRACE_LAYER_HID 0x001e0000
+#define TRACE_LAYER_BIP 0x001f0000
+#define TRACE_LAYER_AVP 0x00200000
+#define TRACE_LAYER_A2D 0x00210000
+#define TRACE_LAYER_SAP 0x00220000
+#define TRACE_LAYER_AMP 0x00230000
+#define TRACE_LAYER_MCA 0x00240000
+#define TRACE_LAYER_ATT 0x00250000
+#define TRACE_LAYER_SMP 0x00260000
+#define TRACE_LAYER_NFC 0x00270000
+#define TRACE_LAYER_NCI 0x00280000
+#define TRACE_LAYER_LLCP 0x00290000
+#define TRACE_LAYER_NDEF 0x002a0000
+#define TRACE_LAYER_RW 0x002b0000
+#define TRACE_LAYER_CE 0x002c0000
+#define TRACE_LAYER_P2P 0x002d0000
+#define TRACE_LAYER_SNEP 0x002e0000
+#define TRACE_LAYER_CHO 0x002f0000
+#define TRACE_LAYER_NFA 0x00300000
+
+#define TRACE_LAYER_MAX_NUM 0x0031
+
+
+/* TRACE_ORIGINATOR 0x0000^^00*/
+#define TRACE_ORG_MASK 0x0000ff00
+#define TRACE_GET_ORG(x) ((((UINT32)(x)) & TRACE_ORG_MASK) >> 8)
+
+#define TRACE_ORG_STACK 0x00000000
+#define TRACE_ORG_HCI_TRANS 0x00000100
+#define TRACE_ORG_PROTO_DISP 0x00000200
+#define TRACE_ORG_RPC 0x00000300
+#define TRACE_ORG_GKI 0x00000400
+#define TRACE_ORG_APPL 0x00000500
+#define TRACE_ORG_SCR_WRAPPER 0x00000600
+#define TRACE_ORG_SCR_ENGINE 0x00000700
+#define TRACE_ORG_USER_SCR 0x00000800
+#define TRACE_ORG_TESTER 0x00000900
+#define TRACE_ORG_MAX_NUM 10 /* 32-bit mask; must be < 32 */
+#define TRACE_LITE_ORG_MAX_NUM 6
+#define TRACE_ORG_ALL 0x03ff
+#define TRACE_ORG_RPC_TRANS 0x04
+
+#define TRACE_ORG_REG 0x00000909
+#define TRACE_ORG_REG_SUCCESS 0x0000090a
+
+/* TRACE_TYPE 0x000000^^*/
+#define TRACE_TYPE_MASK 0x000000ff
+#define TRACE_GET_TYPE(x) (((UINT32)(x)) & TRACE_TYPE_MASK)
+
+#define TRACE_TYPE_ERROR 0x00000000
+#define TRACE_TYPE_WARNING 0x00000001
+#define TRACE_TYPE_API 0x00000002
+#define TRACE_TYPE_EVENT 0x00000003
+#define TRACE_TYPE_DEBUG 0x00000004
+#define TRACE_TYPE_STACK_ONLY_MAX TRACE_TYPE_DEBUG
+#define TRACE_TYPE_TX 0x00000005
+#define TRACE_TYPE_RX 0x00000006
+#define TRACE_TYPE_DEBUG_ASSERT 0x00000007
+#define TRACE_TYPE_GENERIC 0x00000008
+#define TRACE_TYPE_REG 0x00000009
+#define TRACE_TYPE_REG_SUCCESS 0x0000000a
+#define TRACE_TYPE_CMD_TX 0x0000000b
+#define TRACE_TYPE_EVT_TX 0x0000000c
+#define TRACE_TYPE_ACL_TX 0x0000000d
+#define TRACE_TYPE_CMD_RX 0x0000000e
+#define TRACE_TYPE_EVT_RX 0x0000000f
+#define TRACE_TYPE_ACL_RX 0x00000010
+#define TRACE_TYPE_TARGET_TRACE 0x00000011
+#define TRACE_TYPE_SCO_TX 0x00000012
+#define TRACE_TYPE_SCO_RX 0x00000013
+
+
+#define TRACE_TYPE_MAX_NUM 20
+#define TRACE_TYPE_ALL 0xffff
+
+/* Define color for script type */
+#define SCR_COLOR_DEFAULT 0
+#define SCR_COLOR_TYPE_COMMENT 1
+#define SCR_COLOR_TYPE_COMMAND 2
+#define SCR_COLOR_TYPE_EVENT 3
+#define SCR_COLOR_TYPE_SELECT 4
+
+/* Define protocol trace flag values */
+#define SCR_PROTO_TRACE_HCI_SUMMARY 0x00000001
+#define SCR_PROTO_TRACE_HCI_DATA 0x00000002
+#define SCR_PROTO_TRACE_L2CAP 0x00000004
+#define SCR_PROTO_TRACE_RFCOMM 0x00000008
+#define SCR_PROTO_TRACE_SDP 0x00000010
+#define SCR_PROTO_TRACE_TCS 0x00000020
+#define SCR_PROTO_TRACE_OBEX 0x00000040
+#define SCR_PROTO_TRACE_OAPP 0x00000080 /* OBEX Application Profile */
+#define SCR_PROTO_TRACE_AMP 0x00000100
+#define SCR_PROTO_TRACE_BNEP 0x00000200
+#define SCR_PROTO_TRACE_AVP 0x00000400
+#define SCR_PROTO_TRACE_MCA 0x00000800
+#define SCR_PROTO_TRACE_ATT 0x00001000
+#define SCR_PROTO_TRACE_SMP 0x00002000
+#define SCR_PROTO_TRACE_NCI 0x00004000
+#define SCR_PROTO_TRACE_LLCP 0x00008000
+#define SCR_PROTO_TRACE_NDEF 0x00010000
+#define SCR_PROTO_TRACE_RW 0x00020000
+#define SCR_PROTO_TRACE_CE 0x00040000
+#define SCR_PROTO_TRACE_SNEP 0x00080000
+#define SCR_PROTO_TRACE_CHO 0x00100000
+#define SCR_PROTO_TRACE_ALL 0x001fffff
+#define SCR_PROTO_TRACE_HCI_LOGGING_VSE 0x0800 /* Brcm vs event for logmsg and protocol traces */
+
+#define MAX_SCRIPT_TYPE 5
+
+#define TCS_PSM_INTERCOM 5
+#define TCS_PSM_CORDLESS 7
+#define BT_PSM_BNEP 0x000F
+/* Define PSMs HID uses */
+#define HID_PSM_CONTROL 0x0011
+#define HID_PSM_INTERRUPT 0x0013
+
+/* Define a function for logging */
+typedef void (BT_LOG_FUNC) (int trace_type, const char *fmt_str, ...);
+
+/* bd addr length and type */
+#ifndef BD_ADDR_LEN
+#define BD_ADDR_LEN 6
+typedef uint8_t BD_ADDR[BD_ADDR_LEN];
+#endif
+
+// From bd.c
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+/* global constant for "any" bd addr */
+static const BD_ADDR bd_addr_any = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+static const BD_ADDR bd_addr_null = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+/*****************************************************************************
+** Functions
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function bdcpy
+**
+** Description Copy bd addr b to a.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static inline void bdcpy(BD_ADDR a, const BD_ADDR b)
+{
+ int i;
+
+ for (i = BD_ADDR_LEN; i != 0; i--) {
+ *a++ = *b++;
+ }
+}
+
+/*******************************************************************************
+**
+** Function bdcmp
+**
+** Description Compare bd addr b to a.
+**
+**
+** Returns Zero if b==a, nonzero otherwise (like memcmp).
+**
+*******************************************************************************/
+static inline int bdcmp(const BD_ADDR a, const BD_ADDR b)
+{
+ int i;
+
+ for (i = BD_ADDR_LEN; i != 0; i--) {
+ if (*a++ != *b++) {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+/*******************************************************************************
+**
+** Function bdcmpany
+**
+** Description Compare bd addr to "any" bd addr.
+**
+**
+** Returns Zero if a equals bd_addr_any.
+**
+*******************************************************************************/
+static inline int bdcmpany(const BD_ADDR a)
+{
+ return bdcmp(a, bd_addr_any);
+}
+
+/*******************************************************************************
+**
+** Function bdsetany
+**
+** Description Set bd addr to "any" bd addr.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static inline void bdsetany(BD_ADDR a)
+{
+ bdcpy(a, bd_addr_any);
+}
+
+/*******************************************************************************
+**
+** Function bt_rcopy
+**
+** Description memory reverse and copy.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+static inline void bt_rcopy(UINT8 *dst, UINT8 const *src, UINT16 len)
+{
+ src += len;
+ while (len --) {
+ *dst++ = *--src;
+ }
+}
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/btm_api.h b/lib/bt/host/bluedroid/stack/include/stack/btm_api.h
new file mode 100644
index 00000000..24024505
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/btm_api.h
@@ -0,0 +1,4363 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the Bluetooth Manager (BTM) API function external
+ * definitions.
+ *
+ ******************************************************************************/
+#ifndef BTM_API_H
+#define BTM_API_H
+
+#include "common/bt_defs.h"
+#include "common/bt_target.h"
+#include "stack/hcidefs.h"
+
+#if SDP_INCLUDED == TRUE
+#include "stack/sdp_api.h"
+#endif
+
+#if SMP_INCLUDED == TRUE
+#include "stack/smp_api.h"
+#endif
+/*****************************************************************************
+** DEVICE CONTROL and COMMON
+*****************************************************************************/
+/*****************************
+** Device Control Constants
+******************************/
+/* Maximum number of bytes allowed for vendor specific command parameters */
+#define BTM_MAX_VENDOR_SPECIFIC_LEN HCI_COMMAND_SIZE
+
+/* BTM application return status codes */
+enum {
+ BTM_SUCCESS = 0, /* 0 Command succeeded */
+ BTM_CMD_STARTED, /* 1 Command started OK. */
+ BTM_BUSY, /* 2 Device busy with another command */
+ BTM_NO_RESOURCES, /* 3 No resources to issue command */
+ BTM_MODE_UNSUPPORTED, /* 4 Request for 1 or more unsupported modes */
+ BTM_ILLEGAL_VALUE, /* 5 Illegal parameter value */
+ BTM_WRONG_MODE, /* 6 Device in wrong mode for request */
+ BTM_UNKNOWN_ADDR, /* 7 Unknown remote BD address */
+ BTM_DEVICE_TIMEOUT, /* 8 Device timeout */
+ BTM_BAD_VALUE_RET, /* 9 A bad value was received from HCI */
+ BTM_ERR_PROCESSING, /* 10 Generic error */
+ BTM_NOT_AUTHORIZED, /* 11 Authorization failed */
+ BTM_DEV_RESET, /* 12 Device has been reset */
+ BTM_CMD_STORED, /* 13 request is stored in control block */
+ BTM_ILLEGAL_ACTION, /* 14 state machine gets illegal command */
+ BTM_DELAY_CHECK, /* 15 delay the check on encryption */
+ BTM_SCO_BAD_LENGTH, /* 16 Bad SCO over HCI data length */
+ BTM_SUCCESS_NO_SECURITY, /* 17 security passed, no security set */
+ BTM_FAILED_ON_SECURITY, /* 18 security failed */
+ BTM_REPEATED_ATTEMPTS, /* 19 repeated attempts for LE security requests */
+ BTM_MODE4_LEVEL4_NOT_SUPPORTED, /* 20 Secure Connections Only Mode can't be supported */
+ BTM_PEER_LE_DATA_LEN_UNSUPPORTED, /* 21 peer setting data length is unsupported*/
+ BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* 22 controller setting data length is unsupported*/
+ BTM_SET_PRIVACY_SUCCESS, /* 23 enable/disable local privacy success */
+ BTM_SET_PRIVACY_FAIL, /* 24 enable/disable local privacy failed*/
+ BTM_SET_STATIC_RAND_ADDR_FAIL, /* 25 Command failed */
+ BTM_INVALID_STATIC_RAND_ADDR, /* 26 invalid static rand addr */
+ BTM_SEC_DEV_REC_REMOVED, /* 27 Device record relate to the bd_addr is removed */
+};
+
+typedef uint8_t tBTM_STATUS;
+
+#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
+typedef enum {
+ BTM_BR_ONE, /*0 First state or BR/EDR scan 1*/
+ BTM_BLE_ONE, /*1BLE scan 1*/
+ BTM_BR_TWO, /*2 BR/EDR scan 2*/
+ BTM_BLE_TWO, /*3 BLE scan 2*/
+ BTM_FINISH, /*4 End of Interleave Scan, or normal scan*/
+ BTM_NO_INTERLEAVING /*5 No Interleaving*/
+} btm_inq_state;
+#endif
+
+
+
+/*************************
+** Device Control Types
+**************************/
+#define BTM_DEVICE_ROLE_BR 0x01
+#define BTM_DEVICE_ROLE_DUAL 0x02
+#define BTM_MAX_DEVICE_ROLE BTM_DEVICE_ROLE_DUAL
+typedef UINT8 tBTM_DEVICE_ROLE;
+
+/* Device name of peer (may be truncated to save space in BTM database) */
+typedef UINT8 tBTM_BD_NAME[BTM_MAX_REM_BD_NAME_LEN + 1];
+
+/* Structure returned with local version information */
+typedef struct {
+ UINT8 hci_version;
+ UINT16 hci_revision;
+ UINT8 lmp_version;
+ UINT16 manufacturer;
+ UINT16 lmp_subversion;
+} tBTM_VERSION_INFO;
+
+/* Structure returned with Vendor Specific Command complete callback */
+typedef struct {
+ UINT16 opcode;
+ UINT16 param_len;
+ UINT8 *p_param_buf;
+} tBTM_VSC_CMPL;
+
+#define BTM_VSC_CMPL_DATA_SIZE (BTM_MAX_VENDOR_SPECIFIC_LEN + sizeof(tBTM_VSC_CMPL))
+/**************************************************
+** Device Control and General Callback Functions
+***************************************************/
+/* Callback function for when device status changes. Appl must poll for
+** what the new state is (BTM_IsDeviceUp). The event occurs whenever the stack
+** has detected that the controller status has changed. This asynchronous event
+** is enabled/disabled by calling BTM_RegisterForDeviceStatusNotif().
+*/
+enum {
+ BTM_DEV_STATUS_UP,
+ BTM_DEV_STATUS_DOWN,
+ BTM_DEV_STATUS_CMD_TOUT
+};
+
+typedef UINT8 tBTM_DEV_STATUS;
+
+typedef struct {
+ UINT16 rx_len;
+ UINT16 tx_len;
+}tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS;
+
+typedef struct {
+ UINT16 min_conn_int;
+ UINT16 max_conn_int;
+ UINT16 conn_int;
+ UINT16 slave_latency;
+ UINT16 supervision_tout;
+}tBTM_LE_UPDATE_CONN_PRAMS;
+
+typedef enum{
+ BTM_WHITELIST_REMOVE = 0X00,
+ BTM_WHITELIST_ADD = 0X01,
+ BTM_WHITELIST_CLEAR = 0x02,
+}tBTM_WL_OPERATION;
+
+
+typedef void (tBTM_DEV_STATUS_CB) (tBTM_DEV_STATUS status);
+
+typedef void (tBTM_GET_DEV_NAME_CBACK) (UINT8 status, char *name);
+
+/* Callback function for when a vendor specific event occurs. The length and
+** array of returned parameter bytes are included. This asynchronous event
+** is enabled/disabled by calling BTM_RegisterForVSEvents().
+*/
+typedef void (tBTM_VS_EVT_CB) (UINT8 len, UINT8 *p);
+
+
+/* General callback function for notifying an application that a synchronous
+** BTM function is complete. The pointer contains the address of any returned data.
+*/
+typedef void (tBTM_CMPL_CB) (void *p1);
+
+typedef void (tBTM_INQ_DIS_CB) (uint32_t num_dis);
+
+/* VSC callback function for notifying an application that a synchronous
+** BTM function is complete. The pointer contains the address of any returned data.
+*/
+typedef void (tBTM_VSC_CMPL_CB) (tBTM_VSC_CMPL *p1);
+
+/* Callback for apps to check connection and inquiry filters.
+** Parameters are the BD Address of remote and the Dev Class of remote.
+** If the app returns none zero, the connection or inquiry result will be dropped.
+*/
+typedef UINT8 (tBTM_FILTER_CB) (BD_ADDR bd_addr, DEV_CLASS dc);
+
+typedef void (tBTM_UPDATE_CONN_PARAM_CBACK) (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params);
+
+typedef void (tBTM_SET_PKT_DATA_LENGTH_CBACK) (UINT8 status, tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS *data_length_params);
+
+typedef void (tBTM_DTM_CMD_CMPL_CBACK) (void *p1);
+
+typedef void (tBTM_SET_RAND_ADDR_CBACK) (UINT8 status);
+
+typedef void (tBTM_UPDATE_WHITELIST_CBACK) (UINT8 status, tBTM_WL_OPERATION wl_opration);
+
+typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status);
+
+/*******************************
+** Device Coexist status
+********************************/
+#if (ESP_COEX_VSC_INCLUDED == TRUE)
+// coexist status for MESH
+#define BTM_COEX_BLE_ST_MESH_CONFIG 0x08
+#define BTM_COEX_BLE_ST_MESH_TRAFFIC 0x10
+#define BTM_COEX_BLE_ST_MESH_STANDBY 0x20
+// coexist status for A2DP
+#define BTM_COEX_BT_ST_A2DP_STREAMING 0x10
+#define BTM_COEX_BT_ST_A2DP_PAUSED 0x20
+
+// coexist operation
+#define BTM_COEX_OP_CLEAR 0x00
+#define BTM_COEX_OP_SET 0x01
+typedef UINT8 tBTM_COEX_OPERATION;
+
+typedef enum {
+ BTM_COEX_TYPE_BLE = 1,
+ BTM_COEX_TYPE_BT,
+} tBTM_COEX_TYPE;
+#endif
+
+/*****************************************************************************
+** DEVICE DISCOVERY - Inquiry, Remote Name, Discovery, Class of Device
+*****************************************************************************/
+/*******************************
+** Device Discovery Constants
+********************************/
+/* Discoverable modes */
+#define BTM_NON_DISCOVERABLE 0
+#define BTM_LIMITED_DISCOVERABLE 1
+#define BTM_GENERAL_DISCOVERABLE 2
+#define BTM_DISCOVERABLE_MASK (BTM_LIMITED_DISCOVERABLE|BTM_GENERAL_DISCOVERABLE)
+#define BTM_MAX_DISCOVERABLE BTM_GENERAL_DISCOVERABLE
+/* high byte for BLE Discoverable modes */
+#define BTM_BLE_NON_DISCOVERABLE 0x0000
+#define BTM_BLE_LIMITED_DISCOVERABLE 0x0100
+#define BTM_BLE_GENERAL_DISCOVERABLE 0x0200
+#define BTM_BLE_MAX_DISCOVERABLE BTM_BLE_GENERAL_DISCOVERABLE
+#define BTM_BLE_DISCOVERABLE_MASK (BTM_BLE_NON_DISCOVERABLE|BTM_BLE_LIMITED_DISCOVERABLE|BTM_BLE_GENERAL_DISCOVERABLE)
+
+/* Connectable modes */
+#define BTM_NON_CONNECTABLE 0
+#define BTM_CONNECTABLE 1
+#define BTM_CONNECTABLE_MASK (BTM_NON_CONNECTABLE | BTM_CONNECTABLE)
+/* high byte for BLE Connectable modes */
+#define BTM_BLE_NON_CONNECTABLE 0x0000
+#define BTM_BLE_CONNECTABLE 0x0100
+#define BTM_BLE_MAX_CONNECTABLE BTM_BLE_CONNECTABLE
+#define BTM_BLE_CONNECTABLE_MASK (BTM_BLE_NON_CONNECTABLE | BTM_BLE_CONNECTABLE)
+
+/* Inquiry modes
+ * Note: These modes are associated with the inquiry active values (BTM_*ACTIVE) */
+#define BTM_INQUIRY_NONE 0
+#define BTM_GENERAL_INQUIRY 0x01
+#define BTM_LIMITED_INQUIRY 0x02
+#define BTM_BR_INQUIRY_MASK (BTM_GENERAL_INQUIRY | BTM_LIMITED_INQUIRY)
+
+/* high byte of inquiry mode for BLE inquiry mode */
+#define BTM_BLE_INQUIRY_NONE 0x00
+#define BTM_BLE_GENERAL_INQUIRY 0x10
+#define BTM_BLE_LIMITED_INQUIRY 0x20
+#define BTM_BLE_INQUIRY_MASK (BTM_BLE_GENERAL_INQUIRY|BTM_BLE_LIMITED_INQUIRY)
+
+/* BTM_IsInquiryActive return values (Bit Mask)
+ * Note: These bit masks are associated with the inquiry modes (BTM_*_INQUIRY) */
+#define BTM_INQUIRY_INACTIVE 0x0 /* no inquiry in progress */
+#define BTM_GENERAL_INQUIRY_ACTIVE BTM_GENERAL_INQUIRY /* a general inquiry is in progress */
+#define BTM_LIMITED_INQUIRY_ACTIVE BTM_LIMITED_INQUIRY /* a limited inquiry is in progress */
+#define BTM_PERIODIC_INQUIRY_ACTIVE 0x8 /* a periodic inquiry is active */
+#define BTM_SSP_INQUIRY_ACTIVE 0x4 /* SSP is active, so inquiry is disallowed (work around for FW bug) */
+#define BTM_LE_GENERAL_INQUIRY_ACTIVE BTM_BLE_GENERAL_INQUIRY /* a general inquiry is in progress */
+#define BTM_LE_LIMITED_INQUIRY_ACTIVE BTM_BLE_LIMITED_INQUIRY /* a limited inquiry is in progress */
+
+/* inquiry activity mask */
+#define BTM_BR_INQ_ACTIVE_MASK (BTM_GENERAL_INQUIRY_ACTIVE|BTM_LIMITED_INQUIRY_ACTIVE|BTM_PERIODIC_INQUIRY_ACTIVE) /* BR/EDR inquiry activity mask */
+#define BTM_BLE_SCAN_ACTIVE_MASK 0x01F0 /* LE scan activity mask */
+#define BTM_BLE_INQ_ACTIVE_MASK (BTM_LE_GENERAL_INQUIRY_ACTIVE|BTM_LE_LIMITED_INQUIRY_ACTIVE) /* LE inquiry activity mask*/
+#define BTM_INQUIRY_ACTIVE_MASK (BTM_BR_INQ_ACTIVE_MASK | BTM_BLE_INQ_ACTIVE_MASK) /* inquiry activity mask */
+
+/* Define scan types */
+#define BTM_SCAN_TYPE_STANDARD 0
+#define BTM_SCAN_TYPE_INTERLACED 1 /* 1.2 devices only */
+
+/* Define inquiry results mode */
+#define BTM_INQ_RESULT_STANDARD 0
+#define BTM_INQ_RESULT_WITH_RSSI 1
+#define BTM_INQ_RESULT_EXTENDED 2
+
+#define BTM_INQ_RES_IGNORE_RSSI 0x7f /* RSSI value not supplied (ignore it) */
+
+/* Inquiry Filter Condition types (see tBTM_INQ_PARMS) */
+#define BTM_CLR_INQUIRY_FILTER 0 /* Inquiry Filtering is turned off */
+#define BTM_FILTER_COND_DEVICE_CLASS HCI_FILTER_COND_DEVICE_CLASS /* Filter on device class */
+#define BTM_FILTER_COND_BD_ADDR HCI_FILTER_COND_BD_ADDR /* Filter on device addr */
+
+/* State of the remote name retrieval during inquiry operations.
+** Used in the tBTM_INQ_INFO structure, and returned in the
+** BTM_InqDbRead, BTM_InqDbFirst, and BTM_InqDbNext functions.
+** The name field is valid when the state returned is
+** BTM_INQ_RMT_NAME_DONE */
+#define BTM_INQ_RMT_NAME_EMPTY 0
+#define BTM_INQ_RMT_NAME_PENDING 1
+#define BTM_INQ_RMT_NAME_DONE 2
+#define BTM_INQ_RMT_NAME_FAILED 3
+
+/*********************************
+ *** Class of Device constants ***
+ *********************************/
+#define BTM_FORMAT_TYPE_1 0x00
+
+/****************************
+** minor device class field
+*****************************/
+
+/* 0x00 is used as unclassified for all minor device classes */
+#define BTM_COD_MINOR_UNCLASSIFIED 0x00
+
+/* minor device class field for Computer Major Class */
+/* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
+#define BTM_COD_MINOR_DESKTOP_WORKSTATION 0x04
+#define BTM_COD_MINOR_SERVER_COMPUTER 0x08
+#define BTM_COD_MINOR_LAPTOP 0x0C
+#define BTM_COD_MINOR_HANDHELD_PC_PDA 0x10 /* clam shell */
+#define BTM_COD_MINOR_PALM_SIZE_PC_PDA 0x14
+#define BTM_COD_MINOR_WEARABLE_COMPUTER 0x18 /* watch sized */
+
+/* minor device class field for Phone Major Class */
+/* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
+#define BTM_COD_MINOR_CELLULAR 0x04
+#define BTM_COD_MINOR_CORDLESS 0x08
+#define BTM_COD_MINOR_SMART_PHONE 0x0C
+#define BTM_COD_MINOR_WIRED_MDM_V_GTWY 0x10 /* wired modem or voice gatway */
+#define BTM_COD_MINOR_ISDN_ACCESS 0x14
+
+/* minor device class field for LAN Access Point Major Class */
+/* Load Factor Field bit 5-7 */
+#define BTM_COD_MINOR_FULLY_AVAILABLE 0x00
+#define BTM_COD_MINOR_1_17_UTILIZED 0x20
+#define BTM_COD_MINOR_17_33_UTILIZED 0x40
+#define BTM_COD_MINOR_33_50_UTILIZED 0x60
+#define BTM_COD_MINOR_50_67_UTILIZED 0x80
+#define BTM_COD_MINOR_67_83_UTILIZED 0xA0
+#define BTM_COD_MINOR_83_99_UTILIZED 0xC0
+#define BTM_COD_MINOR_NO_SERVICE_AVAILABLE 0xE0
+/* sub-Field bit 2-4 */
+/* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
+
+/* minor device class field for Audio/Video Major Class */
+/* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
+#define BTM_COD_MINOR_CONFM_HEADSET 0x04
+#define BTM_COD_MINOR_CONFM_HANDSFREE 0x08
+#define BTM_COD_MINOR_MICROPHONE 0x10
+#define BTM_COD_MINOR_LOUDSPEAKER 0x14
+#define BTM_COD_MINOR_HEADPHONES 0x18
+#define BTM_COD_MINOR_PORTABLE_AUDIO 0x1C
+#define BTM_COD_MINOR_CAR_AUDIO 0x20
+#define BTM_COD_MINOR_SET_TOP_BOX 0x24
+#define BTM_COD_MINOR_HIFI_AUDIO 0x28
+#define BTM_COD_MINOR_VCR 0x2C
+#define BTM_COD_MINOR_VIDEO_CAMERA 0x30
+#define BTM_COD_MINOR_CAMCORDER 0x34
+#define BTM_COD_MINOR_VIDEO_MONITOR 0x38
+#define BTM_COD_MINOR_VIDDISP_LDSPKR 0x3C
+#define BTM_COD_MINOR_VIDEO_CONFERENCING 0x40
+#define BTM_COD_MINOR_GAMING_TOY 0x48
+
+/* minor device class field for Peripheral Major Class */
+/* Bits 6-7 independently specify mouse, keyboard, or combo mouse/keyboard */
+#define BTM_COD_MINOR_KEYBOARD 0x40
+#define BTM_COD_MINOR_POINTING 0x80
+#define BTM_COD_MINOR_COMBO 0xC0
+/* Bits 2-5 OR'd with selection from bits 6-7 */
+/* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
+#define BTM_COD_MINOR_JOYSTICK 0x04
+#define BTM_COD_MINOR_GAMEPAD 0x08
+#define BTM_COD_MINOR_REMOTE_CONTROL 0x0C
+#define BTM_COD_MINOR_SENSING_DEVICE 0x10
+#define BTM_COD_MINOR_DIGITIZING_TABLET 0x14
+#define BTM_COD_MINOR_CARD_READER 0x18 /* e.g. SIM card reader */
+#define BTM_COD_MINOR_DIGITAL_PAN 0x1C
+#define BTM_COD_MINOR_HAND_SCANNER 0x20
+#define BTM_COD_MINOR_HAND_GESTURAL_INPUT 0x24
+
+/* minor device class field for Imaging Major Class */
+/* Bits 5-7 independently specify display, camera, scanner, or printer */
+#define BTM_COD_MINOR_DISPLAY 0x10
+#define BTM_COD_MINOR_CAMERA 0x20
+#define BTM_COD_MINOR_SCANNER 0x40
+#define BTM_COD_MINOR_PRINTER 0x80
+/* Bits 2-3 Reserved */
+/* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
+
+/* minor device class field for Wearable Major Class */
+/* Bits 2-7 meaningful */
+#define BTM_COD_MINOR_WRIST_WATCH 0x04
+#define BTM_COD_MINOR_PAGER 0x08
+#define BTM_COD_MINOR_JACKET 0x0C
+#define BTM_COD_MINOR_HELMET 0x10
+#define BTM_COD_MINOR_GLASSES 0x14
+
+/* minor device class field for Toy Major Class */
+/* Bits 2-7 meaningful */
+#define BTM_COD_MINOR_ROBOT 0x04
+#define BTM_COD_MINOR_VEHICLE 0x08
+#define BTM_COD_MINOR_DOLL_ACTION_FIGURE 0x0C
+#define BTM_COD_MINOR_CONTROLLER 0x10
+#define BTM_COD_MINOR_GAME 0x14
+
+/* minor device class field for Health Major Class */
+/* Bits 2-7 meaningful */
+#define BTM_COD_MINOR_BLOOD_MONITOR 0x04
+#define BTM_COD_MINOR_THERMOMETER 0x08
+#define BTM_COD_MINOR_WEIGHING_SCALE 0x0C
+#define BTM_COD_MINOR_GLUCOSE_METER 0x10
+#define BTM_COD_MINOR_PULSE_OXIMETER 0x14
+#define BTM_COD_MINOR_HEART_PULSE_MONITOR 0x18
+#define BTM_COD_MINOR_HEALTH_DATA_DISPLAY 0x1C
+#define BTM_COD_MINOR_STEP_COUNTER 0x20
+#define BTM_COD_MINOR_BODY_COM_ANALYZER 0x24
+#define BTM_COD_MINOR_PEAK_FLOW_MONITOR 0x28
+#define BTM_COD_MINOR_MEDICATION_MONITOR 0x2C
+#define BTM_COD_MINOR_KNEE_PROSTHESIS 0x30
+#define BTM_COD_MINOR_ANKLE_PROSTHESIS 0x34
+
+
+/***************************
+** major device class field
+****************************/
+#define BTM_COD_MAJOR_MISCELLANEOUS 0x00
+#define BTM_COD_MAJOR_COMPUTER 0x01
+#define BTM_COD_MAJOR_PHONE 0x02
+#define BTM_COD_MAJOR_LAN_ACCESS_PT 0x03
+#define BTM_COD_MAJOR_AUDIO 0x04
+#define BTM_COD_MAJOR_PERIPHERAL 0x05
+#define BTM_COD_MAJOR_IMAGING 0x06
+#define BTM_COD_MAJOR_WEARABLE 0x07
+#define BTM_COD_MAJOR_TOY 0x08
+#define BTM_COD_MAJOR_HEALTH 0x09
+#define BTM_COD_MAJOR_UNCLASSIFIED 0x1F
+
+/***************************
+** service class fields
+****************************/
+#define BTM_COD_SERVICE_LMTD_DISCOVER 0x0020
+#define BTM_COD_SERVICE_POSITIONING 0x0100
+#define BTM_COD_SERVICE_NETWORKING 0x0200
+#define BTM_COD_SERVICE_RENDERING 0x0400
+#define BTM_COD_SERVICE_CAPTURING 0x0800
+#define BTM_COD_SERVICE_OBJ_TRANSFER 0x1000
+#define BTM_COD_SERVICE_AUDIO 0x2000
+#define BTM_COD_SERVICE_TELEPHONY 0x4000
+#define BTM_COD_SERVICE_INFORMATION 0x8000
+
+/* class of device field macros */
+#define BTM_COD_FORMAT_TYPE(u8, pd) {u8 = pd[2]&0x03;}
+#define BTM_COD_MINOR_CLASS(u8, pd) {u8 = pd[2]&0xFC;}
+#define BTM_COD_MAJOR_CLASS(u8, pd) {u8 = pd[1]&0x1F;}
+#define BTM_COD_SERVICE_CLASS(u16, pd) {u16 = pd[0]; u16<<=8; u16 += pd[1]&0xE0;}
+
+/* to set the fields (assumes that format type is always 0) */
+#define FIELDS_TO_COD(pd, mn, mj, sv) {pd[2] = mn; pd[1] = \
+ mj+ ((sv)&BTM_COD_SERVICE_CLASS_LO_B); \
+ pd[0] = (sv) >> 8;}
+
+/* the COD masks */
+#define BTM_COD_FORMAT_TYPE_MASK 0x03
+#define BTM_COD_MINOR_CLASS_MASK 0xFC
+#define BTM_COD_MAJOR_CLASS_MASK 0x1F
+#define BTM_COD_SERVICE_CLASS_LO_B 0x00E0
+#define BTM_COD_SERVICE_CLASS_MASK 0xFFE0
+
+
+/* BTM service definitions
+** Used for storing EIR data to bit mask
+*/
+enum {
+ BTM_EIR_UUID_SERVCLASS_SERVICE_DISCOVERY_SERVER,
+ /* BTM_EIR_UUID_SERVCLASS_BROWSE_GROUP_DESCRIPTOR, */
+ /* BTM_EIR_UUID_SERVCLASS_PUBLIC_BROWSE_GROUP, */
+ BTM_EIR_UUID_SERVCLASS_SERIAL_PORT,
+ BTM_EIR_UUID_SERVCLASS_LAN_ACCESS_USING_PPP,
+ BTM_EIR_UUID_SERVCLASS_DIALUP_NETWORKING,
+ BTM_EIR_UUID_SERVCLASS_IRMC_SYNC,
+ BTM_EIR_UUID_SERVCLASS_OBEX_OBJECT_PUSH,
+ BTM_EIR_UUID_SERVCLASS_OBEX_FILE_TRANSFER,
+ BTM_EIR_UUID_SERVCLASS_IRMC_SYNC_COMMAND,
+ BTM_EIR_UUID_SERVCLASS_HEADSET,
+ BTM_EIR_UUID_SERVCLASS_CORDLESS_TELEPHONY,
+ BTM_EIR_UUID_SERVCLASS_AUDIO_SOURCE,
+ BTM_EIR_UUID_SERVCLASS_AUDIO_SINK,
+ BTM_EIR_UUID_SERVCLASS_AV_REM_CTRL_TARGET,
+ /* BTM_EIR_UUID_SERVCLASS_ADV_AUDIO_DISTRIBUTION, */
+ BTM_EIR_UUID_SERVCLASS_AV_REMOTE_CONTROL,
+ /* BTM_EIR_UUID_SERVCLASS_VIDEO_CONFERENCING, */
+ BTM_EIR_UUID_SERVCLASS_INTERCOM,
+ BTM_EIR_UUID_SERVCLASS_FAX,
+ BTM_EIR_UUID_SERVCLASS_HEADSET_AUDIO_GATEWAY,
+ /* BTM_EIR_UUID_SERVCLASS_WAP, */
+ /* BTM_EIR_UUID_SERVCLASS_WAP_CLIENT, */
+ BTM_EIR_UUID_SERVCLASS_PANU,
+ BTM_EIR_UUID_SERVCLASS_NAP,
+ BTM_EIR_UUID_SERVCLASS_GN,
+ BTM_EIR_UUID_SERVCLASS_DIRECT_PRINTING,
+ /* BTM_EIR_UUID_SERVCLASS_REFERENCE_PRINTING, */
+ BTM_EIR_UUID_SERVCLASS_IMAGING,
+ BTM_EIR_UUID_SERVCLASS_IMAGING_RESPONDER,
+ BTM_EIR_UUID_SERVCLASS_IMAGING_AUTO_ARCHIVE,
+ BTM_EIR_UUID_SERVCLASS_IMAGING_REF_OBJECTS,
+ BTM_EIR_UUID_SERVCLASS_HF_HANDSFREE,
+ BTM_EIR_UUID_SERVCLASS_AG_HANDSFREE,
+ BTM_EIR_UUID_SERVCLASS_DIR_PRT_REF_OBJ_SERVICE,
+ /* BTM_EIR_UUID_SERVCLASS_REFLECTED_UI, */
+ BTM_EIR_UUID_SERVCLASS_BASIC_PRINTING,
+ BTM_EIR_UUID_SERVCLASS_PRINTING_STATUS,
+ BTM_EIR_UUID_SERVCLASS_HUMAN_INTERFACE,
+ BTM_EIR_UUID_SERVCLASS_CABLE_REPLACEMENT,
+ BTM_EIR_UUID_SERVCLASS_HCRP_PRINT,
+ BTM_EIR_UUID_SERVCLASS_HCRP_SCAN,
+ /* BTM_EIR_UUID_SERVCLASS_COMMON_ISDN_ACCESS, */
+ /* BTM_EIR_UUID_SERVCLASS_VIDEO_CONFERENCING_GW, */
+ /* BTM_EIR_UUID_SERVCLASS_UDI_MT, */
+ /* BTM_EIR_UUID_SERVCLASS_UDI_TA, */
+ /* BTM_EIR_UUID_SERVCLASS_VCP, */
+ BTM_EIR_UUID_SERVCLASS_SAP,
+ BTM_EIR_UUID_SERVCLASS_PBAP_PCE,
+ BTM_EIR_UUID_SERVCLASS_PBAP_PSE,
+ /* BTM_EIR_UUID_SERVCLASS_TE_PHONE_ACCESS, */
+ /* BTM_EIR_UUID_SERVCLASS_ME_PHONE_ACCESS, */
+ BTM_EIR_UUID_SERVCLASS_PHONE_ACCESS,
+ BTM_EIR_UUID_SERVCLASS_HEADSET_HS,
+ BTM_EIR_UUID_SERVCLASS_PNP_INFORMATION,
+ /* BTM_EIR_UUID_SERVCLASS_GENERIC_NETWORKING, */
+ /* BTM_EIR_UUID_SERVCLASS_GENERIC_FILETRANSFER, */
+ /* BTM_EIR_UUID_SERVCLASS_GENERIC_AUDIO, */
+ /* BTM_EIR_UUID_SERVCLASS_GENERIC_TELEPHONY, */
+ /* BTM_EIR_UUID_SERVCLASS_UPNP_SERVICE, */
+ /* BTM_EIR_UUID_SERVCLASS_UPNP_IP_SERVICE, */
+ /* BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_PAN, */
+ /* BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_LAP, */
+ /* BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_L2CAP, */
+ BTM_EIR_UUID_SERVCLASS_VIDEO_SOURCE,
+ BTM_EIR_UUID_SERVCLASS_VIDEO_SINK,
+ /* BTM_EIR_UUID_SERVCLASS_VIDEO_DISTRIBUTION */
+ /* BTM_EIR_UUID_SERVCLASS_HDP_PROFILE */
+ BTM_EIR_UUID_SERVCLASS_MESSAGE_ACCESS,
+ BTM_EIR_UUID_SERVCLASS_MESSAGE_NOTIFICATION,
+ BTM_EIR_UUID_SERVCLASS_HDP_SOURCE,
+ BTM_EIR_UUID_SERVCLASS_HDP_SINK,
+ BTM_EIR_MAX_SERVICES
+};
+
+/* search result in EIR of inquiry database */
+#define BTM_EIR_FOUND 0
+#define BTM_EIR_NOT_FOUND 1
+#define BTM_EIR_UNKNOWN 2
+
+typedef UINT8 tBTM_EIR_SEARCH_RESULT;
+
+#define BTM_EIR_FLAGS_TYPE HCI_EIR_FLAGS_TYPE /* 0x01 */
+#define BTM_EIR_MORE_16BITS_UUID_TYPE HCI_EIR_MORE_16BITS_UUID_TYPE /* 0x02 */
+#define BTM_EIR_COMPLETE_16BITS_UUID_TYPE HCI_EIR_COMPLETE_16BITS_UUID_TYPE /* 0x03 */
+#define BTM_EIR_MORE_32BITS_UUID_TYPE HCI_EIR_MORE_32BITS_UUID_TYPE /* 0x04 */
+#define BTM_EIR_COMPLETE_32BITS_UUID_TYPE HCI_EIR_COMPLETE_32BITS_UUID_TYPE /* 0x05 */
+#define BTM_EIR_MORE_128BITS_UUID_TYPE HCI_EIR_MORE_128BITS_UUID_TYPE /* 0x06 */
+#define BTM_EIR_COMPLETE_128BITS_UUID_TYPE HCI_EIR_COMPLETE_128BITS_UUID_TYPE /* 0x07 */
+#define BTM_EIR_SHORTENED_LOCAL_NAME_TYPE HCI_EIR_SHORTENED_LOCAL_NAME_TYPE /* 0x08 */
+#define BTM_EIR_COMPLETE_LOCAL_NAME_TYPE HCI_EIR_COMPLETE_LOCAL_NAME_TYPE /* 0x09 */
+#define BTM_EIR_TX_POWER_LEVEL_TYPE HCI_EIR_TX_POWER_LEVEL_TYPE /* 0x0A */
+#define BTM_EIR_URL_TYPE HCI_EIR_URL_TYPE /* 0x24 */
+#define BTM_EIR_MANUFACTURER_SPECIFIC_TYPE HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xFF */
+
+#define BTM_EIR_TYPE_MAX_NUM 12 /* Max EIR types */
+
+/* the following EIR tags are defined to OOB, not regular EIR data */
+#define BTM_EIR_OOB_BD_ADDR_TYPE HCI_EIR_OOB_BD_ADDR_TYPE /* 6 bytes */
+#define BTM_EIR_OOB_COD_TYPE HCI_EIR_OOB_COD_TYPE /* 3 bytes */
+#define BTM_EIR_OOB_SSP_HASH_C_TYPE HCI_EIR_OOB_SSP_HASH_C_TYPE /* 16 bytes */
+#define BTM_EIR_OOB_SSP_RAND_R_TYPE HCI_EIR_OOB_SSP_RAND_R_TYPE /* 16 bytes */
+
+#define BTM_OOB_MANDATORY_SIZE 8 /* include 2 bytes length & 6 bytes bd_addr */
+#define BTM_OOB_DATA_LEN_SIZE 2
+#define BTM_OOB_BD_ADDR_SIZE 6
+#define BTM_OOB_COD_SIZE BT_OOB_COD_SIZE
+#define BTM_OOB_HASH_C_SIZE BT_OOB_HASH_C_SIZE
+#define BTM_OOB_RAND_R_SIZE BT_OOB_RAND_R_SIZE
+
+
+#if BLE_INCLUDED == TRUE
+#define BTM_BLE_SEC_NONE 0
+#define BTM_BLE_SEC_ENCRYPT 1 /* encrypt the link using current key */
+#define BTM_BLE_SEC_ENCRYPT_NO_MITM 2
+#define BTM_BLE_SEC_ENCRYPT_MITM 3
+typedef UINT8 tBTM_BLE_SEC_ACT;
+#endif
+/************************************************************************************************
+** BTM Services MACROS handle array of UINT32 bits for more than 32 services
+*************************************************************************************************/
+/* Determine the number of UINT32's necessary for services */
+#define BTM_EIR_ARRAY_BITS 32 /* Number of bits in each array element */
+#define BTM_EIR_SERVICE_ARRAY_SIZE (((UINT32)BTM_EIR_MAX_SERVICES / BTM_EIR_ARRAY_BITS) + \
+ (((UINT32)BTM_EIR_MAX_SERVICES % BTM_EIR_ARRAY_BITS) ? 1 : 0))
+
+/* MACRO to set the service bit mask in a bit stream */
+#define BTM_EIR_SET_SERVICE(p, service) (((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] |= \
+ ((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS)))
+
+
+/* MACRO to clear the service bit mask in a bit stream */
+#define BTM_EIR_CLR_SERVICE(p, service) (((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] &= \
+ ~((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS)))
+
+/* MACRO to check the service bit mask in a bit stream */
+#define BTM_EIR_HAS_SERVICE(p, service) ((((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] & \
+ ((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS))) >> (((UINT32)(service)) % BTM_EIR_ARRAY_BITS))
+
+/* start of EIR in HCI buffer, 4 bytes = HCI Command(2) + Length(1) + FEC_Req(1) */
+#define BTM_HCI_EIR_OFFSET (BT_HDR_SIZE + 4)
+
+/***************************
+** Device Discovery Types
+****************************/
+/* Definitions of the parameters passed to BTM_StartInquiry and
+** BTM_SetPeriodicInquiryMode.
+*/
+typedef struct { /* contains the two device class condition fields */
+ DEV_CLASS dev_class;
+ DEV_CLASS dev_class_mask;
+} tBTM_COD_COND;
+
+
+typedef union { /* contains the inquiry filter condition */
+ BD_ADDR bdaddr_cond;
+ tBTM_COD_COND cod_cond;
+} tBTM_INQ_FILT_COND;
+
+
+typedef struct { /* contains the parameters passed to the inquiry functions */
+ UINT8 mode; /* general or limited */
+ UINT8 duration; /* duration of the inquiry (1.28 sec increments) */
+ UINT8 max_resps; /* maximum number of responses to return */
+ BOOLEAN report_dup; /* report duplicated inquiry response with higher RSSI value */
+ UINT8 filter_cond_type; /* new devices, BD ADDR, COD, or No filtering */
+ tBTM_INQ_FILT_COND filter_cond; /* filter value based on filter cond type */
+#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
+ UINT8 intl_duration[4]; /*duration array storing the interleave scan's time portions*/
+#endif
+} tBTM_INQ_PARMS;
+
+#define BTM_INQ_RESULT_BR 0x01
+#define BTM_INQ_RESULT_BLE 0x02
+
+#if (BLE_INCLUDED == TRUE)
+#define BTM_BLE_EVT_CONN_ADV 0x00
+#define BTM_BLE_EVT_CONN_DIR_ADV 0x01
+#define BTM_BLE_EVT_DISC_ADV 0x02
+#define BTM_BLE_EVT_NON_CONN_ADV 0x03
+#define BTM_BLE_EVT_SCAN_RSP 0x04
+typedef UINT8 tBTM_BLE_EVT_TYPE;
+#endif
+
+/* These are the fields returned in each device's response to the inquiry. It
+** is returned in the results callback if registered.
+*/
+typedef struct {
+ UINT16 clock_offset;
+ BD_ADDR remote_bd_addr;
+ DEV_CLASS dev_class;
+ UINT8 page_scan_rep_mode;
+ UINT8 page_scan_per_mode;
+ UINT8 page_scan_mode;
+ INT8 rssi; /* Set to BTM_INQ_RES_IGNORE_RSSI if not valid */
+ UINT32 eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE];
+ BOOLEAN eir_complete_list;
+ tBT_DEVICE_TYPE device_type;
+#if (BLE_INCLUDED == TRUE)
+ UINT8 inq_result_type;
+ UINT8 ble_addr_type;
+ tBTM_BLE_EVT_TYPE ble_evt_type;
+ UINT8 flag;
+ UINT8 adv_data_len;
+ UINT8 scan_rsp_len;
+#endif
+} tBTM_INQ_RESULTS;
+
+
+/* This is the inquiry response information held in its database by BTM, and available
+** to applications via BTM_InqDbRead, BTM_InqDbFirst, and BTM_InqDbNext.
+*/
+typedef struct {
+ tBTM_INQ_RESULTS results;
+
+ BOOLEAN appl_knows_rem_name; /* set by application if it knows the remote name of the peer device.
+ This is later used by application to determine if remote name request is
+ required to be done. Having the flag here avoid duplicate store of inquiry results */
+#if ( BLE_INCLUDED == TRUE)
+ UINT16 remote_name_len;
+ tBTM_BD_NAME remote_name;
+ UINT8 remote_name_state;
+ UINT8 remote_name_type;
+#endif
+
+} tBTM_INQ_INFO;
+
+
+/* Structure returned with inquiry complete callback */
+typedef struct {
+ tBTM_STATUS status;
+ UINT8 num_resp; /* Number of results from the current inquiry */
+} tBTM_INQUIRY_CMPL;
+
+/* Structure returned with remote name request */
+typedef struct {
+ UINT16 status;
+ BD_ADDR bd_addr;
+ UINT16 length;
+ BD_NAME remote_bd_name;
+} tBTM_REMOTE_DEV_NAME;
+
+typedef struct {
+ UINT8 pcm_intf_rate; /* PCM interface rate: 0: 128kbps, 1: 256 kbps;
+ 2:512 bps; 3: 1024kbps; 4: 2048kbps */
+ UINT8 frame_type; /* frame type: 0: short; 1: long */
+ UINT8 sync_mode; /* sync mode: 0: slave; 1: master */
+ UINT8 clock_mode; /* clock mode: 0: slave; 1: master */
+
+} tBTM_SCO_PCM_PARAM;
+
+/****************************************
+** Device Discovery Callback Functions
+*****************************************/
+/* Callback function for asynchronous notifications when the BTM inquiry DB
+** changes. First param is inquiry database, second is if added to or removed
+** from the inquiry database.
+*/
+typedef void (tBTM_INQ_DB_CHANGE_CB) (void *p1, BOOLEAN is_new);
+
+/* Callback function for notifications when the BTM gets inquiry response.
+** First param is inquiry results database, second is pointer of EIR.
+*/
+typedef void (tBTM_INQ_RESULTS_CB) (tBTM_INQ_RESULTS *p_inq_results, UINT8 *p_eir);
+
+/*****************************************************************************
+** ACL CHANNEL MANAGEMENT
+*****************************************************************************/
+/******************
+** ACL Constants
+*******************/
+
+/* ACL modes */
+#define BTM_ACL_MODE_NORMAL HCI_MODE_ACTIVE
+#define BTM_ACL_MODE_HOLD HCI_MODE_HOLD
+#define BTM_ACL_MODE_SNIFF HCI_MODE_SNIFF
+#define BTM_ACL_MODE_PARK HCI_MODE_PARK
+
+/* Returned with structure in role switch callback (tBTM_ROLE_SWITCH_CMPL) */
+#define BTM_ROLE_MASTER HCI_ROLE_MASTER
+#define BTM_ROLE_SLAVE HCI_ROLE_SLAVE
+#define BTM_ROLE_UNDEFINED 0xff /* undefined value (error status) */
+
+/* ACL Packet Types */
+#define BTM_ACL_PKT_TYPES_MASK_DM1 HCI_PKT_TYPES_MASK_DM1
+#define BTM_ACL_PKT_TYPES_MASK_DH1 HCI_PKT_TYPES_MASK_DH1
+#define BTM_ACL_PKT_TYPES_MASK_DM3 HCI_PKT_TYPES_MASK_DM3
+#define BTM_ACL_PKT_TYPES_MASK_DH3 HCI_PKT_TYPES_MASK_DH3
+#define BTM_ACL_PKT_TYPES_MASK_DM5 HCI_PKT_TYPES_MASK_DM5
+#define BTM_ACL_PKT_TYPES_MASK_DH5 HCI_PKT_TYPES_MASK_DH5
+#define BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 HCI_PKT_TYPES_MASK_NO_2_DH1
+#define BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 HCI_PKT_TYPES_MASK_NO_3_DH1
+#define BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 HCI_PKT_TYPES_MASK_NO_2_DH3
+#define BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 HCI_PKT_TYPES_MASK_NO_3_DH3
+#define BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 HCI_PKT_TYPES_MASK_NO_2_DH5
+#define BTM_ACL_PKT_TYPES_MASK_NO_3_DH5 HCI_PKT_TYPES_MASK_NO_3_DH5
+
+/***************
+** ACL Types
+****************/
+
+/* Structure returned with Role Switch information (in tBTM_CMPL_CB callback function)
+** in response to BTM_SwitchRole call.
+*/
+typedef struct {
+ UINT8 hci_status; /* HCI status returned with the event */
+ UINT8 role; /* BTM_ROLE_MASTER or BTM_ROLE_SLAVE */
+ BD_ADDR remote_bd_addr; /* Remote BD addr involved with the switch */
+} tBTM_ROLE_SWITCH_CMPL;
+
+/* Structure returned with QoS information (in tBTM_CMPL_CB callback function)
+** in response to BTM_SetQoS call.
+*/
+typedef struct {
+ FLOW_SPEC flow;
+ UINT16 handle;
+ UINT8 status;
+ BD_ADDR rem_bda;
+} tBTM_QOS_SETUP_CMPL;
+
+
+/* Structure returned with read RSSI event (in tBTM_CMPL_CB callback function)
+** in response to BTM_ReadRSSI call.
+*/
+typedef struct {
+ tBTM_STATUS status;
+ UINT8 hci_status;
+ INT8 rssi;
+ BD_ADDR rem_bda;
+} tBTM_RSSI_RESULTS;
+
+/* Structure returned with read current TX power event (in tBTM_CMPL_CB callback function)
+** in response to BTM_ReadTxPower call.
+*/
+typedef struct {
+ tBTM_STATUS status;
+ UINT8 hci_status;
+ INT8 tx_power;
+ BD_ADDR rem_bda;
+} tBTM_TX_POWER_RESULTS;
+
+/* Structure returned with read link quality event (in tBTM_CMPL_CB callback function)
+** in response to BTM_ReadLinkQuality call.
+*/
+typedef struct {
+ tBTM_STATUS status;
+ UINT8 hci_status;
+ UINT8 link_quality;
+ BD_ADDR rem_bda;
+} tBTM_LINK_QUALITY_RESULTS;
+
+/* Structure returned with set AFH channels event (in tBTM_CMPL_CB callback function)
+** in response to BTM_SetAfhChannels call.
+*/
+typedef struct {
+ tBTM_STATUS status;
+ UINT8 hci_status;
+} tBTM_SET_AFH_CHANNELS_RESULTS;
+
+/* Structure returned with set page timeout event (in tBTM_CMPL_CB callback function)
+** in response to BTM_WritePageTimeout call.
+*/
+typedef struct {
+ tBTM_STATUS status;
+ UINT8 hci_status;
+} tBTM_SET_PAGE_TIMEOUT_RESULTS;
+
+/* Structure returned with get page timeout event (in tBTM_CMPL_CB callback function)
+** in response to BTM_ReadPageTimeout call.
+*/
+typedef struct {
+ tBTM_STATUS status;
+ UINT8 hci_status;
+ UINT16 page_to;
+} tBTM_GET_PAGE_TIMEOUT_RESULTS;
+
+/* Structure returned with set ACL packet types event (in tBTM_CMPL_CB callback function)
+** in response to BTM_SetAclPktTypes call.
+*/
+typedef struct {
+ tBTM_STATUS status;
+ BD_ADDR rem_bda;
+ UINT16 pkt_types;
+} tBTM_SET_ACL_PKT_TYPES_RESULTS;
+
+/* Structure returned with set BLE channels event (in tBTM_CMPL_CB callback function)
+** in response to BTM_BleSetChannels call.
+*/
+typedef struct {
+ tBTM_STATUS status;
+ UINT8 hci_status;
+} tBTM_BLE_SET_CHANNELS_RESULTS;
+
+/* Structure returned with read inq tx power quality event (in tBTM_CMPL_CB callback function)
+** in response to BTM_ReadInquiryRspTxPower call.
+*/
+typedef struct {
+ tBTM_STATUS status;
+ UINT8 hci_status;
+ INT8 tx_power;
+} tBTM_INQ_TXPWR_RESULTS;
+
+
+enum {
+ BTM_ACL_CONN_CMPL_EVT,
+ BTM_ACL_DISCONN_CMPL_EVT
+};
+typedef UINT8 tBTM_ACL_LINK_STAT_EVENT;
+
+typedef struct {
+ UINT8 status; /* The status of ACL connection complete */
+ UINT16 handle; /* The ACL connection handle */
+ BD_ADDR bd_addr; /* Peer Bluetooth device address */
+} tBTM_ACL_CONN_CMPL_DATA;
+
+typedef struct {
+ UINT8 reason; /* The reason for ACL disconnection complete */
+ UINT16 handle; /* The ACL connection handle */
+ BD_ADDR bd_addr; /* Peer Bluetooth device address */
+} tBTM_ACL_DISCONN_CMPL_DATA;
+
+typedef struct {
+ tBTM_ACL_LINK_STAT_EVENT event; /* The event reported */
+ union {
+ tBTM_ACL_CONN_CMPL_DATA conn_cmpl; /* The data associated with BTM_ACL_CONN_CMPL_EVT */
+ tBTM_ACL_DISCONN_CMPL_DATA disconn_cmpl; /* The data associated with BTM_ACL_DISCONN_CMPL_EVT */
+ } link_act;
+} tBTM_ACL_LINK_STAT_EVENT_DATA;
+
+/* Callback function for reporting ACL link related events to upper
+*/
+typedef void (tBTM_ACL_LINK_STAT_CB) (tBTM_ACL_LINK_STAT_EVENT_DATA *p_data);
+
+enum {
+ BTM_BL_CONN_EVT,
+ BTM_BL_DISCN_EVT,
+ BTM_BL_UPDATE_EVT,
+ BTM_BL_ROLE_CHG_EVT,
+ BTM_BL_COLLISION_EVT
+};
+typedef UINT8 tBTM_BL_EVENT;
+typedef UINT16 tBTM_BL_EVENT_MASK;
+
+#define BTM_BL_CONN_MASK 0x0001
+#define BTM_BL_DISCN_MASK 0x0002
+#define BTM_BL_UPDATE_MASK 0x0004
+#define BTM_BL_ROLE_CHG_MASK 0x0008
+
+/* Device features mask definitions */
+#define BTM_FEATURE_BYTES_PER_PAGE HCI_FEATURE_BYTES_PER_PAGE
+#define BTM_EXT_FEATURES_PAGE_MAX HCI_EXT_FEATURES_PAGE_MAX
+
+/* the data type associated with BTM_BL_CONN_EVT */
+typedef struct {
+ tBTM_BL_EVENT event; /* The event reported. */
+ BD_ADDR_PTR p_bda; /* The address of the newly connected device */
+ DEV_CLASS_PTR p_dc; /* The device class */
+ BD_NAME_PTR p_bdn; /* The device name */
+ UINT8 *p_features; /* pointer to the remote device's features page[0] (supported features page) */
+ BOOLEAN sc_downgrade; /* Secure connection downgrade state. */
+#if BLE_INCLUDED == TRUE
+ UINT16 handle; /* connection handle */
+ tBT_TRANSPORT transport; /* link is LE or not */
+#endif
+} tBTM_BL_CONN_DATA;
+
+/* the data type associated with BTM_BL_DISCN_EVT */
+typedef struct {
+ tBTM_BL_EVENT event; /* The event reported. */
+ BD_ADDR_PTR p_bda; /* The address of the disconnected device */
+#if BLE_INCLUDED == TRUE
+ UINT16 handle; /* disconnected connection handle */
+ tBT_TRANSPORT transport; /* link is LE link or not */
+#endif
+} tBTM_BL_DISCN_DATA;
+
+/* Busy-Level shall have the inquiry_paging mask set when
+ * inquiry/paging is in progress, Else the number of ACL links */
+#define BTM_BL_INQUIRY_PAGING_MASK 0x10
+#define BTM_BL_INQUIRY_STARTED (BTM_BL_INQUIRY_PAGING_MASK | 0x1)
+#define BTM_BL_INQUIRY_CANCELLED (BTM_BL_INQUIRY_PAGING_MASK | 0x2)
+#define BTM_BL_INQUIRY_COMPLETE (BTM_BL_INQUIRY_PAGING_MASK | 0x3)
+#define BTM_BL_PAGING_STARTED (BTM_BL_INQUIRY_PAGING_MASK | 0x4)
+#define BTM_BL_PAGING_COMPLETE (BTM_BL_INQUIRY_PAGING_MASK | 0x5)
+/* the data type associated with BTM_BL_UPDATE_EVT */
+typedef struct {
+ tBTM_BL_EVENT event; /* The event reported. */
+ UINT8 busy_level;/* when paging or inquiring, level is 10.
+ * Otherwise, the number of ACL links. */
+ UINT8 busy_level_flags; /* Notifies actual inquiry/page activities */
+} tBTM_BL_UPDATE_DATA;
+
+/* the data type associated with BTM_BL_ROLE_CHG_EVT */
+typedef struct {
+ tBTM_BL_EVENT event; /* The event reported. */
+ BD_ADDR_PTR p_bda; /* The address of the peer connected device */
+ UINT8 new_role;
+ UINT8 hci_status; /* HCI status returned with the event */
+} tBTM_BL_ROLE_CHG_DATA;
+
+typedef union {
+ tBTM_BL_EVENT event; /* The event reported. */
+ tBTM_BL_CONN_DATA conn; /* The data associated with BTM_BL_CONN_EVT */
+ tBTM_BL_DISCN_DATA discn; /* The data associated with BTM_BL_DISCN_EVT */
+ tBTM_BL_UPDATE_DATA update; /* The data associated with BTM_BL_UPDATE_EVT */
+ tBTM_BL_ROLE_CHG_DATA role_chg;/*The data associated with BTM_BL_ROLE_CHG_EVT */
+} tBTM_BL_EVENT_DATA;
+
+/* Callback function for notifications when the BTM busy level
+** changes.
+*/
+typedef void (tBTM_BL_CHANGE_CB) (tBTM_BL_EVENT_DATA *p_data);
+
+/***************************
+** ACL Callback Functions
+****************************/
+/* Callback function for notifications when the BTM ACL connection DB
+** changes. First param is BD address, second is if added or removed.
+** Registered through BTM_AclRegisterForChanges call.
+*/
+#if BLE_INCLUDED == TRUE
+typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
+ BD_NAME p_bdn, UINT8 *features,
+ BOOLEAN is_new, UINT16 handle,
+ tBT_TRANSPORT transport);
+#else
+typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
+ BD_NAME p_bdn, UINT8 *features,
+ BOOLEAN is_new);
+#endif
+/*****************************************************************************
+** SCO CHANNEL MANAGEMENT
+*****************************************************************************/
+/******************
+** SCO Constants
+*******************/
+
+/* Define an invalid SCO index and an invalid HCI handle */
+#define BTM_INVALID_SCO_INDEX 0xFFFF
+#define BTM_INVALID_HCI_HANDLE 0xFFFF
+
+/* Define an invalid SCO disconnect reason */
+#define BTM_INVALID_SCO_DISC_REASON 0xFFFF
+
+/* Define first active SCO index */
+#define BTM_FIRST_ACTIVE_SCO_INDEX BTM_MAX_SCO_LINKS
+
+/* Define SCO packet types used in APIs */
+#define BTM_SCO_PKT_TYPES_MASK_HV1 HCI_ESCO_PKT_TYPES_MASK_HV1
+#define BTM_SCO_PKT_TYPES_MASK_HV2 HCI_ESCO_PKT_TYPES_MASK_HV2
+#define BTM_SCO_PKT_TYPES_MASK_HV3 HCI_ESCO_PKT_TYPES_MASK_HV3
+#define BTM_SCO_PKT_TYPES_MASK_EV3 HCI_ESCO_PKT_TYPES_MASK_EV3
+#define BTM_SCO_PKT_TYPES_MASK_EV4 HCI_ESCO_PKT_TYPES_MASK_EV4
+#define BTM_SCO_PKT_TYPES_MASK_EV5 HCI_ESCO_PKT_TYPES_MASK_EV5
+#define BTM_SCO_PKT_TYPES_MASK_NO_2_EV3 HCI_ESCO_PKT_TYPES_MASK_NO_2_EV3
+#define BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 HCI_ESCO_PKT_TYPES_MASK_NO_3_EV3
+#define BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 HCI_ESCO_PKT_TYPES_MASK_NO_2_EV5
+#define BTM_SCO_PKT_TYPES_MASK_NO_3_EV5 HCI_ESCO_PKT_TYPES_MASK_NO_3_EV5
+
+#define BTM_SCO_LINK_ONLY_MASK (BTM_SCO_PKT_TYPES_MASK_HV1 | \
+ BTM_SCO_PKT_TYPES_MASK_HV2 | \
+ BTM_SCO_PKT_TYPES_MASK_HV3)
+
+#define BTM_ESCO_LINK_ONLY_MASK (BTM_SCO_PKT_TYPES_MASK_EV3 | \
+ BTM_SCO_PKT_TYPES_MASK_EV4 | \
+ BTM_SCO_PKT_TYPES_MASK_EV5)
+
+#define BTM_SCO_LINK_ALL_PKT_MASK (BTM_SCO_LINK_ONLY_MASK | \
+ BTM_ESCO_LINK_ONLY_MASK)
+
+#define BTM_VALID_SCO_ALL_PKT_TYPE HCI_VALID_SCO_ALL_PKT_TYPE
+
+/* Passed in BTM_CreateSco if the packet type parameter should be ignored */
+#define BTM_IGNORE_SCO_PKT_TYPE 0
+
+/***************
+** SCO Types
+****************/
+#define BTM_LINK_TYPE_SCO HCI_LINK_TYPE_SCO
+#define BTM_LINK_TYPE_ESCO HCI_LINK_TYPE_ESCO
+typedef UINT8 tBTM_SCO_TYPE;
+
+
+/*******************
+** SCO Routing Path
+********************/
+#define BTM_SCO_ROUTE_PCM (0) // HCI_BRCM_SCO_ROUTE_PCM
+#define BTM_SCO_ROUTE_HCI (1) // HCI_BRCM_SCO_ROUTE_HCI
+typedef UINT8 tBTM_SCO_ROUTE_TYPE;
+
+
+/*******************
+** SCO Codec Types
+********************/
+// TODO(google) This should use common definitions
+// in hci/include/hci_audio.h
+#define BTM_SCO_CODEC_NONE 0x0000
+#define BTM_SCO_CODEC_CVSD 0x0001
+#define BTM_SCO_CODEC_MSBC 0x0002
+typedef UINT16 tBTM_SCO_CODEC_TYPE;
+
+
+
+/*******************
+** SCO Air Mode Types
+********************/
+#define BTM_SCO_AIR_MODE_U_LAW 0
+#define BTM_SCO_AIR_MODE_A_LAW 1
+#define BTM_SCO_AIR_MODE_CVSD 2
+#define BTM_SCO_AIR_MODE_TRANSPNT 3
+#define BTM_SCO_AIR_MODE_UNKNOWN 0xFF
+typedef UINT8 tBTM_SCO_AIR_MODE_TYPE;
+
+/*******************
+** SCO Voice Settings
+********************/
+#define BTM_VOICE_SETTING_CVSD ((UINT16) (HCI_INP_CODING_LINEAR | \
+ HCI_INP_DATA_FMT_2S_COMPLEMENT | \
+ HCI_INP_SAMPLE_SIZE_16BIT | \
+ HCI_AIR_CODING_FORMAT_CVSD))
+
+#define BTM_VOICE_SETTING_TRANS ((UINT16) (HCI_INP_CODING_LINEAR | \
+ HCI_INP_DATA_FMT_2S_COMPLEMENT | \
+ HCI_INP_SAMPLE_SIZE_8BIT | \
+ HCI_AIR_CODING_FORMAT_TRANSPNT))
+
+/*******************
+** SCO Data Status
+********************/
+enum {
+ BTM_SCO_DATA_CORRECT,
+ BTM_SCO_DATA_PAR_ERR,
+ BTM_SCO_DATA_NONE,
+ BTM_SCO_DATA_PAR_LOST
+};
+typedef UINT8 tBTM_SCO_DATA_FLAG;
+
+/* Count the number of SCO Data Packet Status */
+typedef struct {
+ UINT32 rx_total;
+ UINT32 rx_correct;
+ UINT32 rx_err;
+ UINT32 rx_none;
+ UINT32 rx_lost;
+ UINT32 tx_total;
+ UINT32 tx_discarded;
+} tBTM_SCO_PKT_STAT_NUMS;
+
+/***************************
+** SCO Callback Functions
+****************************/
+typedef void (tBTM_SCO_CB) (UINT16 sco_inx);
+typedef void (tBTM_SCO_DATA_CB) (UINT16 sco_inx, BT_HDR *p_data, tBTM_SCO_DATA_FLAG status);
+
+/******************
+** eSCO Constants
+*******************/
+#define BTM_64KBITS_RATE 0x00001f40 /* 64 kbits/sec data rate */
+
+/* Retransmission effort */
+#define BTM_ESCO_RETRANS_OFF 0
+#define BTM_ESCO_RETRANS_POWER 1
+#define BTM_ESCO_RETRANS_QUALITY 2
+#define BTM_ESCO_RETRANS_DONTCARE 0xff
+
+/* Max Latency Don't Care */
+#define BTM_ESCO_MAX_LAT_DONTCARE 0xffff
+
+/***************
+** eSCO Types
+****************/
+/* tBTM_ESCO_CBACK event types */
+#define BTM_ESCO_CHG_EVT 1
+#define BTM_ESCO_CONN_REQ_EVT 2
+typedef UINT8 tBTM_ESCO_EVT;
+
+/* Passed into BTM_SetEScoMode() */
+typedef struct {
+ UINT32 tx_bw;
+ UINT32 rx_bw;
+ UINT16 max_latency;
+ UINT16 voice_contfmt; /* Voice Settings or Content Format */
+ UINT16 packet_types;
+ UINT8 retrans_effort;
+} tBTM_ESCO_PARAMS;
+
+typedef struct {
+ UINT16 max_latency;
+ UINT16 packet_types;
+ UINT8 retrans_effort;
+} tBTM_CHG_ESCO_PARAMS;
+
+/* Returned by BTM_ReadEScoLinkParms() */
+typedef struct {
+ UINT16 rx_pkt_len;
+ UINT16 tx_pkt_len;
+ BD_ADDR bd_addr;
+ UINT8 link_type; /* BTM_LINK_TYPE_SCO or BTM_LINK_TYPE_ESCO */
+ UINT8 tx_interval;
+ UINT8 retrans_window;
+ UINT8 air_mode;
+} tBTM_ESCO_DATA;
+
+typedef struct {
+ UINT16 sco_inx;
+ UINT16 rx_pkt_len;
+ UINT16 tx_pkt_len;
+ BD_ADDR bd_addr;
+ UINT8 hci_status;
+ UINT8 tx_interval;
+ UINT8 retrans_window;
+} tBTM_CHG_ESCO_EVT_DATA;
+
+typedef struct {
+ UINT16 sco_inx;
+ BD_ADDR bd_addr;
+ DEV_CLASS dev_class;
+ tBTM_SCO_TYPE link_type;
+} tBTM_ESCO_CONN_REQ_EVT_DATA;
+
+typedef union {
+ tBTM_CHG_ESCO_EVT_DATA chg_evt;
+ tBTM_ESCO_CONN_REQ_EVT_DATA conn_evt;
+} tBTM_ESCO_EVT_DATA;
+
+/***************************
+** eSCO Callback Functions
+****************************/
+typedef void (tBTM_ESCO_CBACK) (tBTM_ESCO_EVT event, tBTM_ESCO_EVT_DATA *p_data);
+
+
+/*****************************************************************************
+** SECURITY MANAGEMENT
+*****************************************************************************/
+/*******************************
+** Security Manager Constants
+********************************/
+
+/* Security Mode (BTM_SetSecurityMode) */
+#define BTM_SEC_MODE_UNDEFINED 0
+#define BTM_SEC_MODE_NONE 1
+#define BTM_SEC_MODE_SERVICE 2
+#define BTM_SEC_MODE_LINK 3
+#define BTM_SEC_MODE_SP 4
+#define BTM_SEC_MODE_SP_DEBUG 5
+#define BTM_SEC_MODE_SC 6
+
+/* Maximum Number of BTM Security Modes */
+#define BTM_SEC_MODES_MAX 7
+
+/* Security Service Levels [bit mask] (BTM_SetSecurityLevel)
+** Encryption should not be used without authentication
+*/
+#define BTM_SEC_NONE 0x0000 /* Nothing required */
+#define BTM_SEC_IN_AUTHORIZE 0x0001 /* Inbound call requires authorization */
+#define BTM_SEC_IN_AUTHENTICATE 0x0002 /* Inbound call requires authentication */
+#define BTM_SEC_IN_ENCRYPT 0x0004 /* Inbound call requires encryption */
+#define BTM_SEC_OUT_AUTHORIZE 0x0008 /* Outbound call requires authorization */
+#define BTM_SEC_OUT_AUTHENTICATE 0x0010 /* Outbound call requires authentication */
+#define BTM_SEC_OUT_ENCRYPT 0x0020 /* Outbound call requires encryption */
+#define BTM_SEC_MODE4_LEVEL4 0x0040 /* Secure Connections Only Mode */
+#define BTM_SEC_FORCE_MASTER 0x0100 /* Need to switch connection to be master */
+#define BTM_SEC_ATTEMPT_MASTER 0x0200 /* Try to switch connection to be master */
+#define BTM_SEC_FORCE_SLAVE 0x0400 /* Need to switch connection to be master */
+#define BTM_SEC_ATTEMPT_SLAVE 0x0800 /* Try to switch connection to be slave */
+#define BTM_SEC_IN_MITM 0x1000 /* inbound Do man in the middle protection */
+#define BTM_SEC_OUT_MITM 0x2000 /* outbound Do man in the middle protection */
+#define BTM_SEC_IN_MIN_16_DIGIT_PIN 0x4000 /* enforce a minimum of 16 digit for sec mode 2 */
+
+/* Security Flags [bit mask] (BTM_GetSecurityFlags)
+*/
+#define BTM_SEC_FLAG_AUTHORIZED 0x01
+#define BTM_SEC_FLAG_AUTHENTICATED 0x02
+#define BTM_SEC_FLAG_ENCRYPTED 0x04
+#define BTM_SEC_FLAG_LKEY_KNOWN 0x10
+#define BTM_SEC_FLAG_LKEY_AUTHED 0x20
+
+/* PIN types */
+#define BTM_PIN_TYPE_VARIABLE HCI_PIN_TYPE_VARIABLE
+#define BTM_PIN_TYPE_FIXED HCI_PIN_TYPE_FIXED
+
+/* Link Key types used to generate the new link key.
+** returned in link key notification callback function
+*/
+#define BTM_LKEY_TYPE_COMBINATION HCI_LKEY_TYPE_COMBINATION
+#define BTM_LKEY_TYPE_LOCAL_UNIT HCI_LKEY_TYPE_LOCAL_UNIT
+#define BTM_LKEY_TYPE_REMOTE_UNIT HCI_LKEY_TYPE_REMOTE_UNIT
+#define BTM_LKEY_TYPE_DEBUG_COMB HCI_LKEY_TYPE_DEBUG_COMB
+#define BTM_LKEY_TYPE_UNAUTH_COMB HCI_LKEY_TYPE_UNAUTH_COMB
+#define BTM_LKEY_TYPE_AUTH_COMB HCI_LKEY_TYPE_AUTH_COMB
+#define BTM_LKEY_TYPE_CHANGED_COMB HCI_LKEY_TYPE_CHANGED_COMB
+
+#define BTM_LKEY_TYPE_UNAUTH_COMB_P_256 HCI_LKEY_TYPE_UNAUTH_COMB_P_256
+#define BTM_LKEY_TYPE_AUTH_COMB_P_256 HCI_LKEY_TYPE_AUTH_COMB_P_256
+
+#define BTM_LTK_DERIVED_LKEY_OFFSET 0x20 /* "easy" requirements for Link Key (LK) derived from Long Term Key */
+#define BTM_LKEY_TYPE_IGNORE 0xff /* used when event is response from
+ hci return link keys request */
+
+typedef UINT8 tBTM_LINK_KEY_TYPE;
+
+/* Protocol level security (BTM_SetSecurityLevel) */
+#define BTM_SEC_PROTO_L2CAP 0
+#define BTM_SEC_PROTO_SDP 1
+#define BTM_SEC_PROTO_TCS 2
+#define BTM_SEC_PROTO_RFCOMM 3
+#define BTM_SEC_PROTO_OBEX 4
+#define BTM_SEC_PROTO_BNEP 5
+#define BTM_SEC_PROTO_HID 6 /* HID */
+#define BTM_SEC_PROTO_AVDT 7
+#define BTM_SEC_PROTO_MCA 8
+
+/* Determine the number of UINT32's necessary for security services */
+#define BTM_SEC_ARRAY_BITS 32 /* Number of bits in each array element */
+#define BTM_SEC_SERVICE_ARRAY_SIZE (((UINT32)BTM_SEC_MAX_SERVICES / BTM_SEC_ARRAY_BITS) + \
+ (((UINT32)BTM_SEC_MAX_SERVICES % BTM_SEC_ARRAY_BITS) ? 1 : 0))
+
+/* Security service definitions (BTM_SetSecurityLevel)
+** Used for Authorization APIs
+*/
+#define BTM_SEC_SERVICE_SDP_SERVER 0
+#define BTM_SEC_SERVICE_SERIAL_PORT 1
+#define BTM_SEC_SERVICE_LAN_ACCESS 2
+#define BTM_SEC_SERVICE_DUN 3
+#define BTM_SEC_SERVICE_IRMC_SYNC 4
+#define BTM_SEC_SERVICE_IRMC_SYNC_CMD 5
+#define BTM_SEC_SERVICE_OBEX 6
+#define BTM_SEC_SERVICE_OBEX_FTP 7
+#define BTM_SEC_SERVICE_HEADSET 8
+#define BTM_SEC_SERVICE_CORDLESS 9
+#define BTM_SEC_SERVICE_INTERCOM 10
+#define BTM_SEC_SERVICE_FAX 11
+#define BTM_SEC_SERVICE_HEADSET_AG 12
+#define BTM_SEC_SERVICE_PNP_INFO 13
+#define BTM_SEC_SERVICE_GEN_NET 14
+#define BTM_SEC_SERVICE_GEN_FILE 15
+#define BTM_SEC_SERVICE_GEN_AUDIO 16
+#define BTM_SEC_SERVICE_GEN_TEL 17
+#define BTM_SEC_SERVICE_CTP_DATA 18
+#define BTM_SEC_SERVICE_HCRP_CTRL 19
+#define BTM_SEC_SERVICE_HCRP_DATA 20
+#define BTM_SEC_SERVICE_HCRP_NOTIF 21
+#define BTM_SEC_SERVICE_BPP_JOB 22
+#define BTM_SEC_SERVICE_BPP_STATUS 23
+#define BTM_SEC_SERVICE_BPP_REF 24
+#define BTM_SEC_SERVICE_BNEP_PANU 25
+#define BTM_SEC_SERVICE_BNEP_GN 26
+#define BTM_SEC_SERVICE_BNEP_NAP 27
+#define BTM_SEC_SERVICE_HF_HANDSFREE 28
+#define BTM_SEC_SERVICE_AG_HANDSFREE 29
+#define BTM_SEC_SERVICE_TE_PHONE_ACCESS 30
+#define BTM_SEC_SERVICE_ME_PHONE_ACCESS 31
+
+#define BTM_SEC_SERVICE_HIDH_SEC_CTRL 32
+#define BTM_SEC_SERVICE_HIDH_NOSEC_CTRL 33
+#define BTM_SEC_SERVICE_HIDH_INTR 34
+#define BTM_SEC_SERVICE_BIP 35
+#define BTM_SEC_SERVICE_BIP_REF 36
+#define BTM_SEC_SERVICE_AVDTP 37
+#define BTM_SEC_SERVICE_AVDTP_NOSEC 38
+#define BTM_SEC_SERVICE_AVCTP 39
+#define BTM_SEC_SERVICE_SAP 40
+#define BTM_SEC_SERVICE_PBAP 41
+#define BTM_SEC_SERVICE_RFC_MUX 42
+#define BTM_SEC_SERVICE_AVCTP_BROWSE 43
+#define BTM_SEC_SERVICE_MAP 44
+#define BTM_SEC_SERVICE_MAP_NOTIF 45
+#define BTM_SEC_SERVICE_MCAP_CTRL 46
+#define BTM_SEC_SERVICE_MCAP_DATA 47
+#define BTM_SEC_SERVICE_HDP_SNK 48
+#define BTM_SEC_SERVICE_HDP_SRC 49
+#define BTM_SEC_SERVICE_ATT 50
+#define BTM_SEC_SERVICE_HIDD_SEC_CTRL 51
+#define BTM_SEC_SERVICE_HIDD_NOSEC_CTRL 52
+#define BTM_SEC_SERVICE_HIDD_INTR 53
+
+/* Update these as services are added */
+#define BTM_SEC_SERVICE_FIRST_EMPTY 54
+
+#ifndef BTM_SEC_MAX_SERVICES
+#define BTM_SEC_MAX_SERVICES 65
+#endif
+
+/************************************************************************************************
+** Security Services MACROS handle array of UINT32 bits for more than 32 trusted services
+*************************************************************************************************/
+/* MACRO to set the security service bit mask in a bit stream */
+#define BTM_SEC_SET_SERVICE(p, service) (((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)] |= \
+ ((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))
+
+
+/* MACRO to clear the security service bit mask in a bit stream */
+#define BTM_SEC_CLR_SERVICE(p, service) (((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)] &= \
+ ~((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))
+
+/* MACRO to check the security service bit mask in a bit stream (Returns TRUE or FALSE) */
+#define BTM_SEC_IS_SERVICE_TRUSTED(p, service) (((((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)]) & \
+ (UINT32)(((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))) ? TRUE : FALSE)
+
+/* MACRO to copy two trusted device bitmask */
+#define BTM_SEC_COPY_TRUSTED_DEVICE(p_src, p_dst) {UINT32 trst; for (trst = 0; trst < BTM_SEC_SERVICE_ARRAY_SIZE; trst++) \
+ ((UINT32 *)(p_dst))[trst] = ((UINT32 *)(p_src))[trst];}
+
+/* MACRO to clear two trusted device bitmask */
+#define BTM_SEC_CLR_TRUSTED_DEVICE(p_dst) {UINT32 trst; for (trst = 0; trst < BTM_SEC_SERVICE_ARRAY_SIZE; trst++) \
+ ((UINT32 *)(p_dst))[trst] = 0;}
+
+/* Following bits can be provided by host in the trusted_mask array */
+/* 0..31 bits of mask[0] (Least Significant Word) */
+#define BTM_SEC_TRUST_SDP_SERVER (1 << BTM_SEC_SERVICE_SDP_SERVER)
+#define BTM_SEC_TRUST_SERIAL_PORT (1 << BTM_SEC_SERVICE_SERIAL_PORT)
+#define BTM_SEC_TRUST_LAN_ACCESS (1 << BTM_SEC_SERVICE_LAN_ACCESS)
+#define BTM_SEC_TRUST_DUN (1 << BTM_SEC_SERVICE_DUN)
+#define BTM_SEC_TRUST_IRMC_SYNC (1 << BTM_SEC_SERVICE_IRMC_SYNC)
+#define BTM_SEC_TRUST_IRMC_SYNC_CMD (1 << BTM_SEC_SERVICE_IRMC_SYNC_CMD)
+#define BTM_SEC_TRUST_OBEX (1 << BTM_SEC_SERVICE_OBEX)
+#define BTM_SEC_TRUST_OBEX_FTP (1 << BTM_SEC_SERVICE_OBEX_FTP)
+#define BTM_SEC_TRUST_HEADSET (1 << BTM_SEC_SERVICE_HEADSET)
+#define BTM_SEC_TRUST_CORDLESS (1 << BTM_SEC_SERVICE_CORDLESS)
+#define BTM_SEC_TRUST_INTERCOM (1 << BTM_SEC_SERVICE_INTERCOM)
+#define BTM_SEC_TRUST_FAX (1 << BTM_SEC_SERVICE_FAX)
+#define BTM_SEC_TRUST_HEADSET_AG (1 << BTM_SEC_SERVICE_HEADSET_AG)
+#define BTM_SEC_TRUST_PNP_INFO (1 << BTM_SEC_SERVICE_PNP_INFO)
+#define BTM_SEC_TRUST_GEN_NET (1 << BTM_SEC_SERVICE_GEN_NET)
+#define BTM_SEC_TRUST_GEN_FILE (1 << BTM_SEC_SERVICE_GEN_FILE)
+#define BTM_SEC_TRUST_GEN_AUDIO (1 << BTM_SEC_SERVICE_GEN_AUDIO)
+#define BTM_SEC_TRUST_GEN_TEL (1 << BTM_SEC_SERVICE_GEN_TEL)
+#define BTM_SEC_TRUST_CTP_DATA (1 << BTM_SEC_SERVICE_CTP_DATA)
+#define BTM_SEC_TRUST_HCRP_CTRL (1 << BTM_SEC_SERVICE_HCRP_CTRL)
+#define BTM_SEC_TRUST_HCRP_DATA (1 << BTM_SEC_SERVICE_HCRP_DATA)
+#define BTM_SEC_TRUST_HCRP_NOTIF (1 << BTM_SEC_SERVICE_HCRP_NOTIF)
+#define BTM_SEC_TRUST_BPP_JOB (1 << BTM_SEC_SERVICE_JOB)
+#define BTM_SEC_TRUST_BPP_STATUS (1 << BTM_SEC_SERVICE_STATUS)
+#define BTM_SEC_TRUST_BPP_REF (1 << BTM_SEC_SERVICE_REF)
+#define BTM_SEC_TRUST_BNEP_PANU (1 << BTM_SEC_SERVICE_BNEP_PANU)
+#define BTM_SEC_TRUST_BNEP_GN (1 << BTM_SEC_SERVICE_BNEP_GN)
+#define BTM_SEC_TRUST_BNEP_NAP (1 << BTM_SEC_SERVICE_BNEP_NAP)
+#define BTM_SEC_TRUST_HFP_HF (1 << BTM_SEC_SERVICE_HF_HANDSFREE)
+#define BTM_SEC_TRUST_HFP_AG (1 << BTM_SEC_SERVICE_AG_HANDSFREE)
+#define BTM_SEC_TRUST_TE_PHONE_ACCESS (1 << BTM_SEC_SERVICE_TE_PHONE_ACCESS)
+#define BTM_SEC_TRUST_ME_PHONE_ACCESS (1 << BTM_SEC_SERVICE_ME_PHONE_ACCESS)
+
+/* 0..31 bits of mask[1] (Most Significant Word) */
+#define BTM_SEC_TRUST_HIDH_CTRL (1 << (BTM_SEC_SERVICE_HIDH_SEC_CTRL - 32))
+#define BTM_SEC_TRUST_HIDH_NOSEC_CTRL (1 << (BTM_SEC_SERVICE_HIDH_NOSEC_CTRL - 32))
+#define BTM_SEC_TRUST_HIDH_INTR (1 << (BTM_SEC_SERVICE_HIDH_INTR - 32))
+#define BTM_SEC_TRUST_BIP (1 << (BTM_SEC_SERVICE_BIP - 32))
+#define BTM_SEC_TRUST_BIP_REF (1 << (BTM_SEC_SERVICE_BIP_REF - 32))
+#define BTM_SEC_TRUST_AVDTP (1 << (BTM_SEC_SERVICE_AVDTP - 32))
+#define BTM_SEC_TRUST_AVDTP_NOSEC (1 << (BTM_SEC_SERVICE_AVDTP_NOSEC - 32))
+#define BTM_SEC_TRUST_AVCTP (1 << (BTM_SEC_SERVICE_AVCTP - 32))
+#define BTM_SEC_TRUST_SAP (1 << (BTM_SEC_SERVICE_SAP - 32))
+#define BTM_SEC_TRUST_PBAP (1 << (BTM_SEC_SERVICE_PBAP - 32))
+#define BTM_SEC_TRUST_RFC_MUX (1 << (BTM_SEC_SERVICE_RFC_MUX - 32))
+#define BTM_SEC_TRUST_AVCTP_BROWSE (1 << (BTM_SEC_SERVICE_AVCTP_BROWSE - 32))
+#define BTM_SEC_TRUST_MAP (1 << (BTM_SEC_SERVICE_MAP - 32))
+#define BTM_SEC_TRUST_MAP_NOTIF (1 << (BTM_SEC_SERVICE_MAP_NOTIF - 32))
+#define BTM_SEC_TRUST_MCAP_CTRL (1 << (BTM_SEC_SERVICE_MCAP_CTRL - 32))
+#define BTM_SEC_TRUST_MCAP_DATA (1 << (BTM_SEC_SERVICE_MCAP_DATA - 32))
+#define BTM_SEC_TRUST_HDP_SNK (1 << (BTM_SEC_SERVICE_HDP_SNK - 32))
+#define BTM_SEC_TRUST_HDP_SRC (1 << (BTM_SEC_SERVICE_HDP_SRC - 32))
+
+#define BTM_SEC_TRUST_ALL 0xFFFFFFFF /* for each array element */
+
+/****************************************
+** Security Manager Callback Functions
+*****************************************/
+/* Authorize device for service. Parameters are
+** BD Address of remote
+** Device Class of remote
+** BD Name of remote
+** Service name
+** Service Id (NULL - unknown service or unused
+** [BTM_SEC_SERVICE_NAME_LEN set to 0])
+** Is originator of the connection
+** Result of the operation
+*/
+typedef UINT8 (tBTM_AUTHORIZE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
+ tBTM_BD_NAME bd_name, UINT8 *service_name,
+ UINT8 service_id, BOOLEAN is_originator);
+
+/* Get PIN for the connection. Parameters are
+** BD Address of remote
+** Device Class of remote
+** BD Name of remote
+** Flag indicating the minimum pin code length to be 16 digits
+*/
+typedef UINT8 (tBTM_PIN_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
+ tBTM_BD_NAME bd_name, BOOLEAN min_16_digit);
+
+/* New Link Key for the connection. Parameters are
+** BD Address of remote
+** Link Key
+** Key Type: Combination, Local Unit, or Remote Unit
+*/
+typedef UINT8 (tBTM_LINK_KEY_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
+ tBTM_BD_NAME bd_name, UINT8 *key,
+ UINT8 key_type, BOOLEAN sc_support);
+
+
+/* Remote Name Resolved. Parameters are
+** BD Address of remote
+** BD Name of remote
+*/
+typedef void (tBTM_RMT_NAME_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dc,
+ tBTM_BD_NAME bd_name);
+
+
+/* Authentication complete for the connection. Parameters are
+** BD Address of remote
+** Device Class of remote
+** BD Name of remote
+**
+*/
+typedef UINT8 (tBTM_AUTH_COMPLETE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
+ tBTM_BD_NAME bd_name, int result);
+
+/* Encryption changed for the connection. Parameters are
+** BD Address of remote
+** Encryption mode
+*/
+typedef void (tBTM_ENC_CHANGE_CALLBACK) (BD_ADDR bd_addr, UINT8 enc_mode);
+
+enum {
+ BTM_SP_IO_REQ_EVT, /* received IO_CAPABILITY_REQUEST event */
+ BTM_SP_IO_RSP_EVT, /* received IO_CAPABILITY_RESPONSE event */
+ BTM_SP_CFM_REQ_EVT, /* received USER_CONFIRMATION_REQUEST event */
+ BTM_SP_KEY_NOTIF_EVT, /* received USER_PASSKEY_NOTIFY event */
+ BTM_SP_KEY_REQ_EVT, /* received USER_PASSKEY_REQUEST event */
+ BTM_SP_KEYPRESS_EVT, /* received KEYPRESS_NOTIFY event */
+ BTM_SP_LOC_OOB_EVT, /* received result for READ_LOCAL_OOB_DATA command */
+ BTM_SP_RMT_OOB_EVT, /* received REMOTE_OOB_DATA_REQUEST event */
+ BTM_SP_COMPLT_EVT, /* received SIMPLE_PAIRING_COMPLETE event */
+ BTM_SP_UPGRADE_EVT /* check if the application wants to upgrade the link key */
+};
+typedef UINT8 tBTM_SP_EVT;
+
+/* relate to ESP_IO_CAP_xxx in esp_gap_ble_api.h */
+#define BTM_IO_CAP_OUT 0 /* DisplayOnly */
+#define BTM_IO_CAP_IO 1 /* DisplayYesNo */
+#define BTM_IO_CAP_IN 2 /* KeyboardOnly */
+#define BTM_IO_CAP_NONE 3 /* NoInputNoOutput */
+// #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
+#define BTM_IO_CAP_KBDISP 4 /* Keyboard display */
+#define BTM_IO_CAP_MAX 5
+// #else
+// #define BTM_IO_CAP_MAX 4
+// #endif
+
+typedef UINT8 tBTM_IO_CAP;
+
+#define BTM_MAX_PASSKEY_VAL (999999)
+#define BTM_MIN_PASSKEY_VAL (0)
+
+#define BTM_AUTH_SP_NO 0 /* MITM Protection Not Required - Single Profile/non-bonding
+ Numeric comparison with automatic accept allowed */
+#define BTM_AUTH_SP_YES 1 /* MITM Protection Required - Single Profile/non-bonding
+ Use IO Capabilities to determine authentication procedure */
+#define BTM_AUTH_AP_NO 2 /* MITM Protection Not Required - All Profiles/dedicated bonding
+ Numeric comparison with automatic accept allowed */
+#define BTM_AUTH_AP_YES 3 /* MITM Protection Required - All Profiles/dedicated bonding
+ Use IO Capabilities to determine authentication procedure */
+#define BTM_AUTH_SPGB_NO 4 /* MITM Protection Not Required - Single Profiles/general bonding
+ Numeric comparison with automatic accept allowed */
+#define BTM_AUTH_SPGB_YES 5 /* MITM Protection Required - Single Profiles/general bonding
+ Use IO Capabilities to determine authentication procedure */
+#define BTM_AUTH_DD_BOND 2 /* this bit is ORed to the BTM_AUTH_SP_* when IO exchange for dedicated bonding */
+#define BTM_AUTH_GB_BIT 4 /* the genernal bonding bit */
+#define BTM_AUTH_BONDS 6 /* the general/dedicated bonding bits */
+#define BTM_AUTH_YN_BIT 1 /* this is the Yes or No bit */
+
+#define BTM_BLE_ENC_KEY_MASK (1 << 0)
+#define BTM_BLE_ID_KEY_MASK (1 << 1)
+#define BTM_BLE_CSR_KEY_MASK (1 << 2)
+#define BTM_BLE_LINK_KEY_MASK (1 << 3)
+
+#define BTM_BLE_INITIATOR_KEY_SIZE 15
+#define BTM_BLE_RESPONDER_KEY_SIZE 15
+#define BTM_BLE_MAX_KEY_SIZE 16
+#define BTM_BLE_MIN_KEY_SIZE 7
+
+typedef UINT8 tBTM_AUTH_REQ;
+
+enum {
+ BTM_OOB_NONE,
+ BTM_OOB_PRESENT
+#if BTM_OOB_INCLUDED == TRUE
+ , BTM_OOB_UNKNOWN
+#endif
+};
+typedef UINT8 tBTM_OOB_DATA;
+
+/* data type for BTM_SP_IO_REQ_EVT */
+typedef struct {
+ BD_ADDR bd_addr; /* peer address */
+ tBTM_IO_CAP io_cap; /* local IO capabilities */
+ tBTM_OOB_DATA oob_data; /* OOB data present (locally) for the peer device */
+ tBTM_AUTH_REQ auth_req; /* Authentication required (for local device) */
+ BOOLEAN is_orig; /* TRUE, if local device initiated the SP process */
+} tBTM_SP_IO_REQ;
+
+/* data type for BTM_SP_IO_RSP_EVT */
+typedef struct {
+ BD_ADDR bd_addr; /* peer address */
+ tBTM_IO_CAP io_cap; /* peer IO capabilities */
+ tBTM_OOB_DATA oob_data; /* OOB data present at peer device for the local device */
+ tBTM_AUTH_REQ auth_req; /* Authentication required for peer device */
+} tBTM_SP_IO_RSP;
+
+/* data type for BTM_SP_CFM_REQ_EVT */
+typedef struct {
+ BD_ADDR bd_addr; /* peer address */
+ DEV_CLASS dev_class; /* peer CoD */
+ tBTM_BD_NAME bd_name; /* peer device name */
+ UINT32 num_val; /* the numeric value for comparison. If just_works, do not show this number to UI */
+ BOOLEAN just_works; /* TRUE, if "Just Works" association model */
+ tBTM_AUTH_REQ loc_auth_req; /* Authentication required for local device */
+ tBTM_AUTH_REQ rmt_auth_req; /* Authentication required for peer device */
+ tBTM_IO_CAP loc_io_caps; /* IO Capabilities of the local device */
+ tBTM_IO_CAP rmt_io_caps; /* IO Capabilities of the remot device */
+} tBTM_SP_CFM_REQ;
+
+/* data type for BTM_SP_KEY_REQ_EVT */
+typedef struct {
+ BD_ADDR bd_addr; /* peer address */
+ DEV_CLASS dev_class; /* peer CoD */
+ tBTM_BD_NAME bd_name; /* peer device name */
+} tBTM_SP_KEY_REQ;
+
+/* data type for BTM_SP_KEY_NOTIF_EVT */
+typedef struct {
+ BD_ADDR bd_addr; /* peer address */
+ DEV_CLASS dev_class; /* peer CoD */
+ tBTM_BD_NAME bd_name; /* peer device name */
+ UINT32 passkey; /* passkey */
+} tBTM_SP_KEY_NOTIF;
+
+enum {
+ BTM_SP_KEY_STARTED, /* 0 - passkey entry started */
+ BTM_SP_KEY_ENTERED, /* 1 - passkey digit entered */
+ BTM_SP_KEY_ERASED, /* 2 - passkey digit erased */
+ BTM_SP_KEY_CLEARED, /* 3 - passkey cleared */
+ BTM_SP_KEY_COMPLT, /* 4 - passkey entry completed */
+ BTM_SP_KEY_OUT_OF_RANGE /* 5 - out of range */
+};
+typedef UINT8 tBTM_SP_KEY_TYPE;
+
+/* data type for BTM_SP_KEYPRESS_EVT */
+typedef struct {
+ BD_ADDR bd_addr; /* peer address */
+ tBTM_SP_KEY_TYPE notif_type;
+} tBTM_SP_KEYPRESS;
+
+/* data type for BTM_SP_LOC_OOB_EVT */
+typedef struct {
+ tBTM_STATUS status; /* */
+ BT_OCTET16 c; /* Simple Pairing Hash C */
+ BT_OCTET16 r; /* Simple Pairing Randomnizer R */
+} tBTM_SP_LOC_OOB;
+
+/* data type for BTM_SP_RMT_OOB_EVT */
+typedef struct {
+ BD_ADDR bd_addr; /* peer address */
+ DEV_CLASS dev_class; /* peer CoD */
+ tBTM_BD_NAME bd_name; /* peer device name */
+} tBTM_SP_RMT_OOB;
+
+
+/* data type for BTM_SP_COMPLT_EVT */
+typedef struct {
+ BD_ADDR bd_addr; /* peer address */
+ DEV_CLASS dev_class; /* peer CoD */
+ tBTM_BD_NAME bd_name; /* peer device name */
+ tBTM_STATUS status; /* status of the simple pairing process */
+} tBTM_SP_COMPLT;
+
+/* data type for BTM_SP_UPGRADE_EVT */
+typedef struct {
+ BD_ADDR bd_addr; /* peer address */
+ BOOLEAN upgrade; /* TRUE, to upgrade the link key */
+} tBTM_SP_UPGRADE;
+
+typedef union {
+ tBTM_SP_IO_REQ io_req; /* BTM_SP_IO_REQ_EVT */
+ tBTM_SP_IO_RSP io_rsp; /* BTM_SP_IO_RSP_EVT */
+ tBTM_SP_CFM_REQ cfm_req; /* BTM_SP_CFM_REQ_EVT */
+ tBTM_SP_KEY_NOTIF key_notif; /* BTM_SP_KEY_NOTIF_EVT */
+ tBTM_SP_KEY_REQ key_req; /* BTM_SP_KEY_REQ_EVT */
+ tBTM_SP_KEYPRESS key_press; /* BTM_SP_KEYPRESS_EVT */
+ tBTM_SP_LOC_OOB loc_oob; /* BTM_SP_LOC_OOB_EVT */
+ tBTM_SP_RMT_OOB rmt_oob; /* BTM_SP_RMT_OOB_EVT */
+ tBTM_SP_COMPLT complt; /* BTM_SP_COMPLT_EVT */
+ tBTM_SP_UPGRADE upgrade; /* BTM_SP_UPGRADE_EVT */
+} tBTM_SP_EVT_DATA;
+
+/* Simple Pairing Events. Called by the stack when Simple Pairing related
+** events occur.
+*/
+typedef UINT8 (tBTM_SP_CALLBACK) (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
+
+
+typedef void (tBTM_MKEY_CALLBACK) (BD_ADDR bd_addr, UINT8 status, UINT8 key_flag) ;
+
+/* Encryption enabled/disabled complete: Optionally passed with BTM_SetEncryption.
+** Parameters are
+** BD Address of remote
+** optional data passed in by BTM_SetEncryption
+** tBTM_STATUS - result of the operation
+*/
+typedef void (tBTM_SEC_CBACK) (BD_ADDR bd_addr, tBT_TRANSPORT transport,
+ void *p_ref_data, tBTM_STATUS result);
+
+/* Bond Cancel complete. Parameters are
+** Result of the cancel operation
+**
+*/
+typedef void (tBTM_BOND_CANCEL_CMPL_CALLBACK) (tBTM_STATUS result);
+
+/* LE related event and data structure
+*/
+/* relate to ESP_LE_KEY_xxx in esp_gap_ble_api.h */
+#if (SMP_INCLUDED == TRUE)
+#define BTM_LE_IO_REQ_EVT SMP_IO_CAP_REQ_EVT /* received IO_CAPABILITY_REQUEST event */
+#define BTM_LE_SEC_REQUEST_EVT SMP_SEC_REQUEST_EVT /* security request event */
+#define BTM_LE_KEY_NOTIF_EVT SMP_PASSKEY_NOTIF_EVT /* received USER_PASSKEY_NOTIFY event */
+#define BTM_LE_KEY_REQ_EVT SMP_PASSKEY_REQ_EVT /* received USER_PASSKEY_REQUEST event */
+#define BTM_LE_OOB_REQ_EVT SMP_OOB_REQ_EVT /* OOB data request event */
+#define BTM_LE_NC_REQ_EVT SMP_NC_REQ_EVT /* Numeric Comparison request event */
+#define BTM_LE_PR_KEYPR_NOT_EVT SMP_PEER_KEYPR_NOT_EVT /* Peer keypress notification recd event */
+/* SC OOB request event (both local and peer OOB data) can be expected in response */
+#define BTM_LE_SC_OOB_REQ_EVT SMP_SC_OOB_REQ_EVT
+/* SC OOB local data set is created (as result of SMP_CrLocScOobData(...)) */
+#define BTM_LE_SC_LOC_OOB_EVT SMP_SC_LOC_OOB_DATA_UP_EVT
+#define BTM_LE_BR_KEYS_REQ_EVT SMP_BR_KEYS_REQ_EVT /* SMP over BR keys request event */
+#define BTM_LE_COMPLT_EVT SMP_COMPLT_EVT /* SMP complete event */
+#define BTM_LE_LAST_FROM_SMP BTM_LE_BR_KEYS_REQ_EVT
+#define BTM_LE_KEY_EVT BTM_LE_LAST_FROM_SMP + 1 /* KEY update event */
+#endif ///SMP_INCLUDED == TRUE
+typedef UINT8 tBTM_LE_EVT;
+
+#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
+#define BTM_LE_KEY_NONE 0
+#define BTM_LE_KEY_PENC SMP_SEC_KEY_TYPE_ENC /* encryption information of peer device */
+#define BTM_LE_KEY_PID SMP_SEC_KEY_TYPE_ID /* identity key of the peer device */
+#define BTM_LE_KEY_PCSRK SMP_SEC_KEY_TYPE_CSRK /* peer SRK */
+#define BTM_LE_KEY_PLK SMP_SEC_KEY_TYPE_LK
+#define BTM_LE_KEY_LLK (SMP_SEC_KEY_TYPE_LK << 4)
+#define BTM_LE_KEY_LENC (SMP_SEC_KEY_TYPE_ENC << 4) /* master role security information:div */
+#define BTM_LE_KEY_LID (SMP_SEC_KEY_TYPE_ID << 4) /* master device ID key */
+#define BTM_LE_KEY_LCSRK (SMP_SEC_KEY_TYPE_CSRK << 4) /* local CSRK has been deliver to peer */
+#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
+typedef UINT8 tBTM_LE_KEY_TYPE;
+
+/* relate to ESP_LE_AUTH_xxx in esp_gap_ble_api.h */
+#if (SMP_INCLUDED == TRUE)
+#define BTM_LE_AUTH_REQ_NO_BOND SMP_AUTH_NO_BOND /* 0 */
+#define BTM_LE_AUTH_REQ_BOND SMP_AUTH_GEN_BOND /* 1 << 0 */
+#define BTM_LE_AUTH_REQ_MITM SMP_AUTH_YN_BIT /* 1 << 2 */
+#endif ///SMP_INCLUDED == TRUE
+typedef UINT8 tBTM_LE_AUTH_REQ;
+#if (SMP_INCLUDED == TRUE)
+#define BTM_LE_SC_SUPPORT_BIT SMP_SC_SUPPORT_BIT /* (1 << 3) */
+#define BTM_LE_KP_SUPPORT_BIT SMP_KP_SUPPORT_BIT /* (1 << 4) */
+
+#define BTM_LE_AUTH_REQ_SC_ONLY SMP_AUTH_SC_ENC_ONLY /* 1 << 3 */
+#define BTM_LE_AUTH_REQ_SC_BOND SMP_AUTH_SC_GB /* 1001 */
+#define BTM_LE_AUTH_REQ_SC_MITM SMP_AUTH_SC_MITM_NB /* 1100 */
+#define BTM_LE_AUTH_REQ_SC_MITM_BOND SMP_AUTH_SC_MITM_GB /* 1101 */
+#define BTM_LE_AUTH_REQ_MASK SMP_AUTH_MASK /* 0x1D */
+
+/* LE security level */
+#define BTM_LE_SEC_NONE SMP_SEC_NONE
+#define BTM_LE_SEC_UNAUTHENTICATE SMP_SEC_UNAUTHENTICATE /* 1 */
+#define BTM_LE_SEC_AUTHENTICATED SMP_SEC_AUTHENTICATED /* 4 */
+#endif ///SMP_INCLUDED == TRUE
+typedef UINT8 tBTM_LE_SEC;
+
+
+typedef struct {
+ tBTM_IO_CAP io_cap; /* local IO capabilities */
+ UINT8 oob_data; /* OOB data present (locally) for the peer device */
+ tBTM_LE_AUTH_REQ auth_req; /* Authentication request (for local device) contain bonding and MITM info */
+ UINT8 max_key_size; /* max encryption key size */
+ tBTM_LE_KEY_TYPE init_keys; /* keys to be distributed, bit mask */
+ tBTM_LE_KEY_TYPE resp_keys; /* keys to be distributed, bit mask */
+} tBTM_LE_IO_REQ;
+
+#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
+/* data type for tBTM_LE_COMPLT */
+typedef struct {
+ UINT8 reason;
+ UINT8 sec_level;
+ BOOLEAN is_pair_cancel;
+ BOOLEAN smp_over_br;
+ tSMP_AUTH_REQ auth_mode;
+} tBTM_LE_COMPLT;
+#endif
+
+/* BLE encryption keys */
+typedef struct {
+ BT_OCTET16 ltk;
+ BT_OCTET8 rand;
+ UINT16 ediv;
+ UINT8 sec_level;
+ UINT8 key_size;
+} tBTM_LE_PENC_KEYS;
+
+/* BLE CSRK keys */
+typedef struct {
+ UINT32 counter;
+ BT_OCTET16 csrk;
+ UINT8 sec_level;
+} tBTM_LE_PCSRK_KEYS;
+
+/* BLE Encryption reproduction keys */
+typedef struct {
+ BT_OCTET16 ltk;
+ UINT16 div;
+ UINT8 key_size;
+ UINT8 sec_level;
+} tBTM_LE_LENC_KEYS;
+
+/* BLE SRK keys */
+typedef struct {
+ UINT32 counter;
+ UINT16 div;
+ UINT8 sec_level;
+ BT_OCTET16 csrk;
+} tBTM_LE_LCSRK_KEYS;
+
+typedef struct {
+ BT_OCTET16 irk;
+ tBLE_ADDR_TYPE addr_type;
+ BD_ADDR static_addr;
+} tBTM_LE_PID_KEYS;
+
+typedef union {
+ tBTM_LE_PENC_KEYS penc_key; /* received peer encryption key */
+ tBTM_LE_PCSRK_KEYS pcsrk_key; /* received peer device SRK */
+ tBTM_LE_PID_KEYS pid_key; /* peer device ID key */
+ tBTM_LE_LENC_KEYS lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
+ tBTM_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
+} tBTM_LE_KEY_VALUE;
+
+typedef struct {
+ tBTM_LE_KEY_TYPE key_type;
+ tBTM_LE_KEY_VALUE *p_key_value;
+} tBTM_LE_KEY;
+
+typedef union {
+ tBTM_LE_IO_REQ io_req; /* BTM_LE_IO_REQ_EVT */
+ UINT32 key_notif; /* BTM_LE_KEY_NOTIF_EVT */
+ /* BTM_LE_NC_REQ_EVT */
+ /* no callback data for BTM_LE_KEY_REQ_EVT */
+ /* and BTM_LE_OOB_REQ_EVT */
+#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
+ tBTM_LE_COMPLT complt; /* BTM_LE_COMPLT_EVT */
+ tSMP_OOB_DATA_TYPE req_oob_type;
+ tSMP_LOC_OOB_DATA local_oob_data;
+#endif
+ tBTM_LE_KEY key;
+} tBTM_LE_EVT_DATA;
+
+/* Simple Pairing Events. Called by the stack when Simple Pairing related
+** events occur.
+*/
+typedef UINT8 (tBTM_LE_CALLBACK) (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_DATA *p_data);
+
+#define BTM_BLE_KEY_TYPE_ID 1
+#define BTM_BLE_KEY_TYPE_ER 2
+#define BTM_BLE_KEY_TYPE_COUNTER 3 //tobe obsolete
+
+typedef struct {
+ BT_OCTET16 ir;
+ BT_OCTET16 irk;
+ BT_OCTET16 dhk;
+
+} tBTM_BLE_LOCAL_ID_KEYS;
+
+typedef union {
+ tBTM_BLE_LOCAL_ID_KEYS id_keys;
+ BT_OCTET16 er;
+} tBTM_BLE_LOCAL_KEYS;
+
+
+/* New LE identity key for local device.
+*/
+typedef void (tBTM_LE_KEY_CALLBACK) (UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
+
+
+/***************************
+** Security Manager Types
+****************************/
+/* Structure that applications use to register with BTM_SecRegister */
+typedef struct {
+ tBTM_AUTHORIZE_CALLBACK *p_authorize_callback;
+ tBTM_PIN_CALLBACK *p_pin_callback;
+ tBTM_LINK_KEY_CALLBACK *p_link_key_callback;
+ tBTM_AUTH_COMPLETE_CALLBACK *p_auth_complete_callback;
+ tBTM_BOND_CANCEL_CMPL_CALLBACK *p_bond_cancel_cmpl_callback;
+ tBTM_ENC_CHANGE_CALLBACK *p_enc_change_callback;
+ tBTM_SP_CALLBACK *p_sp_callback;
+#if BLE_INCLUDED == TRUE
+#if SMP_INCLUDED == TRUE
+ tBTM_LE_CALLBACK *p_le_callback;
+#endif
+ tBTM_LE_KEY_CALLBACK *p_le_key_callback;
+#endif
+} tBTM_APPL_INFO;
+
+/* Callback function for when a link supervision timeout event occurs.
+** This asynchronous event is enabled/disabled by calling BTM_RegForLstoEvt().
+*/
+typedef void (tBTM_LSTO_CBACK) (BD_ADDR remote_bda, UINT16 timeout);
+
+/*****************************************************************************
+** POWER MANAGEMENT
+*****************************************************************************/
+/****************************
+** Power Manager Constants
+*****************************/
+/* BTM Power manager status codes */
+enum {
+ BTM_PM_STS_ACTIVE = HCI_MODE_ACTIVE,
+ BTM_PM_STS_HOLD = HCI_MODE_HOLD,
+ BTM_PM_STS_SNIFF = HCI_MODE_SNIFF,
+ BTM_PM_STS_PARK = HCI_MODE_PARK,
+ BTM_PM_STS_SSR, /* report the SSR parameters in HCI_SNIFF_SUB_RATE_EVT */
+ BTM_PM_STS_PENDING, /* when waiting for status from controller */
+ BTM_PM_STS_ERROR /* when HCI command status returns error */
+};
+typedef UINT8 tBTM_PM_STATUS;
+
+/* BTM Power manager modes */
+enum {
+ BTM_PM_MD_ACTIVE = BTM_PM_STS_ACTIVE,
+ BTM_PM_MD_HOLD = BTM_PM_STS_HOLD,
+ BTM_PM_MD_SNIFF = BTM_PM_STS_SNIFF,
+ BTM_PM_MD_PARK = BTM_PM_STS_PARK,
+ BTM_PM_MD_FORCE = 0x10 /* OR this to force ACL link to a certain mode */
+};
+typedef UINT8 tBTM_PM_MODE;
+
+#define BTM_PM_SET_ONLY_ID 0x80
+
+/* Operation codes */
+#define BTM_PM_REG_SET 1 /* The module wants to set the desired power mode */
+#define BTM_PM_REG_NOTIF 2 /* The module wants to receive mode change event */
+#define BTM_PM_DEREG 4 /* The module does not want to involve with PM anymore */
+
+/************************
+** Power Manager Types
+*************************/
+typedef struct {
+ UINT16 max;
+ UINT16 min;
+ UINT16 attempt;
+ UINT16 timeout;
+ tBTM_PM_MODE mode;
+} tBTM_PM_PWR_MD;
+
+/*************************************
+** Power Manager Callback Functions
+**************************************/
+typedef void (tBTM_PM_STATUS_CBACK) (BD_ADDR p_bda, tBTM_PM_STATUS status,
+ UINT16 value, UINT8 hci_status);
+
+
+/************************
+** Stored Linkkey Types
+*************************/
+#define BTM_CB_EVT_DELETE_STORED_LINK_KEYS 4
+
+typedef struct {
+ UINT8 event;
+ UINT8 status;
+ UINT16 num_keys;
+
+} tBTM_DELETE_STORED_LINK_KEY_COMPLETE;
+
+/* MIP evnets, callbacks */
+enum {
+ BTM_MIP_MODE_CHG_EVT,
+ BTM_MIP_DISCONNECT_EVT,
+ BTM_MIP_PKTS_COMPL_EVT,
+ BTM_MIP_RXDATA_EVT
+};
+typedef UINT8 tBTM_MIP_EVT;
+
+typedef struct {
+ tBTM_MIP_EVT event;
+ BD_ADDR bd_addr;
+ UINT16 mip_id;
+} tBTM_MIP_MODE_CHANGE;
+
+typedef struct {
+ tBTM_MIP_EVT event;
+ UINT16 mip_id;
+ UINT8 disc_reason;
+} tBTM_MIP_CONN_TIMEOUT;
+
+#define BTM_MIP_MAX_RX_LEN 17
+
+typedef struct {
+ tBTM_MIP_EVT event;
+ UINT16 mip_id;
+ UINT8 rx_len;
+ UINT8 rx_data[BTM_MIP_MAX_RX_LEN];
+} tBTM_MIP_RXDATA;
+
+typedef struct {
+ tBTM_MIP_EVT event;
+ BD_ADDR bd_addr;
+ UINT8 data[11]; /* data[0] shows Vender-specific device type */
+} tBTM_MIP_EIR_HANDSHAKE;
+
+typedef struct {
+ tBTM_MIP_EVT event;
+ UINT16 num_sent; /* Number of packets completed at the controller */
+} tBTM_MIP_PKTS_COMPL;
+
+typedef union {
+ tBTM_MIP_EVT event;
+ tBTM_MIP_MODE_CHANGE mod_chg;
+ tBTM_MIP_CONN_TIMEOUT conn_tmo;
+ tBTM_MIP_EIR_HANDSHAKE eir;
+ tBTM_MIP_PKTS_COMPL completed;
+ tBTM_MIP_RXDATA rxdata;
+} tBTM_MIP_EVENT_DATA;
+
+/* MIP event callback function */
+typedef void (tBTM_MIP_EVENTS_CB) (tBTM_MIP_EVT event, tBTM_MIP_EVENT_DATA data);
+
+/* MIP Device query callback function */
+typedef BOOLEAN (tBTM_MIP_QUERY_CB) (BD_ADDR dev_addr, UINT8 *p_mode, LINK_KEY link_key);
+
+#define BTM_CONTRL_ACTIVE 1 /* ACL link on, SCO link ongoing, sniff mode */
+#define BTM_CONTRL_SCAN 2 /* Scan state - paging/inquiry/trying to connect*/
+#define BTM_CONTRL_IDLE 3 /* Idle state - page scan, LE advt, inquiry scan */
+
+typedef UINT8 tBTM_CONTRL_STATE;
+
+/*****************************************************************************
+** EXTERNAL FUNCTION DECLARATIONS
+*****************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+** DEVICE CONTROL and COMMON FUNCTIONS
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function BTM_DeviceReset
+**
+** Description This function is called to reset the controller.The Callback function
+** if provided is called when startup of the device has
+** completed.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_DeviceReset (tBTM_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_IsDeviceUp
+**
+** Description This function is called to check if the device is up.
+**
+** Returns TRUE if device is up, else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_IsDeviceUp (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetLocalDeviceName
+**
+** Description This function is called to set the local device name.
+**
+** Returns BTM_CMD_STARTED if successful, otherwise an error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetLocalDeviceName (char *p_name);
+
+/*******************************************************************************
+**
+** Function BTM_SetDeviceClass
+**
+** Description This function is called to set the local device class
+**
+** Returns BTM_SUCCESS if successful, otherwise an error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetDeviceClass (DEV_CLASS dev_class);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadLocalDeviceName
+**
+** Description This function is called to read the local device name.
+**
+** Returns status of the operation
+** If success, BTM_SUCCESS is returned and p_name points stored
+** local device name
+** If BTM doesn't store local device name, BTM_NO_RESOURCES is
+** is returned and p_name is set to NULL
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name);
+
+/*******************************************************************************
+**
+** Function BTM_ReadLocalDeviceNameFromController
+**
+** Description Get local device name from controller. Do not use cached
+** name (used to get chip-id prior to btm reset complete).
+**
+** Returns BTM_CMD_STARTED if successful, otherwise an error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadLocalDeviceNameFromController (tBTM_CMPL_CB *p_rln_cmpl_cback);
+
+/*******************************************************************************
+**
+** Function BTM_ReadDeviceClass
+**
+** Description This function is called to read the local device class
+**
+** Returns pointer to the device class
+**
+*******************************************************************************/
+//extern
+UINT8 *BTM_ReadDeviceClass (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadLocalFeatures
+**
+** Description This function is called to read the local features
+**
+** Returns pointer to the local features string
+**
+*******************************************************************************/
+//extern
+UINT8 *BTM_ReadLocalFeatures (void);
+
+/*******************************************************************************
+**
+** Function BTM_RegisterForDeviceStatusNotif
+**
+** Description This function is called to register for device status
+** change notifications.
+**
+** Returns pointer to previous caller's callback function or NULL if first
+** registration.
+**
+*******************************************************************************/
+//extern
+tBTM_DEV_STATUS_CB *BTM_RegisterForDeviceStatusNotif (tBTM_DEV_STATUS_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_RegisterForVSEvents
+**
+** Description This function is called to register/deregister for vendor
+** specific HCI events.
+**
+** If is_register=TRUE, then the function will be registered;
+** if is_register=FALSE, then the function will be deregistered.
+**
+** Returns BTM_SUCCESS if successful,
+** BTM_BUSY if maximum number of callbacks have already been
+** registered.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_RegisterForVSEvents (tBTM_VS_EVT_CB *p_cb, BOOLEAN is_register);
+
+
+/*******************************************************************************
+**
+** Function BTM_VendorSpecificCommand
+**
+** Description Send a vendor specific HCI command to the controller.
+**
+** Returns
+** BTM_SUCCESS Command sent. Does not expect command complete
+** event. (command cmpl callback param is NULL)
+** BTM_CMD_STARTED Command sent. Waiting for command cmpl event.
+** BTM_BUSY Command not sent. Waiting for cmd cmpl event for
+** prior command.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode,
+ UINT8 param_len,
+ UINT8 *p_param_buf,
+ tBTM_VSC_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_ConfigCoexStatus
+**
+** Description Config coexist status through vendor specific HCI command.
+**
+** Returns
+** BTM_SUCCESS Command sent. Does not expect command complete
+** event. (command cmpl callback param is NULL)
+** BTM_NO_RESOURCES Command not sent. No resources.
+**
+*******************************************************************************/
+#if (ESP_COEX_VSC_INCLUDED == TRUE)
+tBTM_STATUS BTM_ConfigCoexStatus(tBTM_COEX_OPERATION op, tBTM_COEX_TYPE type, UINT8 status);
+#endif
+
+/*******************************************************************************
+**
+** Function BTM_AllocateSCN
+**
+** Description Look through the Server Channel Numbers for a free one to be
+** used with an RFCOMM connection.
+**
+** Returns Allocated SCN number or 0 if none.
+**
+*******************************************************************************/
+//extern
+#if (CLASSIC_BT_INCLUDED == TRUE)
+UINT8 BTM_AllocateSCN(void);
+
+// btla-specific ++
+/*******************************************************************************
+**
+** Function BTM_TryAllocateSCN
+**
+** Description Try to allocate a fixed server channel
+**
+** Returns Returns TRUE if server channel was available
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_TryAllocateSCN(UINT8 scn);
+// btla-specific --
+
+
+/*******************************************************************************
+**
+** Function BTM_FreeSCN
+**
+** Description Free the specified SCN.
+**
+** Returns TRUE if successful, FALSE if SCN is not in use or invalid
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_FreeSCN(UINT8 scn);
+#endif ///CLASSIC_BT_INCLUDED == TRUE
+
+
+/*******************************************************************************
+**
+** Function BTM_SetTraceLevel
+**
+** Description This function sets the trace level for BTM. If called with
+** a value of 0xFF, it simply returns the current trace level.
+**
+** Returns The new or current trace level
+**
+*******************************************************************************/
+//extern
+UINT8 BTM_SetTraceLevel (UINT8 new_level);
+
+
+/*******************************************************************************
+**
+** Function BTM_WritePageTimeout
+**
+** Description Send HCI Wite Page Timeout.
+**
+** Returns
+** BTM_SUCCESS Command sent.
+** BTM_NO_RESOURCES If out of resources to send the command.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout, tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_ReadPageTimeout
+**
+** Description Send HCI Read Page Timeout.
+**
+** Returns
+** BTM_SUCCESS Command sent.
+** BTM_NO_RESOURCES If out of resources to send the command.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadPageTimeout(tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_SetAclPktTypes
+**
+** Description Send HCI Change Connection Packet Type
+**
+** Returns
+** BTM_SUCCESS Command sent.
+** BTM_NO_RESOURCES If out of resources to send the command.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetAclPktTypes(BD_ADDR remote_bda, UINT16 pkt_types, tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_WriteVoiceSettings
+**
+** Description Send HCI Write Voice Settings command.
+** See stack/hcidefs.h for settings bitmask values.
+**
+** Returns
+** BTM_SUCCESS Command sent.
+** BTM_NO_RESOURCES If out of resources to send the command.
+**
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings);
+
+/*******************************************************************************
+**
+** Function BTM_EnableTestMode
+**
+** Description Send HCI the enable device under test command.
+**
+** Note: Controller can only be taken out of this mode by
+** resetting the controller.
+**
+** Returns
+** BTM_SUCCESS Command sent.
+** BTM_NO_RESOURCES If out of resources to send the command.
+**
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_EnableTestMode(void);
+
+
+/*****************************************************************************
+** DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function BTM_SetDiscoverability
+**
+** Description This function is called to set the device into or out of
+** discoverable mode. Discoverable mode means inquiry
+** scans are enabled. If a value of '0' is entered for window or
+** interval, the default values are used.
+**
+** Returns BTM_SUCCESS if successful
+** BTM_BUSY if a setting of the filter is already in progress
+** BTM_NO_RESOURCES if couldn't get a memory pool buffer
+** BTM_ILLEGAL_VALUE if a bad parameter was detected
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window,
+ UINT16 interval);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadDiscoverability
+**
+** Description This function is called to read the current discoverability
+** mode of the device.
+**
+** Output Params: p_window - current inquiry scan duration
+** p_interval - current inquiry scan interval
+**
+** Returns BTM_NON_DISCOVERABLE, BTM_LIMITED_DISCOVERABLE, or
+** BTM_GENERAL_DISCOVERABLE
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_ReadDiscoverability (UINT16 *p_window,
+ UINT16 *p_interval);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetPeriodicInquiryMode
+**
+** Description This function is called to set the device periodic inquiry mode.
+** If the duration is zero, the periodic inquiry mode is cancelled.
+**
+** Parameters: p_inqparms - pointer to the inquiry information
+** mode - GENERAL or LIMITED inquiry
+** duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
+** max_resps - maximum amount of devices to search for before ending the inquiry
+** filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
+** BTM_FILTER_COND_BD_ADDR
+** filter_cond - value for the filter (based on filter_cond_type)
+**
+** max_delay - maximum amount of time between successive inquiries
+** min_delay - minimum amount of time between successive inquiries
+** p_results_cb - callback returning pointer to results (tBTM_INQ_RESULTS)
+**
+** Returns BTM_CMD_STARTED if successfully started
+** BTM_ILLEGAL_VALUE if a bad parameter is detected
+** BTM_NO_RESOURCES if could not allocate a message buffer
+** BTM_SUCCESS - if cancelling the periodic inquiry
+** BTM_BUSY - if an inquiry is already active
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms,
+ UINT16 max_delay, UINT16 min_delay,
+ tBTM_INQ_RESULTS_CB *p_results_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_StartInquiry
+**
+** Description This function is called to start an inquiry.
+**
+** Parameters: p_inqparms - pointer to the inquiry information
+** mode - GENERAL or LIMITED inquiry
+** duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
+** max_resps - maximum amount of devices to search for before ending the inquiry
+** filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
+** BTM_FILTER_COND_BD_ADDR
+** filter_cond - value for the filter (based on filter_cond_type)
+**
+** p_results_cb - Pointer to the callback routine which gets called
+** upon receipt of an inquiry result. If this field is
+** NULL, the application is not notified.
+**
+** p_cmpl_cb - Pointer to the callback routine which gets called
+** upon completion. If this field is NULL, the
+** application is not notified when completed.
+** Returns tBTM_STATUS
+** BTM_CMD_STARTED if successfully initiated
+** BTM_BUSY if already in progress
+** BTM_ILLEGAL_VALUE if parameter(s) are out of range
+** BTM_NO_RESOURCES if could not allocate resources to start the command
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms,
+ tBTM_INQ_RESULTS_CB *p_results_cb,
+ tBTM_CMPL_CB *p_cmpl_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_IsInquiryActive
+**
+** Description This function returns a bit mask of the current inquiry state
+**
+** Returns BTM_INQUIRY_INACTIVE if inactive (0)
+** BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active
+** BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
+** BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_IsInquiryActive (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_CancelInquiry
+**
+** Description This function cancels an inquiry if active
+**
+** Returns BTM_SUCCESS if successful
+** BTM_NO_RESOURCES if could not allocate a message buffer
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_CancelInquiry(void);
+
+
+/*******************************************************************************
+**
+** Function BTM_CancelPeriodicInquiry
+**
+** Description This function cancels a periodic inquiry
+**
+** Returns
+** BTM_NO_RESOURCES if could not allocate a message buffer
+** BTM_SUCCESS - if cancelling the periodic inquiry
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_CancelPeriodicInquiry(void);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetConnectability
+**
+** Description This function is called to set the device into or out of
+** connectable mode. Discoverable mode means page scans enabled.
+**
+** Returns BTM_SUCCESS if successful
+** BTM_ILLEGAL_VALUE if a bad parameter is detected
+** BTM_NO_RESOURCES if could not allocate a message buffer
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetConnectability (UINT16 page_mode, UINT16 window,
+ UINT16 interval);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadConnectability
+**
+** Description This function is called to read the current discoverability
+** mode of the device.
+** Output Params p_window - current page scan duration
+** p_interval - current time between page scans
+**
+** Returns BTM_NON_CONNECTABLE or BTM_CONNECTABLE
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetInquiryMode
+**
+** Description This function is called to set standard, with RSSI
+** mode or extended of the inquiry for local device.
+**
+** Input Params: BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
+** BTM_INQ_RESULT_EXTENDED
+**
+** Returns BTM_SUCCESS if successful
+** BTM_NO_RESOURCES if couldn't get a memory pool buffer
+** BTM_ILLEGAL_VALUE if a bad parameter was detected
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetInquiryMode (UINT8 mode);
+
+/*******************************************************************************
+**
+** Function BTM_SetInquiryScanType
+**
+** Description This function is called to set the iquiry scan-type to
+** standard or interlaced.
+**
+** Input Params: BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
+**
+** Returns BTM_SUCCESS if successful
+** BTM_MODE_UNSUPPORTED if not a 1.2 device
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetInquiryScanType (UINT16 scan_type);
+
+/*******************************************************************************
+**
+** Function BTM_SetPageScanType
+**
+** Description This function is called to set the page scan-type to
+** standard or interlaced.
+**
+** Input Params: BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
+**
+** Returns BTM_SUCCESS if successful
+** BTM_MODE_UNSUPPORTED if not a 1.2 device
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+
+//extern
+tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type);
+
+/*******************************************************************************
+**
+** Function BTM_ReadRemoteDeviceName
+**
+** Description This function initiates a remote device HCI command to the
+** controller and calls the callback when the process has completed.
+**
+** Input Params: remote_bda - device address of name to retrieve
+** p_cb - callback function called when BTM_CMD_STARTED
+** is returned.
+** A pointer to tBTM_REMOTE_DEV_NAME is passed to the
+** callback.
+**
+** Returns
+** BTM_CMD_STARTED is returned if the request was successfully sent
+** to HCI.
+** BTM_BUSY if already in progress
+** BTM_UNKNOWN_ADDR if device address is bad
+** BTM_NO_RESOURCES if could not allocate resources to start the command
+** BTM_WRONG_MODE if the device is not up.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda,
+ tBTM_CMPL_CB *p_cb,
+ tBT_TRANSPORT transport);
+
+
+/*******************************************************************************
+**
+** Function BTM_CancelRemoteDeviceName
+**
+** Description This function initiates the cancel request for the specified
+** remote device.
+**
+** Input Params: None
+**
+** Returns
+** BTM_CMD_STARTED is returned if the request was successfully sent
+** to HCI.
+** BTM_NO_RESOURCES if could not allocate resources to start the command
+** BTM_WRONG_MODE if there is not an active remote name request.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_CancelRemoteDeviceName (void);
+
+/*******************************************************************************
+**
+** Function BTM_ReadRemoteVersion
+**
+** Description This function is called to read a remote device's version
+**
+** Returns BTM_SUCCESS if successful, otherwise an error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadRemoteVersion (BD_ADDR addr,
+ UINT8 *lmp_version,
+ UINT16 *manufacturer,
+ UINT16 *lmp_sub_version);
+
+/*******************************************************************************
+**
+** Function BTM_ReadRemoteFeatures
+**
+** Description This function is called to read a remote device's
+** supported features mask (features mask located at page 0)
+**
+** Note: The size of device features mask page is
+** BTM_FEATURE_BYTES_PER_PAGE bytes.
+**
+** Returns pointer to the remote supported features mask
+**
+*******************************************************************************/
+//extern
+UINT8 *BTM_ReadRemoteFeatures (BD_ADDR addr);
+
+/*******************************************************************************
+**
+** Function BTM_ReadRemoteExtendedFeatures
+**
+** Description This function is called to read a specific extended features
+** page of the remote device
+**
+** Note1: The size of device features mask page is
+** BTM_FEATURE_BYTES_PER_PAGE bytes.
+** Note2: The valid device features mask page number depends on
+** the remote device capabilities. It is expected to be in the
+** range [0 - BTM_EXT_FEATURES_PAGE_MAX].
+
+** Returns pointer to the remote extended features mask
+** or NULL if page_number is not valid
+**
+*******************************************************************************/
+//extern
+UINT8 *BTM_ReadRemoteExtendedFeatures (BD_ADDR addr, UINT8 page_number);
+
+/*******************************************************************************
+**
+** Function BTM_ReadNumberRemoteFeaturesPages
+**
+** Description This function is called to retrieve the number of feature pages
+** read from the remote device
+**
+** Returns number of features pages read from the remote device
+**
+*******************************************************************************/
+//extern
+UINT8 BTM_ReadNumberRemoteFeaturesPages (BD_ADDR addr);
+
+/*******************************************************************************
+**
+** Function BTM_ReadAllRemoteFeatures
+**
+** Description This function is called to read all features of the remote device
+**
+** Returns pointer to the byte[0] of the page[0] of the remote device
+** feature mask.
+**
+** Note: the function returns the pointer to the array of the size
+** BTM_FEATURE_BYTES_PER_PAGE * (BTM_EXT_FEATURES_PAGE_MAX + 1).
+**
+*******************************************************************************/
+//extern
+UINT8 *BTM_ReadAllRemoteFeatures (BD_ADDR addr);
+
+/*******************************************************************************
+**
+** Function BTM_InqDbRead
+**
+** Description This function looks through the inquiry database for a match
+** based on Bluetooth Device Address. This is the application's
+** interface to get the inquiry details of a specific BD address.
+**
+** Returns pointer to entry, or NULL if not found
+**
+*******************************************************************************/
+//extern
+tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda);
+
+
+/*******************************************************************************
+**
+** Function BTM_InqDbFirst
+**
+** Description This function looks through the inquiry database for the first
+** used entry, and returns that. This is used in conjunction with
+** BTM_InqDbNext by applications as a way to walk through the
+** inquiry database.
+**
+** Returns pointer to first in-use entry, or NULL if DB is empty
+**
+*******************************************************************************/
+//extern
+tBTM_INQ_INFO *BTM_InqDbFirst (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_InqDbNext
+**
+** Description This function looks through the inquiry database for the next
+** used entry, and returns that. If the input parameter is NULL,
+** the first entry is returned.
+**
+** Returns pointer to next in-use entry, or NULL if no more found.
+**
+*******************************************************************************/
+//extern
+tBTM_INQ_INFO *BTM_InqDbNext (tBTM_INQ_INFO *p_cur);
+
+
+/*******************************************************************************
+**
+** Function BTM_ClearInqDb
+**
+** Description This function is called to clear out a device or all devices
+** from the inquiry database.
+**
+** Parameter p_bda - (input) BD_ADDR -> Address of device to clear
+** (NULL clears all entries)
+**
+** Returns BTM_BUSY if an inquiry, get remote name, or event filter
+** is active, otherwise BTM_SUCCESS
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda);
+
+/*******************************************************************************
+**
+** Function BTM_ReadInquiryRspTxPower
+**
+** Description This command will read the inquiry Transmit Power level used
+** to transmit the FHS and EIR data packets.
+** This can be used directly in the Tx Power Level EIR data type.
+**
+** Returns BTM_SUCCESS if successful
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb);
+
+#if SDP_INCLUDED == TRUE
+/*******************************************************************************
+**
+** Function BTM_StartDiscovery
+**
+** Description This function is called by an application (or profile)
+** when it wants to trigger an service discovery using the
+** BTM's discovery database.
+**
+** Returns tBTM_STATUS
+** BTM_CMD_STARTED if the discovery was initiated
+** BTM_BUSY if one is already in progress
+** BTM_UNKNOWN_ADDR if no addresses are in the INQ DB
+** BTM_ERR_PROCESSING if err initiating the command
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_StartDiscovery (tBTM_CMPL_CB *p_cmpl_cb,
+ BD_ADDR_PTR p_rem_addr);
+
+
+/*******************************************************************************
+**
+** Function BTM_FindAttribute
+**
+** Description This function is called by an application (or profile)
+** when it wants to see if an attribute exists in the BTM
+** discovery database.
+**
+** Returns Pointer to matching record, or NULL
+**
+*******************************************************************************/
+//extern
+tSDP_DISC_REC *BTM_FindAttribute (UINT16 attr_id,
+ tSDP_DISC_REC *p_start_rec);
+
+
+/*******************************************************************************
+**
+** Function BTM_FindService
+**
+** Description This function is called by an application (or profile)
+** when it wants to see if a service exists in the BTM
+** discovery database.
+**
+** Returns Pointer to matching record, or NULL
+**
+*******************************************************************************/
+//extern
+tSDP_DISC_REC *BTM_FindService (UINT16 service_uuid,
+ tSDP_DISC_REC *p_start_rec);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetDiscoveryParams
+**
+** Description This function is called to set the BTM default discovery parameters.
+** These UUID and attribute filters are used during the call to
+** BTM_StartDiscovery.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_SetDiscoveryParams (UINT16 num_uuid, tSDP_UUID *p_uuid_list,
+ UINT16 num_attr, UINT16 *p_attr_list);
+#endif /*SDP_INCLUDED*/
+
+/*****************************************************************************
+** ACL CHANNEL MANAGEMENT FUNCTIONS
+*****************************************************************************/
+/*******************************************************************************
+**
+** Function BTM_SetLinkPolicy
+**
+** Description Create and send HCI "Write Policy Set" command
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetLinkPolicy (BD_ADDR remote_bda,
+ UINT16 *settings);
+
+/*******************************************************************************
+**
+** Function BTM_SetDefaultLinkPolicy
+**
+** Description Set the default value for HCI "Write Policy Set" command
+** to use when an ACL link is created.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_SetDefaultLinkPolicy (UINT16 settings);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetDefaultLinkSuperTout
+**
+** Description Set the default value for HCI "Write Link Supervision Timeout"
+** command to use when an ACL link is created.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_SetDefaultLinkSuperTout (UINT16 timeout);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetLinkSuperTout
+**
+** Description Create and send HCI "Write Link Supervision Timeout" command
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda,
+ UINT16 timeout);
+/*******************************************************************************
+**
+** Function BTM_GetLinkSuperTout
+**
+** Description Read the link supervision timeout value of the connection
+**
+** Returns status of the operation
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_GetLinkSuperTout (BD_ADDR remote_bda,
+ UINT16 *p_timeout);
+
+/*******************************************************************************
+**
+** Function BTM_IsAclConnectionUp
+**
+** Description This function is called to check if an ACL connection exists
+** to a specific remote BD Address.
+**
+** Returns TRUE if connection is up, else FALSE.
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda, tBT_TRANSPORT transport);
+
+
+/*******************************************************************************
+**
+** Function BTM_GetRole
+**
+** Description This function is called to get the role of the local device
+** for the ACL connection with the specified remote device
+**
+** Returns BTM_SUCCESS if connection exists.
+** BTM_UNKNOWN_ADDR if no active link with bd addr specified
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role);
+
+
+
+/*******************************************************************************
+**
+** Function BTM_SwitchRole
+**
+** Description This function is called to switch role between master and
+** slave. If role is already set it will do nothing. If the
+** command was initiated, the callback function is called upon
+** completion.
+**
+** Returns BTM_SUCCESS if already in specified role.
+** BTM_CMD_STARTED if command issued to controller.
+** BTM_NO_RESOURCES if couldn't allocate memory to issue command
+** BTM_UNKNOWN_ADDR if no active link with bd addr specified
+** BTM_MODE_UNSUPPORTED if local device does not support role switching
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr,
+ UINT8 new_role,
+ tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_ReadRSSI
+**
+** Description This function is called to read the RSSI for a particular transport.
+** The RSSI of results are returned in the callback.
+** (tBTM_RSSI_RESULTS)
+**
+** Returns BTM_CMD_STARTED if command issued to controller.
+** BTM_NO_RESOURCES if couldn't allocate memory to issue command
+** BTM_UNKNOWN_ADDR if no active link with bd addr specified
+** BTM_BUSY if command is already in progress
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadTxPower
+**
+** Description This function is called to read the current connection
+** TX power of the connection. The TX power level results
+** are returned in the callback.
+** (tBTM_RSSI_RESULTS)
+**
+** Returns BTM_CMD_STARTED if command issued to controller.
+** BTM_NO_RESOURCES if couldn't allocate memory to issue command
+** BTM_UNKNOWN_ADDR if no active link with bd addr specified
+** BTM_BUSY if command is already in progress
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda,
+ tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
+
+tBTM_STATUS BTM_BleReadAdvTxPower(tBTM_CMPL_CB *p_cb);
+
+void BTM_BleGetWhiteListSize(uint16_t *length);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadLinkQuality
+**
+** Description This function is called to read the link quality.
+** The value of the link quality is returned in the callback.
+** (tBTM_LINK_QUALITY_RESULTS)
+**
+** Returns BTM_CMD_STARTED if command issued to controller.
+** BTM_NO_RESOURCES if couldn't allocate memory to issue command
+** BTM_UNKNOWN_ADDR if no active link with bd addr specified
+** BTM_BUSY if command is already in progress
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadLinkQuality (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_RegBusyLevelNotif
+**
+** Description This function is called to register a callback to receive
+** busy level change events.
+**
+** Returns BTM_SUCCESS if successfully registered, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level,
+ tBTM_BL_EVENT_MASK evt_mask);
+
+/*******************************************************************************
+**
+** Function BTM_RegAclLinkStatNotif
+**
+** Description This function is called to register a callback to receive
+** ACL link related events.
+**
+** Returns BTM_SUCCESS if successfully registered, otherwise error
+**
+*******************************************************************************/
+tBTM_STATUS BTM_RegAclLinkStatNotif(tBTM_ACL_LINK_STAT_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_AclRegisterForChanges
+**
+** Description This function is called to register a callback to receive
+** ACL database change events, i.e. new connection or removed.
+**
+** Returns BTM_SUCCESS if successfully initiated, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_GetNumAclLinks
+**
+** Description This function is called to count the number of
+** ACL links that are active.
+**
+** Returns UINT16 Number of active ACL links
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_GetNumAclLinks (void);
+
+/*******************************************************************************
+**
+** Function BTM_SetQoS
+**
+** Description This function is called to setup QoS
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetQoS(BD_ADDR bd, FLOW_SPEC *p_flow,
+ tBTM_CMPL_CB *p_cb);
+
+
+/*****************************************************************************
+** (e)SCO CHANNEL MANAGEMENT FUNCTIONS
+*****************************************************************************/
+/*******************************************************************************
+**
+** Function BTM_CreateSco
+**
+** Description This function is called to create an SCO connection. If the
+** "is_orig" flag is TRUE, the connection will be originated,
+** otherwise BTM will wait for the other side to connect.
+**
+** Returns BTM_UNKNOWN_ADDR if the ACL connection is not up
+** BTM_BUSY if another SCO being set up to
+** the same BD address
+** BTM_NO_RESOURCES if the max SCO limit has been reached
+** BTM_CMD_STARTED if the connection establishment is started.
+** In this case, "*p_sco_inx" is filled in
+** with the sco index used for the connection.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig,
+ UINT16 pkt_types, UINT16 *p_sco_inx,
+ tBTM_SCO_CB *p_conn_cb,
+ tBTM_SCO_CB *p_disc_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_RemoveSco
+**
+** Description This function is called to remove a specific SCO connection.
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_RemoveSco (UINT16 sco_inx);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetScoPacketTypes
+**
+** Description This function is called to set the packet types used for
+** a specific SCO connection,
+**
+** Parameters pkt_types - One or more of the following
+** BTM_SCO_PKT_TYPES_MASK_HV1
+** BTM_SCO_PKT_TYPES_MASK_HV2
+** BTM_SCO_PKT_TYPES_MASK_HV3
+** BTM_SCO_PKT_TYPES_MASK_EV3
+** BTM_SCO_PKT_TYPES_MASK_EV4
+** BTM_SCO_PKT_TYPES_MASK_EV5
+**
+** BTM_SCO_LINK_ALL_MASK - enables all supported types
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetScoPacketTypes (UINT16 sco_inx, UINT16 pkt_types);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadScoPacketTypes
+**
+** Description This function is read the packet types used for a specific
+** SCO connection.
+**
+** Returns One or more of the following (bitmask)
+** BTM_SCO_PKT_TYPES_MASK_HV1
+** BTM_SCO_PKT_TYPES_MASK_HV2
+** BTM_SCO_PKT_TYPES_MASK_HV3
+** BTM_SCO_PKT_TYPES_MASK_EV3
+** BTM_SCO_PKT_TYPES_MASK_EV4
+** BTM_SCO_PKT_TYPES_MASK_EV5
+**
+** Returns packet types supported for the connection
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadDeviceScoPacketTypes
+**
+** Description This function is read the SCO packet types that
+** the device supports.
+**
+** Returns packet types supported by the device.
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_ReadDeviceScoPacketTypes (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadScoHandle
+**
+** Description This function is used to read the HCI handle used for a specific
+** SCO connection,
+**
+** Returns handle for the connection, or 0xFFFF if invalid SCO index.
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_ReadScoHandle (UINT16 sco_inx);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadScoBdAddr
+**
+** Description This function is read the remote BD Address for a specific
+** SCO connection,
+**
+** Returns pointer to BD address or NULL if not known
+**
+*******************************************************************************/
+//extern
+UINT8 *BTM_ReadScoBdAddr (UINT16 sco_inx);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadScoDiscReason
+**
+** Description This function is returns the reason why an (e)SCO connection
+** has been removed. It contains the value until read, or until
+** another (e)SCO connection has disconnected.
+**
+** Returns HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_ReadScoDiscReason (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetEScoMode
+**
+** Description This function sets up the negotiated parameters for SCO or
+** eSCO, and sets as the default mode used for calls to
+** BTM_CreateSco. It can be called only when there are no
+** active (e)SCO links.
+**
+** Returns BTM_SUCCESS if the successful.
+** BTM_BUSY if there are one or more active (e)SCO links.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode,
+ tBTM_ESCO_PARAMS *p_parms);
+
+/*******************************************************************************
+**
+** Function BTM_SetWBSCodec
+**
+** Description This function sends command to the controller to setup
+** WBS codec for the upcoming eSCO connection.
+**
+** Returns BTM_SUCCESS.
+**
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type);
+
+/*******************************************************************************
+**
+** Function BTM_RegForEScoEvts
+**
+** Description This function registers a SCO event callback with the
+** specified instance. It should be used to received
+** connection indication events and change of link parameter
+** events.
+**
+** Returns BTM_SUCCESS if the successful.
+** BTM_ILLEGAL_VALUE if there is an illegal sco_inx
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_RegForEScoEvts (UINT16 sco_inx,
+ tBTM_ESCO_CBACK *p_esco_cback);
+
+/*******************************************************************************
+**
+** Function BTM_ReadEScoLinkParms
+**
+** Description This function returns the current eSCO link parameters for
+** the specified handle. This can be called anytime a connection
+** is active, but is typically called after receiving the SCO
+** opened callback.
+**
+** Note: If called over a 1.1 controller, only the packet types
+** field has meaning.
+** Note: If the upper layer doesn't know the current sco index,
+** BTM_FIRST_ACTIVE_SCO_INDEX can be used as the first parameter to
+** find the first active SCO index
+**
+** Returns BTM_SUCCESS if returned data is valid connection.
+** BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
+** BTM_MODE_UNSUPPORTED if local controller does not support
+** 1.2 specification.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadEScoLinkParms (UINT16 sco_inx,
+ tBTM_ESCO_DATA *p_parms);
+
+/*******************************************************************************
+**
+** Function BTM_ChangeEScoLinkParms
+**
+** Description This function requests renegotiation of the parameters on
+** the current eSCO Link. If any of the changes are accepted
+** by the controllers, the BTM_ESCO_CHG_EVT event is sent in
+** the tBTM_ESCO_CBACK function with the current settings of
+** the link. The callback is registered through the call to
+** BTM_SetEScoMode.
+**
+**
+** Returns BTM_CMD_STARTED if command is successfully initiated.
+** BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
+** BTM_NO_RESOURCES - not enough resources to initiate command.
+** BTM_MODE_UNSUPPORTED if local controller does not support
+** 1.2 specification.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ChangeEScoLinkParms (UINT16 sco_inx,
+ tBTM_CHG_ESCO_PARAMS *p_parms);
+
+/*******************************************************************************
+**
+** Function BTM_EScoConnRsp
+**
+** Description This function is called upon receipt of an (e)SCO connection
+** request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
+** the request. Parameters used to negotiate eSCO links.
+** If p_parms is NULL, then values set through BTM_SetEScoMode
+** are used.
+** If the link type of the incoming request is SCO, then only
+** the tx_bw, max_latency, content format, and packet_types are
+** valid. The hci_status parameter should be
+** ([0x0] to accept, [0x0d..0x0f] to reject)
+**
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_EScoConnRsp (UINT16 sco_inx, UINT8 hci_status,
+ tBTM_ESCO_PARAMS *p_parms);
+
+/*******************************************************************************
+**
+** Function BTM_GetNumScoLinks
+**
+** Description This function returns the number of active SCO links.
+**
+** Returns UINT8
+**
+*******************************************************************************/
+//extern
+UINT8 BTM_GetNumScoLinks (void);
+
+/*****************************************************************************
+** SECURITY MANAGEMENT FUNCTIONS
+*****************************************************************************/
+/*******************************************************************************
+**
+** Function BTM_SecRegister
+**
+** Description Application manager calls this function to register for
+** security services. There can be one and only one application
+** saving link keys. BTM allows only first registration.
+**
+** Returns TRUE if registered OK, else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_SecRegister (tBTM_APPL_INFO *p_cb_info);
+
+/*******************************************************************************
+**
+** Function BTM_SecRegisterLinkKeyNotificationCallback
+**
+** Description Profiles can register to be notified when a new Link Key
+** is generated per connection.
+**
+** Returns TRUE if registered OK, else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback(
+ tBTM_LINK_KEY_CALLBACK *p_callback);
+
+/*******************************************************************************
+**
+** Function BTM_SecAddRmtNameNotifyCallback
+**
+** Description Profiles can register to be notified when name of the
+** remote device is resolved (up to BTM_SEC_MAX_RMT_NAME_CALLBACKS).
+**
+** Returns TRUE if registered OK, else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback);
+
+
+/*******************************************************************************
+**
+** Function BTM_SecDeleteRmtNameNotifyCallback
+**
+** Description A profile can deregister notification when a new Link Key
+** is generated per connection.
+**
+** Returns TRUE if OK, else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback);
+
+/*******************************************************************************
+**
+** Function BTM_GetSecurityFlags
+**
+** Description Get security flags for the device
+**
+** Returns BOOLEAN TRUE or FALSE is device found
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_GetSecurityFlags (BD_ADDR bd_addr, UINT8 *p_sec_flags);
+
+/*******************************************************************************
+**
+** Function BTM_GetSecurityFlagsByTransport
+**
+** Description Get security flags for the device on a particular transport
+**
+** Parameters bd_addr: BD address of remote device
+** p_sec_flags : Out parameter to be filled with security flags for the connection
+** transport : Physical transport of the connection (BR/EDR or LE)
+**
+** Returns BOOLEAN TRUE or FALSE is device found
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_GetSecurityFlagsByTransport (BD_ADDR bd_addr,
+ UINT8 *p_sec_flags, tBT_TRANSPORT transport);
+
+/*******************************************************************************
+**
+** Function BTM_ReadTrustedMask
+**
+** Description Get trusted mask for the device
+**
+** Returns NULL, if the device record is not found.
+** otherwise, the trusted mask
+**
+*******************************************************************************/
+//extern
+UINT32 *BTM_ReadTrustedMask (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTM_SetPinType
+**
+** Description Set PIN type for the device.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetPairableMode
+**
+** Description Enable or disable pairing
+**
+** Parameters allow_pairing - (TRUE or FALSE) whether or not the device
+** allows pairing.
+** connect_only_paired - (TRUE or FALSE) whether or not to
+** only allow paired devices to connect.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired);
+
+/*******************************************************************************
+**
+** Function BTM_SetSecureConnectionsOnly
+**
+** Description Enable or disable default treatment for Mode 4 Level 0 services
+**
+** Parameter secure_connections_only_mode - (TRUE or FALSE)
+** TRUE means that the device should treat Mode 4 Level 0 services as
+** services of other levels.
+** FALSE means that the device should provide default treatment for
+** Mode 4 Level 0 services.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_SetSecureConnectionsOnly (BOOLEAN secure_connections_only_mode);
+
+/*******************************************************************************
+**
+** Function BTM_SetSecurityLevel
+**
+** Description Register service security level with Security Manager. Each
+** service must register its requirements regardless of the
+** security level that is used. This API is called once for originators
+** nad again for acceptors of connections.
+**
+** Returns TRUE if registered OK, else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, const char *p_name,
+ UINT8 service_id, UINT16 sec_level,
+ UINT16 psm, UINT32 mx_proto_id,
+ UINT32 mx_chan_id);
+
+/*******************************************************************************
+**
+** Function BTM_SetOutService
+**
+** Description This function is called to set the service for
+** outgoing connection.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id);
+
+/*******************************************************************************
+**
+** Function BTM_SecClrService
+**
+** Description Removes specified service record(s) from the security database.
+** All service records with the specified name are removed.
+** Typically used only by devices with limited RAM so that it can
+** reuse an old security service record.
+** records (except SDP).
+**
+** Returns Number of records that were freed.
+**
+*******************************************************************************/
+//extern
+UINT8 BTM_SecClrService (UINT8 service_id);
+
+/*******************************************************************************
+**
+** Function BTM_SecAddDevice
+**
+** Description Add/modify device. This function will be normally called
+** during host startup to restore all required information
+** stored in the NVRAM.
+** dev_class, bd_name, link_key, and features are NULL if unknown
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class,
+ BD_NAME bd_name, UINT8 *features,
+ UINT32 trusted_mask[], LINK_KEY link_key,
+ UINT8 key_type, tBTM_IO_CAP io_cap, UINT8 pin_length,
+ UINT8 sc_support);
+
+
+/*******************************************************************************
+**
+** Function BTM_SecDeleteDevice
+**
+** Description Free resources associated with the device.
+**
+** Returns TRUE if rmoved OK, FALSE if not found
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr, tBT_TRANSPORT transport);
+
+/*******************************************************************************
+**
+** Function BTM_SecGetDeviceLinkKey
+**
+** Description This function is called to obtain link key for the device
+** it returns BTM_SUCCESS if link key is available, or
+** BTM_UNKNOWN_ADDR if Security Manager does not know about
+** the device or device record does not contain link key info
+**
+** Returns BTM_SUCCESS if successful, otherwise error code
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr,
+ LINK_KEY link_key);
+
+
+/*******************************************************************************
+**
+** Function BTM_SecGetDeviceLinkKeyType
+**
+** Description This function is called to obtain link key type for the
+** device.
+** it returns BTM_SUCCESS if link key is available, or
+** BTM_UNKNOWN_ADDR if Security Manager does not know about
+** the device or device record does not contain link key info
+**
+** Returns BTM_LKEY_TYPE_IGNORE if link key is unknown, link type
+** otherwise.
+**
+*******************************************************************************/
+//extern
+tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType (BD_ADDR bd_addr);
+
+
+/*******************************************************************************
+**
+** Function BTM_PINCodeReply
+**
+** Description This function is called after Security Manager submitted
+** PIN code request to the UI.
+**
+** Parameters: bd_addr - Address of the device for which PIN was requested
+** res - result of the operation BTM_SUCCESS if success
+** pin_len - length in bytes of the PIN Code
+** p_pin - pointer to array with the PIN Code
+** trusted_mask - bitwise OR of trusted services (array of UINT32)
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len,
+ UINT8 *p_pin, UINT32 trusted_mask[]);
+
+
+/*******************************************************************************
+**
+** Function BTM_SecBond
+**
+** Description This function is called to perform bonding with peer device.
+**
+** Parameters: bd_addr - Address of the device to bond
+** pin_len - length in bytes of the PIN Code
+** p_pin - pointer to array with the PIN Code
+** trusted_mask - bitwise OR of trusted services (array of UINT32)
+
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr,
+ UINT8 pin_len, UINT8 *p_pin,
+ UINT32 trusted_mask[]);
+
+/*******************************************************************************
+**
+** Function BTM_SecBondByTransport
+**
+** Description This function is called to perform bonding by designated transport
+**
+** Parameters: bd_addr - Address of the device to bond
+** pin_len - length in bytes of the PIN Code
+** p_pin - pointer to array with the PIN Code
+** trusted_mask - bitwise OR of trusted services (array of UINT32)
+** transport : Physical transport to use for bonding (BR/EDR or LE)
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr,
+ tBT_TRANSPORT transport,
+ UINT8 pin_len, UINT8 *p_pin,
+ UINT32 trusted_mask[]);
+
+/*******************************************************************************
+**
+** Function BTM_SecBondCancel
+**
+** Description This function is called to cancel ongoing bonding process
+** with peer device.
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTM_SetEncryption
+**
+** Description This function is called to ensure that connection is
+** encrypted. Should be called only on an open connection.
+** Typically only needed for connections that first want to
+** bring up unencrypted links, then later encrypt them.
+**
+** Parameters: bd_addr - Address of the peer device
+** p_callback - Pointer to callback function called if
+** this function returns PENDING after required
+** procedures are completed. Can be set to NULL
+** if status is not desired.
+** p_ref_data - pointer to any data the caller wishes to receive
+** in the callback function upon completion.
+* can be set to NULL if not used.
+**
+** Returns BTM_SUCCESS - already encrypted
+** BTM_PENDING - command will be returned in the callback
+** BTM_WRONG_MODE- connection not up.
+** BTM_BUSY - security procedures are currently active
+** BTM_MODE_UNSUPPORTED - if security manager not linked in.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport,
+ tBTM_SEC_CBACK *p_callback, void *p_ref_data);
+
+/*******************************************************************************
+**
+** Function BTM_ConfirmReqReply
+**
+** Description This function is called to confirm the numeric value for
+** Simple Pairing in response to BTM_SP_CFM_REQ_EVT
+**
+** Parameters: res - result of the operation BTM_SUCCESS if success
+** bd_addr - Address of the peer device
+**
+*******************************************************************************/
+//extern
+void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTM_PasskeyReqReply
+**
+** Description This function is called to provide the passkey for
+** Simple Pairing in response to BTM_SP_KEY_REQ_EVT
+**
+** Parameters: res - result of the operation BTM_SUCCESS if success
+** bd_addr - Address of the peer device
+** passkey - numeric value in the range of 0 - 999999(0xF423F).
+**
+*******************************************************************************/
+//extern
+void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey);
+
+/*******************************************************************************
+**
+** Function BTM_SendKeypressNotif
+**
+** Description This function is used during the passkey entry model
+** by a device with KeyboardOnly IO capabilities
+** (very likely to be a HID Device).
+** It is called by a HID Device to inform the remote device when
+** a key has been entered or erased.
+**
+** Parameters: bd_addr - Address of the peer device
+** type - notification type
+**
+*******************************************************************************/
+//extern
+void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type);
+
+/*******************************************************************************
+**
+** Function BTM_IoCapRsp
+**
+** Description This function is called in response to BTM_SP_IO_REQ_EVT
+** When the event data io_req.oob_data is set to BTM_OOB_UNKNOWN
+** by the tBTM_SP_CALLBACK implementation, this function is
+** called to provide the actual response
+**
+** Parameters: bd_addr - Address of the peer device
+** io_cap - The IO capability of local device.
+** oob - BTM_OOB_NONE or BTM_OOB_PRESENT.
+** auth_req- MITM protection required or not.
+**
+*******************************************************************************/
+//extern
+void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap,
+ tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req);
+
+/*******************************************************************************
+**
+** Function BTM_ReadLocalOobData
+**
+** Description This function is called to read the local OOB data from
+** LM
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadLocalOobData(void);
+
+/*******************************************************************************
+**
+** Function BTM_RemoteOobDataReply
+**
+** Description This function is called to provide the remote OOB data for
+** Simple Pairing in response to BTM_SP_RMT_OOB_EVT
+**
+** Parameters: bd_addr - Address of the peer device
+** c - simple pairing Hash C.
+** r - simple pairing Randomizer C.
+**
+*******************************************************************************/
+//extern
+void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr,
+ BT_OCTET16 c, BT_OCTET16 r);
+
+/*******************************************************************************
+**
+** Function BTM_BuildOobData
+**
+** Description This function is called to build the OOB data payload to
+** be sent over OOB (non-Bluetooth) link
+**
+** Parameters: p_data - the location for OOB data
+** max_len - p_data size.
+** c - simple pairing Hash C.
+** r - simple pairing Randomizer C.
+** name_len- 0, local device name would not be included.
+** otherwise, the local device name is included for
+** up to this specified length
+**
+** Returns Number of bytes in p_data.
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c,
+ BT_OCTET16 r, UINT8 name_len);
+
+/*******************************************************************************
+**
+** Function BTM_BothEndsSupportSecureConnections
+**
+** Description This function is called to check if both the local device and the peer device
+** specified by bd_addr support BR/EDR Secure Connections.
+**
+** Parameters: bd_addr - address of the peer
+**
+** Returns TRUE if BR/EDR Secure Connections are supported by both local
+** and the remote device.
+** else FALSE.
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_BothEndsSupportSecureConnections(BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTM_PeerSupportsSecureConnections
+**
+** Description This function is called to check if the peer supports
+** BR/EDR Secure Connections.
+**
+** Parameters: bd_addr - address of the peer
+**
+** Returns TRUE if BR/EDR Secure Connections are supported by the peer,
+** else FALSE.
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_PeerSupportsSecureConnections(BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTM_ReadOobData
+**
+** Description This function is called to parse the OOB data payload
+** received over OOB (non-Bluetooth) link
+**
+** Parameters: p_data - the location for OOB data
+** eir_tag - The associated EIR tag to read the data.
+** *p_len(output) - the length of the data with the given tag.
+**
+** Returns the beginning of the data with the given tag.
+** NULL, if the tag is not found.
+**
+*******************************************************************************/
+//extern
+UINT8 *BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len);
+
+/*******************************************************************************
+**
+** Function BTM_SecReadDevName
+**
+** Description Looks for the device name in the security database for the
+** specified BD address.
+**
+** Returns Pointer to the name or NULL
+**
+*******************************************************************************/
+//extern
+char *BTM_SecReadDevName (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTM_SecClearSecurityFlags
+**
+** Description Reset the security flags (mark as not-paired) for a given
+** remove device.
+**
+*******************************************************************************/
+extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr);
+
+
+
+/*****************************************************************************
+** POWER MANAGEMENT FUNCTIONS
+*****************************************************************************/
+/*******************************************************************************
+**
+** Function BTM_PmRegister
+**
+** Description register or deregister with power manager
+**
+** Returns BTM_SUCCESS if successful,
+** BTM_NO_RESOURCES if no room to hold registration
+** BTM_ILLEGAL_VALUE
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_PmRegister (UINT8 mask, UINT8 *p_pm_id,
+ tBTM_PM_STATUS_CBACK *p_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetPowerMode
+**
+** Description store the mode in control block or
+** alter ACL connection behavior.
+**
+** Returns BTM_SUCCESS if successful,
+** BTM_UNKNOWN_ADDR if bd addr is not active or bad
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda,
+ tBTM_PM_PWR_MD *p_mode);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadPowerMode
+**
+** Description This returns the current mode for a specific
+** ACL connection.
+**
+** Input Param remote_bda - device address of desired ACL connection
+**
+** Output Param p_mode - address where the current mode is copied into.
+** BTM_ACL_MODE_NORMAL
+** BTM_ACL_MODE_HOLD
+** BTM_ACL_MODE_SNIFF
+** BTM_ACL_MODE_PARK
+** (valid only if return code is BTM_SUCCESS)
+**
+** Returns BTM_SUCCESS if successful,
+** BTM_UNKNOWN_ADDR if bd addr is not active or bad
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ReadPowerMode (BD_ADDR remote_bda,
+ tBTM_PM_MODE *p_mode);
+
+/*******************************************************************************
+**
+** Function BTM_SetSsrParams
+**
+** Description This sends the given SSR parameters for the given ACL
+** connection if it is in ACTIVE mode.
+**
+** Input Param remote_bda - device address of desired ACL connection
+** max_lat - maximum latency (in 0.625ms)(0-0xFFFE)
+** min_rmt_to - minimum remote timeout
+** min_loc_to - minimum local timeout
+**
+**
+** Returns BTM_SUCCESS if the HCI command is issued successful,
+** BTM_UNKNOWN_ADDR if bd addr is not active or bad
+** BTM_CMD_STORED if the command is stored
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat,
+ UINT16 min_rmt_to, UINT16 min_loc_to);
+
+/*******************************************************************************
+**
+** Function BTM_GetHCIConnHandle
+**
+** Description This function is called to get the handle for an ACL connection
+** to a specific remote BD Address.
+**
+** Returns the handle of the connection, or 0xFFFF if none.
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport);
+
+/*******************************************************************************
+**
+** Function BTM_DeleteStoredLinkKey
+**
+** Description This function is called to delete link key for the specified
+** device addresses from the NVRAM storage attached to the Bluetooth
+** controller.
+**
+** Parameters: bd_addr - Addresses of the devices
+** p_cb - Call back function to be called to return
+** the results
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_WriteEIR
+**
+** Description This function is called to write EIR data to controller.
+**
+** Parameters p_buff - allocated HCI command buffer including extended
+** inquriry response
+** fec_required - FEC is required or not
+**
+** Returns BTM_SUCCESS - if successful
+** BTM_MODE_UNSUPPORTED - if local device cannot support it
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff, BOOLEAN fec_required);
+
+/*******************************************************************************
+**
+** Function BTM_CheckEirData
+**
+** Description This function is called to get EIR data from significant part.
+**
+** Parameters p_eir - pointer of EIR significant part
+** type - finding EIR data type
+** p_length - return the length of EIR data
+**
+** Returns pointer of EIR data
+**
+*******************************************************************************/
+//extern
+UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length );
+
+/*******************************************************************************
+**
+** Function BTM_HasEirService
+**
+** Description This function is called to know if UUID in bit map of UUID.
+**
+** Parameters p_eir_uuid - bit map of UUID list
+** uuid16 - UUID 16-bit
+**
+** Returns TRUE - if found
+** FALSE - if not found
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
+
+/*******************************************************************************
+**
+** Function BTM_HasInquiryEirService
+**
+** Description This function is called to know if UUID in bit map of UUID list.
+**
+** Parameters p_results - inquiry results
+** uuid16 - UUID 16-bit
+**
+** Returns BTM_EIR_FOUND - if found
+** BTM_EIR_NOT_FOUND - if not found and it is complete list
+** BTM_EIR_UNKNOWN - if not found and it is not complete list
+**
+*******************************************************************************/
+//extern
+tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results,
+ UINT16 uuid16 );
+
+/*******************************************************************************
+**
+** Function BTM_HasCustomEirService
+**
+** Description This function is called to know if UUID is already in custom
+** UUID list.
+**
+** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
+** uuid - UUID struct
+**
+** Returns TRUE - if found
+** FALSE - if not found
+**
+*******************************************************************************/
+BOOLEAN BTM_HasCustomEirService( tBT_UUID *custom_uuid, tBT_UUID uuid );
+
+/*******************************************************************************
+**
+** Function BTM_AddEirService
+**
+** Description This function is called to add a service in bit map of UUID list.
+**
+** Parameters p_eir_uuid - bit mask of UUID list for EIR
+** uuid16 - UUID 16-bit
+**
+** Returns None
+**
+*******************************************************************************/
+//extern
+void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
+
+/*******************************************************************************
+**
+** Function BTM_AddCustomEirService
+**
+** Description This function is called to add a custom UUID.
+**
+** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
+** uuid - UUID struct
+**
+** Returns None
+**
+*******************************************************************************/
+void BTM_AddCustomEirService(tBT_UUID *custom_uuid, tBT_UUID uuid);
+
+/*******************************************************************************
+**
+** Function BTM_RemoveEirService
+**
+** Description This function is called to remove a service in bit map of UUID list.
+**
+** Parameters p_eir_uuid - bit mask of UUID list for EIR
+** uuid16 - UUID 16-bit
+**
+** Returns None
+**
+*******************************************************************************/
+//extern
+void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
+
+/*******************************************************************************
+**
+** Function BTM_RemoveCustomEirService
+**
+** Description This function is called to remove a a custom UUID.
+**
+** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
+ uuid - UUID struct
+**
+** Returns None
+**
+*******************************************************************************/
+void BTM_RemoveCustomEirService(tBT_UUID *custom_uuid, tBT_UUID uuid);
+
+/*******************************************************************************
+**
+** Function BTM_GetEirSupportedServices
+**
+** Description This function is called to get UUID list from bit map of UUID list.
+**
+** Parameters p_eir_uuid - bit mask of UUID list for EIR
+** p - reference of current pointer of EIR
+** max_num_uuid16 - max number of UUID can be written in EIR
+** num_uuid16 - number of UUID have been written in EIR
+**
+** Returns BTM_EIR_MORE_16BITS_UUID_TYPE, if it has more than max
+** BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise
+**
+*******************************************************************************/
+//extern
+UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid, UINT8 **p,
+ UINT8 max_num_uuid16, UINT8 *p_num_uuid16);
+
+/*******************************************************************************
+**
+** Function BTM_GetEirUuidList
+**
+** Description This function parses EIR and returns UUID list.
+**
+** Parameters p_eir - EIR
+** uuid_size - LEN_UUID_16, LEN_UUID_32, LEN_UUID_128
+** p_num_uuid - return number of UUID in found list
+** p_uuid_list - return UUID 16-bit list
+** max_num_uuid - maximum number of UUID to be returned
+**
+** Returns 0 - if not found
+** BTM_EIR_COMPLETE_16BITS_UUID_TYPE
+** BTM_EIR_MORE_16BITS_UUID_TYPE
+** BTM_EIR_COMPLETE_32BITS_UUID_TYPE
+** BTM_EIR_MORE_32BITS_UUID_TYPE
+** BTM_EIR_COMPLETE_128BITS_UUID_TYPE
+** BTM_EIR_MORE_128BITS_UUID_TYPE
+**
+*******************************************************************************/
+//extern
+UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid,
+ UINT8 *p_uuid_list, UINT8 max_num_uuid);
+
+/*****************************************************************************
+** SCO OVER HCI
+*****************************************************************************/
+/*******************************************************************************
+**
+** Function BTM_ConfigScoPath
+**
+** Description This function enable/disable SCO over HCI and registers SCO
+** data callback if SCO over HCI is enabled.
+**
+** Parameter path: SCO or HCI
+** p_sco_data_cb: callback function or SCO data if path is set
+** to transport.
+** p_pcm_param: pointer to the PCM interface parameter. If a NULL
+** pointer is used, PCM parameter maintained in
+** the control block will be used; otherwise update
+** control block value.
+** err_data_rpt: Lisbon feature to enable the erronous data report
+** or not.
+**
+** Returns BTM_SUCCESS if the successful.
+** BTM_NO_RESOURCES: no rsource to start the command.
+** BTM_ILLEGAL_VALUE: invalid callback function pointer.
+** BTM_CMD_STARTED :Command sent. Waiting for command cmpl event.
+**
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_ConfigScoPath (tBTM_SCO_ROUTE_TYPE path,
+ tBTM_SCO_DATA_CB *p_sco_data_cb,
+ tBTM_SCO_PCM_PARAM *p_pcm_param,
+ BOOLEAN err_data_rpt);
+
+/*******************************************************************************
+**
+** Function BTM_WriteScoData
+**
+** Description This function write SCO data to a specified instance. The data
+** to be written p_buf needs to carry an offset of
+** HCI_SCO_PREAMBLE_SIZE bytes, and the data length can not
+** exceed BTM_SCO_DATA_SIZE_MAX bytes, whose default value is set
+** to 60 and is configurable. Data longer than the maximum bytes
+** will be truncated.
+**
+** Returns BTM_SUCCESS: data write is successful
+** BTM_ILLEGAL_VALUE: SCO data contains illegal offset value.
+** BTM_SCO_BAD_LENGTH: SCO data length exceeds the max SCO packet
+** size.
+** BTM_NO_RESOURCES: no resources.
+** BTM_UNKNOWN_ADDR: unknown SCO connection handle, or SCO is not
+** routed via HCI.
+**
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf);
+
+/*******************************************************************************
+**
+** Function BTM_SetARCMode
+**
+** Description Send Audio Routing Control command.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_SetARCMode (UINT8 iface, UINT8 arc_mode, tBTM_VSC_CMPL_CB *p_arc_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_PCM2Setup_Write
+**
+** Description Send PCM2_Setup write command.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p_arc_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_PM_ReadControllerState
+**
+** Description This function is called to obtain the controller state
+**
+** Returns Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and BTM_CONTRL_IDLE)
+**
+*******************************************************************************/
+//extern
+tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
+
+/*******************************************************************************
+**
+** Function BTM_SetAfhChannels
+**
+** Description This function is called to set AFH channels
+**
+** Returns status of the operation
+**
+*******************************************************************************/
+tBTM_STATUS BTM_SetAfhChannels (AFH_CHANNELS channels, tBTM_CMPL_CB *p_afh_channels_cmpl_cback);
+
+/*******************************************************************************
+**
+** Function BTM_BleSetChannels
+**
+** Description This function is called to set BLE channels
+**
+** Returns status of the operation
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels, tBTM_CMPL_CB *p_ble_channels_cmpl_cback);
+
+/*******************************************************************************
+**
+** Function BTM_PktStatNumsGet
+**
+** Description This function is called to get the number of packet status struct
+**
+** Returns void
+**
+*******************************************************************************/
+void BTM_PktStatNumsGet(UINT16 sync_conn_handle, tBTM_SCO_PKT_STAT_NUMS *pkt_nums);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTM_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/lib/bt/host/bluedroid/stack/include/stack/btm_ble_api.h
new file mode 100644
index 00000000..a3085361
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/btm_ble_api.h
@@ -0,0 +1,2724 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the Bluetooth Manager (BTM) API function external
+ * definitions.
+ *
+ ******************************************************************************/
+#ifndef BTM_BLE_API_H
+#define BTM_BLE_API_H
+
+#include "common/bt_defs.h"
+#include "stack/btm_api.h"
+#include "common/bt_common_types.h"
+
+#define CHANNEL_MAP_LEN 5
+typedef UINT8 tBTM_BLE_CHNL_MAP[CHANNEL_MAP_LEN];
+
+/* 0x00-0x04 only used for set advertising parameter command */
+#define BTM_BLE_CONNECT_EVT 0x00 /* 0x00-0x04 only used for set advertising
+ parameter command */
+#define BTM_BLE_CONNECT_DIR_EVT 0x01 /* Connectable directed advertising */
+#define BTM_BLE_DISCOVER_EVT 0x02 /* Scannable undirected advertising */
+#define BTM_BLE_NON_CONNECT_EVT 0x03 /* Non connectable undirected advertising */
+#define BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 0x04 /* Connectable low duty
+ cycle directed advertising */
+/* 0x00 - 0x05 can be received on adv event type */
+#define BTM_BLE_SCAN_RSP_EVT 0x04
+#define BTM_BLE_SCAN_REQ_EVT 0x05
+#define BTM_BLE_UNKNOWN_EVT 0xff
+
+#define BTM_BLE_UNKNOWN_EVT 0xff
+
+typedef UINT8 tBTM_BLE_EVT;
+typedef UINT8 tBTM_BLE_CONN_MODE;
+
+typedef UINT32 tBTM_BLE_REF_VALUE;
+
+#define BTM_BLE_SCAN_MODE_PASS 0
+#define BTM_BLE_SCAN_MODE_ACTI 1
+#define BTM_BLE_SCAN_MODE_NONE 0xff
+typedef UINT8 tBLE_SCAN_MODE;
+
+#define BTM_BLE_BATCH_SCAN_MODE_DISABLE 0
+#define BTM_BLE_BATCH_SCAN_MODE_PASS 1
+#define BTM_BLE_BATCH_SCAN_MODE_ACTI 2
+#define BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI 3
+
+typedef UINT8 tBTM_BLE_BATCH_SCAN_MODE;
+
+/* advertising channel map */
+#define BTM_BLE_ADV_CHNL_37 (0x01 << 0)
+#define BTM_BLE_ADV_CHNL_38 (0x01 << 1)
+#define BTM_BLE_ADV_CHNL_39 (0x01 << 2)
+typedef UINT8 tBTM_BLE_ADV_CHNL_MAP;
+
+/*d efault advertising channel map */
+#ifndef BTM_BLE_DEFAULT_ADV_CHNL_MAP
+#define BTM_BLE_DEFAULT_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37| BTM_BLE_ADV_CHNL_38| BTM_BLE_ADV_CHNL_39)
+#endif
+
+/* advertising filter policy */
+#define AP_SCAN_CONN_ALL 0x00 /* default */
+#define AP_SCAN_WL_CONN_ALL 0x01
+#define AP_SCAN_ALL_CONN_WL 0x02
+#define AP_SCAN_CONN_WL 0x03
+#define AP_SCAN_CONN_POLICY_MAX 0x04
+typedef UINT8 tBTM_BLE_AFP;
+
+/* default advertising filter policy */
+#ifndef BTM_BLE_DEFAULT_AFP
+#define BTM_BLE_DEFAULT_AFP AP_SCAN_CONN_ALL
+#endif
+
+/* scanning filter policy */
+#define SP_ADV_ALL 0x00 /* 0: accept adv packet from all, directed adv pkt not directed */
+/* to local device is ignored */
+#define SP_ADV_WL 0x01 /* 1: accept adv packet from device in white list, directed adv */
+/* packet not directed to local device is ignored */
+#define SP_ADV_ALL_RPA_DIR_ADV 0x02 /* 2: accept adv packet from all, directed adv pkt */
+/* not directed to me is ignored except direct adv with RPA */
+#define SP_ADV_WL_RPA_DIR_ADV 0x03 /* 3: accept adv packet from device in white list, directed */
+/* adv pkt not directed to me is ignored except direct adv */
+/* with RPA */
+typedef UINT8 tBTM_BLE_SFP;
+
+#ifndef BTM_BLE_DEFAULT_SFP
+#define BTM_BLE_DEFAULT_SFP SP_ADV_ALL
+#endif
+
+/* adv parameter boundary values */
+#if BLE_HIGH_DUTY_ADV_INTERVAL
+#define BTM_BLE_ADV_INT_MIN 0x0008 /* 5ms */
+#else
+#define BTM_BLE_ADV_INT_MIN 0x0020 /* 20ms */
+#endif
+#define BTM_BLE_ADV_INT_MAX 0x4000 /* 10240ms */
+
+/* Full scan boundary values */
+#define BTM_BLE_ADV_SCAN_FULL_MIN 0x00
+#define BTM_BLE_ADV_SCAN_FULL_MAX 0x64
+
+/* Partial scan boundary values */
+#define BTM_BLE_ADV_SCAN_TRUNC_MIN BTM_BLE_ADV_SCAN_FULL_MIN
+#define BTM_BLE_ADV_SCAN_TRUNC_MAX BTM_BLE_ADV_SCAN_FULL_MAX
+
+/* Threshold values */
+#define BTM_BLE_ADV_SCAN_THR_MIN BTM_BLE_ADV_SCAN_FULL_MIN
+#define BTM_BLE_ADV_SCAN_THR_MAX BTM_BLE_ADV_SCAN_FULL_MAX
+
+/* connection parameter boundary values */
+#define BTM_BLE_SCAN_INT_MIN 0x0004
+#define BTM_BLE_SCAN_INT_MAX 0x4000
+#define BTM_BLE_SCAN_WIN_MIN 0x0004
+#define BTM_BLE_SCAN_WIN_MAX 0x4000
+#define BTM_BLE_EXT_SCAN_INT_MAX 0x00FFFFFF
+#define BTM_BLE_EXT_SCAN_WIN_MAX 0xFFFF
+#define BTM_BLE_CONN_INT_MIN 0x0006
+#define BTM_BLE_CONN_INT_MAX 0x0C80
+#define BTM_BLE_CONN_LATENCY_MAX 499
+#define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A
+#define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80
+#define BTM_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
+#define BTM_BLE_SCAN_PARAM_UNDEF 0xffffffff
+
+/* default connection parameters if not configured, use GAP recommend value for auto/selective connection */
+/* default scan interval */
+#ifndef BTM_BLE_SCAN_FAST_INT
+#define BTM_BLE_SCAN_FAST_INT 96 /* 30 ~ 60 ms (use 60) = 96 *0.625 */
+#endif
+/* default scan window for background connection, applicable for auto connection or selective conenction */
+#ifndef BTM_BLE_SCAN_FAST_WIN
+#define BTM_BLE_SCAN_FAST_WIN 48 /* 30 ms = 48 *0.625 */
+#endif
+
+/* default scan paramter used in reduced power cycle (background scanning) */
+#ifndef BTM_BLE_SCAN_SLOW_INT_1
+#define BTM_BLE_SCAN_SLOW_INT_1 2048 /* 1.28 s = 2048 *0.625 */
+#endif
+#ifndef BTM_BLE_SCAN_SLOW_WIN_1
+#define BTM_BLE_SCAN_SLOW_WIN_1 48 /* 30 ms = 48 *0.625 */
+#endif
+
+/* default scan paramter used in reduced power cycle (background scanning) */
+#ifndef BTM_BLE_SCAN_SLOW_INT_2
+#define BTM_BLE_SCAN_SLOW_INT_2 4096 /* 2.56 s = 4096 *0.625 */
+#endif
+#ifndef BTM_BLE_SCAN_SLOW_WIN_2
+#define BTM_BLE_SCAN_SLOW_WIN_2 36 /* 22.5 ms = 36 *0.625 */
+#endif
+
+/* default connection interval min */
+#ifndef BTM_BLE_CONN_INT_MIN_DEF
+#define BTM_BLE_CONN_INT_MIN_DEF 10 /* recommended min: 12.5 ms = 10 * 1.25 */
+#endif
+
+/* default connection interval max */
+#ifndef BTM_BLE_CONN_INT_MAX_DEF
+#if CONFIG_IDF_TARGET_ESP32
+#define BTM_BLE_CONN_INT_MAX_DEF 12 /* recommended max: 15 ms = 12 * 1.25 */
+#else
+#define BTM_BLE_CONN_INT_MAX_DEF (((MAX_ACL_CONNECTIONS + 1) * 4) > 12 ? ((MAX_ACL_CONNECTIONS + 1) * 4) : 12) /* recommended max: BTM_BLE_CONN_INT_MAX_DEF * 1.25 ms*/
+#endif
+#endif
+
+/* default slave latency */
+#ifndef BTM_BLE_CONN_SLAVE_LATENCY_DEF
+#define BTM_BLE_CONN_SLAVE_LATENCY_DEF 0 /* 0 */
+#endif
+
+/* default supervision timeout */
+#ifndef BTM_BLE_CONN_TIMEOUT_DEF
+#define BTM_BLE_CONN_TIMEOUT_DEF 600
+#endif
+
+/* minimum acceptable connection interval */
+#ifndef BTM_BLE_CONN_INT_MIN_LIMIT
+#define BTM_BLE_CONN_INT_MIN_LIMIT 0x0009
+#endif
+
+#define BTM_BLE_DIR_CONN_FALLBACK_UNDIR 1
+#define BTM_BLE_DIR_CONN_FALLBACK_NO_ADV 2
+
+#ifndef BTM_BLE_DIR_CONN_FALLBACK
+#define BTM_BLE_DIR_CONN_FALLBACK BTM_BLE_DIR_CONN_FALLBACK_UNDIR
+#endif
+
+#define BTM_CMAC_TLEN_SIZE 8 /* 64 bits */
+#define BTM_BLE_AUTH_SIGN_LEN 12 /* BLE data signature length 8 Bytes + 4 bytes counter*/
+typedef UINT8 BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN]; /* Device address */
+
+#ifndef BTM_BLE_HOST_SUPPORT
+#define BTM_BLE_HOST_SUPPORT 0x01
+#endif
+
+#ifndef BTM_BLE_SIMULTANEOUS_HOST
+#define BTM_BLE_SIMULTANEOUS_HOST 0x01
+#endif
+
+/* Appearance Values Reported with BTM_BLE_AD_TYPE_APPEARANCE */
+#define BTM_BLE_APPEARANCE_UNKNOWN 0x0000
+#define BTM_BLE_APPEARANCE_GENERIC_PHONE 0x0040
+#define BTM_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080
+#define BTM_BLE_APPEARANCE_GENERIC_WATCH 0x00C0
+#define BTM_BLE_APPEARANCE_SPORTS_WATCH 0x00C1
+#define BTM_BLE_APPEARANCE_GENERIC_CLOCK 0x0100
+#define BTM_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140
+#define BTM_BLE_APPEARANCE_GENERIC_REMOTE 0x0180
+#define BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0
+#define BTM_BLE_APPEARANCE_GENERIC_TAG 0x0200
+#define BTM_BLE_APPEARANCE_GENERIC_KEYRING 0x0240
+#define BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280
+#define BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0
+#define BTM_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300
+#define BTM_BLE_APPEARANCE_THERMOMETER_EAR 0x0301
+#define BTM_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340
+#define BTM_BLE_APPEARANCE_HEART_RATE_BELT 0x0341
+#define BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380
+#define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381
+#define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382
+#define BTM_BLE_APPEARANCE_GENERIC_HID 0x03C0
+#define BTM_BLE_APPEARANCE_HID_KEYBOARD 0x03C1
+#define BTM_BLE_APPEARANCE_HID_MOUSE 0x03C2
+#define BTM_BLE_APPEARANCE_HID_JOYSTICK 0x03C3
+#define BTM_BLE_APPEARANCE_HID_GAMEPAD 0x03C4
+#define BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5
+#define BTM_BLE_APPEARANCE_HID_CARD_READER 0x03C6
+#define BTM_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7
+#define BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8
+#define BTM_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400
+#define BTM_BLE_APPEARANCE_GENERIC_WALKING 0x0440
+#define BTM_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441
+#define BTM_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442
+#define BTM_BLE_APPEARANCE_WALKING_ON_HIP 0x0443
+#define BTM_BLE_APPEARANCE_GENERIC_CYCLING 0x0480
+#define BTM_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481
+#define BTM_BLE_APPEARANCE_CYCLING_SPEED 0x0482
+#define BTM_BLE_APPEARANCE_CYCLING_CADENCE 0x0483
+#define BTM_BLE_APPEARANCE_CYCLING_POWER 0x0484
+#define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485
+#define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40
+#define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41
+#define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42
+#define BTM_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80
+#define BTM_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE 0x0CC0
+#define BTM_BLE_APPEARANCE_POWERED_WHEELCHAIR 0x0CC1
+#define BTM_BLE_APPEARANCE_MOBILITY_SCOOTER 0x0CC2
+#define BTM_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR 0x0D00
+#define BTM_BLE_APPEARANCE_GENERIC_INSULIN_PUMP 0x0D40
+#define BTM_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP 0x0D41
+#define BTM_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP 0x0D44
+#define BTM_BLE_APPEARANCE_INSULIN_PEN 0x0D48
+#define BTM_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY 0x0D80
+#define BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443
+#define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444
+
+
+/* Structure returned with Rand/Encrypt complete callback */
+typedef struct {
+ UINT8 status;
+ UINT8 param_len;
+ UINT16 opcode;
+ UINT8 param_buf[BT_OCTET16_LEN];
+} tBTM_RAND_ENC;
+
+/* General callback function for notifying an application that a synchronous
+** BTM function is complete. The pointer contains the address of any returned data.
+*/
+typedef void (tBTM_RAND_ENC_CB) (tBTM_RAND_ENC *p1);
+
+#define BTM_BLE_FILTER_TARGET_SCANNER 0x01
+#define BTM_BLE_FILTER_TARGET_ADVR 0x00
+
+#define BTM_BLE_POLICY_BLACK_ALL 0x00 /* relevant to both */
+#define BTM_BLE_POLICY_ALLOW_SCAN 0x01 /* relevant to advertiser */
+#define BTM_BLE_POLICY_ALLOW_CONN 0x02 /* relevant to advertiser */
+#define BTM_BLE_POLICY_WHITE_ALL 0x03 /* relevant to both */
+
+/* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */
+#define BTM_BLE_LIMIT_DISC_FLAG (0x01 << 0)
+#define BTM_BLE_GEN_DISC_FLAG (0x01 << 1)
+#define BTM_BLE_BREDR_NOT_SPT (0x01 << 2)
+/* 4.1 spec adv flag for simultaneous BR/EDR+LE connection support */
+#define BTM_BLE_DMT_CONTROLLER_SPT (0x01 << 3)
+#define BTM_BLE_DMT_HOST_SPT (0x01 << 4)
+#define BTM_BLE_NON_LIMIT_DISC_FLAG (0x00 ) /* lowest bit unset */
+#define BTM_BLE_ADV_FLAG_MASK (BTM_BLE_LIMIT_DISC_FLAG | BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG)
+#define BTM_BLE_LIMIT_DISC_MASK (BTM_BLE_LIMIT_DISC_FLAG )
+
+#define BTM_BLE_AD_BIT_DEV_NAME (0x00000001 << 0)
+#define BTM_BLE_AD_BIT_FLAGS (0x00000001 << 1)
+#define BTM_BLE_AD_BIT_MANU (0x00000001 << 2)
+#define BTM_BLE_AD_BIT_TX_PWR (0x00000001 << 3)
+#define BTM_BLE_AD_BIT_INT_RANGE (0x00000001 << 5)
+#define BTM_BLE_AD_BIT_SERVICE (0x00000001 << 6)
+#define BTM_BLE_AD_BIT_SERVICE_SOL (0x00000001 << 7)
+#define BTM_BLE_AD_BIT_SERVICE_DATA (0x00000001 << 8)
+#define BTM_BLE_AD_BIT_SIGN_DATA (0x00000001 << 9)
+#define BTM_BLE_AD_BIT_SERVICE_128SOL (0x00000001 << 10)
+#define BTM_BLE_AD_BIT_APPEARANCE (0x00000001 << 11)
+#define BTM_BLE_AD_BIT_PUBLIC_ADDR (0x00000001 << 12)
+#define BTM_BLE_AD_BIT_RANDOM_ADDR (0x00000001 << 13)
+#define BTM_BLE_AD_BIT_SERVICE_32 (0x00000001 << 4)
+#define BTM_BLE_AD_BIT_SERVICE_32SOL (0x00000001 << 14)
+#define BTM_BLE_AD_BIT_PROPRIETARY (0x00000001 << 15)
+#define BTM_BLE_AD_BIT_SERVICE_128 (0x00000001 << 16) /*128-bit Service UUIDs*/
+
+typedef UINT32 tBTM_BLE_AD_MASK;
+
+/* relate to ESP_BLE_AD_TYPE_xxx in esp_gap_ble_api.h */
+#define BTM_BLE_AD_TYPE_FLAG HCI_EIR_FLAGS_TYPE /* 0x01 */
+#define BTM_BLE_AD_TYPE_16SRV_PART HCI_EIR_MORE_16BITS_UUID_TYPE /* 0x02 */
+#define BTM_BLE_AD_TYPE_16SRV_CMPL HCI_EIR_COMPLETE_16BITS_UUID_TYPE /* 0x03 */
+#define BTM_BLE_AD_TYPE_32SRV_PART HCI_EIR_MORE_32BITS_UUID_TYPE /* 0x04 */
+#define BTM_BLE_AD_TYPE_32SRV_CMPL HCI_EIR_COMPLETE_32BITS_UUID_TYPE /* 0x05 */
+#define BTM_BLE_AD_TYPE_128SRV_PART HCI_EIR_MORE_128BITS_UUID_TYPE /* 0x06 */
+#define BTM_BLE_AD_TYPE_128SRV_CMPL HCI_EIR_COMPLETE_128BITS_UUID_TYPE /* 0x07 */
+#define BTM_BLE_AD_TYPE_NAME_SHORT HCI_EIR_SHORTENED_LOCAL_NAME_TYPE /* 0x08 */
+#define BTM_BLE_AD_TYPE_NAME_CMPL HCI_EIR_COMPLETE_LOCAL_NAME_TYPE /* 0x09 */
+#define BTM_BLE_AD_TYPE_TX_PWR HCI_EIR_TX_POWER_LEVEL_TYPE /* 0x0A */
+#define BTM_BLE_AD_TYPE_DEV_CLASS 0x0D
+#define BTM_BLE_AD_TYPE_SM_TK 0x10
+#define BTM_BLE_AD_TYPE_SM_OOB_FLAG 0x11
+#define BTM_BLE_AD_TYPE_INT_RANGE 0x12
+#define BTM_BLE_AD_TYPE_SOL_SRV_UUID 0x14
+#define BTM_BLE_AD_TYPE_128SOL_SRV_UUID 0x15
+#define BTM_BLE_AD_TYPE_SERVICE_DATA 0x16
+#define BTM_BLE_AD_TYPE_PUBLIC_TARGET 0x17
+#define BTM_BLE_AD_TYPE_RANDOM_TARGET 0x18
+#define BTM_BLE_AD_TYPE_APPEARANCE 0x19
+#define BTM_BLE_AD_TYPE_ADV_INT 0x1a
+#define BTM_BLE_AD_TYPE_LE_DEV_ADDR 0x1b
+#define BTM_BLE_AD_TYPE_LE_ROLE 0x1c
+#define BTM_BLE_AD_TYPE_SPAIR_C256 0x1d
+#define BTM_BLE_AD_TYPE_SPAIR_R256 0x1e
+#define BTM_BLE_AD_TYPE_32SOL_SRV_UUID 0x1f
+#define BTM_BLE_AD_TYPE_32SERVICE_DATA 0x20
+#define BTM_BLE_AD_TYPE_128SERVICE_DATA 0x21
+#define BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM 0x22
+#define BTM_BLE_AD_TYPE_LE_SECURE_RANDOM 0x23
+#define BTM_BLE_AD_TYPE_URI 0x24
+#define BTM_BLE_AD_TYPE_INDOOR_POSITION 0x25
+#define BTM_BLE_AD_TYPE_TRANS_DISC_DATA 0x26
+#define BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE 0x27
+#define BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE 0x28
+
+#define BTM_BLE_AD_TYPE_MANU HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xff */
+typedef UINT8 tBTM_BLE_AD_TYPE;
+
+#define BTM_BLE_LONG_ADV_MAX_LEN 249
+
+/* Security settings used with L2CAP LE COC */
+#define BTM_SEC_LE_LINK_ENCRYPTED 0x01
+#define BTM_SEC_LE_LINK_PAIRED_WITHOUT_MITM 0x02
+#define BTM_SEC_LE_LINK_PAIRED_WITH_MITM 0x04
+
+/* Min/max Preferred number of payload octets that the local Controller
+ should include in a single Link Layer Data Channel PDU. */
+#define BTM_BLE_DATA_SIZE_MAX 0x00fb
+#define BTM_BLE_DATA_SIZE_MIN 0x001b
+
+/* Preferred maximum number of microseconds that the local Controller
+ should use to transmit a single Link Layer Data Channel PDU. */
+#define BTM_BLE_DATA_TX_TIME_MIN 0x0148
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#define BTM_BLE_DATA_TX_TIME_MAX 0x04290 // define by spec v5.0
+#else
+#define BTM_BLE_DATA_TX_TIME_MAX 0x0848
+#endif
+
+/* adv tx power level */
+#define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */
+#define BTM_BLE_ADV_TX_POWER_MAX BTM_TX_POWER_LEVEL_MAX /* maximum tx power */
+typedef UINT8 tBTM_BLE_ADV_TX_POWER;
+
+/* adv tx power in dBm */
+typedef struct {
+ UINT8 adv_inst_max; /* max adv instance supported in controller */
+ UINT8 rpa_offloading;
+ UINT16 tot_scan_results_strg;
+ UINT8 max_irk_list_sz;
+ UINT8 filter_support;
+ UINT8 max_filter;
+ UINT8 energy_support;
+ BOOLEAN values_read;
+ UINT16 version_supported;
+ UINT16 total_trackable_advertisers;
+ UINT8 extended_scan_support;
+ UINT8 debug_logging_supported;
+} tBTM_BLE_VSC_CB;
+
+/* slave preferred connection interval range */
+typedef struct {
+ UINT16 low;
+ UINT16 hi;
+
+} tBTM_BLE_INT_RANGE;
+
+/* Service tag supported in the device */
+typedef struct {
+ UINT8 num_service;
+ BOOLEAN list_cmpl;
+ UINT16 *p_uuid;
+} tBTM_BLE_SERVICE;
+
+/* 32 bits Service supported in the device */
+typedef struct {
+ UINT8 num_service;
+ BOOLEAN list_cmpl;
+ UINT32 *p_uuid;
+} tBTM_BLE_32SERVICE;
+
+/* 128 bits Service supported in the device */
+typedef struct {
+ BOOLEAN list_cmpl;
+ UINT8 uuid128[MAX_UUID_SIZE];
+} tBTM_BLE_128SERVICE;
+
+typedef struct {
+ UINT8 len;
+ UINT8 *p_val;
+} tBTM_BLE_MANU;
+
+
+typedef struct {
+ tBT_UUID service_uuid;
+ UINT8 len;
+ UINT8 *p_val;
+} tBTM_BLE_SERVICE_DATA;
+
+typedef struct {
+ UINT8 adv_type;
+ UINT8 len;
+ UINT8 *p_val; /* number of len byte */
+} tBTM_BLE_PROP_ELEM;
+
+typedef struct {
+ UINT8 num_elem;
+ tBTM_BLE_PROP_ELEM *p_elem;
+} tBTM_BLE_PROPRIETARY;
+
+typedef struct {
+ tBTM_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
+ tBTM_BLE_MANU *p_manu; /* manufacturer data */
+ tBTM_BLE_SERVICE *p_services; /* services */
+ tBTM_BLE_128SERVICE *p_services_128b; /* 128 bits service */
+ tBTM_BLE_32SERVICE *p_service_32b; /* 32 bits Service UUID */
+ tBTM_BLE_SERVICE *p_sol_services; /* 16 bits services Solicitation UUIDs */
+ tBTM_BLE_32SERVICE *p_sol_service_32b; /* List of 32 bit Service Solicitation UUIDs */
+ tBTM_BLE_128SERVICE *p_sol_service_128b; /* List of 128 bit Service Solicitation UUIDs */
+ tBTM_BLE_PROPRIETARY *p_proprietary;
+ tBTM_BLE_SERVICE_DATA *p_service_data; /* service data */
+ UINT16 appearance;
+ UINT8 flag;
+ UINT8 tx_power;
+} tBTM_BLE_ADV_DATA;
+
+#ifndef BTM_BLE_MULTI_ADV_MAX
+#define BTM_BLE_MULTI_ADV_MAX 16 /* controller returned adv_inst_max should be less
+ than this number */
+#endif
+
+#define BTM_BLE_MULTI_ADV_INVALID 0
+
+#define BTM_BLE_MULTI_ADV_ENB_EVT 1
+#define BTM_BLE_MULTI_ADV_DISABLE_EVT 2
+#define BTM_BLE_MULTI_ADV_PARAM_EVT 3
+#define BTM_BLE_MULTI_ADV_DATA_EVT 4
+typedef UINT8 tBTM_BLE_MULTI_ADV_EVT;
+
+#define BTM_BLE_MULTI_ADV_DEFAULT_STD 0
+
+typedef struct {
+ UINT16 adv_int_min;
+ UINT16 adv_int_max;
+ UINT8 adv_type;
+ tBTM_BLE_ADV_CHNL_MAP channel_map;
+ tBTM_BLE_AFP adv_filter_policy;
+ tBTM_BLE_ADV_TX_POWER tx_power;
+} tBTM_BLE_ADV_PARAMS;
+
+typedef struct {
+ UINT8 *p_sub_code; /* dynamic array to store sub code */
+ UINT8 *p_inst_id; /* dynamic array to store instance id */
+ UINT8 pending_idx;
+ UINT8 next_idx;
+} tBTM_BLE_MULTI_ADV_OPQ;
+
+typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, UINT8 inst_id,
+ void *p_ref, tBTM_STATUS status);
+
+typedef struct {
+ UINT8 inst_id;
+ BOOLEAN in_use;
+ UINT8 adv_evt;
+ BD_ADDR rpa;
+ TIMER_LIST_ENT raddr_timer_ent;
+ tBTM_BLE_MULTI_ADV_CBACK *p_cback;
+ void *p_ref;
+ UINT8 index;
+} tBTM_BLE_MULTI_ADV_INST;
+
+typedef struct {
+ UINT8 inst_index_queue[BTM_BLE_MULTI_ADV_MAX];
+ int front;
+ int rear;
+} tBTM_BLE_MULTI_ADV_INST_IDX_Q;
+
+typedef struct {
+ tBTM_BLE_MULTI_ADV_INST *p_adv_inst; /* dynamic array to store adv instance */
+ tBTM_BLE_MULTI_ADV_OPQ op_q;
+} tBTM_BLE_MULTI_ADV_CB;
+
+typedef UINT8 tGATT_IF;
+
+typedef void (tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value);
+typedef void (tBTM_BLE_SCAN_REP_CBACK)(tBTM_BLE_REF_VALUE ref_value, UINT8 report_format,
+ UINT8 num_records, UINT16 total_len,
+ UINT8 *p_rep_data, UINT8 status);
+typedef void (tBTM_BLE_SCAN_SETUP_CBACK)(UINT8 evt, tBTM_BLE_REF_VALUE ref_value, UINT8 status);
+
+#ifndef BTM_BLE_BATCH_SCAN_MAX
+#define BTM_BLE_BATCH_SCAN_MAX 5
+#endif
+
+#ifndef BTM_BLE_BATCH_REP_MAIN_Q_SIZE
+#define BTM_BLE_BATCH_REP_MAIN_Q_SIZE 2
+#endif
+
+typedef enum {
+ BTM_BLE_SCAN_INVALID_STATE = 0,
+ BTM_BLE_SCAN_ENABLE_CALLED = 1,
+ BTM_BLE_SCAN_ENABLED_STATE = 2,
+ BTM_BLE_SCAN_DISABLE_CALLED = 3,
+ BTM_BLE_SCAN_DISABLED_STATE = 4
+} tBTM_BLE_BATCH_SCAN_STATE;
+
+enum {
+ BTM_BLE_DISCARD_OLD_ITEMS,
+ BTM_BLE_DISCARD_LOWER_RSSI_ITEMS
+};
+typedef UINT8 tBTM_BLE_DISCARD_RULE;
+
+typedef struct {
+ UINT8 sub_code[BTM_BLE_BATCH_SCAN_MAX];
+ tBTM_BLE_BATCH_SCAN_STATE cur_state[BTM_BLE_BATCH_SCAN_MAX];
+ tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_SCAN_MAX];
+ UINT8 pending_idx;
+ UINT8 next_idx;
+} tBTM_BLE_BATCH_SCAN_OPQ;
+
+typedef struct {
+ UINT8 rep_mode[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
+ tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
+ UINT8 num_records[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
+ UINT16 data_len[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
+ UINT8 *p_data[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
+ UINT8 pending_idx;
+ UINT8 next_idx;
+} tBTM_BLE_BATCH_SCAN_REP_Q;
+
+typedef struct {
+ tBTM_BLE_BATCH_SCAN_STATE cur_state;
+ tBTM_BLE_BATCH_SCAN_MODE scan_mode;
+ UINT32 scan_interval;
+ UINT32 scan_window;
+ tBLE_ADDR_TYPE addr_type;
+ tBTM_BLE_DISCARD_RULE discard_rule;
+ tBTM_BLE_BATCH_SCAN_OPQ op_q;
+ tBTM_BLE_BATCH_SCAN_REP_Q main_rep_q;
+ tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback;
+ tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback;
+ tBTM_BLE_SCAN_REP_CBACK *p_scan_rep_cback;
+ tBTM_BLE_REF_VALUE ref_value;
+} tBTM_BLE_BATCH_SCAN_CB;
+
+/// Ble scan duplicate type
+enum {
+ BTM_BLE_SCAN_DUPLICATE_DISABLE = 0x0, /*!< the Link Layer should generate advertising reports to the host for each packet received */
+ BTM_BLE_SCAN_DUPLICATE_ENABLE = 0x1, /*!< the Link Layer should filter out duplicate advertising reports to the Host */
+ BTM_BLE_SCAN_DUPLICATE_MAX = 0x2, /*!< 0x02 – 0xFF, Reserved for future use */
+};
+/* filter selection bit index */
+#define BTM_BLE_PF_ADDR_FILTER 0
+#define BTM_BLE_PF_SRVC_DATA 1
+#define BTM_BLE_PF_SRVC_UUID 2
+#define BTM_BLE_PF_SRVC_SOL_UUID 3
+#define BTM_BLE_PF_LOCAL_NAME 4
+#define BTM_BLE_PF_MANU_DATA 5
+#define BTM_BLE_PF_SRVC_DATA_PATTERN 6
+#define BTM_BLE_PF_TYPE_ALL 7 /* when passed in payload filter type all, only clear action is applicable */
+#define BTM_BLE_PF_TYPE_MAX 8
+
+/* max number of filter spot for different filter type */
+#ifndef BTM_BLE_MAX_UUID_FILTER
+#define BTM_BLE_MAX_UUID_FILTER 8
+#endif
+#ifndef BTM_BLE_MAX_ADDR_FILTER
+#define BTM_BLE_MAX_ADDR_FILTER 8
+#endif
+#ifndef BTM_BLE_PF_STR_COND_MAX
+#define BTM_BLE_PF_STR_COND_MAX 4 /* apply to manu data , or local name */
+#endif
+#ifndef BTM_BLE_PF_STR_LEN_MAX
+#define BTM_BLE_PF_STR_LEN_MAX 29 /* match for first 29 bytes */
+#endif
+
+typedef UINT8 tBTM_BLE_PF_COND_TYPE;
+
+#define BTM_BLE_PF_LOGIC_OR 0
+#define BTM_BLE_PF_LOGIC_AND 1
+typedef UINT8 tBTM_BLE_PF_LOGIC_TYPE;
+
+#define BTM_BLE_PF_ENABLE 1
+#define BTM_BLE_PF_CONFIG 2
+typedef UINT8 tBTM_BLE_PF_ACTION;
+
+typedef UINT8 tBTM_BLE_PF_FILT_INDEX;
+
+typedef UINT8 tBTM_BLE_PF_AVBL_SPACE;
+
+#define BTM_BLE_PF_BRDCAST_ADDR_FILT 1
+#define BTM_BLE_PF_SERV_DATA_CHG_FILT 2
+#define BTM_BLE_PF_SERV_UUID 4
+#define BTM_BLE_PF_SERV_SOLC_UUID 8
+#define BTM_BLE_PF_LOC_NAME_CHECK 16
+#define BTM_BLE_PF_MANUF_NAME_CHECK 32
+#define BTM_BLE_PF_SERV_DATA_CHECK 64
+typedef UINT16 tBTM_BLE_PF_FEAT_SEL;
+
+#define BTM_BLE_PF_LIST_LOGIC_OR 1
+#define BTM_BLE_PF_LIST_LOGIC_AND 2
+typedef UINT16 tBTM_BLE_PF_LIST_LOGIC_TYPE;
+
+#define BTM_BLE_PF_FILT_LOGIC_OR 0
+#define BTM_BLE_PF_FILT_LOGIC_AND 1
+typedef UINT16 tBTM_BLE_PF_FILT_LOGIC_TYPE;
+
+typedef UINT8 tBTM_BLE_PF_RSSI_THRESHOLD;
+typedef UINT8 tBTM_BLE_PF_DELIVERY_MODE;
+typedef UINT16 tBTM_BLE_PF_TIMEOUT;
+typedef UINT8 tBTM_BLE_PF_TIMEOUT_CNT;
+typedef UINT16 tBTM_BLE_PF_ADV_TRACK_ENTRIES;
+
+typedef struct {
+ tBTM_BLE_PF_FEAT_SEL feat_seln;
+ tBTM_BLE_PF_LIST_LOGIC_TYPE logic_type;
+ tBTM_BLE_PF_FILT_LOGIC_TYPE filt_logic_type;
+ tBTM_BLE_PF_RSSI_THRESHOLD rssi_high_thres;
+ tBTM_BLE_PF_RSSI_THRESHOLD rssi_low_thres;
+ tBTM_BLE_PF_DELIVERY_MODE dely_mode;
+ tBTM_BLE_PF_TIMEOUT found_timeout;
+ tBTM_BLE_PF_TIMEOUT lost_timeout;
+ tBTM_BLE_PF_TIMEOUT_CNT found_timeout_cnt;
+ tBTM_BLE_PF_ADV_TRACK_ENTRIES num_of_tracking_entries;
+} tBTM_BLE_PF_FILT_PARAMS;
+
+enum {
+ BTM_BLE_SCAN_COND_ADD,
+ BTM_BLE_SCAN_COND_DELETE,
+ BTM_BLE_SCAN_COND_CLEAR = 2
+};
+typedef UINT8 tBTM_BLE_SCAN_COND_OP;
+
+enum {
+ BTM_BLE_FILT_ENABLE_DISABLE = 1,
+ BTM_BLE_FILT_CFG = 2,
+ BTM_BLE_FILT_ADV_PARAM = 3
+};
+
+typedef UINT8 tBTM_BLE_FILT_CB_EVT;
+
+/* BLE adv payload filtering config complete callback */
+typedef void (tBTM_BLE_PF_CFG_CBACK)(tBTM_BLE_PF_ACTION action, tBTM_BLE_SCAN_COND_OP cfg_op,
+ tBTM_BLE_PF_AVBL_SPACE avbl_space, tBTM_STATUS status,
+ tBTM_BLE_REF_VALUE ref_value);
+
+typedef void (tBTM_BLE_PF_CMPL_CBACK) (tBTM_BLE_PF_CFG_CBACK);
+
+/* BLE adv payload filtering status setup complete callback */
+typedef void (tBTM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTM_STATUS status,
+ tBTM_BLE_REF_VALUE ref_value);
+
+/* BLE adv payload filtering param setup complete callback */
+typedef void (tBTM_BLE_PF_PARAM_CBACK) (tBTM_BLE_PF_ACTION action_type,
+ tBTM_BLE_PF_AVBL_SPACE avbl_space,
+ tBTM_BLE_REF_VALUE ref_value, tBTM_STATUS status);
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#define MAX_BLE_ADV_INSTANCE 10
+#define MIN_BLE_PERIODIC_ADV_REPORT_LEN 7
+typedef struct {
+ UINT8 inst_id;
+ BOOLEAN configured;
+ BOOLEAN legacy_pdu;
+
+
+ BOOLEAN directed;
+ BOOLEAN scannable;
+ BOOLEAN connetable;
+} tBTM_BLE_EXTENDED_INST;
+
+typedef struct {
+ tBTM_BLE_EXTENDED_INST inst[MAX_BLE_ADV_INSTANCE]; /* dynamic array to store adv instance */
+ UINT8 scan_duplicate;
+} tBTM_BLE_EXTENDED_CB;
+
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE (1 << 0)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE (1 << 1)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED (1 << 2)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED (1 << 3)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY (1 << 4)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_ANON_ADV (1 << 5)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_INCLUDE_TX_PWR (1 << 6)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_MASK (0x7F)
+
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
+ ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
+ ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_LD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
+ ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
+ ESP_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_HD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
+ ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
+ ESP_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_SCAN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
+ ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
+#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_NONCONN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY)
+typedef UINT16 tBTM_BLE_EXT_ADV_TYPE_MASK;
+
+#define BTM_BLE_GAP_PHY_1M 1
+#define BTM_BLE_GAP_PHY_2M 2
+#define BTM_BLE_GAP_PHY_CODED 3
+typedef UINT8 tBTM_BLE_GAP_PHY;
+
+#define BTM_BLE_GAP_PHY_NO_TX_PREF_MASK (0x01)
+#define BTM_BLE_GAP_PHY_NO_RX_PREF_MASK (0x02)
+#define BTM_BLE_GAP_PHY_1M_PREF_MASK (0x03)
+#define BTM_BLE_GAP_PHY_2M_PREF_MASK (0x04)
+#define BTM_BLE_GAP_PHY_CODED_PREF_MASK (0x05)
+typedef UINT8 tBTM_BLE_GAP_PHY_MASK;
+
+#define BTM_BLE_GAP_EXT_SCAN_UNCODE_MASK 0x01
+#define BTM_BLE_GAP_EXT_SCAN_CODE_MASK 0x02
+typedef UINT8 tBTM_BLE_EXT_SCAN_CFG_MASK;
+
+typedef struct {
+ tBTM_BLE_EXT_ADV_TYPE_MASK type;
+ UINT32 interval_min;
+ UINT32 interval_max;
+ tBTM_BLE_ADV_CHNL_MAP channel_map;
+ tBLE_ADDR_TYPE own_addr_type;
+ tBLE_ADDR_TYPE peer_addr_type;
+ BD_ADDR peer_addr;
+ tBTM_BLE_AFP filter_policy;
+ INT8 tx_power;
+ tBTM_BLE_GAP_PHY primary_phy;
+ UINT8 max_skip;
+ tBTM_BLE_GAP_PHY secondary_phy;
+ UINT8 sid;
+ BOOLEAN scan_req_notif;
+} tBTM_BLE_GAP_EXT_ADV_PARAMS;
+
+typedef struct {
+ UINT8 instance;
+ int duration;
+ int max_events;
+} tBTM_BLE_EXT_ADV;
+
+
+typedef struct {
+ tBLE_SCAN_MODE scan_type;
+ UINT16 scan_interval;
+ UINT16 scan_window;
+} tBTM_BLE_EXT_SCAN_CFG;
+
+typedef struct {
+ tBLE_ADDR_TYPE own_addr_type;
+ UINT8 filter_policy;
+ UINT8 scan_duplicate;
+ tBTM_BLE_EXT_SCAN_CFG_MASK cfg_mask;
+ tBTM_BLE_EXT_SCAN_CFG uncoded_cfg;
+ tBTM_BLE_EXT_SCAN_CFG coded_cfg;
+} tBTM_BLE_EXT_SCAN_PARAMS;
+
+typedef struct {
+ UINT16 interval_min;
+ UINT16 interval_max;
+ UINT8 properties;
+} tBTM_BLE_Periodic_Adv_Params;
+
+typedef struct {
+ UINT8 filter_policy;
+ #if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH)
+ UINT8 reports_disabled;
+ UINT8 filter_duplicates;
+ #endif
+ UINT8 sid;
+ tBLE_ADDR_TYPE addr_type;
+ BD_ADDR addr;
+ UINT16 skip;
+ UINT16 sync_timeout;
+} tBTM_BLE_Periodic_Sync_Params;
+
+typedef struct {
+ uint8_t status;
+ uint16_t conn_idx;
+ uint8_t tx_phy;
+ uint8_t rx_phy;
+} tBTM_BLE_UPDATE_PHY;
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+typedef union {
+ UINT16 uuid16_mask;
+ UINT32 uuid32_mask;
+ UINT8 uuid128_mask[LEN_UUID_128];
+} tBTM_BLE_PF_COND_MASK;
+
+typedef struct {
+ tBLE_BD_ADDR *p_target_addr; /* target address, if NULL, generic UUID filter */
+ tBT_UUID uuid; /* UUID condition */
+ tBTM_BLE_PF_LOGIC_TYPE cond_logic; /* AND/OR */
+ tBTM_BLE_PF_COND_MASK *p_uuid_mask; /* UUID mask */
+} tBTM_BLE_PF_UUID_COND;
+
+typedef struct {
+ UINT8 data_len; /* <= 20 bytes */
+ UINT8 *p_data;
+} tBTM_BLE_PF_LOCAL_NAME_COND;
+
+typedef struct {
+ UINT16 company_id; /* company ID */
+ UINT8 data_len; /* <= 20 bytes */
+ UINT8 *p_pattern;
+ UINT16 company_id_mask; /* UUID value mask */
+ UINT8 *p_pattern_mask; /* Manufacturer data matching mask,
+ same length as data pattern,
+ set to all 0xff, match exact data */
+} tBTM_BLE_PF_MANU_COND;
+
+typedef struct {
+ UINT16 uuid; /* service ID */
+ UINT8 data_len; /* <= 20 bytes */
+ UINT8 *p_pattern;
+ UINT8 *p_pattern_mask; /* Service data matching mask, same length as data pattern,
+ set to all 0xff, match exact data */
+} tBTM_BLE_PF_SRVC_PATTERN_COND;
+
+
+typedef union {
+ tBLE_BD_ADDR target_addr;
+ tBTM_BLE_PF_LOCAL_NAME_COND local_name; /* local name filtering */
+ tBTM_BLE_PF_MANU_COND manu_data; /* manufacturer data filtering */
+ tBTM_BLE_PF_UUID_COND srvc_uuid; /* service UUID filtering */
+ tBTM_BLE_PF_UUID_COND solicitate_uuid; /* solicited service UUID filtering */
+ tBTM_BLE_PF_SRVC_PATTERN_COND srvc_data; /* service data pattern */
+} tBTM_BLE_PF_COND_PARAM;
+
+typedef struct {
+ UINT8 action_ocf[BTM_BLE_PF_TYPE_MAX];
+ tBTM_BLE_REF_VALUE ref_value[BTM_BLE_PF_TYPE_MAX];
+ tBTM_BLE_PF_PARAM_CBACK *p_filt_param_cback[BTM_BLE_PF_TYPE_MAX];
+ tBTM_BLE_PF_CFG_CBACK *p_scan_cfg_cback[BTM_BLE_PF_TYPE_MAX];
+ UINT8 cb_evt[BTM_BLE_PF_TYPE_MAX];
+ UINT8 pending_idx;
+ UINT8 next_idx;
+} tBTM_BLE_ADV_FILTER_ADV_OPQ;
+
+#define BTM_BLE_MAX_FILTER_COUNTER (BTM_BLE_MAX_ADDR_FILTER + 1) /* per device filter + one generic filter indexed by 0 */
+
+#ifndef BTM_CS_IRK_LIST_MAX
+#define BTM_CS_IRK_LIST_MAX 0x20
+#endif
+
+typedef struct {
+ BOOLEAN in_use;
+ BD_ADDR bd_addr;
+ UINT8 pf_counter[BTM_BLE_PF_TYPE_MAX]; /* number of filter indexed by tBTM_BLE_PF_COND_TYPE */
+} tBTM_BLE_PF_COUNT;
+
+typedef struct {
+ BOOLEAN enable;
+ UINT8 op_type;
+ tBTM_BLE_PF_COUNT *p_addr_filter_count; /* per BDA filter array */
+ tBLE_BD_ADDR cur_filter_target;
+ tBTM_BLE_PF_STATUS_CBACK *p_filt_stat_cback;
+ tBTM_BLE_ADV_FILTER_ADV_OPQ op_q;
+} tBTM_BLE_ADV_FILTER_CB;
+
+/* Sub codes */
+#define BTM_BLE_META_PF_ENABLE 0x00
+#define BTM_BLE_META_PF_FEAT_SEL 0x01
+#define BTM_BLE_META_PF_ADDR 0x02
+#define BTM_BLE_META_PF_UUID 0x03
+#define BTM_BLE_META_PF_SOL_UUID 0x04
+#define BTM_BLE_META_PF_LOCAL_NAME 0x05
+#define BTM_BLE_META_PF_MANU_DATA 0x06
+#define BTM_BLE_META_PF_SRVC_DATA 0x07
+#define BTM_BLE_META_PF_ALL 0x08
+
+typedef UINT8 BTM_BLE_ADV_STATE;
+typedef UINT8 BTM_BLE_ADV_INFO_PRESENT;
+typedef UINT8 BTM_BLE_RSSI_VALUE;
+typedef UINT16 BTM_BLE_ADV_INFO_TIMESTAMP;
+
+/* These are the fields returned in each device adv packet. It
+** is returned in the results callback if registered.
+*/
+typedef struct {
+ UINT8 conn_mode;
+ tBTM_BLE_AD_MASK ad_mask; /* mask of the valid adv data field */
+ UINT8 flag;
+ UINT8 tx_power_level;
+ UINT8 remote_name_len;
+ UINT8 *p_remote_name;
+ tBTM_BLE_SERVICE service;
+} tBTM_BLE_INQ_DATA;
+
+enum {
+ BTM_BLE_CONN_NONE,
+ BTM_BLE_CONN_AUTO,
+ BTM_BLE_CONN_SELECTIVE
+};
+typedef UINT8 tBTM_BLE_CONN_TYPE;
+
+#define ADV_INFO_PRESENT 0x00
+#define NO_ADV_INFO_PRESENT 0x01
+
+typedef btgatt_track_adv_info_t tBTM_BLE_TRACK_ADV_DATA;
+
+typedef void (tBTM_BLE_TRACK_ADV_CBACK)(tBTM_BLE_TRACK_ADV_DATA *p_track_adv_data);
+
+typedef UINT8 tBTM_BLE_TRACK_ADV_EVT;
+
+typedef struct {
+ tBTM_BLE_REF_VALUE ref_value;
+ tBTM_BLE_TRACK_ADV_CBACK *p_track_cback;
+} tBTM_BLE_ADV_TRACK_CB;
+
+enum {
+ BTM_BLE_TRACK_ADV_ADD,
+ BTM_BLE_TRACK_ADV_REMOVE
+};
+
+typedef UINT8 tBTM_BLE_TRACK_ADV_ACTION;
+
+#define BTM_BLE_MULTI_ADV_INVALID 0
+
+#define BTM_BLE_BATCH_SCAN_ENABLE_EVT 1
+#define BTM_BLE_BATCH_SCAN_CFG_STRG_EVT 2
+#define BTM_BLE_BATCH_SCAN_READ_REPTS_EVT 3
+#define BTM_BLE_BATCH_SCAN_THR_EVT 4
+#define BTM_BLE_BATCH_SCAN_PARAM_EVT 5
+#define BTM_BLE_BATCH_SCAN_DISABLE_EVT 6
+
+typedef UINT8 tBTM_BLE_BATCH_SCAN_EVT;
+
+typedef UINT32 tBTM_BLE_TX_TIME_MS;
+typedef UINT32 tBTM_BLE_RX_TIME_MS;
+typedef UINT32 tBTM_BLE_IDLE_TIME_MS;
+typedef UINT32 tBTM_BLE_ENERGY_USED;
+
+typedef void (tBTM_BLE_ENERGY_INFO_CBACK)(tBTM_BLE_TX_TIME_MS tx_time, tBTM_BLE_RX_TIME_MS rx_time,
+ tBTM_BLE_IDLE_TIME_MS idle_time,
+ tBTM_BLE_ENERGY_USED energy_used,
+ tBTM_STATUS status);
+
+typedef struct {
+ tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback;
+} tBTM_BLE_ENERGY_INFO_CB;
+
+typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
+typedef void (tBTM_BLE_CTRL_FEATURES_CBACK)(tBTM_STATUS status);
+
+/* callback function for SMP signing algorithm, signed data in little endian order with tlen bits long */
+typedef void (tBTM_BLE_SIGN_CBACK)(void *p_ref_data, UINT8 *p_signing_data);
+typedef void (tBTM_BLE_VERIFY_CBACK)(void *p_ref_data, BOOLEAN match);
+/* random address set complete callback */
+typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda);
+
+typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt);
+typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS status);
+
+tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb;
+
+typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status);
+typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status);
+
+typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info);
+typedef void (tBTM_CLEAR_ADV_CMPL_CBACK) (UINT8 status);
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#define BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT 1
+#define BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT 2
+#define BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT 3
+#define BTM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT 4
+#define BTM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT 5
+#define BTM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT 6
+#define BTM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT 7
+#define BTM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT 8
+#define BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT 9
+#define BTM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT 10
+#define BTM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT 11
+#define BTM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT 12
+#define BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT 13
+#define BTM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT 14
+#define BTM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT 15
+#define BTM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT 16
+#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT 17
+#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT 18
+#define BTM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT 19
+#define BTM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT 20
+#define BTM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT 21
+#define BTM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT 22
+#define BTM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT 23
+#define BTM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT 24
+#define BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT 25
+#define BTM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT 26
+#define BTM_BLE_5_GAP_EXT_ADV_REPORT_EVT 27
+#define BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT 28
+#define BTM_BLE_5_GAP_ADV_TERMINATED_EVT 29
+#define BTM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT 30
+#define BTM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT 31
+#define BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT 32
+#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT 33
+#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT 34
+#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+#define BTM_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT 35
+#define BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT 36
+#define BTM_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT 37
+#define BTM_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT 38
+#define BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT 39
+#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+#define BTM_BLE_5_GAP_UNKNOWN_EVT 40
+typedef UINT8 tBTM_BLE_5_GAP_EVENT;
+
+#define BTM_BLE_EXT_ADV_DATA_COMPLETE 0x00
+#define BTM_BLE_EXT_ADV_DATA_INCOMPLETE 0x01
+#define BTM_BLE_EXT_ADV_DATA_TRUNCATED 0x02
+typedef UINT8 tBTM_BLE_EXT_ADV_DATA_STATUS;
+
+#define BTM_BLE_ADV_DATA_COMPLETE_MASK (0x0000)
+#define BTM_BLE_ADV_DATA_INCOMPLETE_MASK (0x0020)
+#define BTM_BLE_ADV_DATA_TRUNCATED_MASK (0x0040)
+#define BTM_BLE_ADV_DATA_STATUS_MASK (0x0060)
+
+
+//#define BTM_BLE_ADV_CONN_MASK (0x0001)
+//#define BTM_BLE_ADV_SCAN_MASK (0x0002)
+//#define BTM_BLE_ADV_DIRECT_MASK (0x0004)
+//#define BTM_BLE_SCAN_RSP_MASK (0x0008)
+#define BTM_BLE_ADV_LEGACY_MASK (0x0010)
+typedef UINT8 tBTM_BLE_ADV_MASK;
+
+// /* Advertising report */
+// #define BTM_BLE_ADV_REPORT_ADV_IND (0)
+// #define BTM_BLE_ADV_REPORT_DIR_IND (1)
+// #define BTM_BLE_ADV_REPORT_SCAN_IND (2)
+// #define BTM_BLE_ADV_REPORT_NONCONN_IND (3)
+// #define BTM_BLE_ADV_REPORT_SCAN_RSP (4)
+
+// /* Bluetooth 5.0, Vol 2, Part E, 7.7.65.13 */
+// #define BTM_BLE_LEGACY_ADV_TYPE_IND (0x13)
+// #define BTM_BLE_LEGACY_ADV_TYPE_DIRECT_IND (0x15)
+// #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_IND (0x12)
+// #define BTM_BLE_LEGACY_ADV_TYPE_NONCON_IND (0x10)
+// #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_IND (0x1b)
+// #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_SCAN_IND (0x1a)
+
+typedef struct {
+ UINT8 status;
+ BD_ADDR addr;
+ UINT8 tx_phy;
+ UINT8 rx_phy;
+} tBTM_BLE_READ_PHY_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_SET_PREF_DEF_PHY_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_SET_PERF_PHY_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_EXT_ADV_DATA_SET_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_EXT_ADV_START_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_EXT_ADV_STOP_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_START_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_STOP_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_EXT_SCAN_START_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_EXT_SCAN_STOP_CMPL;
+
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL;
+
+typedef struct {
+ uint8_t status;
+ BD_ADDR addr;
+ uint8_t tx_phy;
+ uint8_t rx_phy;
+} tBTM_BLE_PHY_UPDATE_CMPL;
+
+typedef struct {
+ // UINT8 props;
+ // UINT8 legacy_event_type;
+ UINT8 event_type;
+ tBLE_ADDR_TYPE addr_type;
+ BD_ADDR addr;
+ UINT8 primary_phy;
+ UINT8 secondry_phy;
+ UINT8 sid;
+ UINT8 tx_power;
+ UINT8 rssi;
+ UINT16 per_adv_interval;
+ tBLE_ADDR_TYPE dir_addr_type;
+ BD_ADDR dir_addr;
+ tBTM_BLE_EXT_ADV_DATA_STATUS data_status;
+ UINT8 adv_data_len;
+ UINT8 *adv_data;
+} tBTM_BLE_EXT_ADV_REPORT;
+
+typedef struct {
+ UINT8 status;
+ UINT8 adv_handle;
+ UINT16 conn_handle;
+ UINT8 completed_event;
+} tBTM_BLE_ADV_TERMINAT;
+
+typedef struct {
+ UINT8 adv_handle;
+ tBLE_ADDR_TYPE scan_addr_type;
+ BD_ADDR scan_addr;
+} tBTM_BLE_SCAN_REQ_RECEIVED;
+
+typedef struct {
+ UINT16 conn_handle;
+ UINT8 channel_sel_alg;
+} tBTM_BLE_CHANNEL_SEL_ALG;
+
+typedef struct {
+ UINT16 sync_handle;
+ UINT8 tx_power;
+ INT8 rssi;
+ tBTM_BLE_EXT_ADV_DATA_STATUS data_status;
+ UINT8 data_length;
+ UINT8 *data;
+} tBTM_PERIOD_ADV_REPORT;
+
+typedef struct {
+ UINT16 sync_handle;
+} tBTM_BLE_PERIOD_ADV_SYNC_LOST;
+
+typedef struct {
+ UINT8 status;
+ UINT16 sync_handle;
+ UINT8 sid;
+ tBLE_ADDR_TYPE adv_addr_type;
+ BD_ADDR adv_addr;
+ UINT8 adv_phy;
+ UINT16 period_adv_interval;
+ UINT8 adv_clk_accuracy;
+} tBTM_BLE_PERIOD_ADV_SYNC_ESTAB;
+
+typedef struct {
+ UINT16 scan_interval;
+ UINT16 scan_window;
+ UINT16 interval_min;
+ UINT16 interval_max;
+ UINT16 latency;
+ UINT16 supervision_timeout;
+ UINT16 min_ce_len;
+ UINT16 max_ce_len;
+} tBTM_BLE_CONN_PARAMS;
+
+#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+typedef struct {
+ UINT8 status;
+} tBTM_BLE_PERIOD_ADV_RECV_ENABLE_CMPL;
+
+typedef struct {
+ UINT8 status;
+ BD_ADDR addr;
+} tBTM_BLE_PERIOD_ADV_SYNC_TRANS_CMPL;
+
+typedef struct {
+ UINT8 status;
+ BD_ADDR addr;
+} tBTM_BLE_PERIOD_ADV_SET_INFO_TRANS_CMPL;
+
+typedef struct {
+ UINT8 status;
+ BD_ADDR addr;
+} tBTM_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS_CMPL;
+
+typedef struct {
+ UINT8 status;
+ BD_ADDR addr;
+ UINT16 service_data;
+ UINT16 sync_handle;
+ UINT8 adv_sid;
+ UINT8 adv_addr_type;
+ BD_ADDR adv_addr;
+ UINT8 adv_phy;
+ UINT16 adv_interval;
+ UINT8 adv_clk_accuracy;
+} tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV;
+#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+
+typedef union {
+ UINT8 status;
+ tBTM_BLE_READ_PHY_CMPL read_phy;
+ tBTM_BLE_SET_PREF_DEF_PHY_CMPL set_perf_def_phy;
+ tBTM_BLE_SET_PERF_PHY_CMPL set_perf_phy;
+ tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL set_ext_rand_addr;
+ tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL set_params;
+ tBTM_BLE_EXT_ADV_DATA_SET_CMPL adv_data_set;
+ tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL scan_rsp_data_set;
+ tBTM_BLE_EXT_ADV_START_CMPL adv_start;
+ tBTM_BLE_EXT_ADV_STOP_CMPL adv_stop;
+ tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL per_adv_set_params;
+ tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL per_adv_data_set;
+ tBTM_BLE_PERIOD_ADV_START_CMPL per_adv_start;
+ tBTM_BLE_PERIOD_ADV_STOP_CMPL per_adv_stop;
+ tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL per_adv_sync_create;
+ tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL per_adv_sync_cancel;
+ tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL per_adv_sync_term;
+ tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL per_adv_add_dev;
+ tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL per_adv_remove_dev;
+ tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL per_adv_clear_dev;
+ tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL ext_scan;
+ tBTM_BLE_EXT_SCAN_START_CMPL scan_start;
+ tBTM_BLE_EXT_SCAN_STOP_CMPL scan_stop;
+ tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL ext_conn_set_params;
+ tBTM_BLE_PHY_UPDATE_CMPL phy_update;
+ tBTM_BLE_EXT_ADV_REPORT ext_adv_report;
+ tBTM_BLE_ADV_TERMINAT adv_term;
+ tBTM_BLE_SCAN_REQ_RECEIVED scan_req;
+ tBTM_BLE_CHANNEL_SEL_ALG channel_sel;
+ tBTM_PERIOD_ADV_REPORT period_adv_report;
+ tBTM_BLE_PERIOD_ADV_SYNC_LOST sync_lost;
+ tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab;
+#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+ tBTM_BLE_PERIOD_ADV_RECV_ENABLE_CMPL per_adv_recv_enable;
+ tBTM_BLE_PERIOD_ADV_SYNC_TRANS_CMPL per_adv_sync_trans;
+ tBTM_BLE_PERIOD_ADV_SET_INFO_TRANS_CMPL per_adv_set_info_trans;
+ tBTM_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS_CMPL set_past_params;
+ tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV past_recv;
+#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+} tBTM_BLE_5_GAP_CB_PARAMS;
+
+typedef struct {
+ UINT8 phy_mask;
+ tBTM_BLE_CONN_PARAMS phy_1m_conn_params;
+ tBTM_BLE_CONN_PARAMS phy_2m_conn_params;
+ tBTM_BLE_CONN_PARAMS phy_coded_conn_params;
+} tBTM_EXT_CONN_PARAMS;
+
+typedef void (*tBTM_BLE_5_HCI_CBACK)(tBTM_BLE_5_GAP_EVENT event, tBTM_BLE_5_GAP_CB_PARAMS *params);
+
+#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
+
+/*****************************************************************************
+** EXTERNAL FUNCTION DECLARATIONS
+*****************************************************************************/
+/*
+#ifdef __cplusplus
+extern "C" {
+#endif
+*/
+
+/*******************************************************************************
+**
+** Function BTM_BleRegiseterConnParamCallback
+**
+** Description register connection parameters update callback func
+**
+** Parameters: update_conn_param_cb
+**
+** Returns void
+**
+*******************************************************************************/
+void BTM_BleRegiseterConnParamCallback(tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb);
+
+/*******************************************************************************
+**
+** Function BTM_SecAddBleDevice
+**
+** Description Add/modify device. This function will be normally called
+** during host startup to restore all required information
+** for a LE device stored in the NVRAM.
+**
+** Parameters: bd_addr - BD address of the peer
+** bd_name - Name of the peer device. NULL if unknown.
+** dev_type - Remote device's device type.
+** addr_type - LE device address type.
+** auth_mode - auth mode
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name,
+ tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type, UINT32 auth_mode);
+
+/*******************************************************************************
+**
+** Function BTM_SecAddBleKey
+**
+** Description Add/modify LE device information. This function will be
+** normally called during host startup to restore all required
+** information stored in the NVRAM.
+**
+** Parameters: bd_addr - BD address of the peer
+** p_le_key - LE key values.
+** key_type - LE SMP key type.
+*
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key,
+ tBTM_LE_KEY_TYPE key_type);
+
+/*******************************************************************************
+**
+** Function BTM_BleSetAdvParams
+**
+** Description This function is called to set advertising parameters.
+**
+** Parameters: None.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
+ tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map);
+
+
+
+/*******************************************************************************
+**
+** Function BTM_BleSetAdvParamsAll
+**
+** Description This function is called to set all of the advertising parameters.
+**
+** Parameters: None.
+**
+** Returns void
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
+ tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
+ tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp, tBTM_START_ADV_CMPL_CBACK *adv_cb);
+
+/*******************************************************************************
+**
+** Function BTM_BleStartAdv
+**
+** Description This function is called to start adv.
+**
+** Parameters: None.
+**
+** Returns status
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleStartAdv(void);
+
+
+/*******************************************************************************
+**
+** Function BTM_BleWriteAdvData
+**
+** Description This function is called to write advertising data.
+**
+** Parameters: None.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask,
+ tBTM_BLE_ADV_DATA *p_data);
+
+/*******************************************************************************
+**
+** Function BTM_BleWriteLongAdvData
+**
+** Description This function is called to write long advertising data.
+**
+** Parameters: adv_data: long advertising data
+** adv_data_len: the length of long advertising data
+**
+** Returns void
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleWriteLongAdvData(uint8_t *adv_data, uint8_t adv_data_len);
+
+/*******************************************************************************
+**
+** Function BTM_BleWriteAdvDataRaw
+**
+** Description This function is called to write raw advertising data.
+**
+** Parameters: p_raw_adv : point to raw advertising data
+** raw_adv_len : raw advertising data
+**
+** Returns BTM_SUCCESS means success.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len);
+
+
+tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr);
+
+void BTM_BleClearRandAddress(void);
+
+
+/*******************************************************************************
+**
+** Function BTM_BleSetAdvParams
+**
+** Description This function is called to set advertising parameters.
+**
+** Parameters adv_int_min: minimum advertising interval
+** adv_int_max: maximum advertising interval
+** p_dir_bda: connectable direct initiator's LE device address
+** chnl_map: advertising channel map.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max,
+ tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map);
+
+/*******************************************************************************
+**
+** Function BTM_BleObtainVendorCapabilities
+**
+** Description This function is called to obtain vendor capabilities
+**
+** Parameters p_cmn_vsc_cb - Returns the vendor capabilities
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
+
+/*******************************************************************************
+**
+** Function BTM_BleSetScanParams
+**
+** Description This function is called to set Scan parameters.
+**
+** Parameters client_if - Client IF value
+** scan_interval - Scan interval
+** scan_window - Scan window
+** scan_type - Scan type
+** scan_setup_status_cback - Scan setup status callback
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval,
+ UINT32 scan_window, tBLE_SCAN_MODE scan_type,
+ tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
+
+
+
+/*******************************************************************************
+**
+** Function BTM_BleSetScanFilterParams
+**
+** Description This function is called to set Scan Filter & parameters.
+**
+** Parameters client_if - Client IF value
+** scan_interval - Scan interval
+** scan_window - Scan window
+** scan_type - Scan type
+** addr_type_own - owner address type
+** scan_duplicate_filter - scan duplicate filter
+** scan_filter_policy - scan filter policy
+** scan_setup_status_cback - Scan setup status callback
+**
+** Returns void
+**
+*******************************************************************************/
+tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window,
+ tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBTM_BLE_SFP scan_filter_policy,
+ tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
+
+
+/*******************************************************************************
+**
+** Function BTM_BleGetVendorCapabilities
+**
+** Description This function reads local LE features
+**
+** Parameters p_cmn_vsc_cb : Locala LE capability structure
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
+/*******************************************************************************
+**
+** Function BTM_BleSetStorageConfig
+**
+** Description This function is called to setup storage configuration and setup callbacks.
+**
+** Parameters UINT8 batch_scan_full_max -Batch scan full maximum
+ UINT8 batch_scan_trunc_max - Batch scan truncated value maximum
+ UINT8 batch_scan_notify_threshold - Threshold value
+ tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback - Setup callback
+ tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback -Threshold callback
+ void *p_ref - Reference value
+**
+** Returns tBTM_STATUS
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max,
+ UINT8 batch_scan_trunc_max,
+ UINT8 batch_scan_notify_threshold,
+ tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback,
+ tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
+ tBTM_BLE_SCAN_REP_CBACK *p_cback,
+ tBTM_BLE_REF_VALUE ref_value);
+
+/*******************************************************************************
+**
+** Function BTM_BleEnableBatchScan
+**
+** Description This function is called to enable batch scan
+**
+** Parameters tBTM_BLE_BATCH_SCAN_MODE scan_mode - Batch scan mode
+ UINT32 scan_interval -Scan interval
+ UINT32 scan_window - Scan window value
+ tBLE_ADDR_TYPE addr_type - Address type
+ tBTM_BLE_DISCARD_RULE discard_rule - Data discard rules
+**
+** Returns tBTM_STATUS
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
+ UINT32 scan_interval, UINT32 scan_window,
+ tBTM_BLE_DISCARD_RULE discard_rule,
+ tBLE_ADDR_TYPE addr_type,
+ tBTM_BLE_REF_VALUE ref_value);
+
+/*******************************************************************************
+**
+** Function BTM_BleDisableBatchScan
+**
+** Description This function is called to disable batch scanning
+**
+** Parameters void
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value);
+
+/*******************************************************************************
+**
+** Function BTM_BleReadScanReports
+**
+** Description This function is called to read batch scan reports
+**
+** Parameters tBLE_SCAN_MODE scan_mode - Scan mode report to be read out
+ tBTM_BLE_SCAN_REP_CBACK* p_cback - Reports callback
+**
+** Returns tBTM_STATUS
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode,
+ tBTM_BLE_REF_VALUE ref_value);
+
+/*******************************************************************************
+**
+** Function BTM_BleTrackAdvertiser
+**
+** Description This function is called to read batch scan reports
+**
+** Parameters p_track_cback - Tracking callback
+** ref_value - Reference value
+**
+** Returns tBTM_STATUS
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback,
+ tBTM_BLE_REF_VALUE ref_value);
+
+/*******************************************************************************
+**
+** Function BTM_BleWriteScanRsp
+**
+** Description This function is called to write LE scan response.
+**
+** Parameters: p_scan_rsp: scan response.
+**
+** Returns status
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
+ tBTM_BLE_ADV_DATA *p_data);
+
+/*******************************************************************************
+**
+** Function BTM_BleWriteScanRspRaw
+**
+** Description This function is called to write raw scan response data
+**
+** Parameters: None.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len);
+
+/*******************************************************************************
+**
+** Function BTM_BleObserve
+**
+** Description This procedure keep the device listening for advertising
+** events from a broadcast device.
+**
+** Parameters start: start or stop observe.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
+ tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb);
+
+/*******************************************************************************
+**
+** Function BTM_BleScan
+**
+** Description This procedure keep the device listening for advertising
+** events from a broadcast device.
+**
+** Parameters start: start or stop scan.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
+ tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb, tBTM_INQ_DIS_CB *p_discard_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_GetDeviceIDRoot
+**
+** Description This function is called to read the local device identity
+** root.
+**
+** Returns void
+** the local device ER is copied into er
+**
+*******************************************************************************/
+//extern
+void BTM_GetDeviceIDRoot (BT_OCTET16 ir);
+
+/*******************************************************************************
+**
+** Function BTM_GetDeviceEncRoot
+**
+** Description This function is called to read the local device encryption
+** root.
+**
+** Returns void
+** the local device ER is copied into er
+**
+*******************************************************************************/
+//extern
+void BTM_GetDeviceEncRoot (BT_OCTET16 er);
+
+/*******************************************************************************
+**
+** Function BTM_GetDeviceDHK
+**
+** Description This function is called to read the local device DHK.
+**
+** Returns void
+** the local device DHK is copied into dhk
+**
+*******************************************************************************/
+//extern
+void BTM_GetDeviceDHK (BT_OCTET16 dhk);
+
+/*******************************************************************************
+**
+** Function BTM_SecurityGrant
+**
+** Description This function is called to grant security process.
+**
+** Parameters bd_addr - peer device bd address.
+** res - result of the operation BTM_SUCCESS if success.
+** Otherwise, BTM_REPEATED_ATTEMPTS is too many attempts.
+**
+** Returns None
+**
+*******************************************************************************/
+//extern
+void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res);
+
+/*******************************************************************************
+**
+** Function BTM_BlePasskeyReply
+**
+** Description This function is called after Security Manager submitted
+** passkey request to the application.
+**
+** Parameters: bd_addr - Address of the device for which passkey was requested
+** res - result of the operation SMP_SUCCESS if success
+** passkey - numeric value in the range of
+** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
+**
+*******************************************************************************/
+//extern
+void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey);
+
+/*******************************************************************************
+**
+** Function BTM_BleSetStaticPasskey
+**
+** Description This function is called to set static passkey
+**
+**
+** Parameters: add - set static passkey when add is TRUE
+** clear static passkey when add is FALSE
+** passkey - static passkey
+**
+**
+*******************************************************************************/
+void BTM_BleSetStaticPasskey(BOOLEAN add, UINT32 passkey);
+
+/*******************************************************************************
+**
+** Function BTM_BleConfirmReply
+**
+** Description This function is called after Security Manager submitted
+** numeric comparison request to the application.
+**
+** Parameters: bd_addr - Address of the device with which numeric
+** comparison was requested
+** res - comparison result BTM_SUCCESS if success
+**
+*******************************************************************************/
+//extern
+void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res);
+
+/*******************************************************************************
+**
+** Function BTM_LeOobDataReply
+**
+** Description This function is called to provide the OOB data for
+** SMP in response to BTM_LE_OOB_REQ_EVT
+**
+** Parameters: bd_addr - Address of the peer device
+** res - result of the operation SMP_SUCCESS if success
+** p_data - simple pairing Randomizer C.
+**
+*******************************************************************************/
+//extern
+void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data);
+
+/*******************************************************************************
+**
+** Function BTM_BleSecureConnectionOobDataReply
+**
+** Description This function is called to provide the OOB data for
+** SMP in response to BTM_LE_SC_OOB_REQ_EVT when secure connection
+**
+** Parameters: bd_addr - Address of the peer device
+** p_c - pointer to Confirmation
+** p_r - pointer to Randomizer
+**
+*******************************************************************************/
+void BTM_BleSecureConnectionOobDataReply(BD_ADDR bd_addr, UINT8 *p_c, UINT8 *p_r);
+
+/*******************************************************************************
+**
+** Function BTM_BleSecureConnectionCreateOobData
+**
+** Description This function is called to create the OOB data for
+** SMP when secure connection
+**
+*******************************************************************************/
+void BTM_BleSecureConnectionCreateOobData(void);
+
+/*******************************************************************************
+**
+** Function BTM_BleDataSignature
+**
+** Description This function is called to sign the data using AES128 CMAC
+** algorith.
+**
+** Parameter bd_addr: target device the data to be signed for.
+** p_text: singing data
+** len: length of the signing data
+** signature: output parameter where data signature is going to
+** be stored.
+**
+** Returns TRUE if signing sucessul, otherwise FALSE.
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len,
+ BLE_SIGNATURE signature);
+
+/*******************************************************************************
+**
+** Function BTM_BleVerifySignature
+**
+** Description This function is called to verify the data signature
+**
+** Parameter bd_addr: target device the data to be signed for.
+** p_orig: original data before signature.
+** len: length of the signing data
+** counter: counter used when doing data signing
+** p_comp: signature to be compared against.
+
+** Returns TRUE if signature verified correctly; otherwise FALSE.
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig,
+ UINT16 len, UINT32 counter,
+ UINT8 *p_comp);
+
+/*******************************************************************************
+**
+** Function BTM_ReadConnectionAddr
+**
+** Description This function is called to set the local device random address
+** .
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr,
+ tBLE_ADDR_TYPE *p_addr_type);
+
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadRemoteConnectionAddr
+**
+** Description This function is read the remote device address currently used
+** .
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr,
+ BD_ADDR conn_addr,
+ tBLE_ADDR_TYPE *p_addr_type);
+
+/*******************************************************************************
+**
+** Function BTM_BleLoadLocalKeys
+**
+** Description Local local identity key, encryption root or sign counter.
+**
+** Parameters: key_type: type of key, can be BTM_BLE_KEY_TYPE_ID, BTM_BLE_KEY_TYPE_ER
+** or BTM_BLE_KEY_TYPE_COUNTER.
+** p_key: pointer to the key.
+*
+** Returns non2.
+**
+*******************************************************************************/
+//extern
+void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
+
+
+/*******************************************************************************
+**
+** Function BTM_BleSetBgConnType
+**
+** Description This function is called to set BLE background connection
+** procedure type. It can be auto connection, or selective connection.
+**
+** Parameters conn_type: it can be auto connection, or selective connection.
+** p_select_cback: callback function when selective connection procedure
+** is being used.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE conn_type,
+ tBTM_BLE_SEL_CBACK *p_select_cback);
+
+/*******************************************************************************
+**
+** Function BTM_BleUpdateBgConnDev
+**
+** Description This function is called to add or remove a device into/from
+** background connection procedure. The background connection
+* procedure is decided by the background connection type, it can be
+* auto connection, or selective connection.
+**
+** Parameters add_remove: TRUE to add; FALSE to remove.
+** remote_bda: device address to add/remove.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR remote_bda);
+
+/*******************************************************************************
+**
+** Function BTM_BleClearBgConnDev
+**
+** Description This function is called to clear the whitelist,
+** end any pending whitelist connections,
+* and reset the local bg device list.
+**
+** Parameters void
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleClearBgConnDev(void);
+
+/********************************************************
+**
+** Function BTM_BleSetPrefConnParams
+**
+** Description Set a peripheral's preferred connection parameters. When
+** any of the value does not want to be updated while others
+** do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to
+** leave untouched.
+**
+** Parameters: bd_addr - BD address of the peripheral
+** min_conn_int - minimum preferred connection interval
+** max_conn_int - maximum preferred connection interval
+** slave_latency - preferred slave latency
+** supervision_tout - preferred supervision timeout
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleSetPrefConnParams (BD_ADDR bd_addr,
+ UINT16 min_conn_int, UINT16 max_conn_int,
+ UINT16 slave_latency, UINT16 supervision_tout);
+
+/******************************************************************************
+**
+** Function BTM_BleSetConnScanParams
+**
+** Description Set scan parameters used in BLE connection request
+**
+** Parameters: scan_interval - scan interval
+** scan_window - scan window
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window);
+
+/******************************************************************************
+**
+** Function BTM_BleReadControllerFeatures
+**
+** Description Reads BLE specific controller features
+**
+** Parameters: tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when features are read
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback);
+
+/*******************************************************************************
+**
+** Function BTM_CheckAdvData
+**
+** Description This function is called to get ADV data for a specific type.
+**
+** Parameters p_adv - pointer of ADV data
+** type - finding ADV data type
+** p_length - return the length of ADV data not including type
+**
+** Returns pointer of ADV data
+**
+*******************************************************************************/
+//extern
+UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length);
+
+/*******************************************************************************
+**
+** Function BTM_BleGetCurrentAddress
+**
+** Description This function is called to get local used BLE address.
+**
+** Parameters: None.
+**
+** Returns success or fail
+**
+*******************************************************************************/
+BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type);
+
+/*******************************************************************************
+**
+** Function BTM__BLEReadDiscoverability
+**
+** Description This function is called to read the current LE discoverability
+** mode of the device.
+**
+** Returns BTM_BLE_NON_DISCOVERABLE ,BTM_BLE_LIMITED_DISCOVERABLE or
+** BTM_BLE_GENRAL_DISCOVERABLE
+**
+*******************************************************************************/
+UINT16 BTM_BleReadDiscoverability(void);
+
+/*******************************************************************************
+**
+** Function BTM__BLEReadConnectability
+**
+** Description This function is called to read the current LE connectibility
+** mode of the device.
+**
+** Returns BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE
+**
+*******************************************************************************/
+//extern
+UINT16 BTM_BleReadConnectability (void);
+
+void BTM_Recovery_Pre_State(void);
+
+/*******************************************************************************
+**
+** Function BTM_ReadDevInfo
+**
+** Description This function is called to read the device/address type
+** of BD address.
+**
+** Parameter remote_bda: remote device address
+** p_dev_type: output parameter to read the device type.
+** p_addr_type: output parameter to read the address type.
+**
+*******************************************************************************/
+//extern
+void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type,
+ tBLE_ADDR_TYPE *p_addr_type);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadConnectedTransportAddress
+**
+** Description This function is called to read the paired device/address type of other device paired
+** corresponding to the BD_address
+**
+** Parameter remote_bda: remote device address, carry out the transport address
+** transport: active transport
+**
+** Return TRUE if an active link is identified; FALSE otherwise
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda,
+ tBT_TRANSPORT transport);
+
+/*******************************************************************************
+**
+** Function BTM_BleBroadcast
+**
+** Description This function is to start or stop broadcasting.
+**
+** Parameters start: start or stop broadcasting.
+**
+** Returns status.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback);
+
+/*******************************************************************************
+**
+** Function BTM_BleConfigPrivacy
+**
+** Description This function is called to enable or disable the privacy in
+** the local device.
+**
+** Parameters enable: TRUE to enable it; FALSE to disable it.
+**
+** Returns BOOLEAN privacy mode set success; otherwise failed.
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck);
+
+/*******************************************************************************
+**
+** Function BTM_BleConfigLocalIcon
+**
+** Description This function is called to set local icon
+**
+** Parameters icon: appearance value.
+**
+**
+*******************************************************************************/
+void BTM_BleConfigLocalIcon(uint16_t icon);
+
+/*******************************************************************************
+**
+** Function BTM_BleConfigConnParams
+**
+** Description This function is called to set the connection parameters
+**
+** Parameters int_min: minimum connection interval
+** int_max: maximum connection interval
+** latency: slave latency
+** timeout: supervision timeout
+**
+*******************************************************************************/
+void BTM_BleConfigConnParams(uint16_t int_min, uint16_t int_max, uint16_t latency, uint16_t timeout);
+
+/*******************************************************************************
+**
+** Function BTM_BleLocalPrivacyEnabled
+**
+** Description Checks if local device supports private address
+**
+** Returns Return TRUE if local privacy is enabled else FALSE
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_BleLocalPrivacyEnabled(void);
+
+/*******************************************************************************
+**
+** Function BTM_BleEnableMixedPrivacyMode
+**
+** Description This function is called to enabled Mixed mode if privacy 1.2
+** is applicable in controller.
+**
+** Parameters mixed_on: mixed mode to be used or not.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on);
+
+/*******************************************************************************
+**
+** Function BTM_BleMaxMultiAdvInstanceCount
+**
+** Description Returns max number of multi adv instances supported by controller
+**
+** Returns Max multi adv instance count
+**
+*******************************************************************************/
+//extern
+UINT8 BTM_BleMaxMultiAdvInstanceCount(void);
+
+/*******************************************************************************
+**
+** Function BTM_BleSetConnectableMode
+**
+** Description This function is called to set BLE connectable mode for a
+** peripheral device.
+**
+** Parameters connectable_mode: directed connectable mode, or non-directed.It can
+** be BTM_BLE_CONNECT_EVT, BTM_BLE_CONNECT_DIR_EVT or
+** BTM_BLE_CONNECT_LO_DUTY_DIR_EVT
+**
+** Returns BTM_ILLEGAL_VALUE if controller does not support BLE.
+** BTM_SUCCESS is status set successfully; otherwise failure.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleSetConnectableMode(tBTM_BLE_CONN_MODE connectable_mode);
+
+/*******************************************************************************
+**
+** Function BTM_BleTurnOnPrivacyOnRemote
+**
+** Description This function is called to enable or disable the privacy on the
+** remote device.
+**
+** Parameters bd_addr: remote device address.
+** privacy_on: TRUE to enable it; FALSE to disable it.
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr,
+ BOOLEAN privacy_on);
+
+/*******************************************************************************
+**
+** Function BTM_BleUpdateAdvWhitelist
+**
+** Description Add or remove device from advertising white list
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
+
+/*******************************************************************************
+**
+** Function BTM_BleClearWhitelist
+**
+** Description Clear all white list
+**
+** Returns void
+**
+*******************************************************************************/
+void BTM_BleClearWhitelist(tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
+
+/*******************************************************************************
+**
+** Function BTM_BleUpdateAdvFilterPolicy
+**
+** Description This function update the filter policy of advertiser.
+**
+** Parameter adv_policy: advertising filter policy
+**
+** Return void
+*******************************************************************************/
+//extern
+void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy);
+
+/*******************************************************************************
+**
+** Function BTM_BleReceiverTest
+**
+** Description This function is called to start the LE Receiver test
+**
+** Parameter rx_freq - Frequency Range
+** p_cmd_cmpl_cback - Command Complete callback
+**
+*******************************************************************************/
+void BTM_BleReceiverTest(UINT8 rx_freq, tBTM_CMPL_CB *p_cmd_cmpl_cback);
+
+
+/*******************************************************************************
+**
+** Function BTM_BleTransmitterTest
+**
+** Description This function is called to start the LE Transmitter test
+**
+** Parameter tx_freq - Frequency Range
+** test_data_len - Length in bytes of payload data in each packet
+** packet_payload - Pattern to use in the payload
+** p_cmd_cmpl_cback - Command Complete callback
+**
+*******************************************************************************/
+void BTM_BleTransmitterTest(UINT8 tx_freq, UINT8 test_data_len,
+ UINT8 packet_payload, tBTM_CMPL_CB *p_cmd_cmpl_cback);
+
+/*******************************************************************************
+**
+** Function BTM_BleTestEnd
+**
+** Description This function is called to stop the in-progress TX or RX test
+**
+** Parameter p_cmd_cmpl_cback - Command complete callback
+**
+*******************************************************************************/
+void BTM_BleTestEnd(tBTM_CMPL_CB *p_cmd_cmpl_cback);
+
+/*******************************************************************************
+**
+** Function BTM_UseLeLink
+**
+** Description This function is to select the underneath physical link to use.
+**
+** Returns TRUE to use LE, FALSE use BR/EDR.
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTM_BleStackEnable
+**
+** Description Enable/Disable BLE functionality on stack regarless controller
+** capability.
+**
+** Parameters: enable: TRUE to enable, FALSE to disable.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable);
+
+/*******************************************************************************
+**
+** Function BTM_GetLeSecurityState
+**
+** Description This function is called to get security mode 1 flags and
+** encryption key size for LE peer.
+**
+** Returns BOOLEAN TRUE if LE device is found, FALSE otherwise.
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_GetLeSecurityState (BD_ADDR bd_addr,
+ UINT8 *p_le_dev_sec_flags,
+ UINT8 *p_le_key_size);
+
+/*******************************************************************************
+**
+** Function BTM_BleSecurityProcedureIsRunning
+**
+** Description This function indicates if LE security procedure is
+** currently running with the peer.
+**
+** Returns BOOLEAN TRUE if security procedure is running, FALSE otherwise.
+**
+*******************************************************************************/
+//extern
+BOOLEAN BTM_BleSecurityProcedureIsRunning (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTM_BleGetSupportedKeySize
+**
+** Description This function gets the maximum encryption key size in bytes
+** the local device can suport.
+** record.
+**
+** Returns the key size or 0 if the size can't be retrieved.
+**
+*******************************************************************************/
+//extern
+UINT8 BTM_BleGetSupportedKeySize (BD_ADDR bd_addr);
+
+/*******************************************************************************/
+/* Multi ADV API */
+/*******************************************************************************
+**
+** Function BTM_BleEnableAdvInstance
+**
+** Description This function enable a Multi-ADV instance with the specified
+** adv parameters
+**
+** Parameters p_params: pointer to the adv parameter structure, set as default
+** adv parameter when the instance is enabled.
+** p_cback: callback function for the adv instance.
+** p_ref: reference data attach to the adv instance to be enabled.
+**
+** Returns status
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params,
+ tBTM_BLE_MULTI_ADV_CBACK *p_cback,
+ void *p_ref);
+
+/*******************************************************************************
+**
+** Function BTM_BleUpdateAdvInstParam
+**
+** Description This function update a Multi-ADV instance with the specififed
+** adv parameters.
+**
+** Parameters inst_id: adv instance ID
+** p_params: pointer to the adv parameter structure.
+**
+** Returns status
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params);
+
+/*******************************************************************************
+**
+** Function BTM_BleCfgAdvInstData
+**
+** Description This function configure a Multi-ADV instance with the specified
+** adv data or scan response data.
+**
+** Parameters inst_id: adv instance ID
+** is_scan_rsp: is this scacn response, if no set as adv data.
+** data_mask: adv data mask.
+** p_data: pointer to the adv data structure.
+**
+** Returns status
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
+ tBTM_BLE_AD_MASK data_mask,
+ tBTM_BLE_ADV_DATA *p_data);
+
+/*******************************************************************************
+**
+** Function BTM_BleDisableAdvInstance
+**
+** Description This function disable a Multi-ADV instance.
+**
+** Parameters inst_id: adv instance ID
+**
+** Returns status
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id);
+
+/*******************************************************************************
+**
+** Function BTM_BleAdvFilterParamSetup
+**
+** Description This function is called to setup the adv data payload filter
+** condition.
+**
+** Parameters p_target: enabble the filter condition on a target device; if NULL
+** enable the generic scan condition.
+** enable: enable or disable the filter condition
+**
+** Returns void
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleAdvFilterParamSetup(int action,
+ tBTM_BLE_PF_FILT_INDEX filt_index,
+ tBTM_BLE_PF_FILT_PARAMS *p_filt_params,
+ tBLE_BD_ADDR *p_target, tBTM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
+ tBTM_BLE_REF_VALUE ref_value);
+
+/*******************************************************************************
+**
+** Function BTM_BleCfgFilterCondition
+**
+** Description This function is called to configure the adv data payload filter
+** condition.
+**
+** Parameters action: to read/write/clear
+** cond_type: filter condition type.
+** p_cond: filter condition paramter
+**
+** Returns tBTM_STATUS
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP action,
+ tBTM_BLE_PF_COND_TYPE cond_type,
+ tBTM_BLE_PF_FILT_INDEX filt_index,
+ tBTM_BLE_PF_COND_PARAM *p_cond,
+ tBTM_BLE_PF_CFG_CBACK *p_cmpl_cback,
+ tBTM_BLE_REF_VALUE ref_value);
+
+/*******************************************************************************
+**
+** Function BTM_BleEnableDisableFilterFeature
+**
+** Description This function is called to enable or disable the APCF feature
+**
+** Parameters enable - TRUE - enables the APCF, FALSE - disables the APCF
+** ref_value - Ref value
+**
+** Returns tBTM_STATUS
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable,
+ tBTM_BLE_PF_STATUS_CBACK *p_stat_cback,
+ tBTM_BLE_REF_VALUE ref_value);
+
+/*******************************************************************************
+**
+** Function BTM_BleGetEnergyInfo
+**
+** Description This function obtains the energy info
+**
+** Parameters p_ener_cback - Callback pointer
+**
+** Returns status
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback);
+
+/*******************************************************************************
+**
+** Function BTM_SetBleDataLength
+**
+** Description This function is called to set maximum BLE transmission packet size
+**
+** Returns BTM_SUCCESS if success; otherwise failed.
+**
+*******************************************************************************/
+//extern
+tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length);
+
+/*******************************************************************************
+**
+** Function BTM_UpdateBleDuplicateExceptionalList
+**
+** Description This function is called to update duplicate scan exceptional list.
+**
+** Parameters: subcode: add, remove or clean duplicate scan exceptional list.
+** type: device info type
+** device_info: device information
+** update_exceptional_list_cmp_cb: complete callback
+**
+** Returns status
+**
+*******************************************************************************/
+
+tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info, tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb);
+
+/*******************************************************************************
+**
+** Function BTM_GetCurrentConnParams
+**
+** Description This function is called to read the current connection parameters
+** of the device
+**
+** Returns TRUE or FALSE
+**
+*******************************************************************************/
+
+BOOLEAN BTM_GetCurrentConnParams(BD_ADDR bda, uint16_t *interval, uint16_t *latency, uint16_t *timeout);
+
+/*******************************************************************************
+**
+** Function BTM_Ble_Authorization
+**
+** Description This function is used to authorize a specified device
+**
+** Returns TRUE or FALSE
+**
+*******************************************************************************/
+BOOLEAN BTM_Ble_Authorization(BD_ADDR bd_addr, BOOLEAN authorize);
+
+/*******************************************************************************
+**
+** Function BTM_BleClearAdv
+**
+** Description This function is called to clear legacy advertising
+**
+** Parameter p_clear_adv_cback - Command complete callback
+**
+*******************************************************************************/
+BOOLEAN BTM_BleClearAdv(tBTM_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback);
+/*
+#ifdef __cplusplus
+}
+#endif
+*/
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+void BTM_BleGapRegisterCallback(tBTM_BLE_5_HCI_CBACK cb);
+
+tBTM_STATUS BTM_BleReadPhy(BD_ADDR bd_addr, UINT8 *tx_phy, UINT8 *rx_phy);
+
+tBTM_STATUS BTM_BleSetPreferDefaultPhy(UINT8 tx_phy_mask, UINT8 rx_phy_mask);
+
+tBTM_STATUS BTM_BleSetPreferPhy(BD_ADDR bd_addr, UINT8 all_phys, UINT8 tx_phy_mask,
+ UINT8 rx_phy_mask, UINT16 phy_options);
+
+tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr);
+
+tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PARAMS *params);
+
+tBTM_STATUS BTM_BleConfigExtendedAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 len, UINT8 *data);
+
+tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_adv);
+
+tBTM_STATUS BTM_BleExtAdvSetRemove(UINT8 instance);
+
+tBTM_STATUS BTM_BleExtAdvSetClear(void);
+
+tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Params *params);
+
+tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data, BOOLEAN only_update_did);
+
+tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, UINT8 enable);
+
+tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params);
+
+tBTM_STATUS BTM_BlePeriodicAdvSyncCancel(void);
+
+tBTM_STATUS BTM_BlePeriodicAdvSyncTerm(UINT16 sync_handle);
+
+tBTM_STATUS BTM_BlePeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid);
+
+tBTM_STATUS BTM_BlePeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid);
+
+tBTM_STATUS BTM_BlePeriodicAdvClearDev(void);
+
+tBTM_STATUS BTM_BleSetExtendedScanParams(tBTM_BLE_EXT_SCAN_PARAMS *params);
+
+tBTM_STATUS BTM_BleExtendedScan(BOOLEAN enable, UINT16 duration, UINT16 period);
+
+void BTM_BleSetPreferExtenedConnParams(BD_ADDR bd_addr, tBTM_EXT_CONN_PARAMS *params);
+
+void BTM_BleEnhancedReceiverTest(UINT8 rx_freq, UINT8 phy, UINT8 modulation_index, tBTM_CMPL_CB *p_cmd_cmpl_cback);
+
+void BTM_BleEnhancedTransmitterTest(UINT8 tx_freq, UINT8 test_data_len, UINT8 packet_payload, UINT8 phy, tBTM_CMPL_CB *p_cmd_cmpl_cback);
+
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+
+#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+void BTM_BlePeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable);
+
+void BTM_BlePeriodicAdvSyncTrans(BD_ADDR bd_addr, UINT16 service_data, UINT16 sync_handle);
+
+void BTM_BlePeriodicAdvSetInfoTrans(BD_ADDR bd_addr, UINT16 service_data, UINT8 adv_handle);
+
+void BTM_BleSetPeriodicAdvSyncTransParams(BD_ADDR bd_addr, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type);
+#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/btu.h b/lib/bt/host/bluedroid/stack/include/stack/btu.h
new file mode 100644
index 00000000..8df767b4
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/btu.h
@@ -0,0 +1,311 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * this file contains the main Bluetooth Upper Layer definitions. The Broadcom
+ * implementations of L2CAP RFCOMM, SDP and the BTIf run as one GKI task. The
+ * btu_task switches between them.
+ *
+ ******************************************************************************/
+
+#ifndef BTU_H
+#define BTU_H
+
+#include "common/bt_target.h"
+#include "common/bt_defs.h"
+#include "osi/thread.h"
+
+// HACK(zachoverflow): temporary dark magic
+#define BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK 0x1700 // didn't look used in bt_types...here goes nothing
+typedef struct {
+ void (*callback)(BT_HDR *);
+} post_to_task_hack_t;
+
+typedef struct {
+ void (*callback)(BT_HDR *);
+ BT_HDR *response;
+ void *context;
+} command_complete_hack_t;
+
+typedef struct {
+ void (*callback)(BT_HDR *);
+ uint8_t status;
+ BT_HDR *command;
+ void *context;
+} command_status_hack_t;
+
+/* callbacks
+*/
+typedef void (*tBTU_TIMER_CALLBACK)(TIMER_LIST_ENT *p_tle);
+typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr);
+
+
+/* Define the timer types maintained by BTU
+*/
+#define BTU_TTYPE_BTM_DEV_CTL 1
+#define BTU_TTYPE_L2CAP_LINK 2
+#define BTU_TTYPE_L2CAP_CHNL 3
+#define BTU_TTYPE_L2CAP_HOLD 4
+#define BTU_TTYPE_SDP 5
+#define BTU_TTYPE_BTM_SCO 6
+#define BTU_TTYPE_BTM_ACL 9
+#define BTU_TTYPE_BTM_RMT_NAME 10
+#define BTU_TTYPE_RFCOMM_MFC 11
+#define BTU_TTYPE_RFCOMM_PORT 12
+#define BTU_TTYPE_TCS_L2CAP 13
+#define BTU_TTYPE_TCS_CALL 14
+#define BTU_TTYPE_TCS_WUG 15
+#define BTU_TTYPE_AUTO_SYNC 16
+#define BTU_TTYPE_CTP_RECON 17
+#define BTU_TTYPE_CTP_T100 18
+#define BTU_TTYPE_CTP_GUARD 19
+#define BTU_TTYPE_CTP_DETACH 20
+
+#define BTU_TTYPE_SPP_CONN_RETRY 21
+#define BTU_TTYPE_USER_FUNC 22
+
+#define BTU_TTYPE_FTP_DISC 25
+#define BTU_TTYPE_OPP_DISC 26
+
+#define BTU_TTYPE_CTP_TL_DISCVY 28
+#define BTU_TTYPE_IPFRAG_TIMER 29
+#define BTU_TTYPE_HSP2_AT_CMD_TO 30
+#define BTU_TTYPE_HSP2_REPEAT_RING 31
+
+#define BTU_TTYPE_CTP_GW_INIT 32
+#define BTU_TTYPE_CTP_GW_CONN 33
+#define BTU_TTYPE_CTP_GW_IDLE 35
+
+#define BTU_TTYPE_ICP_L2CAP 36
+#define BTU_TTYPE_ICP_T100 37
+
+#define BTU_TTYPE_HSP2_WAIT_OK 38
+
+/* HCRP Timers */
+#define BTU_TTYPE_HCRP_NOTIF_REG 39
+#define BTU_TTYPE_HCRP_PROTO_RSP 40
+#define BTU_TTYPE_HCRP_CR_GRANT 41
+#define BTU_TTYPE_HCRP_CR_CHECK 42
+#define BTU_TTYPE_HCRP_W4_CLOSE 43
+
+/* HCRPM Timers */
+#define BTU_TTYPE_HCRPM_NOTIF_REG 44
+#define BTU_TTYPE_HCRPM_NOTIF_KEEP 45
+#define BTU_TTYPE_HCRPM_API_RSP 46
+#define BTU_TTYPE_HCRPM_W4_OPEN 47
+#define BTU_TTYPE_HCRPM_W4_CLOSE 48
+
+/* BNEP Timers */
+#define BTU_TTYPE_BNEP 50
+
+#define BTU_TTYPE_HSP2_SDP_FAIL_TO 55
+#define BTU_TTYPE_HSP2_SDP_RTRY_TO 56
+
+/* BTU internal */
+#define BTU_TTYPE_AVDT_SCB_DELAY_RPT 60
+#define BTU_TTYPE_AVDT_CCB_RET 61
+#define BTU_TTYPE_AVDT_CCB_RSP 62
+#define BTU_TTYPE_AVDT_CCB_IDLE 63
+#define BTU_TTYPE_AVDT_SCB_TC 64
+
+#define BTU_TTYPE_HID_DEV_REPAGE_TO 65
+#define BTU_TTYPE_HID_HOST_REPAGE_TO 66
+
+#define BTU_TTYPE_HSP2_DELAY_CKPD_RCV 67
+
+#define BTU_TTYPE_SAP_TO 68
+
+/* BPP Timer */
+#define BTU_TTYPE_BPP_REF_CHNL 72
+
+/* LP HC idle Timer */
+#define BTU_TTYPE_LP_HC_IDLE_TO 74
+
+/* Patch RAM Timer */
+#define BTU_TTYPE_PATCHRAM_TO 75
+
+/* eL2CAP Info Request and other proto cmds timer */
+#define BTU_TTYPE_L2CAP_FCR_ACK 78
+#define BTU_TTYPE_L2CAP_INFO 79
+/* L2CAP update connection parameters timer */
+#define BTU_TTYPE_L2CAP_UPDA_CONN_PARAMS 80
+
+#define BTU_TTYPE_MCA_CCB_RSP 98
+
+/* BTU internal timer for BLE activity */
+#define BTU_TTYPE_BLE_INQUIRY 99
+#define BTU_TTYPE_BLE_GAP_LIM_DISC 100
+#define BTU_TTYPE_ATT_WAIT_FOR_RSP 101
+#define BTU_TTYPE_SMP_PAIRING_CMD 102
+#define BTU_TTYPE_BLE_RANDOM_ADDR 103
+#define BTU_TTYPE_ATT_WAIT_FOR_APP_RSP 104
+#define BTU_TTYPE_ATT_WAIT_FOR_IND_ACK 105
+
+#define BTU_TTYPE_BLE_GAP_FAST_ADV 106
+#define BTU_TTYPE_BLE_OBSERVE 107
+
+#define BTU_TTYPE_UCD_TO 108
+#define BTU_TTYPE_BLE_SCAN 109
+
+/* BTU internal timer for QOS */
+#define BTU_TTYPE_BTM_QOS 110
+
+/* BTU internal timer for set page timeout*/
+#define BTU_TTYPE_BTM_SET_PAGE_TO 111
+
+/* BTU Task Signal */
+typedef enum {
+ SIG_BTU_START_UP = 0,
+ SIG_BTU_HCI_MSG,
+ SIG_BTU_BTA_MSG,
+ SIG_BTU_BTA_ALARM,
+ SIG_BTU_GENERAL_ALARM,
+ SIG_BTU_ONESHOT_ALARM,
+ SIG_BTU_L2CAP_ALARM,
+ SIG_BTU_HCI_ADV_RPT_MSG,
+ SIG_BTU_NUM,
+} SIG_BTU_t;
+
+/* This is the inquiry response information held by BTU, and available
+** to applications.
+*/
+typedef struct {
+ BD_ADDR remote_bd_addr;
+ UINT8 page_scan_rep_mode;
+ UINT8 page_scan_per_mode;
+ UINT8 page_scan_mode;
+ DEV_CLASS dev_class;
+ UINT16 clock_offset;
+} tBTU_INQ_INFO;
+
+
+
+#define BTU_MAX_REG_TIMER (2) /* max # timer callbacks which may register */
+#define BTU_MAX_REG_EVENT (6) /* max # event callbacks which may register */
+#define BTU_DEFAULT_DATA_SIZE (0x2a0)
+
+#if (BLE_INCLUDED == TRUE)
+#define BTU_DEFAULT_BLE_DATA_SIZE (27)
+#endif
+
+/* structure to hold registered timers */
+typedef struct {
+ TIMER_LIST_ENT *p_tle; /* timer entry */
+ tBTU_TIMER_CALLBACK timer_cb; /* callback triggered when timer expires */
+} tBTU_TIMER_REG;
+
+/* structure to hold registered event callbacks */
+typedef struct {
+ UINT16 event_range; /* start of event range */
+ tBTU_EVENT_CALLBACK event_cb; /* callback triggered when event is in range */
+} tBTU_EVENT_REG;
+
+#define NFC_MAX_LOCAL_CTRLS 0
+
+/* the index to BTU command queue array */
+#define NFC_CONTROLLER_ID (1)
+#define BTU_MAX_LOCAL_CTRLS (1 + NFC_MAX_LOCAL_CTRLS) /* only BR/EDR */
+
+/* Define structure holding BTU variables
+*/
+typedef struct {
+ tBTU_TIMER_REG timer_reg[BTU_MAX_REG_TIMER];
+ tBTU_EVENT_REG event_reg[BTU_MAX_REG_EVENT];
+
+ BOOLEAN reset_complete; /* TRUE after first ack from device received */
+ UINT8 trace_level; /* Trace level for HCI layer */
+} tBTU_CB;
+
+/*
+#ifdef __cplusplus
+extern "C" {
+#endif
+*/
+/* Global BTU data */
+#if BTU_DYNAMIC_MEMORY == FALSE
+extern tBTU_CB btu_cb;
+#else
+extern tBTU_CB *btu_cb_ptr;
+#define btu_cb (*btu_cb_ptr)
+#endif
+
+extern const BD_ADDR BT_BD_ANY;
+
+/* Functions provided by btu_task.c
+************************************
+*/
+void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
+void btu_stop_timer (TIMER_LIST_ENT *p_tle);
+void btu_free_timer (TIMER_LIST_ENT *p_tle);
+void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
+void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle);
+
+void btu_uipc_rx_cback(BT_HDR *p_msg);
+
+/*
+** Quick Timer
+*/
+#if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0)
+void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
+void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle);
+void btu_free_quick_timer (TIMER_LIST_ENT *p_tle);
+void btu_process_quick_timer_evt (void);
+#endif
+
+#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
+void btu_check_bt_sleep (void);
+#endif
+
+/* Functions provided by btu_hcif.c
+************************************
+*/
+void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf);
+void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg);
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+UINT8 btu_hcif_send_cmd_sync (UINT8 controller_id, BT_HDR *p_buf);
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+void btu_hcif_send_host_rdy_for_data(void);
+void btu_hcif_cmd_timeout (UINT8 controller_id);
+
+/* Functions provided by btu_core.c
+************************************
+*/
+void btu_init_core(void);
+void btu_free_core(void);
+
+void BTU_StartUp(void);
+void BTU_ShutDown(void);
+
+void btu_task_start_up(void *param);
+void btu_task_shut_down(void);
+
+UINT16 BTU_BleAclPktSize(void);
+
+bool btu_task_post(uint32_t sig, void *param, uint32_t timeout);
+
+int get_btu_work_queue_size(void);
+
+osi_thread_t *btu_get_current_thread(void);
+/*
+#ifdef __cplusplus
+}
+#endif
+*/
+
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/dyn_mem.h b/lib/bt/host/bluedroid/stack/include/stack/dyn_mem.h
new file mode 100644
index 00000000..fa1ed498
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/dyn_mem.h
@@ -0,0 +1,234 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2002-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+#ifndef DYN_MEM_H
+#define DYN_MEM_H
+
+#include "common/bluedroid_user_config.h"
+
+#if UC_BT_BLE_DYNAMIC_ENV_MEMORY
+#define BTU_DYNAMIC_MEMORY TRUE
+#define BTM_DYNAMIC_MEMORY TRUE
+#define L2C_DYNAMIC_MEMORY TRUE
+#define GATT_DYNAMIC_MEMORY TRUE
+#define SMP_DYNAMIC_MEMORY TRUE
+#define BTA_DYNAMIC_MEMORY TRUE
+#define SDP_DYNAMIC_MEMORY TRUE
+#define GAP_DYNAMIC_MEMORY TRUE
+#define RFC_DYNAMIC_MEMORY TRUE
+#define TCS_DYNAMIC_MEMORY TRUE
+#define BNEP_DYNAMIC_MEMORY TRUE
+#define AVDT_DYNAMIC_MEMORY TRUE
+#define AVCT_DYNAMIC_MEMORY TRUE
+#define MCA_DYNAMIC_MEMORY TRUE
+#define A2D_DYNAMIC_MEMORY TRUE
+#define VDP_DYNAMIC_MEMORY TRUE
+#define AVRC_DYNAMIC_MEMORY TRUE
+#define BIP_DYNAMIC_MEMORY TRUE
+#define BPP_DYNAMIC_MEMORY TRUE
+#define CTP_DYNAMIC_MEMORY TRUE
+#define FTP_DYNAMIC_MEMORY TRUE
+#define HCRP_DYNAMIC_MEMORY TRUE
+#define HFP_DYNAMIC_MEMORY TRUE
+#define HID_DYNAMIC_MEMORY TRUE
+#define HSP2_DYNAMIC_MEMORY TRUE
+#define ICP_DYNAMIC_MEMORY TRUE
+#define OPP_DYNAMIC_MEMORY TRUE
+#define PAN_DYNAMIC_MEMORY TRUE
+#define SPP_DYNAMIC_MEMORY TRUE
+#define SLIP_DYNAMIC_MEMORY TRUE
+#define LLCP_DYNAMIC_MEMORY TRUE
+#define BTC_SBC_DEC_DYNAMIC_MEMORY TRUE
+
+#else /* #if UC_BT_BLE_DYNAMIC_ENV_MEMORY */
+#define BTU_DYNAMIC_MEMORY FALSE
+#define BTM_DYNAMIC_MEMORY FALSE
+#define L2C_DYNAMIC_MEMORY FALSE
+#define GATT_DYNAMIC_MEMORY FALSE
+#define SMP_DYNAMIC_MEMORY FALSE
+#define BTA_DYNAMIC_MEMORY FALSE
+#define SDP_DYNAMIC_MEMORY FALSE
+#define GAP_DYNAMIC_MEMORY FALSE
+#define RFC_DYNAMIC_MEMORY FALSE
+#define TCS_DYNAMIC_MEMORY FALSE
+#define BNEP_DYNAMIC_MEMORY FALSE
+#define AVDT_DYNAMIC_MEMORY FALSE
+#define AVCT_DYNAMIC_MEMORY FALSE
+#define MCA_DYNAMIC_MEMORY FALSE
+#define A2D_DYNAMIC_MEMORY FALSE
+#define VDP_DYNAMIC_MEMORY FALSE
+#define AVRC_DYNAMIC_MEMORY FALSE
+#define BIP_DYNAMIC_MEMORY FALSE
+#define BPP_DYNAMIC_MEMORY FALSE
+#define CTP_DYNAMIC_MEMORY FALSE
+#define FTP_DYNAMIC_MEMORY FALSE
+#define HCRP_DYNAMIC_MEMORY FALSE
+#define HFP_DYNAMIC_MEMORY FALSE
+#define HID_DYNAMIC_MEMORY FALSE
+#define HSP2_DYNAMIC_MEMORY FALSE
+#define ICP_DYNAMIC_MEMORY FALSE
+#define OPP_DYNAMIC_MEMORY FALSE
+#define PAN_DYNAMIC_MEMORY FALSE
+#define SPP_DYNAMIC_MEMORY FALSE
+#define SLIP_DYNAMIC_MEMORY FALSE
+#define LLCP_DYNAMIC_MEMORY FALSE
+#define BTC_SBC_DEC_DYNAMIC_MEMORY FALSE
+
+#endif /* #if UC_BT_BLE_DYNAMIC_ENV_MEMORY */
+
+
+/****************************************************************************
+** Define memory usage for each CORE component (if not defined in bdroid_buildcfg.h)
+** The default for each component is to use static memory allocations.
+*/
+#ifndef BTU_DYNAMIC_MEMORY
+#define BTU_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef BTM_DYNAMIC_MEMORY
+#define BTM_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef SDP_DYNAMIC_MEMORY
+#define SDP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef GAP_DYNAMIC_MEMORY
+#define GAP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef L2C_DYNAMIC_MEMORY
+#define L2C_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef RFC_DYNAMIC_MEMORY
+#define RFC_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef TCS_DYNAMIC_MEMORY
+#define TCS_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef BNEP_DYNAMIC_MEMORY
+#define BNEP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef AVDT_DYNAMIC_MEMORY
+#define AVDT_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef AVCT_DYNAMIC_MEMORY
+#define AVCT_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef MCA_DYNAMIC_MEMORY
+#define MCA_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef GATT_DYNAMIC_MEMORY
+#define GATT_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef SMP_DYNAMIC_MEMORY
+#define SMP_DYNAMIC_MEMORY FALSE
+#endif
+
+/****************************************************************************
+** Define memory usage for each PROFILE component (if not defined in bdroid_buildcfg.h)
+** The default for each component is to use static memory allocations.
+*/
+#ifndef A2D_DYNAMIC_MEMORY
+#define A2D_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef VDP_DYNAMIC_MEMORY
+#define VDP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef AVRC_DYNAMIC_MEMORY
+#define AVRC_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef BIP_DYNAMIC_MEMORY
+#define BIP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef BPP_DYNAMIC_MEMORY
+#define BPP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef CTP_DYNAMIC_MEMORY
+#define CTP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef FTP_DYNAMIC_MEMORY
+#define FTP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef HCRP_DYNAMIC_MEMORY
+#define HCRP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef HFP_DYNAMIC_MEMORY
+#define HFP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef HID_DYNAMIC_MEMORY
+#define HID_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef HSP2_DYNAMIC_MEMORY
+#define HSP2_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef ICP_DYNAMIC_MEMORY
+#define ICP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef OPP_DYNAMIC_MEMORY
+#define OPP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef PAN_DYNAMIC_MEMORY
+#define PAN_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef SPP_DYNAMIC_MEMORY
+#define SPP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef SLIP_DYNAMIC_MEMORY
+#define SLIP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef LLCP_DYNAMIC_MEMORY
+#define LLCP_DYNAMIC_MEMORY FALSE
+#endif
+
+/****************************************************************************
+** Define memory usage for BTA and BTC (if not defined in bdroid_buildcfg.h)
+** The default for each component is to use static memory allocations.
+*/
+#ifndef BTA_DYNAMIC_MEMORY
+#define BTA_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef BTC_DYNAMIC_MEMORY
+#define BTC_DYNAMIC_MEMORY FALSE
+#endif
+
+#endif /* #ifdef DYN_MEM_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/gap_api.h b/lib/bt/host/bluedroid/stack/include/stack/gap_api.h
new file mode 100644
index 00000000..62062d2f
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/gap_api.h
@@ -0,0 +1,403 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2009-2013 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef GAP_API_H
+#define GAP_API_H
+
+#include "stack/sdpdefs.h"
+#include "stack/profiles_api.h"
+#include "stack/btm_api.h"
+#include "stack/l2c_api.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+/*** GAP Error and Status Codes ***/
+#define GAP_UNSUPPORTED (GAP_ERR_GRP + 0x01) /* Unsupported call */
+#define GAP_EOINQDB (GAP_ERR_GRP + 0x02) /* End of inquiry database marker */
+#define GAP_ERR_BUSY (GAP_ERR_GRP + 0x03) /* The requested function was busy */
+#define GAP_ERR_NO_CTRL_BLK (GAP_ERR_GRP + 0x04) /* No control blocks available */
+#define GAP_ERR_STARTING_CMD (GAP_ERR_GRP + 0x05) /* Error occurred while initiating the command */
+#define GAP_NO_BDADDR_REC (GAP_ERR_GRP + 0x06) /* No Inquiry DB record for BD_ADDR */
+#define GAP_ERR_ILL_MODE (GAP_ERR_GRP + 0x07) /* An illegal mode parameter was detected */
+#define GAP_ERR_ILL_INQ_TIME (GAP_ERR_GRP + 0x08) /* An illegal time parameter was detected */
+#define GAP_ERR_ILL_PARM (GAP_ERR_GRP + 0x09) /* An illegal parameter was detected */
+#define GAP_ERR_REM_NAME (GAP_ERR_GRP + 0x0a) /* Error starting the remote device name request */
+#define GAP_CMD_INITIATED (GAP_ERR_GRP + 0x0b) /* The GAP command was started (result pending) */
+#define GAP_DEVICE_NOT_UP (GAP_ERR_GRP + 0x0c) /* The device was not up; the request was not executed */
+#define GAP_BAD_BD_ADDR (GAP_ERR_GRP + 0x0d) /* The bd addr passed in was not found or invalid */
+
+#define GAP_ERR_BAD_HANDLE (GAP_ERR_GRP + 0x0e) /* Bad GAP handle */
+#define GAP_ERR_BUF_OFFSET (GAP_ERR_GRP + 0x0f) /* Buffer offset invalid */
+#define GAP_ERR_BAD_STATE (GAP_ERR_GRP + 0x10) /* Connection is in invalid state */
+#define GAP_NO_DATA_AVAIL (GAP_ERR_GRP + 0x11) /* No data available */
+#define GAP_ERR_CONGESTED (GAP_ERR_GRP + 0x12) /* BT stack is congested */
+#define GAP_ERR_SECURITY (GAP_ERR_GRP + 0x13) /* Security failed */
+
+#define GAP_ERR_PROCESSING (GAP_ERR_GRP + 0x14) /* General error processing BTM request */
+#define GAP_ERR_TIMEOUT (GAP_ERR_GRP + 0x15) /* Timeout occurred while processing cmd */
+#define GAP_EVT_CONN_OPENED 0x0100
+#define GAP_EVT_CONN_CLOSED 0x0101
+#define GAP_EVT_CONN_DATA_AVAIL 0x0102
+#define GAP_EVT_CONN_CONGESTED 0x0103
+#define GAP_EVT_CONN_UNCONGESTED 0x0104
+/* Values for 'chan_mode_mask' field */
+/* GAP_ConnOpen() - optional channels to negotiate */
+#define GAP_FCR_CHAN_OPT_BASIC L2CAP_FCR_CHAN_OPT_BASIC
+#define GAP_FCR_CHAN_OPT_ERTM L2CAP_FCR_CHAN_OPT_ERTM
+#define GAP_FCR_CHAN_OPT_STREAM L2CAP_FCR_CHAN_OPT_STREAM
+/*** used in connection variables and functions ***/
+#define GAP_INVALID_HANDLE 0xFFFF
+
+/* This is used to change the criteria for AMP */
+#define GAP_PROTOCOL_ID (UUID_PROTOCOL_UDP)
+
+
+#ifndef GAP_PREFER_CONN_INT_MAX
+#define GAP_PREFER_CONN_INT_MAX BTM_BLE_CONN_INT_MIN
+#endif
+
+#ifndef GAP_PREFER_CONN_INT_MIN
+#define GAP_PREFER_CONN_INT_MIN BTM_BLE_CONN_INT_MIN
+#endif
+
+#ifndef GAP_PREFER_CONN_LATENCY
+#define GAP_PREFER_CONN_LATENCY 0
+#endif
+
+#ifndef GAP_PREFER_CONN_SP_TOUT
+#define GAP_PREFER_CONN_SP_TOUT 2000
+#endif
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+/*
+** Callback function for connection services
+*/
+typedef void (tGAP_CONN_CALLBACK) (UINT16 gap_handle, UINT16 event);
+
+/*
+** Define the callback function prototypes. Parameters are specific
+** to each event and are described below
+*/
+typedef void (tGAP_CALLBACK) (UINT16 event, void *p_data);
+
+
+/* Definition of the GAP_FindAddrByName results structure */
+typedef struct {
+ UINT16 status;
+ BD_ADDR bd_addr;
+ tBTM_BD_NAME devname;
+} tGAP_FINDADDR_RESULTS;
+
+typedef struct {
+ UINT16 int_min;
+ UINT16 int_max;
+ UINT16 latency;
+ UINT16 sp_tout;
+} tGAP_BLE_PREF_PARAM;
+
+typedef union {
+ tGAP_BLE_PREF_PARAM conn_param;
+ BD_ADDR reconn_bda;
+ UINT16 icon;
+ UINT8 *p_dev_name;
+ UINT8 addr_resolution;
+
+} tGAP_BLE_ATTR_VALUE;
+
+typedef void (tGAP_BLE_CMPL_CBACK)(BOOLEAN status, BD_ADDR addr, UINT16 length, char *p_name);
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+
+/*** Functions for L2CAP connection interface ***/
+
+/*******************************************************************************
+**
+** Function GAP_ConnOpen
+**
+** Description This function is called to open a generic L2CAP connection.
+**
+** Returns handle of the connection if successful, else GAP_INVALID_HANDLE
+**
+*******************************************************************************/
+extern UINT16 GAP_ConnOpen (const char *p_serv_name, UINT8 service_id, BOOLEAN is_server,
+ BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg,
+ tL2CAP_ERTM_INFO *ertm_info,
+ UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb);
+
+/*******************************************************************************
+**
+** Function GAP_ConnClose
+**
+** Description This function is called to close a connection.
+**
+** Returns BT_PASS - closed OK
+** GAP_ERR_BAD_HANDLE - invalid handle
+**
+*******************************************************************************/
+extern UINT16 GAP_ConnClose (UINT16 gap_handle);
+
+/*******************************************************************************
+**
+** Function GAP_ConnReadData
+**
+** Description GKI buffer unaware application will call this function
+** after receiving GAP_EVT_RXDATA event. A data copy is made
+** into the receive buffer parameter.
+**
+** Returns BT_PASS - data read
+** GAP_ERR_BAD_HANDLE - invalid handle
+** GAP_NO_DATA_AVAIL - no data available
+**
+*******************************************************************************/
+extern UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data,
+ UINT16 max_len, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function GAP_GetRxQueueCnt
+**
+** Description This function return number of bytes on the rx queue.
+**
+** Parameters: handle - Handle returned in the GAP_ConnOpen
+** p_rx_queue_count - Pointer to return queue count in.
+**
+**
+*******************************************************************************/
+extern int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count);
+
+/*******************************************************************************
+**
+** Function GAP_ConnBTRead
+**
+** Description GKI buffer aware applications will call this function after
+** receiving an GAP_EVT_RXDATA event to process the incoming
+** data buffer.
+**
+** Returns BT_PASS - data read
+** GAP_ERR_BAD_HANDLE - invalid handle
+** GAP_NO_DATA_AVAIL - no data available
+**
+*******************************************************************************/
+extern UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf);
+
+/*******************************************************************************
+**
+** Function GAP_ConnBTWrite
+**
+** Description GKI buffer aware applications can call this function to write data
+** by passing a pointer to the GKI buffer of data.
+**
+** Returns BT_PASS - data read
+** GAP_ERR_BAD_HANDLE - invalid handle
+** GAP_ERR_BAD_STATE - connection not established
+** GAP_INVALID_BUF_OFFSET - buffer offset is invalid
+*******************************************************************************/
+extern UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf);
+
+/*******************************************************************************
+**
+** Function GAP_ConnWriteData
+**
+** Description GKI buffer unaware application will call this function
+** to send data to the connection. A data copy is made into a GKI
+** buffer.
+**
+** Returns BT_PASS - data read
+** GAP_ERR_BAD_HANDLE - invalid handle
+** GAP_ERR_BAD_STATE - connection not established
+** GAP_CONGESTION - system is congested
+**
+*******************************************************************************/
+extern UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data,
+ UINT16 max_len, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function GAP_ConnReconfig
+**
+** Description Applications can call this function to reconfigure the connection.
+**
+** Returns BT_PASS - config process started
+** GAP_ERR_BAD_HANDLE - invalid handle
+**
+*******************************************************************************/
+extern UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg);
+
+/*******************************************************************************
+**
+** Function GAP_ConnSetIdleTimeout
+**
+** Description Higher layers call this function to set the idle timeout for
+** a connection, or for all future connections. The "idle timeout"
+** is the amount of time that a connection can remain up with
+** no L2CAP channels on it. A timeout of zero means that the
+** connection will be torn down immediately when the last channel
+** is removed. A timeout of 0xFFFF means no timeout. Values are
+** in seconds.
+**
+** Returns BT_PASS - config process started
+** GAP_ERR_BAD_HANDLE - invalid handle
+**
+*******************************************************************************/
+extern UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout);
+
+/*******************************************************************************
+**
+** Function GAP_ConnGetRemoteAddr
+**
+** Description This function is called to get the remote BD address
+** of a connection.
+**
+** Returns BT_PASS - closed OK
+** GAP_ERR_BAD_HANDLE - invalid handle
+**
+*******************************************************************************/
+extern UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle);
+
+/*******************************************************************************
+**
+** Function GAP_ConnGetRemMtuSize
+**
+** Description Returns the remote device's MTU size.
+**
+** Returns UINT16 - maximum size buffer that can be transmitted to the peer
+**
+*******************************************************************************/
+extern UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle);
+
+/*******************************************************************************
+**
+** Function GAP_ConnGetL2CAPCid
+**
+** Description Returns the L2CAP channel id
+**
+** Parameters: handle - Handle of the connection
+**
+** Returns UINT16 - The L2CAP channel id
+** 0, if error
+**
+*******************************************************************************/
+extern UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle);
+
+/*******************************************************************************
+**
+** Function GAP_SetTraceLevel
+**
+** Description This function sets the trace level for GAP. If called with
+** a value of 0xFF, it simply returns the current trace level.
+**
+** Returns The new or current trace level
+**
+*******************************************************************************/
+extern UINT8 GAP_SetTraceLevel (UINT8 new_level);
+
+/*******************************************************************************
+**
+** Function GAP_Init
+**
+** Description Initializes the control blocks used by GAP.
+** This routine should not be called except once per
+** stack invocation.
+**
+** Returns status
+**
+*******************************************************************************/
+extern bt_status_t GAP_Init(void);
+
+/*******************************************************************************
+**
+** Function GAP_Deinit
+**
+** Description This function is called to deinitialize the control block
+** for this layer.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void GAP_Deinit(void);
+
+#if (BLE_INCLUDED == TRUE)
+/*******************************************************************************
+**
+** Function GAP_BleAttrDBUpdate
+**
+** Description update GAP local BLE attribute database.
+**
+** Returns Nothing
+**
+*******************************************************************************/
+extern void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value);
+
+
+/*******************************************************************************
+**
+** Function GAP_BleReadPeerPrefConnParams
+**
+** Description Start a process to read a connected peripheral's preferred
+** connection parameters
+**
+** Returns TRUE if read started, else FALSE if GAP is busy
+**
+*******************************************************************************/
+extern BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda);
+
+/*******************************************************************************
+**
+** Function GAP_BleReadPeerDevName
+**
+** Description Start a process to read a connected peripheral's device name.
+**
+** Returns TRUE if request accepted
+**
+*******************************************************************************/
+extern BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_CMPL_CBACK *p_cback);
+
+
+/*******************************************************************************
+**
+** Function GAP_BleReadPeerAddressResolutionCap
+**
+** Description Start a process to read peer address resolution capability
+**
+** Returns TRUE if request accepted
+**
+*******************************************************************************/
+extern BOOLEAN GAP_BleReadPeerAddressResolutionCap (BD_ADDR peer_bda,
+ tGAP_BLE_CMPL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function GAP_BleCancelReadPeerDevName
+**
+** Description Cancel reading a peripheral's device name.
+**
+** Returns TRUE if request accepted
+**
+*******************************************************************************/
+extern BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda);
+
+
+#endif
+
+#endif /* GAP_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/gatt_api.h b/lib/bt/host/bluedroid/stack/include/stack/gatt_api.h
new file mode 100644
index 00000000..7872e139
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/gatt_api.h
@@ -0,0 +1,1298 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+#ifndef GATT_API_H
+#define GATT_API_H
+
+#include "common/bt_target.h"
+#include "stack/gattdefs.h"
+#include "stack/btm_ble_api.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+/* Success code and error codes */
+#define GATT_SUCCESS 0x00
+#define GATT_INVALID_HANDLE 0x01
+#define GATT_READ_NOT_PERMIT 0x02
+#define GATT_WRITE_NOT_PERMIT 0x03
+#define GATT_INVALID_PDU 0x04
+#define GATT_INSUF_AUTHENTICATION 0x05
+#define GATT_REQ_NOT_SUPPORTED 0x06
+#define GATT_INVALID_OFFSET 0x07
+#define GATT_INSUF_AUTHORIZATION 0x08
+#define GATT_PREPARE_Q_FULL 0x09
+#define GATT_NOT_FOUND 0x0a
+#define GATT_NOT_LONG 0x0b
+#define GATT_INSUF_KEY_SIZE 0x0c
+#define GATT_INVALID_ATTR_LEN 0x0d
+#define GATT_ERR_UNLIKELY 0x0e
+#define GATT_INSUF_ENCRYPTION 0x0f
+#define GATT_UNSUPPORT_GRP_TYPE 0x10
+#define GATT_INSUF_RESOURCE 0x11
+#define GATT_DATABASE_OUT_OF_SYNC 0x12
+#define GATT_VALUE_NOT_ALLOWED 0x13
+
+
+#define GATT_NO_RESOURCES 0x80
+#define GATT_INTERNAL_ERROR 0x81
+#define GATT_WRONG_STATE 0x82
+#define GATT_DB_FULL 0x83
+#define GATT_BUSY 0x84
+#define GATT_ERROR 0x85
+#define GATT_CMD_STARTED 0x86
+#define GATT_ILLEGAL_PARAMETER 0x87
+#define GATT_PENDING 0x88
+#define GATT_AUTH_FAIL 0x89
+#define GATT_MORE 0x8a
+#define GATT_INVALID_CFG 0x8b
+#define GATT_SERVICE_STARTED 0x8c
+#define GATT_ENCRYPED_MITM GATT_SUCCESS
+#define GATT_ENCRYPED_NO_MITM 0x8d
+#define GATT_NOT_ENCRYPTED 0x8e
+#define GATT_CONGESTED 0x8f
+
+#define GATT_DUP_REG 0x90
+#define GATT_ALREADY_OPEN 0x91
+#define GATT_CANCEL 0x92
+
+/* 0xE0 ~ 0xFC reserved for future use */
+#define GATT_STACK_RSP 0xE0
+#define GATT_APP_RSP 0xE1
+//Error caused by customer application or stack bug
+#define GATT_UNKNOWN_ERROR 0XEF
+
+#define GATT_CCC_CFG_ERR 0xFD /* Client Characteristic Configuration Descriptor Improperly Configured */
+#define GATT_PRC_IN_PROGRESS 0xFE /* Procedure Already in progress */
+#define GATT_OUT_OF_RANGE 0xFF /* Attribute value out of range */
+
+typedef UINT8 tGATT_STATUS;
+
+
+#define GATT_RSP_ERROR 0x01
+#define GATT_REQ_MTU 0x02
+#define GATT_RSP_MTU 0x03
+#define GATT_REQ_FIND_INFO 0x04
+#define GATT_RSP_FIND_INFO 0x05
+#define GATT_REQ_FIND_TYPE_VALUE 0x06
+#define GATT_RSP_FIND_TYPE_VALUE 0x07
+#define GATT_REQ_READ_BY_TYPE 0x08
+#define GATT_RSP_READ_BY_TYPE 0x09
+#define GATT_REQ_READ 0x0A
+#define GATT_RSP_READ 0x0B
+#define GATT_REQ_READ_BLOB 0x0C
+#define GATT_RSP_READ_BLOB 0x0D
+#define GATT_REQ_READ_MULTI 0x0E
+#define GATT_RSP_READ_MULTI 0x0F
+#define GATT_REQ_READ_BY_GRP_TYPE 0x10
+#define GATT_RSP_READ_BY_GRP_TYPE 0x11
+#define GATT_REQ_WRITE 0x12 /* 0001-0010 (write)*/
+#define GATT_RSP_WRITE 0x13
+#define GATT_CMD_WRITE 0x52 /* changed in V4.0 01001-0010(write cmd)*/
+#define GATT_REQ_PREPARE_WRITE 0x16
+#define GATT_RSP_PREPARE_WRITE 0x17
+#define GATT_REQ_EXEC_WRITE 0x18
+#define GATT_RSP_EXEC_WRITE 0x19
+#define GATT_HANDLE_VALUE_NOTIF 0x1B
+#define GATT_HANDLE_VALUE_IND 0x1D
+#define GATT_HANDLE_VALUE_CONF 0x1E
+#define GATT_REQ_READ_MULTI_VAR 0x20
+#define GATT_RSP_READ_MULTI_VAR 0x21
+#define GATT_HANDLE_MULTI_VALUE_NOTIF 0x23
+#define GATT_SIGN_CMD_WRITE 0xD2 /* changed in V4.0 1101-0010 (signed write) see write cmd above*/
+#define GATT_OP_CODE_MAX GATT_HANDLE_MULTI_VALUE_NOTIF + 1 /* 0x1E = 30 + 1 = 31*/
+
+#define GATT_COMMAND_FLAG 0x40 /* Command Flag: set to one means command */
+
+#define GATT_HANDLE_IS_VALID(x) ((x) != 0)
+
+#define GATT_CONN_UNKNOWN 0
+#define GATT_CONN_L2C_FAILURE 1 /* general L2cap failure */
+#define GATT_CONN_TIMEOUT HCI_ERR_CONNECTION_TOUT /* 0x08 connection timeout */
+#define GATT_CONN_TERMINATE_PEER_USER HCI_ERR_PEER_USER /* 0x13 connection terminate by peer user */
+#define GATT_CONN_TERMINATE_LOCAL_HOST HCI_ERR_CONN_CAUSE_LOCAL_HOST /* 0x16 connectionterminated by local host */
+#define GATT_CONN_FAIL_ESTABLISH HCI_ERR_CONN_FAILED_ESTABLISHMENT/* 0x03E connection fail to establish */
+#define GATT_CONN_LMP_TIMEOUT HCI_ERR_LMP_RESPONSE_TIMEOUT /* 0x22 connection fail for LMP response tout */
+#define GATT_CONN_CANCEL L2CAP_CONN_CANCEL /* 0x0100 L2CAP connection cancelled */
+typedef UINT16 tGATT_DISCONN_REASON;
+
+/* MAX GATT MTU size
+*/
+#ifndef GATT_MAX_MTU_SIZE
+#define GATT_MAX_MTU_SIZE 517
+#endif
+
+/* max length of an attribute value
+*/
+#ifndef GATT_MAX_ATTR_LEN
+#define GATT_MAX_ATTR_LEN 600
+#endif
+
+/* default GATT MTU size over LE link
+*/
+#define GATT_DEF_BLE_MTU_SIZE 23
+
+/* invalid connection ID
+*/
+#define GATT_INVALID_CONN_ID 0xFFFF
+
+#ifndef GATT_CL_MAX_LCB
+#define GATT_CL_MAX_LCB 12 // 22
+#endif
+
+#ifndef GATT_MAX_SCCB
+#define GATT_MAX_SCCB 10
+#endif
+
+
+/* GATT notification caching timer, default to be three seconds
+*/
+#ifndef GATTC_NOTIF_TIMEOUT
+#define GATTC_NOTIF_TIMEOUT 3
+#endif
+
+/*****************************************************************************
+** GATT Structure Definition
+*****************************************************************************/
+
+/* Attribute permissions
+*/
+#define GATT_PERM_READ (1 << 0) /* bit 0 */
+#define GATT_PERM_READ_ENCRYPTED (1 << 1) /* bit 1 */
+#define GATT_PERM_READ_ENC_MITM (1 << 2) /* bit 2 */
+#define GATT_PERM_WRITE (1 << 4) /* bit 4 */
+#define GATT_PERM_WRITE_ENCRYPTED (1 << 5) /* bit 5 */
+#define GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 */
+#define GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 */
+#define GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 */
+#define GATT_PERM_READ_AUTHORIZATION (1 << 9) /* bit 9 */
+#define GATT_PERM_WRITE_AUTHORIZATION (1 << 10)/* bit 10 */
+typedef UINT16 tGATT_PERM;
+
+#define GATT_ENCRYPT_KEY_SIZE_MASK (0xF000) /* the MS nibble of tGATT_PERM; key size 7=0; size 16=9 */
+
+#define GATT_READ_ALLOWED (GATT_PERM_READ | GATT_PERM_READ_ENCRYPTED | GATT_PERM_READ_ENC_MITM | GATT_PERM_READ_AUTHORIZATION)
+#define GATT_READ_AUTH_REQUIRED (GATT_PERM_READ_ENCRYPTED)
+#define GATT_READ_MITM_REQUIRED (GATT_PERM_READ_ENC_MITM)
+#define GATT_READ_ENCRYPTED_REQUIRED (GATT_PERM_READ_ENCRYPTED | GATT_PERM_READ_ENC_MITM)
+#define GATT_READ_AUTHORIZATION (GATT_PERM_READ_AUTHORIZATION)
+
+
+#define GATT_WRITE_ALLOWED (GATT_PERM_WRITE | GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_ENC_MITM | \
+ GATT_PERM_WRITE_SIGNED | GATT_PERM_WRITE_SIGNED_MITM | GATT_PERM_WRITE_AUTHORIZATION)
+
+#define GATT_WRITE_AUTH_REQUIRED (GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_SIGNED)
+
+#define GATT_WRITE_MITM_REQUIRED (GATT_PERM_WRITE_ENC_MITM | GATT_PERM_WRITE_SIGNED_MITM)
+
+#define GATT_WRITE_ENCRYPTED_PERM (GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_ENC_MITM)
+
+#define GATT_WRITE_SIGNED_PERM (GATT_PERM_WRITE_SIGNED | GATT_PERM_WRITE_SIGNED_MITM)
+
+#define GATT_WRITE_AUTHORIZATION (GATT_PERM_WRITE_AUTHORIZATION)
+
+
+/* Characteristic properties
+*/
+#define GATT_CHAR_PROP_BIT_BROADCAST (1 << 0)
+#define GATT_CHAR_PROP_BIT_READ (1 << 1)
+#define GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2)
+#define GATT_CHAR_PROP_BIT_WRITE (1 << 3)
+#define GATT_CHAR_PROP_BIT_NOTIFY (1 << 4)
+#define GATT_CHAR_PROP_BIT_INDICATE (1 << 5)
+#define GATT_CHAR_PROP_BIT_AUTH (1 << 6)
+#define GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7)
+typedef UINT8 tGATT_CHAR_PROP;
+
+
+/* Format of the value of a characteristic. enumeration type
+*/
+enum {
+ GATT_FORMAT_RES, /* rfu */
+ GATT_FORMAT_BOOL, /* 0x01 boolean */
+ GATT_FORMAT_2BITS, /* 0x02 2 bit */
+ GATT_FORMAT_NIBBLE, /* 0x03 nibble */
+ GATT_FORMAT_UINT8, /* 0x04 uint8 */
+ GATT_FORMAT_UINT12, /* 0x05 uint12 */
+ GATT_FORMAT_UINT16, /* 0x06 uint16 */
+ GATT_FORMAT_UINT24, /* 0x07 uint24 */
+ GATT_FORMAT_UINT32, /* 0x08 uint32 */
+ GATT_FORMAT_UINT48, /* 0x09 uint48 */
+ GATT_FORMAT_UINT64, /* 0x0a uint64 */
+ GATT_FORMAT_UINT128, /* 0x0B uint128 */
+ GATT_FORMAT_SINT8, /* 0x0C signed 8 bit integer */
+ GATT_FORMAT_SINT12, /* 0x0D signed 12 bit integer */
+ GATT_FORMAT_SINT16, /* 0x0E signed 16 bit integer */
+ GATT_FORMAT_SINT24, /* 0x0F signed 24 bit integer */
+ GATT_FORMAT_SINT32, /* 0x10 signed 32 bit integer */
+ GATT_FORMAT_SINT48, /* 0x11 signed 48 bit integer */
+ GATT_FORMAT_SINT64, /* 0x12 signed 64 bit integer */
+ GATT_FORMAT_SINT128, /* 0x13 signed 128 bit integer */
+ GATT_FORMAT_FLOAT32, /* 0x14 float 32 */
+ GATT_FORMAT_FLOAT64, /* 0x15 float 64*/
+ GATT_FORMAT_SFLOAT, /* 0x16 IEEE-11073 16 bit SFLOAT */
+ GATT_FORMAT_FLOAT, /* 0x17 IEEE-11073 32 bit SFLOAT */
+ GATT_FORMAT_DUINT16, /* 0x18 IEEE-20601 format */
+ GATT_FORMAT_UTF8S, /* 0x19 UTF-8 string */
+ GATT_FORMAT_UTF16S, /* 0x1a UTF-16 string */
+ GATT_FORMAT_STRUCT, /* 0x1b Opaque structure*/
+ GATT_FORMAT_MAX /* 0x1c or above reserved */
+};
+typedef UINT8 tGATT_FORMAT;
+
+/* Characteristic Presentation Format Descriptor value
+*/
+typedef struct {
+ UINT16 unit; /* as UUID defined by SIG */
+ UINT16 descr; /* as UUID as defined by SIG */
+ tGATT_FORMAT format;
+ INT8 exp;
+ UINT8 name_spc; /* The name space of the description */
+} tGATT_CHAR_PRES;
+
+/* Characteristic Report reference Descriptor format
+*/
+typedef struct {
+ UINT8 rpt_id; /* report ID */
+ UINT8 rpt_type; /* report type */
+} tGATT_CHAR_RPT_REF;
+
+
+#define GATT_VALID_RANGE_MAX_SIZE 16
+typedef struct {
+ UINT8 format;
+ UINT16 len;
+ UINT8 lower_range[GATT_VALID_RANGE_MAX_SIZE]; /* in little endian format */
+ UINT8 upper_range[GATT_VALID_RANGE_MAX_SIZE];
+} tGATT_VALID_RANGE;
+
+/* Characteristic Aggregate Format attribute value
+*/
+#define GATT_AGGR_HANDLE_NUM_MAX 10
+typedef struct {
+ UINT8 num_handle;
+ UINT16 handle_list[GATT_AGGR_HANDLE_NUM_MAX];
+} tGATT_CHAR_AGGRE;
+
+/* Characteristic descriptor: Extended Properties value
+*/
+#define GATT_CHAR_BIT_REL_WRITE 0x0001 /* permits reliable writes of the Characteristic Value */
+#define GATT_CHAR_BIT_WRITE_AUX 0x0002 /* permits writes to the characteristic descriptor */
+
+
+/* characteristic descriptor: client configuration value
+*/
+#define GATT_CLT_CONFIG_NONE 0x0000
+#define GATT_CLT_CONFIG_NOTIFICATION 0x0001
+#define GATT_CLT_CONFIG_INDICATION 0x0002
+typedef UINT16 tGATT_CLT_CHAR_CONFIG;
+
+
+/* characteristic descriptor: server configuration value
+*/
+#define GATT_SVR_CONFIG_NONE 0x0000
+#define GATT_SVR_CONFIG_BROADCAST 0x0001
+typedef UINT16 tGATT_SVR_CHAR_CONFIG;
+
+/* Characteristic descriptor: Extended Properties value
+*/
+#define GATT_CHAR_BIT_REL_WRITE 0x0001 /* permits reliable writes of the Characteristic Value */
+#define GATT_CHAR_BIT_WRITE_AUX 0x0002 /* permits writes to the characteristic descriptor */
+
+/* authentication requirement
+*/
+#define GATT_AUTH_REQ_NONE 0
+#define GATT_AUTH_REQ_NO_MITM 1 /* unauthenticated encryption */
+#define GATT_AUTH_REQ_MITM 2 /* authenticated encryption */
+#define GATT_AUTH_REQ_SIGNED_NO_MITM 3
+#define GATT_AUTH_REQ_SIGNED_MITM 4
+typedef UINT8 tGATT_AUTH_REQ;
+
+/* Attribute Value structure
+*/
+typedef struct {
+ UINT16 conn_id;
+ UINT16 handle; /* attribute handle */
+ UINT16 offset; /* attribute value offset, if no offset is needed for the command, ignore it */
+ UINT16 len; /* length of attribute value */
+ tGATT_AUTH_REQ auth_req; /* authentication request */
+ UINT8 value[GATT_MAX_ATTR_LEN]; /* the actual attribute value */
+} tGATT_VALUE;
+
+typedef struct{
+ UINT16 attr_max_len;
+ UINT16 attr_len;
+ UINT8 *attr_val;
+}tGATT_ATTR_VAL;
+
+typedef struct{
+ uint8_t auto_rsp;
+}tGATTS_ATTR_CONTROL;
+
+/* Mask for gatt server attribute */
+#define GATT_ATTR_VALUE_ALLOCATED 0x01
+typedef UINT8 tGATT_ATTR_MASK;
+
+/* Union of the event data which is used in the server respond API to carry the server response information
+*/
+typedef union {
+ /* data type member event */
+ tGATT_VALUE attr_value; /* READ, HANDLE_VALUE_IND, PREPARE_WRITE */
+ /* READ_BLOB, READ_BY_TYPE */
+ UINT16 handle; /* WRITE, WRITE_BLOB */
+
+} tGATTS_RSP;
+
+/* Transports for the primary service */
+#define GATT_TRANSPORT_LE BT_TRANSPORT_LE
+#define GATT_TRANSPORT_BR_EDR BT_TRANSPORT_BR_EDR
+#define GATT_TRANSPORT_LE_BR_EDR (BT_TRANSPORT_LE|BT_TRANSPORT_BR_EDR)
+typedef UINT8 tGATT_TRANSPORT;
+
+#define GATT_PREP_WRITE_CANCEL 0x00
+#define GATT_PREP_WRITE_EXEC 0x01
+typedef UINT8 tGATT_EXEC_FLAG;
+
+/* read request always based on UUID */
+typedef struct {
+ UINT16 handle;
+ UINT16 offset;
+ BOOLEAN is_long;
+ BOOLEAN need_rsp;
+} tGATT_READ_REQ;
+
+/* write request data */
+typedef struct {
+ UINT16 handle; /* attribute handle */
+ UINT16 offset; /* attribute value offset, if no offset is needed for the command, ignore it */
+ UINT16 len; /* length of attribute value */
+ UINT8 value[GATT_MAX_ATTR_LEN]; /* the actual attribute value */
+ BOOLEAN need_rsp; /* need write response */
+ BOOLEAN is_prep; /* is prepare write */
+} tGATT_WRITE_REQ;
+
+/* callback data for server access request from client */
+typedef union {
+ tGATT_READ_REQ read_req; /* read request, read by Type, read blob */
+
+ tGATT_WRITE_REQ write_req; /* write */
+ /* prepare write */
+ /* write blob */
+ UINT16 handle; /* handle value confirmation */
+ UINT16 mtu; /* MTU exchange request */
+ tGATT_EXEC_FLAG exec_write; /* execute write */
+} tGATTS_DATA;
+
+typedef UINT8 tGATT_SERV_IF; /* GATT Service Interface */
+
+enum {
+ GATTS_REQ_TYPE_READ = 1, /* Attribute read request */
+ GATTS_REQ_TYPE_WRITE, /* Attribute write request */
+ GATTS_REQ_TYPE_WRITE_EXEC, /* Execute write */
+ GATTS_REQ_TYPE_MTU, /* MTU exchange information */
+ GATTS_REQ_TYPE_CONF /* handle value confirmation */
+};
+typedef UINT8 tGATTS_REQ_TYPE;
+
+
+
+/* Client Used Data Structure
+*/
+/* definition of different discovery types */
+enum {
+ GATT_DISC_SRVC_ALL = 1, /* discover all services */
+ GATT_DISC_SRVC_BY_UUID, /* discover service of a special type */
+ GATT_DISC_INC_SRVC, /* discover the included service within a service */
+ GATT_DISC_CHAR, /* discover characteristics of a service with/without type requirement */
+ GATT_DISC_CHAR_BY_UUID, /* discover characteristic with type requirement */
+ GATT_DISC_CHAR_DSCPT, /* discover characteristic descriptors of a character */
+ GATT_DISC_MAX /* maximnun discover type */
+};
+typedef UINT8 tGATT_DISC_TYPE;
+
+/* Discover parameters of different discovery types
+*/
+typedef struct {
+ tBT_UUID service;
+ UINT16 s_handle;
+ UINT16 e_handle;
+} tGATT_DISC_PARAM;
+
+/* GATT read type enumeration
+*/
+enum {
+ GATT_READ_BY_TYPE = 1,
+ GATT_READ_BY_HANDLE,
+ GATT_READ_MULTIPLE,
+ GATT_READ_MULTIPLE_VAR,
+ GATT_READ_CHAR_VALUE,
+ GATT_READ_PARTIAL,
+ GATT_READ_MAX
+};
+typedef UINT8 tGATT_READ_TYPE;
+
+/* Read By Type Request (GATT_READ_BY_TYPE) Data
+*/
+typedef struct {
+ tGATT_AUTH_REQ auth_req;
+ UINT16 s_handle;
+ UINT16 e_handle;
+ tBT_UUID uuid;
+} tGATT_READ_BY_TYPE;
+
+/* GATT_READ_MULTIPLE request data
+*/
+#define GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */
+typedef struct {
+ tGATT_AUTH_REQ auth_req;
+ UINT16 num_handles; /* number of handles to read */
+ UINT16 handles[GATT_MAX_READ_MULTI_HANDLES]; /* handles list to be read */
+} tGATT_READ_MULTI;
+
+/* Read By Handle Request (GATT_READ_BY_HANDLE) data */
+typedef struct {
+ tGATT_AUTH_REQ auth_req;
+ UINT16 handle;
+} tGATT_READ_BY_HANDLE;
+
+/* READ_BT_HANDLE_Request data */
+typedef struct {
+ tGATT_AUTH_REQ auth_req;
+ UINT16 handle;
+ UINT16 offset;
+} tGATT_READ_PARTIAL;
+
+/* Read Request Data
+*/
+typedef union {
+ tGATT_READ_BY_TYPE service;
+ tGATT_READ_BY_TYPE char_type; /* characteristic type */
+ tGATT_READ_MULTI read_multiple;
+ tGATT_READ_BY_HANDLE by_handle;
+ tGATT_READ_PARTIAL partial;
+} tGATT_READ_PARAM;
+
+/* GATT write type enumeration */
+enum {
+ GATT_WRITE_NO_RSP = 1,
+ GATT_WRITE ,
+ GATT_WRITE_PREPARE
+};
+typedef UINT8 tGATT_WRITE_TYPE;
+
+/* Client Operation Complete Callback Data
+*/
+typedef union {
+ tGATT_VALUE att_value;
+ UINT16 mtu;
+ UINT16 handle;
+} tGATT_CL_COMPLETE;
+
+/* GATT client operation type, used in client callback function
+*/
+#define GATTC_OPTYPE_NONE 0
+#define GATTC_OPTYPE_DISCOVERY 1
+#define GATTC_OPTYPE_READ 2
+#define GATTC_OPTYPE_WRITE 3
+#define GATTC_OPTYPE_EXE_WRITE 4
+#define GATTC_OPTYPE_CONFIG 5
+#define GATTC_OPTYPE_NOTIFICATION 6
+#define GATTC_OPTYPE_INDICATION 7
+typedef UINT8 tGATTC_OPTYPE;
+
+/* characteristic declaration
+*/
+typedef struct {
+ tGATT_CHAR_PROP char_prop; /* characteristic properties */
+ UINT16 val_handle; /* characteristic value attribute handle */
+ tBT_UUID char_uuid; /* characteristic UUID type */
+} tGATT_CHAR_DCLR_VAL;
+
+/* primary service group data
+*/
+typedef struct {
+ UINT16 e_handle; /* ending handle of the group */
+ tBT_UUID service_type; /* group type */
+} tGATT_GROUP_VALUE;
+
+
+/* included service attribute value
+*/
+typedef struct {
+ tBT_UUID service_type; /* included service UUID */
+ UINT16 s_handle; /* starting handle */
+ UINT16 e_handle; /* ending handle */
+} tGATT_INCL_SRVC;
+
+typedef union {
+ tGATT_INCL_SRVC incl_service; /* include service value */
+ tGATT_GROUP_VALUE group_value; /* Service UUID type.
+ This field is used with GATT_DISC_SRVC_ALL
+ or GATT_DISC_SRVC_BY_UUID
+ type of discovery result callback. */
+
+ UINT16 handle; /* When used with GATT_DISC_INC_SRVC type discovery result,
+ it is the included service starting handle.*/
+
+ tGATT_CHAR_DCLR_VAL dclr_value; /* Characteristic declaration value.
+ This field is used with GATT_DISC_CHAR type discovery.*/
+} tGATT_DISC_VALUE;
+
+/* discover result record
+*/
+typedef struct {
+ tBT_UUID type;
+ UINT16 handle;
+ tGATT_DISC_VALUE value;
+} tGATT_DISC_RES;
+
+
+#define GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP 0 /* start a idle timer for this duration
+ when no application need to use the link */
+
+#define GATT_LINK_NO_IDLE_TIMEOUT 0xFFFF
+
+#define GATT_INVALID_ACL_HANDLE 0xFFFF
+/* discover result callback function */
+typedef void (tGATT_DISC_RES_CB) (UINT16 conn_id, tGATT_DISC_TYPE disc_type,
+ tGATT_DISC_RES *p_data);
+
+/* discover complete callback function */
+typedef void (tGATT_DISC_CMPL_CB) (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status);
+
+/* Define a callback function for when read/write/disc/config operation is completed. */
+typedef void (tGATT_CMPL_CBACK) (UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
+ tGATT_CL_COMPLETE *p_data);
+
+/* Define a callback function when an initialized connection is established. */
+typedef void (tGATT_CONN_CBACK) (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, BOOLEAN connected,
+ tGATT_DISCONN_REASON reason, tBT_TRANSPORT transport);
+
+/* attribute request callback for ATT server */
+typedef void (tGATT_REQ_CBACK )(UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type,
+ tGATTS_DATA *p_data);
+
+/* channel congestion/uncongestion callback */
+typedef void (tGATT_CONGESTION_CBACK )(UINT16 conn_id, BOOLEAN congested);
+
+/* Define a callback function when encryption is established. */
+typedef void (tGATT_ENC_CMPL_CB)(tGATT_IF gatt_if, BD_ADDR bda);
+
+
+/* Define the structure that applications use to register with
+** GATT. This structure includes callback functions. All functions
+** MUST be provided.
+*/
+typedef struct {
+ tGATT_CONN_CBACK *p_conn_cb;
+ tGATT_CMPL_CBACK *p_cmpl_cb;
+ tGATT_DISC_RES_CB *p_disc_res_cb;
+ tGATT_DISC_CMPL_CB *p_disc_cmpl_cb;
+ tGATT_REQ_CBACK *p_req_cb;
+ tGATT_ENC_CMPL_CB *p_enc_cmpl_cb;
+ tGATT_CONGESTION_CBACK *p_congestion_cb;
+} tGATT_CBACK;
+
+/*********************** Start Handle Management Definitions **********************
+*/
+
+
+typedef struct {
+ tBT_UUID app_uuid128;
+ tBT_UUID svc_uuid;
+ UINT16 svc_inst;
+ UINT16 s_handle;
+ UINT16 e_handle;
+ BOOLEAN is_primary; /* primary service or secondary */
+} tGATTS_HNDL_RANGE;
+
+
+
+#define GATTS_SRV_CHG_CMD_ADD_CLIENT 1
+#define GATTS_SRV_CHG_CMD_UPDATE_CLIENT 2
+#define GATTS_SRV_CHG_CMD_REMOVE_CLIENT 3
+#define GATTS_SRV_CHG_CMD_READ_NUM_CLENTS 4
+#define GATTS_SRV_CHG_CMD_READ_CLENT 5
+typedef UINT8 tGATTS_SRV_CHG_CMD;
+
+typedef struct {
+ BD_ADDR bda;
+ BOOLEAN srv_changed;
+} tGATTS_SRV_CHG;
+
+
+typedef union {
+ tGATTS_SRV_CHG srv_chg;
+ UINT8 client_read_index; /* only used for sequential reading client srv chg info */
+} tGATTS_SRV_CHG_REQ;
+
+typedef union {
+ tGATTS_SRV_CHG srv_chg;
+ UINT8 num_clients;
+} tGATTS_SRV_CHG_RSP;
+
+
+
+typedef struct {
+ tGATTS_HNDL_RANGE *p_new_srv_start;
+} tGATTS_PENDING_NEW_SRV_START;
+
+/* Attribute server handle ranges NV storage callback functions
+*/
+typedef void (tGATTS_NV_SAVE_CBACK)(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
+typedef BOOLEAN (tGATTS_NV_SRV_CHG_CBACK)(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req,
+ tGATTS_SRV_CHG_RSP *p_rsp);
+
+typedef struct {
+ tGATTS_NV_SAVE_CBACK *p_nv_save_callback;
+ tGATTS_NV_SRV_CHG_CBACK *p_srv_chg_callback;
+} tGATT_APPL_INFO;
+
+typedef struct {
+ UINT16 handle;
+ UINT16 length;
+ UINT8 *value;
+} tGATT_HLV;
+
+/*
+*********************** End Handle Management Definitions **********************/
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function GATT_SetTraceLevel
+**
+** Description This function sets the trace level. If called with
+** a value of 0xFF, it simply returns the current trace level.
+**
+** Returns The new or current trace level
+**
+*******************************************************************************/
+extern UINT8 GATT_SetTraceLevel (UINT8 new_level);
+
+
+/*******************************************************************************/
+/* GATT Profile API Functions */
+/*******************************************************************************/
+/* GATT Profile Server Functions */
+/*******************************************************************************/
+/*******************************************************************************
+**
+** Function GATTS_AddHandleRange
+**
+** Description This function add the allocated handles range for the specifed
+** application UUID, service UUID and service instance
+**
+** Parameter p_hndl_range: pointer to allocated handles information
+**
+** Returns TRUE if handle range is added successfully; otherwise FALSE.
+**
+*******************************************************************************/
+
+extern BOOLEAN GATTS_AddHandleRange(tGATTS_HNDL_RANGE *p_hndl_range);
+
+/*******************************************************************************
+**
+** Function GATTS_NVRegister
+**
+** Description Application manager calls this function to register for
+** NV save callback function. There can be one and only one
+** NV save callback function.
+**
+** Parameter p_cb_info : callback informaiton
+**
+** Returns TRUE if registered OK, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN GATTS_NVRegister (const tGATT_APPL_INFO *p_cb_info);
+
+
+/*******************************************************************************
+**
+** Function GATTS_CreateService
+**
+** Description This function is called to reserve a block of handles for a service.
+**
+** *** It should be called only once per service instance ***
+**
+** Parameter gatt_if : application if
+** p_svc_uuid : service UUID
+** svc_inst : instance of the service inside the application
+** num_handles : number of handles needed by the service.
+** is_pri : is a primary service or not.
+**
+** Returns service handle if successful, otherwise 0.
+**
+*******************************************************************************/
+extern UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
+ UINT16 svc_inst, UINT16 num_handles, BOOLEAN is_pri);
+
+
+/*******************************************************************************
+**
+** Function GATTS_AddIncludeService
+**
+** Description This function is called to add an included service.
+**
+** Parameter service_handle : To which service this included service is added to.
+** include_svc_handle : included service handle.
+**
+** Returns included service attribute handle. If 0, add included service
+** fail.
+**
+*******************************************************************************/
+extern UINT16 GATTS_AddIncludeService (UINT16 service_handle,
+ UINT16 include_svc_handle);
+
+
+/*******************************************************************************
+**
+** Function GATTS_AddCharacteristic
+**
+** Description This function is called to add a characteristic into a service.
+** It will add a characteristic declaration and characteristic
+** value declaration into the service database identified by the
+** service handle.
+**
+** Parameter service_handle : To which service this included service is added to.
+** char_uuid : Characteristic UUID.
+** perm : Characteristic value declaration attribute permission.
+** property : Characteristic Properties
+**
+** Returns Characteristic value declaration attribute handle. 0 if add
+** characteristic failed.
+**
+*******************************************************************************/
+extern UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
+ tGATT_PERM perm, tGATT_CHAR_PROP property,
+ tGATT_ATTR_VAL *attr_val, tGATTS_ATTR_CONTROL *control);
+
+/*******************************************************************************
+**
+** Function GATTS_AddCharDescriptor
+**
+** Description This function is called to add a characteristic descriptor
+** into a service database. Add descriptor should follow add char
+** to which it belongs, and next add char should be done only
+** after all add descriptors for the previous char.
+**
+** Parameter service_handle : To which service this characteristic descriptor
+** is added to.
+** perm : Characteristic value declaration attribute
+** permission.
+** p_descr_uuid : Characteristic descriptor UUID.
+**
+** Returns Characteristic descriptor attribute handle. 0 if add
+** characteristic descriptor failed.
+**
+*******************************************************************************/
+extern UINT16 GATTS_AddCharDescriptor (UINT16 service_handle, tGATT_PERM perm,
+ tBT_UUID *p_descr_uuid, tGATT_ATTR_VAL *attr_val,
+ tGATTS_ATTR_CONTROL *control);
+
+/*******************************************************************************
+**
+** Function GATTS_DeleteService
+**
+** Description This function is called to delete a service.
+**
+** Parameter gatt_if : application interface
+** p_svc_uuid : service UUID
+** svc_inst : instance of the service inside the application
+**
+** Returns TRUE if operation succeed, FALSE if handle block was not found.
+**
+*******************************************************************************/
+extern BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
+ UINT16 svc_inst);
+
+/*******************************************************************************
+**
+** Function GATTS_StartService
+**
+** Description This function is called to start a service with GATT
+**
+** Parameter gatt_if : service handle.
+** p_cback : application service callback functions.
+** sup_transport : supported transport(s) for this primary service
+**
+** return GATT_SUCCESS if successfully started; otherwise error code.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
+ tGATT_TRANSPORT sup_transport);
+
+
+/*******************************************************************************
+**
+** Function GATTS_StopService
+**
+** Description This function is called to stop a service
+**
+** Parameter service_handle : this is the start handle of a service
+**
+** Returns None.
+**
+*******************************************************************************/
+extern void GATTS_StopService (UINT16 service_handle);
+
+
+/*******************************************************************************
+**
+** Function GATTs_HandleValueIndication
+**
+** Description This function sends a handle value indication to a client.
+**
+** Parameter conn_id: connection identifier.
+** attr_handle: Attribute handle of this handle value indication.
+** val_len: Length of the indicated attribute value.
+** p_val: Pointer to the indicated attribute value data.
+**
+** Returns GATT_SUCCESS if successfully sent or queued; otherwise error code.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id,
+ UINT16 attr_handle,
+ UINT16 val_len, UINT8 *p_val);
+
+/*******************************************************************************
+**
+** Function GATTS_HandleValueNotification
+**
+** Description This function sends a handle value notification to a client.
+**
+** Parameter conn_id: connection identifier.
+** attr_handle: Attribute handle of this handle value indication.
+** val_len: Length of the indicated attribute value.
+** p_val: Pointer to the indicated attribute value data.
+**
+** Returns GATT_SUCCESS if successfully sent; otherwise error code.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle,
+ UINT16 val_len, UINT8 *p_val);
+
+
+/*******************************************************************************
+**
+** Function GATTS_SendRsp
+**
+** Description This function sends the server response to client.
+**
+** Parameter conn_id: connection identifier.
+** trans_id: transaction id
+** status: response status
+** p_msg: pointer to message parameters structure.
+**
+** Returns GATT_SUCCESS if successfully sent; otherwise error code.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
+ tGATT_STATUS status, tGATTS_RSP *p_msg);
+
+
+/*******************************************************************************
+**
+** Function GATTS_SetAttributeValue
+**
+** Description This function sends to set the attribute value .
+**
+** Parameter attr_handle:the attribute handle
+** length: the attribute length
+** value: the value to be set to the attribute in the database
+**
+** Returns GATT_SUCCESS if successfully sent; otherwise error code.
+**
+*******************************************************************************/
+tGATT_STATUS GATTS_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *value);
+
+
+/*******************************************************************************
+**
+** Function GATTS_GetAttributeValue
+**
+** Description This function sends to set the attribute value .
+**
+** Parameter attr_handle: the attribute handle
+** length:the attribute value length in the database
+** value: the attribute value out put
+**
+** Returns GATT_SUCCESS if successfully sent; otherwise error code.
+**
+*******************************************************************************/
+tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value);
+
+tGATT_STATUS GATTS_GetAttributeValueInternal(UINT16 attr_handle, UINT16 *length, UINT8 **value);
+
+/*******************************************************************************/
+/* GATT Profile Client Functions */
+/*******************************************************************************/
+
+/*******************************************************************************
+**
+** Function GATTC_ConfigureMTU
+**
+** Description This function is called to configure the ATT MTU size for
+** a connection on an LE transport.
+**
+** Parameters conn_id: connection identifier.
+** mtu - attribute MTU size..
+**
+** Returns GATT_SUCCESS if command started successfully.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id);
+
+/*******************************************************************************
+**
+** Function GATTC_Discover
+**
+** Description This function is called to do a discovery procedure on ATT server.
+**
+** Parameters conn_id: connection identifier.
+** disc_type:discovery type.
+** p_param: parameters of discovery requirement.
+**
+** Returns GATT_SUCCESS if command received/sent successfully.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTC_Discover (UINT16 conn_id,
+ tGATT_DISC_TYPE disc_type,
+ tGATT_DISC_PARAM *p_param );
+/*******************************************************************************
+**
+** Function GATTC_Read
+**
+** Description This function is called to read the value of an attribute from
+** the server.
+**
+** Parameters conn_id: connection identifier.
+** type - attribute read type.
+** p_read - read operation parameters.
+**
+** Returns GATT_SUCCESS if command started successfully.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type,
+ tGATT_READ_PARAM *p_read);
+
+/*******************************************************************************
+**
+** Function GATTC_Write
+**
+** Description This function is called to read the value of an attribute from
+** the server.
+**
+** Parameters conn_id: connection identifier.
+** type - attribute write type.
+** p_write - write operation parameters.
+**
+** Returns GATT_SUCCESS if command started successfully.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type,
+ tGATT_VALUE *p_write);
+
+
+/*******************************************************************************
+**
+** Function GATTC_ExecuteWrite
+**
+** Description This function is called to send an Execute write request to
+** the server.
+**
+** Parameters conn_id: connection identifier.
+** is_execute - to execute or cancel the prepare write request(s)
+**
+** Returns GATT_SUCCESS if command started successfully.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute);
+
+/*******************************************************************************
+**
+** Function GATTC_SendHandleValueConfirm
+**
+** Description This function is called to send a handle value confirmation
+** as response to a handle value notification from server.
+**
+** Parameters conn_id: connection identifier.
+** handle: the handle of the attribute confirmation.
+**
+** Returns GATT_SUCCESS if command started successfully.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTC_SendHandleValueConfirm (UINT16 conn_id, UINT16 handle);
+
+/*******************************************************************************
+**
+** Function GATTC_AutoDiscoverEnable
+**
+** Description This function is called to enable/disable auto discover.
+**
+** Parameters enable: 0 for disable, otherwise enable.
+**
+** Returns GATT_SUCCESS if command started successfully.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTC_AutoDiscoverEnable(UINT8 enable);
+
+/*******************************************************************************
+**
+** Function GATT_SetIdleTimeout
+**
+** Description This function (common to both client and server) sets the idle
+** timeout for a tansport connection
+**
+** Parameter bd_addr: target device bd address.
+** idle_tout: timeout value in seconds.
+** transport: transport option.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout,
+ tGATT_TRANSPORT transport);
+
+
+/*******************************************************************************
+**
+** Function GATT_Register
+**
+** Description This function is called to register an application
+** with GATT
+**
+** Parameter p_app_uuid128: Application UUID
+** p_cb_info: callback functions.
+**
+** Returns 0 for error, otherwise the index of the client registered with GATT
+**
+*******************************************************************************/
+extern tGATT_IF GATT_Register (tBT_UUID *p_app_uuid128, const tGATT_CBACK *p_cb_info);
+
+/*******************************************************************************
+**
+** Function GATT_Deregister
+**
+** Description This function deregistered the application from GATT.
+**
+** Parameters gatt_if: application interface.
+**
+** Returns None.
+**
+*******************************************************************************/
+extern void GATT_Deregister (tGATT_IF gatt_if);
+
+/*******************************************************************************
+**
+** Function GATT_StartIf
+**
+** Description This function is called after registration to start receiving
+** callbacks for registered interface. Function may call back
+** with connection status and queued notifications
+**
+** Parameter gatt_if: application interface.
+**
+** Returns None
+**
+*******************************************************************************/
+extern void GATT_StartIf (tGATT_IF gatt_if);
+
+/*******************************************************************************
+**
+** Function GATT_Connect
+**
+** Description This function initiate a connection to a remote device on GATT
+** channel.
+**
+** Parameters gatt_if: application interface
+** bd_addr: peer device address.
+** bd_addr_type: peer device address type.
+** is_direct: is a direct connection or a background auto connection
+** transport : Physical transport for GATT connection (BR/EDR or LE)
+**
+** Returns TRUE if connection started; FALSE if connection start failure.
+**
+*******************************************************************************/
+extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type,
+ BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux);
+
+
+/*******************************************************************************
+**
+** Function GATT_CancelConnect
+**
+** Description This function terminate the connection initaition to a remote
+** device on GATT channel.
+**
+** Parameters gatt_if: client interface. If 0 used as unconditionally disconnect,
+** typically used for direct connection cancellation.
+** bd_addr: peer device address.
+** is_direct: is a direct connection or a background auto connection
+**
+** Returns TRUE if connection started; FALSE if connection start failure.
+**
+*******************************************************************************/
+extern BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr,
+ BOOLEAN is_direct);
+
+/*******************************************************************************
+**
+** Function GATT_Disconnect
+**
+** Description This function disconnect the GATT channel for this registered
+** application.
+**
+** Parameters conn_id: connection identifier.
+**
+** Returns GATT_SUCCESS if disconnected.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATT_Disconnect (UINT16 conn_id);
+
+/*******************************************************************************
+**
+** Function GATT_SendServiceChangeIndication
+**
+** Description This function is to send a service change indication
+**
+** Parameters bd_addr: peer device address.
+**
+** Returns status.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function GATT_GetConnectionInfor
+**
+** Description This function use conn_id to find its associated BD address and application
+** interface
+**
+** Parameters conn_id: connection id (input)
+** p_gatt_if: application interface (output)
+** bd_addr: peer device address. (output)
+** transport : physical transport of the GATT connection (BR/EDR or LE)
+**
+** Returns TRUE the logical link information is found for conn_id
+**
+*******************************************************************************/
+extern BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if,
+ BD_ADDR bd_addr, tBT_TRANSPORT *p_transport);
+
+
+/*******************************************************************************
+**
+** Function GATT_GetConnIdIfConnected
+**
+** Description This function find the conn_id if the logical link for BD address
+** and application interface is connected
+**
+** Parameters gatt_if: application interface (input)
+** bd_addr: peer device address. (input)
+** p_conn_id: connection id (output)
+** transport : physical transport of the GATT connection (BR/EDR or LE)
+**
+** Returns TRUE the logical link is connected
+**
+*******************************************************************************/
+extern BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr,
+ UINT16 *p_conn_id, tBT_TRANSPORT transport);
+
+
+/*******************************************************************************
+**
+** Function GATT_Listen
+**
+** Description This function start or stop LE advertisement and listen for
+** connection.
+**
+** Parameters gatt_if: application interface
+** p_bd_addr: listen for specific address connection, or NULL for
+** listen to all device connection.
+** start: is a direct connection or a background auto connection
+**
+** Returns TRUE if advertisement is started; FALSE if adv start failure.
+**
+*******************************************************************************/
+extern BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr);
+
+/*******************************************************************************
+**
+** Function GATT_ConfigServiceChangeCCC
+**
+** Description Configure service change indication on remote device
+**
+** Returns None.
+**
+*******************************************************************************/
+extern void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable,
+ tBT_TRANSPORT transport);
+
+/*******************************************************************************
+**
+** Function GATTS_SetServiceChangeMode
+**
+** Description Configure service change indication mode
+**
+** Parameters mode: service change mode
+**
+** Returns Status.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTS_SetServiceChangeMode(UINT8 mode);
+
+/*******************************************************************************
+**
+** Function GATTS_HandleMultiValueNotification
+**
+** Description This function sends multiple handle value notification to a client.
+**
+** Parameter conn_id: connection identifier.
+** tuples: Pointer to handle-length-value tuple list.
+** num_tuples: Number of tuples.
+**
+** Returns GATT_SUCCESS if successfully sent; otherwise error code.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTS_HandleMultiValueNotification (UINT16 conn_id, tGATT_HLV *tuples, UINT16 num_tuples);
+
+/*******************************************************************************
+**
+** Function GATTS_ShowLocalDatabase
+**
+** Description This function print local service database.
+**
+** Returns GATT_SUCCESS if successfully sent; otherwise error code.
+**
+*******************************************************************************/
+extern tGATT_STATUS GATTS_ShowLocalDatabase(void);
+
+#ifdef __cplusplus
+
+}
+#endif
+
+#endif /* GATT_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/gattdefs.h b/lib/bt/host/bluedroid/stack/include/stack/gattdefs.h
new file mode 100644
index 00000000..d8e4cb59
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/gattdefs.h
@@ -0,0 +1,128 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains internally used ATT definitions
+ *
+ ******************************************************************************/
+
+#ifndef _GATTDEFS_H
+#define _GATTDEFS_H
+
+#define GATT_ILLEGAL_UUID 0
+
+/* GATT attribute types
+*/
+#define GATT_UUID_PRI_SERVICE 0x2800
+#define GATT_UUID_SEC_SERVICE 0x2801
+#define GATT_UUID_INCLUDE_SERVICE 0x2802
+#define GATT_UUID_CHAR_DECLARE 0x2803 /* Characteristic Declaration*/
+
+#define GATT_UUID_CHAR_EXT_PROP 0x2900 /* Characteristic Extended Properties */
+#define GATT_UUID_CHAR_DESCRIPTION 0x2901 /* Characteristic User Description*/
+#define GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */
+#define GATT_UUID_CHAR_SRVR_CONFIG 0x2903 /* Server Characteristic Configuration */
+#define GATT_UUID_CHAR_PRESENT_FORMAT 0x2904 /* Characteristic Presentation Format*/
+#define GATT_UUID_CHAR_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
+#define GATT_UUID_CHAR_VALID_RANGE 0x2906 /* Characteristic Valid Range */
+#define GATT_UUID_EXT_RPT_REF_DESCR 0x2907
+#define GATT_UUID_RPT_REF_DESCR 0x2908
+
+
+/* GAP Profile Attributes
+*/
+#define GATT_UUID_GAP_DEVICE_NAME 0x2A00
+#define GATT_UUID_GAP_ICON 0x2A01
+#define GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
+#define GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6
+
+/* Attribute Profile Attribute UUID */
+#define GATT_UUID_GATT_SRV_CHGD 0x2A05
+/* Attribute Protocol Test */
+
+/* Link Loss Service */
+#define GATT_UUID_ALERT_LEVEL 0x2A06 /* Alert Level */
+#define GATT_UUID_TX_POWER_LEVEL 0x2A07 /* TX power level */
+
+/* Time Profile */
+/* Current Time Service */
+#define GATT_UUID_CURRENT_TIME 0x2A2B /* Current Time */
+#define GATT_UUID_LOCAL_TIME_INFO 0x2A0F /* Local time info */
+#define GATT_UUID_REF_TIME_INFO 0x2A14 /* reference time information */
+
+/* NwA Profile */
+#define GATT_UUID_NW_STATUS 0x2A18 /* network availability status */
+#define GATT_UUID_NW_TRIGGER 0x2A1A /* Network availability trigger */
+
+/* phone alert */
+#define GATT_UUID_ALERT_STATUS 0x2A3F /* alert status */
+#define GATT_UUID_RINGER_CP 0x2A40 /* ringer control point */
+#define GATT_UUID_RINGER_SETTING 0x2A41 /* ringer setting */
+
+/* Glucose Service */
+#define GATT_UUID_GM_MEASUREMENT 0x2A18
+#define GATT_UUID_GM_CONTEXT 0x2A34
+#define GATT_UUID_GM_CONTROL_POINT 0x2A52
+#define GATT_UUID_GM_FEATURE 0x2A51
+
+/* device infor characteristic */
+#define GATT_UUID_SYSTEM_ID 0x2A23
+#define GATT_UUID_MODEL_NUMBER_STR 0x2A24
+#define GATT_UUID_SERIAL_NUMBER_STR 0x2A25
+#define GATT_UUID_FW_VERSION_STR 0x2A26
+#define GATT_UUID_HW_VERSION_STR 0x2A27
+#define GATT_UUID_SW_VERSION_STR 0x2A28
+#define GATT_UUID_MANU_NAME 0x2A29
+#define GATT_UUID_IEEE_DATA 0x2A2A
+#define GATT_UUID_PNP_ID 0x2A50
+
+/* HID characteristics */
+#define GATT_UUID_HID_INFORMATION 0x2A4A
+#define GATT_UUID_HID_REPORT_MAP 0x2A4B
+#define GATT_UUID_HID_CONTROL_POINT 0x2A4C
+#define GATT_UUID_HID_REPORT 0x2A4D
+#define GATT_UUID_HID_PROTO_MODE 0x2A4E
+#define GATT_UUID_HID_BT_KB_INPUT 0x2A22
+#define GATT_UUID_HID_BT_KB_OUTPUT 0x2A32
+#define GATT_UUID_HID_BT_MOUSE_INPUT 0x2A33
+
+/* Battery Service char */
+#define GATT_UUID_BATTERY_LEVEL 0x2A19
+
+#define GATT_UUID_SC_CONTROL_POINT 0x2A55
+#define GATT_UUID_SENSOR_LOCATION 0x2A5D
+
+/* RUNNERS SPEED AND CADENCE SERVICE */
+#define GATT_UUID_RSC_MEASUREMENT 0x2A53
+#define GATT_UUID_RSC_FEATURE 0x2A54
+
+/* CYCLING SPEED AND CADENCE SERVICE */
+#define GATT_UUID_CSC_MEASUREMENT 0x2A5B
+#define GATT_UUID_CSC_FEATURE 0x2A5C
+
+
+/* Scan Parameter charatceristics */
+#define GATT_UUID_SCAN_INT_WINDOW 0x2A4F
+#define GATT_UUID_SCAN_REFRESH 0x2A31
+
+#define GATT_UUID_CLIENT_SUP_FEAT 0x2B29
+#define GATT_UUID_GATT_DATABASE_HASH 0x2B2A
+#define GATT_UUID_SERVER_SUP_FEAT 0x2B3A
+
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/hcidefs.h b/lib/bt/host/bluedroid/stack/include/stack/hcidefs.h
new file mode 100644
index 00000000..8c5ba3f2
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/hcidefs.h
@@ -0,0 +1,2730 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef HCIDEFS_H
+#define HCIDEFS_H
+
+#include "common/bt_target.h"
+
+#include "stack/bt_types.h"
+
+#define HCI_PROTO_VERSION 0x01 /* Version for BT spec 1.1 */
+#define HCI_PROTO_VERSION_1_2 0x02 /* Version for BT spec 1.2 */
+#define HCI_PROTO_VERSION_2_0 0x03 /* Version for BT spec 2.0 */
+#define HCI_PROTO_VERSION_2_1 0x04 /* Version for BT spec 2.1 [Lisbon] */
+#define HCI_PROTO_VERSION_3_0 0x05 /* Version for BT spec 3.0 */
+#define HCI_PROTO_VERSION_4_0 0x06 /* Version for BT spec 4.0 */
+#define HCI_PROTO_VERSION_4_1 0x07 /* Version for BT spec 4.1 */
+#define HCI_PROTO_VERSION_4_2 0x08 /* Version for BT spec 4.2 */
+#define HCI_PROTO_REVISION 0x000C /* Current implementation version */
+/*
+** Definitions for HCI groups
+*/
+#define HCI_GRP_LINK_CONTROL_CMDS (0x01 << 10) /* 0x0400 */
+#define HCI_GRP_LINK_POLICY_CMDS (0x02 << 10) /* 0x0800 */
+#define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10) /* 0x0C00 */
+#define HCI_GRP_INFORMATIONAL_PARAMS (0x04 << 10) /* 0x1000 */
+#define HCI_GRP_STATUS_PARAMS (0x05 << 10) /* 0x1400 */
+#define HCI_GRP_TESTING_CMDS (0x06 << 10) /* 0x1800 */
+
+#define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10) /* 0xFC00 */
+
+/* Group occupies high 6 bits of the HCI command rest is opcode itself */
+#define HCI_OGF(p) (UINT8)(0x003F & (p >> 10))
+#define HCI_OCF(p) ( 0x3FF & (p))
+
+/*
+** Definitions for Link Control Commands
+*/
+/* Following opcode is used only in command complete event for flow control */
+#define HCI_COMMAND_NONE 0x0000
+
+/* Commands of HCI_GRP_LINK_CONTROL_CMDS group */
+#define HCI_INQUIRY (0x0001 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_INQUIRY_CANCEL (0x0002 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_PERIODIC_INQUIRY_MODE (0x0003 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_EXIT_PERIODIC_INQUIRY_MODE (0x0004 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_CREATE_CONNECTION (0x0005 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_DISCONNECT (0x0006 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_ADD_SCO_CONNECTION (0x0007 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_CREATE_CONNECTION_CANCEL (0x0008 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_ACCEPT_CONNECTION_REQUEST (0x0009 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_REJECT_CONNECTION_REQUEST (0x000A | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_LINK_KEY_REQUEST_REPLY (0x000B | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_LINK_KEY_REQUEST_NEG_REPLY (0x000C | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_PIN_CODE_REQUEST_REPLY (0x000D | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_PIN_CODE_REQUEST_NEG_REPLY (0x000E | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_CHANGE_CONN_PACKET_TYPE (0x000F | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_AUTHENTICATION_REQUESTED (0x0011 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_SET_CONN_ENCRYPTION (0x0013 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_CHANGE_CONN_LINK_KEY (0x0015 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_MASTER_LINK_KEY (0x0017 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_RMT_NAME_REQUEST (0x0019 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_RMT_NAME_REQUEST_CANCEL (0x001A | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_READ_RMT_FEATURES (0x001B | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_READ_RMT_EXT_FEATURES (0x001C | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_READ_RMT_VERSION_INFO (0x001D | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_READ_RMT_CLOCK_OFFSET (0x001F | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_READ_LMP_HANDLE (0x0020 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_SETUP_ESCO_CONNECTION (0x0028 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_ACCEPT_ESCO_CONNECTION (0x0029 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_REJECT_ESCO_CONNECTION (0x002A | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_IO_CAPABILITY_REQUEST_REPLY (0x002B | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_USER_CONF_REQUEST_REPLY (0x002C | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_USER_CONF_VALUE_NEG_REPLY (0x002D | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_USER_PASSKEY_REQ_REPLY (0x002E | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_USER_PASSKEY_REQ_NEG_REPLY (0x002F | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_REM_OOB_DATA_REQ_REPLY (0x0030 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_REM_OOB_DATA_REQ_NEG_REPLY (0x0033 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_IO_CAP_REQ_NEG_REPLY (0x0034 | HCI_GRP_LINK_CONTROL_CMDS)
+
+/* AMP HCI */
+#define HCI_CREATE_PHYSICAL_LINK (0x0035 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_ACCEPT_PHYSICAL_LINK (0x0036 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_DISCONNECT_PHYSICAL_LINK (0x0037 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_CREATE_LOGICAL_LINK (0x0038 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_ACCEPT_LOGICAL_LINK (0x0039 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_DISCONNECT_LOGICAL_LINK (0x003A | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_LOGICAL_LINK_CANCEL (0x003B | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_FLOW_SPEC_MODIFY (0x003C | HCI_GRP_LINK_CONTROL_CMDS)
+
+#define HCI_ENH_SETUP_ESCO_CONNECTION (0x003D | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_ENH_ACCEPT_ESCO_CONNECTION (0x003E | HCI_GRP_LINK_CONTROL_CMDS)
+
+/* ConnectionLess Broadcast */
+#define HCI_TRUNCATED_PAGE (0x003F | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_TRUNCATED_PAGE_CANCEL (0x0040 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_SET_CLB (0x0041 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_RECEIVE_CLB (0x0042 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_START_SYNC_TRAIN (0x0043 | HCI_GRP_LINK_CONTROL_CMDS)
+#define HCI_RECEIVE_SYNC_TRAIN (0x0044 | HCI_GRP_LINK_CONTROL_CMDS)
+
+#define HCI_LINK_CTRL_CMDS_FIRST HCI_INQUIRY
+#define HCI_LINK_CTRL_CMDS_LAST HCI_RECEIVE_SYNC_TRAIN
+
+/* Commands of HCI_GRP_LINK_POLICY_CMDS */
+#define HCI_HOLD_MODE (0x0001 | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_SNIFF_MODE (0x0003 | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_EXIT_SNIFF_MODE (0x0004 | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_PARK_MODE (0x0005 | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_EXIT_PARK_MODE (0x0006 | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_QOS_SETUP (0x0007 | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_ROLE_DISCOVERY (0x0009 | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_SWITCH_ROLE (0x000B | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_READ_POLICY_SETTINGS (0x000C | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_WRITE_POLICY_SETTINGS (0x000D | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_READ_DEF_POLICY_SETTINGS (0x000E | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_WRITE_DEF_POLICY_SETTINGS (0x000F | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_FLOW_SPECIFICATION (0x0010 | HCI_GRP_LINK_POLICY_CMDS)
+#define HCI_SNIFF_SUB_RATE (0x0011 | HCI_GRP_LINK_POLICY_CMDS)
+
+#define HCI_LINK_POLICY_CMDS_FIRST HCI_HOLD_MODE
+#define HCI_LINK_POLICY_CMDS_LAST HCI_SNIFF_SUB_RATE
+
+
+/* Commands of HCI_GRP_HOST_CONT_BASEBAND_CMDS */
+#define HCI_SET_EVENT_MASK (0x0001 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_EVENT_FILTER (0x0005 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_FLUSH (0x0008 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_PIN_TYPE (0x0009 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_PIN_TYPE (0x000A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_CREATE_NEW_UNIT_KEY (0x000B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_GET_MWS_TRANS_LAYER_CFG (0x000C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_STORED_LINK_KEY (0x000D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_STORED_LINK_KEY (0x0011 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_DELETE_STORED_LINK_KEY (0x0012 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_CHANGE_LOCAL_NAME (0x0013 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_LOCAL_NAME (0x0014 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_CONN_ACCEPT_TOUT (0x0015 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_CONN_ACCEPT_TOUT (0x0016 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_PAGE_TOUT (0x0017 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_PAGE_TOUT (0x0018 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_SCAN_ENABLE (0x0019 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_SCAN_ENABLE (0x001A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_PAGESCAN_CFG (0x001B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_PAGESCAN_CFG (0x001C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_INQUIRYSCAN_CFG (0x001D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_INQUIRYSCAN_CFG (0x001E | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_AUTHENTICATION_ENABLE (0x001F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_AUTHENTICATION_ENABLE (0x0020 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_ENCRYPTION_MODE (0x0021 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_ENCRYPTION_MODE (0x0022 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_CLASS_OF_DEVICE (0x0023 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_CLASS_OF_DEVICE (0x0024 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_VOICE_SETTINGS (0x0025 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_VOICE_SETTINGS (0x0026 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_AUTO_FLUSH_TOUT (0x0027 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_AUTO_FLUSH_TOUT (0x0028 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_NUM_BCAST_REXMITS (0x0029 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_NUM_BCAST_REXMITS (0x002A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_HOLD_MODE_ACTIVITY (0x002B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_HOLD_MODE_ACTIVITY (0x002C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_TRANSMIT_POWER_LEVEL (0x002D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_SCO_FLOW_CTRL_ENABLE (0x002E | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_SCO_FLOW_CTRL_ENABLE (0x002F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_HC_TO_HOST_FLOW_CTRL (0x0031 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_HOST_BUFFER_SIZE (0x0033 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_HOST_NUM_PACKETS_DONE (0x0035 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_LINK_SUPER_TOUT (0x0036 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_LINK_SUPER_TOUT (0x0037 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_NUM_SUPPORTED_IAC (0x0038 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_CURRENT_IAC_LAP (0x0039 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_CURRENT_IAC_LAP (0x003A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_PAGESCAN_PERIOD_MODE (0x003B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_PAGESCAN_PERIOD_MODE (0x003C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_PAGESCAN_MODE (0x003D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_PAGESCAN_MODE (0x003E | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_AFH_CHANNELS (0x003F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+
+#define HCI_READ_INQSCAN_TYPE (0x0042 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_INQSCAN_TYPE (0x0043 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_INQUIRY_MODE (0x0044 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_INQUIRY_MODE (0x0045 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_PAGESCAN_TYPE (0x0046 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_PAGESCAN_TYPE (0x0047 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_AFH_ASSESSMENT_MODE (0x0048 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_AFH_ASSESSMENT_MODE (0x0049 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_EXT_INQ_RESPONSE (0x0051 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_EXT_INQ_RESPONSE (0x0052 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_REFRESH_ENCRYPTION_KEY (0x0053 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_SIMPLE_PAIRING_MODE (0x0055 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_SIMPLE_PAIRING_MODE (0x0056 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_LOCAL_OOB_DATA (0x0057 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_INQ_TX_POWER_LEVEL (0x0058 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_INQ_TX_POWER_LEVEL (0x0059 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_ERRONEOUS_DATA_RPT (0x005A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_ERRONEOUS_DATA_RPT (0x005B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_ENHANCED_FLUSH (0x005F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SEND_KEYPRESS_NOTIF (0x0060 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+
+
+/* AMP HCI */
+#define HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT (0x0061 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT (0x0062 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_EVENT_MASK_PAGE_2 (0x0063 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_LOCATION_DATA (0x0064 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_LOCATION_DATA (0x0065 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_FLOW_CONTROL_MODE (0x0066 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_FLOW_CONTROL_MODE (0x0067 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_BE_FLUSH_TOUT (0x0069 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_BE_FLUSH_TOUT (0x006A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SHORT_RANGE_MODE (0x006B | HCI_GRP_HOST_CONT_BASEBAND_CMDS) /* 802.11 only */
+#define HCI_READ_LE_HOST_SUPPORT (0x006C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_LE_HOST_SUPPORT (0x006D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+
+
+/* MWS coexistence */
+#define HCI_SET_MWS_CHANNEL_PARAMETERS (0x006E | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_EXTERNAL_FRAME_CONFIGURATION (0x006F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_MWS_SIGNALING (0x0070 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_MWS_TRANSPORT_LAYER (0x0071 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_MWS_SCAN_FREQUENCY_TABLE (0x0072 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_MWS_PATTERN_CONFIGURATION (0x0073 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+
+/* Connectionless Broadcast */
+#define HCI_SET_RESERVED_LT_ADDR (0x0074 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_DELETE_RESERVED_LT_ADDR (0x0075 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_CLB_DATA (0x0076 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_SYNC_TRAIN_PARAM (0x0077 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_SYNC_TRAIN_PARAM (0x0078 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+
+#define HCI_READ_SECURE_CONNS_SUPPORT (0x0079 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_SECURE_CONNS_SUPPORT (0x007A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_CONT_BASEBAND_CMDS_FIRST HCI_SET_EVENT_MASK
+#define HCI_CONT_BASEBAND_CMDS_LAST HCI_READ_SYNC_TRAIN_PARAM
+
+
+/* Commands of HCI_GRP_INFORMATIONAL_PARAMS group */
+#define HCI_READ_LOCAL_VERSION_INFO (0x0001 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_LOCAL_SUPPORTED_CMDS (0x0002 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_LOCAL_FEATURES (0x0003 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_LOCAL_EXT_FEATURES (0x0004 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_BUFFER_SIZE (0x0005 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_COUNTRY_CODE (0x0007 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_BD_ADDR (0x0009 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_DATA_BLOCK_SIZE (0x000A | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_LOCAL_SUPPORTED_CODECS (0x000B | HCI_GRP_INFORMATIONAL_PARAMS)
+
+#define HCI_INFORMATIONAL_CMDS_FIRST HCI_READ_LOCAL_VERSION_INFO
+#define HCI_INFORMATIONAL_CMDS_LAST HCI_READ_LOCAL_SUPPORTED_CODECS
+
+
+/* Commands of HCI_GRP_STATUS_PARAMS group */
+#define HCI_READ_FAILED_CONTACT_COUNT (0x0001 | HCI_GRP_STATUS_PARAMS)
+#define HCI_RESET_FAILED_CONTACT_COUNT (0x0002 | HCI_GRP_STATUS_PARAMS)
+#define HCI_GET_LINK_QUALITY (0x0003 | HCI_GRP_STATUS_PARAMS)
+#define HCI_READ_RSSI (0x0005 | HCI_GRP_STATUS_PARAMS)
+#define HCI_READ_AFH_CH_MAP (0x0006 | HCI_GRP_STATUS_PARAMS)
+#define HCI_READ_CLOCK (0x0007 | HCI_GRP_STATUS_PARAMS)
+#define HCI_READ_ENCR_KEY_SIZE (0x0008 | HCI_GRP_STATUS_PARAMS)
+
+/* AMP HCI */
+#define HCI_READ_LOCAL_AMP_INFO (0x0009 | HCI_GRP_STATUS_PARAMS)
+#define HCI_READ_LOCAL_AMP_ASSOC (0x000A | HCI_GRP_STATUS_PARAMS)
+#define HCI_WRITE_REMOTE_AMP_ASSOC (0x000B | HCI_GRP_STATUS_PARAMS)
+
+#define HCI_STATUS_PARAMS_CMDS_FIRST HCI_READ_FAILED_CONTACT_COUNT
+#define HCI_STATUS_PARAMS_CMDS_LAST HCI_WRITE_REMOTE_AMP_ASSOC
+
+/* Commands of HCI_GRP_TESTING_CMDS group */
+#define HCI_READ_LOOPBACK_MODE (0x0001 | HCI_GRP_TESTING_CMDS)
+#define HCI_WRITE_LOOPBACK_MODE (0x0002 | HCI_GRP_TESTING_CMDS)
+#define HCI_ENABLE_DEV_UNDER_TEST_MODE (0x0003 | HCI_GRP_TESTING_CMDS)
+#define HCI_WRITE_SIMP_PAIR_DEBUG_MODE (0x0004 | HCI_GRP_TESTING_CMDS)
+
+/* AMP HCI */
+#define HCI_ENABLE_AMP_RCVR_REPORTS (0x0007 | HCI_GRP_TESTING_CMDS)
+#define HCI_AMP_TEST_END (0x0008 | HCI_GRP_TESTING_CMDS)
+#define HCI_AMP_TEST (0x0009 | HCI_GRP_TESTING_CMDS)
+
+#define HCI_TESTING_CMDS_FIRST HCI_READ_LOOPBACK_MODE
+#define HCI_TESTING_CMDS_LAST HCI_AMP_TEST
+
+#define HCI_VENDOR_CMDS_FIRST 0x0001
+#define HCI_VENDOR_CMDS_LAST 0xFFFF
+#define HCI_VSC_MULTI_AV_HANDLE 0x0AAA
+#define HCI_VSC_BURST_MODE_HANDLE 0x0BBB
+
+/* BLE HCI */
+#define HCI_GRP_BLE_CMDS (0x08 << 10)
+/* Commands of BLE Controller setup and configuration */
+#define HCI_BLE_SET_EVENT_MASK (0x0001 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_BUFFER_SIZE (0x0002 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_LOCAL_SPT_FEAT (0x0003 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WRITE_LOCAL_SPT_FEAT (0x0004 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WRITE_RANDOM_ADDR (0x0005 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WRITE_ADV_PARAMS (0x0006 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_ADV_CHNL_TX_POWER (0x0007 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WRITE_ADV_DATA (0x0008 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WRITE_SCAN_RSP_DATA (0x0009 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WRITE_ADV_ENABLE (0x000A | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WRITE_SCAN_PARAMS (0x000B | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WRITE_SCAN_ENABLE (0x000C | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_CREATE_LL_CONN (0x000D | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_CREATE_CONN_CANCEL (0x000E | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_WHITE_LIST_SIZE (0x000F | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_CLEAR_WHITE_LIST (0x0010 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_ADD_WHITE_LIST (0x0011 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_REMOVE_WHITE_LIST (0x0012 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_UPD_LL_CONN_PARAMS (0x0013 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_HOST_CHNL_CLASS (0x0014 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_CHNL_MAP (0x0015 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_REMOTE_FEAT (0x0016 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_ENCRYPT (0x0017 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_RAND (0x0018 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_START_ENC (0x0019 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_LTK_REQ_REPLY (0x001A | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_LTK_REQ_NEG_REPLY (0x001B | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_SUPPORTED_STATES (0x001C | HCI_GRP_BLE_CMDS)
+/*0x001D, 0x001E and 0x001F are reserved*/
+#define HCI_BLE_RECEIVER_TEST (0x001D | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_TRANSMITTER_TEST (0x001E | HCI_GRP_BLE_CMDS)
+/* BLE TEST COMMANDS */
+#define HCI_BLE_TEST_END (0x001F | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_RC_PARAM_REQ_REPLY (0x0020 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_RC_PARAM_REQ_NEG_REPLY (0x0021 | HCI_GRP_BLE_CMDS)
+
+#define HCI_BLE_SET_DATA_LENGTH (0x0022 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_DEFAULT_DATA_LENGTH (0x0023 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WRITE_DEFAULT_DATA_LENGTH (0x0024 | HCI_GRP_BLE_CMDS)
+
+#define HCI_BLE_ADD_DEV_RESOLVING_LIST (0x0027 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_RM_DEV_RESOLVING_LIST (0x0028 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_CLEAR_RESOLVING_LIST (0x0029 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_RESOLVING_LIST_SIZE (0x002A | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_RESOLVABLE_ADDR_PEER (0x002B | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL (0x002C | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_ADDR_RESOLUTION_ENABLE (0x002D | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT (0x002E | HCI_GRP_BLE_CMDS)
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#define HCI_BLE_READ_PHY (0x0030 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_DEFAULT_PHY (0x0031 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_PHY (0x0032 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_ENH_RX_TEST (0x0033 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_ENH_TX_TEST (0x0034 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_ADV_RAND_ADDR (0x0035 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_EXT_ADV_PARAM (0x0036 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_EXT_ADV_DATA (0x0037 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_EXT_SCAN_RSP_DATA (0x0038 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_EXT_ADV_ENABLE (0x0039 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_RD_MAX_ADV_DATA_LEN (0x003A | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_RD_NUM_OF_ADV_SETS (0x003B | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_REMOVE_ADV_SET (0x003C | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_CLEAR_ADV_SETS (0x003D | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_PERIOD_ADV_PARAMS (0x003E | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_PERIOD_ADV_DATA (0x003F | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_PERIOD_ADV_ENABLE (0x0040 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_EXT_SCAN_PARAMS (0x0041 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_EXT_SCAN_ENABLE (0x0042 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_EXT_CREATE_CONN (0x0043 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_PERIOD_ADV_CREATE_SYNC (0x0044 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_PERIOD_ADV_CREATE_SYNC_CANCEL (0x0045 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_PERIOD_ADV_TERM_SYNC (0x0046 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_ADV_DEV_TO_PERIOD_ADV_LIST (0x0047 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_REMOVE_DEV_FROM_PERIOD_ADV_LIST (0x0048 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_CLEAR_PERIOD_ADV_LIST (0x0049 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_RD_PERIOD_ADV_LIST_SIZE (0x004A | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_RD_TRANSMIT_POWER (0x004B | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_RD_RF_PATH_COMPENSATION (0x004C | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_WR_RF_PATH_COMPENSATION (0x004D | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_PRIVACY_MODE (0x004E | HCI_GRP_BLE_CMDS)
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+#define HCI_BLE_SET_PERIOD_ADV_RECV_ENABLE (0x0059 | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_PERIOD_ADV_SYNC_TRANS (0x005A | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_PERIOD_ADV_SET_INFO_TRANS (0x005B | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_PAST_PARAMS (0x005C | HCI_GRP_BLE_CMDS)
+#define HCI_BLE_SET_DEFAULT_PAST_PARAMS (0x005D | HCI_GRP_BLE_CMDS)
+#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+// Vendor OGF define
+#define HCI_VENDOR_OGF 0x3F
+
+// ESP vendor group define
+#define HCI_ESP_GROUP_COMMON 0x01
+#define HCI_ESP_GROUP_BLE 0x02
+#define HCI_ESP_GROUP_BT 0x03
+#define HCI_ESP_GROUP_END 0x07
+
+//ESP common subcode define
+#define HCI_SUBCODE_COMMON_INIT 0x00
+#define HCI_SUBCODE_COMMON_ECHO 0x01
+#define HCI_SUBCODE_COMMON_COEX_STATUS 0x02
+#define HCI_SUBCODE_COMMON_MAX 0x7F
+
+//ESP BLE subcode define
+#define HCI_SUBCODE_BLE_INIT 0x00
+#define HCI_SUBCODE_BLE_MULTI_ADV 0x01
+#define HCI_SUBCODE_BLE_BATCH_SCAN 0x02
+#define HCI_SUBCODE_BLE_ADV_FILTER 0x03
+#define HCI_SUBCODE_BLE_TRACK_ADV 0x04
+#define HCI_SUBCODE_BLE_ENERGY_INFO 0x05
+#define HCI_SUBCODE_BLE_EXTENDED_SCAN_PARAMS 0x06
+#define HCI_SUBCODE_BLE_LONG_ADV 0x07
+#define HCI_SUBCODE_BLE_DUPLICATE_EXCEPTIONAL_LIST 0x08
+#define HCI_SUBCODE_BLE_SET_ADV_FLOW_CONTROL 0x09
+#define HCI_SUBCODE_BLE_ADV_REPORT_FLOW_CONTROL 0x0A
+#define HCI_SUBCODE_BLE_RD_STATIC_ADDR 0x0B
+#define HCI_SUBCODE_BLE_CLEAR_ADV 0x0C
+#define HCI_SUBCODE_BLE_MAX 0x7F
+
+//ESP BT subcode define
+#define HCI_SUBCODE_BT_INIT 0x00
+#define HCI_SUBCODE_BT_MAX 0x7F
+
+#define HCI_ESP_VENDOR_OPCODE_BUILD(ogf, group, subcode) ((ogf << 10) | (group <<7) | (subcode << 0))
+/*
+* | OGF | VENDIOR GROUP | GROUP SUBCODE |
+* | 1 1 1 1 1 1 | 0 0 0 | X X X X X X X | Already Exist
+* | 1 1 1 1 1 1 | 0 0 1 | X X X X X X X | ESP VENDOR COMMON HCI CMD
+* | 1 1 1 1 1 1 | 0 1 0 | X X X X X X X | ESP VENDOR BLE HCI CMD
+* | 1 1 1 1 1 1 | 0 1 1 | X X X X X X X | ESP VENDOR BT HCI CMD
+* | 1 1 1 1 1 1 | 1 0 0 | X X X X X X X | RESERVED FOR FUTURE USE
+* | 1 1 1 1 1 1 | 1 0 1 | X X X X X X X | RESERVED FOR FUTURE USE
+* | 1 1 1 1 1 1 | 1 1 0 | X X X X X X X | RESERVED FOR FUTURE USE
+* | 1 1 1 1 1 1 | 1 1 1 | X X X X X X X | RESERVED FOR FUTURE USE
+*/
+
+// ESP COMMON HCI CMD
+#define HCI_VENDOR_COMMON_ECHO_CMD_OPCODE HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_COMMON, HCI_SUBCODE_COMMON_ECHO)
+// Set/clear coex schm status
+#define HCI_VENDOR_COMMON_COEX_STATUS_CMD_OPCODE HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_COMMON, HCI_SUBCODE_COMMON_COEX_STATUS)
+
+//ESP BLE HCI CMD
+/* Multi adv OCF */
+#define HCI_BLE_MULTI_ADV_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_MULTI_ADV)
+/* Batch scan OCF */
+#define HCI_BLE_BATCH_SCAN_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_BATCH_SCAN)
+/* ADV filter OCF */
+#define HCI_BLE_ADV_FILTER_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_ADV_FILTER)
+/* Tracking OCF */
+#define HCI_BLE_TRACK_ADV_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_TRACK_ADV)
+/* Energy info OCF */
+#define HCI_BLE_ENERGY_INFO_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_ENERGY_INFO)
+/* Extended BLE Scan parameters OCF */
+#define HCI_BLE_EXTENDED_SCAN_PARAMS_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_EXTENDED_SCAN_PARAMS)
+/* Long BLE Adv data OCF */
+#define HCI_VENDOR_BLE_LONG_ADV_DATA HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_LONG_ADV)
+/* BLE update duplicate scan exceptional list */
+#define HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_DUPLICATE_EXCEPTIONAL_LIST)
+#define HCI_VENDOR_BLE_SET_ADV_FLOW_CONTROL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_SET_ADV_FLOW_CONTROL)
+#define HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_ADV_REPORT_FLOW_CONTROL)
+/* BLE clear legacy advertising */
+#define HCI_VENDOR_BLE_CLEAR_ADV HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_CLEAR_ADV)
+//ESP BT HCI CMD
+
+/* subcode for multi adv feature */
+#define BTM_BLE_MULTI_ADV_SET_PARAM 0x01
+#define BTM_BLE_MULTI_ADV_WRITE_ADV_DATA 0x02
+#define BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA 0x03
+#define BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR 0x04
+#define BTM_BLE_MULTI_ADV_ENB 0x05
+
+/* multi adv VSE subcode */
+#define HCI_VSE_SUBCODE_BLE_MULTI_ADV_ST_CHG 0x55 /* multi adv instance state change */
+
+/* subcode for batch scan feature */
+#define BTM_BLE_BATCH_SCAN_ENB_DISAB_CUST_FEATURE 0x01
+#define BTM_BLE_BATCH_SCAN_SET_STORAGE_PARAM 0x02
+#define BTM_BLE_BATCH_SCAN_SET_PARAMS 0x03
+#define BTM_BLE_BATCH_SCAN_READ_RESULTS 0x04
+
+/* batch scan VSE subcode */
+#define HCI_VSE_SUBCODE_BLE_THRESHOLD_SUB_EVT 0x54 /* Threshold event */
+
+/* tracking sub event */
+#define HCI_VSE_SUBCODE_BLE_TRACKING_SUB_EVT 0x56 /* Tracking event */
+
+/* LE supported states definition */
+#define HCI_LE_ADV_STATE 0x00000001
+#define HCI_LE_SCAN_STATE 0x00000002
+#define HCI_LE_INIT_STATE 0x00000004
+#define HCI_LE_CONN_SL_STATE 0x00000008
+#define HCI_LE_ADV_SCAN_STATE 0x00000010
+#define HCI_LE_ADV_INIT_STATE 0x00000020
+#define HCI_LE_ADV_MA_STATE 0x00000040
+#define HCI_LE_ADV_SL_STATE 0x00000080
+#define HCI_LE_SCAN_INIT_STATE 0x00000100
+#define HCI_LE_SCAN_MA_STATE 0x00000200
+#define HCI_LE_SCAN_SL_STATE 0x00000400
+#define HCI_LE_INIT_MA_STATE 0x00000800
+
+/* LE Supported States */
+/* Non Connectable Adv state is supported. 0x0000000000000001 */
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_MASK 0x01
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_OFF 0
+#define HCI_LE_STATES_NON_CONN_ADV_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_NON_CONN_ADV_OFF] & HCI_SUPP_LE_STATES_NON_CONN_ADV_MASK)
+
+/*Scanneable Connectable Adv state is supported. 0x0000000000000002 */
+#define HCI_SUPP_LE_STATES_SCAN_ADV_MASK 0x02
+#define HCI_SUPP_LE_STATESSCAN_ADV_OFF 0
+#define HCI_LE_STATES_SCAN_ADV_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATESSCAN_ADV_OFF] & HCI_SUPP_LE_STATES_SCAN_ADV_MASK)
+
+/* Connectable Adv state is supported. 0x0000000000000004 */
+#define HCI_SUPP_LE_STATES_CONN_ADV_MASK 0x04
+#define HCI_SUPP_LE_STATES_CONN_ADV_OFF 0
+#define HCI_LE_STATES_CONN_ADV_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_CONN_ADV_OFF] & HCI_SUPP_LE_STATES_CONN_ADV_MASK)
+
+/* Hi duty Cycle Directed Adv state is supported. 0x0000000000000008 */
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_MASK 0x08
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_OFF 0
+#define HCI_LE_STATES_HI_DUTY_DIR_ADV_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_OFF] & HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_MASK)
+
+/* Passive Scan state is supported. 0x0000000000000010 */
+#define HCI_SUPP_LE_STATES_PASS_SCAN_MASK 0x10
+#define HCI_SUPP_LE_STATES_PASS_SCAN_OFF 0
+#define HCI_LE_STATES_PASS_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_PASS_SCAN_OFF] & HCI_SUPP_LE_STATES_PASS_SCAN_MASK)
+
+/* Active Scan state is supported. 0x0000000000000020 */
+#define HCI_SUPP_LE_STATES_ACTIVE_SCAN_MASK 0x20
+#define HCI_SUPP_LE_STATES_ACTIVE_SCAN_OFF 0
+#define HCI_LE_STATES_ACTIVE_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_ACTIVE_SCAN_OFF] & HCI_SUPP_LE_STATES_ACTIVE_SCAN_MASK)
+
+/* Initiating state is supported. 0x0000000000000040 (or connection state in master role is also supported) */
+#define HCI_SUPP_LE_STATES_INIT_MASK 0x40
+#define HCI_SUPP_LE_STATES_INIT_OFF 0
+#define HCI_LE_STATES_INIT_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_INIT_OFF] & HCI_SUPP_LE_STATES_INIT_MASK)
+
+/*connection state in slave role is also supported. 0x0000000000000080 */
+#define HCI_SUPP_LE_STATES_SLAVE_MASK 0x80
+#define HCI_SUPP_LE_STATES_SLAVE_OFF 0
+#define HCI_LE_STATES_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_SLAVE_OFF] & HCI_SUPP_LE_STATES_SLAVE_MASK)
+
+/* Non Connectable Adv state and Passive Scanning State combination is supported. 0x0000000000000100 */
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_PASS_SCAN_MASK 0x01
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_PASS_SCAN_OFF 1
+#define HCI_LE_STATES_NON_CONN_ADV_PASS_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_NON_CONN_ADV_PASS_SCAN_OFF] & HCI_SUPP_LE_STATES_NON_CONN_ADV_PASS_SCAN_MASK)
+
+/*Scannable Adv state and Passive Scanning State combination is supported. 0x0000000000000200 */
+#define HCI_SUPP_LE_STATES_SCAN_ADV_PASS_SCAN_MASK 0x02
+#define HCI_SUPP_LE_STATES_SCAN_ADV_PASS_SCAN_OFF 1
+#define HCI_LE_STATES_SCAN_ADV_PASS_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_SCAN_ADV_PASS_SCAN_OFF] & HCI_SUPP_LE_STATES_SCAN_ADV_PASS_SCAN_MASK)
+
+/*Connectable Adv state and Passive Scanning State combination is supported. 0x0000000000000400 */
+#define HCI_SUPP_LE_STATES_CONN_ADV_PASS_SCAN_MASK 0x04
+#define HCI_SUPP_LE_STATES_CONN_ADV_PASS_SCAN_OFF 1
+#define HCI_LE_STATES_CONN_ADV_PASS_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_CONN_ADV_PASS_SCAN_OFF] & HCI_SUPP_LE_STATES_CONN_ADV_PASS_SCAN_MASK)
+
+/*High Duty Cycl Directed ADv and Passive Scanning State combination is supported. 0x0000000000000800 */
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_PASS_SCAN_MASK 0x08
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_PASS_SCAN_OFF 1
+#define HCI_LE_STATES_HI_DUTY_DIR_ADV_PASS_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_PASS_SCAN_MASK] & HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_PASS_SCAN_OFF)
+
+/*Non Connectable Adv state and Passive Scanning State combination is supported. 0x0000000000001000 */
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_ACTIVE_SCAN_MASK 0x10
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_ACTIVE_SCAN_OFF 1
+#define HCI_LE_STATES_NON_CONN_ADV_ACTIVE_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_NON_CONN_ADV_ACTIVE_SCAN_OFF] & HCI_SUPP_LE_STATES_NON_CONN_ADV_ACTIVE_SCAN_MASK)
+
+/*Scannable Adv state and Active Scanning State combination is supported. 0x0000000000002000 */
+#define HCI_SUPP_LE_STATES_SCAN_ADV_ACTIVE_SCAN_MASK 0x20
+#define HCI_SUPP_LE_STATES_SCAN_ADV_ACTIVE_SCAN_OFF 1
+#define HCI_LE_STATES_SCAN_ADV_ACTIVE_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_SCAN_ADV_ACTIVE_SCAN_OFF] & HCI_SUPP_LE_STATES_SCAN_ADV_ACTIVE_SCAN_MASK)
+
+/*Connectable Adv state and Active Scanning State combination is supported. 0x0000000000004000 */
+#define HCI_SUPP_LE_STATES_CONN_ADV_ACTIVE_SCAN_MASK 0x40
+#define HCI_SUPP_LE_STATES_CONN_ADV_ACTIVE_SCAN_OFF 1
+#define HCI_LE_STATES_CONN_ADV_ACTIVE_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_CONN_ADV_ACTIVE_SCAN_OFF] & HCI_SUPP_LE_STATES_CONN_ADV_ACTIVE_SCAN_MASK)
+
+/*High Duty Cycl Directed ADv and ACtive Scanning State combination is supported. 0x0000000000008000 */
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_ACTIVE_SCAN_MASK 0x80
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_ACTIVE_SCAN_OFF 1
+#define HCI_LE_STATES_HI_DUTY_DIR_ADV_ACTIVE_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_ACTIVE_SCAN_MASK] & HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_ACTIVE_SCAN_OFF)
+
+/*Non-Connectable Adv state and Initiating State combination is supported. 0x0000000000010000 */
+#define HCI_SUPP_LE_STATES_NON_CONN_INIT_MASK 0x01
+#define HCI_SUPP_LE_STATES_NON_CONN_INIT_OFF 2
+#define HCI_LE_STATES_NON_CONN_INIT_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_NON_CONN_INIT_OFF] & HCI_SUPP_LE_STATES_NON_CONN_INIT_MASK)
+
+/* Scannable Adv state and Initiating State combination is supported. 0x0000000000020000 */
+#define HCI_SUPP_LE_STATES_SCAN_ADV_INIT_MASK 0x02
+#define HCI_SUPP_LE_STATES_SCAN_ADV_INIT_OFF 2
+#define HCI_LE_STATES_SCAN_ADV_INIT_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_SCAN_ADV_INIT_OFF] & HCI_SUPP_LE_STATES_SCAN_ADV_INIT_MASK)
+
+/* Non-Connectable Adv state and Master Role combination is supported. 0x0000000000040000 */
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_MASTER_MASK 0x04
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_MASTER_OFF 2
+#define HCI_LE_STATES_NON_CONN_ADV_MASTER_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_NON_CONN_ADV_MASTER_OFF] & HCI_SUPP_LE_STATES_NON_CONN_ADV_MASTER_MASK)
+
+/*Scannable Adv state and Master Role combination is supported. 0x0000000000040000 */
+#define HCI_SUPP_LE_STATES_SCAN_ADV_MASTER_MASK 0x08
+#define HCI_SUPP_LE_STATES_SCAN_ADV_MASTER_OFF 2
+#define HCI_LE_STATES_SCAN_ADV_MASTER_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_SCAN_ADV_MASTER_OFF] & HCI_SUPP_LE_STATES_SCAN_ADV_MASTER_MASK)
+
+/* Non-Connectable Adv and Slave Role combination is supported. 0x000000000100000 */
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_SLAVE_MASK 0x10
+#define HCI_SUPP_LE_STATES_NON_CONN_ADV_SLAVE_OFF 2
+#define HCI_LE_STATES_NON_CONN_ADV_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_NON_CONN_ADV_SLAVE_OFF] & HCI_SUPP_LE_STATES_NON_CONN_ADV_SLAVE_MASK)
+
+/*Scannable Adv and Slave Role combination is supported. 0x000000000200000 */
+#define HCI_SUPP_LE_STATES_SCAN_ADV_SLAVE_MASK 0x20
+#define HCI_SUPP_LE_STATES_SCAN_ADV_SLAVE_OFF 2
+#define HCI_LE_STATES_SCAN_ADV_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_SCAN_ADV_SLAVE_OFF] & HCI_SUPP_LE_STATES_SCAN_ADV_SLAVE_MASK)
+
+/*Passive Scan and Initiating State combination is supported. 0x000000000400000 */
+#define HCI_SUPP_LE_STATES_PASS_SCAN_INIT_MASK 0x40
+#define HCI_SUPP_LE_STATES_PASS_SCAN_INIT_OFF 2
+#define HCI_LE_STATES_PASS_SCAN_INIT_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_PASS_SCAN_INIT_OFF] & HCI_SUPP_LE_STATES_PASS_SCAN_INIT_MASK)
+
+/*Active Scan and Initiating State combination is supported. 0x000000000800000 */
+#define HCI_SUPP_LE_STATES_ACTIVE_SCAN_INIT_MASK 0x80
+#define HCI_SUPP_LE_STATES_ACTIVE_SCAN_INIT_OFF 2
+#define HCI_LE_STATES_ACTIVE_SCAN_INIT_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_ACTIVE_SCAN_INIT_OFF] & HCI_SUPP_LE_STATES_ACTIVE_SCAN_INIT_MASK)
+
+/*Passive Scan and Master Role combination is supported. 0x000000001000000 */
+#define HCI_SUPP_LE_STATES_PASS_SCAN_MASTER_MASK 0x01
+#define HCI_SUPP_LE_STATES_PASS_SCAN_MASTER_OFF 3
+#define HCI_LE_STATES_PASS_SCAN_MASTER_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_PASS_SCAN_MASTER_OFF] & HCI_SUPP_LE_STATES_PASS_SCAN_MASTER_MASK)
+
+/*Active Scan and Master Role combination is supported. 0x000000002000000 */
+#define HCI_SUPP_LE_STATES_ACTIVE_SCAN_MASTER_MASK 0x02
+#define HCI_SUPP_LE_STATES_ACTIVE_SCAN_MASTER_OFF 3
+#define HCI_LE_STATES_ACTIVE_SCAN_MASTER_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_ACTIVE_SCAN_MASTER_OFF] & HCI_SUPP_LE_STATES_ACTIVE_SCAN_MASTER_MASK)
+
+/*Passive Scan and Slave Role combination is supported. 0x000000004000000 */
+#define HCI_SUPP_LE_STATES_PASS_SCAN_SLAVE_MASK 0x04
+#define HCI_SUPP_LE_STATES_PASS_SCAN_SLAVE_OFF 3
+#define HCI_LE_STATES_PASS_SCAN_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_PASS_SCAN_SLAVE_OFF] & HCI_SUPP_LE_STATES_PASS_SCAN_SLAVE_MASK)
+
+/*Active Scan and Slave Role combination is supported. 0x000000008000000 */
+#define HCI_SUPP_LE_STATES_ACTIVE_SCAN_SLAVE_MASK 0x08
+#define HCI_SUPP_LE_STATES_ACTIVE_SCAN_SLAVE_OFF 3
+#define HCI_LE_STATES_ACTIVE_SCAN_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_ACTIVE_SCAN_SLAVE_OFF] & HCI_SUPP_LE_STATES_ACTIVE_SCAN_SLAVE_MASK)
+
+/*Link Layer Topology Added States Combo */
+/*Initiating State and Master Role combination supported.
+ Master Role and Master Role combination is also supported. 0x0000000010000000 */
+#define HCI_SUPP_LE_STATES_INIT_MASTER_MASK 0x10
+#define HCI_SUPP_LE_STATES_INIT_MASTER_OFF 3
+#define HCI_LE_STATES_INIT_MASTER_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_INIT_MASTER_OFF] & HCI_SUPP_LE_STATES_INIT_MASTER_MASK)
+
+/*Low Duty Cycle Directed Advertising State . 0x0000000020000000 */
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_MASK 0x20
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_OFF 3
+#define HCI_LE_STATES_LOW_DUTY_DIR_ADV_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_LOW_DUTY_DIR_ADV_OFF] & HCI_SUPP_LE_STATES_LOW_DUTY_DIR_ADV_MASK)
+
+/*Low Duty Cycle Directed Advertising State and Passive scan combination. 0x0000000040000000 */
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_PASS_SCAN_MASK 0x40
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_PASS_SCAN_OFF 3
+#define HCI_LE_STATES_LO_DUTY_DIR_ADV_PASS_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_PASS_SCAN_OFF] & HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_PASS_SCAN_MASK)
+
+/*Low Duty Cycle Directed Advertising State and Active scan combination . 0x0000000080000000 */
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_ACTIVE_SCAN_MASK 0x80
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_ACTIVE_SCAN_OFF 3
+#define HCI_LE_STATES_LO_DUTY_DIR_ADV_ACTIVE_SCAN_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_ACTIVE_SCAN_OFF] & HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_ACTIVE_SCAN_MASK)
+
+/* Connectable Advertising State and Initiating State combination supported. 0x0000000100000000 */
+#define HCI_SUPP_LE_STATES_CONN_ADV_INIT_MASK 0x01
+#define HCI_SUPP_LE_STATES_CONN_ADV_INIT_OFF 4
+#define HCI_LE_STATES_CONN_ADV_INIT_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_CONN_ADV_INIT_OFF] & HCI_SUPP_LE_STATES_CONN_ADV_INIT_MASK)
+
+/* High Duty Cycle Directed Advertising State and Initiating State combination supported. */
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_INIT_MASK 0x02
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_INIT_OFF 4
+#define HCI_LE_STATES_HI_DUTY_DIR_ADV_INIT_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_INIT_OFF] & HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_INIT_MASK)
+
+/* Low Duty Cycle Directed Advertising State and Initiating State combination supported.*/
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_INIT_MASK 0x04
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_INIT_OFF 4
+#define HCI_LE_STATES_LO_DUTY_DIR_ADV_INIT_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_INIT_OFF] & HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_INIT_MASK)
+
+/* Connectable Advertising State and Master Role combination supported.*/
+#define HCI_SUPP_LE_STATES_CONN_ADV_MASTER_MASK 0x08
+#define HCI_SUPP_LE_STATES_CONN_ADV_MASTER_OFF 4
+#define HCI_LE_STATES_CONN_ADV_MASTER_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_CONN_ADV_MASTER_OFF] & HCI_SUPP_LE_STATES_CONN_ADV_MASTER_MASK)
+
+/* High Duty Cycle Directed Advertising State and Master Role combination supported.*/
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_MASTER_MASK 0x10
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_MASTER_OFF 4
+#define HCI_LE_STATES_HI_DUTY_DIR_ADV_MASTER_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_MASTER_OFF] & HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_MASTER_MASK)
+
+/* Low Duty Cycle Directed Advertising State and Master Role combination supported.*/
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_MASTER_MASK 0x20
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_MASTER_OFF 4
+#define HCI_LE_STATES_LO_DUTY_DIR_ADV_MASTER_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_MASTER_OFF] & HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_MASTER_MASK)
+
+/* Connectable Advertising State and Slave Role combination supported. */
+#define HCI_SUPP_LE_STATES_CONN_ADV_SLAVE_MASK 0x40
+#define HCI_SUPP_LE_STATES_CONN_ADV_SLAVE_OFF 4
+#define HCI_LE_STATES_CONN_ADV_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_CONN_ADV_SLAVE_OFF] & HCI_SUPP_LE_STATES_CONN_ADV_SLAVE_MASK)
+
+/* High Duty Cycle Directed Advertising State and slave Role combination supported.*/
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_SLAVE_MASK 0x80
+#define HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_SLAVE_OFF 4
+#define HCI_LE_STATES_HI_DUTY_DIR_ADV_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_SLAVE_OFF] & HCI_SUPP_LE_STATES_HI_DUTY_DIR_ADV_SLAVE_MASK)
+
+/* Low Duty Cycle Directed Advertising State and slave Role combination supported.*/
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_SLAVE_MASK 0x01
+#define HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_SLAVE_OFF 5
+#define HCI_LE_STATES_LO_DUTY_DIR_ADV_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_SLAVE_OFF] & HCI_SUPP_LE_STATES_LO_DUTY_DIR_ADV_SLAVE_MASK)
+
+/* Initiating State and Slave Role combination supported.
+ Master Role and Slave Role combination also supported.
+ */
+#define HCI_SUPP_LE_STATES_INIT_MASTER_SLAVE_MASK 0x02
+#define HCI_SUPP_LE_STATES_INIT_MASTER_SLAVE_OFF 5
+#define HCI_LE_STATES_INIT_MASTER_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_INIT_MASTER_SLAVE_OFF] & HCI_SUPP_LE_STATES_INIT_MASTER_SLAVE_MASK)
+
+/*
+** Definitions for HCI Events
+*/
+#define HCI_INQUIRY_COMP_EVT 0x01
+#define HCI_INQUIRY_RESULT_EVT 0x02
+#define HCI_CONNECTION_COMP_EVT 0x03
+#define HCI_CONNECTION_REQUEST_EVT 0x04
+#define HCI_DISCONNECTION_COMP_EVT 0x05
+#define HCI_AUTHENTICATION_COMP_EVT 0x06
+#define HCI_RMT_NAME_REQUEST_COMP_EVT 0x07
+#define HCI_ENCRYPTION_CHANGE_EVT 0x08
+#define HCI_CHANGE_CONN_LINK_KEY_EVT 0x09
+#define HCI_MASTER_LINK_KEY_COMP_EVT 0x0A
+#define HCI_READ_RMT_FEATURES_COMP_EVT 0x0B
+#define HCI_READ_RMT_VERSION_COMP_EVT 0x0C
+#define HCI_QOS_SETUP_COMP_EVT 0x0D
+#define HCI_COMMAND_COMPLETE_EVT 0x0E
+#define HCI_COMMAND_STATUS_EVT 0x0F
+#define HCI_HARDWARE_ERROR_EVT 0x10
+#define HCI_FLUSH_OCCURED_EVT 0x11
+#define HCI_ROLE_CHANGE_EVT 0x12
+#define HCI_NUM_COMPL_DATA_PKTS_EVT 0x13
+#define HCI_MODE_CHANGE_EVT 0x14
+#define HCI_RETURN_LINK_KEYS_EVT 0x15
+#define HCI_PIN_CODE_REQUEST_EVT 0x16
+#define HCI_LINK_KEY_REQUEST_EVT 0x17
+#define HCI_LINK_KEY_NOTIFICATION_EVT 0x18
+#define HCI_LOOPBACK_COMMAND_EVT 0x19
+#define HCI_DATA_BUF_OVERFLOW_EVT 0x1A
+#define HCI_MAX_SLOTS_CHANGED_EVT 0x1B
+#define HCI_READ_CLOCK_OFF_COMP_EVT 0x1C
+#define HCI_CONN_PKT_TYPE_CHANGE_EVT 0x1D
+#define HCI_QOS_VIOLATION_EVT 0x1E
+#define HCI_PAGE_SCAN_MODE_CHANGE_EVT 0x1F
+#define HCI_PAGE_SCAN_REP_MODE_CHNG_EVT 0x20
+#define HCI_FLOW_SPECIFICATION_COMP_EVT 0x21
+#define HCI_INQUIRY_RSSI_RESULT_EVT 0x22
+#define HCI_READ_RMT_EXT_FEATURES_COMP_EVT 0x23
+#define HCI_ESCO_CONNECTION_COMP_EVT 0x2C
+#define HCI_ESCO_CONNECTION_CHANGED_EVT 0x2D
+#define HCI_SNIFF_SUB_RATE_EVT 0x2E
+#define HCI_EXTENDED_INQUIRY_RESULT_EVT 0x2F
+#define HCI_ENCRYPTION_KEY_REFRESH_COMP_EVT 0x30
+#define HCI_IO_CAPABILITY_REQUEST_EVT 0x31
+#define HCI_IO_CAPABILITY_RESPONSE_EVT 0x32
+#define HCI_USER_CONFIRMATION_REQUEST_EVT 0x33
+#define HCI_USER_PASSKEY_REQUEST_EVT 0x34
+#define HCI_REMOTE_OOB_DATA_REQUEST_EVT 0x35
+#define HCI_SIMPLE_PAIRING_COMPLETE_EVT 0x36
+#define HCI_LINK_SUPER_TOUT_CHANGED_EVT 0x38
+#define HCI_ENHANCED_FLUSH_COMPLETE_EVT 0x39
+#define HCI_USER_PASSKEY_NOTIFY_EVT 0x3B
+#define HCI_KEYPRESS_NOTIFY_EVT 0x3C
+#define HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT 0x3D
+
+/*#define HCI_GENERIC_AMP_LINK_KEY_NOTIF_EVT 0x3E Removed from spec */
+#define HCI_PHYSICAL_LINK_COMP_EVT 0x40
+#define HCI_CHANNEL_SELECTED_EVT 0x41
+#define HCI_DISC_PHYSICAL_LINK_COMP_EVT 0x42
+#define HCI_PHY_LINK_LOSS_EARLY_WARNING_EVT 0x43
+#define HCI_PHY_LINK_RECOVERY_EVT 0x44
+#define HCI_LOGICAL_LINK_COMP_EVT 0x45
+#define HCI_DISC_LOGICAL_LINK_COMP_EVT 0x46
+#define HCI_FLOW_SPEC_MODIFY_COMP_EVT 0x47
+#define HCI_NUM_COMPL_DATA_BLOCKS_EVT 0x48
+#define HCI_SHORT_RANGE_MODE_COMPLETE_EVT 0x4C
+#define HCI_AMP_STATUS_CHANGE_EVT 0x4D
+#define HCI_SET_TRIGGERED_CLOCK_CAPTURE_EVT 0x4E
+
+/* ULP HCI Event */
+#define HCI_BLE_EVENT 0x3e
+/* ULP Event sub code */
+#define HCI_BLE_CONN_COMPLETE_EVT 0x01
+#define HCI_BLE_ADV_PKT_RPT_EVT 0x02
+#define HCI_BLE_LL_CONN_PARAM_UPD_EVT 0x03
+#define HCI_BLE_READ_REMOTE_FEAT_CMPL_EVT 0x04
+#define HCI_BLE_LTK_REQ_EVT 0x05
+#define HCI_BLE_RC_PARAM_REQ_EVT 0x06
+#define HCI_BLE_DATA_LENGTH_CHANGE_EVT 0x07
+#define HCI_BLE_ENHANCED_CONN_COMPLETE_EVT 0x0a
+#define HCI_BLE_DIRECT_ADV_EVT 0x0b
+/* ESP vendor BLE Event sub code */
+#define HCI_BLE_ADV_DISCARD_REPORT_EVT 0XF0
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#define HCI_BLE_PHY_UPDATE_COMPLETE_EVT 0x0c
+#define HCI_BLE_EXT_ADV_REPORT_EVT 0x0d
+#define HCI_BLE_PERIOD_ADV_SYNC_ESTAB_EVT 0x0e
+#define HCI_BLE_PERIOD_ADV_REPORT_EVT 0x0f
+#define HCI_BLE_PERIOD_ADV_SYNC_LOST_EVT 0x10
+#define HCI_BLE_SCAN_TIMEOUT_EVT 0x11
+#define HCI_BLE_ADV_SET_TERMINATED_EVT 0x12
+#define HCI_BLE_SCAN_REQ_RECEIVED_EVT 0x13
+#define HCI_BLE_CHANNEL_SELECT_ALG 0x14
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+#define HCI_BLE_PERIOD_ADV_SYNC_TRANS_RECV_EVT 0x18
+#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+
+/* Definitions for LE Channel Map */
+#define HCI_BLE_CHNL_MAP_SIZE 5
+
+#define HCI_VENDOR_SPECIFIC_EVT 0xFF /* Vendor specific events */
+#define HCI_NAP_TRACE_EVT 0xFF /* was define 0xFE, 0xFD, change to 0xFF
+ because conflict w/ TCI_EVT and per
+ specification compliant */
+
+/*
+** Defentions for HCI Error Codes that are past in the events
+*/
+#define HCI_SUCCESS 0x00
+#define HCI_ERR_ILLEGAL_COMMAND 0x01
+#define HCI_ERR_NO_CONNECTION 0x02
+#define HCI_ERR_HW_FAILURE 0x03
+#define HCI_ERR_PAGE_TIMEOUT 0x04
+#define HCI_ERR_AUTH_FAILURE 0x05
+#define HCI_ERR_KEY_MISSING 0x06
+#define HCI_ERR_MEMORY_FULL 0x07
+#define HCI_ERR_CONNECTION_TOUT 0x08
+#define HCI_ERR_MAX_NUM_OF_CONNECTIONS 0x09
+#define HCI_ERR_MAX_NUM_OF_SCOS 0x0A
+#define HCI_ERR_CONNECTION_EXISTS 0x0B
+#define HCI_ERR_COMMAND_DISALLOWED 0x0C
+#define HCI_ERR_HOST_REJECT_RESOURCES 0x0D
+#define HCI_ERR_HOST_REJECT_SECURITY 0x0E
+#define HCI_ERR_HOST_REJECT_DEVICE 0x0F
+#define HCI_ERR_HOST_TIMEOUT 0x10
+#define HCI_ERR_UNSUPPORTED_VALUE 0x11
+#define HCI_ERR_ILLEGAL_PARAMETER_FMT 0x12
+#define HCI_ERR_PEER_USER 0x13
+#define HCI_ERR_PEER_LOW_RESOURCES 0x14
+#define HCI_ERR_PEER_POWER_OFF 0x15
+#define HCI_ERR_CONN_CAUSE_LOCAL_HOST 0x16
+#define HCI_ERR_REPEATED_ATTEMPTS 0x17
+#define HCI_ERR_PAIRING_NOT_ALLOWED 0x18
+#define HCI_ERR_UNKNOWN_LMP_PDU 0x19
+#define HCI_ERR_UNSUPPORTED_REM_FEATURE 0x1A
+#define HCI_ERR_SCO_OFFSET_REJECTED 0x1B
+#define HCI_ERR_SCO_INTERVAL_REJECTED 0x1C
+#define HCI_ERR_SCO_AIR_MODE 0x1D
+#define HCI_ERR_INVALID_LMP_PARAM 0x1E
+#define HCI_ERR_UNSPECIFIED 0x1F
+#define HCI_ERR_UNSUPPORTED_LMP_PARAMETERS 0x20
+#define HCI_ERR_ROLE_CHANGE_NOT_ALLOWED 0x21
+#define HCI_ERR_LMP_RESPONSE_TIMEOUT 0x22
+#define HCI_ERR_LMP_ERR_TRANS_COLLISION 0x23
+#define HCI_ERR_LMP_PDU_NOT_ALLOWED 0x24
+#define HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE 0x25
+#define HCI_ERR_UNIT_KEY_USED 0x26
+#define HCI_ERR_QOS_NOT_SUPPORTED 0x27
+#define HCI_ERR_INSTANT_PASSED 0x28
+#define HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED 0x29
+#define HCI_ERR_DIFF_TRANSACTION_COLLISION 0x2A
+#define HCI_ERR_UNDEFINED_0x2B 0x2B
+#define HCI_ERR_QOS_UNACCEPTABLE_PARAM 0x2C
+#define HCI_ERR_QOS_REJECTED 0x2D
+#define HCI_ERR_CHAN_CLASSIF_NOT_SUPPORTED 0x2E
+#define HCI_ERR_INSUFFCIENT_SECURITY 0x2F
+#define HCI_ERR_PARAM_OUT_OF_RANGE 0x30
+#define HCI_ERR_UNDEFINED_0x31 0x31
+#define HCI_ERR_ROLE_SWITCH_PENDING 0x32
+#define HCI_ERR_UNDEFINED_0x33 0x33
+#define HCI_ERR_RESERVED_SLOT_VIOLATION 0x34
+#define HCI_ERR_ROLE_SWITCH_FAILED 0x35
+#define HCI_ERR_INQ_RSP_DATA_TOO_LARGE 0x36
+#define HCI_ERR_SIMPLE_PAIRING_NOT_SUPPORTED 0x37
+#define HCI_ERR_HOST_BUSY_PAIRING 0x38
+#define HCI_ERR_REJ_NO_SUITABLE_CHANNEL 0x39
+#define HCI_ERR_CONTROLLER_BUSY 0x3A
+#define HCI_ERR_UNACCEPT_CONN_INTERVAL 0x3B
+#define HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT 0x3C
+#define HCI_ERR_CONN_TOUT_DUE_TO_MIC_FAILURE 0x3D
+#define HCI_ERR_CONN_FAILED_ESTABLISHMENT 0x3E
+#define HCI_ERR_MAC_CONNECTION_FAILED 0x3F
+
+/* ConnectionLess Broadcast errors */
+#define HCI_ERR_LT_ADDR_ALREADY_IN_USE 0x40
+#define HCI_ERR_LT_ADDR_NOT_ALLOCATED 0x41
+#define HCI_ERR_CLB_NOT_ENABLED 0x42
+#define HCI_ERR_CLB_DATA_TOO_BIG 0x43
+
+#define HCI_ERR_MAX_ERR 0x43
+
+//ESP vendor error code
+#define HCI_ERR_ESP_VENDOR_FAIL 0xE0
+
+#define HCI_HINT_TO_RECREATE_AMP_PHYS_LINK 0xFF
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+typedef UINT8 tHCI_STATUS;
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+
+/*
+** Definitions for HCI enable event
+*/
+#define HCI_INQUIRY_COMPLETE_EV(p) (*((UINT32 *)(p)) & 0x00000001)
+#define HCI_INQUIRY_RESULT_EV(p) (*((UINT32 *)(p)) & 0x00000002)
+#define HCI_CONNECTION_COMPLETE_EV(p) (*((UINT32 *)(p)) & 0x00000004)
+#define HCI_CONNECTION_REQUEST_EV(p) (*((UINT32 *)(p)) & 0x00000008)
+#define HCI_DISCONNECTION_COMPLETE_EV(p) (*((UINT32 *)(p)) & 0x00000010)
+#define HCI_AUTHENTICATION_COMPLETE_EV(p) (*((UINT32 *)(p)) & 0x00000020)
+#define HCI_RMT_NAME_REQUEST_COMPL_EV(p) (*((UINT32 *)(p)) & 0x00000040)
+#define HCI_CHANGE_CONN_ENCRPT_ENABLE_EV(p) (*((UINT32 *)(p)) & 0x00000080)
+#define HCI_CHANGE_CONN_LINK_KEY_EV(p) (*((UINT32 *)(p)) & 0x00000100)
+#define HCI_MASTER_LINK_KEY_COMPLETE_EV(p) (*((UINT32 *)(p)) & 0x00000200)
+#define HCI_READ_RMT_FEATURES_COMPL_EV(p) (*((UINT32 *)(p)) & 0x00000400)
+#define HCI_READ_RMT_VERSION_COMPL_EV(p) (*((UINT32 *)(p)) & 0x00000800)
+#define HCI_QOS_SETUP_COMPLETE_EV(p) (*((UINT32 *)(p)) & 0x00001000)
+#define HCI_COMMAND_COMPLETE_EV(p) (*((UINT32 *)(p)) & 0x00002000)
+#define HCI_COMMAND_STATUS_EV(p) (*((UINT32 *)(p)) & 0x00004000)
+#define HCI_HARDWARE_ERROR_EV(p) (*((UINT32 *)(p)) & 0x00008000)
+#define HCI_FLASH_OCCURED_EV(p) (*((UINT32 *)(p)) & 0x00010000)
+#define HCI_ROLE_CHANGE_EV(p) (*((UINT32 *)(p)) & 0x00020000)
+#define HCI_NUM_COMPLETED_PKTS_EV(p) (*((UINT32 *)(p)) & 0x00040000)
+#define HCI_MODE_CHANGE_EV(p) (*((UINT32 *)(p)) & 0x00080000)
+#define HCI_RETURN_LINK_KEYS_EV(p) (*((UINT32 *)(p)) & 0x00100000)
+#define HCI_PIN_CODE_REQUEST_EV(p) (*((UINT32 *)(p)) & 0x00200000)
+#define HCI_LINK_KEY_REQUEST_EV(p) (*((UINT32 *)(p)) & 0x00400000)
+#define HCI_LINK_KEY_NOTIFICATION_EV(p) (*((UINT32 *)(p)) & 0x00800000)
+#define HCI_LOOPBACK_COMMAND_EV(p) (*((UINT32 *)(p)) & 0x01000000)
+#define HCI_DATA_BUF_OVERFLOW_EV(p) (*((UINT32 *)(p)) & 0x02000000)
+#define HCI_MAX_SLOTS_CHANGE_EV(p) (*((UINT32 *)(p)) & 0x04000000)
+#define HCI_READ_CLOCK_OFFSET_COMP_EV(p) (*((UINT32 *)(p)) & 0x08000000)
+#define HCI_CONN_PKT_TYPE_CHANGED_EV(p) (*((UINT32 *)(p)) & 0x10000000)
+#define HCI_QOS_VIOLATION_EV(p) (*((UINT32 *)(p)) & 0x20000000)
+#define HCI_PAGE_SCAN_MODE_CHANGED_EV(p) (*((UINT32 *)(p)) & 0x40000000)
+#define HCI_PAGE_SCAN_REP_MODE_CHNG_EV(p) (*((UINT32 *)(p)) & 0x80000000)
+
+/* the default event mask for 2.1+EDR (Lisbon) does not include Lisbon events */
+#define HCI_DEFAULT_EVENT_MASK_0 0xFFFFFFFF
+#define HCI_DEFAULT_EVENT_MASK_1 0x00001FFF
+
+/* the event mask for 2.0 + EDR and later (includes Lisbon events) */
+#define HCI_LISBON_EVENT_MASK_0 0xFFFFFFFF
+#define HCI_LISBON_EVENT_MASK_1 0x1DBFFFFF
+#define HCI_LISBON_EVENT_MASK "\x0D\xBF\xFF\xFF\xFF\xFF\xFF\xFF"
+#define HCI_LISBON_EVENT_MASK_EXT "\x1D\xBF\xFF\xFF\xFF\xFF\xFF\xFF"
+#define HCI_DUMO_EVENT_MASK_EXT "\x3D\xBF\xFF\xFF\xFF\xFF\xFF\xFF"
+/* 0x00001FFF FFFFFFFF Default - no Lisbon events
+ 0x00000800 00000000 Synchronous Connection Complete Event
+ 0x00001000 00000000 Synchronous Connection Changed Event
+ 0x00002000 00000000 Sniff Subrate Event
+ 0x00004000 00000000 Extended Inquiry Result Event
+ 0x00008000 00000000 Encryption Key Refresh Complete Event
+ 0x00010000 00000000 IO Capability Request Event
+ 0x00020000 00000000 IO Capability Response Event
+ 0x00040000 00000000 User Confirmation Request Event
+ 0x00080000 00000000 User Passkey Request Event
+ 0x00100000 00000000 Remote OOB Data Request Event
+ 0x00200000 00000000 Simple Pairing Complete Event
+ 0x00400000 00000000 Generic AMP Link Key Notification Event
+ 0x00800000 00000000 Link Supervision Timeout Changed Event
+ 0x01000000 00000000 Enhanced Flush Complete Event
+ 0x04000000 00000000 User Passkey Notification Event
+ 0x08000000 00000000 Keypress Notification Event
+ 0x10000000 00000000 Remote Host Supported Features Notification Event
+ 0x20000000 00000000 LE Meta Event
+ */
+
+#define HCI_LE_ONLY_EVENT_MASK "\x20\x00\x80\x00\x02\x00\x88\x90"
+/* 0x00000000 00000010 Disconnection complete event
+ 0x00000000 00000080 Encryption change event
+ 0x00000000 00000800 Read remote version information complete event
+ 0x00000000 00008000 Hardware error event
+ 0x00000000 02000000 Data buffer overflow event
+ 0x00008000 00000000 Encryption key refresh complete event
+ 0x20000000 00000000 LE Meta Event
+*/
+
+/* the event mask for AMP controllers */
+#define HCI_AMP_EVENT_MASK_3_0 "\x00\x00\x00\x00\x00\x00\x3F\xFF"
+
+/* 0x0000000000000000 No events specified (default)
+ 0x0000000000000001 Physical Link Complete Event
+ 0x0000000000000002 Channel Selected Event
+ 0x0000000000000004 Disconnection Physical Link Event
+ 0x0000000000000008 Physical Link Loss Early Warning Event
+ 0x0000000000000010 Physical Link Recovery Event
+ 0x0000000000000020 Logical Link Complete Event
+ 0x0000000000000040 Disconnection Logical Link Complete Event
+ 0x0000000000000080 Flow Spec Modify Complete Event
+ 0x0000000000000100 Number of Completed Data Blocks Event
+ 0x0000000000000200 AMP Start Test Event
+ 0x0000000000000400 AMP Test End Event
+ 0x0000000000000800 AMP Receiver Report Event
+ 0x0000000000001000 Short Range Mode Change Complete Event
+ 0x0000000000002000 AMP Status Change Event
+*/
+
+/* the event mask page 2 (CLB + CSA4) for BR/EDR controller */
+#define HCI_PAGE_2_EVENT_MASK "\x00\x00\x00\x00\x00\x7F\xC0\x00"
+/* 0x0000000000004000 Triggered Clock Capture Event
+ 0x0000000000008000 Sync Train Complete Event
+ 0x0000000000010000 Sync Train Received Event
+ 0x0000000000020000 Connectionless Broadcast Receive Event
+ 0x0000000000040000 Connectionless Broadcast Timeout Event
+ 0x0000000000080000 Truncated Page Complete Event
+ 0x0000000000100000 Salve Page Response Timeout Event
+ 0x0000000000200000 Connectionless Broadcast Channel Map Change Event
+ 0x0000000000400000 Inquiry Response Notification Event
+*/
+#if BLE_PRIVACY_SPT == TRUE
+/* BLE event mask */
+#define HCI_BLE_EVENT_MASK_DEF "\x00\x00\x00\x00\x00\x00\x07\xff"
+#else
+#define HCI_BLE_EVENT_MASK_DEF "\x00\x00\x00\x00\x00\x00\x00\x7f"
+#endif
+/*
+** Definitions for packet type masks (BT1.2 and BT2.0 definitions)
+*/
+#define HCI_PKT_TYPES_MASK_NO_2_DH1 0x0002
+#define HCI_PKT_TYPES_MASK_NO_3_DH1 0x0004
+#define HCI_PKT_TYPES_MASK_DM1 0x0008
+#define HCI_PKT_TYPES_MASK_DH1 0x0010
+#define HCI_PKT_TYPES_MASK_HV1 0x0020
+#define HCI_PKT_TYPES_MASK_HV2 0x0040
+#define HCI_PKT_TYPES_MASK_HV3 0x0080
+#define HCI_PKT_TYPES_MASK_NO_2_DH3 0x0100
+#define HCI_PKT_TYPES_MASK_NO_3_DH3 0x0200
+#define HCI_PKT_TYPES_MASK_DM3 0x0400
+#define HCI_PKT_TYPES_MASK_DH3 0x0800
+#define HCI_PKT_TYPES_MASK_NO_2_DH5 0x1000
+#define HCI_PKT_TYPES_MASK_NO_3_DH5 0x2000
+#define HCI_PKT_TYPES_MASK_DM5 0x4000
+#define HCI_PKT_TYPES_MASK_DH5 0x8000
+
+/* Packet type should be one of valid but at least one should be specified */
+#define HCI_VALID_SCO_PKT_TYPE(t) (((((t) & ~(HCI_PKT_TYPES_MASK_HV1 \
+ | HCI_PKT_TYPES_MASK_HV2 \
+ | HCI_PKT_TYPES_MASK_HV3)) == 0)) \
+ && ((t) != 0))
+
+
+
+
+
+/* Packet type should not be invalid and at least one should be specified */
+#define HCI_VALID_ACL_PKT_TYPE(t) (((((t) & ~(HCI_PKT_TYPES_MASK_DM1 \
+ | HCI_PKT_TYPES_MASK_DH1 \
+ | HCI_PKT_TYPES_MASK_DM3 \
+ | HCI_PKT_TYPES_MASK_DH3 \
+ | HCI_PKT_TYPES_MASK_DM5 \
+ | HCI_PKT_TYPES_MASK_DH5 \
+ | HCI_PKT_TYPES_MASK_NO_2_DH1 \
+ | HCI_PKT_TYPES_MASK_NO_3_DH1 \
+ | HCI_PKT_TYPES_MASK_NO_2_DH3 \
+ | HCI_PKT_TYPES_MASK_NO_3_DH3 \
+ | HCI_PKT_TYPES_MASK_NO_2_DH5 \
+ | HCI_PKT_TYPES_MASK_NO_3_DH5 )) == 0)) \
+ && (((t) & (HCI_PKT_TYPES_MASK_DM1 \
+ | HCI_PKT_TYPES_MASK_DH1 \
+ | HCI_PKT_TYPES_MASK_DM3 \
+ | HCI_PKT_TYPES_MASK_DH3 \
+ | HCI_PKT_TYPES_MASK_DM5 \
+ | HCI_PKT_TYPES_MASK_DH5)) != 0))
+
+/*
+** Definitions for eSCO packet type masks (BT1.2 and BT2.0 definitions)
+*/
+#define HCI_ESCO_PKT_TYPES_MASK_HV1 0x0001
+#define HCI_ESCO_PKT_TYPES_MASK_HV2 0x0002
+#define HCI_ESCO_PKT_TYPES_MASK_HV3 0x0004
+#define HCI_ESCO_PKT_TYPES_MASK_EV3 0x0008
+#define HCI_ESCO_PKT_TYPES_MASK_EV4 0x0010
+#define HCI_ESCO_PKT_TYPES_MASK_EV5 0x0020
+#define HCI_ESCO_PKT_TYPES_MASK_NO_2_EV3 0x0040
+#define HCI_ESCO_PKT_TYPES_MASK_NO_3_EV3 0x0080
+#define HCI_ESCO_PKT_TYPES_MASK_NO_2_EV5 0x0100
+#define HCI_ESCO_PKT_TYPES_MASK_NO_3_EV5 0x0200
+
+/* Packet type should be one of valid but at least one should be specified for 1.2 */
+#define HCI_VALID_ESCO_PKT_TYPE(t) (((((t) & ~(HCI_ESCO_PKT_TYPES_MASK_EV3 \
+ | HCI_ESCO_PKT_TYPES_MASK_EV4 \
+ | HCI_ESCO_PKT_TYPES_MASK_EV5)) == 0)) \
+ && ((t) != 0))/* Packet type should be one of valid but at least one should be specified */
+
+#define HCI_VALID_ESCO_SCOPKT_TYPE(t) (((((t) & ~(HCI_ESCO_PKT_TYPES_MASK_HV1 \
+ | HCI_ESCO_PKT_TYPES_MASK_HV2 \
+ | HCI_ESCO_PKT_TYPES_MASK_HV3)) == 0)) \
+ && ((t) != 0))
+
+#define HCI_VALID_SCO_ALL_PKT_TYPE(t) (((((t) & ~(HCI_ESCO_PKT_TYPES_MASK_HV1 \
+ | HCI_ESCO_PKT_TYPES_MASK_HV2 \
+ | HCI_ESCO_PKT_TYPES_MASK_HV3 \
+ | HCI_ESCO_PKT_TYPES_MASK_EV3 \
+ | HCI_ESCO_PKT_TYPES_MASK_EV4 \
+ | HCI_ESCO_PKT_TYPES_MASK_EV5)) == 0)) \
+ && ((t) != 0))
+
+/*
+** Define parameters to allow role switch during create connection
+*/
+#define HCI_CR_CONN_NOT_ALLOW_SWITCH 0x00
+#define HCI_CR_CONN_ALLOW_SWITCH 0x01
+
+/*
+** Hold Mode command destination
+*/
+#define HOLD_MODE_DEST_LOCAL_DEVICE 0x00
+#define HOLD_MODE_DEST_RMT_DEVICE 0x01
+
+/*
+** Definitions for different HCI parameters
+*/
+#define HCI_PER_INQ_MIN_MAX_PERIOD 0x0003
+#define HCI_PER_INQ_MAX_MAX_PERIOD 0xFFFF
+#define HCI_PER_INQ_MIN_MIN_PERIOD 0x0002
+#define HCI_PER_INQ_MAX_MIN_PERIOD 0xFFFE
+
+#define HCI_MAX_INQUIRY_LENGTH 0x30
+
+#define HCI_MIN_INQ_LAP 0x9E8B00
+#define HCI_MAX_INQ_LAP 0x9E8B3F
+
+/* HCI role defenitions */
+#define HCI_ROLE_MASTER 0x00
+#define HCI_ROLE_SLAVE 0x01
+#define HCI_ROLE_UNKNOWN 0xff
+
+/* HCI mode defenitions */
+#define HCI_MODE_ACTIVE 0x00
+#define HCI_MODE_HOLD 0x01
+#define HCI_MODE_SNIFF 0x02
+#define HCI_MODE_PARK 0x03
+
+/* HCI Flow Control Mode defenitions */
+#define HCI_PACKET_BASED_FC_MODE 0x00
+#define HCI_BLOCK_BASED_FC_MODE 0x01
+
+/* Define Packet types as requested by the Host */
+#define HCI_ACL_PKT_TYPE_NONE 0x0000
+#define HCI_ACL_PKT_TYPE_DM1 0x0008
+#define HCI_ACL_PKT_TYPE_DH1 0x0010
+#define HCI_ACL_PKT_TYPE_AUX1 0x0200
+#define HCI_ACL_PKT_TYPE_DM3 0x0400
+#define HCI_ACL_PKT_TYPE_DH3 0x0800
+#define HCI_ACL_PKT_TYPE_DM5 0x4000
+#define HCI_ACL_PKT_TYPE_DH5 0x8000
+
+/* Define key type in the Master Link Key command */
+#define HCI_USE_SEMI_PERMANENT_KEY 0x00
+#define HCI_USE_TEMPORARY_KEY 0x01
+
+/* Page scan period modes */
+#define HCI_PAGE_SCAN_REP_MODE_R0 0x00
+#define HCI_PAGE_SCAN_REP_MODE_R1 0x01
+#define HCI_PAGE_SCAN_REP_MODE_R2 0x02
+
+/* Define limits for page scan repetition modes */
+#define HCI_PAGE_SCAN_R1_LIMIT 0x0800
+#define HCI_PAGE_SCAN_R2_LIMIT 0x1000
+
+/* Page scan period modes */
+#define HCI_PAGE_SCAN_PER_MODE_P0 0x00
+#define HCI_PAGE_SCAN_PER_MODE_P1 0x01
+#define HCI_PAGE_SCAN_PER_MODE_P2 0x02
+
+/* Page scan modes */
+#define HCI_MANDATARY_PAGE_SCAN_MODE 0x00
+#define HCI_OPTIONAL_PAGE_SCAN_MODE1 0x01
+#define HCI_OPTIONAL_PAGE_SCAN_MODE2 0x02
+#define HCI_OPTIONAL_PAGE_SCAN_MODE3 0x03
+
+/* Page and inquiry scan types */
+#define HCI_SCAN_TYPE_STANDARD 0x00
+#define HCI_SCAN_TYPE_INTERLACED 0x01 /* 1.2 devices or later */
+#define HCI_DEF_SCAN_TYPE HCI_SCAN_TYPE_STANDARD
+
+/* Definitions for quality of service service types */
+#define HCI_SERVICE_NO_TRAFFIC 0x00
+#define HCI_SERVICE_BEST_EFFORT 0x01
+#define HCI_SERVICE_GUARANTEED 0x02
+
+#define HCI_QOS_LATENCY_DO_NOT_CARE 0xFFFFFFFF
+#define HCI_QOS_DELAY_DO_NOT_CARE 0xFFFFFFFF
+
+/* Definitions for Flow Specification */
+#define HCI_FLOW_SPEC_LATENCY_DO_NOT_CARE 0xFFFFFFFF
+
+/* Definitions for AFH Channel Map */
+#define HCI_AFH_CHANNEL_MAP_LEN 10
+
+/* Definitions for Extended Inquiry Response */
+#define HCI_EXT_INQ_RESPONSE_LEN 240
+#define HCI_EIR_FLAGS_TYPE BT_EIR_FLAGS_TYPE
+#define HCI_EIR_MORE_16BITS_UUID_TYPE BT_EIR_MORE_16BITS_UUID_TYPE
+#define HCI_EIR_COMPLETE_16BITS_UUID_TYPE BT_EIR_COMPLETE_16BITS_UUID_TYPE
+#define HCI_EIR_MORE_32BITS_UUID_TYPE BT_EIR_MORE_32BITS_UUID_TYPE
+#define HCI_EIR_COMPLETE_32BITS_UUID_TYPE BT_EIR_COMPLETE_32BITS_UUID_TYPE
+#define HCI_EIR_MORE_128BITS_UUID_TYPE BT_EIR_MORE_128BITS_UUID_TYPE
+#define HCI_EIR_COMPLETE_128BITS_UUID_TYPE BT_EIR_COMPLETE_128BITS_UUID_TYPE
+#define HCI_EIR_SHORTENED_LOCAL_NAME_TYPE BT_EIR_SHORTENED_LOCAL_NAME_TYPE
+#define HCI_EIR_COMPLETE_LOCAL_NAME_TYPE BT_EIR_COMPLETE_LOCAL_NAME_TYPE
+#define HCI_EIR_TX_POWER_LEVEL_TYPE BT_EIR_TX_POWER_LEVEL_TYPE
+#define HCI_EIR_URL_TYPE BT_EIR_URL_TYPE
+#define HCI_EIR_MANUFACTURER_SPECIFIC_TYPE BT_EIR_MANUFACTURER_SPECIFIC_TYPE
+#define HCI_EIR_OOB_BD_ADDR_TYPE BT_EIR_OOB_BD_ADDR_TYPE
+#define HCI_EIR_OOB_COD_TYPE BT_EIR_OOB_COD_TYPE
+#define HCI_EIR_OOB_SSP_HASH_C_TYPE BT_EIR_OOB_SSP_HASH_C_TYPE
+#define HCI_EIR_OOB_SSP_RAND_R_TYPE BT_EIR_OOB_SSP_RAND_R_TYPE
+
+/* Definitions for Write Simple Pairing Mode */
+#define HCI_SP_MODE_UNDEFINED 0x00
+#define HCI_SP_MODE_ENABLED 0x01
+
+/* Definitions for Write Simple Pairing Debug Mode */
+#define HCI_SPD_MODE_DISABLED 0x00
+#define HCI_SPD_MODE_ENABLED 0x01
+
+/* Definitions for Write Secure Connections Host Support */
+#define HCI_SC_MODE_DISABLED 0x00
+#define HCI_SC_MODE_ENABLED 0x01
+
+/* Definitions for IO Capability Response/Command */
+#define HCI_IO_CAP_DISPLAY_ONLY 0x00
+#define HCI_IO_CAP_DISPLAY_YESNO 0x01
+#define HCI_IO_CAP_KEYBOARD_ONLY 0x02
+#define HCI_IO_CAP_NO_IO 0x03
+
+#define HCI_OOB_AUTH_DATA_NOT_PRESENT 0x00
+#define HCI_OOB_REM_AUTH_DATA_PRESENT 0x01
+
+#define HCI_MITM_PROTECT_NOT_REQUIRED 0x00
+#define HCI_MITM_PROTECT_REQUIRED 0x01
+
+
+/* Policy settings status */
+#define HCI_DISABLE_ALL_LM_MODES 0x0000
+#define HCI_ENABLE_MASTER_SLAVE_SWITCH 0x0001
+#define HCI_ENABLE_HOLD_MODE 0x0002
+#define HCI_ENABLE_SNIFF_MODE 0x0004
+#define HCI_ENABLE_PARK_MODE 0x0008
+
+/* By default allow switch, because host can not allow that */
+/* that until he created the connection */
+#define HCI_DEFAULT_POLICY_SETTINGS HCI_DISABLE_ALL_LM_MODES
+
+/* Filters that are sent in set filter command */
+#define HCI_FILTER_TYPE_CLEAR_ALL 0x00
+#define HCI_FILTER_INQUIRY_RESULT 0x01
+#define HCI_FILTER_CONNECTION_SETUP 0x02
+
+#define HCI_FILTER_COND_NEW_DEVICE 0x00
+#define HCI_FILTER_COND_DEVICE_CLASS 0x01
+#define HCI_FILTER_COND_BD_ADDR 0x02
+
+#define HCI_DO_NOT_AUTO_ACCEPT_CONNECT 1
+#define HCI_DO_AUTO_ACCEPT_CONNECT 2 /* role switch disabled */
+#define HCI_DO_AUTO_ACCEPT_CONNECT_RS 3 /* role switch enabled (1.1 errata 1115) */
+
+/* Auto accept flags */
+#define HCI_AUTO_ACCEPT_OFF 0x00
+#define HCI_AUTO_ACCEPT_ACL_CONNECTIONS 0x01
+#define HCI_AUTO_ACCEPT_SCO_CONNECTIONS 0x02
+
+/* PIN type */
+#define HCI_PIN_TYPE_VARIABLE 0
+#define HCI_PIN_TYPE_FIXED 1
+
+/* Loopback Modes */
+#define HCI_LOOPBACK_MODE_DISABLED 0
+#define HCI_LOOPBACK_MODE_LOCAL 1
+#define HCI_LOOPBACK_MODE_REMOTE 2
+
+#define SLOTS_PER_10MS 16 /* 0.625 ms slots in a 10 ms tick */
+
+/* Maximum connection accept timeout in 0.625msec */
+#define HCI_MAX_CONN_ACCEPT_TOUT 0xB540 /* 29 sec */
+#define HCI_DEF_CONN_ACCEPT_TOUT 0x1F40 /* 5 sec */
+
+/* Page timeout is used in LC only and LC is counting down slots not using OS */
+#define HCI_DEFAULT_PAGE_TOUT 0x2000 /* 5.12 sec (in slots) */
+#define HCI_MIN_PAGE_TOUT 0x0016 /* 13.75 ms (in slots) */
+
+/* Scan enable flags */
+#define HCI_NO_SCAN_ENABLED 0x00
+#define HCI_INQUIRY_SCAN_ENABLED 0x01
+#define HCI_PAGE_SCAN_ENABLED 0x02
+
+/* Pagescan timer definitions in 0.625 ms */
+#define HCI_MIN_PAGESCAN_INTERVAL 0x12 /* 11.25 ms */
+#define HCI_MAX_PAGESCAN_INTERVAL 0x1000 /* 2.56 sec */
+#define HCI_DEF_PAGESCAN_INTERVAL 0x0800 /* 1.28 sec */
+
+/* Parameter for pagescan window is passed to LC and is kept in slots */
+#define HCI_MIN_PAGESCAN_WINDOW 0x11 /* 10.625 ms */
+#define HCI_MAX_PAGESCAN_WINDOW 0x1000 /* 2.56 sec */
+#define HCI_DEF_PAGESCAN_WINDOW 0x12 /* 11.25 ms */
+
+/* Inquiryscan timer definitions in 0.625 ms */
+#define HCI_MIN_INQUIRYSCAN_INTERVAL 0x12 /* 11.25 ms */
+#define HCI_MAX_INQUIRYSCAN_INTERVAL 0x1000 /* 2.56 sec */
+#define HCI_DEF_INQUIRYSCAN_INTERVAL 0x1000 /* 2.56 sec */
+
+/* Parameter for inquiryscan window is passed to LC and is kept in slots */
+#define HCI_MIN_INQUIRYSCAN_WINDOW 0x11 /* 10.625 ms */
+#define HCI_MAX_INQUIRYSCAN_WINDOW 0x1000 /* 2.56 sec */
+#define HCI_DEF_INQUIRYSCAN_WINDOW 0x12 /* 11.25 ms */
+
+/* Encryption modes */
+#define HCI_ENCRYPT_MODE_DISABLED 0x00
+#define HCI_ENCRYPT_MODE_POINT_TO_POINT 0x01
+#define HCI_ENCRYPT_MODE_ALL 0x02
+
+/* Voice settings */
+#define HCI_INP_CODING_LINEAR 0x0000 /* 0000000000 */
+#define HCI_INP_CODING_U_LAW 0x0100 /* 0100000000 */
+#define HCI_INP_CODING_A_LAW 0x0200 /* 1000000000 */
+#define HCI_INP_CODING_MASK 0x0300 /* 1100000000 */
+
+#define HCI_INP_DATA_FMT_1S_COMPLEMENT 0x0000 /* 0000000000 */
+#define HCI_INP_DATA_FMT_2S_COMPLEMENT 0x0040 /* 0001000000 */
+#define HCI_INP_DATA_FMT_SIGN_MAGNITUDE 0x0080 /* 0010000000 */
+#define HCI_INP_DATA_FMT_UNSIGNED 0x00c0 /* 0011000000 */
+#define HCI_INP_DATA_FMT_MASK 0x00c0 /* 0011000000 */
+
+#define HCI_INP_SAMPLE_SIZE_8BIT 0x0000 /* 0000000000 */
+#define HCI_INP_SAMPLE_SIZE_16BIT 0x0020 /* 0000100000 */
+#define HCI_INP_SAMPLE_SIZE_MASK 0x0020 /* 0000100000 */
+
+#define HCI_INP_LINEAR_PCM_BIT_POS_MASK 0x001c /* 0000011100 */
+#define HCI_INP_LINEAR_PCM_BIT_POS_OFFS 2
+
+#define HCI_AIR_CODING_FORMAT_CVSD 0x0000 /* 0000000000 */
+#define HCI_AIR_CODING_FORMAT_U_LAW 0x0001 /* 0000000001 */
+#define HCI_AIR_CODING_FORMAT_A_LAW 0x0002 /* 0000000010 */
+#define HCI_AIR_CODING_FORMAT_TRANSPNT 0x0003 /* 0000000011 */
+#define HCI_AIR_CODING_FORMAT_MASK 0x0003 /* 0000000011 */
+
+/* default 0001100000 */
+#define HCI_DEFAULT_VOICE_SETTINGS (HCI_INP_CODING_LINEAR \
+ | HCI_INP_DATA_FMT_2S_COMPLEMENT \
+ | HCI_INP_SAMPLE_SIZE_16BIT \
+ | HCI_AIR_CODING_FORMAT_CVSD)
+
+#define HCI_CVSD_SUPPORTED(x) (((x) & HCI_AIR_CODING_FORMAT_MASK) == HCI_AIR_CODING_FORMAT_CVSD)
+#define HCI_U_LAW_SUPPORTED(x) (((x) & HCI_AIR_CODING_FORMAT_MASK) == HCI_AIR_CODING_FORMAT_U_LAW)
+#define HCI_A_LAW_SUPPORTED(x) (((x) & HCI_AIR_CODING_FORMAT_MASK) == HCI_AIR_CODING_FORMAT_A_LAW)
+#define HCI_TRANSPNT_SUPPORTED(x) (((x) & HCI_AIR_CODING_FORMAT_MASK) == HCI_AIR_CODING_FORMAT_TRANSPNT)
+
+/* Retransmit timer definitions in 0.625 */
+#define HCI_MAX_AUTO_FLUSH_TOUT 0x07FF
+#define HCI_DEFAULT_AUTO_FLUSH_TOUT 0 /* No auto flush */
+
+/* Broadcast retransmitions */
+#define HCI_DEFAULT_NUM_BCAST_RETRAN 1
+
+/* Define broadcast data types as passed in the hci data packet */
+#define HCI_DATA_POINT_TO_POINT 0x00
+#define HCI_DATA_ACTIVE_BCAST 0x01
+#define HCI_DATA_PICONET_BCAST 0x02
+
+/* Hold mode activity */
+#define HCI_MAINTAIN_CUR_POWER_STATE 0x00
+#define HCI_SUSPEND_PAGE_SCAN 0x01
+#define HCI_SUSPEND_INQUIRY_SCAN 0x02
+#define HCI_SUSPEND_PERIODIC_INQUIRIES 0x04
+
+/* Default Link Supervision timeoout */
+#define HCI_DEFAULT_INACT_TOUT 0x7D00 /* BR/EDR (20 seconds) */
+#define HCI_DEFAULT_AMP_INACT_TOUT 0x3E80 /* AMP (10 seconds) */
+
+/* Read transmit power level parameter */
+#define HCI_READ_CURRENT 0x00
+#define HCI_READ_MAXIMUM 0x01
+
+/* Link types for connection complete event */
+#define HCI_LINK_TYPE_SCO 0x00
+#define HCI_LINK_TYPE_ACL 0x01
+#define HCI_LINK_TYPE_ESCO 0x02
+
+/* Link Key Notification Event (Key Type) definitions */
+#define HCI_LKEY_TYPE_COMBINATION 0x00
+#define HCI_LKEY_TYPE_LOCAL_UNIT 0x01
+#define HCI_LKEY_TYPE_REMOTE_UNIT 0x02
+#define HCI_LKEY_TYPE_DEBUG_COMB 0x03
+#define HCI_LKEY_TYPE_UNAUTH_COMB 0x04
+#define HCI_LKEY_TYPE_AUTH_COMB 0x05
+#define HCI_LKEY_TYPE_CHANGED_COMB 0x06
+#define HCI_LKEY_TYPE_UNAUTH_COMB_P_256 0x07
+#define HCI_LKEY_TYPE_AUTH_COMB_P_256 0x08
+
+/* Internal definitions - not used over HCI */
+#define HCI_LKEY_TYPE_AMP_WIFI 0x80
+#define HCI_LKEY_TYPE_AMP_UWB 0x81
+#define HCI_LKEY_TYPE_UNKNOWN 0xff
+
+/* Read Local Version HCI Version return values (Command Complete Event) */
+#define HCI_VERSION_1_0B 0x00
+#define HCI_VERSION_1_1 0x01
+
+/* Define an invalid value for a handle */
+#define HCI_INVALID_HANDLE 0xFFFF
+
+/* Define max ammount of data in the HCI command */
+#define HCI_COMMAND_SIZE 255
+
+/* Define the preamble length for all HCI Commands.
+** This is 2-bytes for opcode and 1 byte for length
+*/
+#define HCIC_PREAMBLE_SIZE 3
+
+/* Define the preamble length for all HCI Events
+** This is 1-byte for opcode and 1 byte for length
+*/
+#define HCIE_PREAMBLE_SIZE 2
+#define HCI_SCO_PREAMBLE_SIZE 3
+#define HCI_DATA_PREAMBLE_SIZE 4
+
+/* local Bluetooth controller id for AMP HCI */
+#define LOCAL_BR_EDR_CONTROLLER_ID 0
+
+/* controller id types for AMP HCI */
+#define HCI_CONTROLLER_TYPE_BR_EDR 0
+#define HCI_CONTROLLER_TYPE_802_11 1
+#define HCI_CONTROLLER_TYPE_ECMA 2
+#define HCI_MAX_CONTROLLER_TYPES 3
+
+/* ConnectionLess Broadcast */
+#define HCI_CLB_DISABLE 0x00
+#define HCI_CLB_ENABLE 0x01
+
+/* ConnectionLess Broadcast Data fragment */
+#define HCI_CLB_FRAGMENT_CONT 0x00
+#define HCI_CLB_FRAGMENT_START 0x01
+#define HCI_CLB_FRAGMENT_END 0x02
+#define HCI_CLB_FRAGMENT_SINGLE 0x03
+
+/* AMP Controller Status codes
+*/
+#define HCI_AMP_CTRLR_PHYSICALLY_DOWN 0
+#define HCI_AMP_CTRLR_USABLE_BY_BT 1
+#define HCI_AMP_CTRLR_UNUSABLE_FOR_BT 2
+#define HCI_AMP_CTRLR_LOW_CAP_FOR_BT 3
+#define HCI_AMP_CTRLR_MED_CAP_FOR_BT 4
+#define HCI_AMP_CTRLR_HIGH_CAP_FOR_BT 5
+#define HCI_AMP_CTRLR_FULL_CAP_FOR_BT 6
+
+#define HCI_MAX_AMP_STATUS_TYPES 7
+
+
+/* Define the extended flow specification fields used by AMP */
+typedef struct {
+ UINT8 id;
+ UINT8 stype;
+ UINT16 max_sdu_size;
+ UINT32 sdu_inter_time;
+ UINT32 access_latency;
+ UINT32 flush_timeout;
+} tHCI_EXT_FLOW_SPEC;
+
+
+/* HCI message type definitions (for H4 messages) */
+#define HCIT_TYPE_COMMAND 1
+#define HCIT_TYPE_ACL_DATA 2
+#define HCIT_TYPE_SCO_DATA 3
+#define HCIT_TYPE_EVENT 4
+#define HCIT_TYPE_LM_DIAG 7
+#define HCIT_TYPE_NFC 16
+
+#define HCIT_LM_DIAG_LENGTH 63
+
+/* Parameter information for HCI_BRCM_SET_ACL_PRIORITY */
+#define HCI_BRCM_ACL_PRIORITY_PARAM_SIZE 3
+#define HCI_BRCM_ACL_PRIORITY_LOW 0x00
+#define HCI_BRCM_ACL_PRIORITY_HIGH 0xFF
+#define HCI_BRCM_SET_ACL_PRIORITY (0x0057 | HCI_GRP_VENDOR_SPECIFIC)
+
+/* Define values for LMP Test Control parameters
+** Test Scenario, Hopping Mode, Power Control Mode
+*/
+#define LMP_TESTCTL_TESTSC_PAUSE 0
+#define LMP_TESTCTL_TESTSC_TXTEST_0 1
+#define LMP_TESTCTL_TESTSC_TXTEST_1 2
+#define LMP_TESTCTL_TESTSC_TXTEST_1010 3
+#define LMP_TESTCTL_TESTSC_PSRND_BITSEQ 4
+#define LMP_TESTCTL_TESTSC_CLOSEDLB_ACL 5
+#define LMP_TESTCTL_TESTSC_CLOSEDLB_SCO 6
+#define LMP_TESTCTL_TESTSC_ACL_NOWHIT 7
+#define LMP_TESTCTL_TESTSC_SCO_NOWHIT 8
+#define LMP_TESTCTL_TESTSC_TXTEST_11110000 9
+#define LMP_TESTCTL_TESTSC_EXITTESTMODE 255
+
+#define LMP_TESTCTL_HOPMOD_RXTX1FREQ 0
+#define LMP_TESTCTL_HOPMOD_HOP_EURUSA 1
+#define LMP_TESTCTL_HOPMOD_HOP_JAPAN 2
+#define LMP_TESTCTL_HOPMOD_HOP_FRANCE 3
+#define LMP_TESTCTL_HOPMOD_HOP_SPAIN 4
+#define LMP_TESTCTL_HOPMOD_REDUCED_HOP 5
+
+#define LMP_TESTCTL_POWCTL_FIXEDTX_OP 0
+#define LMP_TESTCTL_POWCTL_ADAPTIVE 1
+
+// TODO(zachoverflow): remove this once broadcom specific hacks are removed
+#define LMP_COMPID_BROADCOM 15
+
+/*
+** Define the packet types in the packet header, and a couple extra
+*/
+#define PKT_TYPE_NULL 0x00
+#define PKT_TYPE_POLL 0x01
+#define PKT_TYPE_FHS 0x02
+#define PKT_TYPE_DM1 0x03
+
+#define PKT_TYPE_DH1 0x04
+#define PKT_TYPE_HV1 0x05
+#define PKT_TYPE_HV2 0x06
+#define PKT_TYPE_HV3 0x07
+#define PKT_TYPE_DV 0x08
+#define PKT_TYPE_AUX1 0x09
+
+#define PKT_TYPE_DM3 0x0a
+#define PKT_TYPE_DH3 0x0b
+
+#define PKT_TYPE_DM5 0x0e
+#define PKT_TYPE_DH5 0x0f
+
+
+#define PKT_TYPE_ID 0x10 /* Internally used packet types */
+#define PKT_TYPE_BAD 0x11
+#define PKT_TYPE_NONE 0x12
+
+/*
+** Define packet size
+*/
+#define HCI_DM1_PACKET_SIZE 17
+#define HCI_DH1_PACKET_SIZE 27
+#define HCI_DM3_PACKET_SIZE 121
+#define HCI_DH3_PACKET_SIZE 183
+#define HCI_DM5_PACKET_SIZE 224
+#define HCI_DH5_PACKET_SIZE 339
+#define HCI_AUX1_PACKET_SIZE 29
+#define HCI_HV1_PACKET_SIZE 10
+#define HCI_HV2_PACKET_SIZE 20
+#define HCI_HV3_PACKET_SIZE 30
+#define HCI_DV_PACKET_SIZE 9
+#define HCI_EDR2_DH1_PACKET_SIZE 54
+#define HCI_EDR2_DH3_PACKET_SIZE 367
+#define HCI_EDR2_DH5_PACKET_SIZE 679
+#define HCI_EDR3_DH1_PACKET_SIZE 83
+#define HCI_EDR3_DH3_PACKET_SIZE 552
+#define HCI_EDR3_DH5_PACKET_SIZE 1021
+
+/* Feature Pages */
+#define HCI_EXT_FEATURES_PAGE_0 0 /* Extended Feature Page 0 (regular features) */
+#define HCI_EXT_FEATURES_PAGE_1 1 /* Extended Feature Page 1 */
+#define HCI_EXT_FEATURES_PAGE_2 2 /* Extended Feature Page 2 */
+#define HCI_EXT_FEATURES_PAGE_MAX HCI_EXT_FEATURES_PAGE_2
+
+#define HCI_FEATURE_BYTES_PER_PAGE 8
+
+#define HCI_FEATURES_KNOWN(x) ((x[0] | x[1] | x[2] | x[3] | x[4] | x[5] | x[6] | x[7]) != 0)
+
+/*
+** LMP features encoding - page 0
+*/
+#define HCI_FEATURE_3_SLOT_PACKETS_MASK 0x01
+#define HCI_FEATURE_3_SLOT_PACKETS_OFF 0
+#define HCI_3_SLOT_PACKETS_SUPPORTED(x) ((x)[HCI_FEATURE_3_SLOT_PACKETS_OFF] & HCI_FEATURE_3_SLOT_PACKETS_MASK)
+
+#define HCI_FEATURE_5_SLOT_PACKETS_MASK 0x02
+#define HCI_FEATURE_5_SLOT_PACKETS_OFF 0
+#define HCI_5_SLOT_PACKETS_SUPPORTED(x) ((x)[HCI_FEATURE_5_SLOT_PACKETS_OFF] & HCI_FEATURE_5_SLOT_PACKETS_MASK)
+
+#define HCI_FEATURE_ENCRYPTION_MASK 0x04
+#define HCI_FEATURE_ENCRYPTION_OFF 0
+#define HCI_ENCRYPTION_SUPPORTED(x) ((x)[HCI_FEATURE_ENCRYPTION_OFF] & HCI_FEATURE_ENCRYPTION_MASK)
+
+#define HCI_FEATURE_SLOT_OFFSET_MASK 0x08
+#define HCI_FEATURE_SLOT_OFFSET_OFF 0
+#define HCI_SLOT_OFFSET_SUPPORTED(x) ((x)[HCI_FEATURE_SLOT_OFFSET_OFF] & HCI_FEATURE_SLOT_OFFSET_MASK)
+
+#define HCI_FEATURE_TIMING_ACC_MASK 0x10
+#define HCI_FEATURE_TIMING_ACC_OFF 0
+#define HCI_TIMING_ACC_SUPPORTED(x) ((x)[HCI_FEATURE_TIMING_ACC_OFF] & HCI_FEATURE_TIMING_ACC_MASK)
+
+#define HCI_FEATURE_SWITCH_MASK 0x20
+#define HCI_FEATURE_SWITCH_OFF 0
+#define HCI_SWITCH_SUPPORTED(x) ((x)[HCI_FEATURE_SWITCH_OFF] & HCI_FEATURE_SWITCH_MASK)
+
+#define HCI_FEATURE_HOLD_MODE_MASK 0x40
+#define HCI_FEATURE_HOLD_MODE_OFF 0
+#define HCI_HOLD_MODE_SUPPORTED(x) ((x)[HCI_FEATURE_HOLD_MODE_OFF] & HCI_FEATURE_HOLD_MODE_MASK)
+
+#define HCI_FEATURE_SNIFF_MODE_MASK 0x80
+#define HCI_FEATURE_SNIFF_MODE_OFF 0
+#define HCI_SNIFF_MODE_SUPPORTED(x) ((x)[HCI_FEATURE_SNIFF_MODE_OFF] & HCI_FEATURE_SNIFF_MODE_MASK)
+
+#define HCI_FEATURE_PARK_MODE_MASK 0x01
+#define HCI_FEATURE_PARK_MODE_OFF 1
+#define HCI_PARK_MODE_SUPPORTED(x) ((x)[HCI_FEATURE_PARK_MODE_OFF] & HCI_FEATURE_PARK_MODE_MASK)
+
+#define HCI_FEATURE_RSSI_MASK 0x02
+#define HCI_FEATURE_RSSI_OFF 1
+#define HCI_RSSI_SUPPORTED(x) ((x)[HCI_FEATURE_RSSI_OFF] & HCI_FEATURE_RSSI_MASK)
+
+#define HCI_FEATURE_CQM_DATA_RATE_MASK 0x04
+#define HCI_FEATURE_CQM_DATA_RATE_OFF 1
+#define HCI_CQM_DATA_RATE_SUPPORTED(x) ((x)[HCI_FEATURE_CQM_DATA_RATE_OFF] & HCI_FEATURE_CQM_DATA_RATE_MASK)
+
+#define HCI_FEATURE_SCO_LINK_MASK 0x08
+#define HCI_FEATURE_SCO_LINK_OFF 1
+#define HCI_SCO_LINK_SUPPORTED(x) ((x)[HCI_FEATURE_SCO_LINK_OFF] & HCI_FEATURE_SCO_LINK_MASK)
+
+#define HCI_FEATURE_HV2_PACKETS_MASK 0x10
+#define HCI_FEATURE_HV2_PACKETS_OFF 1
+#define HCI_HV2_PACKETS_SUPPORTED(x) ((x)[HCI_FEATURE_HV2_PACKETS_OFF] & HCI_FEATURE_HV2_PACKETS_MASK)
+
+#define HCI_FEATURE_HV3_PACKETS_MASK 0x20
+#define HCI_FEATURE_HV3_PACKETS_OFF 1
+#define HCI_HV3_PACKETS_SUPPORTED(x) ((x)[HCI_FEATURE_HV3_PACKETS_OFF] & HCI_FEATURE_HV3_PACKETS_MASK)
+
+#define HCI_FEATURE_U_LAW_MASK 0x40
+#define HCI_FEATURE_U_LAW_OFF 1
+#define HCI_LMP_U_LAW_SUPPORTED(x) ((x)[HCI_FEATURE_U_LAW_OFF] & HCI_FEATURE_U_LAW_MASK)
+
+#define HCI_FEATURE_A_LAW_MASK 0x80
+#define HCI_FEATURE_A_LAW_OFF 1
+#define HCI_LMP_A_LAW_SUPPORTED(x) ((x)[HCI_FEATURE_A_LAW_OFF] & HCI_FEATURE_A_LAW_MASK)
+
+#define HCI_FEATURE_CVSD_MASK 0x01
+#define HCI_FEATURE_CVSD_OFF 2
+#define HCI_LMP_CVSD_SUPPORTED(x) ((x)[HCI_FEATURE_CVSD_OFF] & HCI_FEATURE_CVSD_MASK)
+
+#define HCI_FEATURE_PAGING_SCHEME_MASK 0x02
+#define HCI_FEATURE_PAGING_SCHEME_OFF 2
+#define HCI_PAGING_SCHEME_SUPPORTED(x) ((x)[HCI_FEATURE_PAGING_SCHEME_OFF] & HCI_FEATURE_PAGING_SCHEME_MASK)
+
+#define HCI_FEATURE_POWER_CTRL_MASK 0x04
+#define HCI_FEATURE_POWER_CTRL_OFF 2
+#define HCI_POWER_CTRL_SUPPORTED(x) ((x)[HCI_FEATURE_POWER_CTRL_OFF] & HCI_FEATURE_POWER_CTRL_MASK)
+
+#define HCI_FEATURE_TRANSPNT_MASK 0x08
+#define HCI_FEATURE_TRANSPNT_OFF 2
+#define HCI_LMP_TRANSPNT_SUPPORTED(x) ((x)[HCI_FEATURE_TRANSPNT_OFF] & HCI_FEATURE_TRANSPNT_MASK)
+
+#define HCI_FEATURE_FLOW_CTRL_LAG_MASK 0x70
+#define HCI_FEATURE_FLOW_CTRL_LAG_OFF 2
+#define HCI_FLOW_CTRL_LAG_VALUE(x) (((x)[HCI_FEATURE_FLOW_CTRL_LAG_OFF] & HCI_FEATURE_FLOW_CTRL_LAG_MASK) >> 4)
+
+#define HCI_FEATURE_BROADCAST_ENC_MASK 0x80
+#define HCI_FEATURE_BROADCAST_ENC_OFF 2
+#define HCI_LMP_BCAST_ENC_SUPPORTED(x) ((x)[HCI_FEATURE_BROADCAST_ENC_OFF] & HCI_FEATURE_BROADCAST_ENC_MASK)
+
+#define HCI_FEATURE_SCATTER_MODE_MASK 0x01
+#define HCI_FEATURE_SCATTER_MODE_OFF 3
+#define HCI_LMP_SCATTER_MODE_SUPPORTED(x) ((x)[HCI_FEATURE_SCATTER_MODE_OFF] & HCI_FEATURE_SCATTER_MODE_MASK)
+
+#define HCI_FEATURE_EDR_ACL_2MPS_MASK 0x02
+#define HCI_FEATURE_EDR_ACL_2MPS_OFF 3
+#define HCI_EDR_ACL_2MPS_SUPPORTED(x) ((x)[HCI_FEATURE_EDR_ACL_2MPS_OFF] & HCI_FEATURE_EDR_ACL_2MPS_MASK)
+
+#define HCI_FEATURE_EDR_ACL_3MPS_MASK 0x04
+#define HCI_FEATURE_EDR_ACL_3MPS_OFF 3
+#define HCI_EDR_ACL_3MPS_SUPPORTED(x) ((x)[HCI_FEATURE_EDR_ACL_3MPS_OFF] & HCI_FEATURE_EDR_ACL_3MPS_MASK)
+
+#define HCI_FEATURE_ENHANCED_INQ_MASK 0x08
+#define HCI_FEATURE_ENHANCED_INQ_OFF 3
+#define HCI_ENHANCED_INQ_SUPPORTED(x) ((x)[HCI_FEATURE_ENHANCED_INQ_OFF] & HCI_FEATURE_ENHANCED_INQ_MASK)
+
+#define HCI_FEATURE_INTERLACED_INQ_SCAN_MASK 0x10
+#define HCI_FEATURE_INTERLACED_INQ_SCAN_OFF 3
+#define HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(x) ((x)[HCI_FEATURE_INTERLACED_INQ_SCAN_OFF] & HCI_FEATURE_INTERLACED_INQ_SCAN_MASK)
+
+#define HCI_FEATURE_INTERLACED_PAGE_SCAN_MASK 0x20
+#define HCI_FEATURE_INTERLACED_PAGE_SCAN_OFF 3
+#define HCI_LMP_INTERLACED_PAGE_SCAN_SUPPORTED(x) ((x)[HCI_FEATURE_INTERLACED_PAGE_SCAN_OFF] & HCI_FEATURE_INTERLACED_PAGE_SCAN_MASK)
+
+#define HCI_FEATURE_INQ_RSSI_MASK 0x40
+#define HCI_FEATURE_INQ_RSSI_OFF 3
+#define HCI_LMP_INQ_RSSI_SUPPORTED(x) ((x)[HCI_FEATURE_INQ_RSSI_OFF] & HCI_FEATURE_INQ_RSSI_MASK)
+
+#define HCI_FEATURE_ESCO_EV3_MASK 0x80
+#define HCI_FEATURE_ESCO_EV3_OFF 3
+#define HCI_ESCO_EV3_SUPPORTED(x) ((x)[HCI_FEATURE_ESCO_EV3_OFF] & HCI_FEATURE_ESCO_EV3_MASK)
+
+#define HCI_FEATURE_ESCO_EV4_MASK 0x01
+#define HCI_FEATURE_ESCO_EV4_OFF 4
+#define HCI_ESCO_EV4_SUPPORTED(x) ((x)[HCI_FEATURE_ESCO_EV4_OFF] & HCI_FEATURE_ESCO_EV4_MASK)
+
+#define HCI_FEATURE_ESCO_EV5_MASK 0x02
+#define HCI_FEATURE_ESCO_EV5_OFF 4
+#define HCI_ESCO_EV5_SUPPORTED(x) ((x)[HCI_FEATURE_ESCO_EV5_OFF] & HCI_FEATURE_ESCO_EV5_MASK)
+
+#define HCI_FEATURE_ABSENCE_MASKS_MASK 0x04
+#define HCI_FEATURE_ABSENCE_MASKS_OFF 4
+#define HCI_LMP_ABSENCE_MASKS_SUPPORTED(x) ((x)[HCI_FEATURE_ABSENCE_MASKS_OFF] & HCI_FEATURE_ABSENCE_MASKS_MASK)
+
+#define HCI_FEATURE_AFH_CAP_SLAVE_MASK 0x08
+#define HCI_FEATURE_AFH_CAP_SLAVE_OFF 4
+#define HCI_LMP_AFH_CAP_SLAVE_SUPPORTED(x) ((x)[HCI_FEATURE_AFH_CAP_SLAVE_OFF] & HCI_FEATURE_AFH_CAP_SLAVE_MASK)
+
+#define HCI_FEATURE_AFH_CLASS_SLAVE_MASK 0x10
+#define HCI_FEATURE_AFH_CLASS_SLAVE_OFF 4
+#define HCI_LMP_AFH_CLASS_SLAVE_SUPPORTED(x) ((x)[HCI_FEATURE_AFH_CLASS_SLAVE_OFF] & HCI_FEATURE_AFH_CLASS_SLAVE_MASK)
+
+#if 1
+#define HCI_FEATURE_BREDR_NOT_SPT_MASK 0x20
+#define HCI_FEATURE_BREDR_NOT_SPT_OFF 4
+#define HCI_BREDR_NOT_SPT_SUPPORTED(x) ((x)[HCI_FEATURE_BREDR_NOT_SPT_OFF] & HCI_FEATURE_BREDR_NOT_SPT_MASK)
+
+#define HCI_FEATURE_LE_SPT_MASK 0x40
+#define HCI_FEATURE_LE_SPT_OFF 4
+#define HCI_LE_SPT_SUPPORTED(x) ((x)[HCI_FEATURE_LE_SPT_OFF] & HCI_FEATURE_LE_SPT_MASK)
+#else
+
+#define HCI_FEATURE_ALIAS_AUTH_MASK 0x20
+#define HCI_FEATURE_ALIAS_AUTH_OFF 4
+#define HCI_LMP_ALIAS_AUTH_SUPPORTED(x) ((x)[HCI_FEATURE_ALIAS_AUTH_OFF] & HCI_FEATURE_ALIAS_AUTH_MASK)
+
+#define HCI_FEATURE_ANON_MODE_MASK 0x40
+#define HCI_FEATURE_ANON_MODE_OFF 4
+#define HCI_LMP_ANON_MODE_SUPPORTED(x) ((x)[HCI_FEATURE_ANON_MODE_OFF] & HCI_FEATURE_ANON_MODE_MASK)
+#endif
+
+#define HCI_FEATURE_3_SLOT_EDR_ACL_MASK 0x80
+#define HCI_FEATURE_3_SLOT_EDR_ACL_OFF 4
+#define HCI_3_SLOT_EDR_ACL_SUPPORTED(x) ((x)[HCI_FEATURE_3_SLOT_EDR_ACL_OFF] & HCI_FEATURE_3_SLOT_EDR_ACL_MASK)
+
+#define HCI_FEATURE_5_SLOT_EDR_ACL_MASK 0x01
+#define HCI_FEATURE_5_SLOT_EDR_ACL_OFF 5
+#define HCI_5_SLOT_EDR_ACL_SUPPORTED(x) ((x)[HCI_FEATURE_5_SLOT_EDR_ACL_OFF] & HCI_FEATURE_5_SLOT_EDR_ACL_MASK)
+
+#define HCI_FEATURE_SNIFF_SUB_RATE_MASK 0x02
+#define HCI_FEATURE_SNIFF_SUB_RATE_OFF 5
+#define HCI_SNIFF_SUB_RATE_SUPPORTED(x) ((x)[HCI_FEATURE_SNIFF_SUB_RATE_OFF] & HCI_FEATURE_SNIFF_SUB_RATE_MASK)
+
+#define HCI_FEATURE_ATOMIC_ENCRYPT_MASK 0x04
+#define HCI_FEATURE_ATOMIC_ENCRYPT_OFF 5
+#define HCI_ATOMIC_ENCRYPT_SUPPORTED(x) ((x)[HCI_FEATURE_ATOMIC_ENCRYPT_OFF] & HCI_FEATURE_ATOMIC_ENCRYPT_MASK)
+
+#define HCI_FEATURE_AFH_CAP_MASTR_MASK 0x08
+#define HCI_FEATURE_AFH_CAP_MASTR_OFF 5
+#define HCI_LMP_AFH_CAP_MASTR_SUPPORTED(x) ((x)[HCI_FEATURE_AFH_CAP_MASTR_OFF] & HCI_FEATURE_AFH_CAP_MASTR_MASK)
+
+#define HCI_FEATURE_AFH_CLASS_MASTR_MASK 0x10
+#define HCI_FEATURE_AFH_CLASS_MASTR_OFF 5
+#define HCI_LMP_AFH_CLASS_MASTR_SUPPORTED(x) ((x)[HCI_FEATURE_AFH_CLASS_MASTR_OFF] & HCI_FEATURE_AFH_CLASS_MASTR_MASK)
+
+#define HCI_FEATURE_EDR_ESCO_2MPS_MASK 0x20
+#define HCI_FEATURE_EDR_ESCO_2MPS_OFF 5
+#define HCI_EDR_ESCO_2MPS_SUPPORTED(x) ((x)[HCI_FEATURE_EDR_ESCO_2MPS_OFF] & HCI_FEATURE_EDR_ESCO_2MPS_MASK)
+
+#define HCI_FEATURE_EDR_ESCO_3MPS_MASK 0x40
+#define HCI_FEATURE_EDR_ESCO_3MPS_OFF 5
+#define HCI_EDR_ESCO_3MPS_SUPPORTED(x) ((x)[HCI_FEATURE_EDR_ESCO_3MPS_OFF] & HCI_FEATURE_EDR_ESCO_3MPS_MASK)
+
+#define HCI_FEATURE_3_SLOT_EDR_ESCO_MASK 0x80
+#define HCI_FEATURE_3_SLOT_EDR_ESCO_OFF 5
+#define HCI_3_SLOT_EDR_ESCO_SUPPORTED(x) ((x)[HCI_FEATURE_3_SLOT_EDR_ESCO_OFF] & HCI_FEATURE_3_SLOT_EDR_ESCO_MASK)
+
+#define HCI_FEATURE_EXT_INQ_RSP_MASK 0x01
+#define HCI_FEATURE_EXT_INQ_RSP_OFF 6
+#define HCI_EXT_INQ_RSP_SUPPORTED(x) ((x)[HCI_FEATURE_EXT_INQ_RSP_OFF] & HCI_FEATURE_EXT_INQ_RSP_MASK)
+
+#if 1 /* TOKYO spec definition */
+#define HCI_FEATURE_SIMUL_LE_BREDR_MASK 0x02
+#define HCI_FEATURE_SIMUL_LE_BREDR_OFF 6
+#define HCI_SIMUL_LE_BREDR_SUPPORTED(x) ((x)[HCI_FEATURE_SIMUL_LE_BREDR_OFF] & HCI_FEATURE_SIMUL_LE_BREDR_MASK)
+
+#else
+#define HCI_FEATURE_ANUM_PIN_AWARE_MASK 0x02
+#define HCI_FEATURE_ANUM_PIN_AWARE_OFF 6
+#define HCI_ANUM_PIN_AWARE_SUPPORTED(x) ((x)[HCI_FEATURE_ANUM_PIN_AWARE_OFF] & HCI_FEATURE_ANUM_PIN_AWARE_MASK)
+#endif
+
+#define HCI_FEATURE_ANUM_PIN_CAP_MASK 0x04
+#define HCI_FEATURE_ANUM_PIN_CAP_OFF 6
+#define HCI_ANUM_PIN_CAP_SUPPORTED(x) ((x)[HCI_FEATURE_ANUM_PIN_CAP_OFF] & HCI_FEATURE_ANUM_PIN_CAP_MASK)
+
+#define HCI_FEATURE_SIMPLE_PAIRING_MASK 0x08
+#define HCI_FEATURE_SIMPLE_PAIRING_OFF 6
+#define HCI_SIMPLE_PAIRING_SUPPORTED(x) ((x)[HCI_FEATURE_SIMPLE_PAIRING_OFF] & HCI_FEATURE_SIMPLE_PAIRING_MASK)
+
+#define HCI_FEATURE_ENCAP_PDU_MASK 0x10
+#define HCI_FEATURE_ENCAP_PDU_OFF 6
+#define HCI_ENCAP_PDU_SUPPORTED(x) ((x)[HCI_FEATURE_ENCAP_PDU_OFF] & HCI_FEATURE_ENCAP_PDU_MASK)
+
+#define HCI_FEATURE_ERROR_DATA_MASK 0x20
+#define HCI_FEATURE_ERROR_DATA_OFF 6
+#define HCI_ERROR_DATA_SUPPORTED(x) ((x)[HCI_FEATURE_ERROR_DATA_OFF] & HCI_FEATURE_ERROR_DATA_MASK)
+
+#define HCI_FEATURE_NON_FLUSHABLE_PB_MASK 0x40
+#define HCI_FEATURE_NON_FLUSHABLE_PB_OFF 6
+
+/* This feature is causing frequent link drops when doing call switch with certain av/hfp headsets */
+#define HCI_NON_FLUSHABLE_PB_SUPPORTED(x) (0)//((x)[HCI_FEATURE_NON_FLUSHABLE_PB_OFF] & HCI_FEATURE_NON_FLUSHABLE_PB_MASK)
+
+#define HCI_FEATURE_LINK_SUP_TO_EVT_MASK 0x01
+#define HCI_FEATURE_LINK_SUP_TO_EVT_OFF 7
+#define HCI_LINK_SUP_TO_EVT_SUPPORTED(x) ((x)[HCI_FEATURE_LINK_SUP_TO_EVT_OFF] & HCI_FEATURE_LINK_SUP_TO_EVT_MASK)
+
+#define HCI_FEATURE_INQ_RESP_TX_MASK 0x02
+#define HCI_FEATURE_INQ_RESP_TX_OFF 7
+#define HCI_INQ_RESP_TX_SUPPORTED(x) ((x)[HCI_FEATURE_INQ_RESP_TX_OFF] & HCI_FEATURE_INQ_RESP_TX_MASK)
+
+#define HCI_FEATURE_EXTENDED_MASK 0x80
+#define HCI_FEATURE_EXTENDED_OFF 7
+#define HCI_LMP_EXTENDED_SUPPORTED(x) ((x)[HCI_FEATURE_EXTENDED_OFF] & HCI_FEATURE_EXTENDED_MASK)
+
+/*
+** LMP features encoding - page 1
+*/
+#define HCI_EXT_FEATURE_SSP_HOST_MASK 0x01
+#define HCI_EXT_FEATURE_SSP_HOST_OFF 0
+#define HCI_SSP_HOST_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_SSP_HOST_OFF] & HCI_EXT_FEATURE_SSP_HOST_MASK)
+
+#define HCI_EXT_FEATURE_LE_HOST_MASK 0x02
+#define HCI_EXT_FEATURE_LE_HOST_OFF 0
+#define HCI_LE_HOST_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_LE_HOST_OFF] & HCI_EXT_FEATURE_LE_HOST_MASK)
+
+#define HCI_EXT_FEATURE_SIMUL_DUMO_HOST_MASK 0x04
+#define HCI_EXT_FEATURE_SIMUL_DUMO_HOST_OFF 0
+#define HCI_SIMUL_DUMO_HOST_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_SIMUL_DUMO_HOST_OFF] & HCI_EXT_FEATURE_SIMUL_DUMO_HOST_MASK)
+
+#define HCI_EXT_FEATURE_SC_HOST_MASK 0x08
+#define HCI_EXT_FEATURE_SC_HOST_OFF 0
+#define HCI_SC_HOST_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_SC_HOST_OFF] & HCI_EXT_FEATURE_SC_HOST_MASK)
+
+/*
+** LMP features encoding - page 2
+*/
+#define HCI_EXT_FEATURE_CSB_MASTER_MASK 0x01
+#define HCI_EXT_FEATURE_CSB_MASTER_OFF 0
+#define HCI_CSB_MASTER_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_CSB_MASTER_OFF] & HCI_EXT_FEATURE_CSB_MASTER_MASK)
+
+#define HCI_EXT_FEATURE_CSB_SLAVE_MASK 0x02
+#define HCI_EXT_FEATURE_CSB_SLAVE_OFF 0
+#define HCI_CSB_SLAVE_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_CSB_SLAVE_OFF] & HCI_EXT_FEATURE_CSB_SLAVE_MASK)
+
+#define HCI_EXT_FEATURE_SYNC_TRAIN_MASTER_MASK 0x04
+#define HCI_EXT_FEATURE_SYNC_TRAIN_MASTER_OFF 0
+#define HCI_SYNC_TRAIN_MASTER_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_SYNC_TRAIN_MASTER_OFF] & HCI_EXT_FEATURE_SYNC_TRAIN_MASTER_MASK)
+
+#define HCI_EXT_FEATURE_SYNC_SCAN_SLAVE_MASK 0x08
+#define HCI_EXT_FEATURE_SYNC_SCAN_SLAVE_OFF 0
+#define HCI_SYNC_SCAN_SLAVE_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_SYNC_SCAN_SLAVE_OFF] & HCI_EXT_FEATURE_SYNC_SCAN_SLAVE_MASK)
+
+#define HCI_EXT_FEATURE_INQ_RESP_NOTIF_MASK 0x10
+#define HCI_EXT_FEATURE_INQ_RESP_NOTIF_OFF 0
+#define HCI_INQ_RESP_NOTIF_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_INQ_RESP_NOTIF_OFF] & HCI_EXT_FEATURE_INQ_RESP_NOTIF_MASK)
+
+#define HCI_EXT_FEATURE_SC_CTRLR_MASK 0x01
+#define HCI_EXT_FEATURE_SC_CTRLR_OFF 1
+#define HCI_SC_CTRLR_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_SC_CTRLR_OFF] & HCI_EXT_FEATURE_SC_CTRLR_MASK)
+
+#define HCI_EXT_FEATURE_PING_MASK 0x02
+#define HCI_EXT_FEATURE_PING_OFF 1
+#define HCI_PING_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_PING_OFF] & HCI_EXT_FEATURE_PING_MASK)
+
+/*
+** LE features encoding - page 0 (the only page for now)
+*/
+/* LE Encryption */
+#define HCI_LE_FEATURE_LE_ENCRYPTION_MASK 0x01
+#define HCI_LE_FEATURE_LE_ENCRYPTION_OFF 0
+#define HCI_LE_ENCRYPTION_SUPPORTED(x) ((x)[HCI_LE_FEATURE_LE_ENCRYPTION_OFF] & HCI_LE_FEATURE_LE_ENCRYPTION_MASK)
+
+/* Connection Parameters Request Procedure */
+#define HCI_LE_FEATURE_CONN_PARAM_REQ_MASK 0x02
+#define HCI_LE_FEATURE_CONN_PARAM_REQ_OFF 0
+#define HCI_LE_CONN_PARAM_REQ_SUPPORTED(x) ((x)[HCI_LE_FEATURE_CONN_PARAM_REQ_OFF] & HCI_LE_FEATURE_CONN_PARAM_REQ_MASK)
+
+/* Extended Reject Indication */
+#define HCI_LE_FEATURE_EXT_REJ_IND_MASK 0x04
+#define HCI_LE_FEATURE_EXT_REJ_IND_OFF 0
+#define HCI_LE_EXT_REJ_IND_SUPPORTED(x) ((x)[HCI_LE_FEATURE_EXT_REJ_IND_OFF] & HCI_LE_FEATURE_EXT_REJ_IND_MASK)
+
+/* Slave-initiated Features Exchange */
+#define HCI_LE_FEATURE_SLAVE_INIT_FEAT_EXC_MASK 0x08
+#define HCI_LE_FEATURE_SLAVE_INIT_FEAT_EXC_OFF 0
+#define HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(x) ((x)[HCI_LE_FEATURE_SLAVE_INIT_FEAT_EXC_OFF] & HCI_LE_FEATURE_SLAVE_INIT_FEAT_EXC_MASK)
+
+/* Enhanced privacy Feature: bit 6 */
+#define HCI_LE_FEATURE_ENHANCED_PRIVACY_MASK 0x40
+#define HCI_LE_FEATURE_ENHANCED_PRIVACY_OFF 0
+#define HCI_LE_ENHANCED_PRIVACY_SUPPORTED(x) ((x)[HCI_LE_FEATURE_ENHANCED_PRIVACY_OFF] & HCI_LE_FEATURE_ENHANCED_PRIVACY_MASK)
+
+/* Extended scanner filter policy : 7 */
+#define HCI_LE_FEATURE_EXT_SCAN_FILTER_POLICY_MASK 0x80
+#define HCI_LE_FEATURE_EXT_SCAN_FILTER_POLICY_OFF 0
+#define HCI_LE_EXT_SCAN_FILTER_POLICY_SUPPORTED(x) ((x)[HCI_LE_FEATURE_EXT_SCAN_FILTER_POLICY_OFF] & HCI_LE_FEATURE_EXT_SCAN_FILTER_POLICY_MASK)
+
+/* Slave-initiated Features Exchange */
+#define HCI_LE_FEATURE_DATA_LEN_EXT_MASK 0x20
+#define HCI_LE_FEATURE_DATA_LEN_EXT_OFF 0
+#define HCI_LE_DATA_LEN_EXT_SUPPORTED(x) ((x)[HCI_LE_FEATURE_DATA_LEN_EXT_OFF] & HCI_LE_FEATURE_DATA_LEN_EXT_MASK)
+
+/*
+** Local Supported Commands encoding
+*/
+#define HCI_NUM_SUPP_COMMANDS_BYTES 64
+
+/* Supported Commands Byte 0 */
+#define HCI_SUPP_COMMANDS_INQUIRY_MASK 0x01
+#define HCI_SUPP_COMMANDS_INQUIRY_OFF 0
+#define HCI_INQUIRY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_INQUIRY_OFF] & HCI_SUPP_COMMANDS_INQUIRY_MASK)
+
+#define HCI_SUPP_COMMANDS_INQUIRY_CANCEL_MASK 0x02
+#define HCI_SUPP_COMMANDS_INQUIRY_CANCEL_OFF 0
+#define HCI_INQUIRY_CANCEL_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_INQUIRY_CANCEL_OFF] & HCI_SUPP_COMMANDS_INQUIRY_CANCEL_MASK)
+
+#define HCI_SUPP_COMMANDS_PERIODIC_INQUIRY_MASK 0x04
+#define HCI_SUPP_COMMANDS_PERIODIC_INQUIRY_OFF 0
+#define HCI_PERIODIC_INQUIRY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_PERIODIC_INQUIRY_OFF] & HCI_SUPP_COMMANDS_PERIODIC_INQUIRY_MASK)
+
+#define HCI_SUPP_COMMANDS_EXIT_PERIODIC_INQUIRY_MASK 0x08
+#define HCI_SUPP_COMMANDS_EXIT_PERIODIC_INQUIRY_OFF 0
+#define HCI_EXIT_PERIODIC_INQUIRY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_EXIT_PERIODIC_INQUIRY_OFF] & HCI_SUPP_COMMANDS_EXIT_PERIODIC_INQUIRY_MASK)
+
+#define HCI_SUPP_COMMANDS_CREATE_CONN_MASK 0x10
+#define HCI_SUPP_COMMANDS_CREATE_CONN_OFF 0
+#define HCI_CREATE_CONN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_CREATE_CONN_OFF] & HCI_SUPP_COMMANDS_CREATE_CONN_MASK)
+
+#define HCI_SUPP_COMMANDS_DISCONNECT_MASK 0x20
+#define HCI_SUPP_COMMANDS_DISCONNECT_OFF 0
+#define HCI_DISCONNECT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_DISCONNECT_OFF] & HCI_SUPP_COMMANDS_DISCONNECT_MASK)
+
+#define HCI_SUPP_COMMANDS_ADD_SCO_CONN_MASK 0x40
+#define HCI_SUPP_COMMANDS_ADD_SCO_CONN_OFF 0
+#define HCI_ADD_SCO_CONN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ADD_SCO_CONN_OFF] & HCI_SUPP_COMMANDS_ADD_SCO_CONN_MASK)
+
+#define HCI_SUPP_COMMANDS_CANCEL_CREATE_CONN_MASK 0x80
+#define HCI_SUPP_COMMANDS_CANCEL_CREATE_CONN_OFF 0
+#define HCI_CANCEL_CREATE_CONN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_CANCEL_CREATE_CONN_OFF] & HCI_SUPP_COMMANDS_CANCEL_CREATE_CONN_MASK)
+
+#define HCI_SUPP_COMMANDS_ACCEPT_CONN_REQUEST_MASK 0x01
+#define HCI_SUPP_COMMANDS_ACCEPT_CONN_REQUEST_OFF 1
+#define HCI_ACCEPT_CONN_REQUEST_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ACCEPT_CONN_REQUEST_OFF] & HCI_SUPP_COMMANDS_ACCEPT_CONN_REQUEST_MASK)
+
+#define HCI_SUPP_COMMANDS_REJECT_CONN_REQUEST_MASK 0x02
+#define HCI_SUPP_COMMANDS_REJECT_CONN_REQUEST_OFF 1
+#define HCI_REJECT_CONN_REQUEST_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_REJECT_CONN_REQUEST_OFF] & HCI_SUPP_COMMANDS_REJECT_CONN_REQUEST_MASK)
+
+#define HCI_SUPP_COMMANDS_LINK_KEY_REQUEST_REPLY_MASK 0x04
+#define HCI_SUPP_COMMANDS_LINK_KEY_REQUEST_REPLY_OFF 1
+#define HCI_LINK_KEY_REQUEST_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_LINK_KEY_REQUEST_REPLY_OFF] & HCI_SUPP_COMMANDS_LINK_KEY_REQUEST_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_LINK_KEY_REQUEST_NEG_REPLY_MASK 0x08
+#define HCI_SUPP_COMMANDS_LINK_KEY_REQUEST_NEG_REPLY_OFF 1
+#define HCI_LINK_KEY_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_LINK_KEY_REQUEST_NEG_REPLY_OFF] & HCI_SUPP_COMMANDS_LINK_KEY_REQUEST_NEG_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_PIN_CODE_REQUEST_REPLY_MASK 0x10
+#define HCI_SUPP_COMMANDS_PIN_CODE_REQUEST_REPLY_OFF 1
+#define HCI_PIN_CODE_REQUEST_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_PIN_CODE_REQUEST_REPLY_OFF] & HCI_SUPP_COMMANDS_PIN_CODE_REQUEST_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_PIN_CODE_REQUEST_NEG_REPLY_MASK 0x20
+#define HCI_SUPP_COMMANDS_PIN_CODE_REQUEST_NEG_REPLY_OFF 1
+#define HCI_PIN_CODE_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_PIN_CODE_REQUEST_NEG_REPLY_OFF] & HCI_SUPP_COMMANDS_PIN_CODE_REQUEST_NEG_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_CHANGE_CONN_PKT_TYPE_MASK 0x40
+#define HCI_SUPP_COMMANDS_CHANGE_CONN_PKT_TYPE_OFF 1
+#define HCI_CHANGE_CONN_PKT_TYPE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_CHANGE_CONN_PKT_TYPE_OFF] & HCI_SUPP_COMMANDS_CHANGE_CONN_PKT_TYPE_MASK)
+
+#define HCI_SUPP_COMMANDS_AUTH_REQUEST_MASK 0x80
+#define HCI_SUPP_COMMANDS_AUTH_REQUEST_OFF 1
+#define HCI_AUTH_REQUEST_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_AUTH_REQUEST_OFF] & HCI_SUPP_COMMANDS_AUTH_REQUEST_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_CONN_ENCRYPTION_MASK 0x01
+#define HCI_SUPP_COMMANDS_SET_CONN_ENCRYPTION_OFF 2
+#define HCI_SET_CONN_ENCRYPTION_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_CONN_ENCRYPTION_OFF] & HCI_SUPP_COMMANDS_SET_CONN_ENCRYPTION_MASK)
+
+#define HCI_SUPP_COMMANDS_CHANGE_CONN_LINK_KEY_MASK 0x02
+#define HCI_SUPP_COMMANDS_CHANGE_CONN_LINK_KEY_OFF 2
+#define HCI_CHANGE_CONN_LINK_KEY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_CHANGE_CONN_LINK_KEY_OFF] & HCI_SUPP_COMMANDS_CHANGE_CONN_LINK_KEY_MASK)
+
+#define HCI_SUPP_COMMANDS_MASTER_LINK_KEY_MASK 0x04
+#define HCI_SUPP_COMMANDS_MASTER_LINK_KEY_OFF 2
+#define HCI_MASTER_LINK_KEY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_MASTER_LINK_KEY_OFF] & HCI_SUPP_COMMANDS_MASTER_LINK_KEY_MASK)
+
+#define HCI_SUPP_COMMANDS_REMOTE_NAME_REQUEST_MASK 0x08
+#define HCI_SUPP_COMMANDS_REMOTE_NAME_REQUEST_OFF 2
+#define HCI_REMOTE_NAME_REQUEST_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_REMOTE_NAME_REQUEST_OFF] & HCI_SUPP_COMMANDS_REMOTE_NAME_REQUEST_MASK)
+
+#define HCI_SUPP_COMMANDS_CANCEL_REMOTE_NAME_REQUEST_MASK 0x10
+#define HCI_SUPP_COMMANDS_CANCEL_REMOTE_NAME_REQUEST_OFF 2
+#define HCI_CANCEL_REMOTE_NAME_REQUEST_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_CANCEL_REMOTE_NAME_REQUEST_OFF] & HCI_SUPP_COMMANDS_CANCEL_REMOTE_NAME_REQUEST_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_REMOTE_SUPP_FEATURES_MASK 0x20
+#define HCI_SUPP_COMMANDS_READ_REMOTE_SUPP_FEATURES_OFF 2
+#define HCI_READ_REMOTE_SUPP_FEATURES_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_REMOTE_SUPP_FEATURES_OFF] & HCI_SUPP_COMMANDS_READ_REMOTE_SUPP_FEATURES_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_REMOTE_EXT_FEATURES_MASK 0x40
+#define HCI_SUPP_COMMANDS_READ_REMOTE_EXT_FEATURES_OFF 2
+#define HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_REMOTE_EXT_FEATURES_OFF] & HCI_SUPP_COMMANDS_READ_REMOTE_EXT_FEATURES_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_REMOTE_VER_INFO_MASK 0x80
+#define HCI_SUPP_COMMANDS_READ_REMOTE_VER_INFO_OFF 2
+#define HCI_READ_REMOTE_VER_INFO_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_REMOTE_VER_INFO_OFF] & HCI_SUPP_COMMANDS_READ_REMOTE_VER_INFO_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_CLOCK_OFFSET_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_CLOCK_OFFSET_OFF 3
+#define HCI_READ_CLOCK_OFFSET_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_CLOCK_OFFSET_OFF] & HCI_SUPP_COMMANDS_READ_CLOCK_OFFSET_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LMP_HANDLE_MASK 0x02
+#define HCI_SUPP_COMMANDS_READ_LMP_HANDLE_OFF 3
+#define HCI_READ_LMP_HANDLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LMP_HANDLE_OFF] & HCI_SUPP_COMMANDS_READ_LMP_HANDLE_MASK)
+
+#define HCI_SUPP_COMMANDS_HOLD_MODE_CMD_MASK 0x02
+#define HCI_SUPP_COMMANDS_HOLD_MODE_CMD_OFF 4
+#define HCI_HOLD_MODE_CMD_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_HOLD_MODE_CMD_OFF] & HCI_SUPP_COMMANDS_HOLD_MODE_CMD_MASK)
+
+#define HCI_SUPP_COMMANDS_SNIFF_MODE_CMD_MASK 0x04
+#define HCI_SUPP_COMMANDS_SNIFF_MODE_CMD_OFF 4
+#define HCI_SNIFF_MODE_CMD_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SNIFF_MODE_CMD_OFF] & HCI_SUPP_COMMANDS_SNIFF_MODE_CMD_MASK)
+
+#define HCI_SUPP_COMMANDS_EXIT_SNIFF_MODE_MASK 0x08
+#define HCI_SUPP_COMMANDS_EXIT_SNIFF_MODE_OFF 4
+#define HCI_EXIT_SNIFF_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_EXIT_SNIFF_MODE_OFF] & HCI_SUPP_COMMANDS_EXIT_SNIFF_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_PARK_STATE_MASK 0x10
+#define HCI_SUPP_COMMANDS_PARK_STATE_OFF 4
+#define HCI_PARK_STATE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_PARK_STATE_OFF] & HCI_SUPP_COMMANDS_PARK_STATE_MASK)
+
+#define HCI_SUPP_COMMANDS_EXIT_PARK_STATE_MASK 0x20
+#define HCI_SUPP_COMMANDS_EXIT_PARK_STATE_OFF 4
+#define HCI_EXIT_PARK_STATE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_EXIT_PARK_STATE_OFF] & HCI_SUPP_COMMANDS_EXIT_PARK_STATE_MASK)
+
+#define HCI_SUPP_COMMANDS_QOS_SETUP_MASK 0x40
+#define HCI_SUPP_COMMANDS_QOS_SETUP_OFF 4
+#define HCI_QOS_SETUP_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_QOS_SETUP_OFF] & HCI_SUPP_COMMANDS_QOS_SETUP_MASK)
+
+#define HCI_SUPP_COMMANDS_ROLE_DISCOVERY_MASK 0x80
+#define HCI_SUPP_COMMANDS_ROLE_DISCOVERY_OFF 4
+#define HCI_ROLE_DISCOVERY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ROLE_DISCOVERY_OFF] & HCI_SUPP_COMMANDS_ROLE_DISCOVERY_MASK)
+
+#define HCI_SUPP_COMMANDS_SWITCH_ROLE_MASK 0x01
+#define HCI_SUPP_COMMANDS_SWITCH_ROLE_OFF 5
+#define HCI_SWITCH_ROLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SWITCH_ROLE_OFF] & HCI_SUPP_COMMANDS_SWITCH_ROLE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LINK_POLICY_SET_MASK 0x02
+#define HCI_SUPP_COMMANDS_READ_LINK_POLICY_SET_OFF 5
+#define HCI_READ_LINK_POLICY_SET_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LINK_POLICY_SET_OFF] & HCI_SUPP_COMMANDS_READ_LINK_POLICY_SET_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_LINK_POLICY_SET_MASK 0x04
+#define HCI_SUPP_COMMANDS_WRITE_LINK_POLICY_SET_OFF 5
+#define HCI_WRITE_LINK_POLICY_SET_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_LINK_POLICY_SET_OFF] & HCI_SUPP_COMMANDS_WRITE_LINK_POLICY_SET_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_DEF_LINK_POLICY_SET_MASK 0x08
+#define HCI_SUPP_COMMANDS_READ_DEF_LINK_POLICY_SET_OFF 5
+#define HCI_READ_DEF_LINK_POLICY_SET_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_DEF_LINK_POLICY_SET_OFF] & HCI_SUPP_COMMANDS_READ_DEF_LINK_POLICY_SET_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_DEF_LINK_POLICY_SET_MASK 0x10
+#define HCI_SUPP_COMMANDS_WRITE_DEF_LINK_POLICY_SET_OFF 5
+#define HCI_WRITE_DEF_LINK_POLICY_SET_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_DEF_LINK_POLICY_SET_OFF] & HCI_SUPP_COMMANDS_WRITE_DEF_LINK_POLICY_SET_MASK)
+
+#define HCI_SUPP_COMMANDS_FLOW_SPECIFICATION_MASK 0x20
+#define HCI_SUPP_COMMANDS_FLOW_SPECIFICATION_OFF 5
+#define HCI_FLOW_SPECIFICATION_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_FLOW_SPECIFICATION_OFF] & HCI_SUPP_COMMANDS_FLOW_SPECIFICATION_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_EVENT_MASK_MASK 0x40
+#define HCI_SUPP_COMMANDS_SET_EVENT_MASK_OFF 5
+#define HCI_SET_EVENT_MASK_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_EVENT_MASK_OFF] & HCI_SUPP_COMMANDS_SET_EVENT_MASK_MASK)
+
+#define HCI_SUPP_COMMANDS_RESET_MASK 0x80
+#define HCI_SUPP_COMMANDS_RESET_OFF 5
+#define HCI_RESET_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_RESET_OFF] & HCI_SUPP_COMMANDS_RESET_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_EVENT_FILTER_MASK 0x01
+#define HCI_SUPP_COMMANDS_SET_EVENT_FILTER_OFF 6
+#define HCI_SET_EVENT_FILTER_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_EVENT_FILTER_OFF] & HCI_SUPP_COMMANDS_SET_EVENT_FILTER_MASK)
+
+#define HCI_SUPP_COMMANDS_FLUSH_MASK 0x02
+#define HCI_SUPP_COMMANDS_FLUSH_OFF 6
+#define HCI_FLUSH_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_FLUSH_OFF] & HCI_SUPP_COMMANDS_FLUSH_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_PIN_TYPE_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_PIN_TYPE_OFF 6
+#define HCI_READ_PIN_TYPE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_PIN_TYPE_OFF] & HCI_SUPP_COMMANDS_READ_PIN_TYPE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_PIN_TYPE_MASK 0x08
+#define HCI_SUPP_COMMANDS_WRITE_PIN_TYPE_OFF 6
+#define HCI_WRITE_PIN_TYPE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_PIN_TYPE_OFF] & HCI_SUPP_COMMANDS_WRITE_PIN_TYPE_MASK)
+
+#define HCI_SUPP_COMMANDS_CREATE_NEW_UNIT_KEY_MASK 0x10
+#define HCI_SUPP_COMMANDS_CREATE_NEW_UNIT_KEY_OFF 6
+#define HCI_CREATE_NEW_UNIT_KEY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_CREATE_NEW_UNIT_KEY_OFF] & HCI_SUPP_COMMANDS_CREATE_NEW_UNIT_KEY_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_STORED_LINK_KEY_MASK 0x20
+#define HCI_SUPP_COMMANDS_READ_STORED_LINK_KEY_OFF 6
+#define HCI_READ_STORED_LINK_KEY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_STORED_LINK_KEY_OFF] & HCI_SUPP_COMMANDS_READ_STORED_LINK_KEY_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_STORED_LINK_KEY_MASK 0x40
+#define HCI_SUPP_COMMANDS_WRITE_STORED_LINK_KEY_OFF 6
+#define HCI_WRITE_STORED_LINK_KEY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_STORED_LINK_KEY_OFF] & HCI_SUPP_COMMANDS_WRITE_STORED_LINK_KEY_MASK)
+
+#define HCI_SUPP_COMMANDS_DELETE_STORED_LINK_KEY_MASK 0x80
+#define HCI_SUPP_COMMANDS_DELETE_STORED_LINK_KEY_OFF 6
+#define HCI_DELETE_STORED_LINK_KEY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_DELETE_STORED_LINK_KEY_OFF] & HCI_SUPP_COMMANDS_DELETE_STORED_LINK_KEY_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_LOCAL_NAME_MASK 0x01
+#define HCI_SUPP_COMMANDS_WRITE_LOCAL_NAME_OFF 7
+#define HCI_WRITE_LOCAL_NAME_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_LOCAL_NAME_OFF] & HCI_SUPP_COMMANDS_WRITE_LOCAL_NAME_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_NAME_MASK 0x02
+#define HCI_SUPP_COMMANDS_READ_LOCAL_NAME_OFF 7
+#define HCI_READ_LOCAL_NAME_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_NAME_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_NAME_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_CONN_ACCEPT_TOUT_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_CONN_ACCEPT_TOUT_OFF 7
+#define HCI_READ_CONN_ACCEPT_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_CONN_ACCEPT_TOUT_OFF] & HCI_SUPP_COMMANDS_READ_CONN_ACCEPT_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_CONN_ACCEPT_TOUT_MASK 0x08
+#define HCI_SUPP_COMMANDS_WRITE_CONN_ACCEPT_TOUT_OFF 7
+#define HCI_WRITE_CONN_ACCEPT_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_CONN_ACCEPT_TOUT_OFF] & HCI_SUPP_COMMANDS_WRITE_CONN_ACCEPT_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_PAGE_TOUT_MASK 0x10
+#define HCI_SUPP_COMMANDS_READ_PAGE_TOUT_OFF 7
+#define HCI_READ_PAGE_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_PAGE_TOUT_OFF] & HCI_SUPP_COMMANDS_READ_PAGE_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_TOUT_MASK 0x20
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_TOUT_OFF 7
+#define HCI_WRITE_PAGE_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_PAGE_TOUT_OFF] & HCI_SUPP_COMMANDS_WRITE_PAGE_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_SCAN_ENABLE_MASK 0x40
+#define HCI_SUPP_COMMANDS_READ_SCAN_ENABLE_OFF 7
+#define HCI_READ_SCAN_ENABLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_SCAN_ENABLE_OFF] & HCI_SUPP_COMMANDS_READ_SCAN_ENABLE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_SCAN_ENABLE_MASK 0x80
+#define HCI_SUPP_COMMANDS_WRITE_SCAN_ENABLE_OFF 7
+#define HCI_WRITE_SCAN_ENABLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_SCAN_ENABLE_OFF] & HCI_SUPP_COMMANDS_WRITE_SCAN_ENABLE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_PAGE_SCAN_ACTIVITY_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_PAGE_SCAN_ACTIVITY_OFF 8
+#define HCI_READ_PAGE_SCAN_ACTIVITY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_PAGE_SCAN_ACTIVITY_OFF] & HCI_SUPP_COMMANDS_READ_PAGE_SCAN_ACTIVITY_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_ACTIVITY_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_ACTIVITY_OFF 8
+#define HCI_WRITE_PAGE_SCAN_ACTIVITY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_ACTIVITY_OFF] & HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_ACTIVITY_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_INQURIY_SCAN_ACTIVITY_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_INQURIY_SCAN_ACTIVITY_OFF 8
+#define HCI_READ_INQURIY_SCAN_ACTIVITY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_INQURIY_SCAN_ACTIVITY_OFF] & HCI_SUPP_COMMANDS_READ_INQURIY_SCAN_ACTIVITY_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_INQURIY_SCAN_ACTIVITY_MASK 0x08
+#define HCI_SUPP_COMMANDS_WRITE_INQURIY_SCAN_ACTIVITY_OFF 8
+#define HCI_WRITE_INQURIY_SCAN_ACTIVITY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_INQURIY_SCAN_ACTIVITY_OFF] & HCI_SUPP_COMMANDS_WRITE_INQURIY_SCAN_ACTIVITY_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_AUTH_ENABLE_MASK 0x10
+#define HCI_SUPP_COMMANDS_READ_AUTH_ENABLE_OFF 8
+#define HCI_READ_AUTH_ENABLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_AUTH_ENABLE_OFF] & HCI_SUPP_COMMANDS_READ_AUTH_ENABLE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_AUTH_ENABLE_MASK 0x20
+#define HCI_SUPP_COMMANDS_WRITE_AUTH_ENABLE_OFF 8
+#define HCI_WRITE_AUTH_ENABLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_AUTH_ENABLE_OFF] & HCI_SUPP_COMMANDS_WRITE_AUTH_ENABLE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_ENCRYPT_ENABLE_MASK 0x40
+#define HCI_SUPP_COMMANDS_READ_ENCRYPT_ENABLE_OFF 8
+#define HCI_READ_ENCRYPT_ENABLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_ENCRYPT_ENABLE_OFF] & HCI_SUPP_COMMANDS_READ_ENCRYPT_ENABLE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_ENCRYPT_ENABLE_MASK 0x80
+#define HCI_SUPP_COMMANDS_WRITE_ENCRYPT_ENABLE_OFF 8
+#define HCI_WRITE_ENCRYPT_ENABLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_ENCRYPT_ENABLE_OFF] & HCI_SUPP_COMMANDS_WRITE_ENCRYPT_ENABLE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_CLASS_DEVICE_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_CLASS_DEVICE_OFF 9
+#define HCI_READ_CLASS_DEVICE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_CLASS_DEVICE_OFF] & HCI_SUPP_COMMANDS_READ_CLASS_DEVICE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_CLASS_DEVICE_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_CLASS_DEVICE_OFF 9
+#define HCI_WRITE_CLASS_DEVICE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_CLASS_DEVICE_OFF] & HCI_SUPP_COMMANDS_WRITE_CLASS_DEVICE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_VOICE_SETTING_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_VOICE_SETTING_OFF 9
+#define HCI_READ_VOICE_SETTING_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_VOICE_SETTING_OFF] & HCI_SUPP_COMMANDS_READ_VOICE_SETTING_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_VOICE_SETTING_MASK 0x08
+#define HCI_SUPP_COMMANDS_WRITE_VOICE_SETTING_OFF 9
+#define HCI_WRITE_VOICE_SETTING_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_VOICE_SETTING_OFF] & HCI_SUPP_COMMANDS_WRITE_VOICE_SETTING_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_AUTO_FLUSH_TOUT_MASK 0x10
+#define HCI_SUPP_COMMANDS_READ_AUTO_FLUSH_TOUT_OFF 9
+#define HCI_READ_AUTO_FLUSH_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_AUTO_FLUSH_TOUT_OFF] & HCI_SUPP_COMMANDS_READ_AUTO_FLUSH_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_AUTO_FLUSH_TOUT_MASK 0x20
+#define HCI_SUPP_COMMANDS_WRITE_AUTO_FLUSH_TOUT_OFF 9
+#define HCI_WRITE_AUTO_FLUSH_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_AUTO_FLUSH_TOUT_OFF] & HCI_SUPP_COMMANDS_WRITE_AUTO_FLUSH_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_NUM_BROAD_RETRANS_MASK 0x40
+#define HCI_SUPP_COMMANDS_READ_NUM_BROAD_RETRANS_OFF 9
+#define HCI_READ_NUM_BROAD_RETRANS_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_NUM_BROAD_RETRANS_OFF] & HCI_SUPP_COMMANDS_READ_NUM_BROAD_RETRANS_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_NUM_BROAD_RETRANS_MASK 0x80
+#define HCI_SUPP_COMMANDS_WRITE_NUM_BROAD_RETRANS_OFF 9
+#define HCI_WRITE_NUM_BROAD_RETRANS_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_NUM_BROAD_RETRANS_OFF] & HCI_SUPP_COMMANDS_WRITE_NUM_BROAD_RETRANS_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_HOLD_MODE_ACTIVITY_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_HOLD_MODE_ACTIVITY_OFF 10
+#define HCI_READ_HOLD_MODE_ACTIVITY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_HOLD_MODE_ACTIVITY_OFF] & HCI_SUPP_COMMANDS_READ_HOLD_MODE_ACTIVITY_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_HOLD_MODE_ACTIVITY_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_HOLD_MODE_ACTIVITY_OFF 10
+#define HCI_WRITE_HOLD_MODE_ACTIVITY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_HOLD_MODE_ACTIVITY_OFF] & HCI_SUPP_COMMANDS_WRITE_HOLD_MODE_ACTIVITY_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_TRANS_PWR_LEVEL_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_TRANS_PWR_LEVEL_OFF 10
+#define HCI_READ_TRANS_PWR_LEVEL_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_TRANS_PWR_LEVEL_OFF] & HCI_SUPP_COMMANDS_READ_TRANS_PWR_LEVEL_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_SYNCH_FLOW_CTRL_ENABLE_MASK 0x08
+#define HCI_SUPP_COMMANDS_READ_SYNCH_FLOW_CTRL_ENABLE_OFF 10
+#define HCI_READ_SYNCH_FLOW_CTRL_ENABLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_SYNCH_FLOW_CTRL_ENABLE_OFF] & HCI_SUPP_COMMANDS_READ_SYNCH_FLOW_CTRL_ENABLE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_SYNCH_FLOW_CTRL_ENABLE_MASK 0x10
+#define HCI_SUPP_COMMANDS_WRITE_SYNCH_FLOW_CTRL_ENABLE_OFF 10
+#define HCI_WRITE_SYNCH_FLOW_CTRL_ENABLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_SYNCH_FLOW_CTRL_ENABLE_OFF] & HCI_SUPP_COMMANDS_WRITE_SYNCH_FLOW_CTRL_ENABLE_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_HOST_CTRLR_TO_HOST_FC_MASK 0x20
+#define HCI_SUPP_COMMANDS_SET_HOST_CTRLR_TO_HOST_FC_OFF 10
+#define HCI_SET_HOST_CTRLR_TO_HOST_FC_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_HOST_CTRLR_TO_HOST_FC_OFF] & HCI_SUPP_COMMANDS_SET_HOST_CTRLR_TO_HOST_FC_MASK)
+
+#define HCI_SUPP_COMMANDS_HOST_BUFFER_SIZE_MASK 0x40
+#define HCI_SUPP_COMMANDS_HOST_BUFFER_SIZE_OFF 10
+#define HCI_HOST_BUFFER_SIZE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_HOST_BUFFER_SIZE_OFF] & HCI_SUPP_COMMANDS_HOST_BUFFER_SIZE_MASK)
+
+#define HCI_SUPP_COMMANDS_HOST_NUM_COMPLETED_PKTS_MASK 0x80
+#define HCI_SUPP_COMMANDS_HOST_NUM_COMPLETED_PKTS_OFF 10
+#define HCI_HOST_NUM_COMPLETED_PKTS_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_HOST_NUM_COMPLETED_PKTS_OFF] & HCI_SUPP_COMMANDS_HOST_NUM_COMPLETED_PKTS_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LINK_SUP_TOUT_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_LINK_SUP_TOUT_OFF 11
+#define HCI_READ_LINK_SUP_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LINK_SUP_TOUT_OFF] & HCI_SUPP_COMMANDS_READ_LINK_SUP_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_LINK_SUP_TOUT_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_LINK_SUP_TOUT_OFF 11
+#define HCI_WRITE_LINK_SUP_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_LINK_SUP_TOUT_OFF] & HCI_SUPP_COMMANDS_WRITE_LINK_SUP_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_NUM_SUPP_IAC_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_NUM_SUPP_IAC_OFF 11
+#define HCI_READ_NUM_SUPP_IAC_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_NUM_SUPP_IAC_OFF] & HCI_SUPP_COMMANDS_READ_NUM_SUPP_IAC_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_CURRENT_IAC_LAP_MASK 0x08
+#define HCI_SUPP_COMMANDS_READ_CURRENT_IAC_LAP_OFF 11
+#define HCI_READ_CURRENT_IAC_LAP_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_CURRENT_IAC_LAP_OFF] & HCI_SUPP_COMMANDS_READ_CURRENT_IAC_LAP_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_CURRENT_IAC_LAP_MASK 0x10
+#define HCI_SUPP_COMMANDS_WRITE_CURRENT_IAC_LAP_OFF 11
+#define HCI_WRITE_CURRENT_IAC_LAP_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_CURRENT_IAC_LAP_OFF] & HCI_SUPP_COMMANDS_WRITE_CURRENT_IAC_LAP_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_PAGE_SCAN_PER_MODE_MASK 0x20
+#define HCI_SUPP_COMMANDS_READ_PAGE_SCAN_PER_MODE_OFF 11
+#define HCI_READ_PAGE_SCAN_PER_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_PAGE_SCAN_PER_MODE_OFF] & HCI_SUPP_COMMANDS_READ_PAGE_SCAN_PER_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_PER_MODE_MASK 0x40
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_PER_MODE_OFF 11
+#define HCI_WRITE_PAGE_SCAN_PER_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_PER_MODE_OFF] & HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_PER_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_PAGE_SCAN_MODE_MASK 0x80
+#define HCI_SUPP_COMMANDS_READ_PAGE_SCAN_MODE_OFF 11
+#define HCI_READ_PAGE_SCAN_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_PAGE_SCAN_MODE_OFF] & HCI_SUPP_COMMANDS_READ_PAGE_SCAN_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_MODE_MASK 0x01
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_MODE_OFF 12
+#define HCI_WRITE_PAGE_SCAN_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_MODE_OFF] & HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_AFH_CHNL_CLASS_MASK 0x02
+#define HCI_SUPP_COMMANDS_SET_AFH_CHNL_CLASS_OFF 12
+#define HCI_SET_AFH_CHNL_CLASS_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_AFH_CHNL_CLASS_OFF] & HCI_SUPP_COMMANDS_SET_AFH_CHNL_CLASS_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_INQUIRY_SCAN_TYPE_MASK 0x10
+#define HCI_SUPP_COMMANDS_READ_INQUIRY_SCAN_TYPE_OFF 12
+#define HCI_READ_INQUIRY_SCAN_TYPE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_INQUIRY_SCAN_TYPE_OFF] & HCI_SUPP_COMMANDS_READ_INQUIRY_SCAN_TYPE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_INQUIRY_SCAN_TYPE_MASK 0x20
+#define HCI_SUPP_COMMANDS_WRITE_INQUIRY_SCAN_TYPE_OFF 12
+#define HCI_WRITE_INQUIRY_SCAN_TYPE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_INQUIRY_SCAN_TYPE_OFF] & HCI_SUPP_COMMANDS_WRITE_INQUIRY_SCAN_TYPE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_INQUIRY_MODE_MASK 0x40
+#define HCI_SUPP_COMMANDS_READ_INQUIRY_MODE_OFF 12
+#define HCI_READ_INQUIRY_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_INQUIRY_MODE_OFF] & HCI_SUPP_COMMANDS_READ_INQUIRY_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_INQUIRY_MODE_MASK 0x80
+#define HCI_SUPP_COMMANDS_WRITE_INQUIRY_MODE_OFF 12
+#define HCI_WRITE_INQUIRY_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_INQUIRY_MODE_OFF] & HCI_SUPP_COMMANDS_WRITE_INQUIRY_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_PAGE_SCAN_TYPE_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_PAGE_SCAN_TYPE_OFF 13
+#define HCI_READ_PAGE_SCAN_TYPE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_PAGE_SCAN_TYPE_OFF] & HCI_SUPP_COMMANDS_READ_PAGE_SCAN_TYPE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_TYPE_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_TYPE_OFF 13
+#define HCI_WRITE_PAGE_SCAN_TYPE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_TYPE_OFF] & HCI_SUPP_COMMANDS_WRITE_PAGE_SCAN_TYPE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_AFH_CHNL_ASSESS_MODE_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_AFH_CHNL_ASSESS_MODE_OFF 13
+#define HCI_READ_AFH_CHNL_ASSESS_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_AFH_CHNL_ASSESS_MODE_OFF] & HCI_SUPP_COMMANDS_READ_AFH_CHNL_ASSESS_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_AFH_CHNL_ASSESS_MODE_MASK 0x08
+#define HCI_SUPP_COMMANDS_WRITE_AFH_CHNL_ASSESS_MODE_OFF 13
+#define HCI_WRITE_AFH_CHNL_ASSESS_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_AFH_CHNL_ASSESS_MODE_OFF] & HCI_SUPP_COMMANDS_WRITE_AFH_CHNL_ASSESS_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_VER_INFO_MASK 0x08
+#define HCI_SUPP_COMMANDS_READ_LOCAL_VER_INFO_OFF 14
+#define HCI_READ_LOCAL_VER_INFO_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_VER_INFO_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_VER_INFO_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_SUP_CMDS_MASK 0x10
+#define HCI_SUPP_COMMANDS_READ_LOCAL_SUP_CMDS_OFF 14
+#define HCI_READ_LOCAL_SUP_CMDS_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_SUP_CMDS_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_SUP_CMDS_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_SUPP_FEATURES_MASK 0x20
+#define HCI_SUPP_COMMANDS_READ_LOCAL_SUPP_FEATURES_OFF 14
+#define HCI_READ_LOCAL_SUPP_FEATURES_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_SUPP_FEATURES_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_SUPP_FEATURES_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_EXT_FEATURES_MASK 0x40
+#define HCI_SUPP_COMMANDS_READ_LOCAL_EXT_FEATURES_OFF 14
+#define HCI_READ_LOCAL_EXT_FEATURES_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_EXT_FEATURES_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_EXT_FEATURES_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_BUFFER_SIZE_MASK 0x80
+#define HCI_SUPP_COMMANDS_READ_BUFFER_SIZE_OFF 14
+#define HCI_READ_BUFFER_SIZE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_BUFFER_SIZE_OFF] & HCI_SUPP_COMMANDS_READ_BUFFER_SIZE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_COUNTRY_CODE_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_COUNTRY_CODE_OFF 15
+#define HCI_READ_COUNTRY_CODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_COUNTRY_CODE_OFF] & HCI_SUPP_COMMANDS_READ_COUNTRY_CODE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_BD_ADDR_MASK 0x02
+#define HCI_SUPP_COMMANDS_READ_BD_ADDR_OFF 15
+#define HCI_READ_BD_ADDR_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_BD_ADDR_OFF] & HCI_SUPP_COMMANDS_READ_BD_ADDR_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_FAIL_CONTACT_CNTR_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_FAIL_CONTACT_CNTR_OFF 15
+#define HCI_READ_FAIL_CONTACT_CNTR_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_FAIL_CONTACT_CNTR_OFF] & HCI_SUPP_COMMANDS_READ_FAIL_CONTACT_CNTR_MASK)
+
+#define HCI_SUPP_COMMANDS_RESET_FAIL_CONTACT_CNTR_MASK 0x08
+#define HCI_SUPP_COMMANDS_RESET_FAIL_CONTACT_CNTR_OFF 15
+#define HCI_RESET_FAIL_CONTACT_CNTR_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_RESET_FAIL_CONTACT_CNTR_OFF] & HCI_SUPP_COMMANDS_RESET_FAIL_CONTACT_CNTR_MASK)
+
+#define HCI_SUPP_COMMANDS_GET_LINK_QUALITY_MASK 0x10
+#define HCI_SUPP_COMMANDS_GET_LINK_QUALITY_OFF 15
+#define HCI_GET_LINK_QUALITY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_GET_LINK_QUALITY_OFF] & HCI_SUPP_COMMANDS_GET_LINK_QUALITY_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_RSSI_MASK 0x20
+#define HCI_SUPP_COMMANDS_READ_RSSI_OFF 15
+#define HCI_READ_RSSI_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_RSSI_OFF] & HCI_SUPP_COMMANDS_READ_RSSI_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_AFH_CH_MAP_MASK 0x40
+#define HCI_SUPP_COMMANDS_READ_AFH_CH_MAP_OFF 15
+#define HCI_READ_AFH_CH_MAP_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_AFH_CH_MAP_OFF] & HCI_SUPP_COMMANDS_READ_AFH_CH_MAP_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_BD_CLOCK_MASK 0x80
+#define HCI_SUPP_COMMANDS_READ_BD_CLOCK_OFF 15
+#define HCI_READ_BD_CLOCK_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_BD_CLOCK_OFF] & HCI_SUPP_COMMANDS_READ_BD_CLOCK_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOOPBACK_MODE_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_LOOPBACK_MODE_OFF 16
+#define HCI_READ_LOOPBACK_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOOPBACK_MODE_OFF] & HCI_SUPP_COMMANDS_READ_LOOPBACK_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_LOOPBACK_MODE_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_LOOPBACK_MODE_OFF 16
+#define HCI_WRITE_LOOPBACK_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_LOOPBACK_MODE_OFF] & HCI_SUPP_COMMANDS_WRITE_LOOPBACK_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_ENABLE_DEV_UNDER_TEST_MASK 0x04
+#define HCI_SUPP_COMMANDS_ENABLE_DEV_UNDER_TEST_OFF 16
+#define HCI_ENABLE_DEV_UNDER_TEST_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ENABLE_DEV_UNDER_TEST_OFF] & HCI_SUPP_COMMANDS_ENABLE_DEV_UNDER_TEST_MASK)
+
+#define HCI_SUPP_COMMANDS_SETUP_SYNCH_CONN_MASK 0x08
+#define HCI_SUPP_COMMANDS_SETUP_SYNCH_CONN_OFF 16
+#define HCI_SETUP_SYNCH_CONN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SETUP_SYNCH_CONN_OFF] & HCI_SUPP_COMMANDS_SETUP_SYNCH_CONN_MASK)
+
+#define HCI_SUPP_COMMANDS_ACCEPT_SYNCH_CONN_MASK 0x10
+#define HCI_SUPP_COMMANDS_ACCEPT_SYNCH_CONN_OFF 16
+#define HCI_ACCEPT_SYNCH_CONN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ACCEPT_SYNCH_CONN_OFF] & HCI_SUPP_COMMANDS_ACCEPT_SYNCH_CONN_MASK)
+
+#define HCI_SUPP_COMMANDS_REJECT_SYNCH_CONN_MASK 0x20
+#define HCI_SUPP_COMMANDS_REJECT_SYNCH_CONN_OFF 16
+#define HCI_REJECT_SYNCH_CONN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_REJECT_SYNCH_CONN_OFF] & HCI_SUPP_COMMANDS_REJECT_SYNCH_CONN_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_EXT_INQUIRY_RESP_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_EXT_INQUIRY_RESP_OFF 17
+#define HCI_READ_EXT_INQUIRY_RESP_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_EXT_INQUIRY_RESP_OFF] & HCI_SUPP_COMMANDS_READ_EXT_INQUIRY_RESP_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_EXT_INQUIRY_RESP_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_EXT_INQUIRY_RESP_OFF 17
+#define HCI_WRITE_EXT_INQUIRY_RESP_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_EXT_INQUIRY_RESP_OFF] & HCI_SUPP_COMMANDS_WRITE_EXT_INQUIRY_RESP_MASK)
+
+#define HCI_SUPP_COMMANDS_REFRESH_ENCRYPTION_KEY_MASK 0x04
+#define HCI_SUPP_COMMANDS_REFRESH_ENCRYPTION_KEY_OFF 17
+#define HCI_REFRESH_ENCRYPTION_KEY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_REFRESH_ENCRYPTION_KEY_OFF] & HCI_SUPP_COMMANDS_REFRESH_ENCRYPTION_KEY_MASK)
+
+/* Octet 17, bit 3 is reserved */
+
+#define HCI_SUPP_COMMANDS_SNIFF_SUB_RATE_MASK 0x10
+#define HCI_SUPP_COMMANDS_SNIFF_SUB_RATE_OFF 17
+#define HCI_SNIFF_SUB_RATE_CMD_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SNIFF_SUB_RATE_OFF] & HCI_SUPP_COMMANDS_SNIFF_SUB_RATE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_SIMPLE_PAIRING_MODE_MASK 0x20
+#define HCI_SUPP_COMMANDS_READ_SIMPLE_PAIRING_MODE_OFF 17
+#define HCI_READ_SIMPLE_PAIRING_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_SIMPLE_PAIRING_MODE_OFF] & HCI_SUPP_COMMANDS_READ_SIMPLE_PAIRING_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_SIMPLE_PAIRING_MODE_MASK 0x40
+#define HCI_SUPP_COMMANDS_WRITE_SIMPLE_PAIRING_MODE_OFF 17
+#define HCI_WRITE_SIMPLE_PAIRING_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_SIMPLE_PAIRING_MODE_OFF] & HCI_SUPP_COMMANDS_WRITE_SIMPLE_PAIRING_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_OOB_DATA_MASK 0x80
+#define HCI_SUPP_COMMANDS_READ_LOCAL_OOB_DATA_OFF 17
+#define HCI_READ_LOCAL_OOB_DATA_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_OOB_DATA_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_OOB_DATA_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_INQUIRY_RESPONSE_TX_POWER_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_INQUIRY_RESPONSE_TX_POWER_OFF 18
+#define HCI_READ_INQUIRY_RESPONSE_TX_POWER_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_INQUIRY_RESPONSE_TX_POWER_OFF] & HCI_SUPP_COMMANDS_READ_INQUIRY_RESPONSE_TX_POWER_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_INQUIRY_RESPONSE_TX_POWER_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_INQUIRY_RESPONSE_TX_POWER_OFF 18
+#define HCI_WRITE_INQUIRY_RESPONSE_TX_POWER_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_INQUIRY_RESPONSE_TX_POWER_OFF] & HCI_SUPP_COMMANDS_WRITE_INQUIRY_RESPONSE_TX_POWER_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_DEFAULT_ERRONEOUS_DATA_REPORTING_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_DEFAULT_ERRONEOUS_DATA_REPORTING_OFF 18
+#define HCI_READ_DEFAULT_ERRONEOUS_DATA_REPORTING_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_DEFAULT_ERRONEOUS_DATA_REPORTING_OFF] & HCI_SUPP_COMMANDS_READ_DEFAULT_ERRONEOUS_DATA_REPORTING_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING_MASK 0x08
+#define HCI_SUPP_COMMANDS_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING_OFF 18
+#define HCI_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING_OFF] & HCI_SUPP_COMMANDS_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING_MASK)
+
+#define HCI_SUPP_COMMANDS_IO_CAPABILITY_REQUEST_REPLY_MASK 0x80
+#define HCI_SUPP_COMMANDS_IO_CAPABILITY_REQUEST_REPLY_OFF 18
+#define HCI_IO_CAPABILITY_REQUEST_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_IO_CAPABILITY_REQUEST_REPLY_OFF] & HCI_SUPP_COMMANDS_IO_CAPABILITY_REQUEST_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_USER_CONFIRMATION_REQUEST_REPLY_MASK 0x01
+#define HCI_SUPP_COMMANDS_USER_CONFIRMATION_REQUEST_REPLY_OFF 19
+#define HCI_USER_CONFIRMATION_REQUEST_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_USER_CONFIRMATION_REQUEST_REPLY_OFF] & HCI_SUPP_COMMANDS_USER_CONFIRMATION_REQUEST_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_USER_CONFIRMATION_REQUEST_NEG_REPLY_MASK 0x02
+#define HCI_SUPP_COMMANDS_USER_CONFIRMATION_REQUEST_NEG_REPLY_OFF 19
+#define HCI_USER_CONFIRMATION_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_USER_CONFIRMATION_REQUEST_NEG_REPLY_OFF] & HCI_SUPP_COMMANDS_USER_CONFIRMATION_REQUEST_NEG_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_USER_PASSKEY_REQUEST_REPLY_MASK 0x04
+#define HCI_SUPP_COMMANDS_USER_PASSKEY_REQUEST_REPLY_OFF 19
+#define HCI_USER_PASSKEY_REQUEST_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_USER_PASSKEY_REQUEST_REPLY_OFF] & HCI_SUPP_COMMANDS_USER_PASSKEY_REQUEST_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_USER_PASSKEY_REQUEST_NEG_REPLY_MASK 0x08
+#define HCI_SUPP_COMMANDS_USER_PASSKEY_REQUEST_NEG_REPLY_OFF 19
+#define HCI_USER_PASSKEY_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_USER_PASSKEY_REQUEST_NEG_REPLY_OFF] & HCI_SUPP_COMMANDS_USER_PASSKEY_REQUEST_NEG_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_REMOTE_OOB_DATA_REQUEST_REPLY_MASK 0x10
+#define HCI_SUPP_COMMANDS_REMOTE_OOB_DATA_REQUEST_REPLY_OFF 19
+#define HCI_REMOTE_OOB_DATA_REQUEST_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_REMOTE_OOB_DATA_REQUEST_REPLY_OFF] & HCI_SUPP_COMMANDS_REMOTE_OOB_DATA_REQUEST_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_SIMPLE_PAIRING_DBG_MODE_MASK 0x20
+#define HCI_SUPP_COMMANDS_WRITE_SIMPLE_PAIRING_DBG_MODE_OFF 19
+#define HCI_WRITE_SIMPLE_PAIRING_DBG_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_SIMPLE_PAIRING_DBG_MODE_OFF] & HCI_SUPP_COMMANDS_WRITE_SIMPLE_PAIRING_DBG_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_ENHANCED_FLUSH_MASK 0x40
+#define HCI_SUPP_COMMANDS_ENHANCED_FLUSH_OFF 19
+#define HCI_ENHANCED_FLUSH_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ENHANCED_FLUSH_OFF] & HCI_SUPP_COMMANDS_ENHANCED_FLUSH_MASK)
+
+#define HCI_SUPP_COMMANDS_REMOTE_OOB_DATA_REQUEST_NEG_REPLY_MASK 0x80
+#define HCI_SUPP_COMMANDS_REMOTE_OOB_DATA_REQUEST_NEG_REPLY_OFF 19
+#define HCI_REMOTE_OOB_DATA_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_REMOTE_OOB_DATA_REQUEST_NEG_REPLY_OFF] & HCI_SUPP_COMMANDS_REMOTE_OOB_DATA_REQUEST_NEG_REPLY_MASK)
+
+/* Supported Commands (Byte 20) */
+#define HCI_SUPP_COMMANDS_SEND_KEYPRESS_NOTIF_MASK 0x04
+#define HCI_SUPP_COMMANDS_SEND_KEYPRESS_NOTIF_OFF 20
+#define HCI_SEND_NOTIF_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SEND_KEYPRESS_NOTIF_OFF] & HCI_SUPP_COMMANDS_SEND_KEYPRESS_NOTIF_MASK)
+
+#define HCI_SUPP_COMMANDS_IO_CAP_REQ_NEG_REPLY_MASK 0x08
+#define HCI_SUPP_COMMANDS_IO_CAP_REQ_NEG_REPLY_OFF 20
+#define HCI_IO_CAP_REQ_NEG_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_IO_CAP_REQ_NEG_REPLY_OFF] & HCI_SUPP_COMMANDS_IO_CAP_REQ_NEG_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_ENCR_KEY_SIZE_MASK 0x10
+#define HCI_SUPP_COMMANDS_READ_ENCR_KEY_SIZE_OFF 20
+#define HCI_READ_ENCR_KEY_SIZE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_ENCR_KEY_SIZE_OFF] & HCI_SUPP_COMMANDS_READ_ENCR_KEY_SIZE_MASK)
+
+/* Supported Commands (Byte 21) */
+#define HCI_SUPP_COMMANDS_CREATE_PHYSICAL_LINK_MASK 0x01
+#define HCI_SUPP_COMMANDS_CREATE_PHYSICAL_LINK_OFF 21
+#define HCI_CREATE_PHYSICAL_LINK_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_CREATE_PHYSICAL_LINK_OFF] & HCI_SUPP_COMMANDS_CREATE_PHYSICAL_LINK_MASK)
+
+#define HCI_SUPP_COMMANDS_ACCEPT_PHYSICAL_LINK_MASK 0x02
+#define HCI_SUPP_COMMANDS_ACCEPT_PHYSICAL_LINK_OFF 21
+#define HCI_ACCEPT_PHYSICAL_LINK_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ACCEPT_PHYSICAL_LINK_OFF] & HCI_SUPP_COMMANDS_ACCEPT_PHYSICAL_LINK_MASK)
+
+#define HCI_SUPP_COMMANDS_DISCONNECT_PHYSICAL_LINK_MASK 0x04
+#define HCI_SUPP_COMMANDS_DISCONNECT_PHYSICAL_LINK_OFF 21
+#define HCI_DISCONNECT_PHYSICAL_LINK_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_DISCONNECT_PHYSICAL_LINK_OFF] & HCI_SUPP_COMMANDS_DISCONNECT_PHYSICAL_LINK_MASK)
+
+#define HCI_SUPP_COMMANDS_CREATE_LOGICAL_LINK_MASK 0x08
+#define HCI_SUPP_COMMANDS_CREATE_LOGICAL_LINK_OFF 21
+#define HCI_CREATE_LOGICAL_LINK_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_CREATE_LOGICAL_LINK_OFF] & HCI_SUPP_COMMANDS_CREATE_LOGICAL_LINK_MASK)
+
+#define HCI_SUPP_COMMANDS_ACCEPT_LOGICAL_LINK_MASK 0x10
+#define HCI_SUPP_COMMANDS_ACCEPT_LOGICAL_LINK_OFF 21
+#define HCI_ACCEPT_LOGICAL_LINK_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ACCEPT_LOGICAL_LINK_OFF] & HCI_SUPP_COMMANDS_ACCEPT_LOGICAL_LINK_MASK)
+
+#define HCI_SUPP_COMMANDS_DISCONNECT_LOGICAL_LINK_MASK 0x20
+#define HCI_SUPP_COMMANDS_DISCONNECT_LOGICAL_LINK_OFF 21
+#define HCI_DISCONNECT_LOGICAL_LINK_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_DISCONNECT_LOGICAL_LINK_OFF] & HCI_SUPP_COMMANDS_DISCONNECT_LOGICAL_LINK_MASK)
+
+#define HCI_SUPP_COMMANDS_LOGICAL_LINK_CANCEL_MASK 0x40
+#define HCI_SUPP_COMMANDS_LOGICAL_LINK_CANCEL_OFF 21
+#define HCI_LOGICAL_LINK_CANCEL_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_LOGICAL_LINK_CANCEL_OFF] & HCI_SUPP_COMMANDS_LOGICAL_LINK_CANCEL_MASK)
+
+#define HCI_SUPP_COMMANDS_FLOW_SPEC_MODIFY_MASK 0x80
+#define HCI_SUPP_COMMANDS_FLOW_SPEC_MODIFY_OFF 21
+#define HCI_FLOW_SPEC_MODIFY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_FLOW_SPEC_MODIFY_OFF] & HCI_SUPP_COMMANDS_FLOW_SPEC_MODIFY_MASK)
+
+/* Supported Commands (Byte 22) */
+#define HCI_SUPP_COMMANDS_READ_LOGICAL_LINK_ACCEPT_TIMEOUT_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_LOGICAL_LINK_ACCEPT_TIMEOUT_OFF 22
+#define HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOGICAL_LINK_ACCEPT_TIMEOUT_OFF] & HCI_SUPP_COMMANDS_READ_LOGICAL_LINK_ACCEPT_TIMEOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_OFF 22
+#define HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_OFF] & HCI_SUPP_COMMANDS_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_EVENT_MASK_PAGE_2_MASK 0x04
+#define HCI_SUPP_COMMANDS_SET_EVENT_MASK_PAGE_2_OFF 22
+#define HCI_SET_EVENT_MASK_PAGE_2_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_EVENT_MASK_PAGE_2_OFF] & HCI_SUPP_COMMANDS_SET_EVENT_MASK_PAGE_2_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCATION_DATA_MASK 0x08
+#define HCI_SUPP_COMMANDS_READ_LOCATION_DATA_OFF 22
+#define HCI_READ_LOCATION_DATA_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCATION_DATA_OFF] & HCI_SUPP_COMMANDS_READ_LOCATION_DATA_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_LOCATION_DATA_MASK 0x10
+#define HCI_SUPP_COMMANDS_WRITE_LOCATION_DATA_OFF 22
+#define HCI_WRITE_LOCATION_DATA_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_LOCATION_DATA_OFF] & HCI_SUPP_COMMANDS_WRITE_LOCATION_DATA_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_AMP_INFO_MASK 0x20
+#define HCI_SUPP_COMMANDS_READ_LOCAL_AMP_INFO_OFF 22
+#define HCI_READ_LOCAL_AMP_INFO_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_AMP_INFO_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_AMP_INFO_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_AMP_ASSOC_MASK 0x40
+#define HCI_SUPP_COMMANDS_READ_LOCAL_AMP_ASSOC_OFF 22
+#define HCI_READ_LOCAL_AMP_ASSOC_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_AMP_ASSOC_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_AMP_ASSOC_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_REMOTE_AMP_ASSOC_MASK 0x80
+#define HCI_SUPP_COMMANDS_WRITE_REMOTE_AMP_ASSOC_OFF 22
+#define HCI_WRITE_REMOTE_AMP_ASSOC_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_REMOTE_AMP_ASSOC_OFF] & HCI_SUPP_COMMANDS_WRITE_REMOTE_AMP_ASSOC_MASK)
+
+/* Supported Commands (Byte 23) */
+#define HCI_SUPP_COMMANDS_READ_FLOW_CONTROL_MODE_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_FLOW_CONTROL_MODE_OFF 23
+#define HCI_READ_FLOW_CONTROL_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_FLOW_CONTROL_MODE_OFF] & HCI_SUPP_COMMANDS_READ_FLOW_CONTROL_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_FLOW_CONTROL_MODE_MASK 0x02
+#define HCI_SUPP_COMMANDS_WRITE_FLOW_CONTROL_MODE_OFF 23
+#define HCI_WRITE_FLOW_CONTROL_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_FLOW_CONTROL_MODE_OFF] & HCI_SUPP_COMMANDS_WRITE_FLOW_CONTROL_MODE_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_DATA_BLOCK_SIZE_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_DATA_BLOCK_SIZE_OFF 23
+#define HCI_READ_DATA_BLOCK_SIZE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_DATA_BLOCK_SIZE_OFF] & HCI_SUPP_COMMANDS_READ_DATA_BLOCK_SIZE_MASK)
+
+#define HCI_SUPP_COMMANDS_ENABLE_AMP_RCVR_REPORTS_MASK 0x20
+#define HCI_SUPP_COMMANDS_ENABLE_AMP_RCVR_REPORTS_OFF 23
+#define HCI_ENABLE_AMP_RCVR_REPORTS_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ENABLE_AMP_RCVR_REPORTS_OFF] & HCI_SUPP_COMMANDS_ENABLE_AMP_RCVR_REPORTS_MASK)
+
+#define HCI_SUPP_COMMANDS_AMP_TEST_END_MASK 0x40
+#define HCI_SUPP_COMMANDS_AMP_TEST_END_OFF 23
+#define HCI_AMP_TEST_END_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_AMP_TEST_END_OFF] & HCI_SUPP_COMMANDS_AMP_TEST_END_MASK)
+
+#define HCI_SUPP_COMMANDS_AMP_TEST_MASK 0x80
+#define HCI_SUPP_COMMANDS_AMP_TEST_OFF 23
+#define HCI_AMP_TEST_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_AMP_TEST_OFF] & HCI_SUPP_COMMANDS_AMP_TEST_MASK)
+
+/* Supported Commands (Byte 24) */
+#define HCI_SUPP_COMMANDS_READ_TRANSMIT_POWER_LEVEL_MASK 0x01
+#define HCI_SUPP_COMMANDS_READ_TRANSMIT_POWER_LEVEL_OFF 24
+#define HCI_READ_TRANSMIT_POWER_LEVEL_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_TRANSMIT_POWER_LEVEL_OFF] & HCI_SUPP_COMMANDS_READ_TRANSMIT_POWER_LEVEL_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_BE_FLUSH_TOUT_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_BE_FLUSH_TOUT_OFF 24
+#define HCI_READ_BE_FLUSH_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_BE_FLUSH_TOUT_OFF] & HCI_SUPP_COMMANDS_READ_BE_FLUSH_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_BE_FLUSH_TOUT_MASK 0x08
+#define HCI_SUPP_COMMANDS_WRITE_BE_FLUSH_TOUT_OFF 24
+#define HCI_WRITE_BE_FLUSH_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_BE_FLUSH_TOUT_OFF] & HCI_SUPP_COMMANDS_WRITE_BE_FLUSH_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_SHORT_RANGE_MODE_MASK 0x10
+#define HCI_SUPP_COMMANDS_SHORT_RANGE_MODE_OFF 24
+#define HCI_SHORT_RANGE_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SHORT_RANGE_MODE_OFF] & HCI_SUPP_COMMANDS_SHORT_RANGE_MODE_MASK)
+
+/* LE commands TBD
+** Supported Commands (Byte 24 continued)
+** Supported Commands (Byte 25)
+** Supported Commands (Byte 26)
+** Supported Commands (Byte 27)
+** Supported Commands (Byte 28)
+*/
+
+/* Supported Commands (Byte 29) */
+#define HCI_SUPP_COMMANDS_ENH_SETUP_SYNCH_CONN_MASK 0x08
+#define HCI_SUPP_COMMANDS_ENH_SETUP_SYNCH_CONN_OFF 29
+#define HCI_READ_ENH_SETUP_SYNCH_CONN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ENH_SETUP_SYNCH_CONN_OFF] & HCI_SUPP_COMMANDS_ENH_SETUP_SYNCH_CONN_MASK)
+
+#define HCI_SUPP_COMMANDS_ENH_ACCEPT_SYNCH_CONN_MASK 0x10
+#define HCI_SUPP_COMMANDS_ENH_ACCEPT_SYNCH_CONN_OFF 29
+#define HCI_READ_ENH_ACCEPT_SYNCH_CONN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_ENH_ACCEPT_SYNCH_CONN_OFF] & HCI_SUPP_COMMANDS_ENH_ACCEPT_SYNCH_CONN_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_CODECS_MASK 0x20
+#define HCI_SUPP_COMMANDS_READ_LOCAL_CODECS_OFF 29
+#define HCI_READ_LOCAL_CODECS_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_CODECS_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_CODECS_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_MWS_CHANN_PARAM_MASK 0x40
+#define HCI_SUPP_COMMANDS_SET_MWS_CHANN_PARAM_OFF 29
+#define HCI_SET_MWS_CHANNEL_PARAMETERS_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_MWS_CHANN_PARAM_OFF] & HCI_SUPP_COMMANDS_SET_MWS_CHANN_PARAM_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_EXT_FRAME_CONF_MASK 0x80
+#define HCI_SUPP_COMMANDS_SET_EXT_FRAME_CONF_OFF 29
+#define HCI_SET_EXTERNAL_FRAME_CONFIGURATION_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_EXT_FRAME_CONF_OFF] & HCI_SUPP_COMMANDS_SET_EXT_FRAME_CONF_MASK)
+
+
+/* Supported Commands (Byte 30) */
+#define HCI_SUPP_COMMANDS_SET_MWS_SIGNALING_MASK 0x01
+#define HCI_SUPP_COMMANDS_SET_MWS_SIGNALING_OFF 30
+#define HCI_SET_MWS_SIGNALING_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_MWS_SIGNALING_OFF] & HCI_SUPP_COMMANDS_SET_MWS_SIGNALING_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_MWS_TRANS_LAYER_MASK 0x02
+#define HCI_SUPP_COMMANDS_SET_MWS_TRANS_LAYER_OFF 30
+#define HCI_SET_MWS_TRANSPORT_LAYER_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_MWS_TRANS_LAYER_OFF] & HCI_SUPP_COMMANDS_SET_MWS_TRANS_LAYER_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_MWS_SCAN_FREQ_TABLE_MASK 0x04
+#define HCI_SUPP_COMMANDS_SET_MWS_SCAN_FREQ_TABLE_OFF 30
+#define HCI_SET_MWS_SCAN_FREQUENCY_TABLE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_MWS_SCAN_FREQ_TABLE_OFF] & HCI_SUPP_COMMANDS_SET_MWS_SCAN_FREQ_TABLE_MASK)
+
+#define HCI_SUPP_COMMANDS_GET_TRANS_LAYER_CONF_MASK 0x08
+#define HCI_SUPP_COMMANDS_GET_TRANS_LAYER_CONF_OFF 30
+#define HCI_GET_MWS_TRANS_LAYER_CFG_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_GET_TRANS_LAYER_CONF_OFF] & HCI_SUPP_COMMANDS_GET_TRANS_LAYER_CONF_MASK)
+
+#define HCI_SUPP_COMMANDS_SET_MWS_PATTERN_CONF_MASK 0x10
+#define HCI_SUPP_COMMANDS_SET_MWS_PATTERN_CONF_OFF 30
+#define HCI_SET_MWS_PATTERN_CONFIGURATION_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_MWS_PATTERN_CONF_OFF] & HCI_SUPP_COMMANDS_SET_MWS_PATTERN_CONF_MASK)
+
+/* Supported Commands (Byte 30 bit 5) */
+#define HCI_SUPP_COMMANDS_SET_TRIG_CLK_CAP_MASK 0x20
+#define HCI_SUPP_COMMANDS_SET_TRIG_CLK_CAP_OFF 30
+#define HCI_SET_TRIG_CLK_CAP_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_TRIG_CLK_CAP_OFF] & HCI_SUPP_COMMANDS_SET_TRIG_CLK_CAP_MASK)
+
+
+/* Supported Commands (Byte 30 bit 6-7) */
+#define HCI_SUPP_COMMANDS_TRUNCATED_PAGE 0x06
+#define HCI_SUPP_COMMANDS_TRUNCATED_PAGE_OFF 30
+#define HCI_TRUNCATED_PAGE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_TRUNCATED_PAGE_OFF] & HCI_SUPP_COMMANDS_TRUNCATED_PAGE)
+
+#define HCI_SUPP_COMMANDS_TRUNCATED_PAGE_CANCEL 0x07
+#define HCI_SUPP_COMMANDS_TRUNCATED_PAGE_CANCEL_OFF 30
+#define HCI_TRUNCATED_PAGE_CANCEL_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_TRUNCATED_PAGE_CANCEL_OFF] & HCI_SUPP_COMMANDS_TRUNCATED_PAGE_CANCEL)
+
+/* Supported Commands (Byte 31 bit 6-7) */
+#define HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST 0x00
+#define HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_OFF 31
+#define HCI_SET_CONLESS_SLAVE_BRCST_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_OFF] & HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST)
+
+#define HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_RECEIVE 0x01
+#define HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_RECEIVE_OFF 31
+#define HCI_SET_CONLESS_SLAVE_BRCST_RECEIVE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_RECEIVE_OFF] & HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_RECEIVE)
+
+#define HCI_SUPP_COMMANDS_START_SYNC_TRAIN 0x02
+#define HCI_SUPP_COMMANDS_START_SYNC_TRAIN_OFF 31
+#define HCI_START_SYNC_TRAIN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_START_SYNC_TRAIN_OFF] & HCI_SUPP_COMMANDS_START_SYNC_TRAIN)
+
+#define HCI_SUPP_COMMANDS_RECEIVE_SYNC_TRAIN 0x03
+#define HCI_SUPP_COMMANDS_RECEIVE_SYNC_TRAIN_OFF 31
+#define HCI_RECEIVE_SYNC_TRAIN_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_RECEIVE_SYNC_TRAIN_OFF] & HCI_SUPP_COMMANDS_RECEIVE_SYNC_TRAIN)
+
+#define HCI_SUPP_COMMANDS_SET_RESERVED_LT_ADDR 0x04
+#define HCI_SUPP_COMMANDS_SET_RESERVED_LT_ADDR_OFF 31
+#define HCI_SET_RESERVED_LT_ADDR_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_RESERVED_LT_ADDR_OFF] & HCI_SUPP_COMMANDS_SET_RESERVED_LT_ADDR)
+
+#define HCI_SUPP_COMMANDS_DELETE_RESERVED_LT_ADDR 0x05
+#define HCI_SUPP_COMMANDS_DELETE_RESERVED_LT_ADDR_OFF 31
+#define HCI_DELETE_RESERVED_LT_ADDR_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_DELETE_RESERVED_LT_ADDR_OFF] & HCI_SUPP_COMMANDS_DELETE_RESERVED_LT_ADDR)
+
+#define HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_DATA 0x06
+#define HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_DATA_OFF 31
+#define HCI_SET_CONLESS_SLAVE_BRCST_DATA_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_DATA_OFF] & HCI_SUPP_COMMANDS_SET_CONLESS_SLAVE_BRCST_DATA)
+
+#define HCI_SUPP_COMMANDS_READ_SYNC_TRAIN_PARAM 0x07
+#define HCI_SUPP_COMMANDS_READ_SYNC_TRAIN_PARAM_OFF 31
+#define HCI_READ_SYNC_TRAIN_PARAM_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_SYNC_TRAIN_PARAM_OFF] & HCI_SUPP_COMMANDS_READ_SYNC_TRAIN_PARAM)
+
+/* Supported Commands (Byte 32 bit 0) */
+#define HCI_SUPP_COMMANDS_WRITE_SYNC_TRAIN_PARAM 0x00
+#define HCI_SUPP_COMMANDS_WRITE_SYNC_TRAIN_PARAM_OFF 32
+#define HCI_WRITE_SYNC_TRAIN_PARAM_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_SYNC_TRAIN_PARAM_OFF] & HCI_SUPP_COMMANDS_WRITE_SYNC_TRAIN_PARAM)
+
+#define HCI_SUPP_COMMANDS_REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY_MASK 0x02
+#define HCI_SUPP_COMMANDS_REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY_OFF 32
+#define HCI_REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY_OFF] & HCI_SUPP_COMMANDS_REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_SECURE_CONNS_SUPPORT_MASK 0x04
+#define HCI_SUPP_COMMANDS_READ_SECURE_CONNS_SUPPORT_OFF 32
+#define HCI_READ_SECURE_CONNS_SUPPORT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_SECURE_CONNS_SUPPORT_OFF] & HCI_SUPP_COMMANDS_READ_SECURE_CONNS_SUPPORT_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_SECURE_CONNS_SUPPORT_MASK 0x08
+#define HCI_SUPP_COMMANDS_WRITE_SECURE_CONNS_SUPPORT_OFF 32
+#define HCI_WRITE_SECURE_CONNS_SUPPORT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_SECURE_CONNS_SUPPORT_OFF] & HCI_SUPP_COMMANDS_WRITE_SECURE_CONNS_SUPPORT_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_AUTHENT_PAYLOAD_TOUT_MASK 0x10
+#define HCI_SUPP_COMMANDS_READ_AUTHENT_PAYLOAD_TOUT_OFF 32
+#define HCI_READ_AUTHENT_PAYLOAD_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_AUTHENT_PAYLOAD_TOUT_OFF] & HCI_SUPP_COMMANDS_READ_AUTHENT_PAYLOAD_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_AUTHENT_PAYLOAD_TOUT_MASK 0x20
+#define HCI_SUPP_COMMANDS_WRITE_AUTHENT_PAYLOAD_TOUT_OFF 32
+#define HCI_WRITE_AUTHENT_PAYLOAD_TOUT_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_AUTHENT_PAYLOAD_TOUT_OFF] & HCI_SUPP_COMMANDS_WRITE_AUTHENT_PAYLOAD_TOUT_MASK)
+
+#define HCI_SUPP_COMMANDS_READ_LOCAL_OOB_EXTENDED_DATA_MASK 0x40
+#define HCI_SUPP_COMMANDS_READ_LOCAL_OOB_EXTENDED_DATA_OFF 32
+#define HCI_READ_LOCAL_OOB_EXTENDED_DATA_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_READ_LOCAL_OOB_EXTENDED_DATA_OFF] & HCI_SUPP_COMMANDS_READ_LOCAL_OOB_EXTENDED_DATA_MASK)
+
+#define HCI_SUPP_COMMANDS_WRITE_SECURE_CONNECTIONS_TEST_MODE_MASK 0x80
+#define HCI_SUPP_COMMANDS_WRITE_SECURE_CONNECTIONS_TEST_MODE_OFF 32
+#define HCI_WRITE_SECURE_CONNECTIONS_TEST_MODE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_WRITE_SECURE_CONNECTIONS_TEST_MODE_OFF] & HCI_SUPP_COMMANDS_WRITE_SECURE_CONNECTIONS_TEST_MODE_MASK)
+
+/* supported LE remote control connection parameter request reply */
+#define HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_RPY_MASK 0x10
+#define HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_RPY_OFF 33
+#define HCI_LE_RC_CONN_PARAM_UPD_RPY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_RPY_OFF] & HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_RPY_MASK)
+
+#define HCI_SUPP_COMMANDS_RLE_RC_CONN_PARAM_UPD_NEG_RPY_MASK 0x20
+#define HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_NEG_RPY_OFF 33
+#define HCI_LE_RC_CONN_PARAM_UPD_NEG_RPY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_NEG_RPY_OFF] & HCI_SUPP_COMMANDS_RLE_RC_CONN_PARAM_UPD_NEG_RPY_MASK)
+
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/hcimsgs.h b/lib/bt/host/bluedroid/stack/include/stack/hcimsgs.h
new file mode 100644
index 00000000..bd328fab
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/hcimsgs.h
@@ -0,0 +1,1065 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef HCIMSGS_H
+#define HCIMSGS_H
+
+#include <stddef.h>
+#include "common/bt_target.h"
+#include "stack/hcidefs.h"
+#include "stack/bt_types.h"
+#include "osi/pkt_queue.h"
+#include "osi/allocator.h"
+
+#define HCI_CMD_BUF_TYPE_METADATA (0xa56e)
+
+#define HCI_CMD_MSG_F_SRC_NOACK (0x01)
+
+typedef void (*hci_cmd_cmpl_cb)(BT_HDR *response, void *context);
+typedef void (*hci_cmd_stat_cb)(uint8_t status, BT_HDR *command, void *context);
+typedef void (*hci_cmd_free_cb)(pkt_linked_item_t *linked_pkt);
+
+typedef struct {
+ uint8_t flags_src;
+ uint8_t flags_vnd; // used for downstream layer
+ uint16_t opcode;
+ hci_cmd_cmpl_cb command_complete_cb;
+ hci_cmd_stat_cb command_status_cb;
+ void *context;
+ void *complete_future;
+ hci_cmd_free_cb command_free_cb;
+ BT_HDR command;
+} hci_cmd_metadata_t;
+
+#define HCI_CMD_METADATA_HDR_SIZE (sizeof(hci_cmd_metadata_t))
+
+#define HCI_CMD_LINKED_BUF_SIZE(paramlen) (BT_PKT_LINKED_HDR_SIZE + HCI_CMD_METADATA_HDR_SIZE + HCIC_PREAMBLE_SIZE + (paramlen))
+
+#define HCI_GET_CMD_METAMSG(cmd_ptr) (hci_cmd_metadata_t *)((void *)(cmd_ptr) - offsetof(hci_cmd_metadata_t, command))
+#define HCI_GET_CMD_LINKED_STRUCT(metadata_ptr) (pkt_linked_item_t *)((void *)(metadata_ptr) - offsetof(pkt_linked_item_t, data))
+
+static inline BT_HDR *hci_get_cmd_buf(size_t param_len)
+{
+ pkt_linked_item_t *linked_pkt = osi_calloc(HCI_CMD_LINKED_BUF_SIZE(param_len));
+ if (linked_pkt == NULL) {
+ return NULL;
+ }
+ hci_cmd_metadata_t *metadata = (hci_cmd_metadata_t *)linked_pkt->data;
+ BT_HDR *command = &metadata->command;
+
+ command->layer_specific = HCI_CMD_BUF_TYPE_METADATA;
+ command->len = HCIC_PREAMBLE_SIZE + param_len;
+ command->offset = 0;
+
+ return command;
+}
+
+static inline void hci_free_cmd_buf(BT_HDR *buf)
+{
+ assert(buf->layer_specific == HCI_CMD_BUF_TYPE_METADATA);
+ hci_cmd_metadata_t *metadata = HCI_GET_CMD_METAMSG(buf);
+ pkt_linked_item_t *linked_pkt = HCI_GET_CMD_LINKED_STRUCT(metadata);
+ osi_free(linked_pkt);
+}
+
+#define HCI_GET_CMD_BUF(param_len) hci_get_cmd_buf(param_len)
+#define HCI_FREE_CMD_BUF(buf) hci_free_cmd_buf(buf)
+
+void bte_main_hci_send(BT_HDR *p_msg, UINT16 event);
+void bte_main_lpm_allow_bt_device_sleep(void);
+
+/* Message by message.... */
+
+BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration,
+ UINT8 response_cnt);
+
+#define HCIC_PARAM_SIZE_INQUIRY 5
+
+
+#define HCIC_INQ_INQ_LAP_OFF 0
+#define HCIC_INQ_DUR_OFF 3
+#define HCIC_INQ_RSP_CNT_OFF 4
+/* Inquiry */
+
+/* Inquiry Cancel */
+BOOLEAN btsnd_hcic_inq_cancel(void);
+
+#define HCIC_PARAM_SIZE_INQ_CANCEL 0
+
+/* Periodic Inquiry Mode */
+BOOLEAN btsnd_hcic_per_inq_mode(UINT16 max_period, UINT16 min_period,
+ const LAP inq_lap, UINT8 duration,
+ UINT8 response_cnt);
+
+#define HCIC_PARAM_SIZE_PER_INQ_MODE 9
+
+#define HCI_PER_INQ_MAX_INTRVL_OFF 0
+#define HCI_PER_INQ_MIN_INTRVL_OFF 2
+#define HCI_PER_INQ_INQ_LAP_OFF 4
+#define HCI_PER_INQ_DURATION_OFF 7
+#define HCI_PER_INQ_RSP_CNT_OFF 8
+/* Periodic Inquiry Mode */
+
+/* Exit Periodic Inquiry Mode */
+BOOLEAN btsnd_hcic_exit_per_inq(void);
+
+#define HCIC_PARAM_SIZE_EXIT_PER_INQ 0
+/* Create Connection */
+BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types,
+ UINT8 page_scan_rep_mode,
+ UINT8 page_scan_mode,
+ UINT16 clock_offset,
+ UINT8 allow_switch);
+
+#define HCIC_PARAM_SIZE_CREATE_CONN 13
+
+#define HCIC_CR_CONN_BD_ADDR_OFF 0
+#define HCIC_CR_CONN_PKT_TYPES_OFF 6
+#define HCIC_CR_CONN_REP_MODE_OFF 8
+#define HCIC_CR_CONN_PAGE_SCAN_MODE_OFF 9
+#define HCIC_CR_CONN_CLK_OFF_OFF 10
+#define HCIC_CR_CONN_ALLOW_SWITCH_OFF 12
+/* Create Connection */
+
+/* Disconnect */
+BOOLEAN btsnd_hcic_disconnect(UINT16 handle, UINT8 reason);
+
+#define HCIC_PARAM_SIZE_DISCONNECT 3
+
+#define HCI_DISC_HANDLE_OFF 0
+#define HCI_DISC_REASON_OFF 2
+/* Disconnect */
+
+#if BTM_SCO_INCLUDED == TRUE
+/* Add SCO Connection */
+BOOLEAN btsnd_hcic_add_SCO_conn (UINT16 handle, UINT16 packet_types);
+#endif /* BTM_SCO_INCLUDED */
+
+#define HCIC_PARAM_SIZE_ADD_SCO_CONN 4
+
+#define HCI_ADD_SCO_HANDLE_OFF 0
+#define HCI_ADD_SCO_PACKET_TYPES_OFF 2
+/* Add SCO Connection */
+
+/* Create Connection Cancel */
+BOOLEAN btsnd_hcic_create_conn_cancel(BD_ADDR dest);
+
+#define HCIC_PARAM_SIZE_CREATE_CONN_CANCEL 6
+
+#define HCIC_CR_CONN_CANCEL_BD_ADDR_OFF 0
+/* Create Connection Cancel */
+
+/* Accept Connection Request */
+BOOLEAN btsnd_hcic_accept_conn (BD_ADDR bd_addr, UINT8 role);
+
+#define HCIC_PARAM_SIZE_ACCEPT_CONN 7
+
+#define HCI_ACC_CONN_BD_ADDR_OFF 0
+#define HCI_ACC_CONN_ROLE_OFF 6
+/* Accept Connection Request */
+
+/* Reject Connection Request */
+BOOLEAN btsnd_hcic_reject_conn (BD_ADDR bd_addr, UINT8 reason);
+
+#define HCIC_PARAM_SIZE_REJECT_CONN 7
+
+#define HCI_REJ_CONN_BD_ADDR_OFF 0
+#define HCI_REJ_CONN_REASON_OFF 6
+/* Reject Connection Request */
+
+/* Link Key Request Reply */
+BOOLEAN btsnd_hcic_link_key_req_reply (BD_ADDR bd_addr,
+ LINK_KEY link_key);
+
+#define HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY 22
+
+#define HCI_LINK_KEY_REPLY_BD_ADDR_OFF 0
+#define HCI_LINK_KEY_REPLY_LINK_KEY_OFF 6
+/* Link Key Request Reply */
+
+/* Link Key Request Neg Reply */
+BOOLEAN btsnd_hcic_link_key_neg_reply (BD_ADDR bd_addr);
+
+#define HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY 6
+
+#define HCI_LINK_KEY_NEG_REP_BD_ADR_OFF 0
+/* Link Key Request Neg Reply */
+
+/* PIN Code Request Reply */
+BOOLEAN btsnd_hcic_pin_code_req_reply (BD_ADDR bd_addr,
+ UINT8 pin_code_len,
+ PIN_CODE pin_code);
+
+#define HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY 23
+
+#define HCI_PIN_CODE_REPLY_BD_ADDR_OFF 0
+#define HCI_PIN_CODE_REPLY_PIN_LEN_OFF 6
+#define HCI_PIN_CODE_REPLY_PIN_CODE_OFF 7
+/* PIN Code Request Reply */
+
+/* Link Key Request Neg Reply */
+BOOLEAN btsnd_hcic_pin_code_neg_reply (BD_ADDR bd_addr);
+
+#define HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY 6
+
+#define HCI_PIN_CODE_NEG_REP_BD_ADR_OFF 0
+/* Link Key Request Neg Reply */
+
+/* Change Connection Type */
+BOOLEAN btsnd_hcic_change_conn_type (UINT16 handle, UINT16 packet_types);
+
+#define HCIC_PARAM_SIZE_CHANGE_CONN_TYPE 4
+
+#define HCI_CHNG_PKT_TYPE_HANDLE_OFF 0
+#define HCI_CHNG_PKT_TYPE_PKT_TYPE_OFF 2
+/* Change Connection Type */
+
+#define HCIC_PARAM_SIZE_CMD_HANDLE 2
+
+#define HCI_CMD_HANDLE_HANDLE_OFF 0
+
+BOOLEAN btsnd_hcic_auth_request (UINT16 handle); /* Authentication Request */
+
+/* Set Connection Encryption */
+BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enable);
+#define HCIC_PARAM_SIZE_SET_CONN_ENCRYPT 3
+
+
+#define HCI_SET_ENCRYPT_HANDLE_OFF 0
+#define HCI_SET_ENCRYPT_ENABLE_OFF 2
+/* Set Connection Encryption */
+
+/* Remote Name Request */
+BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr,
+ UINT8 page_scan_rep_mode,
+ UINT8 page_scan_mode,
+ UINT16 clock_offset);
+
+#define HCIC_PARAM_SIZE_RMT_NAME_REQ 10
+
+#define HCI_RMT_NAME_BD_ADDR_OFF 0
+#define HCI_RMT_NAME_REP_MODE_OFF 6
+#define HCI_RMT_NAME_PAGE_SCAN_MODE_OFF 7
+#define HCI_RMT_NAME_CLK_OFF_OFF 8
+/* Remote Name Request */
+
+/* Remote Name Request Cancel */
+BOOLEAN btsnd_hcic_rmt_name_req_cancel(BD_ADDR bd_addr);
+
+#define HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL 6
+
+#define HCI_RMT_NAME_CANCEL_BD_ADDR_OFF 0
+/* Remote Name Request Cancel */
+
+BOOLEAN btsnd_hcic_rmt_features_req(UINT16 handle); /* Remote Features Request */
+
+/* Remote Extended Features */
+BOOLEAN btsnd_hcic_rmt_ext_features(UINT16 handle, UINT8 page_num);
+
+#define HCIC_PARAM_SIZE_RMT_EXT_FEATURES 3
+
+#define HCI_RMT_EXT_FEATURES_HANDLE_OFF 0
+#define HCI_RMT_EXT_FEATURES_PAGE_NUM_OFF 2
+/* Remote Extended Features */
+
+
+BOOLEAN btsnd_hcic_rmt_ver_req(UINT16 handle); /* Remote Version Info Request */
+BOOLEAN btsnd_hcic_read_rmt_clk_offset(UINT16 handle); /* Remote Clock Offset */
+BOOLEAN btsnd_hcic_read_lmp_handle(UINT16 handle); /* Remote LMP Handle */
+
+BOOLEAN btsnd_hcic_setup_esco_conn (UINT16 handle,
+ UINT32 tx_bw, UINT32 rx_bw,
+ UINT16 max_latency, UINT16 voice,
+ UINT8 retrans_effort,
+ UINT16 packet_types);
+#define HCIC_PARAM_SIZE_SETUP_ESCO 17
+
+#define HCI_SETUP_ESCO_HANDLE_OFF 0
+#define HCI_SETUP_ESCO_TX_BW_OFF 2
+#define HCI_SETUP_ESCO_RX_BW_OFF 6
+#define HCI_SETUP_ESCO_MAX_LAT_OFF 10
+#define HCI_SETUP_ESCO_VOICE_OFF 12
+#define HCI_SETUP_ESCO_RETRAN_EFF_OFF 14
+#define HCI_SETUP_ESCO_PKT_TYPES_OFF 15
+
+
+BOOLEAN btsnd_hcic_accept_esco_conn (BD_ADDR bd_addr,
+ UINT32 tx_bw, UINT32 rx_bw,
+ UINT16 max_latency,
+ UINT16 content_fmt,
+ UINT8 retrans_effort,
+ UINT16 packet_types);
+#define HCIC_PARAM_SIZE_ACCEPT_ESCO 21
+
+#define HCI_ACCEPT_ESCO_BDADDR_OFF 0
+#define HCI_ACCEPT_ESCO_TX_BW_OFF 6
+#define HCI_ACCEPT_ESCO_RX_BW_OFF 10
+#define HCI_ACCEPT_ESCO_MAX_LAT_OFF 14
+#define HCI_ACCEPT_ESCO_VOICE_OFF 16
+#define HCI_ACCEPT_ESCO_RETRAN_EFF_OFF 18
+#define HCI_ACCEPT_ESCO_PKT_TYPES_OFF 19
+
+
+BOOLEAN btsnd_hcic_reject_esco_conn (BD_ADDR bd_addr, UINT8 reason);
+#define HCIC_PARAM_SIZE_REJECT_ESCO 7
+
+#define HCI_REJECT_ESCO_BDADDR_OFF 0
+#define HCI_REJECT_ESCO_REASON_OFF 6
+
+/* Hold Mode */
+BOOLEAN btsnd_hcic_hold_mode(UINT16 handle, UINT16 max_hold_period,
+ UINT16 min_hold_period);
+
+#define HCIC_PARAM_SIZE_HOLD_MODE 6
+
+#define HCI_HOLD_MODE_HANDLE_OFF 0
+#define HCI_HOLD_MODE_MAX_PER_OFF 2
+#define HCI_HOLD_MODE_MIN_PER_OFF 4
+/* Hold Mode */
+
+/**
+ * Sniff Mode
+ * sniff_attempt should no more than 0xFF
+ */
+BOOLEAN btsnd_hcic_sniff_mode(UINT16 handle,
+ UINT16 max_sniff_period,
+ UINT16 min_sniff_period,
+ UINT16 sniff_attempt,
+ UINT16 sniff_timeout);
+
+#define HCIC_PARAM_SIZE_SNIFF_MODE 10
+
+
+#define HCI_SNIFF_MODE_HANDLE_OFF 0
+#define HCI_SNIFF_MODE_MAX_PER_OFF 2
+#define HCI_SNIFF_MODE_MIN_PER_OFF 4
+#define HCI_SNIFF_MODE_ATTEMPT_OFF 6
+#define HCI_SNIFF_MODE_TIMEOUT_OFF 8
+/* Sniff Mode */
+
+BOOLEAN btsnd_hcic_exit_sniff_mode(UINT16 handle); /* Exit Sniff Mode */
+
+/* Park Mode */
+BOOLEAN btsnd_hcic_park_mode (UINT16 handle,
+ UINT16 beacon_max_interval,
+ UINT16 beacon_min_interval);
+
+#define HCIC_PARAM_SIZE_PARK_MODE 6
+
+#define HCI_PARK_MODE_HANDLE_OFF 0
+#define HCI_PARK_MODE_MAX_PER_OFF 2
+#define HCI_PARK_MODE_MIN_PER_OFF 4
+/* Park Mode */
+
+BOOLEAN btsnd_hcic_exit_park_mode(UINT16 handle); /* Exit Park Mode */
+
+/* QoS Setup */
+BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags,
+ UINT8 service_type,
+ UINT32 token_rate, UINT32 peak,
+ UINT32 latency, UINT32 delay_var);
+
+#define HCIC_PARAM_SIZE_QOS_SETUP 20
+
+#define HCI_QOS_HANDLE_OFF 0
+#define HCI_QOS_FLAGS_OFF 2
+#define HCI_QOS_SERVICE_TYPE_OFF 3
+#define HCI_QOS_TOKEN_RATE_OFF 4
+#define HCI_QOS_PEAK_BANDWIDTH_OFF 8
+#define HCI_QOS_LATENCY_OFF 12
+#define HCI_QOS_DELAY_VAR_OFF 16
+/* QoS Setup */
+
+/* Switch Role Request */
+BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role);
+
+#define HCIC_PARAM_SIZE_SWITCH_ROLE 7
+
+#define HCI_SWITCH_BD_ADDR_OFF 0
+#define HCI_SWITCH_ROLE_OFF 6
+/* Switch Role Request */
+
+/* Write Policy Settings */
+BOOLEAN btsnd_hcic_write_policy_set(UINT16 handle, UINT16 settings);
+
+#define HCIC_PARAM_SIZE_WRITE_POLICY_SET 4
+
+#define HCI_WRITE_POLICY_HANDLE_OFF 0
+#define HCI_WRITE_POLICY_SETTINGS_OFF 2
+/* Write Policy Settings */
+
+/* Write Default Policy Settings */
+BOOLEAN btsnd_hcic_write_def_policy_set(UINT16 settings);
+
+#define HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET 2
+
+#define HCI_WRITE_DEF_POLICY_SETTINGS_OFF 0
+/* Write Default Policy Settings */
+
+/******************************************
+** Lisbon Features
+*******************************************/
+#if BTM_SSR_INCLUDED == TRUE
+/* Sniff Subrating */
+BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat,
+ UINT16 min_remote_lat,
+ UINT16 min_local_lat);
+
+#define HCIC_PARAM_SIZE_SNIFF_SUB_RATE 8
+
+#define HCI_SNIFF_SUB_RATE_HANDLE_OFF 0
+#define HCI_SNIFF_SUB_RATE_MAX_LAT_OFF 2
+#define HCI_SNIFF_SUB_RATE_MIN_REM_LAT_OFF 4
+#define HCI_SNIFF_SUB_RATE_MIN_LOC_LAT_OFF 6
+/* Sniff Subrating */
+
+#else /* BTM_SSR_INCLUDED == FALSE */
+
+#define btsnd_hcic_sniff_sub_rate(handle, max_lat, min_remote_lat, min_local_lat) FALSE
+
+#endif /* BTM_SSR_INCLUDED */
+
+/* Extended Inquiry Response */
+void btsnd_hcic_write_ext_inquiry_response(BT_HDR *buffer, UINT8 fec_req);
+
+#define HCIC_PARAM_SIZE_EXT_INQ_RESP 241
+
+#define HCIC_EXT_INQ_RESP_FEC_OFF 0
+#define HCIC_EXT_INQ_RESP_RESPONSE 1
+/* IO Capabilities Response */
+BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability,
+ UINT8 oob_present, UINT8 auth_req);
+
+#define HCIC_PARAM_SIZE_IO_CAP_RESP 9
+
+#define HCI_IO_CAP_BD_ADDR_OFF 0
+#define HCI_IO_CAPABILITY_OFF 6
+#define HCI_IO_CAP_OOB_DATA_OFF 7
+#define HCI_IO_CAP_AUTH_REQ_OFF 8
+
+/* IO Capabilities Req Neg Reply */
+BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 err_code);
+
+#define HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY 7
+
+#define HCI_IO_CAP_NR_BD_ADDR_OFF 0
+#define HCI_IO_CAP_NR_ERR_CODE 6
+
+/* Read Local OOB Data */
+BOOLEAN btsnd_hcic_read_local_oob_data (void);
+
+#define HCIC_PARAM_SIZE_R_LOCAL_OOB 0
+
+
+BOOLEAN btsnd_hcic_user_conf_reply (BD_ADDR bd_addr, BOOLEAN is_yes);
+
+#define HCIC_PARAM_SIZE_UCONF_REPLY 6
+
+#define HCI_USER_CONF_BD_ADDR_OFF 0
+
+
+BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 value);
+
+#define HCIC_PARAM_SIZE_U_PKEY_REPLY 10
+
+#define HCI_USER_PASSKEY_BD_ADDR_OFF 0
+#define HCI_USER_PASSKEY_VALUE_OFF 6
+
+
+BOOLEAN btsnd_hcic_user_passkey_neg_reply (BD_ADDR bd_addr);
+
+#define HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY 6
+
+#define HCI_USER_PASSKEY_NEG_BD_ADDR_OFF 0
+
+/* Remote OOB Data Request Reply */
+BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c,
+ UINT8 *p_r);
+
+#define HCIC_PARAM_SIZE_REM_OOB_REPLY 38
+
+#define HCI_REM_OOB_DATA_BD_ADDR_OFF 0
+#define HCI_REM_OOB_DATA_C_OFF 6
+#define HCI_REM_OOB_DATA_R_OFF 22
+
+/* Remote OOB Data Request Negative Reply */
+BOOLEAN btsnd_hcic_rem_oob_neg_reply (BD_ADDR bd_addr);
+
+#define HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY 6
+
+#define HCI_REM_OOB_DATA_NEG_BD_ADDR_OFF 0
+
+/* Read Tx Power Level */
+BOOLEAN btsnd_hcic_read_inq_tx_power (void);
+
+#define HCIC_PARAM_SIZE_R_TX_POWER 0
+
+/* Read Default Erroneous Data Reporting */
+BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void);
+
+#define HCIC_PARAM_SIZE_R_ERR_DATA_RPT 0
+
+#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
+BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type);
+
+#define HCIC_PARAM_SIZE_ENHANCED_FLUSH 3
+#endif
+
+
+BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif);
+
+#define HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF 7
+
+#define HCI_SEND_KEYPRESS_NOTIF_BD_ADDR_OFF 0
+#define HCI_SEND_KEYPRESS_NOTIF_NOTIF_OFF 6
+
+/**** end of Simple Pairing Commands ****/
+
+/* Store Current Settings */
+#define MAX_FILT_COND (sizeof (BD_ADDR) + 1)
+
+BOOLEAN btsnd_hcic_set_event_filter(UINT8 filt_type,
+ UINT8 filt_cond_type,
+ UINT8 *filt_cond,
+ UINT8 filt_cond_len);
+
+#define HCIC_PARAM_SIZE_SET_EVT_FILTER 9
+
+#define HCI_FILT_COND_FILT_TYPE_OFF 0
+#define HCI_FILT_COND_COND_TYPE_OFF 1
+#define HCI_FILT_COND_FILT_OFF 2
+/* Set Event Filter */
+
+/* Delete Stored Key */
+BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN delete_all_flag);
+
+#define HCIC_PARAM_SIZE_DELETE_STORED_KEY 7
+
+#define HCI_DELETE_KEY_BD_ADDR_OFF 0
+#define HCI_DELETE_KEY_ALL_FLAG_OFF 6
+/* Delete Stored Key */
+
+/* Change Local Name */
+BOOLEAN btsnd_hcic_change_name (const UINT8 *name);
+
+#define HCIC_PARAM_SIZE_CHANGE_NAME BD_NAME_LEN
+
+#define HCI_CHANGE_NAME_NAME_OFF 0
+/* Change Local Name */
+
+
+#define HCIC_PARAM_SIZE_READ_CMD 0
+
+#define HCIC_PARAM_SIZE_WRITE_PARAM1 1
+
+#define HCIC_WRITE_PARAM1_PARAM_OFF 0
+
+#define HCIC_PARAM_SIZE_WRITE_PARAM2 2
+
+#define HCIC_WRITE_PARAM2_PARAM_OFF 0
+
+#define HCIC_PARAM_SIZE_WRITE_PARAM3 3
+
+#define HCIC_WRITE_PARAM3_PARAM_OFF 0
+
+/* set AFH channels */
+BOOLEAN btsnd_hcic_set_afh_channels (AFH_CHANNELS channels);
+#define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10
+BOOLEAN btsnd_hcic_ble_set_channels (BLE_CHANNELS channels);
+#define HCIC_PARAM_SIZE_BLE_SET_CHANNELS 5
+
+BOOLEAN btsnd_hcic_write_pin_type(UINT8 type); /* Write PIN Type */
+BOOLEAN btsnd_hcic_write_auto_accept(UINT8 flag); /* Write Auto Accept */
+BOOLEAN btsnd_hcic_read_name (void); /* Read Local Name */
+BOOLEAN btsnd_hcic_write_page_tout(UINT16 timeout); /* Write Page Timeout */
+BOOLEAN btsnd_hcic_write_scan_enable(UINT8 flag); /* Write Scan Enable */
+BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval,
+ UINT16 window); /* Write Page Scan Activity */
+
+#define HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG 4
+
+#define HCI_SCAN_CFG_INTERVAL_OFF 0
+#define HCI_SCAN_CFG_WINDOW_OFF 2
+/* Write Page Scan Activity */
+
+/* Write Inquiry Scan Activity */
+BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window);
+
+#define HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG 4
+
+#define HCI_SCAN_CFG_INTERVAL_OFF 0
+#define HCI_SCAN_CFG_WINDOW_OFF 2
+/* Write Inquiry Scan Activity */
+
+BOOLEAN btsnd_hcic_write_auth_enable(UINT8 flag); /* Write Authentication Enable */
+BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev); /* Write Class of Device */
+BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags); /* Write Voice Settings */
+
+/* Host Controller to Host flow control */
+#define HCI_HOST_FLOW_CTRL_OFF 0
+#define HCI_HOST_FLOW_CTRL_ACL_ON 1
+#define HCI_HOST_FLOW_CTRL_SCO_ON 2
+#define HCI_HOST_FLOW_CTRL_BOTH_ON 3
+
+#define HCI_HOST_FLOW_CTRL_ADV_REPORT_OFF 0
+#define HCI_HOST_FLOW_CTRL_ADV_REPORT_ON 1
+
+
+BOOLEAN btsnd_hcic_write_auto_flush_tout(UINT16 handle,
+ UINT16 timeout); /* Write Retransmit Timout */
+
+#define HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT 4
+
+#define HCI_FLUSH_TOUT_HANDLE_OFF 0
+#define HCI_FLUSH_TOUT_TOUT_OFF 2
+
+BOOLEAN btsnd_hcic_read_tx_power(UINT16 handle, UINT8 type); /* Read Tx Power */
+
+#define HCIC_PARAM_SIZE_READ_TX_POWER 3
+
+#define HCI_READ_TX_POWER_HANDLE_OFF 0
+#define HCI_READ_TX_POWER_TYPE_OFF 2
+
+/* Read transmit power level parameter */
+#define HCI_READ_CURRENT 0x00
+#define HCI_READ_MAXIMUM 0x01
+
+BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles,
+ UINT16 *handle,
+ UINT16 *num_pkts); /* Set Host Buffer Size */
+
+#define HCIC_PARAM_SIZE_NUM_PKTS_DONE_SIZE sizeof(btmsg_hcic_num_pkts_done_t)
+
+#define MAX_DATA_HANDLES 10
+
+#define HCI_PKTS_DONE_NUM_HANDLES_OFF 0
+#define HCI_PKTS_DONE_HANDLE_OFF 1
+#define HCI_PKTS_DONE_NUM_PKTS_OFF 3
+
+/* Write Link Supervision Timeout */
+BOOLEAN btsnd_hcic_write_link_super_tout(UINT8 local_controller_id, UINT16 handle, UINT16 timeout);
+
+#define HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT 4
+
+#define HCI_LINK_SUPER_TOUT_HANDLE_OFF 0
+#define HCI_LINK_SUPER_TOUT_TOUT_OFF 2
+/* Write Link Supervision Timeout */
+
+BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac,
+ LAP *const iac_lap); /* Write Current IAC LAP */
+
+#define MAX_IAC_LAPS 0x40
+
+#define HCI_WRITE_IAC_LAP_NUM_OFF 0
+#define HCI_WRITE_IAC_LAP_LAP_OFF 1
+/* Write Current IAC LAP */
+
+BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle); /* Get Link Quality */
+BOOLEAN btsnd_hcic_read_rssi (UINT16 handle); /* Read RSSI */
+BOOLEAN btsnd_hcic_enable_test_mode (void); /* Enable Device Under Test Mode */
+BOOLEAN btsnd_hcic_write_pagescan_type(UINT8 type); /* Write Page Scan Type */
+BOOLEAN btsnd_hcic_write_inqscan_type(UINT8 type); /* Write Inquiry Scan Type */
+BOOLEAN btsnd_hcic_write_inquiry_mode(UINT8 type); /* Write Inquiry Mode */
+
+#define HCI_DATA_HANDLE_MASK 0x0FFF
+
+#define HCID_GET_HANDLE_EVENT(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset) + \
+ (*((UINT8 *)((p) + 1) + p->offset + 1) << 8)))
+
+#define HCID_GET_HANDLE(u16) (UINT16)((u16) & HCI_DATA_HANDLE_MASK)
+
+#define HCI_DATA_EVENT_MASK 3
+#define HCI_DATA_EVENT_OFFSET 12
+#define HCID_GET_EVENT(u16) (UINT8)(((u16) >> HCI_DATA_EVENT_OFFSET) & HCI_DATA_EVENT_MASK)
+
+#define HCI_DATA_BCAST_MASK 3
+#define HCI_DATA_BCAST_OFFSET 10
+#define HCID_GET_BCAST(u16) (UINT8)(((u16) >> HCI_DATA_BCAST_OFFSET) & HCI_DATA_BCAST_MASK)
+
+#define HCID_GET_ACL_LEN(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset + 2) + \
+ (*((UINT8 *)((p) + 1) + p->offset + 3) << 8)))
+
+#define HCID_HEADER_SIZE 4
+
+#define HCID_GET_SCO_LEN(p) (*((UINT8 *)((p) + 1) + p->offset + 2))
+
+void btsnd_hcic_vendor_spec_cmd (BT_HDR *buffer, UINT16 opcode,
+ UINT8 len, UINT8 *p_data,
+ void *p_cmd_cplt_cback);
+
+#if (BLE_INCLUDED == TRUE)
+/********************************************************************************
+** BLE Commands
+** Note: "local_controller_id" is for transport, not counted in HCI message size
+*********************************************************************************/
+#define HCIC_BLE_RAND_DI_SIZE 8
+#define HCIC_BLE_ENCRYT_KEY_SIZE 16
+#define HCIC_BLE_IRK_SIZE 16
+
+#define HCIC_PARAM_SIZE_SET_USED_FEAT_CMD 8
+#define HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD 6
+#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS 15
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#define HCIC_PARAM_SIZE_BLE_WRITE_EXT_ADV_PARAMS 25
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP 31
+#define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE 1
+#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM 7
+#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE 2
+#define HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN 25
+#define HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL 0
+#define HCIC_PARAM_SIZE_CLEAR_WHITE_LIST 0
+#define HCIC_PARAM_SIZE_ADD_WHITE_LIST 7
+#define HCIC_PARAM_SIZE_REMOVE_WHITE_LIST 7
+#define HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS 14
+#define HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS 5
+#define HCIC_PARAM_SIZE_READ_CHNL_MAP 2
+#define HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT 2
+#define HCIC_PARAM_SIZE_BLE_ENCRYPT 32
+#define HCIC_PARAM_SIZE_BLE_RAND 0
+#define HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED 2
+
+#define HCIC_BLE_RAND_DI_SIZE 8
+#define HCIC_BLE_ENCRYT_KEY_SIZE 16
+#define HCIC_PARAM_SIZE_BLE_START_ENC (4 + HCIC_BLE_RAND_DI_SIZE + HCIC_BLE_ENCRYT_KEY_SIZE)
+#define HCIC_PARAM_SIZE_LTK_REQ_REPLY (2 + HCIC_BLE_ENCRYT_KEY_SIZE)
+#define HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY 2
+#define HCIC_BLE_CHNL_MAP_SIZE 5
+#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA 31
+
+#define HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST (7 + HCIC_BLE_IRK_SIZE * 2)
+#define HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST 7
+#define HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST 0
+#define HCIC_PARAM_SIZE_BLE_READ_RESOLVING_LIST_SIZE 0
+#define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER 7
+#define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL 7
+#define HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE 1
+#define HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT 2
+#define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6
+#define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11
+#define HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL 2
+#define HCIC_PARAM_SIZE_BLE_CLEAR_ADV 0
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+#define HCIC_PARAM_SIZE_BLE_READ_PHY 2
+#define HCIC_PARAM_SIZE_BLE_SET_DEF_PHY 3
+#define HCIC_PARAM_SIZE_BLE_SET_PHY 7
+#define HCIC_PARAM_SIZE_ENH_RX_TEST 3
+#define HCIC_PARAM_SIZE_ENH_TX_TEST 4
+#define HCIC_PARAM_SIZE_EXT_RAND_ADDR 7
+#define HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS 25
+#define HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA 251
+#define HCIC_PARAM_SIZE_READ_MAX_ADV_SIZE 0
+#define HCIC_PARAM_SIZE_NUM_SUPPORT_ADV_SET 0
+#define HCIC_PARAM_SIZE_REMOVE_ADV_SET 1
+#define HCIC_PARAM_SIZE_CLEAR_ADV_SET 0
+#define HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS 7
+#define HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA 252
+#define HCIC_PARAM_SIZE_PERIODIC_ADV_ENABLE 2
+#define HCIC_PARAM_SIZE_SET_EXT_SCAN_PARAMS 3
+#define HCIC_PARAM_SIZE_EXT_SCAN_ENABLE 6
+#define HCIC_PARAM_SIZE_EXT_CONN_CREATE_BASE 10
+#define HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC 12
+#define HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC_CANCEL 0
+#define HCIC_PARAM_SIZE_PERIODIC_ADV_TERM_SYNC 2
+#define HCIC_PARAM_SIZE_ADD_DEV_TO_PERIODIC_ADV_LIST 8
+#define HCIC_PARAM_SIZE_RM_DEV_FROM_PERIODIC_ADV_LIST 8
+#define HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADV_LIST 0
+#define HCIC_PARAM_SIZE_READ_PERIODIC_ADV_LIST 0
+#define HCIC_PARAM_SIZE_READ_TRANS_POWER 0
+#define HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION 0
+#define HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION 4
+
+BlE_SYNC *btsnd_hcic_ble_get_sync_info(void);
+void btsnd_hcic_ble_sync_sem_init(void);
+void btsnd_hcic_ble_sync_sem_deinit(void);
+
+uint8_t btsnd_hcic_ble_get_status(void);
+
+void btsnd_hci_ble_set_status(UINT8 hci_status);
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+
+/* ULP HCI command */
+BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask);
+
+BOOLEAN btsnd_hcic_ble_read_buffer_size (void);
+
+BOOLEAN btsnd_hcic_ble_read_local_spt_feat (void);
+
+BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]);
+
+BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_addr);
+
+BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
+ UINT8 adv_type, UINT8 addr_type_own,
+ UINT8 addr_type_dir, BD_ADDR direct_bda,
+ UINT8 channel_map, UINT8 adv_filter_policy);
+
+BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void);
+
+BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data);
+
+BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp);
+
+BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable);
+
+BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
+ UINT16 scan_int, UINT16 scan_win,
+ UINT8 addr_type, UINT8 scan_filter_policy);
+
+BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate);
+
+BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win,
+ UINT8 init_filter_policy, UINT8 addr_type_peer, BD_ADDR bda_peer, UINT8 addr_type_own,
+ UINT16 conn_int_min, UINT16 conn_int_max, UINT16 conn_latency, UINT16 conn_timeout,
+ UINT16 min_ce_len, UINT16 max_ce_len);
+
+BOOLEAN btsnd_hcic_ble_create_conn_cancel (void);
+
+BOOLEAN btsnd_hcic_ble_read_white_list_size (void);
+
+BOOLEAN btsnd_hcic_ble_clear_white_list (void);
+
+BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda);
+
+BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda);
+
+BOOLEAN btsnd_hcic_ble_upd_ll_conn_params (UINT16 handle, UINT16 conn_int_min, UINT16 conn_int_max,
+ UINT16 conn_latency, UINT16 conn_timeout, UINT16 min_len, UINT16 max_len);
+
+BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE]);
+
+BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle);
+
+BOOLEAN btsnd_hcic_ble_read_remote_feat ( UINT16 handle);
+
+BOOLEAN btsnd_hcic_ble_encrypt (UINT8 *key, UINT8 key_len, UINT8 *plain_text, UINT8 pt_len, void *p_cmd_cplt_cback);
+
+BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback);
+
+BOOLEAN btsnd_hcic_ble_start_enc ( UINT16 handle,
+ UINT8 rand[HCIC_BLE_RAND_DI_SIZE],
+ UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
+
+BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
+
+BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle);
+
+BOOLEAN btsnd_hcic_ble_read_supported_states (void);
+
+BOOLEAN btsnd_hcic_ble_write_host_supported (UINT8 le_host_spt, UINT8 simul_le_host_spt);
+
+BOOLEAN btsnd_hcic_ble_read_host_supported (void);
+
+BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq);
+
+BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len,
+ UINT8 payload);
+BOOLEAN btsnd_hcic_ble_test_end(void);
+
+#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
+
+#define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY 14
+BOOLEAN btsnd_hcic_ble_rc_param_req_reply(UINT16 handle,
+ UINT16 conn_int_min, UINT16 conn_int_max,
+ UINT16 conn_latency, UINT16 conn_timeout,
+ UINT16 min_ce_len, UINT16 max_ce_len);
+
+#define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY 3
+BOOLEAN btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle, UINT8 reason);
+
+#endif /* BLE_LLT_INCLUDED */
+
+BOOLEAN btsnd_hcic_ble_set_data_length(UINT16 conn_handle, UINT16 tx_octets,
+ UINT16 tx_time);
+
+BOOLEAN btsnd_hcic_ble_add_device_resolving_list (UINT8 addr_type_peer,
+ BD_ADDR bda_peer,
+ UINT8 irk_peer[HCIC_BLE_IRK_SIZE],
+ UINT8 irk_local[HCIC_BLE_IRK_SIZE]);
+
+BOOLEAN btsnd_hcic_ble_rm_device_resolving_list (UINT8 addr_type_peer,
+ BD_ADDR bda_peer);
+
+BOOLEAN btsnd_hcic_ble_clear_resolving_list (void);
+
+BOOLEAN btsnd_hcic_ble_read_resolvable_addr_peer (UINT8 addr_type_peer,
+ BD_ADDR bda_peer);
+
+BOOLEAN btsnd_hcic_ble_read_resolvable_addr_local (UINT8 addr_type_peer,
+ BD_ADDR bda_peer);
+
+BOOLEAN btsnd_hcic_ble_set_addr_resolution_enable (UINT8 addr_resolution_enable);
+
+BOOLEAN btsnd_hcic_ble_set_rand_priv_addr_timeout (UINT16 rpa_timout);
+
+BOOLEAN btsnd_hcic_ble_clear_adv(void);
+
+#endif /* BLE_INCLUDED */
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+typedef struct {
+ UINT8 scan_type;
+ UINT16 scan_interval;
+ UINT16 scan_window;
+} tHCI_EXT_SCAN_PARAMS;
+
+typedef struct {
+ UINT16 scan_interval;
+ UINT16 scan_window;
+ UINT16 conn_interval_min;
+ UINT16 conn_interval_max;
+ UINT16 conn_latency;
+ UINT16 sup_timeout;
+ UINT16 min_ce_len;
+ UINT16 max_ce_len;
+} tHCI_ExtConnParams;
+
+typedef struct {
+ UINT8 filter_policy;
+ UINT8 own_addr_type;
+ UINT8 peer_addr_type;
+ BD_ADDR peer_addr;
+ UINT8 init_phy_mask;
+ tHCI_ExtConnParams params[3];
+} tHCI_CreatExtConn;
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+BOOLEAN btsnd_hcic_read_authenticated_payload_tout(UINT16 handle);
+
+BOOLEAN btsnd_hcic_write_authenticated_payload_tout(UINT16 handle,
+ UINT16 timeout);
+
+BOOLEAN btsnd_hcic_ble_update_adv_report_flow_control (UINT16 num, BT_HDR *static_buf);
+#if (BLE_50_FEATURE_SUPPORT == TRUE)
+BOOLEAN btsnd_hcic_ble_read_phy(UINT16 conn_handle);
+
+UINT8 btsnd_hcic_ble_set_prefered_default_phy(UINT8 all_phys,
+ UINT8 tx_phys,
+ UINT8 rx_phys);
+BOOLEAN btsnd_hcic_ble_set_phy(UINT16 conn_handle,
+ UINT8 all_phys, UINT8 tx_phys,
+ UINT8 rx_phys, UINT16 phy_options);
+
+UINT8 btsnd_hcic_ble_enhand_rx_test(UINT8 rx_channel, UINT8 phy,
+ UINT8 modulation_idx);
+
+UINT8 btsnd_hcic_ble_enhand_tx_test(UINT8 tx_channel, UINT8 len,
+ UINT8 packect,
+ UINT8 phy);
+
+UINT8 btsnd_hcic_ble_set_extend_rand_address(UINT8 adv_handle, BD_ADDR rand_addr);
+
+UINT8 btsnd_hcic_ble_set_ext_adv_params(UINT8 adv_handle, UINT16 properties, UINT32 interval_min,
+ UINT32 interval_max, UINT8 channel_map, UINT8 own_addr_type,
+ UINT8 peer_addr_type, BD_ADDR peer_addr,
+ UINT8 adv_filter_policy, INT8 adv_tx_power,
+ UINT8 primary_adv_phy, UINT8 secondary_adv_max_skip,
+ UINT8 secondary_adv_phy,
+ UINT8 adv_sid, UINT8 scan_req_ntf_enable);
+
+UINT8 btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle,
+ UINT8 operation, UINT8 fragment_prefrence,
+ UINT8 data_len, UINT8 *p_data);
+
+UINT8 btsnd_hcic_ble_set_ext_adv_scan_rsp_data(UINT8 adv_handle,
+ UINT8 operation, UINT8 fragment_prefrence,
+ UINT8 data_len, UINT8 *p_data);
+
+UINT8 btsnd_hcic_ble_ext_adv_enable(UINT8 enable, UINT8 num_of_sets, UINT8 *adv_handle,
+ UINT16 *duration, UINT8 *max_adv_evt);
+
+UINT8 btsnd_hcic_ble_read_max_adv_len(void);
+
+UINT8 btsnd_hcic_ble_read_num_support_adv_set(void);
+
+UINT8 btsnd_hcic_ble_remove_adv_set(UINT8 adv_handle);
+
+UINT8 btsnd_hcic_ble_clear_adv_set(void);
+
+UINT8 btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle,
+ UINT16 interval_min,
+ UINT16 interval_max,
+ UINT8 propertics);
+
+UINT8 btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle,
+ UINT8 operation,
+ UINT8 len,
+ UINT8 *p_data);
+
+UINT8 btsnd_hcic_ble_periodic_adv_enable(UINT8 enable, UINT8 adv_handle);
+
+UINT8 btsnd_hcic_ble_set_ext_scan_params(UINT8 own_addr_type, UINT8 filter_policy,
+ UINT8 phy_mask, UINT8 phy_count,
+ tHCI_EXT_SCAN_PARAMS *params);
+
+UINT8 btsnd_hcic_ble_ext_scan_enable(UINT8 enable, UINT8 filter_dups,
+ UINT16 duration, UINT16 period);
+
+
+BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn);
+
+BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 filter_policy, UINT8 adv_sid,
+ UINT8 adv_addr_type, BD_ADDR adv_addr,
+ UINT16 sync_timeout, UINT8 unused);
+
+UINT8 btsnd_hcic_ble_periodic_adv_create_sync_cancel(void);
+
+
+UINT8 btsnd_hcic_ble_periodic_adv_term_sync(UINT16 sync_handle);
+
+UINT8 btsnd_hcic_ble_add_dev_to_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR adv_addr,
+ UINT8 adv_sid);
+UINT8 btsnd_hcic_ble_rm_dev_from_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR adv_addr,
+ UINT8 adv_sid);
+
+UINT8 btsnd_hcic_ble_clear_periodic_adv_list(void);
+
+UINT8 btsnd_hcic_ble_read_periodic_adv_list_size(void);
+
+UINT8 btsnd_hcic_ble_read_trans_power(void);
+
+UINT8 btsnd_hcic_ble_read_rf_path_compensation(void);
+
+UINT8 btsnd_hcic_ble_write_rf_path_compensation(UINT16 rf_tx_path, UINT16 rf_rx_path);
+
+#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
+
+#define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4
+
+#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0
+#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_TOUT_OFF 2
+
+#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+#define HCIC_PARAM_SIZE_PERIODIC_ADV_RECV_ENABLE 3
+#define HCI_PERIODIC_ADV_RECV_REPORT_EN 1
+#define HCI_PERIODIC_ADV_RECV_DUP_FILTER_EN 2
+#define HCIC_PARAM_SIZE_PERIODIC_ADV_SYNC_TRANS 6
+#define HCIC_PARAM_SIZE_PERIODIC_ADV_SET_INFO_TRANS 5
+#define HCIC_PARAM_SIZE_SET_PAST_PARAMS 8
+#define HCIC_PARAM_SIZE_SET_DEFAULT_PAST_PARAMS 6
+
+UINT8 btsnd_hcic_ble_set_periodic_adv_recv_enable(UINT16 sync_handle, UINT8 enable);
+
+BOOLEAN btsnd_hcic_ble_periodic_adv_sync_trans(UINT16 conn_handle, UINT16 service_data, UINT16 sync_handle);
+
+BOOLEAN btsnd_hcic_ble_periodic_adv_set_info_trans(UINT16 conn_handle, UINT16 service_data, UINT8 adv_handle);
+
+BOOLEAN btsnd_hcic_ble_set_periodic_adv_sync_trans_params(UINT16 conn_handle, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type);
+
+UINT8 btsnd_hcic_ble_set_default_periodic_adv_sync_trans_params(UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type);
+#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
+
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/hidd_api.h b/lib/bt/host/bluedroid/stack/include/stack/hidd_api.h
new file mode 100644
index 00000000..3e99db9d
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/hidd_api.h
@@ -0,0 +1,273 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2002-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+#ifndef HIDD_API_H
+#define HIDD_API_H
+#include "hiddefs.h"
+#include "sdp_api.h"
+
+#if (HID_DEV_INCLUDED == TRUE)
+/*****************************************************************************
+ * Type Definitions
+ ****************************************************************************/
+enum {
+ HID_CHANNEL_INTR,
+ HID_CHANNEL_CTRL
+};
+/*
+ HID_DHOST_EVT_OPEN - connected to host device (CTRL and INTR), data = n/a
+ HID_DHOST_EVT_CLOSE - disconnected from host device, data=reason
+ HID_DHOST_EVT_GET_REPORT - got GET_REPORT from host
+ HID_DHOST_EVT_SET_REPORT - got SET_REPORT from host
+ HID_DHOST_EVT_SET_PROTOCOL - got SET_PROTOCOL from host
+*/
+
+enum {
+ HID_DHOST_EVT_OPEN,
+ HID_DHOST_EVT_CLOSE,
+ HID_DHOST_EVT_GET_REPORT,
+ HID_DHOST_EVT_SET_REPORT,
+ HID_DHOST_EVT_SET_PROTOCOL,
+ HID_DHOST_EVT_INTR_DATA,
+ HID_DHOST_EVT_VC_UNPLUG,
+ HID_DHOST_EVT_SUSPEND,
+ HID_DHOST_EVT_EXIT_SUSPEND,
+};
+
+typedef void (tHID_DEV_HOST_CALLBACK)(BD_ADDR bd_addr, uint8_t event, uint32_t data, BT_HDR* p_buf);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*****************************************************************************
+ * External Function Declarations
+ ****************************************************************************/
+
+/*******************************************************************************
+ *
+ * Function HID_DevInit
+ *
+ * Description Initializes control block
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevInit(void);
+
+/*******************************************************************************
+ *
+ * Function HID_DevInit
+ *
+ * Description Deinitializes control block
+ *
+ * Returns void
+ *
+ ******************************************************************************/
+extern void HID_DevDeinit(void);
+
+/*******************************************************************************
+ *
+ * Function HID_DevRegister
+ *
+ * Description Registers HID device with lower layers
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevRegister(tHID_DEV_HOST_CALLBACK* host_cback);
+
+/*******************************************************************************
+ *
+ * Function HID_DevDeregister
+ *
+ * Description Deregisters HID device with lower layers
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevDeregister(void);
+
+/*******************************************************************************
+ *
+ * Function HID_DevSetSecurityLevel
+ *
+ * Description Sets security level for HID device connections
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevSetSecurityLevel(uint8_t sec_lvl);
+
+/*******************************************************************************
+ *
+ * Function HID_DevAddRecord
+ *
+ * Description Creates SDP record for HID device
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name,
+ char* p_description, char* p_provider,
+ uint16_t subclass, uint16_t desc_len,
+ uint8_t* p_desc_data);
+
+/*******************************************************************************
+ *
+ * Function HID_DevSendReport
+ *
+ * Description Sends report
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevSendReport(uint8_t channel, uint8_t type, uint8_t id,
+ uint16_t len, uint8_t* p_data);
+
+/*******************************************************************************
+ *
+ * Function HID_DevVirtualCableUnplug
+ *
+ * Description Sends Virtual Cable Unplug
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevVirtualCableUnplug(void);
+
+/*******************************************************************************
+ *
+ * Function HID_DevPlugDevice
+ *
+ * Description Establishes virtual cable to given host
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevPlugDevice(BD_ADDR addr);
+
+/*******************************************************************************
+ *
+ * Function HID_DevUnplugDevice
+ *
+ * Description Unplugs virtual cable from given host
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevUnplugDevice(BD_ADDR addr);
+
+/*******************************************************************************
+ *
+ * Function HID_DevConnect
+ *
+ * Description Connects to device
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevConnect(void);
+
+/*******************************************************************************
+ *
+ * Function HID_DevDisconnect
+ *
+ * Description Disconnects from device
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevDisconnect(void);
+
+/*******************************************************************************
+ *
+ * Function HID_DevSetIncomingPolicy
+ *
+ * Description Sets policy for incoming connections (allowed/disallowed)
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevSetIncomingPolicy(bool allow);
+
+/*******************************************************************************
+ *
+ * Function HID_DevReportError
+ *
+ * Description Reports error for Set Report via HANDSHAKE
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevReportError(uint8_t error);
+
+/*******************************************************************************
+ *
+ * Function HID_DevGetDevice
+ *
+ * Description Returns the BD Address of virtually cabled device
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevGetDevice(BD_ADDR* addr);
+
+/*******************************************************************************
+ *
+ * Function HID_DevSetIncomingQos
+ *
+ * Description Sets Incoming QoS values for Interrupt L2CAP Channel
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevSetIncomingQos(
+ uint8_t service_type, uint32_t token_rate, uint32_t token_bucket_size,
+ uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation);
+
+/*******************************************************************************
+ *
+ * Function HID_DevSetOutgoingQos
+ *
+ * Description Sets Outgoing QoS values for Interrupt L2CAP Channel
+ *
+ * Returns tHID_STATUS
+ *
+ ******************************************************************************/
+extern tHID_STATUS HID_DevSetOutgoingQos(
+ uint8_t service_type, uint32_t token_rate, uint32_t token_bucket_size,
+ uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation);
+
+/*******************************************************************************
+ *
+ * Function HID_DevSetTraceLevel
+ *
+ * Description This function sets the trace level for HID Dev. If called
+ * with a value of 0xFF, it simply reads the current trace level.
+ *
+ * Returns the new (current) trace level
+ *
+ ******************************************************************************/
+extern uint8_t HID_DevSetTraceLevel(uint8_t new_level);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+#endif /* HIDD_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/hiddefs.h b/lib/bt/host/bluedroid/stack/include/stack/hiddefs.h
new file mode 100644
index 00000000..71dd73e0
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/hiddefs.h
@@ -0,0 +1,163 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2002-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains HID protocol definitions
+ *
+ ******************************************************************************/
+
+#ifndef HIDDEFS_H
+#define HIDDEFS_H
+#include "common/bt_target.h"
+
+#if (HID_HOST_INCLUDED == TRUE || HID_DEV_INCLUDED == TRUE)
+
+#if (SDP_INCLUDED == TRUE)
+#include "stack/sdp_api.h"
+#endif ///SDP_INCLUDED == TRUE
+/*
+** tHID_STATUS: HID result codes, returned by HID and device and host functions.
+*/
+enum {
+ HID_SUCCESS,
+ HID_ERR_NOT_REGISTERED,
+ HID_ERR_ALREADY_REGISTERED,
+ HID_ERR_NO_RESOURCES,
+ HID_ERR_NO_CONNECTION,
+ HID_ERR_INVALID_PARAM,
+ HID_ERR_UNSUPPORTED,
+ HID_ERR_UNKNOWN_COMMAND,
+ HID_ERR_CONGESTED,
+ HID_ERR_CONN_IN_PROCESS,
+ HID_ERR_ALREADY_CONN,
+ HID_ERR_DISCONNECTING,
+ HID_ERR_SET_CONNABLE_FAIL,
+ /* Device specific error codes */
+ HID_ERR_HOST_UNKNOWN,
+ HID_ERR_L2CAP_FAILED,
+ HID_ERR_AUTH_FAILED,
+ HID_ERR_SDP_BUSY,
+ HID_ERR_GATT,
+
+ HID_ERR_INVALID = 0xFF
+};
+
+typedef UINT8 tHID_STATUS;
+
+#define HID_L2CAP_CONN_FAIL (0x0100) /* Connection Attempt was made but failed */
+#define HID_L2CAP_REQ_FAIL (0x0200) /* L2CAP_ConnectReq API failed */
+#define HID_L2CAP_CFG_FAIL (0x0400) /* L2CAP Configuration was rejected by peer */
+
+
+
+/* Define the HID transaction types
+*/
+#define HID_TRANS_HANDSHAKE (0)
+#define HID_TRANS_CONTROL (1)
+#define HID_TRANS_GET_REPORT (4)
+#define HID_TRANS_SET_REPORT (5)
+#define HID_TRANS_GET_PROTOCOL (6)
+#define HID_TRANS_SET_PROTOCOL (7)
+#define HID_TRANS_GET_IDLE (8)
+#define HID_TRANS_SET_IDLE (9)
+#define HID_TRANS_DATA (10)
+#define HID_TRANS_DATAC (11)
+
+#define HID_GET_TRANS_FROM_HDR(x) ((x >> 4) & 0x0f)
+#define HID_GET_PARAM_FROM_HDR(x) (x & 0x0f)
+#define HID_BUILD_HDR(t,p) (UINT8)((t << 4) | (p & 0x0f))
+
+
+/* Parameters for Handshake
+*/
+#define HID_PAR_HANDSHAKE_RSP_SUCCESS (0)
+#define HID_PAR_HANDSHAKE_RSP_NOT_READY (1)
+#define HID_PAR_HANDSHAKE_RSP_ERR_INVALID_REP_ID (2)
+#define HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ (3)
+#define HID_PAR_HANDSHAKE_RSP_ERR_INVALID_PARAM (4)
+#define HID_PAR_HANDSHAKE_RSP_ERR_UNKNOWN (14)
+#define HID_PAR_HANDSHAKE_RSP_ERR_FATAL (15)
+
+
+/* Parameters for Control
+*/
+#define HID_PAR_CONTROL_NOP (0)
+#define HID_PAR_CONTROL_HARD_RESET (1)
+#define HID_PAR_CONTROL_SOFT_RESET (2)
+#define HID_PAR_CONTROL_SUSPEND (3)
+#define HID_PAR_CONTROL_EXIT_SUSPEND (4)
+#define HID_PAR_CONTROL_VIRTUAL_CABLE_UNPLUG (5)
+
+
+/* Different report types in get, set, data
+*/
+#define HID_PAR_REP_TYPE_MASK (0x03)
+#define HID_PAR_REP_TYPE_OTHER (0x00)
+#define HID_PAR_REP_TYPE_INPUT (0x01)
+#define HID_PAR_REP_TYPE_OUTPUT (0x02)
+#define HID_PAR_REP_TYPE_FEATURE (0x03)
+
+/* Parameters for Get Report
+*/
+
+/* Buffer size in two bytes after Report ID */
+#define HID_PAR_GET_REP_BUFSIZE_FOLLOWS (0x08)
+
+
+/* Parameters for Protocol Type
+*/
+#define HID_PAR_PROTOCOL_MASK (0x01)
+#define HID_PAR_PROTOCOL_REPORT (0x01)
+#define HID_PAR_PROTOCOL_BOOT_MODE (0x00)
+
+#define HID_PAR_REP_TYPE_MASK (0x03)
+
+/* Descriptor types in the SDP record
+*/
+#define HID_SDP_DESCRIPTOR_REPORT (0x22)
+#define HID_SDP_DESCRIPTOR_PHYSICAL (0x23)
+
+typedef struct desc_info {
+ UINT16 dl_len;
+ UINT8 *dsc_list;
+} tHID_DEV_DSCP_INFO;
+
+#define HID_SSR_PARAM_INVALID 0xffff
+
+typedef struct sdp_info {
+ char svc_name[HID_MAX_SVC_NAME_LEN]; /*Service Name */
+ char svc_descr[HID_MAX_SVC_DESCR_LEN]; /*Service Description*/
+ char prov_name[HID_MAX_PROV_NAME_LEN]; /*Provider Name.*/
+ UINT16 rel_num; /*Release Number */
+ UINT16 hpars_ver; /*HID Parser Version.*/
+ UINT16 ssr_max_latency; /* HIDSSRHostMaxLatency value, if HID_SSR_PARAM_INVALID not used*/
+ UINT16 ssr_min_tout; /* HIDSSRHostMinTimeout value, if HID_SSR_PARAM_INVALID not used* */
+ UINT8 sub_class; /*Device Subclass.*/
+ UINT8 ctry_code; /*Country Code.*/
+ UINT16 sup_timeout;/* Supervisory Timeout */
+
+ tHID_DEV_DSCP_INFO dscp_info; /* Descriptor list and Report list to be set in the SDP record.
+ This parameter is used if HID_DEV_USE_GLB_SDP_REC is set to FALSE.*/
+#if(SDP_INCLUDED == TRUE)
+ tSDP_DISC_REC *p_sdp_layer_rec;
+#endif ///SDP_INCLUDED == TRUE
+} tHID_DEV_SDP_INFO;
+
+#endif ///HID_HOST_INCLUDED == TRUE
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/hidh_api.h b/lib/bt/host/bluedroid/stack/include/stack/hidh_api.h
new file mode 100644
index 00000000..2ddaf1c5
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/hidh_api.h
@@ -0,0 +1,258 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2002-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+#ifndef HIDH_API_H
+#define HIDH_API_H
+
+#include "stack/hiddefs.h"
+#include "stack/sdp_api.h"
+
+#if (HID_HOST_INCLUDED == TRUE)
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+enum {
+ HID_SDP_NO_SERV_UUID = (SDP_ILLEGAL_PARAMETER + 1),
+ HID_SDP_MANDATORY_MISSING
+};
+
+/* Attributes mask values to be used in HID_HostAddDev API */
+#define HID_VIRTUAL_CABLE 0x0001
+#define HID_NORMALLY_CONNECTABLE 0x0002
+#define HID_RECONN_INIT 0x0004
+#define HID_SDP_DISABLE 0x0008
+#define HID_BATTERY_POWER 0x0010
+#define HID_REMOTE_WAKE 0x0020
+#define HID_SUP_TOUT_AVLBL 0x0040
+#define HID_SSR_MAX_LATENCY 0x0080
+#define HID_SSR_MIN_TOUT 0x0100
+
+#define HID_SEC_REQUIRED 0x8000
+#define HID_ATTR_MASK_IGNORE 0
+
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+typedef void (tHID_HOST_SDP_CALLBACK) (UINT16 result, UINT16 attr_mask,
+ tHID_DEV_SDP_INFO *sdp_rec );
+
+/* HID-HOST returns the events in the following table to the application via tHID_HOST_DEV_CALLBACK
+HID_HDEV_EVT_OPEN Connected to device with Interrupt and Control Channels in OPEN state.
+ Data = NA
+HID_HDEV_EVT_CLOSE Connection with device is closed. Data=reason code.
+HID_HDEV_EVT_RETRYING Lost connection is being re-connected.
+ Data=Retrial number
+HID_HDEV_EVT_IN_REPORT Device sent an input report Data=Report Type pdata= pointer to BT_HDR
+ (GKI buffer having report data.)
+HID_HDEV_EVT_HANDSHAKE Device sent SET_REPORT Data=Result-code pdata=NA.
+HID_HDEV_EVT_VC_UNPLUG Device sent Virtual Unplug Data=NA. pdata=NA.
+*/
+
+enum {
+ HID_HDEV_EVT_OPEN,
+ HID_HDEV_EVT_CLOSE,
+ HID_HDEV_EVT_RETRYING,
+ HID_HDEV_EVT_INTR_DATA,
+ HID_HDEV_EVT_INTR_DATC,
+ HID_HDEV_EVT_CTRL_DATA,
+ HID_HDEV_EVT_CTRL_DATC,
+ HID_HDEV_EVT_HANDSHAKE,
+ HID_HDEV_EVT_VC_UNPLUG
+};
+typedef void (tHID_HOST_DEV_CALLBACK) (UINT8 dev_handle,
+ BD_ADDR addr,
+ UINT8 event, /* Event from HID-DEVICE. */
+ UINT32 data, /* Integer data corresponding to the event.*/
+ BT_HDR *p_buf ); /* Pointer data corresponding to the event. */
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function HID_HostGetSDPRecord
+**
+** Description This function reads the device SDP record.
+**
+** Returns tHID_STATUS
+**
+*******************************************************************************/
+extern tHID_STATUS HID_HostGetSDPRecord (BD_ADDR addr,
+ tSDP_DISCOVERY_DB *p_db,
+ UINT32 db_len,
+ tHID_HOST_SDP_CALLBACK *sdp_cback );
+
+/*******************************************************************************
+**
+** Function HID_HostRegister
+**
+** Description This function registers HID-Host with lower layers.
+**
+** Returns tHID_STATUS
+**
+*******************************************************************************/
+extern tHID_STATUS HID_HostRegister (tHID_HOST_DEV_CALLBACK *dev_cback);
+
+/*******************************************************************************
+**
+** Function HID_HostDeregister
+**
+** Description This function is called when the host is about power down.
+**
+** Returns tHID_STATUS
+**
+*******************************************************************************/
+extern tHID_STATUS HID_HostDeregister(void);
+
+/*******************************************************************************
+**
+** Function HID_HostAddDev
+**
+** Description This is called so HID-host may manage this device.
+**
+** Returns tHID_STATUS
+**
+*******************************************************************************/
+extern tHID_STATUS HID_HostAddDev (BD_ADDR addr, UINT16 attr_mask,
+ UINT8 *handle );
+
+/*******************************************************************************
+**
+** Function HID_HostGetDev
+**
+** Description This is called so HID-host can find this device.
+**
+** Returns tHID_STATUS
+**
+*******************************************************************************/
+extern tHID_STATUS HID_HostGetDev(BD_ADDR addr, UINT8 *handle);
+
+/*******************************************************************************
+**
+** Function HID_HostRemoveDev
+**
+** Description This removes the device from list devices that host has to manage.
+**
+** Returns tHID_STATUS
+**
+*******************************************************************************/
+extern tHID_STATUS HID_HostRemoveDev (UINT8 dev_handle );
+
+/*******************************************************************************
+**
+** Function HID_HostOpenDev
+**
+** Description This function is called when the user wants to initiate a
+** connection attempt to a device.
+**
+** Returns void
+**
+*******************************************************************************/
+extern tHID_STATUS HID_HostOpenDev (UINT8 dev_handle );
+
+/*******************************************************************************
+**
+** Function HID_HostWriteDev
+**
+** Description This function is called when the host has a report to send.
+**
+** Returns void
+**
+*******************************************************************************/
+extern tHID_STATUS HID_HostWriteDev(UINT8 dev_handle, UINT8 t_type,
+ UINT8 param, UINT16 data,
+ UINT8 report_id, BT_HDR *pbuf);
+
+/*******************************************************************************
+**
+** Function HID_HostCloseDev
+**
+** Description This function disconnects the device.
+**
+** Returns void
+**
+*******************************************************************************/
+extern tHID_STATUS HID_HostCloseDev(UINT8 dev_handle );
+
+/*******************************************************************************
+** Function HID_HostInit
+**
+** Description This function initializes the control block and trace variable
+**
+** Returns tHID_STATUS
+*******************************************************************************/
+extern tHID_STATUS HID_HostInit(void);
+
+/*******************************************************************************
+** Function HID_HostDeinit
+**
+** Description This function deinitializes the control block
+**
+** Returns void
+*******************************************************************************/
+extern void HID_HostDeinit(void);
+
+/*******************************************************************************
+** Function HID_HostSetSecurityLevel
+**
+** Description This function sets the security level for the devices which
+** are marked by application as requiring security
+**
+** Returns tHID_STATUS
+*******************************************************************************/
+extern tHID_STATUS HID_HostSetSecurityLevel( char serv_name[], UINT8 sec_lvl );
+
+/*******************************************************************************
+**
+** Function hid_known_hid_device
+**
+** Description This function checks if this device is of type HID Device
+**
+** Returns TRUE if device exists else FALSE
+**
+*******************************************************************************/
+BOOLEAN hid_known_hid_device (BD_ADDR bd_addr);
+
+
+/*******************************************************************************
+**
+** Function HID_HostSetTraceLevel
+**
+** Description This function sets the trace level for HID Host. If called with
+** a value of 0xFF, it simply reads the current trace level.
+**
+** Returns the new (current) trace level
+**
+*******************************************************************************/
+extern UINT8 HID_HostSetTraceLevel (UINT8 new_level);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif ///HID_HOST_INCLUDED == TRUE
+
+#endif /* HIDH_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/l2c_api.h b/lib/bt/host/bluedroid/stack/include/stack/l2c_api.h
new file mode 100644
index 00000000..b985b641
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/l2c_api.h
@@ -0,0 +1,1270 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * this file contains the L2CAP API definitions
+ *
+ ******************************************************************************/
+#ifndef L2C_API_H
+#define L2C_API_H
+
+#include <stdbool.h>
+
+#include "common/bt_target.h"
+#include "stack/l2cdefs.h"
+#include "stack/hcidefs.h"
+#include "osi/fixed_queue.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+/* Define the minimum offset that L2CAP needs in a buffer. This is made up of
+** HCI type(1), len(2), handle(2), L2CAP len(2) and CID(2) => 9
+*/
+#define L2CAP_MIN_OFFSET 13 /* plus control(2), SDU length(2) */
+#define L2CAP_FCS_LEN 2 /* FCS 0 or 2 bytes */
+
+/* Minimum offset for broadcast needs another two bytes for the PSM */
+#define L2CAP_BCST_MIN_OFFSET 11
+
+/* ping result codes */
+#define L2CAP_PING_RESULT_OK 0 /* Ping reply received OK */
+#define L2CAP_PING_RESULT_NO_LINK 1 /* Link could not be setup */
+#define L2CAP_PING_RESULT_NO_RESP 2 /* Remote L2CAP did not reply */
+
+/* result code for L2CA_DataWrite() */
+#define L2CAP_DW_FAILED FALSE
+#define L2CAP_DW_SUCCESS TRUE
+#define L2CAP_DW_CONGESTED 2
+
+/* Values for priority parameter to L2CA_SetAclPriority */
+#define L2CAP_PRIORITY_NORMAL 0
+#define L2CAP_PRIORITY_HIGH 1
+
+/* Values for priority parameter to L2CA_SetTxPriority */
+#define L2CAP_CHNL_PRIORITY_HIGH 0
+#define L2CAP_CHNL_PRIORITY_MEDIUM 1
+#define L2CAP_CHNL_PRIORITY_LOW 2
+
+typedef UINT8 tL2CAP_CHNL_PRIORITY;
+
+/* Values for Tx/Rx data rate parameter to L2CA_SetChnlDataRate */
+#define L2CAP_CHNL_DATA_RATE_HIGH 3
+#define L2CAP_CHNL_DATA_RATE_MEDIUM 2
+#define L2CAP_CHNL_DATA_RATE_LOW 1
+#define L2CAP_CHNL_DATA_RATE_NO_TRAFFIC 0
+
+typedef UINT8 tL2CAP_CHNL_DATA_RATE;
+
+/* Data Packet Flags (bits 2-15 are reserved) */
+/* layer specific 14-15 bits are used for FCR SAR */
+#define L2CAP_FLUSHABLE_MASK 0x0003
+#define L2CAP_FLUSHABLE_CH_BASED 0x0000
+#define L2CAP_FLUSHABLE_PKT 0x0001
+#define L2CAP_NON_FLUSHABLE_PKT 0x0002
+
+
+/* L2CA_FlushChannel num_to_flush definitions */
+#define L2CAP_FLUSH_CHANS_ALL 0xffff
+#define L2CAP_FLUSH_CHANS_GET 0x0000
+
+
+/* special CID for Multi-AV for reporting congestion */
+#define L2CAP_MULTI_AV_CID 0
+
+/* length of the HCI header block */
+/* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) */
+#define L2CAP_MULTI_AV_HCI_HDR_LEN 8
+
+/* length of padding for 4 bytes align */
+#define L2CAP_MULTI_AV_PADDING_LEN 2
+
+/* length of the HCI header block with padding for FCR */
+/* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) + padding(2) */
+#define L2CAP_MULTI_AV_HCI_HDR_LEN_WITH_PADDING 10
+
+/* length of the L2CAP header block */
+/* HCI header(4) + L2CAP header(4) + padding(4) or control word(2) + FCS(2) */
+#define L2CAP_MULTI_AV_L2C_HDR_LEN 12
+
+/* definition used for L2CA_SetDesireRole */
+#define L2CAP_ROLE_SLAVE HCI_ROLE_SLAVE
+#define L2CAP_ROLE_MASTER HCI_ROLE_MASTER
+#define L2CAP_ROLE_ALLOW_SWITCH 0x80 /* set this bit to allow switch at create conn */
+#define L2CAP_ROLE_DISALLOW_SWITCH 0x40 /* set this bit to disallow switch at create conn */
+#define L2CAP_ROLE_CHECK_SWITCH 0xC0
+
+
+/* Values for 'allowed_modes' field passed in structure tL2CAP_ERTM_INFO
+*/
+#define L2CAP_FCR_CHAN_OPT_BASIC (1 << L2CAP_FCR_BASIC_MODE)
+#define L2CAP_FCR_CHAN_OPT_ERTM (1 << L2CAP_FCR_ERTM_MODE)
+#define L2CAP_FCR_CHAN_OPT_STREAM (1 << L2CAP_FCR_STREAM_MODE)
+
+#define L2CAP_FCR_CHAN_OPT_ALL_MASK (L2CAP_FCR_CHAN_OPT_BASIC | L2CAP_FCR_CHAN_OPT_ERTM | L2CAP_FCR_CHAN_OPT_STREAM)
+
+/* Validity check for PSM. PSM values must be odd. Also, all PSM values must
+** be assigned such that the least significant bit of the most sigificant
+** octet equals zero.
+*/
+#define L2C_INVALID_PSM(psm) (((psm) & 0x0101) != 0x0001)
+#define L2C_IS_VALID_PSM(psm) (((psm) & 0x0101) == 0x0001)
+#define L2C_IS_VALID_LE_PSM(psm) (((psm) > 0x0000) && ((psm) < 0x0100))
+
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+typedef struct {
+#define L2CAP_FCR_BASIC_MODE 0x00
+#define L2CAP_FCR_ERTM_MODE 0x03
+#define L2CAP_FCR_STREAM_MODE 0x04
+
+ UINT8 mode;
+
+ UINT8 tx_win_sz;
+ UINT8 max_transmit;
+ UINT16 rtrans_tout;
+ UINT16 mon_tout;
+ UINT16 mps;
+} tL2CAP_FCR_OPTS;
+
+/* Define a structure to hold the configuration parameters. Since the
+** parameters are optional, for each parameter there is a boolean to
+** use to signify its presence or absence.
+*/
+typedef struct {
+ UINT16 result; /* Only used in confirm messages */
+ BOOLEAN mtu_present;
+ UINT16 mtu;
+ BOOLEAN qos_present;
+ FLOW_SPEC qos;
+ BOOLEAN flush_to_present;
+ UINT16 flush_to;
+ BOOLEAN fcr_present;
+ tL2CAP_FCR_OPTS fcr;
+ BOOLEAN fcs_present; /* Optionally bypasses FCS checks */
+ UINT8 fcs; /* '0' if desire is to bypass FCS, otherwise '1' */
+ BOOLEAN ext_flow_spec_present;
+ tHCI_EXT_FLOW_SPEC ext_flow_spec;
+ UINT16 flags; /* bit 0: 0-no continuation, 1-continuation */
+} tL2CAP_CFG_INFO;
+
+/* Define a structure to hold the configuration parameter for LE L2CAP connection
+** oriented channels.
+*/
+typedef struct
+{
+ UINT16 mtu;
+ UINT16 mps;
+ UINT16 credits;
+} tL2CAP_LE_CFG_INFO;
+
+
+/* L2CAP channel configured field bitmap */
+#define L2CAP_CH_CFG_MASK_MTU 0x0001
+#define L2CAP_CH_CFG_MASK_QOS 0x0002
+#define L2CAP_CH_CFG_MASK_FLUSH_TO 0x0004
+#define L2CAP_CH_CFG_MASK_FCR 0x0008
+#define L2CAP_CH_CFG_MASK_FCS 0x0010
+#define L2CAP_CH_CFG_MASK_EXT_FLOW_SPEC 0x0020
+
+typedef UINT16 tL2CAP_CH_CFG_BITS;
+
+/*********************************
+** Callback Functions Prototypes
+**********************************/
+
+/* Connection indication callback prototype. Parameters are
+** BD Address of remote
+** Local CID assigned to the connection
+** PSM that the remote wants to connect to
+** Identifier that the remote sent
+*/
+typedef void (tL2CA_CONNECT_IND_CB) (BD_ADDR, UINT16, UINT16, UINT8);
+
+
+/* Connection confirmation callback prototype. Parameters are
+** Local CID
+** Result - 0 = connected, non-zero means failure reason
+*/
+typedef void (tL2CA_CONNECT_CFM_CB) (UINT16, UINT16);
+
+
+/* Connection pending callback prototype. Parameters are
+** Local CID
+*/
+typedef void (tL2CA_CONNECT_PND_CB) (UINT16);
+
+
+/* Configuration indication callback prototype. Parameters are
+** Local CID assigned to the connection
+** Pointer to configuration info
+*/
+typedef void (tL2CA_CONFIG_IND_CB) (UINT16, tL2CAP_CFG_INFO *);
+
+
+/* Configuration confirm callback prototype. Parameters are
+** Local CID assigned to the connection
+** Pointer to configuration info
+*/
+typedef void (tL2CA_CONFIG_CFM_CB) (UINT16, tL2CAP_CFG_INFO *);
+
+
+/* Disconnect indication callback prototype. Parameters are
+** Local CID
+** Boolean whether upper layer should ack this
+*/
+typedef void (tL2CA_DISCONNECT_IND_CB) (UINT16, BOOLEAN);
+
+
+/* Disconnect confirm callback prototype. Parameters are
+** Local CID
+** Result
+*/
+typedef void (tL2CA_DISCONNECT_CFM_CB) (UINT16, UINT16);
+
+
+/* QOS Violation indication callback prototype. Parameters are
+** BD Address of violating device
+*/
+typedef void (tL2CA_QOS_VIOLATION_IND_CB) (BD_ADDR);
+
+
+/* Data received indication callback prototype. Parameters are
+** Local CID
+** Address of buffer
+*/
+typedef void (tL2CA_DATA_IND_CB) (UINT16, BT_HDR *);
+
+
+/* Echo response callback prototype. Note that this is not included in the
+** registration information, but is passed to L2CAP as part of the API to
+** actually send an echo request. Parameters are
+** Result
+*/
+typedef void (tL2CA_ECHO_RSP_CB) (UINT16);
+
+
+/* Callback function prototype to pass broadcom specific echo response */
+/* to the upper layer */
+typedef void (tL2CA_ECHO_DATA_CB) (BD_ADDR, UINT16, UINT8 *);
+
+
+/* Congestion status callback protype. This callback is optional. If
+** an application tries to send data when the transmit queue is full,
+** the data will anyways be dropped. The parameter is:
+** Local CID
+** TRUE if congested, FALSE if uncongested
+*/
+typedef void (tL2CA_CONGESTION_STATUS_CB) (UINT16, BOOLEAN);
+
+/* Callback prototype for number of packets completed events.
+** This callback notifies the application when Number of Completed Packets
+** event has been received.
+** This callback is originally designed for 3DG devices.
+** The parameter is:
+** peer BD_ADDR
+*/
+typedef void (tL2CA_NOCP_CB) (BD_ADDR);
+
+/* Transmit complete callback protype. This callback is optional. If
+** set, L2CAP will call it when packets are sent or flushed. If the
+** count is 0xFFFF, it means all packets are sent for that CID (eRTM
+** mode only). The parameters are:
+** Local CID
+** Number of SDUs sent or dropped
+*/
+typedef void (tL2CA_TX_COMPLETE_CB) (UINT16, UINT16);
+
+/* Define the structure that applications use to register with
+** L2CAP. This structure includes callback functions. All functions
+** MUST be provided, with the exception of the "connect pending"
+** callback and "congestion status" callback.
+*/
+typedef struct {
+ tL2CA_CONNECT_IND_CB *pL2CA_ConnectInd_Cb;
+ tL2CA_CONNECT_CFM_CB *pL2CA_ConnectCfm_Cb;
+ tL2CA_CONNECT_PND_CB *pL2CA_ConnectPnd_Cb;
+ tL2CA_CONFIG_IND_CB *pL2CA_ConfigInd_Cb;
+ tL2CA_CONFIG_CFM_CB *pL2CA_ConfigCfm_Cb;
+ tL2CA_DISCONNECT_IND_CB *pL2CA_DisconnectInd_Cb;
+ tL2CA_DISCONNECT_CFM_CB *pL2CA_DisconnectCfm_Cb;
+ tL2CA_QOS_VIOLATION_IND_CB *pL2CA_QoSViolationInd_Cb;
+ tL2CA_DATA_IND_CB *pL2CA_DataInd_Cb;
+ tL2CA_CONGESTION_STATUS_CB *pL2CA_CongestionStatus_Cb;
+ tL2CA_TX_COMPLETE_CB *pL2CA_TxComplete_Cb;
+
+} tL2CAP_APPL_INFO;
+
+/* Define the structure that applications use to create or accept
+** connections with enhanced retransmission mode.
+*/
+typedef struct {
+ UINT8 preferred_mode;
+ UINT8 allowed_modes;
+ UINT16 user_rx_buf_size;
+ UINT16 user_tx_buf_size;
+ UINT16 fcr_rx_buf_size;
+ UINT16 fcr_tx_buf_size;
+
+} tL2CAP_ERTM_INFO;
+
+#define L2CA_REGISTER(a,b,c) L2CA_Register(a,(tL2CAP_APPL_INFO *)b)
+#define L2CA_DEREGISTER(a) L2CA_Deregister(a)
+#define L2CA_CONNECT_REQ(a,b,c,d) L2CA_ErtmConnectReq(a,b,c)
+#define L2CA_CONNECT_RSP(a,b,c,d,e,f,g) L2CA_ErtmConnectRsp(a,b,c,d,e,f)
+#define L2CA_CONFIG_REQ(a,b) L2CA_ConfigReq(a,b)
+#define L2CA_CONFIG_RSP(a,b) L2CA_ConfigRsp(a,b)
+#define L2CA_DISCONNECT_REQ(a) L2CA_DisconnectReq(a)
+#define L2CA_DISCONNECT_RSP(a) L2CA_DisconnectRsp(a)
+#define L2CA_DATA_WRITE(a, b) L2CA_DataWrite(a, b)
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#if (CLASSIC_BT_INCLUDED == TRUE)
+/*******************************************************************************
+**
+** Function L2CA_Register
+**
+** Description Other layers call this function to register for L2CAP
+** services.
+**
+** Returns PSM to use or zero if error. Typically, the PSM returned
+** is the same as was passed in, but for an outgoing-only
+** connection to a dynamic PSM, a "virtual" PSM is returned
+** and should be used in the calls to L2CA_ConnectReq() and
+** BTM_SetSecurityLevel().
+**
+*******************************************************************************/
+extern UINT16 L2CA_Register (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info);
+
+/*******************************************************************************
+**
+** Function L2CA_Deregister
+**
+** Description Other layers call this function to deregister for L2CAP
+** services.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void L2CA_Deregister (UINT16 psm);
+
+/*******************************************************************************
+**
+** Function L2CA_AllocatePSM
+**
+** Description Other layers call this function to find an unused PSM for L2CAP
+** services.
+**
+** Returns PSM to use.
+**
+*******************************************************************************/
+extern UINT16 L2CA_AllocatePSM(void);
+
+/*******************************************************************************
+**
+** Function L2CA_ConnectReq
+**
+** Description Higher layers call this function to create an L2CAP connection.
+** Note that the connection is not established at this time, but
+** connection establishment gets started. The callback function
+** will be invoked when connection establishes or fails.
+**
+** Returns the CID of the connection, or 0 if it failed to start
+**
+*******************************************************************************/
+extern UINT16 L2CA_ConnectReq (UINT16 psm, BD_ADDR p_bd_addr);
+
+/*******************************************************************************
+**
+** Function L2CA_ConnectRsp
+**
+** Description Higher layers call this function to accept an incoming
+** L2CAP connection, for which they had gotten an connect
+** indication callback.
+**
+** Returns TRUE for success, FALSE for failure
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_ConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid,
+ UINT16 result, UINT16 status);
+
+/*******************************************************************************
+**
+** Function L2CA_ErtmConnectReq
+**
+** Description Higher layers call this function to create an L2CAP connection
+** that needs to use Enhanced Retransmission Mode.
+** Note that the connection is not established at this time, but
+** connection establishment gets started. The callback function
+** will be invoked when connection establishes or fails.
+**
+** Returns the CID of the connection, or 0 if it failed to start
+**
+*******************************************************************************/
+extern UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr,
+ tL2CAP_ERTM_INFO *p_ertm_info);
+
+// This function sets the callback routines for the L2CAP connection referred to by
+// |local_cid|. The callback routines can only be modified for outgoing connections
+// established by |L2CA_ConnectReq| or accepted incoming connections. |callbacks|
+// must not be NULL. This function returns true if the callbacks could be updated,
+// false if not (e.g. |local_cid| was not found).
+bool L2CA_SetConnectionCallbacks(uint16_t local_cid, const tL2CAP_APPL_INFO *callbacks);
+
+/*******************************************************************************
+**
+** Function L2CA_ErtmConnectRsp
+**
+** Description Higher layers call this function to accept an incoming
+** L2CAP connection, for which they had gotten an connect
+** indication callback, and for which the higher layer wants
+** to use Enhanced Retransmission Mode.
+**
+** Returns TRUE for success, FALSE for failure
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid,
+ UINT16 result, UINT16 status,
+ tL2CAP_ERTM_INFO *p_ertm_info);
+
+/*******************************************************************************
+**
+** Function L2CA_ConfigReq
+**
+** Description Higher layers call this function to send configuration.
+**
+** Returns TRUE if configuration sent, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_ConfigReq (UINT16 cid, tL2CAP_CFG_INFO *p_cfg);
+
+/*******************************************************************************
+**
+** Function L2CA_ConfigRsp
+**
+** Description Higher layers call this function to send a configuration
+** response.
+**
+** Returns TRUE if configuration response sent, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_ConfigRsp (UINT16 cid, tL2CAP_CFG_INFO *p_cfg);
+
+/*******************************************************************************
+**
+** Function L2CA_DisconnectReq
+**
+** Description Higher layers call this function to disconnect a channel.
+**
+** Returns TRUE if disconnect sent, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_DisconnectReq (UINT16 cid);
+
+/*******************************************************************************
+**
+** Function L2CA_DisconnectRsp
+**
+** Description Higher layers call this function to acknowledge the
+** disconnection of a channel.
+**
+** Returns void
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
+#endif ///CLASSIC_BT_INCLUDED == TRUE
+
+#if (BLE_L2CAP_COC_INCLUDED == TRUE)
+/*******************************************************************************
+**
+** Function L2CA_RegisterLECoc
+**
+** Description Other layers call this function to register for L2CAP
+** Connection Oriented Channel.
+**
+** Returns PSM to use or zero if error. Typically, the PSM returned
+** is the same as was passed in, but for an outgoing-only
+** connection to a dynamic PSM, a "virtual" PSM is returned
+** and should be used in the calls to L2CA_ConnectLECocReq()
+** and BTM_SetSecurityLevel().
+**
+*******************************************************************************/
+extern UINT16 L2CA_RegisterLECoc (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info);
+
+/*******************************************************************************
+**
+** Function L2CA_DeregisterLECoc
+**
+** Description Other layers call this function to deregister for L2CAP
+** Connection Oriented Channel.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void L2CA_DeregisterLECoc (UINT16 psm);
+
+/*******************************************************************************
+**
+** Function L2CA_ConnectLECocReq
+**
+** Description Higher layers call this function to create an L2CAP LE COC.
+** Note that the connection is not established at this time, but
+** connection establishment gets started. The callback function
+** will be invoked when connection establishes or fails.
+**
+** Returns the CID of the connection, or 0 if it failed to start
+**
+*******************************************************************************/
+extern UINT16 L2CA_ConnectLECocReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_LE_CFG_INFO *p_cfg);
+
+/*******************************************************************************
+**
+** Function L2CA_ConnectLECocRsp
+**
+** Description Higher layers call this function to accept an incoming
+** L2CAP LE COC connection, for which they had gotten an connect
+** indication callback.
+**
+** Returns TRUE for success, FALSE for failure
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_ConnectLECocRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 result,
+ UINT16 status, tL2CAP_LE_CFG_INFO *p_cfg);
+
+/*******************************************************************************
+**
+** Function L2CA_GetPeerLECocConfig
+**
+** Description Get peers configuration for LE Connection Oriented Channel.
+**
+** Return value: TRUE if peer is connected
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_GetPeerLECocConfig (UINT16 lcid, tL2CAP_LE_CFG_INFO* peer_cfg);
+
+#endif // (BLE_L2CAP_COC_INCLUDED == TRUE)
+
+/*******************************************************************************
+**
+** Function L2CA_DataWrite
+**
+** Description Higher layers call this function to write data.
+**
+** Returns L2CAP_DW_SUCCESS, if data accepted, else FALSE
+** L2CAP_DW_CONGESTED, if data accepted and the channel is congested
+** L2CAP_DW_FAILED, if error
+**
+*******************************************************************************/
+extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data);
+
+#if (CLASSIC_BT_INCLUDED == TRUE)
+
+/*******************************************************************************
+**
+** Function L2CA_Ping
+**
+** Description Higher layers call this function to send an echo request.
+**
+** Returns TRUE if echo request sent, else FALSE.
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function L2CA_Echo
+**
+** Description Higher layers call this function to send an echo request
+** with application-specific data.
+**
+** Returns TRUE if echo request sent, else FALSE.
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback);
+#endif ///CLASSIC_BT_INCLUDED == TRUE
+
+
+// Given a local channel identifier, |lcid|, this function returns the bound remote
+// channel identifier, |rcid|, and the ACL link handle, |handle|. If |lcid| is not
+// known or is invalid, this function returns false and does not modify the values
+// pointed at by |rcid| and |handle|. |rcid| and |handle| may be NULL.
+bool L2CA_GetIdentifiers(uint16_t lcid, uint16_t *rcid, uint16_t *handle);
+
+/*******************************************************************************
+**
+** Function L2CA_SetIdleTimeout
+**
+** Description Higher layers call this function to set the idle timeout for
+** a connection, or for all future connections. The "idle timeout"
+** is the amount of time that a connection can remain up with
+** no L2CAP channels on it. A timeout of zero means that the
+** connection will be torn down immediately when the last channel
+** is removed. A timeout of 0xFFFF means no timeout. Values are
+** in seconds.
+**
+** Returns TRUE if command succeeded, FALSE if failed
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout,
+ BOOLEAN is_global);
+
+
+/*******************************************************************************
+**
+** Function L2CA_SetIdleTimeoutByBdAddr
+**
+** Description Higher layers call this function to set the idle timeout for
+** a connection. The "idle timeout" is the amount of time that
+** a connection can remain up with no L2CAP channels on it.
+** A timeout of zero means that the connection will be torn
+** down immediately when the last channel is removed.
+** A timeout of 0xFFFF means no timeout. Values are in seconds.
+** A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY,
+** then the idle timeouts for all active l2cap links will be
+** changed.
+**
+** Returns TRUE if command succeeded, FALSE if failed
+**
+** NOTE This timeout applies to all logical channels active on the
+** ACL link.
+*******************************************************************************/
+extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout,
+ tBT_TRANSPORT transport);
+
+
+/*******************************************************************************
+**
+** Function L2CA_SetTraceLevel
+**
+** Description This function sets the trace level for L2CAP. If called with
+** a value of 0xFF, it simply reads the current trace level.
+**
+** Returns the new (current) trace level
+**
+*******************************************************************************/
+extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level);
+
+
+/*******************************************************************************
+**
+** Function L2CA_SetDesireRole
+**
+** Description This function sets the desire role for L2CAP.
+** If the new role is L2CAP_ROLE_ALLOW_SWITCH, allow switch on
+** HciCreateConnection.
+** If the new role is L2CAP_ROLE_DISALLOW_SWITCH, do not allow switch on
+** HciCreateConnection.
+**
+** If the new role is a valid role (HCI_ROLE_MASTER or HCI_ROLE_SLAVE),
+** the desire role is set to the new value. Otherwise, it is not changed.
+**
+** Returns the new (current) role
+**
+*******************************************************************************/
+extern UINT8 L2CA_SetDesireRole (UINT8 new_role);
+#if (CLASSIC_BT_INCLUDED == TRUE)
+/*******************************************************************************
+**
+** Function L2CA_LocalLoopbackReq
+**
+** Description This function sets up a CID for local loopback
+**
+** Returns CID of 0 if none.
+**
+*******************************************************************************/
+extern UINT16 L2CA_LocalLoopbackReq (UINT16 psm, UINT16 handle, BD_ADDR p_bd_addr);
+
+/*******************************************************************************
+**
+** Function L2CA_FlushChannel
+**
+** Description This function flushes none, some or all buffers queued up
+** for xmission for a particular CID. If called with
+** L2CAP_FLUSH_CHANS_GET (0), it simply returns the number
+** of buffers queued for that CID L2CAP_FLUSH_CHANS_ALL (0xffff)
+** flushes all buffers. All other values specifies the maximum
+** buffers to flush.
+**
+** Returns Number of buffers left queued for that CID
+**
+*******************************************************************************/
+extern UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush);
+
+
+/*******************************************************************************
+**
+** Function L2CA_SetAclPriority
+**
+** Description Sets the transmission priority for an ACL channel.
+** (For initial implementation only two values are valid.
+** L2CAP_PRIORITY_NORMAL and L2CAP_PRIORITY_HIGH).
+**
+** Returns TRUE if a valid channel, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_SetAclPriority (BD_ADDR bd_addr, UINT8 priority);
+
+/*******************************************************************************
+**
+** Function L2CA_FlowControl
+**
+** Description Higher layers call this function to flow control a channel.
+**
+** data_enabled - TRUE data flows, FALSE data is stopped
+**
+** Returns TRUE if valid channel, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_FlowControl (UINT16 cid, BOOLEAN data_enabled);
+
+/*******************************************************************************
+**
+** Function L2CA_SendTestSFrame
+**
+** Description Higher layers call this function to send a test S-frame.
+**
+** Returns TRUE if valid Channel, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_SendTestSFrame (UINT16 cid, UINT8 sup_type,
+ UINT8 back_track);
+
+/*******************************************************************************
+**
+** Function L2CA_SetTxPriority
+**
+** Description Sets the transmission priority for a channel. (FCR Mode)
+**
+** Returns TRUE if a valid channel, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_SetTxPriority (UINT16 cid, tL2CAP_CHNL_PRIORITY priority);
+
+/*******************************************************************************
+**
+** Function L2CA_RegForNoCPEvt
+**
+** Description Register callback for Number of Completed Packets event.
+**
+** Input Param p_cb - callback for Number of completed packets event
+** p_bda - BT address of remote device
+**
+** Returns
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda);
+
+/*******************************************************************************
+**
+** Function L2CA_SetChnlDataRate
+**
+** Description Sets the tx/rx data rate for a channel.
+**
+** Returns TRUE if a valid channel, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_SetChnlDataRate (UINT16 cid, tL2CAP_CHNL_DATA_RATE tx, tL2CAP_CHNL_DATA_RATE rx);
+
+typedef void (tL2CA_RESERVE_CMPL_CBACK) (void);
+
+/*******************************************************************************
+**
+** Function L2CA_SetFlushTimeout
+**
+** Description This function set the automatic flush time out in Baseband
+** for ACL-U packets.
+** BdAddr : the remote BD address of ACL link. If it is BT_DB_ANY
+** then the flush time out will be applied to all ACL link.
+** FlushTimeout: flush time out in ms
+** 0x0000 : No automatic flush
+** L2CAP_NO_RETRANSMISSION : No retransmission
+** 0x0002 - 0xFFFE : flush time out, if (flush_tout*8)+3/5)
+** <= HCI_MAX_AUTO_FLUSH_TOUT (in 625us slot).
+** Otherwise, return FALSE.
+** L2CAP_NO_AUTOMATIC_FLUSH : No automatic flush
+**
+** Returns TRUE if command succeeded, FALSE if failed
+**
+** NOTE This flush timeout applies to all logical channels active on the
+** ACL link.
+*******************************************************************************/
+extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout);
+#endif ///CLASSIC_BT_INCLUDED == TRUE
+
+/*******************************************************************************
+**
+** Function L2CA_DataWriteEx
+**
+** Description Higher layers call this function to write data with extended
+** flags.
+** flags : L2CAP_FLUSHABLE_CH_BASED
+** L2CAP_FLUSHABLE_PKT
+** L2CAP_NON_FLUSHABLE_PKT
+**
+** Returns L2CAP_DW_SUCCESS, if data accepted, else FALSE
+** L2CAP_DW_CONGESTED, if data accepted and the channel is congested
+** L2CAP_DW_FAILED, if error
+**
+*******************************************************************************/
+extern UINT8 L2CA_DataWriteEx (UINT16 cid, BT_HDR *p_data, UINT16 flags);
+
+/*******************************************************************************
+**
+** Function L2CA_SetChnlFlushability
+**
+** Description Higher layers call this function to set a channels
+** flushability flags
+**
+** Returns TRUE if CID found, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushable);
+
+/*******************************************************************************
+**
+** Function L2CA_GetPeerFeatures
+**
+** Description Get a peers features and fixed channel map
+**
+** Parameters: BD address of the peer
+** Pointers to features and channel mask storage area
+**
+** Return value: TRUE if peer is connected
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat, UINT8 *p_chnl_mask);
+
+/*******************************************************************************
+**
+** Function L2CA_GetBDAddrbyHandle
+**
+** Description Get BD address for the given HCI handle
+**
+** Parameters: HCI handle
+** BD address of the peer
+**
+** Return value: TRUE if found lcb for the given handle, FALSE otherwise
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr);
+
+#if (CLASSIC_BT_INCLUDED == TRUE)
+
+/*******************************************************************************
+**
+** Function L2CA_GetChnlFcrMode
+**
+** Description Get the channel FCR mode
+**
+** Parameters: Local CID
+**
+** Return value: Channel mode
+**
+*******************************************************************************/
+extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid);
+#endif ///CLASSIC_BT_INCLUDED == TRUE
+
+
+/*******************************************************************************
+**
+** UCD callback prototypes
+**
+*******************************************************************************/
+
+/* UCD discovery. Parameters are
+** BD Address of remote
+** Data Type
+** Data
+*/
+#define L2CAP_UCD_INFO_TYPE_RECEPTION 0x01
+#define L2CAP_UCD_INFO_TYPE_MTU 0x02
+
+typedef void (tL2CA_UCD_DISCOVER_CB) (BD_ADDR, UINT8, UINT32);
+
+/* UCD data received. Parameters are
+** BD Address of remote
+** Pointer to buffer with data
+*/
+typedef void (tL2CA_UCD_DATA_CB) (BD_ADDR, BT_HDR *);
+
+/* Congestion status callback protype. This callback is optional. If
+** an application tries to send data when the transmit queue is full,
+** the data will anyways be dropped. The parameter is:
+** remote BD_ADDR
+** TRUE if congested, FALSE if uncongested
+*/
+typedef void (tL2CA_UCD_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
+
+/* UCD registration info (the callback addresses and PSM)
+*/
+typedef struct {
+ tL2CA_UCD_DISCOVER_CB *pL2CA_UCD_Discover_Cb;
+ tL2CA_UCD_DATA_CB *pL2CA_UCD_Data_Cb;
+ tL2CA_UCD_CONGESTION_STATUS_CB *pL2CA_UCD_Congestion_Status_Cb;
+} tL2CAP_UCD_CB_INFO;
+
+/*******************************************************************************
+**
+** Function L2CA_UcdRegister
+**
+** Description Register PSM on UCD.
+**
+** Parameters: tL2CAP_UCD_CB_INFO
+**
+** Return value: TRUE if successs
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info );
+
+/*******************************************************************************
+**
+** Function L2CA_UcdDeregister
+**
+** Description Deregister PSM on UCD.
+**
+** Parameters: PSM
+**
+** Return value: TRUE if successs
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm );
+
+/*******************************************************************************
+**
+** Function L2CA_UcdDiscover
+**
+** Description Discover UCD of remote device.
+**
+** Parameters: PSM
+** BD_ADDR of remote device
+** info_type : L2CAP_UCD_INFO_TYPE_RECEPTION
+** L2CAP_UCD_INFO_TYPE_MTU
+**
+**
+** Return value: TRUE if successs
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 info_type );
+
+/*******************************************************************************
+**
+** Function L2CA_UcdDataWrite
+**
+** Description Send UCD to remote device
+**
+** Parameters: PSM
+** BD Address of remote
+** Pointer to buffer of type BT_HDR
+** flags : L2CAP_FLUSHABLE_CH_BASED
+** L2CAP_FLUSHABLE_PKT
+** L2CAP_NON_FLUSHABLE_PKT
+**
+** Return value L2CAP_DW_SUCCESS, if data accepted
+** L2CAP_DW_FAILED, if error
+**
+*******************************************************************************/
+extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 flags);
+
+/*******************************************************************************
+**
+** Function L2CA_UcdSetIdleTimeout
+**
+** Description Set UCD Idle timeout.
+**
+** Parameters: BD Addr
+** Timeout in second
+**
+** Return value: TRUE if successs
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout );
+
+/*******************************************************************************
+**
+** Function L2CA_UCDSetTxPriority
+**
+** Description Sets the transmission priority for a connectionless channel.
+**
+** Returns TRUE if a valid channel, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_UCDSetTxPriority ( BD_ADDR rem_bda, tL2CAP_CHNL_PRIORITY priority );
+
+
+/*******************************************************************************
+**
+** Fixed Channel callback prototypes
+**
+*******************************************************************************/
+
+/* Fixed channel connected and disconnected. Parameters are
+** channel
+** BD Address of remote
+** TRUE if channel is connected, FALSE if disconnected
+** Reason for connection failure
+** transport : physical transport, BR/EDR or LE
+*/
+typedef void (tL2CA_FIXED_CHNL_CB) (UINT16, BD_ADDR, BOOLEAN, UINT16, tBT_TRANSPORT);
+
+/* Signalling data received. Parameters are
+** channel
+** BD Address of remote
+** Pointer to buffer with data
+*/
+typedef void (tL2CA_FIXED_DATA_CB) (UINT16, BD_ADDR, BT_HDR *);
+
+/* Congestion status callback protype. This callback is optional. If
+** an application tries to send data when the transmit queue is full,
+** the data will anyways be dropped. The parameter is:
+** remote BD_ADDR
+** TRUE if congested, FALSE if uncongested
+*/
+typedef void (tL2CA_FIXED_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
+
+/* Fixed channel registration info (the callback addresses and channel config)
+*/
+typedef struct {
+ tL2CA_FIXED_CHNL_CB *pL2CA_FixedConn_Cb;
+ tL2CA_FIXED_DATA_CB *pL2CA_FixedData_Cb;
+ tL2CA_FIXED_CONGESTION_STATUS_CB *pL2CA_FixedCong_Cb;
+ tL2CAP_FCR_OPTS fixed_chnl_opts;
+
+ UINT16 default_idle_tout;
+ tL2CA_TX_COMPLETE_CB *pL2CA_FixedTxComplete_Cb; /* fixed channel tx complete callback */
+} tL2CAP_FIXED_CHNL_REG;
+
+
+#if (L2CAP_NUM_FIXED_CHNLS > 0)
+/*******************************************************************************
+**
+** Function L2CA_RegisterFixedChannel
+**
+** Description Register a fixed channel.
+**
+** Parameters: Fixed Channel #
+** Channel Callbacks and config
+**
+** Return value: TRUE if registered OK
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_freg);
+
+/*******************************************************************************
+**
+** Function L2CA_ConnectFixedChnl
+**
+** Description Connect an fixed signalling channel to a remote device.
+**
+** Parameters: Fixed CID
+** BD Address of remote
+** BD Address type
+**
+** Return value: TRUE if connection started
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux);
+
+/*******************************************************************************
+**
+** Function L2CA_SendFixedChnlData
+**
+** Description Write data on a fixed signalling channel.
+**
+** Parameters: Fixed CID
+** BD Address of remote
+** Pointer to buffer of type BT_HDR
+**
+** Return value L2CAP_DW_SUCCESS, if data accepted
+** L2CAP_DW_FAILED, if error
+**
+*******************************************************************************/
+extern UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf);
+
+/*******************************************************************************
+**
+** Function L2CA_RemoveFixedChnl
+**
+** Description Remove a fixed channel to a remote device.
+**
+** Parameters: Fixed CID
+** BD Address of remote
+** Idle timeout to use (or 0xFFFF if don't care)
+**
+** Return value: TRUE if channel removed
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda);
+
+/*******************************************************************************
+**
+** Function L2CA_SetFixedChannelTout
+**
+** Description Higher layers call this function to set the idle timeout for
+** a fixed channel. The "idle timeout" is the amount of time that
+** a connection can remain up with no L2CAP channels on it.
+** A timeout of zero means that the connection will be torn
+** down immediately when the last channel is removed.
+** A timeout of 0xFFFF means no timeout. Values are in seconds.
+** A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY,
+** then the idle timeouts for all active l2cap links will be
+** changed.
+**
+** Returns TRUE if command succeeded, FALSE if failed
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT16 idle_tout);
+
+#endif /* (L2CAP_NUM_FIXED_CHNLS > 0) */
+
+#if (CLASSIC_BT_INCLUDED == TRUE)
+/*******************************************************************************
+**
+** Function L2CA_GetCurrentConfig
+**
+** Description This function returns configurations of L2CAP channel
+** pp_our_cfg : pointer of our saved configuration options
+** p_our_cfg_bits : valid config in bitmap
+** pp_peer_cfg: pointer of peer's saved configuration options
+** p_peer_cfg_bits : valid config in bitmap
+**
+** Returns TRUE if successful
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_GetCurrentConfig (UINT16 lcid,
+ tL2CAP_CFG_INFO **pp_our_cfg, tL2CAP_CH_CFG_BITS *p_our_cfg_bits,
+ tL2CAP_CFG_INFO **pp_peer_cfg, tL2CAP_CH_CFG_BITS *p_peer_cfg_bits);
+#endif ///CLASSIC_BT_INCLUDED == TRUE
+
+
+#if (BLE_INCLUDED == TRUE)
+/*******************************************************************************
+**
+** Function L2CA_CancelBleConnectReq
+**
+** Description Cancel a pending connection attempt to a BLE device.
+**
+** Parameters: BD Address of remote
+**
+** Return value: TRUE if connection was cancelled
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda);
+
+/*******************************************************************************
+**
+** Function L2CA_UpdateBleConnParams
+**
+** Description Update BLE connection parameters.
+**
+** Parameters: BD Address of remote
+**
+** Return value: TRUE if update started
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bdRa, UINT16 min_int,
+ UINT16 max_int, UINT16 latency, UINT16 timeout);
+
+/*******************************************************************************
+**
+** Function L2CA_EnableUpdateBleConnParams
+**
+** Description Update BLE connection parameters.
+**
+** Parameters: BD Address of remote
+** enable flag
+**
+** Return value: TRUE if update started
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable);
+
+/*******************************************************************************
+**
+** Function L2CA_GetBleConnRole
+**
+** Description This function returns the connection role.
+**
+** Returns link role.
+**
+*******************************************************************************/
+extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function L2CA_BleDisconnect
+**
+** Description This function use to disconnect LE connection.
+**
+** Parameters BD Address of remote
+**
+** Returns TRUE if disconnect successfully.
+**
+*******************************************************************************/
+extern BOOLEAN L2CA_BleDisconnect (BD_ADDR rem_bda);
+#endif /* (BLE_INCLUDED == TRUE) */
+
+/*******************************************************************************
+**
+** Function L2CA_GetDisconnectReason
+**
+** Description This function returns the disconnect reason code.
+**
+** Parameters: BD Address of remote
+** Physical transport for the L2CAP connection (BR/EDR or LE)
+**
+** Returns disconnect reason
+**
+*******************************************************************************/
+extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport);
+
+extern BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, BD_ADDR addr);
+
+#define L2CA_GET_ATT_NUM 0
+#define L2CA_ADD_BTC_NUM 1
+#define L2CA_DECREASE_BTC_NUM 2
+#define L2CA_ADD_BTU_NUM 3
+#define L2CA_DECREASE_BTU_NUM 4
+#define L2CA_BUFF_INI 5
+#define L2CA_BUFF_DEINIT 6
+#define L2CA_BUFF_FREE 7
+
+typedef struct {
+ UINT16 conn_id;
+ UINT16 * get_num;
+} tl2c_buff_param_t;
+
+
+extern void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* L2C_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/l2cap_client.h b/lib/bt/host/bluedroid/stack/include/stack/l2cap_client.h
new file mode 100644
index 00000000..d18be32c
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/l2cap_client.h
@@ -0,0 +1,80 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef _L2CAP_CLIENT_H_
+#define _L2CAP_CLIENT_H_
+#if (defined(L2CAP_CLIENT_INCLUDED) && L2CAP_CLIENT_INCLUDED == TRUE)
+
+//#include <hardware/bluetooth.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+typedef struct buffer_t buffer_t;
+typedef struct l2cap_client_t l2cap_client_t;
+
+typedef struct {
+ void (*connected)(l2cap_client_t *client, void *context);
+ void (*disconnected)(l2cap_client_t *client, void *context);
+ void (*read_ready)(l2cap_client_t *client, buffer_t *packet, void *context);
+ void (*write_ready)(l2cap_client_t *client, void *context);
+} l2cap_client_callbacks_t;
+
+// Returns a new buffer with enough space for |size| bytes of L2CAP payload.
+// |size| must be greater than zero. This function returns NULL if the buffer
+// could not be allocated. The returned buffer must be freed with |buffer_free|
+// when it is no longer needed.
+buffer_t *l2cap_buffer_new(size_t size);
+
+// Creates and returns a new L2CAP client object. |callbacks| must not be NULL and
+// must specify a set of functions that should be called back when events occur
+// on the L2CAP connection. |context| may be NULL and will be passed as the argument
+// to all callbacks in |l2cap_client_callbacks_t|. The returned object must be freed
+// with |l2cap_client_free|.
+l2cap_client_t *l2cap_client_new(const l2cap_client_callbacks_t *callbacks, void *context);
+
+// Frees the L2CAP client object allocated with |l2cap_client_new|. |client| may be NULL.
+void l2cap_client_free(l2cap_client_t *client);
+
+// Attempts to connect the |client| to a peer device specified by |remote_bdaddr|
+// using the |psm| protocol specifier. This function returns true if the connect
+// operation could be started and will indicate completion with either a 'connected'
+// callback (success) or a 'disconnected' callback (failure).
+//
+// This function must not be called while a connect operation is in progress or
+// while |l2cap_client_is_connected|. |client| and |remote_bdaddr| must not be NULL.
+// |psm| must be greater than zero.
+bool l2cap_client_connect(l2cap_client_t *client, const bt_bdaddr_t *remote_bdaddr, uint16_t psm);
+
+// Disconnects a connected |client|. This function is asynchronous and idempotent. It
+// will indicate completion with a 'disconnected' callback. |client| must not be NULL.
+void l2cap_client_disconnect(l2cap_client_t *client);
+
+// Returns true if |client| is connected and is ready to accept data written to it.
+// |client| must not be NULL.
+bool l2cap_client_is_connected(const l2cap_client_t *client);
+
+// Writes data contained in |packet| to a connected |client|. This function returns
+// true if the packet was successfully queued for delivery, false if the client cannot
+// accept more data at this time. If this function returns false, the caller must wait
+// for the 'write_ready' callback to write additional data to the client. Neither
+// |client| nor |packet| may be NULL.
+bool l2cap_client_write(l2cap_client_t *client, buffer_t *packet);
+
+#endif ///(defined(L2CAP_CLIENT_INCLUDED) && L2CAP_CLIENT_INCLUDED == TRUE)
+
+#endif /*_L2CAP_CLIENT_H_*/
diff --git a/lib/bt/host/bluedroid/stack/include/stack/l2cap_hci_link_interface.h b/lib/bt/host/bluedroid/stack/include/stack/l2cap_hci_link_interface.h
new file mode 100644
index 00000000..61e1daac
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/l2cap_hci_link_interface.h
@@ -0,0 +1,15 @@
+/*
+ * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef L2CAP_HCI_LINK_INTERFACE_H
+#define L2CAP_HCI_LINK_INTERFACE_H
+
+#include "bt_common.h"
+
+extern BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda);
+extern BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason);
+
+#endif /* L2CAP_HCI_LINK_INTERFACE_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/l2cdefs.h b/lib/bt/host/bluedroid/stack/include/stack/l2cdefs.h
new file mode 100644
index 00000000..1572a37d
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/l2cdefs.h
@@ -0,0 +1,336 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef L2CDEFS_H
+#define L2CDEFS_H
+
+/* L2CAP command codes
+*/
+#define L2CAP_CMD_REJECT 0x01
+#define L2CAP_CMD_CONN_REQ 0x02
+#define L2CAP_CMD_CONN_RSP 0x03
+#define L2CAP_CMD_CONFIG_REQ 0x04
+#define L2CAP_CMD_CONFIG_RSP 0x05
+#define L2CAP_CMD_DISC_REQ 0x06
+#define L2CAP_CMD_DISC_RSP 0x07
+#define L2CAP_CMD_ECHO_REQ 0x08
+#define L2CAP_CMD_ECHO_RSP 0x09
+#define L2CAP_CMD_INFO_REQ 0x0A
+#define L2CAP_CMD_INFO_RSP 0x0B
+#define L2CAP_CMD_AMP_CONN_REQ 0x0C
+#define L2CAP_CMD_AMP_CONN_RSP 0x0D
+#define L2CAP_CMD_AMP_MOVE_REQ 0x0E
+#define L2CAP_CMD_AMP_MOVE_RSP 0x0F
+#define L2CAP_CMD_AMP_MOVE_CFM 0x10
+#define L2CAP_CMD_AMP_MOVE_CFM_RSP 0x11
+
+#define L2CAP_CMD_BLE_UPDATE_REQ 0x12
+#define L2CAP_CMD_BLE_UPDATE_RSP 0x13
+#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ 0x14
+#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES 0x15
+#define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT 0x16
+
+
+
+/* Define some packet and header lengths
+*/
+#define L2CAP_PKT_OVERHEAD 4 /* Length and CID */
+#define L2CAP_CMD_OVERHEAD 4 /* Cmd code, Id and length */
+#define L2CAP_CMD_REJECT_LEN 2 /* Reason (data is optional) */
+#define L2CAP_CONN_REQ_LEN 4 /* PSM and source CID */
+#define L2CAP_CONN_RSP_LEN 8 /* Dest CID, source CID, reason, status */
+#define L2CAP_CONFIG_REQ_LEN 4 /* Dest CID, flags (data is optional) */
+#define L2CAP_CONFIG_RSP_LEN 6 /* Dest CID, flags, result,data optional*/
+#define L2CAP_DISC_REQ_LEN 4 /* Dest CID, source CID */
+#define L2CAP_DISC_RSP_LEN 4 /* Dest CID, source CID */
+#define L2CAP_ECHO_REQ_LEN 0 /* Data is optional */
+#define L2CAP_ECHO_RSP_LEN 0 /* Data is optional */
+#define L2CAP_INFO_REQ_LEN 2 /* Info type */
+#define L2CAP_INFO_RSP_LEN 4 /* Info type, result (data is optional) */
+#define L2CAP_BCST_OVERHEAD 2 /* Additional broadcast packet overhead */
+#define L2CAP_UCD_OVERHEAD 2 /* Additional connectionless packet overhead */
+
+#define L2CAP_AMP_CONN_REQ_LEN 5 /* PSM, CID, and remote controller ID */
+#define L2CAP_AMP_MOVE_REQ_LEN 3 /* CID and remote controller ID */
+#define L2CAP_AMP_MOVE_RSP_LEN 4 /* CID and result */
+#define L2CAP_AMP_MOVE_CFM_LEN 4 /* CID and result */
+#define L2CAP_AMP_MOVE_CFM_RSP_LEN 2 /* CID */
+
+#define L2CAP_CMD_BLE_UPD_REQ_LEN 8 /* Min and max interval, latency, tout */
+#define L2CAP_CMD_BLE_UPD_RSP_LEN 2 /* Result */
+
+#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ_LEN 10 /* LE_PSM, SCID, MTU, MPS, Init Credit */
+#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN 10 /* DCID, MTU, MPS, Init credit, Result */
+#define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT_LEN 4 /* CID, Credit */
+
+
+
+/* Define the packet boundary flags
+*/
+#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
+#define L2CAP_PKT_START_FLUSHABLE 2
+#define L2CAP_PKT_START_NON_FLUSHABLE 0
+#endif
+#define L2CAP_COMPLETE_AMP_PKT 3 /* complete L2CAP packet on AMP HCI */
+#define L2CAP_PKT_START 2
+#define L2CAP_PKT_CONTINUE 1
+#define L2CAP_MASK_FLAG 0x0FFF
+#define L2CAP_PKT_TYPE_SHIFT 12
+#define L2CAP_PKT_TYPE_MASK 3
+
+
+/* Define the L2CAP connection result codes
+*/
+#define L2CAP_CONN_OK 0
+#define L2CAP_CONN_PENDING 1
+#define L2CAP_CONN_NO_PSM 2
+#define L2CAP_CONN_SECURITY_BLOCK 3
+#define L2CAP_CONN_NO_RESOURCES 4
+#define L2CAP_CONN_BAD_CTLR_ID 5 /* AMP related */
+#define L2CAP_CONN_TIMEOUT 0xEEEE
+#define L2CAP_CONN_AMP_FAILED 254
+#define L2CAP_CONN_NO_LINK 255 /* Add a couple of our own for internal use */
+#define L2CAP_CONN_CANCEL 256 /* L2CAP connection cancelled */
+
+
+/* Define L2CAP Move Channel Response result codes
+*/
+#define L2CAP_MOVE_OK 0
+#define L2CAP_MOVE_PENDING 1
+#define L2CAP_MOVE_CTRL_ID_NOT_SUPPORT 2
+#define L2CAP_MOVE_SAME_CTRLR_ID 3
+#define L2CAP_MOVE_CONFIG_NOT_SUPPORTED 4
+#define L2CAP_MOVE_CHAN_COLLISION 5
+#define L2CAP_MOVE_NOT_ALLOWED 6
+
+
+/* Define L2CAP Move Channel Confirmation result codes
+*/
+#define L2CAP_MOVE_CFM_OK 0
+#define L2CAP_MOVE_CFM_REFUSED 1
+
+
+/* Define the L2CAP command reject reason codes
+*/
+#define L2CAP_CMD_REJ_NOT_UNDERSTOOD 0
+#define L2CAP_CMD_REJ_MTU_EXCEEDED 1
+#define L2CAP_CMD_REJ_INVALID_CID 2
+
+
+/* L2CAP Predefined CIDs
+*/
+#define L2CAP_SIGNALLING_CID 1
+#define L2CAP_CONNECTIONLESS_CID 2
+#define L2CAP_AMP_CID 3
+#define L2CAP_ATT_CID 4
+#define L2CAP_BLE_SIGNALLING_CID 5
+#define L2CAP_SMP_CID 6
+#define L2CAP_SMP_BR_CID 7
+#define L2CAP_AMP_TEST_CID 0x003F
+#define L2CAP_BASE_APPL_CID 0x0040
+#define L2CAP_BLE_CONN_MAX_CID 0x007F
+
+/* Fixed Channels mask bits */
+
+/* Signal channel supported (Mandatory) */
+#define L2CAP_FIXED_CHNL_SIG_BIT (1 << L2CAP_SIGNALLING_CID)
+
+/* Connectionless reception */
+#define L2CAP_FIXED_CHNL_CNCTLESS_BIT (1 << L2CAP_CONNECTIONLESS_CID)
+
+/* AMP Manager supported */
+#define L2CAP_FIXED_CHNL_AMP_BIT (1 << L2CAP_AMP_CID)
+
+/* Attribute protocol supported */
+#define L2CAP_FIXED_CHNL_ATT_BIT (1 << L2CAP_ATT_CID)
+
+/* BLE Signalling supported */
+#define L2CAP_FIXED_CHNL_BLE_SIG_BIT (1 << L2CAP_BLE_SIGNALLING_CID)
+
+/* BLE Security Mgr supported */
+#define L2CAP_FIXED_CHNL_SMP_BIT (1 << L2CAP_SMP_CID)
+
+/* Security Mgr over BR supported */
+#define L2CAP_FIXED_CHNL_SMP_BR_BIT (1 << L2CAP_SMP_BR_CID)
+
+
+
+/* Define the L2CAP configuration result codes
+*/
+#define L2CAP_CFG_OK 0
+#define L2CAP_CFG_UNACCEPTABLE_PARAMS 1
+#define L2CAP_CFG_FAILED_NO_REASON 2
+#define L2CAP_CFG_UNKNOWN_OPTIONS 3
+#define L2CAP_CFG_PENDING 4
+#define L2CAP_CFG_FLOW_SPEC_REJECTED 5
+
+
+/* Define the L2CAP configuration option types
+*/
+#define L2CAP_CFG_TYPE_MTU 0x01
+#define L2CAP_CFG_TYPE_FLUSH_TOUT 0x02
+#define L2CAP_CFG_TYPE_QOS 0x03
+#define L2CAP_CFG_TYPE_FCR 0x04
+#define L2CAP_CFG_TYPE_FCS 0x05
+#define L2CAP_CFG_TYPE_EXT_FLOW 0x06
+#define L2CAP_CFG_TYPE_EXT_WIN_SIZE 0x07
+
+#define L2CAP_CFG_MTU_OPTION_LEN 2 /* MTU option length */
+#define L2CAP_CFG_FLUSH_OPTION_LEN 2 /* Flush option len */
+#define L2CAP_CFG_QOS_OPTION_LEN 22 /* QOS option length */
+#define L2CAP_CFG_FCR_OPTION_LEN 9 /* FCR option length */
+#define L2CAP_CFG_FCS_OPTION_LEN 1 /* FCR option length */
+#define L2CAP_CFG_EXT_FLOW_OPTION_LEN 16 /* Extended Flow Spec */
+#define L2CAP_CFG_EXT_WIN_SIZE_LEN 2 /* Ext window size length */
+#define L2CAP_CFG_OPTION_OVERHEAD 2 /* Type and length */
+
+/* Configuration Cmd/Rsp Flags mask
+*/
+#define L2CAP_CFG_FLAGS_MASK_CONT 0x0001 /* Flags mask: Continuation */
+
+/* FCS Check Option values
+*/
+#define L2CAP_CFG_FCS_BYPASS 0 /* Bypass the FCS in streaming or ERTM modes */
+#define L2CAP_CFG_FCS_USE 1 /* Use the FCS in streaming or ERTM modes [default] */
+
+/* Default values for configuration
+*/
+#define L2CAP_NO_AUTOMATIC_FLUSH 0xFFFF
+#define L2CAP_NO_RETRANSMISSION 0x0001
+
+#define L2CAP_DEFAULT_MTU (672)
+#define L2CAP_DEFAULT_FLUSH_TO L2CAP_NO_AUTOMATIC_FLUSH
+#define L2CAP_DEFAULT_SERV_TYPE 1
+#define L2CAP_DEFAULT_TOKEN_RATE 0
+#define L2CAP_DEFAULT_BUCKET_SIZE 0
+#define L2CAP_DEFAULT_PEAK_BANDWIDTH 0
+#define L2CAP_DEFAULT_LATENCY 0xFFFFFFFF
+#define L2CAP_DEFAULT_DELAY 0xFFFFFFFF
+#define L2CAP_DEFAULT_FCS L2CAP_CFG_FCS_USE
+
+
+/* Define the L2CAP disconnect result codes
+*/
+#define L2CAP_DISC_OK 0
+#define L2CAP_DISC_TIMEOUT 0xEEEE
+
+/* Define the L2CAP info resp result codes
+*/
+#define L2CAP_INFO_RESP_RESULT_SUCCESS 0
+#define L2CAP_INFO_RESP_RESULT_NOT_SUPPORTED 1
+
+/* Define the info-type fields of information request & response
+*/
+#define L2CAP_CONNLESS_MTU_INFO_TYPE 0x0001
+#define L2CAP_EXTENDED_FEATURES_INFO_TYPE 0x0002 /* Used in Information Req/Response */
+#define L2CAP_FIXED_CHANNELS_INFO_TYPE 0x0003 /* Used in AMP */
+
+#define L2CAP_CONNLESS_MTU_INFO_SIZE 2 /* Connectionless MTU size */
+#define L2CAP_EXTENDED_FEATURES_ARRAY_SIZE 4 /* Extended features array size */
+#define L2CAP_FIXED_CHNL_ARRAY_SIZE 8 /* Fixed channel array size */
+
+/* Extended features mask bits
+*/
+#define L2CAP_EXTFEA_RTRANS 0x00000001 /* Retransmission Mode (Not Supported) */
+#define L2CAP_EXTFEA_FC 0x00000002 /* Flow Control Mode (Not Supported) */
+#define L2CAP_EXTFEA_QOS 0x00000004
+#define L2CAP_EXTFEA_ENH_RETRANS 0x00000008 /* Enhanced retransmission mode */
+#define L2CAP_EXTFEA_STREAM_MODE 0x00000010 /* Streaming Mode */
+#define L2CAP_EXTFEA_NO_CRC 0x00000020 /* Optional FCS (if set No FCS desired) */
+#define L2CAP_EXTFEA_EXT_FLOW_SPEC 0x00000040 /* Extended flow spec */
+#define L2CAP_EXTFEA_FIXED_CHNLS 0x00000080 /* Fixed channels */
+#define L2CAP_EXTFEA_EXT_WINDOW 0x00000100 /* Extended Window Size */
+#define L2CAP_EXTFEA_UCD_RECEPTION 0x00000200 /* Unicast Connectionless Data Reception */
+
+/* Mask for LE supported features used in Information Response (default to none) */
+#ifndef L2CAP_BLE_EXTFEA_MASK
+#define L2CAP_BLE_EXTFEA_MASK 0
+#endif
+
+/* Define a value that tells L2CAP to use the default HCI ACL buffer size */
+#define L2CAP_INVALID_ERM_BUF_SIZE 0
+
+/* Define a value that tells L2CAP to use the default MPS */
+#define L2CAP_DEFAULT_ERM_MPS 0x0000
+
+#define L2CAP_FCR_OVERHEAD 2 /* Control word */
+#define L2CAP_FCS_LEN 2 /* FCS takes 2 bytes */
+#define L2CAP_SDU_LEN_OVERHEAD 2 /* SDU length field is 2 bytes */
+#define L2CAP_SDU_LEN_OFFSET 2 /* SDU length offset is 2 bytes */
+#define L2CAP_EXT_CONTROL_OVERHEAD 4 /* Extended Control Field */
+#define L2CAP_MAX_HEADER_FCS (L2CAP_PKT_OVERHEAD + L2CAP_EXT_CONTROL_OVERHEAD + L2CAP_SDU_LEN_OVERHEAD + L2CAP_FCS_LEN)
+/* length(2), channel(2), control(4), SDU length(2) FCS(2) */
+/* To optimize this, it must be a multiplum of the L2CAP PDU length AND match the 3DH5 air
+ * including the l2cap headers in each packet - to match the latter - the -5 is added
+ */
+#define L2CAP_MAX_SDU_LENGTH (8080 + 26 - (L2CAP_MIN_OFFSET + 6))
+#define L2CAP_MAX_BUF_SIZE (10240 + 24)
+
+/* Part of L2CAP_MIN_OFFSET that is not part of L2CAP
+*/
+#define L2CAP_OFFSET_WO_L2HDR (L2CAP_MIN_OFFSET-(L2CAP_PKT_OVERHEAD+L2CAP_FCR_OVERHEAD))
+
+/* SAR bits in the control word
+*/
+#define L2CAP_FCR_UNSEG_SDU 0x0000 /* Control word to begin with for unsegmented PDU*/
+#define L2CAP_FCR_START_SDU 0x4000 /* ...for Starting PDU of a semented SDU */
+#define L2CAP_FCR_END_SDU 0x8000 /* ...for ending PDU of a segmented SDU */
+#define L2CAP_FCR_CONT_SDU 0xc000 /* ...for continuation PDU of a segmented SDU */
+
+/* Supervisory frame types
+*/
+#define L2CAP_FCR_SUP_RR 0x0000 /* Supervisory frame - RR */
+#define L2CAP_FCR_SUP_REJ 0x0001 /* Supervisory frame - REJ */
+#define L2CAP_FCR_SUP_RNR 0x0002 /* Supervisory frame - RNR */
+#define L2CAP_FCR_SUP_SREJ 0x0003 /* Supervisory frame - SREJ */
+
+#define L2CAP_FCR_SAR_BITS 0xC000 /* Mask to get the SAR bits from control word */
+#define L2CAP_FCR_SAR_BITS_SHIFT 14 /* Bits to shift right to get the SAR bits from ctrl-word */
+
+#define L2CAP_FCR_S_FRAME_BIT 0x0001 /* Mask to check if a PDU is S-frame */
+#define L2CAP_FCR_REQ_SEQ_BITS 0x3F00 /* Mask to get the req-seq from control word */
+#define L2CAP_FCR_REQ_SEQ_BITS_SHIFT 8 /* Bits to shift right to get the req-seq from ctrl-word */
+#define L2CAP_FCR_TX_SEQ_BITS 0x007E /* Mask on get the tx-seq from control word */
+#define L2CAP_FCR_TX_SEQ_BITS_SHIFT 1 /* Bits to shift right to get the tx-seq from ctrl-word */
+
+#define L2CAP_FCR_F_BIT 0x0080 /* F-bit in the control word (Sup and I frames) */
+#define L2CAP_FCR_P_BIT 0x0010 /* P-bit in the control word (Sup frames only) */
+
+#define L2CAP_FCR_F_BIT_SHIFT 7
+#define L2CAP_FCR_P_BIT_SHIFT 4
+
+#define L2CAP_FCR_SEG_BITS 0xC000 /* Mask to get the segmentation bits from ctrl-word */
+#define L2CAP_FCR_SUP_SHIFT 2 /* Bits to shift right to get the S-bits from ctrl-word */
+#define L2CAP_FCR_SUP_BITS 0x000C /* Mask to get the supervisory bits from ctrl-word */
+
+#define L2CAP_FCR_INIT_CRC 0 /* Initial state of the CRC register */
+#define L2CAP_FCR_SEQ_MODULO 0x3F /* Mask for sequence numbers (range 0 - 63) */
+
+#define L2CAP_LE_RESULT_CONN_OK 0
+#define L2CAP_LE_RESULT_NO_PSM 2
+#define L2CAP_LE_RESULT_NO_RESOURCES 4
+#define L2CAP_LE_RESULT_INSUFFICIENT_AUTHENTICATION 5
+#define L2CAP_LE_RESULT_INSUFFICIENT_AUTHORIZATION 6
+#define L2CAP_LE_RESULT_INSUFFICIENT_ENCRY_KEY_SIZE 7
+#define L2CAP_LE_RESULT_INSUFFICIENT_ENCRY 8
+#define L2CAP_LE_RESULT_INVALID_SOURCE_CID 9
+#define L2CAP_LE_RESULT_SOURCE_CID_ALREADY_ALLOCATED 0x0A
+#define L2CAP_LE_RESULT_UNACCEPTABLE_PARAMETERS 0x0B
+#define L2CAP_LE_RESULT_INVALID_PARAMETERS 0x0C
+
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/port_api.h b/lib/bt/host/bluedroid/stack/include/stack/port_api.h
new file mode 100644
index 00000000..599cfaa3
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/port_api.h
@@ -0,0 +1,710 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * this file contains the PORT API definitions
+ *
+ ******************************************************************************/
+#ifndef PORT_API_H
+#define PORT_API_H
+
+#include "common/bt_target.h"
+#include "common/bt_defs.h"
+
+/*****************************************************************************
+** Constants and Types
+*****************************************************************************/
+
+/*
+** Define port settings structure send from the application in the
+** set settings request, or to the application in the set settings indication.
+*/
+typedef struct {
+
+#define PORT_BAUD_RATE_2400 0x00
+#define PORT_BAUD_RATE_4800 0x01
+#define PORT_BAUD_RATE_7200 0x02
+#define PORT_BAUD_RATE_9600 0x03
+#define PORT_BAUD_RATE_19200 0x04
+#define PORT_BAUD_RATE_38400 0x05
+#define PORT_BAUD_RATE_57600 0x06
+#define PORT_BAUD_RATE_115200 0x07
+#define PORT_BAUD_RATE_230400 0x08
+
+ UINT8 baud_rate;
+
+#define PORT_5_BITS 0x00
+#define PORT_6_BITS 0x01
+#define PORT_7_BITS 0x02
+#define PORT_8_BITS 0x03
+
+ UINT8 byte_size;
+
+#define PORT_ONESTOPBIT 0x00
+#define PORT_ONE5STOPBITS 0x01
+ UINT8 stop_bits;
+
+#define PORT_PARITY_NO 0x00
+#define PORT_PARITY_YES 0x01
+ UINT8 parity;
+
+#define PORT_ODD_PARITY 0x00
+#define PORT_EVEN_PARITY 0x01
+#define PORT_MARK_PARITY 0x02
+#define PORT_SPACE_PARITY 0x03
+
+ UINT8 parity_type;
+
+#define PORT_FC_OFF 0x00
+#define PORT_FC_XONXOFF_ON_INPUT 0x01
+#define PORT_FC_XONXOFF_ON_OUTPUT 0x02
+#define PORT_FC_CTS_ON_INPUT 0x04
+#define PORT_FC_CTS_ON_OUTPUT 0x08
+#define PORT_FC_DSR_ON_INPUT 0x10
+#define PORT_FC_DSR_ON_OUTPUT 0x20
+
+ UINT8 fc_type;
+
+ UINT8 rx_char1;
+
+#define PORT_XON_DC1 0x11
+ UINT8 xon_char;
+
+#define PORT_XOFF_DC3 0x13
+ UINT8 xoff_char;
+
+} tPORT_STATE;
+
+
+/*
+** Define the callback function prototypes. Parameters are specific
+** to each event and are described bellow
+*/
+typedef int (tPORT_DATA_CALLBACK) (UINT16 port_handle, void *p_data, UINT16 len);
+
+#define DATA_CO_CALLBACK_TYPE_INCOMING 1
+#define DATA_CO_CALLBACK_TYPE_OUTGOING_SIZE 2
+#define DATA_CO_CALLBACK_TYPE_OUTGOING 3
+typedef int (tPORT_DATA_CO_CALLBACK) (UINT16 port_handle, UINT8 *p_buf, UINT16 len, int type);
+
+typedef void (tPORT_CALLBACK) (UINT32 code, UINT16 port_handle);
+
+typedef void (tPORT_MGMT_CALLBACK) (UINT32 code, UINT16 port_handle, void* data);
+
+/**
+ * Define the server port manage callback function argument
+ */
+typedef struct {
+ BOOLEAN accept; /* If upper layer accepts the incoming connection */
+ BOOLEAN ignore_rfc_state; /* If need to ignore rfc state for PORT_CheckConnection */
+ UINT16 peer_mtu; /* Max MTU that port can send */
+} tPORT_MGMT_SR_CALLBACK_ARG;
+
+/**
+ * Define the client port manage callback function argument
+ */
+typedef struct {
+ UINT16 peer_mtu; /* Max MTU that port can send */
+} tPORT_MGMT_CL_CALLBACK_ARG;
+
+/*
+** Define events that registered application can receive in the callback
+*/
+
+#define PORT_EV_RXCHAR 0x00000001 /* Any Character received */
+#define PORT_EV_RXFLAG 0x00000002 /* Received certain character */
+#define PORT_EV_TXEMPTY 0x00000004 /* Transmitt Queue Empty */
+#define PORT_EV_CTS 0x00000008 /* CTS changed state */
+#define PORT_EV_DSR 0x00000010 /* DSR changed state */
+#define PORT_EV_RLSD 0x00000020 /* RLSD changed state */
+#define PORT_EV_BREAK 0x00000040 /* BREAK received */
+#define PORT_EV_ERR 0x00000080 /* Line status error occurred */
+#define PORT_EV_RING 0x00000100 /* Ring signal detected */
+#define PORT_EV_CTSS 0x00000400 /* CTS state */
+#define PORT_EV_DSRS 0x00000800 /* DSR state */
+#define PORT_EV_RLSDS 0x00001000 /* RLSD state */
+#define PORT_EV_OVERRUN 0x00002000 /* receiver buffer overrun */
+#define PORT_EV_TXCHAR 0x00004000 /* Any character transmitted */
+
+#define PORT_EV_CONNECTED 0x00000200 /* RFCOMM connection established */
+#define PORT_EV_CONNECT_ERR 0x00008000 /* Was not able to establish connection */
+/* or disconnected */
+#define PORT_EV_FC 0x00010000 /* data flow enabled flag changed by remote */
+#define PORT_EV_FCS 0x00020000 /* data flow enable status true = enabled */
+
+/*
+** To register for events application should provide bitmask with
+** corresponding bit set
+*/
+
+#define PORT_MASK_ALL (PORT_EV_RXCHAR | PORT_EV_TXEMPTY | PORT_EV_CTS | \
+ PORT_EV_DSR | PORT_EV_RLSD | PORT_EV_BREAK | \
+ PORT_EV_ERR | PORT_EV_RING | PORT_EV_CONNECT_ERR | \
+ PORT_EV_DSRS | PORT_EV_CTSS | PORT_EV_RLSDS | \
+ PORT_EV_RXFLAG | PORT_EV_TXCHAR | PORT_EV_OVERRUN | \
+ PORT_EV_FC | PORT_EV_FCS | PORT_EV_CONNECTED)
+
+
+/*
+** Define port result codes
+*/
+#define PORT_SUCCESS 0
+
+#define PORT_ERR_BASE 0
+
+#define PORT_UNKNOWN_ERROR (PORT_ERR_BASE + 1)
+#define PORT_ALREADY_OPENED (PORT_ERR_BASE + 2)
+#define PORT_CMD_PENDING (PORT_ERR_BASE + 3)
+#define PORT_APP_NOT_REGISTERED (PORT_ERR_BASE + 4)
+#define PORT_NO_MEM (PORT_ERR_BASE + 5)
+#define PORT_NO_RESOURCES (PORT_ERR_BASE + 6)
+#define PORT_BAD_BD_ADDR (PORT_ERR_BASE + 7)
+#define PORT_BAD_HANDLE (PORT_ERR_BASE + 9)
+#define PORT_NOT_OPENED (PORT_ERR_BASE + 10)
+#define PORT_LINE_ERR (PORT_ERR_BASE + 11)
+#define PORT_START_FAILED (PORT_ERR_BASE + 12)
+#define PORT_PAR_NEG_FAILED (PORT_ERR_BASE + 13)
+#define PORT_PORT_NEG_FAILED (PORT_ERR_BASE + 14)
+#define PORT_SEC_FAILED (PORT_ERR_BASE + 15)
+#define PORT_PEER_CONNECTION_FAILED (PORT_ERR_BASE + 16)
+#define PORT_PEER_FAILED (PORT_ERR_BASE + 17)
+#define PORT_PEER_TIMEOUT (PORT_ERR_BASE + 18)
+#define PORT_CLOSED (PORT_ERR_BASE + 19)
+#define PORT_TX_FULL (PORT_ERR_BASE + 20)
+#define PORT_LOCAL_CLOSED (PORT_ERR_BASE + 21)
+#define PORT_LOCAL_TIMEOUT (PORT_ERR_BASE + 22)
+#define PORT_TX_QUEUE_DISABLED (PORT_ERR_BASE + 23)
+#define PORT_PAGE_TIMEOUT (PORT_ERR_BASE + 24)
+#define PORT_INVALID_SCN (PORT_ERR_BASE + 25)
+
+#define PORT_ERR_MAX (PORT_ERR_BASE + 26)
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function RFCOMM_CreateConnection
+**
+** Description RFCOMM_CreateConnection function is used from the application
+** to establish serial port connection to the peer device,
+** or allow RFCOMM to accept a connection from the peer
+** application.
+**
+** Parameters: scn - Service Channel Number as registered with
+** the SDP (server) or obtained using SDP from
+** the peer device (client).
+** is_server - TRUE if requesting application is a server
+** mtu - Maximum frame size the application can accept
+** bd_addr - BD_ADDR of the peer (client)
+** mask - specifies events to be enabled. A value
+** of zero disables all events.
+** p_handle - OUT pointer to the handle.
+** p_mgmt_cb - pointer to callback function to receive
+** connection up/down events.
+** Notes:
+**
+** Server can call this function with the same scn parameter multiple times if
+** it is ready to accept multiple simulteneous connections.
+**
+** DLCI for the connection is (scn * 2 + 1) if client originates connection on
+** existing none initiator multiplexer channel. Otherwise it is (scn * 2).
+** For the server DLCI can be changed later if client will be calling it using
+** (scn * 2 + 1) dlci.
+**
+*******************************************************************************/
+extern int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn,
+ BOOLEAN is_server, UINT16 mtu,
+ BD_ADDR bd_addr, UINT16 *p_handle,
+ tPORT_MGMT_CALLBACK *p_mgmt_cb);
+
+
+/*******************************************************************************
+**
+** Function RFCOMM_RemoveConnection
+**
+** Description This function is called to close the specified connection.
+**
+** Parameters: handle - Handle of the port returned in the Open
+**
+*******************************************************************************/
+extern int RFCOMM_RemoveConnection (UINT16 handle);
+
+
+/*******************************************************************************
+**
+** Function RFCOMM_RemoveServer
+**
+** Description This function is called to close the server port.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+**
+*******************************************************************************/
+extern int RFCOMM_RemoveServer (UINT16 handle);
+
+
+/*******************************************************************************
+**
+** Function PORT_SetEventCallback
+**
+** Description Set event callback the specified connection.
+**
+** Parameters: handle - Handle of the port returned in the Open
+** p_callback - address of the callback function which should
+** be called from the RFCOMM when an event
+** specified in the mask occurs.
+**
+*******************************************************************************/
+extern int PORT_SetEventCallback (UINT16 port_handle,
+ tPORT_CALLBACK *p_port_cb);
+
+/*******************************************************************************
+**
+** Function PORT_ClearKeepHandleFlag
+**
+** Description This function is called to clear the keep handle flag
+** which will cause not to keep the port handle open when closed
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+**
+*******************************************************************************/
+int PORT_ClearKeepHandleFlag (UINT16 port_handle);
+
+/*******************************************************************************
+**
+** Function PORT_SetEventCallback
+**
+** Description Set event data callback the specified connection.
+**
+** Parameters: handle - Handle of the port returned in the Open
+** p_callback - address of the callback function which should
+** be called from the RFCOMM when a data
+** packet is received.
+**
+*******************************************************************************/
+extern int PORT_SetDataCallback (UINT16 port_handle,
+ tPORT_DATA_CALLBACK *p_cb);
+
+extern int PORT_SetDataCOCallback (UINT16 port_handle, tPORT_DATA_CO_CALLBACK *p_port_cb);
+/*******************************************************************************
+**
+** Function PORT_SetEventMask
+**
+** Description This function is called to close the specified connection.
+**
+** Parameters: handle - Handle of the port returned in the Open
+** mask - specifies events to be enabled. A value
+** of zero disables all events.
+**
+*******************************************************************************/
+extern int PORT_SetEventMask (UINT16 port_handle, UINT32 mask);
+
+
+/*******************************************************************************
+**
+** Function PORT_CheckConnection
+**
+** Description This function returns PORT_SUCCESS if connection referenced
+** by handle is up and running
+**
+** Parameters: handle - Handle of the port returned in the Open
+** ignore_rfc_state - If need to ignore rfc state
+** bd_addr - OUT bd_addr of the peer
+** p_lcid - OUT L2CAP's LCID
+**
+*******************************************************************************/
+extern int PORT_CheckConnection (UINT16 handle, BOOLEAN ignore_rfc_state, BD_ADDR bd_addr,
+ UINT16 *p_lcid);
+
+/*******************************************************************************
+**
+** Function PORT_IsOpening
+**
+** Description This function returns TRUE if there is any RFCOMM connection
+** opening in process.
+**
+** Parameters: TRUE if any connection opening is found
+** bd_addr - bd_addr of the peer
+**
+*******************************************************************************/
+extern BOOLEAN PORT_IsOpening (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function PORT_SetState
+**
+** Description This function configures connection according to the
+** specifications in the tPORT_STATE structure.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** p_settings - Pointer to a tPORT_STATE structure containing
+** configuration information for the connection.
+**
+*******************************************************************************/
+extern int PORT_SetState (UINT16 handle, tPORT_STATE *p_settings);
+
+/*******************************************************************************
+**
+** Function PORT_GetRxQueueCnt
+**
+** Description This function return number of buffers on the rx queue.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** p_rx_queue_count - Pointer to return queue count in.
+**
+*******************************************************************************/
+extern int PORT_GetRxQueueCnt (UINT16 handle, UINT16 *p_rx_queue_count);
+
+/*******************************************************************************
+**
+** Function PORT_GetState
+**
+** Description This function is called to fill tPORT_STATE structure
+** with the current control settings for the port
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** p_settings - Pointer to a tPORT_STATE structure in which
+** configuration information is returned.
+**
+*******************************************************************************/
+extern int PORT_GetState (UINT16 handle, tPORT_STATE *p_settings);
+
+
+/*******************************************************************************
+**
+** Function PORT_Control
+**
+** Description This function directs a specified connection to pass control
+** control information to the peer device.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** signal - specify the function to be passed
+**
+*******************************************************************************/
+#define PORT_SET_DTRDSR 0x01
+#define PORT_CLR_DTRDSR 0x02
+#define PORT_SET_CTSRTS 0x03
+#define PORT_CLR_CTSRTS 0x04
+#define PORT_SET_RI 0x05 /* DCE only */
+#define PORT_CLR_RI 0x06 /* DCE only */
+#define PORT_SET_DCD 0x07 /* DCE only */
+#define PORT_CLR_DCD 0x08 /* DCE only */
+#define PORT_BREAK 0x09 /* Break event */
+
+extern int PORT_Control (UINT16 handle, UINT8 signal);
+
+
+/*******************************************************************************
+**
+** Function PORT_FlowControl
+**
+** Description This function directs a specified connection to pass
+** flow control message to the peer device. Enable flag passed
+** shows if port can accept more data.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** enable - enables data flow
+**
+*******************************************************************************/
+extern int PORT_FlowControl (UINT16 handle, BOOLEAN enable);
+
+/*******************************************************************************
+**
+** Function PORT_FlowControl_GiveCredit
+**
+** Description This function gives specified credits to the peer
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** enable - enables data flow
+** credits_given - credits to give
+**
+*******************************************************************************/
+extern int PORT_FlowControl_GiveCredit (UINT16 handle, BOOLEAN enable, UINT16 credits_given);
+/*******************************************************************************
+**
+** Function PORT_GetModemStatus
+**
+** Description This function retrieves modem control signals. Normally
+** application will call this function after a callback
+** function is called with notification that one of signals
+** has been changed.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** callback.
+** p_signal - specify the pointer to control signals info
+**
+*******************************************************************************/
+#define PORT_DTRDSR_ON 0x01
+#define PORT_CTSRTS_ON 0x02
+#define PORT_RING_ON 0x04
+#define PORT_DCD_ON 0x08
+
+/*
+** Define default initial local modem signals state set after connection established
+*/
+#define PORT_OBEX_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
+#define PORT_SPP_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
+#define PORT_PPP_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
+#define PORT_DUN_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON)
+
+extern int PORT_GetModemStatus (UINT16 handle, UINT8 *p_control_signal);
+
+
+/*******************************************************************************
+**
+** Function PORT_ClearError
+**
+** Description This function retreives information about a communications
+** error and reports current status of a connection. The
+** function should be called when an error occures to clear
+** the connection error flag and to enable additional read
+** and write operations.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** p_errors - pointer of the variable to receive error codes
+** p_status - pointer to the tPORT_STATUS structur to receive
+** connection status
+**
+*******************************************************************************/
+
+#define PORT_ERR_BREAK 0x01 /* Break condition occured on the peer device */
+#define PORT_ERR_OVERRUN 0x02 /* Overrun is reported by peer device */
+#define PORT_ERR_FRAME 0x04 /* Framing error reported by peer device */
+#define PORT_ERR_RXOVER 0x08 /* Input queue overflow occured */
+#define PORT_ERR_TXFULL 0x10 /* Output queue overflow occured */
+
+typedef struct {
+#define PORT_FLAG_CTS_HOLD 0x01 /* Tx is waiting for CTS signal */
+#define PORT_FLAG_DSR_HOLD 0x02 /* Tx is waiting for DSR signal */
+#define PORT_FLAG_RLSD_HOLD 0x04 /* Tx is waiting for RLSD signal */
+
+ UINT16 flags;
+ UINT16 in_queue_size; /* Number of bytes in the input queue */
+ UINT16 out_queue_size; /* Number of bytes in the output queue */
+ UINT16 mtu_size; /* peer MTU size */
+} tPORT_STATUS;
+
+
+extern int PORT_ClearError (UINT16 handle, UINT16 *p_errors,
+ tPORT_STATUS *p_status);
+
+
+/*******************************************************************************
+**
+** Function PORT_SendError
+**
+** Description This function send a communications error to the peer device
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** errors - receive error codes
+**
+*******************************************************************************/
+extern int PORT_SendError (UINT16 handle, UINT8 errors);
+
+
+/*******************************************************************************
+**
+** Function PORT_GetQueueStatus
+**
+** Description This function reports current status of a connection.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** p_status - pointer to the tPORT_STATUS structur to receive
+** connection status
+**
+*******************************************************************************/
+extern int PORT_GetQueueStatus (UINT16 handle, tPORT_STATUS *p_status);
+
+
+/*******************************************************************************
+**
+** Function PORT_Purge
+**
+** Description This function discards all the data from the output or
+** input queues of the specified connection.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** purge_flags - specify the action to take.
+**
+*******************************************************************************/
+#define PORT_PURGE_TXCLEAR 0x01
+#define PORT_PURGE_RXCLEAR 0x02
+
+extern int PORT_Purge (UINT16 handle, UINT8 purge_flags);
+
+
+/*******************************************************************************
+**
+** Function PORT_Read
+**
+** Description This function returns the pointer to the buffer received
+** from the peer device. Normally application will call this
+** function after receiving PORT_EVT_RXCHAR event.
+** Application calling this function is responsible to free
+** buffer returned.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** callback.
+** pp_buf - pointer to address of buffer with data,
+**
+*******************************************************************************/
+extern int PORT_Read (UINT16 handle, BT_HDR **pp_buf);
+
+
+/*******************************************************************************
+**
+** Function PORT_ReadData
+**
+** Description Normally application will call this function after receiving
+** PORT_EVT_RXCHAR event.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** callback.
+** p_data - Data area
+** max_len - Byte count requested
+** p_len - Byte count received
+**
+*******************************************************************************/
+extern int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len,
+ UINT16 *p_len);
+
+
+/*******************************************************************************
+**
+** Function PORT_Write
+**
+** Description This function to send BT buffer to the peer device.
+** Application should not free the buffer.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** p_buf - pointer to the buffer with data,
+**
+*******************************************************************************/
+extern int PORT_Write (UINT16 handle, BT_HDR *p_buf);
+
+
+/*******************************************************************************
+**
+** Function PORT_WriteData
+**
+** Description This function is called from the legacy application to
+** send data.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** p_data - Data area
+** max_len - Byte count to write
+** p_len - Bytes written
+**
+*******************************************************************************/
+extern int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len,
+ UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function PORT_WriteDataCO
+**
+** Description Normally not GKI aware application will call this function
+** to send data to the port by callout functions.
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+**
+*******************************************************************************/
+extern int PORT_WriteDataCO (UINT16 handle, int *p_len, int len, UINT8 *p_data);
+
+/*******************************************************************************
+**
+** Function PORT_Test
+**
+** Description Application can call this function to send RFCOMM Test frame
+**
+** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
+** p_data - Data area
+** max_len - Byte count requested
+**
+*******************************************************************************/
+extern int PORT_Test (UINT16 handle, UINT8 *p_data, UINT16 len);
+
+
+/*******************************************************************************
+**
+** Function RFCOMM_Init
+**
+** Description This function is called to initialize RFCOMM layer
+**
+*******************************************************************************/
+extern bt_status_t RFCOMM_Init (void);
+
+/*******************************************************************************
+**
+** Function RFCOMM_Deinit
+**
+** Description This function is called to deinitialize the control block
+** for this layer.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void RFCOMM_Deinit(void);
+
+/*******************************************************************************
+**
+** Function PORT_SetTraceLevel
+**
+** Description This function sets the trace level for RFCOMM. If called with
+** a value of 0xFF, it simply reads the current trace level.
+**
+** Returns the new (current) trace level
+**
+*******************************************************************************/
+extern UINT8 PORT_SetTraceLevel (UINT8 new_level);
+
+
+/*******************************************************************************
+**
+** Function PORT_GetResultString
+**
+** Description This function returns the human-readable string for a given
+** result code.
+**
+** Returns a pointer to the human-readable string for the given
+** result. Note that the string returned must not be freed.
+**
+*******************************************************************************/
+extern const char *PORT_GetResultString (const uint8_t result_code);
+
+/*******************************************************************************
+**
+** Function PORT_SetL2capErtm
+**
+** Description This function sets whether RFCOMM uses L2CAP ERTM.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void PORT_SetL2capErtm (BOOLEAN enable_l2cap_ertm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PORT_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/port_ext.h b/lib/bt/host/bluedroid/stack/include/stack/port_ext.h
new file mode 100644
index 00000000..40cdbfce
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/port_ext.h
@@ -0,0 +1,31 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains external definitions of Port Emulation entity unit
+ *
+ ******************************************************************************/
+
+#ifndef PORTEXT_H
+#define PORTEXT_H
+
+
+/* Port emulation entity Entry Points */
+extern void rfcomm_process_timeout (TIMER_LIST_ENT *p_tle);
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/profiles_api.h b/lib/bt/host/bluedroid/stack/include/stack/profiles_api.h
new file mode 100644
index 00000000..4bbf5a22
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/profiles_api.h
@@ -0,0 +1,69 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2009-2013 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef PROFILES_API_H
+#define PROFILES_API_H
+
+#include "common/bt_target.h"
+#include "stack/btm_api.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+#define BT_PASS 0 /* Used for general successful function returns */
+
+/*** Port entity passes back 8 bit errors; will use upper byte offset ***/
+#define PORT_ERR_GRP 0x0000 /* base offset for port entity */
+#define GAP_ERR_GRP 0x0100 /* base offset for GAP profile */
+#define SPP_ERR_GRP 0x0200 /* base offset for serial port profile */
+#define HCRP_ERR_GRP 0x0300 /* base offset for HCRP */
+#define HCRPM_ERR_GRP 0x0400 /* base offset for HCRPM */
+
+/* #define HSP2_ERR_GRP 0x0F00 */
+
+/* security level definitions (tBT_SECURITY) */
+#define BT_USE_DEF_SECURITY 0
+#define BT_SEC_MODE_NONE BTM_SEC_MODE_NONE
+#define BT_SEC_MODE_SERVICE BTM_SEC_MODE_SERVICE
+#define BT_SEC_MODE_LINK BTM_SEC_MODE_LINK
+
+/* security mask definitions (tBT_SECURITY) */
+/* The following definitions are OR'd together to form the security requirements */
+#define BT_SEC_IN_AUTHORIZE BTM_SEC_IN_AUTHORIZE /* Inbound call requires authorization */
+#define BT_SEC_IN_AUTHENTICATE BTM_SEC_IN_AUTHENTICATE /* Inbound call requires authentication */
+#define BT_SEC_IN_ENCRYPT BTM_SEC_IN_ENCRYPT /* Inbound call requires encryption */
+#define BT_SEC_OUT_AUTHORIZE BTM_SEC_OUT_AUTHORIZE /* Outbound call requires authorization */
+#define BT_SEC_OUT_AUTHENTICATE BTM_SEC_OUT_AUTHENTICATE /* Outbound call requires authentication */
+#define BT_SEC_OUT_ENCRYPT BTM_SEC_OUT_ENCRYPT /* Outbound call requires encryption */
+
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+/*
+** Security Definitions
+** This following definitions are used to indicate the security
+** requirements for a service.
+*/
+typedef struct {
+ UINT8 level;
+ UINT8 mask;
+} tBT_SECURITY;
+
+#endif /* PROFILES_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/rfcdefs.h b/lib/bt/host/bluedroid/stack/include/stack/rfcdefs.h
new file mode 100644
index 00000000..dcc37bc7
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/rfcdefs.h
@@ -0,0 +1,248 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/****************************************************************************
+ *
+ * This file contains definitions for the RFCOMM protocol
+ *
+ ****************************************************************************/
+
+#ifndef RFCDEFS_H
+#define RFCDEFS_H
+
+#define PORT_MAX_RFC_PORTS 31
+
+/*
+** If nothing is negotiated MTU should be 127
+*/
+#define RFCOMM_DEFAULT_MTU 127
+
+/*
+** Define used by RFCOMM TS frame types
+*/
+#define RFCOMM_SABME 0x2F
+#define RFCOMM_UA 0x63
+#define RFCOMM_DM 0x0F
+#define RFCOMM_DISC 0x43
+#define RFCOMM_UIH 0xEF
+
+/*
+** Defenitions for the TS control frames
+*/
+#define RFCOMM_CTRL_FRAME_LEN 3
+#define RFCOMM_MIN_OFFSET 5 /* ctrl 2 , len 1 or 2 bytes, credit 1 byte */
+#define RFCOMM_DATA_OVERHEAD (RFCOMM_MIN_OFFSET + 1) /* add 1 for checksum */
+
+#define RFCOMM_EA 1
+#define RFCOMM_EA_MASK 0x01
+#define RFCOMM_CR_MASK 0x02
+#define RFCOMM_SHIFT_CR 1
+#define RFCOMM_SHIFT_DLCI 2
+#define RFCOMM_SHIFT_DLCI2 6
+#define RFCOMM_PF 0x10
+#define RFCOMM_PF_MASK 0x10
+#define RFCOMM_PF_OFFSET 4
+#define RFCOMM_SHIFT_LENGTH1 1
+#define RFCOMM_SHIFT_LENGTH2 7
+#define RFCOMM_SHIFT_MX_CTRL_TYPE 2
+
+#define RFCOMM_INITIATOR_CMD 1
+#define RFCOMM_INITIATOR_RSP 0
+#define RFCOMM_RESPONDER_CMD 0
+#define RFCOMM_RESPONDER_RSP 1
+
+#define RFCOMM_PARSE_CTRL_FIELD(ea, cr, dlci, p_data) \
+{ \
+ ea = *p_data & RFCOMM_EA; \
+ cr = (*p_data & RFCOMM_CR_MASK) >> RFCOMM_SHIFT_CR; \
+ dlci = *p_data++ >> RFCOMM_SHIFT_DLCI; \
+ if (!ea) dlci += *p_data++ << RFCOMM_SHIFT_DLCI2; \
+}
+
+#define RFCOMM_FORMAT_CTRL_FIELD(p_data, ea, cr, dlci) \
+ *p_data++ = ea | cr | (dlci << RFCOMM_SHIFT_DLCI)
+
+#define RFCOMM_PARSE_TYPE_FIELD(type, pf, p_data) \
+{ \
+ type = *p_data & ~RFCOMM_PF_MASK; \
+ pf = (*p_data++ & RFCOMM_PF_MASK) >> RFCOMM_PF_OFFSET;\
+}
+
+#define RFCOMM_FORMAT_TYPE_FIELD(p_data, type, pf) \
+ *p_data++ = (type | (pf << RFCOMM_PF_OFFSET)) \
+{ \
+ type = *p_data & ~RFCOMM_PF_MASK; \
+ pf = (*p_data++ & RFCOMM_PF_MASK) >> RFCOMM_PF_OFFSET;\
+}
+
+#define RFCOMM_PARSE_LEN_FIELD(ea, length, p_data) \
+{ \
+ ea = (*p_data & RFCOMM_EA); \
+ length = (*p_data++ >> RFCOMM_SHIFT_LENGTH1); \
+ if (!ea) length += (*p_data++ << RFCOMM_SHIFT_LENGTH2); \
+}
+
+#define RFCOMM_FRAME_IS_CMD(initiator, cr) \
+ (( (initiator) && !(cr)) || (!(initiator) && (cr)))
+
+#define RFCOMM_FRAME_IS_RSP(initiator, cr) \
+ (( (initiator) && (cr)) || (!(initiator) && !(cr)))
+
+#define RFCOMM_CR(initiator, is_command) \
+ (( ( (initiator) && (is_command)) \
+ || (!(initiator) && !(is_command))) << 1)
+
+#define RFCOMM_I_CR(is_command) ((is_command) ? 0x02 : 0x00)
+
+#define RFCOMM_MAX_DLCI 61
+
+#define RFCOMM_VALID_DLCI(dlci) \
+ (((dlci) == 0) || (((dlci) >= 2) && ((dlci) <= RFCOMM_MAX_DLCI)))
+
+
+/* Port Negotiation (PN) */
+#define RFCOMM_PN_DLCI_MASK 0x3F
+
+#define RFCOMM_PN_FRAM_TYPE_UIH 0x00
+#define RFCOMM_PN_FRAME_TYPE_MASK 0x0F
+
+#define RFCOMM_PN_CONV_LAYER_MASK 0xF0
+#define RFCOMM_PN_CONV_LAYER_TYPE_1 0
+#define RFCOMM_PN_CONV_LAYER_CBFC_I 0xF0
+#define RFCOMM_PN_CONV_LAYER_CBFC_R 0xE0
+
+#define RFCOMM_PN_PRIORITY_MASK 0x3F
+#define RFCOMM_PN_PRIORITY_0 0
+
+#define RFCOMM_PN_K_MASK 0x07
+
+#define RFCOMM_T1_DSEC 0 /* None negotiable in RFCOMM */
+#define RFCOMM_N2 0 /* Number of retransmissions */
+#define RFCOMM_K 0 /* Window size */
+#define RFCOMM_K_MAX 7 /* Max value of K for credit based flow control */
+
+#define RFCOMM_MSC_FC 0x02 /* Flow control*/
+#define RFCOMM_MSC_RTC 0x04 /* Ready to communicate*/
+#define RFCOMM_MSC_RTR 0x08 /* Ready to receive*/
+#define RFCOMM_MSC_IC 0x40 /* Incomming call indicator*/
+#define RFCOMM_MSC_DV 0x80 /* Data Valid*/
+
+#define RFCOMM_MSC_SHIFT_BREAK 4
+#define RFCOMM_MSC_BREAK_MASK 0xF0
+#define RFCOMM_MSC_BREAK_PRESENT_MASK 0x02
+
+#define RFCOMM_BAUD_RATE_2400 0x00
+#define RFCOMM_BAUD_RATE_4800 0x01
+#define RFCOMM_BAUD_RATE_7200 0x02
+#define RFCOMM_BAUD_RATE_9600 0x03
+#define RFCOMM_BAUD_RATE_19200 0x04
+#define RFCOMM_BAUD_RATE_38400 0x05
+#define RFCOMM_BAUD_RATE_57600 0x06
+#define RFCOMM_BAUD_RATE_115200 0x07
+#define RFCOMM_BAUD_RATE_230400 0x08
+
+#define RFCOMM_5_BITS 0x00
+#define RFCOMM_6_BITS 0x01
+#define RFCOMM_7_BITS 0x02
+#define RFCOMM_8_BITS 0x03
+
+#define RFCOMM_RPN_BITS_MASK 0x03
+#define RFCOMM_RPN_BITS_SHIFT 0
+
+#define RFCOMM_ONESTOPBIT 0x00
+#define RFCOMM_ONE5STOPBITS 0x01
+
+#define RFCOMM_RPN_STOP_BITS_MASK 0x01
+#define RFCOMM_RPN_STOP_BITS_SHIFT 2
+
+#define RFCOMM_PARITY_NO 0x00
+#define RFCOMM_PARITY_YES 0x01
+#define RFCOMM_RPN_PARITY_MASK 0x01
+#define RFCOMM_RPN_PARITY_SHIFT 3
+
+#define RFCOMM_ODD_PARITY 0x00
+#define RFCOMM_EVEN_PARITY 0x01
+#define RFCOMM_MARK_PARITY 0x02
+#define RFCOMM_SPACE_PARITY 0x03
+
+#define RFCOMM_RPN_PARITY_TYPE_MASK 0x03
+#define RFCOMM_RPN_PARITY_TYPE_SHIFT 4
+
+#define RFCOMM_FC_OFF 0x00
+#define RFCOMM_FC_XONXOFF_ON_INPUT 0x01
+#define RFCOMM_FC_XONXOFF_ON_OUTPUT 0x02
+#define RFCOMM_FC_RTR_ON_INPUT 0x04
+#define RFCOMM_FC_RTR_ON_OUTPUT 0x08
+#define RFCOMM_FC_RTC_ON_INPUT 0x10
+#define RFCOMM_FC_RTC_ON_OUTPUT 0x20
+#define RFCOMM_FC_MASK 0x3F
+
+#define RFCOMM_RPN_PM_BIT_RATE 0x0001
+#define RFCOMM_RPN_PM_DATA_BITS 0x0002
+#define RFCOMM_RPN_PM_STOP_BITS 0x0004
+#define RFCOMM_RPN_PM_PARITY 0x0008
+#define RFCOMM_RPN_PM_PARITY_TYPE 0x0010
+#define RFCOMM_RPN_PM_XON_CHAR 0x0020
+#define RFCOMM_RPN_PM_XOFF_CHAR 0x0040
+#define RFCOMM_RPN_PM_XONXOFF_ON_INPUT 0x0100
+#define RFCOMM_RPN_PM_XONXOFF_ON_OUTPUT 0x0200
+#define RFCOMM_RPN_PM_RTR_ON_INPUT 0x0400
+#define RFCOMM_RPN_PM_RTR_ON_OUTPUT 0x0800
+#define RFCOMM_RPN_PM_RTC_ON_INPUT 0x1000
+#define RFCOMM_RPN_PM_RTC_ON_OUTPUT 0x2000
+#define RFCOMM_RPN_PM_MASK 0x3F7F
+
+#define RFCOMM_RLS_ERROR 0x01
+#define RFCOMM_RLS_OVERRUN 0x02
+#define RFCOMM_RLS_PARITY 0x04
+#define RFCOMM_RLS_FRAMING 0x08
+
+/* Multiplexor channel uses DLCI 0 */
+#define RFCOMM_MX_DLCI 0
+
+/*
+** Define RFCOMM Multiplexer message types
+*/
+#define RFCOMM_MX_PN 0x80
+#define RFCOMM_MX_PN_LEN 8
+
+#define RFCOMM_MX_CLD 0xC0
+#define RFCOMM_MX_CLD_LEN 0
+
+#define RFCOMM_MX_TEST 0x20
+
+#define RFCOMM_MX_FCON 0xA0
+#define RFCOMM_MX_FCON_LEN 0
+
+#define RFCOMM_MX_FCOFF 0x60
+#define RFCOMM_MX_FCOFF_LEN 0
+
+#define RFCOMM_MX_MSC 0xE0
+#define RFCOMM_MX_MSC_LEN_NO_BREAK 2
+#define RFCOMM_MX_MSC_LEN_WITH_BREAK 3
+
+#define RFCOMM_MX_NSC 0x10
+#define RFCOMM_MX_NSC_LEN 1
+
+#define RFCOMM_MX_RPN 0x90
+#define RFCOMM_MX_RPN_REQ_LEN 1
+#define RFCOMM_MX_RPN_LEN 8
+
+#define RFCOMM_MX_RLS 0x50
+#define RFCOMM_MX_RLS_LEN 2
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/sdp_api.h b/lib/bt/host/bluedroid/stack/include/stack/sdp_api.h
new file mode 100644
index 00000000..70da3182
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/sdp_api.h
@@ -0,0 +1,726 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+#ifndef SDP_API_H
+#define SDP_API_H
+
+#include "common/bt_target.h"
+#include "stack/sdpdefs.h"
+#if (SDP_INCLUDED == TRUE)
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+/* Success code and error codes */
+#define SDP_SUCCESS 0x0000
+#define SDP_INVALID_VERSION 0x0001
+#define SDP_INVALID_SERV_REC_HDL 0x0002
+#define SDP_INVALID_REQ_SYNTAX 0x0003
+#define SDP_INVALID_PDU_SIZE 0x0004
+#define SDP_INVALID_CONT_STATE 0x0005
+#define SDP_NO_RESOURCES 0x0006
+#define SDP_DI_REG_FAILED 0x0007
+#define SDP_DI_DISC_FAILED 0x0008
+#define SDP_NO_DI_RECORD_FOUND 0x0009
+#define SDP_ERR_ATTR_NOT_PRESENT 0x000A
+#define SDP_ILLEGAL_PARAMETER 0x000B
+
+#define SDP_NO_RECS_MATCH 0xFFF0
+#define SDP_CONN_FAILED 0xFFF1
+#define SDP_CFG_FAILED 0xFFF2
+#define SDP_GENERIC_ERROR 0xFFF3
+#define SDP_DB_FULL 0xFFF4
+#define SDP_INVALID_PDU 0xFFF5
+#define SDP_SECURITY_ERR 0xFFF6
+#define SDP_CONN_REJECTED 0xFFF7
+#define SDP_CANCEL 0xFFF8
+
+/* Define the PSM that SDP uses */
+#define SDP_PSM 0x0001
+
+/* Legacy #define to avoid code changes - SDP UUID is same as BT UUID */
+#define tSDP_UUID tBT_UUID
+
+/* Masks for attr_value field of tSDP_DISC_ATTR */
+#define SDP_DISC_ATTR_LEN_MASK 0x0FFF
+#define SDP_DISC_ATTR_TYPE(len_type) (len_type >> 12)
+#define SDP_DISC_ATTR_LEN(len_type) (len_type & SDP_DISC_ATTR_LEN_MASK)
+
+/* Maximum number of protocol list items (list_elem in tSDP_PROTOCOL_ELEM) */
+#define SDP_MAX_LIST_ELEMS 3
+
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+/* Define a callback function for when discovery is complete. */
+typedef void (tSDP_DISC_CMPL_CB) (UINT16 result);
+typedef void (tSDP_DISC_CMPL_CB2) (UINT16 result, void *user_data);
+
+typedef struct {
+ BD_ADDR peer_addr;
+ UINT16 peer_mtu;
+} tSDP_DR_OPEN;
+
+typedef struct {
+ UINT8 *p_data;
+ UINT16 data_len;
+} tSDP_DR_DATA;
+
+typedef union {
+ tSDP_DR_OPEN open;
+ tSDP_DR_DATA data;
+} tSDP_DATA;
+
+/* Define a callback function for when discovery result is received. */
+typedef void (tSDP_DISC_RES_CB) (UINT16 event, tSDP_DATA *p_data);
+
+/* Define a structure to hold the discovered service information. */
+typedef struct {
+ union {
+ UINT8 u8; /* 8-bit integer */
+ UINT16 u16; /* 16-bit integer */
+ UINT32 u32; /* 32-bit integer */
+ UINT8 array[4]; /* Variable length field */
+ struct t_sdp_disc_attr *p_sub_attr; /* Addr of first sub-attr (list)*/
+ } v;
+
+} tSDP_DISC_ATVAL;
+
+typedef struct t_sdp_disc_attr {
+ struct t_sdp_disc_attr *p_next_attr; /* Addr of next linked attr */
+ UINT16 attr_id; /* Attribute ID */
+ UINT16 attr_len_type; /* Length and type fields */
+ tSDP_DISC_ATVAL attr_value; /* Variable length entry data */
+} tSDP_DISC_ATTR;
+
+typedef struct t_sdp_disc_rec {
+ tSDP_DISC_ATTR *p_first_attr; /* First attribute of record */
+ struct t_sdp_disc_rec *p_next_rec; /* Addr of next linked record */
+ UINT32 time_read; /* The time the record was read */
+ BD_ADDR remote_bd_addr; /* Remote BD address */
+} tSDP_DISC_REC;
+
+typedef struct {
+ UINT32 mem_size; /* Memory size of the DB */
+ UINT32 mem_free; /* Memory still available */
+ tSDP_DISC_REC *p_first_rec; /* Addr of first record in DB */
+ UINT16 num_uuid_filters; /* Number of UUIds to filter */
+ tSDP_UUID uuid_filters[SDP_MAX_UUID_FILTERS]; /* UUIDs to filter */
+ UINT16 num_attr_filters; /* Number of attribute filters */
+ UINT16 attr_filters[SDP_MAX_ATTR_FILTERS]; /* Attributes to filter */
+ UINT8 *p_free_mem; /* Pointer to free memory */
+#if (SDP_RAW_DATA_INCLUDED == TRUE)
+ UINT8 *raw_data; /* Received record from server. allocated/released by client */
+ UINT32 raw_size; /* size of raw_data */
+ UINT32 raw_used; /* length of raw_data used */
+#endif
+} tSDP_DISCOVERY_DB;
+
+/* This structure is used to add protocol lists and find protocol elements */
+typedef struct {
+ UINT16 protocol_uuid;
+ UINT16 num_params;
+ UINT16 params[SDP_MAX_PROTOCOL_PARAMS];
+} tSDP_PROTOCOL_ELEM;
+
+typedef struct {
+ UINT16 num_elems;
+ tSDP_PROTOCOL_ELEM list_elem[SDP_MAX_LIST_ELEMS];
+} tSDP_PROTO_LIST_ELEM;
+
+/* Device Identification (DI) data structure
+*/
+/* Used to set the DI record */
+typedef struct t_sdp_di_record {
+ UINT16 vendor;
+ UINT16 vendor_id_source;
+ UINT16 product;
+ UINT16 version;
+ BOOLEAN primary_record;
+ char client_executable_url[SDP_MAX_ATTR_LEN]; /* optional */
+ char service_description[SDP_MAX_ATTR_LEN]; /* optional */
+ char documentation_url[SDP_MAX_ATTR_LEN]; /* optional */
+} tSDP_DI_RECORD;
+
+/* Used to get the DI record */
+typedef struct t_sdp_di_get_record {
+ UINT16 spec_id;
+ tSDP_DI_RECORD rec;
+} tSDP_DI_GET_RECORD;
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* API into the SDP layer for service discovery. */
+
+/*******************************************************************************
+**
+** Function SDP_InitDiscoveryDb
+**
+** Description This function is called to initialize a discovery database.
+**
+** Returns TRUE if successful, FALSE if one or more parameters are bad
+**
+*******************************************************************************/
+extern BOOLEAN SDP_InitDiscoveryDb (tSDP_DISCOVERY_DB *p_db, UINT32 len,
+ UINT16 num_uuid,
+ tSDP_UUID *p_uuid_list,
+ UINT16 num_attr,
+ UINT16 *p_attr_list);
+
+/*******************************************************************************
+**
+** Function SDP_CancelServiceSearch
+**
+** Description This function cancels an active query to an SDP server.
+**
+** Returns TRUE if discovery cancelled, FALSE if a matching activity is not found.
+**
+*******************************************************************************/
+extern BOOLEAN SDP_CancelServiceSearch (tSDP_DISCOVERY_DB *p_db);
+
+/*******************************************************************************
+**
+** Function SDP_ServiceSearchRequest
+**
+** Description This function queries an SDP server for information.
+**
+** Returns TRUE if discovery started, FALSE if failed.
+**
+*******************************************************************************/
+extern BOOLEAN SDP_ServiceSearchRequest (UINT8 *p_bd_addr,
+ tSDP_DISCOVERY_DB *p_db,
+ tSDP_DISC_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** Function SDP_ServiceSearchAttributeRequest
+**
+** Description This function queries an SDP server for information.
+**
+** The difference between this API function and the function
+** SDP_ServiceSearchRequest2 is that this one does a
+** combined ServiceSearchAttributeRequest SDP function.
+**
+** Returns TRUE if discovery started, FALSE if failed.
+**
+*******************************************************************************/
+extern BOOLEAN SDP_ServiceSearchAttributeRequest (UINT8 *p_bd_addr,
+ tSDP_DISCOVERY_DB *p_db,
+ tSDP_DISC_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function SDP_ServiceSearchAttributeRequest2
+**
+** Description This function queries an SDP server for information.
+**
+** The difference between this API function and the function
+** SDP_ServiceSearchRequest is that this one does a
+** combined ServiceSearchAttributeRequest SDP function with the
+** user data piggyback
+**
+** Returns TRUE if discovery started, FALSE if failed.
+**
+*******************************************************************************/
+extern BOOLEAN SDP_ServiceSearchAttributeRequest2 (UINT8 *p_bd_addr,
+ tSDP_DISCOVERY_DB *p_db,
+ tSDP_DISC_CMPL_CB2 *p_cb, void *user_data);
+
+/* API of utilities to find data in the local discovery database */
+
+/*******************************************************************************
+**
+** Function SDP_FindAttributeInDb
+**
+** Description This function queries an SDP database for a specific attribute.
+** If the p_start_rec pointer is NULL, it looks from the beginning
+** of the database, else it continues from the next record after
+** p_start_rec.
+**
+** Returns Pointer to matching record, or NULL
+**
+*******************************************************************************/
+extern tSDP_DISC_REC *SDP_FindAttributeInDb (tSDP_DISCOVERY_DB *p_db,
+ UINT16 attr_id,
+ tSDP_DISC_REC *p_start_rec);
+
+
+/*******************************************************************************
+**
+** Function SDP_FindAttributeInRec
+**
+** Description This function searches an SDP discovery record for a
+** specific attribute.
+**
+** Returns Pointer to matching attribute entry, or NULL
+**
+*******************************************************************************/
+extern tSDP_DISC_ATTR *SDP_FindAttributeInRec (tSDP_DISC_REC *p_rec,
+ UINT16 attr_id);
+
+
+/*******************************************************************************
+**
+** Function SDP_FindServiceInDb
+**
+** Description This function queries an SDP database for a specific service.
+** If the p_start_rec pointer is NULL, it looks from the beginning
+** of the database, else it continues from the next record after
+** p_start_rec.
+**
+** Returns Pointer to record containing service class, or NULL
+**
+*******************************************************************************/
+extern tSDP_DISC_REC *SDP_FindServiceInDb (tSDP_DISCOVERY_DB *p_db,
+ UINT16 service_uuid,
+ tSDP_DISC_REC *p_start_rec);
+
+
+/*******************************************************************************
+**
+** Function SDP_FindServiceUUIDInDb
+**
+** Description This function queries an SDP database for a specific service.
+** If the p_start_rec pointer is NULL, it looks from the beginning
+** of the database, else it continues from the next record after
+** p_start_rec.
+**
+** NOTE the only difference between this function and the previous
+** function "SDP_FindServiceInDb()" is that this function takes
+** a tBT_UUID input.
+**
+** Returns Pointer to record containing service class, or NULL
+**
+*******************************************************************************/
+extern tSDP_DISC_REC *SDP_FindServiceUUIDInDb (tSDP_DISCOVERY_DB *p_db,
+ tBT_UUID *p_uuid,
+ tSDP_DISC_REC *p_start_rec);
+
+/*******************************************************************************
+**
+** Function SDP_FindServiceUUIDInRec_128bit
+**
+** Description This function is called to read the 128-bit service UUID within a record
+** if there is any.
+**
+** Parameters: p_rec - pointer to a SDP record.
+** p_uuid - output parameter to save the UUID found.
+**
+** Returns TRUE if found, otherwise FALSE.
+**
+*******************************************************************************/
+extern BOOLEAN SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC *p_rec, tBT_UUID *p_uuid);
+
+/*******************************************************************************
+**
+** Function SDP_FindServiceInDb_128bit
+**
+** Description This function queries an SDP database for a specific service.
+** If the p_start_rec pointer is NULL, it looks from the beginning
+** of the database, else it continues from the next record after
+** p_start_rec.
+**
+** Returns Pointer to record containing service class, or NULL
+**
+*******************************************************************************/
+extern tSDP_DISC_REC *SDP_FindServiceInDb_128bit(tSDP_DISCOVERY_DB *p_db,
+ tSDP_DISC_REC *p_start_rec);
+
+/*******************************************************************************
+**
+** Function SDP_FindProtocolListElemInRec
+**
+** Description This function looks at a specific discovery record for a
+** protocol list element.
+**
+** Returns TRUE if found, FALSE if not
+** If found, the passed protocol list element is filled in.
+**
+*******************************************************************************/
+extern BOOLEAN SDP_FindProtocolListElemInRec (tSDP_DISC_REC *p_rec,
+ UINT16 layer_uuid,
+ tSDP_PROTOCOL_ELEM *p_elem);
+
+
+/*******************************************************************************
+**
+** Function SDP_FindAddProtoListsElemInRec
+**
+** Description This function looks at a specific discovery record for a
+** protocol list element.
+**
+** Returns TRUE if found, FALSE if not
+** If found, the passed protocol list element is filled in.
+**
+*******************************************************************************/
+extern BOOLEAN SDP_FindAddProtoListsElemInRec (tSDP_DISC_REC *p_rec,
+ UINT16 layer_uuid,
+ tSDP_PROTOCOL_ELEM *p_elem);
+
+
+/*******************************************************************************
+**
+** Function SDP_FindProfileVersionInRec
+**
+** Description This function looks at a specific discovery record for the
+** Profile list descriptor, and pulls out the version number.
+** The version number consists of an 8-bit major version and
+** an 8-bit minor version.
+**
+** Returns TRUE if found, FALSE if not
+** If found, the major and minor version numbers that were passed
+** in are filled in.
+**
+*******************************************************************************/
+extern BOOLEAN SDP_FindProfileVersionInRec (tSDP_DISC_REC *p_rec,
+ UINT16 profile_uuid,
+ UINT16 *p_version);
+
+
+/* API into SDP for local service database updates */
+
+/*******************************************************************************
+**
+** Function SDP_CreateRecord
+**
+** Description This function is called to create a record in the database.
+** This would be through the SDP database maintenance API. The
+** record is created empty, teh application should then call
+** "add_attribute" to add the record's attributes.
+**
+** Returns Record handle if OK, else 0.
+**
+*******************************************************************************/
+extern UINT32 SDP_CreateRecord (void);
+
+
+/*******************************************************************************
+**
+** Function SDP_DeleteRecord
+**
+** Description This function is called to add a record (or all records)
+** from the database. This would be through the SDP database
+** maintenance API.
+**
+** If a record handle of 0 is passed, all records are deleted.
+**
+** Returns TRUE if succeeded, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN SDP_DeleteRecord (UINT32 handle);
+
+
+/*******************************************************************************
+**
+** Function SDP_ReadRecord
+**
+** Description This function is called to get the raw data of the record
+** with the given handle from the database.
+**
+** Returns -1, if the record is not found.
+** Otherwise, the offset (0 or 1) to start of data in p_data.
+**
+** The size of data copied into p_data is in *p_data_len.
+**
+*******************************************************************************/
+extern INT32 SDP_ReadRecord(UINT32 handle, UINT8 *p_data, INT32 *p_data_len);
+
+/*******************************************************************************
+**
+** Function SDP_AddAttribute
+**
+** Description This function is called to add an attribute to a record.
+** This would be through the SDP database maintenance API.
+** If the attribute already exists in the record, it is replaced
+** with the new value.
+**
+** NOTE Attribute values must be passed as a Big Endian stream.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN SDP_AddAttribute (UINT32 handle, UINT16 attr_id,
+ UINT8 attr_type, UINT32 attr_len,
+ UINT8 *p_val);
+
+
+/*******************************************************************************
+**
+** Function SDP_AddSequence
+**
+** Description This function is called to add a sequence to a record.
+** This would be through the SDP database maintenance API.
+** If the sequence already exists in the record, it is replaced
+** with the new sequence.
+**
+** NOTE Element values must be passed as a Big Endian stream.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN SDP_AddSequence (UINT32 handle, UINT16 attr_id,
+ UINT16 num_elem, UINT8 type[],
+ UINT8 len[], UINT8 *p_val[]);
+
+
+/*******************************************************************************
+**
+** Function SDP_AddUuidSequence
+**
+** Description This function is called to add a UUID sequence to a record.
+** This would be through the SDP database maintenance API.
+** If the sequence already exists in the record, it is replaced
+** with the new sequence.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN SDP_AddUuidSequence (UINT32 handle, UINT16 attr_id,
+ UINT16 num_uuids, UINT16 *p_uuids);
+
+
+/*******************************************************************************
+**
+** Function SDP_AddProtocolList
+**
+** Description This function is called to add a protocol descriptor list to
+** a record. This would be through the SDP database maintenance API.
+** If the protocol list already exists in the record, it is replaced
+** with the new list.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN SDP_AddProtocolList (UINT32 handle, UINT16 num_elem,
+ tSDP_PROTOCOL_ELEM *p_elem_list);
+
+
+/*******************************************************************************
+**
+** Function SDP_AddAdditionProtoLists
+**
+** Description This function is called to add a protocol descriptor list to
+** a record. This would be through the SDP database maintenance API.
+** If the protocol list already exists in the record, it is replaced
+** with the new list.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN SDP_AddAdditionProtoLists (UINT32 handle, UINT16 num_elem,
+ tSDP_PROTO_LIST_ELEM *p_proto_list);
+
+
+/*******************************************************************************
+**
+** Function SDP_AddProfileDescriptorList
+**
+** Description This function is called to add a profile descriptor list to
+** a record. This would be through the SDP database maintenance API.
+** If the version already exists in the record, it is replaced
+** with the new one.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN SDP_AddProfileDescriptorList (UINT32 handle,
+ UINT16 profile_uuid,
+ UINT16 version);
+
+
+/*******************************************************************************
+**
+** Function SDP_AddLanguageBaseAttrIDList
+**
+** Description This function is called to add a language base attr list to
+** a record. This would be through the SDP database maintenance API.
+** If the version already exists in the record, it is replaced
+** with the new one.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN SDP_AddLanguageBaseAttrIDList (UINT32 handle,
+ UINT16 lang, UINT16 char_enc,
+ UINT16 base_id);
+
+
+/*******************************************************************************
+**
+** Function SDP_AddServiceClassIdList
+**
+** Description This function is called to add a service list to a record.
+** This would be through the SDP database maintenance API.
+** If the service list already exists in the record, it is replaced
+** with the new list.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+extern BOOLEAN SDP_AddServiceClassIdList (UINT32 handle,
+ UINT16 num_services,
+ UINT16 *p_service_uuids);
+
+
+/*******************************************************************************
+**
+** Function SDP_DeleteAttribute
+**
+** Description This function is called to delete an attribute from a record.
+** This would be through the SDP database maintenance API.
+**
+** Returns TRUE if deleted OK, else FALSE if not found
+**
+*******************************************************************************/
+extern BOOLEAN SDP_DeleteAttribute (UINT32 handle, UINT16 attr_id);
+
+
+/* Device Identification APIs */
+
+/*******************************************************************************
+**
+** Function SDP_SetLocalDiRecord
+**
+** Description This function adds a DI record to the local SDP database.
+**
+** Returns Returns SDP_SUCCESS if record added successfully, else error
+**
+*******************************************************************************/
+extern UINT16 SDP_SetLocalDiRecord (tSDP_DI_RECORD *device_info,
+ UINT32 *p_handle);
+
+/*******************************************************************************
+**
+** Function SDP_DiDiscover
+**
+** Description This function queries a remote device for DI information.
+**
+** Returns SDP_SUCCESS if query started successfully, else error
+**
+*******************************************************************************/
+extern UINT16 SDP_DiDiscover (BD_ADDR remote_device,
+ tSDP_DISCOVERY_DB *p_db, UINT32 len,
+ tSDP_DISC_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** Function SDP_GetNumDiRecords
+**
+** Description Searches specified database for DI records
+**
+** Returns number of DI records found
+**
+*******************************************************************************/
+extern UINT8 SDP_GetNumDiRecords (tSDP_DISCOVERY_DB *p_db);
+
+
+/*******************************************************************************
+**
+** Function SDP_GetDiRecord
+**
+** Description This function retrieves a remote device's DI record from
+** the specified database.
+**
+** Returns SDP_SUCCESS if record retrieved, else error
+**
+*******************************************************************************/
+extern UINT16 SDP_GetDiRecord (UINT8 getRecordIndex,
+ tSDP_DI_GET_RECORD *device_info,
+ tSDP_DISCOVERY_DB *p_db);
+
+
+/*******************************************************************************
+**
+** Function SDP_SetTraceLevel
+**
+** Description This function sets the trace level for SDP. If called with
+** a value of 0xFF, it simply reads the current trace level.
+**
+** Returns the new (current) trace level
+**
+*******************************************************************************/
+extern UINT8 SDP_SetTraceLevel (UINT8 new_level);
+
+/*******************************************************************************
+**
+** Function SDP_ConnOpen
+**
+** Description This function creates a connection to the SDP server on the
+** given device.
+**
+** Returns 0, if failed to initiate connection. Otherwise, the handle.
+**
+*******************************************************************************/
+UINT32 SDP_ConnOpen (UINT8 *p_bd_addr, tSDP_DISC_RES_CB *p_rcb,
+ tSDP_DISC_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function SDP_WriteData
+**
+** Description This function sends data to the connected SDP server.
+**
+** Returns TRUE if data is sent, FALSE if failed.
+**
+*******************************************************************************/
+BOOLEAN SDP_WriteData (UINT32 handle, BT_HDR *p_msg);
+
+/*******************************************************************************
+**
+** Function SDP_ConnClose
+**
+** Description This function is called to close a SDP connection.
+**
+** Parameters: handle - Handle of the connection returned by SDP_ConnOpen
+**
+** Returns TRUE if connection is closed, FALSE if failed to find the handle.
+**
+*******************************************************************************/
+BOOLEAN SDP_ConnClose (UINT32 handle);
+
+/*******************************************************************************
+**
+** Function SDP_FindServiceUUIDInRec
+**
+** Description This function is called to read the service UUID within a record
+** if there is any.
+**
+** Parameters: p_rec - pointer to a SDP record.
+**
+** Returns TRUE if found, otherwise FALSE.
+**
+*******************************************************************************/
+BOOLEAN SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID *p_uuid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif ///SDP_INCLUDED == TRUE
+
+#endif /* SDP_API_H */
diff --git a/lib/bt/host/bluedroid/stack/include/stack/sdpdefs.h b/lib/bt/host/bluedroid/stack/include/stack/sdpdefs.h
new file mode 100644
index 00000000..d7eab356
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/sdpdefs.h
@@ -0,0 +1,325 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the definitions for the SDP API
+ *
+ ******************************************************************************/
+
+#ifndef SDP_DEFS_H
+#define SDP_DEFS_H
+
+/* Define the service attribute IDs.
+*/
+#define ATTR_ID_SERVICE_RECORD_HDL 0x0000
+#define ATTR_ID_SERVICE_CLASS_ID_LIST 0x0001
+#define ATTR_ID_SERVICE_RECORD_STATE 0x0002
+#define ATTR_ID_SERVICE_ID 0x0003
+#define ATTR_ID_PROTOCOL_DESC_LIST 0x0004
+#define ATTR_ID_BROWSE_GROUP_LIST 0x0005
+#define ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST 0x0006
+#define ATTR_ID_SERVICE_INFO_TIME_TO_LIVE 0x0007
+#define ATTR_ID_SERVICE_AVAILABILITY 0x0008
+#define ATTR_ID_BT_PROFILE_DESC_LIST 0x0009
+#define ATTR_ID_DOCUMENTATION_URL 0x000A
+#define ATTR_ID_CLIENT_EXE_URL 0x000B
+#define ATTR_ID_ICON_URL 0x000C
+#define ATTR_ID_ADDITION_PROTO_DESC_LISTS 0x000D
+
+#define LANGUAGE_BASE_ID 0x0100
+#define ATTR_ID_SERVICE_NAME LANGUAGE_BASE_ID + 0x0000
+#define ATTR_ID_SERVICE_DESCRIPTION LANGUAGE_BASE_ID + 0x0001
+#define ATTR_ID_PROVIDER_NAME LANGUAGE_BASE_ID + 0x0002
+
+/* Device Identification (DI)
+*/
+#define ATTR_ID_SPECIFICATION_ID 0x0200
+#define ATTR_ID_VENDOR_ID 0x0201
+#define ATTR_ID_PRODUCT_ID 0x0202
+#define ATTR_ID_PRODUCT_VERSION 0x0203
+#define ATTR_ID_PRIMARY_RECORD 0x0204
+#define ATTR_ID_VENDOR_ID_SOURCE 0x0205
+
+#define BLUETOOTH_DI_SPECIFICATION 0x0103 /* 1.3 */
+#define DI_VENDOR_ID_DEFAULT 0xFFFF
+#define DI_VENDOR_ID_SOURCE_BTSIG 0x0001
+#define DI_VENDOR_ID_SOURCE_USBIF 0x0002
+
+
+#define ATTR_ID_IP_SUBNET 0x0200 /* PAN Profile (***) */
+#define ATTR_ID_VERSION_NUMBER_LIST 0x0200
+#define ATTR_ID_GOEP_L2CAP_PSM 0x0200
+#define ATTR_ID_GROUP_ID 0x0200
+#define ATTR_ID_SERVICE_DATABASE_STATE 0x0201
+#define ATTR_ID_SERVICE_VERSION 0x0300
+#define ATTR_ID_HCRP_1284ID 0x0300
+
+#define ATTR_ID_SUPPORTED_DATA_STORES 0x0301
+#define ATTR_ID_NETWORK 0x0301
+#define ATTR_ID_EXTERNAL_NETWORK 0x0301
+#define ATTR_ID_FAX_CLASS_1_SUPPORT 0x0302
+#define ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL 0x0302
+#define ATTR_ID_DEVICE_NAME 0x0302
+#define ATTR_ID_SUPPORTED_FORMATS_LIST 0x0303
+#define ATTR_ID_FAX_CLASS_2_0_SUPPORT 0x0303
+#define ATTR_ID_FAX_CLASS_2_SUPPORT 0x0304
+#define ATTR_ID_FRIENDLY_NAME 0x0304
+#define ATTR_ID_AUDIO_FEEDBACK_SUPPORT 0x0305
+#define ATTR_ID_NETWORK_ADDRESS 0x0306
+#define ATTR_ID_DEVICE_LOCATION 0x0306
+#define ATTR_ID_WAP_GATEWAY 0x0307
+#define ATTR_ID_HOME_PAGE_URL 0x0308
+#define ATTR_ID_WAP_STACK_TYPE 0x0309
+#define ATTR_ID_IMG_SUPPORTED_CAPABILITIES 0x0310 /* Imaging Profile */
+#define ATTR_ID_SUPPORTED_FEATURES 0x0311 /* HFP, BIP */
+#define ATTR_ID_IMG_SUPPORTED_FUNCTIONS 0x0312 /* Imaging Profile */
+#define ATTR_ID_IMG_TOT_DATA_CAPABILITY 0x0313 /* Imaging Profile */
+#define ATTR_ID_SUPPORTED_REPOSITORIES 0x0314 /* Phone book access Profile */
+#define ATTR_ID_MAS_INSTANCE_ID 0x0315 /* MAP profile */
+#define ATTR_ID_SUPPORTED_MSG_TYPE 0x0316 /* MAP profile */
+#define ATTR_ID_MAP_SUPPORTED_FEATURES 0x0317 /* MAP profile */
+#define ATTR_ID_PBAP_SUPPORTED_FEATURES 0x0317 /* PBAP profile */
+
+
+/* These values are for the BPP profile */
+#define ATTR_ID_DOCUMENT_FORMATS_SUPPORTED 0x0350
+#define ATTR_ID_CHARACTER_REPERTOIRES_SUPPORTED 0x0352
+#define ATTR_ID_XHTML_IMAGE_FORMATS_SUPPORTED 0x0354
+#define ATTR_ID_COLOR_SUPPORTED 0x0356
+#define ATTR_ID_1284ID 0x0358
+#define ATTR_ID_PRINTER_NAME 0x035A
+#define ATTR_ID_PRINTER_LOCATION 0x035C
+#define ATTR_ID_DUPLEX_SUPPORTED 0x035E
+#define ATTR_ID_MEDIA_TYPES_SUPPORTED 0x0360
+#define ATTR_ID_MAX_MEDIA_WIDTH 0x0362
+#define ATTR_ID_MAX_MEDIA_LENGTH 0x0364
+#define ATTR_ID_ENHANCED_LAYOUT_SUPPORTED 0x0366
+#define ATTR_ID_RUI_FORMATS_SUPPORTED 0x0368
+#define ATTR_ID_RUI_REF_PRINTING_SUPPORTED 0x0370 /* Boolean */
+#define ATTR_ID_RUI_DIRECT_PRINTING_SUPPORTED 0x0372 /* Boolean */
+#define ATTR_ID_REF_PRINTING_TOP_URL 0x0374
+#define ATTR_ID_DIRECT_PRINTING_TOP_URL 0x0376
+#define ATTR_ID_PRINTER_ADMIN_RUI_TOP_URL 0x0378
+#define ATTR_ID_BPP_DEVICE_NAME 0x037A
+
+/* These values are for the PAN profile */
+#define ATTR_ID_SECURITY_DESCRIPTION 0x030A
+#define ATTR_ID_NET_ACCESS_TYPE 0x030B
+#define ATTR_ID_MAX_NET_ACCESS_RATE 0x030C
+#define ATTR_ID_IPV4_SUBNET 0x030D
+#define ATTR_ID_IPV6_SUBNET 0x030E
+#define ATTR_ID_PAN_SECURITY 0x0400
+
+/* These values are for HID profile */
+#define ATTR_ID_HID_DEVICE_RELNUM 0x0200
+#define ATTR_ID_HID_PARSER_VERSION 0x0201
+#define ATTR_ID_HID_DEVICE_SUBCLASS 0x0202
+#define ATTR_ID_HID_COUNTRY_CODE 0x0203
+#define ATTR_ID_HID_VIRTUAL_CABLE 0x0204
+#define ATTR_ID_HID_RECONNECT_INITIATE 0x0205
+#define ATTR_ID_HID_DESCRIPTOR_LIST 0x0206
+#define ATTR_ID_HID_LANGUAGE_ID_BASE 0x0207
+#define ATTR_ID_HID_SDP_DISABLE 0x0208
+#define ATTR_ID_HID_BATTERY_POWER 0x0209
+#define ATTR_ID_HID_REMOTE_WAKE 0x020A
+#define ATTR_ID_HID_PROFILE_VERSION 0x020B
+#define ATTR_ID_HID_LINK_SUPERVISION_TO 0x020C
+#define ATTR_ID_HID_NORMALLY_CONNECTABLE 0x020D
+#define ATTR_ID_HID_BOOT_DEVICE 0x020E
+#define ATTR_ID_HID_SSR_HOST_MAX_LAT 0x020F
+#define ATTR_ID_HID_SSR_HOST_MIN_TOUT 0x0210
+
+/* These values are for the HDP profile */
+#define ATTR_ID_HDP_SUP_FEAT_LIST 0x0200 /* Supported features list */
+#define ATTR_ID_HDP_DATA_EXCH_SPEC 0x0301 /* Data exchange specification */
+#define ATTR_ID_HDP_MCAP_SUP_PROC 0x0302 /* MCAP supported procedures */
+
+/* Define common 16-bit protocol UUIDs
+*/
+#define UUID_PROTOCOL_SDP 0x0001
+#define UUID_PROTOCOL_UDP 0x0002
+#define UUID_PROTOCOL_RFCOMM 0x0003
+#define UUID_PROTOCOL_TCP 0x0004
+#define UUID_PROTOCOL_TCS_BIN 0x0005
+#define UUID_PROTOCOL_TCS_AT 0x0006
+#define UUID_PROTOCOL_OBEX 0x0008
+#define UUID_PROTOCOL_IP 0x0009
+#define UUID_PROTOCOL_FTP 0x000A
+#define UUID_PROTOCOL_HTTP 0x000C
+#define UUID_PROTOCOL_WSP 0x000E
+#define UUID_PROTOCOL_BNEP 0x000F
+#define UUID_PROTOCOL_UPNP 0x0010
+#define UUID_PROTOCOL_HIDP 0x0011
+#define UUID_PROTOCOL_HCRP_CTRL 0x0012
+#define UUID_PROTOCOL_HCRP_DATA 0x0014
+#define UUID_PROTOCOL_HCRP_NOTIF 0x0016
+#define UUID_PROTOCOL_AVCTP 0x0017
+#define UUID_PROTOCOL_AVDTP 0x0019
+#define UUID_PROTOCOL_CMTP 0x001B
+#define UUID_PROTOCOL_UDI 0x001D
+#define UUID_PROTOCOL_MCAP_CTRL 0x001E
+#define UUID_PROTOCOL_MCAP_DATA 0x001F
+#define UUID_PROTOCOL_L2CAP 0x0100
+#define UUID_PROTOCOL_ATT 0x0007
+
+/* Define common 16-bit service class UUIDs
+*/
+#define UUID_SERVCLASS_SERVICE_DISCOVERY_SERVER 0X1000
+#define UUID_SERVCLASS_BROWSE_GROUP_DESCRIPTOR 0X1001
+#define UUID_SERVCLASS_PUBLIC_BROWSE_GROUP 0X1002
+#define UUID_SERVCLASS_SERIAL_PORT 0X1101
+#define UUID_SERVCLASS_LAN_ACCESS_USING_PPP 0X1102
+#define UUID_SERVCLASS_DIALUP_NETWORKING 0X1103
+#define UUID_SERVCLASS_IRMC_SYNC 0X1104
+#define UUID_SERVCLASS_OBEX_OBJECT_PUSH 0X1105
+#define UUID_SERVCLASS_OBEX_FILE_TRANSFER 0X1106
+#define UUID_SERVCLASS_IRMC_SYNC_COMMAND 0X1107
+#define UUID_SERVCLASS_HEADSET 0X1108
+#define UUID_SERVCLASS_CORDLESS_TELEPHONY 0X1109
+#define UUID_SERVCLASS_AUDIO_SOURCE 0X110A
+#define UUID_SERVCLASS_AUDIO_SINK 0X110B
+#define UUID_SERVCLASS_AV_REM_CTRL_TARGET 0X110C /* Audio/Video Control profile */
+#define UUID_SERVCLASS_ADV_AUDIO_DISTRIBUTION 0X110D /* Advanced Audio Distribution profile */
+#define UUID_SERVCLASS_AV_REMOTE_CONTROL 0X110E /* Audio/Video Control profile */
+#define UUID_SERVCLASS_AV_REM_CTRL_CONTROL 0X110F /* Audio/Video Control profile */
+#define UUID_SERVCLASS_INTERCOM 0X1110
+#define UUID_SERVCLASS_FAX 0X1111
+#define UUID_SERVCLASS_HEADSET_AUDIO_GATEWAY 0X1112
+#define UUID_SERVCLASS_WAP 0X1113
+#define UUID_SERVCLASS_WAP_CLIENT 0X1114
+#define UUID_SERVCLASS_PANU 0X1115 /* PAN profile */
+#define UUID_SERVCLASS_NAP 0X1116 /* PAN profile */
+#define UUID_SERVCLASS_GN 0X1117 /* PAN profile */
+#define UUID_SERVCLASS_DIRECT_PRINTING 0X1118 /* BPP profile */
+#define UUID_SERVCLASS_REFERENCE_PRINTING 0X1119 /* BPP profile */
+#define UUID_SERVCLASS_IMAGING 0X111A /* Imaging profile */
+#define UUID_SERVCLASS_IMAGING_RESPONDER 0X111B /* Imaging profile */
+#define UUID_SERVCLASS_IMAGING_AUTO_ARCHIVE 0X111C /* Imaging profile */
+#define UUID_SERVCLASS_IMAGING_REF_OBJECTS 0X111D /* Imaging profile */
+#define UUID_SERVCLASS_HF_HANDSFREE 0X111E /* Handsfree profile */
+#define UUID_SERVCLASS_AG_HANDSFREE 0X111F /* Handsfree profile */
+#define UUID_SERVCLASS_DIR_PRT_REF_OBJ_SERVICE 0X1120 /* BPP profile */
+#define UUID_SERVCLASS_REFLECTED_UI 0X1121 /* BPP profile */
+#define UUID_SERVCLASS_BASIC_PRINTING 0X1122 /* BPP profile */
+#define UUID_SERVCLASS_PRINTING_STATUS 0X1123 /* BPP profile */
+#define UUID_SERVCLASS_HUMAN_INTERFACE 0X1124 /* HID profile */
+#define UUID_SERVCLASS_CABLE_REPLACEMENT 0X1125 /* HCRP profile */
+#define UUID_SERVCLASS_HCRP_PRINT 0X1126 /* HCRP profile */
+#define UUID_SERVCLASS_HCRP_SCAN 0X1127 /* HCRP profile */
+#define UUID_SERVCLASS_COMMON_ISDN_ACCESS 0X1128 /* CAPI Message Transport Protocol*/
+#define UUID_SERVCLASS_VIDEO_CONFERENCING_GW 0X1129 /* Video Conferencing profile */
+#define UUID_SERVCLASS_UDI_MT 0X112A /* Unrestricted Digital Information profile */
+#define UUID_SERVCLASS_UDI_TA 0X112B /* Unrestricted Digital Information profile */
+#define UUID_SERVCLASS_VCP 0X112C /* Video Conferencing profile */
+#define UUID_SERVCLASS_SAP 0X112D /* SIM Access profile */
+#define UUID_SERVCLASS_PBAP_PCE 0X112E /* Phonebook Access - PCE */
+#define UUID_SERVCLASS_PBAP_PSE 0X112F /* Phonebook Access - PSE */
+#define UUID_SERVCLASS_PHONE_ACCESS 0x1130
+#define UUID_SERVCLASS_HEADSET_HS 0x1131 /* Headset - HS, from HSP v1.2 */
+#define UUID_SERVCLASS_PNP_INFORMATION 0X1200 /* Device Identification */
+#define UUID_SERVCLASS_GENERIC_NETWORKING 0X1201
+#define UUID_SERVCLASS_GENERIC_FILETRANSFER 0X1202
+#define UUID_SERVCLASS_GENERIC_AUDIO 0X1203
+#define UUID_SERVCLASS_GENERIC_TELEPHONY 0X1204
+#define UUID_SERVCLASS_UPNP_SERVICE 0X1205 /* UPNP_Service [ESDP] */
+#define UUID_SERVCLASS_UPNP_IP_SERVICE 0X1206 /* UPNP_IP_Service [ESDP] */
+#define UUID_SERVCLASS_ESDP_UPNP_IP_PAN 0X1300 /* UPNP_IP_PAN [ESDP] */
+#define UUID_SERVCLASS_ESDP_UPNP_IP_LAP 0X1301 /* UPNP_IP_LAP [ESDP] */
+#define UUID_SERVCLASS_ESDP_UPNP_IP_L2CAP 0X1302 /* UPNP_L2CAP [ESDP] */
+#define UUID_SERVCLASS_VIDEO_SOURCE 0X1303 /* Video Distribution Profile (VDP) */
+#define UUID_SERVCLASS_VIDEO_SINK 0X1304 /* Video Distribution Profile (VDP) */
+#define UUID_SERVCLASS_VIDEO_DISTRIBUTION 0X1305 /* Video Distribution Profile (VDP) */
+#define UUID_SERVCLASS_HDP_PROFILE 0X1400 /* Health Device profile (HDP) */
+#define UUID_SERVCLASS_HDP_SOURCE 0X1401 /* Health Device profile (HDP) */
+#define UUID_SERVCLASS_HDP_SINK 0X1402 /* Health Device profile (HDP) */
+#define UUID_SERVCLASS_MAP_PROFILE 0X1134 /* MAP profile UUID */
+#define UUID_SERVCLASS_MESSAGE_ACCESS 0X1132 /* Message Access Service UUID */
+#define UUID_SERVCLASS_MESSAGE_NOTIFICATION 0X1133 /* Message Notification Service UUID */
+
+#define UUID_SERVCLASS_GAP_SERVER 0x1800
+#define UUID_SERVCLASS_GATT_SERVER 0x1801
+#define UUID_SERVCLASS_IMMEDIATE_ALERT 0x1802 /* immediate alert */
+#define UUID_SERVCLASS_LINKLOSS 0x1803 /* Link Loss Alert */
+#define UUID_SERVCLASS_TX_POWER 0x1804 /* TX power */
+#define UUID_SERVCLASS_CURRENT_TIME 0x1805 /* Link Loss Alert */
+#define UUID_SERVCLASS_DST_CHG 0x1806 /* DST Time change */
+#define UUID_SERVCLASS_REF_TIME_UPD 0x1807 /* reference time update */
+#define UUID_SERVCLASS_THERMOMETER 0x1809 /* Thermometer UUID */
+#define UUID_SERVCLASS_DEVICE_INFO 0x180A /* device info service */
+#define UUID_SERVCLASS_NWA 0x180B /* Network availability */
+#define UUID_SERVCLASS_HEART_RATE 0x180D /* Heart Rate service */
+#define UUID_SERVCLASS_PHALERT 0x180E /* phone alert service */
+#define UUID_SERVCLASS_BATTERY 0x180F /* battery service */
+#define UUID_SERVCLASS_BPM 0x1810 /* blood pressure service */
+#define UUID_SERVCLASS_ALERT_NOTIFICATION 0x1811 /* alert notification service */
+#define UUID_SERVCLASS_LE_HID 0x1812 /* HID over LE */
+#define UUID_SERVCLASS_SCAN_PARAM 0x1813 /* Scan Parameter service */
+#define UUID_SERVCLASS_GLUCOSE 0x1808 /* Glucose Meter Service */
+#define UUID_SERVCLASS_RSC 0x1814 /* RUNNERS SPEED AND CADENCE SERVICE */
+#define UUID_SERVCLASS_CSC 0x1816 /* Cycling SPEED AND CADENCE SERVICE */
+
+#define UUID_SERVCLASS_TEST_SERVER 0x9000 /* Test Group UUID */
+
+#if (BTM_WBS_INCLUDED == TRUE)
+#define UUID_CODEC_CVSD 0x0001 /* CVSD */
+#define UUID_CODEC_MSBC 0x0002 /* mSBC */
+#endif
+
+/* Define all the 'Descriptor Type' values.
+*/
+#define NULL_DESC_TYPE 0
+#define UINT_DESC_TYPE 1
+#define TWO_COMP_INT_DESC_TYPE 2
+#define UUID_DESC_TYPE 3
+#define TEXT_STR_DESC_TYPE 4
+#define BOOLEAN_DESC_TYPE 5
+#define DATA_ELE_SEQ_DESC_TYPE 6
+#define DATA_ELE_ALT_DESC_TYPE 7
+#define URL_DESC_TYPE 8
+
+/* Define all the "Descriptor Size" values.
+*/
+#define SIZE_ONE_BYTE 0
+#define SIZE_TWO_BYTES 1
+#define SIZE_FOUR_BYTES 2
+#define SIZE_EIGHT_BYTES 3
+#define SIZE_SIXTEEN_BYTES 4
+#define SIZE_IN_NEXT_BYTE 5
+#define SIZE_IN_NEXT_WORD 6
+#define SIZE_IN_NEXT_LONG 7
+
+/* Language Encoding Constants */
+#define LANG_ID_CODE_ENGLISH ((UINT16) 0x656e) /* "en" */
+#define LANG_ID_CHAR_ENCODE_UTF8 ((UINT16) 0x006a) /* UTF-8 */
+
+/* Constants used for display purposes only. These define ovelapping attribute values */
+#define ATTR_ID_VERS_OR_GRP_OR_DRELNUM_OR_IPSUB_OR_SPECID 0x0200
+#define ATTR_ID_VEND_ID_OR_SERVICE_DB_STATE_OR_PARSE_VER 0x0201
+#define ATTR_ID_PROD_ID_OR_HID_DEV_SUBCLASS 0x0202
+#define ATTR_ID_PROD_VER_OR_HID_COUNTRY_CODE 0x0203
+#define ATTR_ID_PRIMARY_REC_OR_HID_VIRTUAL_CABLE 0x0204
+#define ATTR_ID_DI_VENDOR_ID_SOURCE_OR_HID_INIT_RECONNECT 0x0205
+#define ATTR_ID_SERV_VERS_OR_1284ID 0x0300
+#define ATTR_ID_DATA_STORES_OR_NETWORK 0x0301
+#define ATTR_ID_FAX_1_OR_AUD_VOL_OR_DEV_NAME 0x0302
+#define ATTR_ID_FORMATS_OR_FAX_2_0 0x0303
+#define ATTR_ID_FAX_CLASS_2_OR_FRIENDLY_NAME 0x0304
+#define ATTR_ID_NETADDRESS_OR_DEVLOCATION 0x0306
+
+#endif
diff --git a/lib/bt/host/bluedroid/stack/include/stack/smp_api.h b/lib/bt/host/bluedroid/stack/include/stack/smp_api.h
new file mode 100644
index 00000000..11d432e7
--- /dev/null
+++ b/lib/bt/host/bluedroid/stack/include/stack/smp_api.h
@@ -0,0 +1,508 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the SMP API function external definitions.
+ *
+ ******************************************************************************/
+#ifndef SMP_API_H
+#define SMP_API_H
+
+#include "common/bt_target.h"
+
+#define SMP_PIN_CODE_LEN_MAX PIN_CODE_LEN
+#define SMP_PIN_CODE_LEN_MIN 6
+
+// #if SMP_INCLUDED == TRUE
+/* SMP command code */
+#define SMP_OPCODE_PAIRING_REQ 0x01
+#define SMP_OPCODE_PAIRING_RSP 0x02
+#define SMP_OPCODE_CONFIRM 0x03
+#define SMP_OPCODE_RAND 0x04
+#define SMP_OPCODE_PAIRING_FAILED 0x05
+#define SMP_OPCODE_ENCRYPT_INFO 0x06
+#define SMP_OPCODE_MASTER_ID 0x07
+#define SMP_OPCODE_IDENTITY_INFO 0x08
+#define SMP_OPCODE_ID_ADDR 0x09
+#define SMP_OPCODE_SIGN_INFO 0x0A
+#define SMP_OPCODE_SEC_REQ 0x0B
+#define SMP_OPCODE_PAIR_PUBLIC_KEY 0x0C
+#define SMP_OPCODE_PAIR_DHKEY_CHECK 0x0D
+#define SMP_OPCODE_PAIR_KEYPR_NOTIF 0x0E
+#define SMP_OPCODE_MAX SMP_OPCODE_PAIR_KEYPR_NOTIF
+#define SMP_OPCODE_MIN SMP_OPCODE_PAIRING_REQ
+#define SMP_OPCODE_PAIR_COMMITM 0x0F
+// #endif
+
+/* SMP event type */
+#define SMP_IO_CAP_REQ_EVT 1 /* IO capability request event */
+#define SMP_SEC_REQUEST_EVT 2 /* SMP pairing request */
+#define SMP_PASSKEY_NOTIF_EVT 3 /* passkey notification event */
+#define SMP_PASSKEY_REQ_EVT 4 /* passkey request event */
+#define SMP_OOB_REQ_EVT 5 /* OOB request event */
+#define SMP_NC_REQ_EVT 6 /* Numeric Comparison request event */
+#define SMP_COMPLT_EVT 7 /* SMP complete event */
+#define SMP_PEER_KEYPR_NOT_EVT 8 /* Peer keypress notification received event */
+#define SMP_SC_OOB_REQ_EVT 9 /* SC OOB request event (both local and peer OOB data */
+/* can be expected in response) */
+#define SMP_SC_LOC_OOB_DATA_UP_EVT 10 /* SC OOB local data set is created */
+/* (as result of SMP_CrLocScOobData(...)) */
+#define SMP_BR_KEYS_REQ_EVT 12 /* SMP over BR keys request event */
+typedef UINT8 tSMP_EVT;
+
+
+/* pairing failure reason code */
+#define SMP_PASSKEY_ENTRY_FAIL 0x01
+#define SMP_OOB_FAIL 0x02
+#define SMP_PAIR_AUTH_FAIL 0x03
+#define SMP_CONFIRM_VALUE_ERR 0x04
+#define SMP_PAIR_NOT_SUPPORT 0x05
+#define SMP_ENC_KEY_SIZE 0x06
+#define SMP_INVALID_CMD 0x07
+#define SMP_PAIR_FAIL_UNKNOWN 0x08
+#define SMP_REPEATED_ATTEMPTS 0x09
+#define SMP_INVALID_PARAMETERS 0x0A
+#define SMP_DHKEY_CHK_FAIL 0x0B
+#define SMP_NUMERIC_COMPAR_FAIL 0x0C
+#define SMP_BR_PARING_IN_PROGR 0x0D
+#define SMP_XTRANS_DERIVE_NOT_ALLOW 0x0E
+#define SMP_MAX_FAIL_RSN_PER_SPEC SMP_XTRANS_DERIVE_NOT_ALLOW
+
+/* self defined error code */
+#define SMP_PAIR_INTERNAL_ERR (SMP_MAX_FAIL_RSN_PER_SPEC + 0x01) /* 0x0F */
+
+/* 0x0F unknown IO capability, unable to decide association model */
+#define SMP_UNKNOWN_IO_CAP (SMP_MAX_FAIL_RSN_PER_SPEC + 0x02) /* 0x10 */
+
+#define SMP_INIT_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x03) /* 0x11 */
+#define SMP_CONFIRM_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x04) /* 0x12 */
+#define SMP_BUSY (SMP_MAX_FAIL_RSN_PER_SPEC + 0x05) /* 0x13 */
+#define SMP_ENC_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x06) /* 0x14 */
+#define SMP_STARTED (SMP_MAX_FAIL_RSN_PER_SPEC + 0x07) /* 0x15 */
+#define SMP_RSP_TIMEOUT (SMP_MAX_FAIL_RSN_PER_SPEC + 0x08) /* 0x16 */
+#define SMP_DIV_NOT_AVAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x09) /* 0x17 */
+
+/* 0x17 unspecified failed reason */
+#define SMP_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x0A) /* 0x18 */
+
+#define SMP_CONN_TOUT (SMP_MAX_FAIL_RSN_PER_SPEC + 0x0B) /* 0x19 */
+#define SMP_SUCCESS 0
+
+typedef UINT8 tSMP_STATUS;
+
+
+/* Device IO capability */
+#define SMP_IO_CAP_OUT BTM_IO_CAP_OUT /* DisplayOnly */
+#define SMP_IO_CAP_IO BTM_IO_CAP_IO /* DisplayYesNo */
+#define SMP_IO_CAP_IN BTM_IO_CAP_IN /* KeyboardOnly */
+#define SMP_IO_CAP_NONE BTM_IO_CAP_NONE /* NoInputNoOutput */
+#define SMP_IO_CAP_KBDISP BTM_IO_CAP_KBDISP /* Keyboard Display */
+#define SMP_IO_CAP_MAX BTM_IO_CAP_MAX
+typedef UINT8 tSMP_IO_CAP;
+
+#ifndef SMP_DEFAULT_IO_CAPS
+#define SMP_DEFAULT_IO_CAPS SMP_IO_CAP_KBDISP
+#endif
+
+/* OOB data present or not */
+enum {
+ SMP_OOB_NONE,
+ SMP_OOB_PRESENT,
+ SMP_OOB_UNKNOWN
+};
+typedef UINT8 tSMP_OOB_FLAG;
+
+/* type of OOB data required from application */
+enum {
+ SMP_OOB_INVALID_TYPE,
+ SMP_OOB_PEER,
+ SMP_OOB_LOCAL,
+ SMP_OOB_BOTH
+};
+typedef UINT8 tSMP_OOB_DATA_TYPE;
+
+#define SMP_AUTH_NO_BOND 0x00
+#define SMP_AUTH_GEN_BOND 0x01 //todo sdh change GEN_BOND to BOND
+
+/* SMP Authentication requirement */
+#define SMP_AUTH_YN_BIT (1 << 2)
+#define SMP_SC_SUPPORT_BIT (1 << 3)
+#define SMP_KP_SUPPORT_BIT (1 << 4)
+
+#define SMP_AUTH_MASK (SMP_AUTH_GEN_BOND|SMP_AUTH_YN_BIT|SMP_SC_SUPPORT_BIT|SMP_KP_SUPPORT_BIT)
+
+#define SMP_AUTH_BOND SMP_AUTH_GEN_BOND
+
+/* no MITM, No Bonding, encryption only */
+#define SMP_AUTH_NB_ENC_ONLY 0x00 //(SMP_AUTH_MASK | BTM_AUTH_SP_NO)
+
+/* MITM, No Bonding, Use IO Capability to determine authentication procedure */
+#define SMP_AUTH_NB_IOCAP (SMP_AUTH_NO_BOND | SMP_AUTH_YN_BIT)
+
+/* No MITM, General Bonding, Encryption only */
+#define SMP_AUTH_GB_ENC_ONLY (SMP_AUTH_GEN_BOND )
+
+/* MITM, General Bonding, Use IO Capability to determine authentication procedure */
+#define SMP_AUTH_GB_IOCAP (SMP_AUTH_GEN_BOND | SMP_AUTH_YN_BIT)
+
+/* Secure Connections, no MITM, no Bonding */
+#define SMP_AUTH_SC_ENC_ONLY (SMP_SC_SUPPORT_BIT)
+
+/* Secure Connections, no MITM, Bonding */
+#define SMP_AUTH_SC_GB (SMP_SC_SUPPORT_BIT | SMP_AUTH_GEN_BOND)
+
+/* Secure Connections, MITM, no Bonding */
+#define SMP_AUTH_SC_MITM_NB (SMP_SC_SUPPORT_BIT | SMP_AUTH_YN_BIT | SMP_AUTH_NO_BOND)
+
+/* Secure Connections, MITM, Bonding */
+#define SMP_AUTH_SC_MITM_GB (SMP_SC_SUPPORT_BIT | SMP_AUTH_YN_BIT | SMP_AUTH_GEN_BOND)
+
+/* All AuthReq RFU bits are set to 1 - NOTE: reserved bit in Bonding_Flags is not set */
+#define SMP_AUTH_ALL_RFU_SET 0xF8
+
+typedef UINT8 tSMP_AUTH_REQ;
+
+#define SMP_SEC_NONE 0
+#define SMP_SEC_UNAUTHENTICATE (1 << 0)
+#define SMP_SEC_AUTHENTICATED (1 << 2)
+typedef UINT8 tSMP_SEC_LEVEL;
+
+/* Maximum Encryption Key Size range */
+#define SMP_ENCR_KEY_SIZE_MIN 7
+#define SMP_ENCR_KEY_SIZE_MAX 16
+
+/* SMP key types */
+#define SMP_SEC_KEY_TYPE_ENC (1 << 0) /* encryption key */
+#define SMP_SEC_KEY_TYPE_ID (1 << 1) /* identity key */
+#define SMP_SEC_KEY_TYPE_CSRK (1 << 2) /* slave CSRK */
+#define SMP_SEC_KEY_TYPE_LK (1 << 3) /* BR/EDR link key */
+typedef UINT8 tSMP_KEYS;
+
+#define SMP_BR_SEC_DEFAULT_KEY (SMP_SEC_KEY_TYPE_ENC | SMP_SEC_KEY_TYPE_ID | \
+ SMP_SEC_KEY_TYPE_CSRK)
+
+/* default security key distribution value */
+#define SMP_SEC_DEFAULT_KEY (SMP_SEC_KEY_TYPE_ENC | SMP_SEC_KEY_TYPE_ID | \
+ SMP_SEC_KEY_TYPE_CSRK | SMP_SEC_KEY_TYPE_LK)
+
+#define SMP_SC_KEY_STARTED 0 /* passkey entry started */
+#define SMP_SC_KEY_ENTERED 1 /* passkey digit entered */
+#define SMP_SC_KEY_ERASED 2 /* passkey digit erased */
+#define SMP_SC_KEY_CLEARED 3 /* passkey cleared */
+#define SMP_SC_KEY_COMPLT 4 /* passkey entry completed */
+#define SMP_SC_KEY_OUT_OF_RANGE 5 /* out of range */
+typedef UINT8 tSMP_SC_KEY_TYPE;
+
+/* data type for BTM_SP_IO_REQ_EVT */
+typedef struct {
+ tSMP_IO_CAP io_cap; /* local IO capabilities */
+ tSMP_OOB_FLAG oob_data; /* OOB data present (locally) for the peer device */
+ tSMP_AUTH_REQ auth_req; /* Authentication required (for local device) */
+ UINT8 max_key_size; /* max encryption key size */
+ tSMP_KEYS init_keys; /* initiator keys to be distributed */
+ tSMP_KEYS resp_keys; /* responder keys */
+} tSMP_IO_REQ;
+
+typedef struct {
+ tSMP_STATUS reason;
+ tSMP_SEC_LEVEL sec_level;
+ BOOLEAN is_pair_cancel;
+ BOOLEAN smp_over_br;
+ tSMP_AUTH_REQ auth_mode;
+} tSMP_CMPL;
+
+typedef struct {
+ BT_OCTET32 x;
+ BT_OCTET32 y;
+} tSMP_PUBLIC_KEY;
+
+/* the data associated with the info sent to the peer via OOB interface */
+typedef struct {
+ BOOLEAN present;
+ BT_OCTET16 randomizer;
+ BT_OCTET16 commitment;
+
+ tBLE_BD_ADDR addr_sent_to;
+ BT_OCTET32 private_key_used; /* is used to calculate: */
+ /* publ_key_used = P-256(private_key_used, curve_p256.G) - send it to the */
+ /* other side */
+ /* dhkey = P-256(private_key_used, publ key rcvd from the other side) */
+ tSMP_PUBLIC_KEY publ_key_used; /* P-256(private_key_used, curve_p256.G) */
+} tSMP_LOC_OOB_DATA;
+
+/* the data associated with the info received from the peer via OOB interface */
+typedef struct {
+ BOOLEAN present;
+ BT_OCTET16 randomizer;
+ BT_OCTET16 commitment;
+ tBLE_BD_ADDR addr_rcvd_from;
+} tSMP_PEER_OOB_DATA;
+
+typedef struct {
+ tSMP_LOC_OOB_DATA loc_oob_data;
+ tSMP_PEER_OOB_DATA peer_oob_data;
+} tSMP_SC_OOB_DATA;
+
+
+typedef union {
+ UINT32 passkey;
+ tSMP_IO_REQ io_req; /* IO request */
+ tSMP_CMPL cmplt;
+ tSMP_OOB_DATA_TYPE req_oob_type;
+ tSMP_LOC_OOB_DATA loc_oob_data;
+} tSMP_EVT_DATA;
+
+
+/* AES Encryption output */
+typedef struct {
+ UINT8 status;
+ UINT8 param_len;
+ UINT16 opcode;
+ UINT8 param_buf[BT_OCTET16_LEN];
+} tSMP_ENC;
+
+/* Security Manager events - Called by the stack when Security Manager related events occur.*/
+typedef UINT8 (tSMP_CALLBACK) (tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data);
+
+/* callback function for CMAC algorithm
+*/
+typedef void (tCMAC_CMPL_CBACK)(UINT8 *p_mac, UINT16 tlen, UINT32 sign_counter);
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* API of SMP */
+
+/*******************************************************************************
+**
+** Function SMP_Init
+**
+** Description This function initializes the SMP unit.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void SMP_Init(void);
+
+/*******************************************************************************
+**
+** Function SMP_Free
+**
+** Description This function de initializes the SMP unit.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void SMP_Free(void);
+
+
+/*******************************************************************************
+**
+** Function SMP_SetTraceLevel
+**
+** Description This function sets the trace level for SMP. If called with
+** a value of 0xFF, it simply returns the current trace level.
+**
+** Returns The new or current trace level
+**
+*******************************************************************************/
+extern UINT8 SMP_SetTraceLevel (UINT8 new_level);
+
+/*******************************************************************************
+**
+** Function SMP_Register
+**
+** Description This function register for the SMP service callback.
+**
+** Returns void
+**
+*******************************************************************************/
+extern BOOLEAN SMP_Register (tSMP_CALLBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function SMP_Pair
+**
+** Description This function is called to start a SMP pairing.
+**
+** Returns SMP_STARTED if bond started, else otherwise exception.
+**
+*******************************************************************************/
+extern tSMP_STATUS SMP_Pair (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function SMP_BR_PairWith
+**
+** Description This function is called to start a SMP pairing over BR/EDR.
+**
+** Returns SMP_STARTED if pairing started, otherwise reason for failure.
+**
+*******************************************************************************/
+extern tSMP_STATUS SMP_BR_PairWith (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function SMP_PairCancel
+**
+** Description This function is called to cancel a SMP pairing.
+**
+** Returns TRUE - pairing cancelled
+**
+*******************************************************************************/
+extern BOOLEAN SMP_PairCancel (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function SMP_SecurityGrant
+**
+** Description This function is called to grant security process.
+**
+** Parameters bd_addr - peer device bd address.
+** res - result of the operation SMP_SUCCESS if success.
+** Otherwise, SMP_REPEATED_ATTEMPTS is too many attempts.
+**
+** Returns None
+**
+*******************************************************************************/
+extern void SMP_SecurityGrant(BD_ADDR bd_addr, UINT8 res);
+
+/*******************************************************************************
+**
+** Function SMP_PasskeyReply
+**
+** Description This function is called after Security Manager submitted
+** Passkey request to the application.
+**
+** Parameters: bd_addr - Address of the device for which PIN was requested
+** res - result of the operation SMP_SUCCESS if success
+** passkey - numeric value in the range of
+** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
+**
+*******************************************************************************/
+extern void SMP_PasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey);
+
+/*******************************************************************************
+**
+** Function SMP_SetStaticPasskey
+**
+** Description This function is called to set static passkey
+**
+**
+** Parameters: add - set static passkey when add is TRUE
+** clear static passkey when add is FALSE
+** passkey - static passkey
+**
+**
+*******************************************************************************/
+extern void SMP_SetStaticPasskey (BOOLEAN add, UINT32 passkey);
+
+/*******************************************************************************
+**
+** Function SMP_ConfirmReply
+**
+** Description This function is called after Security Manager submitted
+** numeric comparison request to the application.
+**
+** Parameters: bd_addr - Address of the device with which numeric
+** comparison was requested
+** res - comparison result SMP_SUCCESS if success
+**
+*******************************************************************************/
+extern void SMP_ConfirmReply (BD_ADDR bd_addr, UINT8 res);
+
+/*******************************************************************************
+**
+** Function SMP_OobDataReply
+**
+** Description This function is called to provide the OOB data for
+** SMP in response to SMP_OOB_REQ_EVT
+**
+** Parameters: bd_addr - Address of the peer device
+** res - result of the operation SMP_SUCCESS if success
+** p_data - SM Randomizer C.
+**
+*******************************************************************************/
+extern void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, UINT8 len,
+ UINT8 *p_data);
+
+/*******************************************************************************
+**
+** Function SMP_SecureConnectionOobDataReply
+**
+** Description This function is called to provide the SC OOB data for
+** SMP in response to SMP_SC_OOB_REQ_EVT
+**
+** Parameters: p_data - pointer to the data
+**
+*******************************************************************************/
+extern void SMP_SecureConnectionOobDataReply(UINT8 *p_data);
+
+/*******************************************************************************
+**
+** Function SMP_Encrypt
+**
+** Description This function is called to encrypt the data with the specified
+** key
+**
+** Parameters: key - Pointer to key key[0] conatins the MSB
+** key_len - key length
+** plain_text - Pointer to data to be encrypted
+** plain_text[0] conatins the MSB
+** pt_len - plain text length
+** p_out - pointer to the encrypted outputs
+**
+** Returns Boolean - TRUE: encryption is successful
+*******************************************************************************/
+extern BOOLEAN SMP_Encrypt (UINT8 *key, UINT8 key_len,
+ UINT8 *plain_text, UINT8 pt_len,
+ tSMP_ENC *p_out);
+
+/*******************************************************************************
+**
+** Function SMP_KeypressNotification
+**
+** Description This function is called to notify SM about Keypress Notification.
+**
+** Parameters: bd_addr - Address of the device to send keypress
+** notification to
+** value - keypress notification parameter value
+**
+*******************************************************************************/
+extern void SMP_KeypressNotification (BD_ADDR bd_addr, UINT8 value);
+
+/*******************************************************************************
+**
+** Function SMP_CreateLocalSecureConnectionsOobData
+**
+** Description This function is called to start creation of local SC OOB
+** data set (tSMP_LOC_OOB_DATA).
+**
+** Returns Boolean - TRUE: creation of local SC OOB data set started.
+*******************************************************************************/
+extern BOOLEAN SMP_CreateLocalSecureConnectionsOobData (void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* SMP_API_H */