summaryrefslogtreecommitdiffstats
path: root/stack/include
diff options
context:
space:
mode:
Diffstat (limited to 'stack/include')
-rw-r--r--stack/include/a2d_api.h257
-rw-r--r--stack/include/a2d_sbc.h212
-rw-r--r--stack/include/avct_api.h279
-rw-r--r--stack/include/avdt_api.h902
-rw-r--r--stack/include/avdtc_api.h231
-rw-r--r--stack/include/avrc_api.h634
-rw-r--r--stack/include/avrc_defs.h1419
-rw-r--r--stack/include/bnep_api.h476
-rw-r--r--stack/include/bt_types.h690
-rw-r--r--stack/include/btm_api.h4556
-rw-r--r--stack/include/btm_ble_api.h729
-rw-r--r--stack/include/btu.h310
-rw-r--r--stack/include/dyn_mem.h187
-rw-r--r--stack/include/gatt_api.h1128
-rw-r--r--stack/include/gattdefs.h109
-rw-r--r--stack/include/goep_fs.h393
-rw-r--r--stack/include/hcidefs.h2233
-rw-r--r--stack/include/hcimsgs.h1331
-rw-r--r--stack/include/hiddefs.h158
-rw-r--r--stack/include/hidh_api.h222
-rw-r--r--stack/include/l2c_api.h1185
-rw-r--r--stack/include/l2cdefs.h309
-rw-r--r--stack/include/mca_api.h495
-rw-r--r--stack/include/mca_defs.h87
-rw-r--r--stack/include/obx_api.h1704
-rw-r--r--stack/include/pan_api.h459
-rw-r--r--stack/include/port_api.h635
-rw-r--r--stack/include/port_ext.h32
-rw-r--r--stack/include/rfcdefs.h248
-rw-r--r--stack/include/sdp_api.h756
-rw-r--r--stack/include/sdpdefs.h319
-rw-r--r--stack/include/smp_api.h300
-rw-r--r--stack/include/uipc_msg.h884
-rw-r--r--stack/include/utfc.h61
-rw-r--r--stack/include/wbt_api.h71
-rw-r--r--stack/include/wcassert.h65
36 files changed, 24066 insertions, 0 deletions
diff --git a/stack/include/a2d_api.h b/stack/include/a2d_api.h
new file mode 100644
index 0000000..f21ba6c
--- /dev/null
+++ b/stack/include/a2d_api.h
@@ -0,0 +1,257 @@
+/******************************************************************************
+ *
+ * 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 "sdp_api.h"
+
+/*****************************************************************************
+** constants
+*****************************************************************************/
+
+/* 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.
+**
+******************************************************************************/
+A2D_API 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.
+**
+******************************************************************************/
+A2D_API 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.
+**
+******************************************************************************/
+A2D_API 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
+******************************************************************************/
+A2D_API extern UINT8 A2D_BitsSet(UINT8 num);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+A2D_API extern void A2D_Init(void);
+
+#endif /* A2D_API_H */
diff --git a/stack/include/a2d_sbc.h b/stack/include/a2d_sbc.h
new file mode 100644
index 0000000..dad0b8b
--- /dev/null
+++ b/stack/include/a2d_sbc.h
@@ -0,0 +1,212 @@
+/******************************************************************************
+ *
+ * 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
+
+/*****************************************************************************
+** 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_SbcChkFrInit
+**
+** Description check if need to init the descramble control block.
+**
+** Returns nothing.
+******************************************************************************/
+A2D_API extern void A2D_SbcChkFrInit(UINT8 *p_pkt);
+
+/******************************************************************************
+**
+** Function A2D_SbcDescramble
+**
+** Description descramble the packet.
+**
+** Returns nothing.
+******************************************************************************/
+A2D_API extern void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len);
+
+/******************************************************************************
+**
+** 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.
+******************************************************************************/
+A2D_API 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.
+******************************************************************************/
+A2D_API 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.
+******************************************************************************/
+A2D_API 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.
+******************************************************************************/
+A2D_API extern void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag,
+ BOOLEAN *p_start, BOOLEAN *p_last,
+ UINT8 *p_num);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* A2D_SBC_H */
diff --git a/stack/include/avct_api.h b/stack/include/avct_api.h
new file mode 100644
index 0000000..2880011
--- /dev/null
+++ b/stack/include/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 "bt_types.h"
+#include "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
+
+/* 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
+**
+*******************************************************************************/
+AVCT_API 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
+**
+*******************************************************************************/
+AVCT_API 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.
+**
+*******************************************************************************/
+AVCT_API 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.
+**
+*******************************************************************************/
+AVCT_API 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.
+**
+*******************************************************************************/
+AVCT_API 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.
+**
+*******************************************************************************/
+AVCT_API 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.
+**
+*******************************************************************************/
+AVCT_API 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.
+**
+*******************************************************************************/
+AVCT_API 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.
+**
+*******************************************************************************/
+AVCT_API extern UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* AVCT_API_H */
+
diff --git a/stack/include/avdt_api.h b/stack/include/avdt_api.h
new file mode 100644
index 0000000..0a9b7f8
--- /dev/null
+++ b/stack/include/avdt_api.h
@@ -0,0 +1,902 @@
+/******************************************************************************
+ *
+ * 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 "bt_types.h"
+#include "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 */
+
+/* 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 */
+
+/*****************************************************************************
+** 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;
+
+
+/*****************************************************************************
+** 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
+**
+*******************************************************************************/
+AVDT_API 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
+**
+*******************************************************************************/
+AVDT_API extern void AVDT_Deregister(void);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
+ UINT8 m_pt);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+*******************************************************************************/
+AVDT_API extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len);
+
+/*******************************************************************************
+**
+** Function AVDT_SendReport
+**
+** Description
+**
+**
+**
+** Returns
+**
+*******************************************************************************/
+AVDT_API 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.
+**
+******************************************************************************/
+AVDT_API extern UINT8 AVDT_SetTraceLevel (UINT8 new_level);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* AVDT_API_H */
diff --git a/stack/include/avdtc_api.h b/stack/include/avdtc_api.h
new file mode 100644
index 0000000..14a1a21
--- /dev/null
+++ b/stack/include/avdtc_api.h
@@ -0,0 +1,231 @@
+/******************************************************************************
+ *
+ * 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 "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
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_Init(tAVDTC_CTRL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function AVDTC_DiscoverRsp
+**
+** Description Send a discover response.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API 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
+**
+*******************************************************************************/
+AVDT_API 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
+**
+*******************************************************************************/
+AVDT_API 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
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_GetConfigReq(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDTC_GetConfigRsp
+**
+** Description Send a get configuration response.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_GetConfigRsp(UINT8 handle, UINT8 label, tAVDT_CFG *p_cfg);
+
+/*******************************************************************************
+**
+** Function AVDTC_OpenReq
+**
+** Description Send an open request.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_OpenReq(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDTC_OpenRsp
+**
+** Description Send an open response.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_OpenRsp(UINT8 handle, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_StartRsp
+**
+** Description Send a start response.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_StartRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_CloseRsp
+**
+** Description Send a close response.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_CloseRsp(UINT8 handle, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_SuspendRsp
+**
+** Description Send a suspend response.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_SuspendRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_AbortReq
+**
+** Description Send an abort request.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_AbortReq(UINT8 handle);
+
+/*******************************************************************************
+**
+** Function AVDTC_AbortRsp
+**
+** Description Send an abort response.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API extern void AVDTC_AbortRsp(UINT8 handle, UINT8 label);
+
+/*******************************************************************************
+**
+** Function AVDTC_Rej
+**
+** Description Send a reject message.
+**
+** Returns void
+**
+*******************************************************************************/
+AVDT_API 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/stack/include/avrc_api.h b/stack/include/avrc_api.h
new file mode 100644
index 0000000..1f4bb7f
--- /dev/null
+++ b/stack/include/avrc_api.h
@@ -0,0 +1,634 @@
+/******************************************************************************
+ *
+ * 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 "bt_target.h"
+#include "avct_api.h"
+#include "sdp_api.h"
+#include "avrc_defs.h"
+
+/*****************************************************************************
+** 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
+
+/* 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().
+**
+** Output Parameters:
+** None.
+**
+** Returns AVRC_SUCCESS if successful.
+** AVRC_NO_RESOURCES if not enough resources to build the SDP record.
+**
+******************************************************************************/
+AVRC_API extern UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
+ char *p_provider_name, UINT16 categories, UINT32 sdp_handle);
+
+/******************************************************************************
+**
+** 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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.
+**
+******************************************************************************/
+AVRC_API 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 void
+**
+*******************************************************************************/
+AVRC_API extern void AVRC_Init(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
+**
+*******************************************************************************/
+AVRC_API 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
+**
+*******************************************************************************/
+AVRC_API extern tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result, UINT8 *p_buf, UINT16 buf_len);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+AVRC_API 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.
+**
+*******************************************************************************/
+AVRC_API 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
+**
+**
+*******************************************************************************/
+AVRC_API 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
+**
+*******************************************************************************/
+AVRC_API extern BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AVRC_API_H */
diff --git a/stack/include/avrc_defs.h b/stack/include/avrc_defs.h
new file mode 100644
index 0000000..16ba057
--- /dev/null
+++ b/stack/include/avrc_defs.h
@@ -0,0 +1,1419 @@
+/******************************************************************************
+ *
+ * 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
+
+/*****************************************************************************
+** constants
+*****************************************************************************/
+
+/* Profile revision numbers */
+#define AVRC_REV_1_0 0x0100
+#define AVRC_REV_1_3 0x0103
+#define AVRC_REV_1_4 0x0104
+
+#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_APP_SETTING_CHANGE)) ? TRUE : FALSE)
+
+#define AVRC_IS_VALID_ATTRIBUTE(a) (((((a > 0) && a <= AVRC_PLAYER_SETTING_SCAN)) || \
+ ((a >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) && \
+ (a <= AVRC_PLAYER_SETTING_HIGH_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 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
diff --git a/stack/include/bnep_api.h b/stack/include/bnep_api.h
new file mode 100644
index 0000000..b2bc0fd
--- /dev/null
+++ b/stack/include/bnep_api.h
@@ -0,0 +1,476 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2001-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 Bluetooth Network
+ * Encapsilation Protocol (BNEP).
+ *
+ ******************************************************************************/
+#ifndef BNEP_API_H
+#define BNEP_API_H
+
+#include "l2c_api.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+/* Define the minimum offset needed in a GKI buffer for
+** sending BNEP packets. Note, we are currently not sending
+** extension headers, but may in the future, so allow
+** space for them
+*/
+#define BNEP_MINIMUM_OFFSET (15 + L2CAP_MIN_OFFSET)
+#define BNEP_INVALID_HANDLE 0xFFFF
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+/* Define the result codes from BNEP
+*/
+enum
+{
+ BNEP_SUCCESS, /* Success */
+ BNEP_CONN_DISCONNECTED, /* Connection terminated */
+ BNEP_NO_RESOURCES, /* No resources */
+ BNEP_MTU_EXCEDED, /* Attempt to write long data */
+ BNEP_INVALID_OFFSET, /* Insufficient offset in GKI buffer */
+ BNEP_CONN_FAILED, /* Connection failed */
+ BNEP_CONN_FAILED_CFG, /* Connection failed cos of config */
+ BNEP_CONN_FAILED_SRC_UUID, /* Connection failed wrong source UUID */
+ BNEP_CONN_FAILED_DST_UUID, /* Connection failed wrong destination UUID */
+ BNEP_CONN_FAILED_UUID_SIZE, /* Connection failed wrong size UUID */
+ BNEP_Q_SIZE_EXCEEDED, /* Too many buffers to dest */
+ BNEP_TOO_MANY_FILTERS, /* Too many local filters specified */
+ BNEP_SET_FILTER_FAIL, /* Set Filter failed */
+ BNEP_WRONG_HANDLE, /* Wrong handle for the connection */
+ BNEP_WRONG_STATE, /* Connection is in wrong state */
+ BNEP_SECURITY_FAIL, /* Failed because of security */
+ BNEP_IGNORE_CMD, /* To ignore the rcvd command */
+ BNEP_TX_FLOW_ON, /* tx data flow enabled */
+ BNEP_TX_FLOW_OFF /* tx data flow disabled */
+
+}; typedef UINT8 tBNEP_RESULT;
+
+
+/***************************
+** Callback Functions
+****************************/
+
+/* Connection state change callback prototype. Parameters are
+** Connection handle
+** BD Address of remote
+** Connection state change result
+** BNEP_SUCCESS indicates connection is success
+** All values are used to indicate the reason for failure
+** Flag to indicate if it is just a role change
+*/
+typedef void (tBNEP_CONN_STATE_CB) (UINT16 handle,
+ BD_ADDR rem_bda,
+ tBNEP_RESULT result,
+ BOOLEAN is_role_change);
+
+
+
+
+/* Connection indication callback prototype. Parameters are
+** BD Address of remote, remote UUID and local UUID
+** and flag to indicate role change and handle to the connection
+** When BNEP calls this function profile should
+** use BNEP_ConnectResp call to accept or reject the request
+*/
+typedef void (tBNEP_CONNECT_IND_CB) (UINT16 handle,
+ BD_ADDR bd_addr,
+ tBT_UUID *remote_uuid,
+ tBT_UUID *local_uuid,
+ BOOLEAN is_role_change);
+
+
+
+/* Data buffer received indication callback prototype. Parameters are
+** Handle to the connection
+** Source BD/Ethernet Address
+** Dest BD/Ethernet address
+** Protocol
+** Pointer to the buffer
+** Flag to indicate whether extension headers to be forwarded are present
+*/
+typedef void (tBNEP_DATA_BUF_CB) (UINT16 handle,
+ UINT8 *src,
+ UINT8 *dst,
+ UINT16 protocol,
+ BT_HDR *p_buf,
+ BOOLEAN fw_ext_present);
+
+
+/* Data received indication callback prototype. Parameters are
+** Handle to the connection
+** Source BD/Ethernet Address
+** Dest BD/Ethernet address
+** Protocol
+** Pointer to the beginning of the data
+** Length of data
+** Flag to indicate whether extension headers to be forwarded are present
+*/
+typedef void (tBNEP_DATA_IND_CB) (UINT16 handle,
+ UINT8 *src,
+ UINT8 *dst,
+ UINT16 protocol,
+ UINT8 *p_data,
+ UINT16 len,
+ BOOLEAN fw_ext_present);
+
+/* Flow control callback for TX data. Parameters are
+** Handle to the connection
+** Event flow status
+*/
+typedef void (tBNEP_TX_DATA_FLOW_CB) (UINT16 handle,
+ tBNEP_RESULT event);
+
+/* Filters received indication callback prototype. Parameters are
+** Handle to the connection
+** TRUE if the cb is called for indication
+** Ignore this if it is indication, otherwise it is the result
+** for the filter set operation performed by the local
+** device
+** Number of protocol filters present
+** Pointer to the filters start. Filters are present in pairs
+** of start of the range and end of the range.
+** They will be present in big endian order. First
+** two bytes will be starting of the first range and
+** next two bytes will be ending of the range.
+*/
+typedef void (tBNEP_FILTER_IND_CB) (UINT16 handle,
+ BOOLEAN indication,
+ tBNEP_RESULT result,
+ UINT16 num_filters,
+ UINT8 *p_filters);
+
+
+
+/* Multicast Filters received indication callback prototype. Parameters are
+** Handle to the connection
+** TRUE if the cb is called for indication
+** Ignore this if it is indication, otherwise it is the result
+** for the filter set operation performed by the local
+** device
+** Number of multicast filters present
+** Pointer to the filters start. Filters are present in pairs
+** of start of the range and end of the range.
+** First six bytes will be starting of the first range and
+** next six bytes will be ending of the range.
+*/
+typedef void (tBNEP_MFILTER_IND_CB) (UINT16 handle,
+ BOOLEAN indication,
+ tBNEP_RESULT result,
+ UINT16 num_mfilters,
+ UINT8 *p_mfilters);
+
+/* This is the structure used by profile to register with BNEP */
+typedef struct
+{
+ tBNEP_CONNECT_IND_CB *p_conn_ind_cb; /* To indicate the conn request */
+ tBNEP_CONN_STATE_CB *p_conn_state_cb; /* To indicate conn state change */
+ tBNEP_DATA_IND_CB *p_data_ind_cb; /* To pass the data received */
+ tBNEP_DATA_BUF_CB *p_data_buf_cb; /* To pass the data buffer received */
+ tBNEP_TX_DATA_FLOW_CB *p_tx_data_flow_cb; /* data flow callback */
+ tBNEP_FILTER_IND_CB *p_filter_ind_cb; /* To indicate that peer set protocol filters */
+ tBNEP_MFILTER_IND_CB *p_mfilter_ind_cb; /* To indicate that peer set mcast filters */
+
+} tBNEP_REGISTER;
+
+
+
+/* This is the structure used by profile to get the status of BNEP */
+typedef struct
+{
+#define BNEP_STATUS_FAILE 0
+#define BNEP_STATUS_CONNECTED 1
+ UINT8 con_status;
+
+ UINT16 l2cap_cid;
+ BD_ADDR rem_bda;
+ UINT16 rem_mtu_size;
+ UINT16 xmit_q_depth;
+
+ UINT16 sent_num_filters;
+ UINT16 sent_mcast_filters;
+ UINT16 rcvd_num_filters;
+ UINT16 rcvd_mcast_filters;
+ tBT_UUID src_uuid;
+ tBT_UUID dst_uuid;
+
+} tBNEP_STATUS;
+
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+**
+** Function BNEP_Register
+**
+** Description This function is called by the upper layer to register
+** its callbacks with BNEP
+**
+** Parameters: p_reg_info - contains all callback function pointers
+**
+**
+** Returns BNEP_SUCCESS if registered successfully
+** BNEP_FAILURE if connection state callback is missing
+**
+*******************************************************************************/
+BNEP_API extern tBNEP_RESULT BNEP_Register (tBNEP_REGISTER *p_reg_info);
+
+/*******************************************************************************
+**
+** Function BNEP_Deregister
+**
+** Description This function is called by the upper layer to de-register
+** its callbacks.
+**
+** Parameters: void
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BNEP_API extern void BNEP_Deregister (void);
+
+
+/*******************************************************************************
+**
+** Function BNEP_Connect
+**
+** Description This function creates a BNEP connection to a remote
+** device.
+**
+** Parameters: p_rem_addr - BD_ADDR of the peer
+** src_uuid - source uuid for the connection
+** dst_uuid - destination uuid for the connection
+** p_handle - pointer to return the handle for the connection
+**
+** Returns BNEP_SUCCESS if connection started
+** BNEP_NO_RESOURCES if no resources
+**
+*******************************************************************************/
+BNEP_API extern tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
+ tBT_UUID *src_uuid,
+ tBT_UUID *dst_uuid,
+ UINT16 *p_handle);
+
+/*******************************************************************************
+**
+** Function BNEP_ConnectResp
+**
+** Description This function is called in responce to connection indication
+**
+**
+** Parameters: handle - handle given in the connection indication
+** resp - responce for the connection indication
+**
+** Returns BNEP_SUCCESS if connection started
+** BNEP_WRONG_HANDLE if the connection is not found
+** BNEP_WRONG_STATE if the responce is not expected
+**
+*******************************************************************************/
+BNEP_API extern tBNEP_RESULT BNEP_ConnectResp (UINT16 handle, tBNEP_RESULT resp);
+
+/*******************************************************************************
+**
+** Function BNEP_Disconnect
+**
+** Description This function is called to close the specified connection.
+**
+** Parameters: handle - handle of the connection
+**
+** Returns BNEP_SUCCESS if connection is disconnected
+** BNEP_WRONG_HANDLE if no connection is not found
+**
+*******************************************************************************/
+BNEP_API extern tBNEP_RESULT BNEP_Disconnect (UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BNEP_WriteBuf
+**
+** Description This function sends data in a GKI buffer on BNEP connection
+**
+** Parameters: handle - handle of the connection to write
+** p_dest_addr - BD_ADDR/Ethernet addr of the destination
+** p_buf - pointer to address of buffer with data
+** protocol - protocol type of the packet
+** p_src_addr - (optional) BD_ADDR/ethernet address of the source
+** (should be NULL if it is local BD Addr)
+** fw_ext_present - forwarded extensions present
+**
+** Returns: BNEP_WRONG_HANDLE - if passed handle is not valid
+** BNEP_MTU_EXCEDED - If the data length is greater than MTU
+** BNEP_IGNORE_CMD - If the packet is filtered out
+** BNEP_Q_SIZE_EXCEEDED - If the Tx Q is full
+** BNEP_SUCCESS - If written successfully
+**
+*******************************************************************************/
+BNEP_API extern tBNEP_RESULT BNEP_WriteBuf (UINT16 handle,
+ UINT8 *p_dest_addr,
+ BT_HDR *p_buf,
+ UINT16 protocol,
+ UINT8 *p_src_addr,
+ BOOLEAN fw_ext_present);
+
+/*******************************************************************************
+**
+** Function BNEP_Write
+**
+** Description This function sends data over a BNEP connection
+**
+** Parameters: handle - handle of the connection to write
+** p_dest_addr - BD_ADDR/Ethernet addr of the destination
+** p_data - pointer to data start
+** protocol - protocol type of the packet
+** p_src_addr - (optional) BD_ADDR/ethernet address of the source
+** (should be NULL if it is local BD Addr)
+** fw_ext_present - forwarded extensions present
+**
+** Returns: BNEP_WRONG_HANDLE - if passed handle is not valid
+** BNEP_MTU_EXCEDED - If the data length is greater than MTU
+** BNEP_IGNORE_CMD - If the packet is filtered out
+** BNEP_Q_SIZE_EXCEEDED - If the Tx Q is full
+** BNEP_NO_RESOURCES - If not able to allocate a buffer
+** BNEP_SUCCESS - If written successfully
+**
+*******************************************************************************/
+BNEP_API extern tBNEP_RESULT BNEP_Write (UINT16 handle,
+ UINT8 *p_dest_addr,
+ UINT8 *p_data,
+ UINT16 len,
+ UINT16 protocol,
+ UINT8 *p_src_addr,
+ BOOLEAN fw_ext_present);
+
+/*******************************************************************************
+**
+** Function BNEP_SetProtocolFilters
+**
+** Description This function sets the protocol filters on peer device
+**
+** Parameters: handle - Handle for the connection
+** num_filters - total number of filter ranges
+** p_start_array - Array of beginings of all protocol ranges
+** p_end_array - Array of ends of all protocol ranges
+**
+** Returns BNEP_WRONG_HANDLE - if the connection handle is not valid
+** BNEP_SET_FILTER_FAIL - if the connection is in wrong state
+** BNEP_TOO_MANY_FILTERS - if too many filters
+** BNEP_SUCCESS - if request sent successfully
+**
+*******************************************************************************/
+BNEP_API extern tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle,
+ UINT16 num_filters,
+ UINT16 *p_start_array,
+ UINT16 *p_end_array);
+
+/*******************************************************************************
+**
+** Function BNEP_SetMulticastFilters
+**
+** Description This function sets the filters for multicast addresses for BNEP.
+**
+** Parameters: handle - Handle for the connection
+** num_filters - total number of filter ranges
+** p_start_array - Pointer to sequence of beginings of all
+** multicast address ranges
+** p_end_array - Pointer to sequence of ends of all
+** multicast address ranges
+**
+** Returns BNEP_WRONG_HANDLE - if the connection handle is not valid
+** BNEP_SET_FILTER_FAIL - if the connection is in wrong state
+** BNEP_TOO_MANY_FILTERS - if too many filters
+** BNEP_SUCCESS - if request sent successfully
+**
+*******************************************************************************/
+BNEP_API extern tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle,
+ UINT16 num_filters,
+ UINT8 *p_start_array,
+ UINT8 *p_end_array);
+
+/*******************************************************************************
+**
+** Function BNEP_GetMyBdAddr
+**
+** Description This function returns a pointer to the local device BD address.
+** If the BD address has not been read yet, it returns NULL.
+**
+** Returns the BD address
+**
+*******************************************************************************/
+BNEP_API extern UINT8 *BNEP_GetMyBdAddr (void);
+
+/*******************************************************************************
+**
+** Function BNEP_SetTraceLevel
+**
+** Description This function sets the trace level for BNEP. If called with
+** a value of 0xFF, it simply reads the current trace level.
+**
+** Returns the new (current) trace level
+**
+*******************************************************************************/
+BNEP_API extern UINT8 BNEP_SetTraceLevel (UINT8 new_level);
+
+/*******************************************************************************
+**
+** Function BNEP_Init
+**
+** Description This function initializes the BNEP unit. It should be called
+** before accessing any other APIs to initialize the control block
+**
+** Returns void
+**
+*******************************************************************************/
+BNEP_API extern void BNEP_Init (void);
+
+/*******************************************************************************
+**
+** Function BNEP_GetStatus
+**
+** Description This function gets the status information for BNEP connection
+**
+** Returns BNEP_SUCCESS - if the status is available
+** BNEP_NO_RESOURCES - if no structure is passed for output
+** BNEP_WRONG_HANDLE - if the handle is invalid
+** BNEP_WRONG_STATE - if not in connected state
+**
+*******************************************************************************/
+BNEP_API extern tBNEP_RESULT BNEP_GetStatus (UINT16 handle, tBNEP_STATUS *p_status);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/stack/include/bt_types.h b/stack/include/bt_types.h
new file mode 100644
index 0000000..5809968
--- /dev/null
+++ b/stack/include/bt_types.h
@@ -0,0 +1,690 @@
+/******************************************************************************
+ *
+ * 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 "data_types.h"
+
+#ifdef _WIN32
+#ifdef BLUESTACK_TESTER
+ #include "bte_stack_entry.h"
+#endif
+#endif
+
+/* 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
+ /* 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_OBX_CL_MSG 0x3100
+#define BT_EVT_TO_OBX_SR_MSG 0x3200
+
+#define BT_EVT_TO_CTP_CMDS 0x3300
+
+/* Obex Over L2CAP */
+#define BT_EVT_TO_OBX_CL_L2C_MSG 0x3400
+#define BT_EVT_TO_OBX_SR_L2C_MSG 0x3500
+
+/* ftp events */
+#define BT_EVT_TO_FTP_SRVR_CMDS 0x3800
+#define BT_EVT_TO_FTP_CLNT_CMDS 0x3900
+
+#define BT_EVT_TO_BTU_SAP 0x3a00 /* SIM Access Profile events */
+
+/* opp events */
+#define BT_EVT_TO_OPP_SRVR_CMDS 0x3b00
+#define BT_EVT_TO_OPP_CLNT_CMDS 0x3c00
+
+/* gap events */
+#define BT_EVT_TO_GAP_MSG 0x3d00
+
+/* start timer */
+#define BT_EVT_TO_START_TIMER 0x3e00
+
+/* start quick timer */
+#define BT_EVT_TO_START_QUICK_TIMER 0x3f00
+
+
+/* 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_LLCP_ECHO 0x4200 /* LLCP Echo Service */
+#define BT_EVT_TO_LLCP_SOCKET 0x4300 /* LLCP over TCP/IP */
+#define BT_EVT_TO_NCI_LP 0x4400 /* Low power */
+#define BT_EVT_TO_NFC_ERR 0x4500 /* 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 BT_EVT_TRIGGER_STACK_INIT EVENT_MASK(APPL_EVT_0)
+
+
+/* Define the header of each buffer used in the Bluetooth stack.
+*/
+typedef struct
+{
+ UINT16 event;
+ UINT16 len;
+ UINT16 offset;
+ UINT16 layer_specific;
+} BT_HDR;
+
+#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++;}
+
+/********************************************************************************
+** 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 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 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 */
+#define BD_ADDR_LEN 6 /* Device address length */
+typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */
+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 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]; /* 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 */
+
+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)
+
+/* Maximum UUID size - 16 bytes, and structure to hold any type of UUID. */
+#define MAX_UUID_SIZE 16
+typedef struct
+{
+#define LEN_UUID_16 2
+#define LEN_UUID_32 4
+#define LEN_UUID_128 16
+
+ UINT16 len;
+
+ union
+ {
+ UINT16 uuid16;
+ UINT32 uuid32;
+ UINT8 uuid128[MAX_UUID_SIZE];
+ } uu;
+
+} tBT_UUID;
+
+#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_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_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC)
+typedef UINT8 tBLE_ADDR_TYPE;
+
+#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 trace levels */
+#define BT_TRACE_LEVEL_NONE 0 /* No trace messages to be generated */
+#define BT_TRACE_LEVEL_ERROR 1 /* Error condition trace messages */
+#define BT_TRACE_LEVEL_WARNING 2 /* Warning condition trace messages */
+#define BT_TRACE_LEVEL_API 3 /* API traces */
+#define BT_TRACE_LEVEL_EVENT 4 /* Debug messages for events */
+#define BT_TRACE_LEVEL_DEBUG 5 /* Full debug messages */
+#define BT_TRACE_LEVEL_VERBOSE 6 /* Verbose debug messages */
+
+#define MAX_TRACE_LEVEL 6
+
+
+/* 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_DUN 0x000f0000
+#define TRACE_LAYER_GOEP 0x00100000
+#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_IDEP 0x00290000
+#define TRACE_LAYER_NDEP 0x002a0000
+#define TRACE_LAYER_LLCP 0x002b0000
+#define TRACE_LAYER_RW 0x002c0000
+#define TRACE_LAYER_CE 0x002d0000
+#define TRACE_LAYER_SNEP 0x002e0000
+#define TRACE_LAYER_NDEF 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_DEP 0x00008000
+#define SCR_PROTO_TRACE_LLCP 0x00010000
+#define SCR_PROTO_TRACE_NDEF 0x00020000
+#define SCR_PROTO_TRACE_TAGS 0x00040000
+#define SCR_PROTO_TRACE_ALL 0x0007ffff
+#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, ...);
+
+#endif
+
diff --git a/stack/include/btm_api.h b/stack/include/btm_api.h
new file mode 100644
index 0000000..09bb749
--- /dev/null
+++ b/stack/include/btm_api.h
@@ -0,0 +1,4556 @@
+/******************************************************************************
+ *
+ * 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 "bt_target.h"
+#include "sdp_api.h"
+#include "hcidefs.h"
+
+#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
+#include "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 */
+};
+typedef UINT8 tBTM_STATUS;
+
+/*************************
+** 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 void (tBTM_DEV_STATUS_CB) (tBTM_DEV_STATUS status);
+
+
+/* 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);
+
+/* 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);
+
+/*****************************************************************************
+** 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_GENERAL_INQUIRY 0
+#define BTM_LIMITED_INQUIRY 1
+#define BTM_BR_INQUIRY_MASK 0x0f
+/* 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 0x1 /* a general inquiry is in progress */
+#define BTM_LIMITED_INQUIRY_ACTIVE 0x2 /* 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 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
+*/
+#ifndef BTM_EIR_UUID_LKUP_TBL
+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
+};
+#endif /* BTM_EIR_UUID_LKUP_TBL */
+
+/* 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_MANUFACTURER_SPECIFIC_TYPE HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xFF */
+
+/* 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 */
+} 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 */
+#if (BTM_EIR_CLIENT_INCLUDED == TRUE)
+ UINT32 eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE];
+ BOOLEAN eir_complete_list;
+#endif
+#if (BLE_INCLUDED == TRUE)
+ tBT_DEVICE_TYPE device_type;
+ UINT8 inq_result_type;
+ UINT8 ble_addr_type;
+ tBTM_BLE_EVT_TYPE ble_evt_type;
+ UINT8 flag;
+#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 (BTM_INQ_GET_REMOTE_NAME == TRUE || 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;
+ 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 link policy information (in tBTM_CMPL_CB callback function)
+** in response to BTM_ReadLinkPolicy call.
+*/
+typedef struct
+{
+ tBTM_STATUS status;
+ UINT8 hci_status;
+ BD_ADDR rem_bda;
+ UINT16 settings;
+} tBTM_LNK_POLICY_RESULTS;
+
+/* 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 Change Link Key information (in tBTM_CMPL_CB callback function)
+** in response to BTM_ChangeLinkKey call.
+*/
+typedef struct
+{
+ UINT8 hci_status; /* HCI status returned with the event */
+ BD_ADDR remote_bd_addr; /* Remote BD addr involved with the change link key */
+} tBTM_CHANGE_KEY_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;
+} 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 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_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
+
+/* 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; /* The remote device's supported features */
+} 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 */
+} 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 as above.
+ * Otherwise, the number of ACL links. */
+} 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.
+*/
+typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
+ BD_NAME p_bdn, BD_FEATURES features,
+ BOOLEAN is_new);
+
+/*****************************************************************************
+** 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 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 HCI_BRCM_SCO_ROUTE_PCM
+#define BTM_SCO_ROUTE_HCI HCI_BRCM_SCO_ROUTE_HCI
+typedef UINT8 tBTM_SCO_ROUTE_TYPE;
+
+
+/*******************
+** SCO Codec Types
+********************/
+#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 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_16BIT | \
+ 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;
+
+/***************************
+** 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
+
+/* 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_BOND 0x0040 /* Bonding */
+#define BTM_SEC_BOND_CONN 0x0080 /* bond_created_connection */
+#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 */
+
+/* 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_IGNORE 0xff /* used when event is response from
+ hci return link keys request */
+
+/* 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_HID_SEC_CTRL 32
+#define BTM_SEC_SERVICE_HID_NOSEC_CTRL 33
+#define BTM_SEC_SERVICE_HID_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
+
+/* Update these as services are added */
+#define BTM_SEC_SERVICE_FIRST_EMPTY 51
+
+#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) {int 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) {int 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_HID_CTRL (1 << (BTM_SEC_SERVICE_HID_SEC_CTRL - 32))
+#define BTM_SEC_TRUST_HID_NOSEC_CTRL (1 << (BTM_SEC_SERVICE_HID_NOSEC_CTRL - 32))
+#define BTM_SEC_TRUST_HID_INTR (1 << (BTM_SEC_SERVICE_HID_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
+*/
+typedef UINT8 (tBTM_PIN_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
+ tBTM_BD_NAME bd_name);
+
+
+/* Get Link Key for the connection. Parameters are
+** BD Address of remote
+** Link Key
+*/
+typedef UINT8 (tBTM_LINK_KEY_REQ_CALLBACK) (BD_ADDR bd_addr, LINK_KEY key);
+
+/* 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);
+
+
+/* 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);
+
+/* Operation abort. Called by the stack when link goes down during. Pin code
+** request or authorization. Parameters are
+** BD Address of remote
+**
+*/
+typedef UINT8 (tBTM_ABORT_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
+ tBTM_BD_NAME bd_name);
+
+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;
+
+#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 */
+
+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, /* passkey entry started */
+ BTM_SP_KEY_ENTERED, /* passkey digit entered */
+ BTM_SP_KEY_ERASED, /* passkey digit erased */
+ BTM_SP_KEY_CLEARED, /* passkey cleared */
+ BTM_SP_KEY_COMPLT /* passkey entry completed */
+};
+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, 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
+*/
+enum
+{
+ BTM_LE_IO_REQ_EVT = 1, /* received IO_CAPABILITY_REQUEST event */
+ BTM_LE_SEC_REQUEST_EVT, /* security request event */
+ BTM_LE_KEY_NOTIF_EVT, /* received USER_PASSKEY_NOTIFY event */
+ BTM_LE_KEY_REQ_EVT, /* received USER_PASSKEY_REQUEST event */
+ BTM_LE_OOB_REQ_EVT, /* OOB data request event */
+ BTM_LE_COMPLT_EVT, /* received SIMPLE_PAIRING_COMPLETE event */
+ BTM_LE_KEY_EVT /* KEY update event */
+};
+typedef UINT8 tBTM_LE_EVT;
+
+#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_LENC (SMP_SEC_KEY_TYPE_ENC << 3) /* master role security information:div */
+#define BTM_LE_KEY_LID (SMP_SEC_KEY_TYPE_ID << 3) /* master device ID key */
+#define BTM_LE_KEY_LCSRK (SMP_SEC_KEY_TYPE_CSRK << 3) /* local CSRK has been deliver to peer */
+typedef UINT8 tBTM_LE_KEY_TYPE;
+
+#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 */
+typedef UINT8 tBTM_LE_AUTH_REQ;
+
+#define BTM_LE_AUTH_REQ_MASK SMP_AUTH_MASK /* 0x03*/
+
+/* LE security level */
+#define BTM_LE_SEC_NONE SMP_SEC_NONE
+#define BTM_LE_SEC_UNAUTHENTICATE SMP_SEC_UNAUTHENTICATE
+#define BTM_LE_SEC_AUTHENTICATED SMP_SEC_AUTHENTICATED
+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;
+}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
+{
+ UINT16 div;
+ UINT8 key_size;
+ UINT8 sec_level;
+}tBTM_LE_LENC_KEYS;
+
+/* BLE SRK keys */
+typedef struct
+{
+ UINT32 counter;
+ UINT16 div;
+ UINT8 sec_level;
+
+}tBTM_LE_LCSRK_KEYS;
+
+
+typedef union
+{
+ tBTM_LE_PENC_KEYS penc_key; /* received peer encryption key */
+ tBTM_LE_PCSRK_KEYS pcsrk_key; /* received peer device SRK */
+ BT_OCTET16 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 */
+ /* no callback dta for BTM_LE_KEY_REQ_EVT & BTM_LE_OOB_REQ_EVT */
+#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
+ tBTM_LE_COMPLT complt; /* BTM_LE_COMPLT_EVT */
+#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_LINK_KEY_REQ_CALLBACK *p_link_key_req_callback;
+ tBTM_AUTH_COMPLETE_CALLBACK *p_auth_complete_callback;
+ tBTM_ABORT_CALLBACK *p_abort_callback;
+ tBTM_BOND_CANCEL_CMPL_CALLBACK *p_bond_cancel_cmpl_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_RETURN_LINK_KEYS 1
+#define BTM_CB_EVT_READ_STORED_LINK_KEYS 2
+#define BTM_CB_EVT_WRITE_STORED_LINK_KEYS 3
+#define BTM_CB_EVT_DELETE_STORED_LINK_KEYS 4
+
+typedef struct
+{
+ UINT8 event;
+
+} tBTM_STORED_LINK_KEYS_EVT;
+
+
+typedef struct
+{
+ UINT8 event;
+ UINT8 num_keys;
+
+} tBTM_RETURN_LINK_KEYS_EVT;
+
+
+typedef struct
+{
+ BD_ADDR bd_addr;
+ LINK_KEY link_key;
+
+} tBTM_BD_ADDR_LINK_KEY_PAIR;
+
+
+typedef struct
+{
+ UINT8 event;
+ UINT8 status;
+ UINT16 max_keys;
+ UINT16 read_keys;
+
+} tBTM_READ_STORED_LINK_KEY_COMPLETE;
+
+
+typedef struct
+{
+ UINT8 event;
+ UINT8 status;
+ UINT8 num_keys;
+
+} tBTM_WRITE_STORED_LINK_KEY_COMPLETE;
+
+
+typedef struct
+{
+ UINT8 event;
+ UINT8 status;
+ UINT16 num_keys;
+
+} tBTM_DELETE_STORED_LINK_KEY_COMPLETE;
+
+
+/* These macros are defined to check the Broadcom features supported in controller
+ * (the return value for BTM_ReadBrcmFeatures() */
+/* multi-av */
+#define BTM_FEATURE_MULTI_AV_MASK 0x01
+#define BTM_FEATURE_MULTI_AV_OFF 0
+#define BTM_VSC_MULTI_AV_SUPPORTED(x) ((x)[BTM_FEATURE_MULTI_AV_OFF] & BTM_FEATURE_MULTI_AV_MASK)
+
+/* WBS SBC codec */
+#define BTM_FEATURE_WBS_SBC_MASK 0x02
+#define BTM_FEATURE_WBS_SBC_OFF 0
+#define BTM_VSC_WBS_SBC_SUPPORTED(x) ((x)[BTM_FEATURE_WBS_SBC_OFF] & BTM_FEATURE_WBS_SBC_MASK)
+
+/* Advanced Audio LC-PLC */
+#define BTM_FEATURE_AUDIO_LC_PLC_MASK 0x04
+#define BTM_FEATURE_AUDIO_LC_PLC_OFF 0
+#define BTM_VSC_AUDIO_LC_PLC_SUPPORTED(x) ((x)[BTM_FEATURE_AUDIO_LC_PLC_OFF] & BTM_FEATURE_AUDIO_LC_PLC_MASK)
+
+/* Light stack for audio routing in Controller */
+#define BTM_FEATURE_LIGHT_STACK_MASK 0x08
+#define BTM_FEATURE_LIGHT_STACK_OFF 0
+#define BTM_VSC_LIGHT_STACK_SUPPORTED(x) ((x)[BTM_FEATURE_LIGHT_STACK_OFF] & BTM_FEATURE_LIGHT_STACK_MASK)
+
+/* NFC support */
+#define BTM_FEATURE_NFC_MASK (HCI_BRCM_FEATURE_NFC_MASK) /* 0x10 */
+#define BTM_FEATURE_NFC_OFF (HCI_BRCM_FEATURE_NFC_OFF) /* 0 */
+#define BTM_VSC_NFC_SUPPORTED(x) ((x)[BTM_FEATURE_NFC_OFF] & BTM_FEATURE_NFC_MASK)
+
+
+/************************
+** Dual-Stack support
+*************************/
+/* BTM_SYNC_FAIL_EVT reason codes */
+#define BTM_SYNC_SUCCESS 0
+#define BTM_SYNC_FAIL_BTE_SWITCH_REJECTED 1
+#define BTM_SYNC_FAIL_TRANS_PAUSE 2
+#define BTM_SYNC_FAIL_CORE_SYNC 3
+#define BTM_SYNC_FAIL_BTA_SYNC 4
+#define BTM_SYNC_FAIL_TRANS_RESUME 5
+#define BTM_SYNC_FAIL_RESYNC 6
+#define BTM_SYNC_FAIL_ERROR 7
+#define BTM_SYNC_FAIL_UIPC_OPEN 8
+typedef UINT8 tBTM_SYNC_STATUS;
+
+/* Direction of sync (used by BTM_SyncStack) */
+#define BTM_SW_BB_TO_MM 0
+#define BTM_SW_TO_BB 1 /* Switch back to baseband stack (from either MM or BTC host) */
+#define BTM_SW_RESYNC 2
+#define BTM_SW_BB_TO_BTC 3 /* Switch from baseband stack to Bluetooth Controller Host stack */
+#define BTM_SW_MM_TO_BB 4
+#define BTM_SW_BTC_TO_BB 5
+typedef UINT8 tBTM_SW_DIR;
+
+/* Stack synchronization events (returned by tBTM_SYNC_STACK_CBACK callback) */
+#define BTM_SYNC_CPLT_EVT 0
+#define BTM_SYNC_BTA_EVT 1
+#define BTM_RESYNC_CPLT_EVT 2
+#define BTM_UIPC_OPENED_EVT 3
+#define BTM_UIPC_CLOSED_EVT 4
+typedef UINT8 tBTM_SYNC_STACK_EVT;
+
+/* Synchronization info from BTA/application that will be sent when calling BTE sync request functions */
+typedef struct
+{
+ tBTM_SW_DIR dir;
+ UINT16 lcid[BTM_SYNC_INFO_NUM_STR];
+ UINT8 avdt_handle[BTM_SYNC_INFO_NUM_STR];
+} tBTM_SYNC_INFO;
+
+/* Stack synchonization callback function
+** Parameters are
+** event: stack synchronization event
+** status: BTM_SUCCESS if event was successful
+*/
+typedef void (*tBTM_SYNC_STACK_CBACK)(tBTM_SYNC_STACK_EVT event, tBTM_SYNC_STATUS status);
+
+
+/* Sync complete callback function. Called by bte layers after synchronization is complete
+** so that BTM_SYNC can procede with the next step for switching stack to MM
+**
+** Parameters are
+** status: BTM_SUCCESS if synchronization was successful
+*/
+typedef void (*tBTM_SYNC_CPLT_CBACK)(tBTM_STATUS status);
+
+
+
+/* IPC event callback function. Called by BTM when an IPC event is received.
+** These events are currently sent to DM through the callback function.
+**
+** Parameters are
+** status: BTM_SUCCESS if synchronization was successful
+** p_data: Actual message in the IPC
+*/
+typedef void (tBTM_IPC_EVT_CBACK)(tBTM_STATUS status, BT_HDR *p_data);
+
+/* 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);
+
+/*****************************************************************************
+** EXTERNAL FUNCTION DECLARATIONS
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+** DEVICE CONTROL and COMMON FUNCTIONS
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function BTM_SetAfhChannels
+**
+** Description This function is called to disable channels
+**
+** Returns status
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetAfhChannels (UINT8 first, UINT8 last);
+
+/*******************************************************************************
+**
+** Function BTM_SetAfhChannelAssessment
+**
+** Description This function is called to set the channel assessment mode on or off
+**
+** Returns status
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetAfhChannelAssessment (BOOLEAN enable_or_disable);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadLocalDeviceNameFromController (tBTM_CMPL_CB *p_rln_cmpl_cback);
+
+/*******************************************************************************
+**
+** Function BTM_ReadLocalVersion
+**
+** Description This function is called to read the local device version
+**
+** Returns BTM_SUCCESS if successful, otherwise an error
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadLocalVersion (tBTM_VERSION_INFO *p_vers);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadLocalDeviceAddr
+**
+** Description This function is called to read the local device address
+**
+** Returns BTM_SUCCESS
+** Callback returns the local device address
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadLocalDeviceAddr (tBTM_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_GetLocalDeviceAddr
+**
+** Description This function is called to read the local device address
+**
+** Returns void
+** the local device address is copied into bd_addr
+**
+*******************************************************************************/
+ BTM_API extern void BTM_GetLocalDeviceAddr (BD_ADDR bd_addr);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadDeviceClass
+**
+** Description This function is called to read the local device class
+**
+** Returns pointer to the device class
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern UINT8 *BTM_ReadLocalFeatures (void);
+
+/*******************************************************************************
+**
+** Function BTM_ReadBrcmFeatures
+**
+** Description This function is called to read the Broadcom specific features
+**
+** Returns pointer to the Broadcom features string
+**
+*******************************************************************************/
+ BTM_API extern UINT8 *BTM_ReadBrcmFeatures (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.
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_RegisterForVSEvents (tBTM_VS_EVT_CB *p_cb, BOOLEAN is_register);
+
+
+/*******************************************************************************
+**
+** Function BTM_ContinueReset
+**
+** Description Instructs stack to continue its stack initialization after
+** an application has completed any vender specific commands
+** sent to the controller.
+**
+** Note: This function is only called if an application
+** initialization function has been inserted in the reset
+** sequence. (BTM_APP_DEV_INIT is defined with a function).
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_ContinueReset (void);
+
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode,
+ UINT8 param_len,
+ UINT8 *p_param_buf,
+ tBTM_VSC_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ BTM_API extern 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
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern BOOLEAN BTM_FreeSCN(UINT8 scn);
+
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout);
+
+/*******************************************************************************
+**
+** Function BTM_WriteVoiceSettings
+**
+** Description Send HCI Write Voice Settings command.
+** See hcidefs.h for settings bitmask values.
+**
+** Returns
+** BTM_SUCCESS Command sent.
+** BTM_NO_RESOURCES If out of resources to send the command.
+**
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_CancelPeriodicInquiry(void);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetInquiryFilterCallback
+**
+** Description Host can register to be asked whenever an inquiry result
+** is received. If host does not like the device no name
+** request is issued for the device
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_SetInquiryFilterCallback(tBTM_FILTER_CB *p_callback);
+
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BT_API 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.
+**
+*******************************************************************************/
+ BT_API 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.
+**
+*******************************************************************************/
+
+ BT_API 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.
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda,
+ tBTM_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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 features
+**
+** Returns pointer to the features string
+**
+*******************************************************************************/
+ BTM_API extern UINT8 *BTM_ReadRemoteFeatures (BD_ADDR addr);
+
+/*******************************************************************************
+**
+** Function BTM_InqFirstResult
+**
+** Description This function looks through the inquiry database for the first
+** used entrysince the LAST inquiry. This is used in conjunction
+** with BTM_InqNext by applications as a way to walk through the
+** inquiry results database.
+**
+** Returns pointer to first in-use entry, or NULL if DB is empty
+**
+*******************************************************************************/
+ BTM_API extern tBTM_INQ_INFO *BTM_InqFirstResult (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_InqNextResult
+**
+** Description This function looks through the inquiry database for the next
+** used entrysince the LAST inquiry. If the input parameter is NULL,
+** the first entry is returned.
+**
+** Returns pointer to next in-use entry, or NULL if no more found.
+**
+*******************************************************************************/
+ BTM_API extern tBTM_INQ_INFO *BTM_InqNextResult (tBTM_INQ_INFO *p_cur);
+
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadNumInqDbEntries
+**
+** Returns This function returns the number of entries in the inquiry database.
+**
+*******************************************************************************/
+ BTM_API extern UINT8 BTM_ReadNumInqDbEntries (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_InquiryRegisterForChanges
+**
+** Description This function is called to register a callback for when the
+** inquiry database changes, i.e. new entry or entry deleted.
+**
+** Returns BTM_SUCCESS if successful, otherwise error code
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_InquiryRegisterForChanges (tBTM_INQ_DB_CHANGE_CB *p_cb);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_WriteInquiryTxPower
+**
+** Description This command is used to write the inquiry transmit power level
+** used to transmit the inquiry (ID) data packets. The Controller
+** should use the supported TX power level closest to the Tx_Power
+** parameter.
+**
+** Returns BTM_SUCCESS if successful
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_WriteInquiryTxPower (INT8 tx_power);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern void BTM_SetDiscoveryParams (UINT16 num_uuid, tSDP_UUID *p_uuid_list,
+ UINT16 num_attr, UINT16 *p_attr_list);
+
+
+/*****************************************************************************
+** 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetLinkPolicy (BD_ADDR remote_bda,
+ UINT16 *settings);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadLinkPolicy
+**
+** Description This function is called to read the link policy settings.
+** The address of link policy results are returned in the callback.
+** (tBTM_LNK_POLICY_RESULTS)
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadLinkPolicy (BD_ADDR remote_bda,
+ tBTM_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetDefaultLinkPolicy
+**
+** Description Set the default value for HCI "Write Policy Set" command
+** to use when an ACL link is created.
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda,
+ UINT16 timeout);
+
+/*******************************************************************************
+**
+** Function BTM_RegForLstoEvt
+**
+** Description register for the HCI "Link Supervision Timeout Change" event
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_RegForLstoEvt (tBTM_LSTO_CBACK *p_cback);
+
+
+/* These next APIs are available if the power manager is not compiled in */
+#if BTM_PWR_MGR_INCLUDED == FALSE
+/*******************************************************************************
+**
+** Function BTM_SetHoldMode
+**
+** Description This function is called to set a connection into hold mode.
+** A check is made if the connection is in sniff or park mode,
+** and if yes, the hold mode is ignored.
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetHoldMode (BD_ADDR remote_bda, UINT16 min_interval,
+ UINT16 max_interval);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetSniffMode
+**
+** Description This function is called to set a connection into sniff mode.
+** A check is made if the connection is already in sniff or park
+** mode, and if yes, the sniff mode is ignored.
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetSniffMode (BD_ADDR remote_bda, UINT16 min_period,
+ UINT16 max_period, UINT16 attempt,
+ UINT16 timeout);
+
+
+/*******************************************************************************
+**
+** Function BTM_CancelSniffMode
+**
+** Description This function is called to put a connection out of sniff mode.
+** A check is made if the connection is already in sniff mode,
+** and if not, the cancel sniff mode is ignored.
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_CancelSniffMode (BD_ADDR remote_bda);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetParkMode
+**
+** Description This function is called to set a connection into park mode.
+** A check is made if the connection is already in sniff or park
+** mode, and if yes, the park mode is ignored.
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetParkMode (BD_ADDR remote_bda,
+ UINT16 beacon_min_period,
+ UINT16 beacon_max_period);
+
+
+/*******************************************************************************
+**
+** Function BTM_CancelParkMode
+**
+** Description This function is called to put a connection out of park mode.
+** A check is made if the connection is already in park mode,
+** and if not, the cancel sniff mode is ignored.
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_CancelParkMode (BD_ADDR remote_bda);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadAclMode
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadAclMode (BD_ADDR remote_bda, UINT8 *p_mode);
+
+#endif /* if BTM_PWR_MGR_INCLUDED == FALSE */
+
+
+/*******************************************************************************
+**
+** Function BTM_SetPacketTypes
+**
+** Description This function is set the packet types used for a specific
+** ACL connection,
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetPacketTypes (BD_ADDR remote_bda, UINT16 pkt_types);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadPacketTypes
+**
+** Description This function is set the packet types used for the specified
+** ACL connection,
+**
+** Returns packet types supported for the connection, or 0 if no BD address
+**
+*******************************************************************************/
+ BTM_API extern UINT16 BTM_ReadPacketTypes (BD_ADDR remote_bda);
+
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ BTM_API extern BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda);
+
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr,
+ UINT8 new_role,
+ tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_ChangeLinkKey
+**
+** Description This function is called to change the link key of the
+** connection.
+**
+** 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 the previous command is not completed
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ChangeLinkKey (BD_ADDR remote_bd_addr,
+ tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function BTM_ReadRSSI
+**
+** Description This function is called to read the link policy settings.
+** The address of link policy 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level,
+ tBTM_BL_EVENT_MASK evt_mask);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern UINT16 BTM_GetNumAclLinks (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadClockOffset
+**
+** Description This returns the clock offset for a specific
+** ACL connection.
+**
+** Returns clock-offset or 0 if unknown
+**
+*******************************************************************************/
+ BTM_API extern UINT16 BTM_ReadClockOffset (BD_ADDR remote_bda);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetQoS
+**
+** Description This function is called to setup QoS
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+**
+** 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.
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback);
+
+
+/*******************************************************************************
+**
+** Function BTM_SecSetConnectFilterCallback
+**
+** Description Host can register to be asked whenever an HCI connection
+** request is received. In the registered function host
+** suppose to check connectibility filters. Yes/No result
+** should be returned synchronously.
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_SecSetConnectFilterCallback (tBTM_FILTER_CB *p_callback);
+
+
+/*******************************************************************************
+**
+** Function BTM_GetSecurityMode
+**
+** Description Get security mode for the device
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern UINT8 BTM_GetSecurityMode (void);
+
+
+/*******************************************************************************
+**
+** Function BTM_GetSecurityFlags
+**
+** Description Get security flags for the device
+**
+** Returns BOOLEAN TRUE or FALSE is device found
+**
+*******************************************************************************/
+ BTM_API extern BOOLEAN BTM_GetSecurityFlags (BD_ADDR bd_addr, UINT8 * p_sec_flags);
+
+/*******************************************************************************
+**
+** Function BTM_ReadTrustedMask
+**
+** Description Get trusted mask for the device
+**
+** Returns NULL, if the device record is not found.
+** otherwise, the trusted mask
+**
+*******************************************************************************/
+ BTM_API extern UINT32 * BTM_ReadTrustedMask (BD_ADDR bd_addr);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetSecurityMode
+**
+** Description Set security mode for the device
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_SetSecurityMode (UINT8 sec_mode);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetPinType
+**
+** Description Set PIN type for the device.
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API extern BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name,
+ UINT8 service_id, UINT16 sec_level,
+ UINT16 psm, UINT32 mx_proto_id,
+ UINT32 mx_chan_id);
+
+/*******************************************************************************
+**
+** Function BTM_SetUCDSecurityLevel
+**
+** Description Register UCD 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
+** and again for acceptors of connections.
+**
+** Returns TRUE if registered OK, else FALSE
+**
+*******************************************************************************/
+ BTM_API extern BOOLEAN BTM_SetUCDSecurityLevel (BOOLEAN is_originator, 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API extern UINT8 BTM_SecClrService (UINT8 service_id);
+
+/*******************************************************************************
+**
+** Function BTM_SecClrUCDService
+**
+** Description
+**
+** Parameters Service ID - Id of the service to remove. ('0' removes all service
+** records.
+**
+** Returns Number of records that were freed.
+**
+*******************************************************************************/
+ BTM_API extern UINT8 BTM_SecClrUCDService (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
+**
+*******************************************************************************/
+ BTM_API extern BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class,
+ BD_NAME bd_name, BD_FEATURES features,
+ UINT32 trusted_mask[], LINK_KEY link_key,
+ UINT8 key_type, tBTM_IO_CAP io_cap);
+
+
+/*******************************************************************************
+**
+** Function BTM_SecDeleteDevice
+**
+** Description Free resources associated with the device.
+**
+** Returns TRUE if rmoved OK, FALSE if not found
+**
+*******************************************************************************/
+ BTM_API extern BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr);
+
+
+/*******************************************************************************
+**
+** Function BTM_SecUseMasterLinkKey
+**
+** Description This function is called to tell master of the piconet to
+** switch to master link key
+**
+** Returns BTM_SUCCESS if command is successully initiated
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SecUseMasterLinkKey (BOOLEAN use_master_key);
+
+
+/*******************************************************************************
+**
+** Function BTM_SetMasterKeyCompCback
+**
+** Description This function is called to register for the master key complete
+** status event.
+**
+** Parameters: mkey_cback - callback registered with the security manager
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_SetMasterKeyCompCback(tBTM_MKEY_CALLBACK *mkey_cback );
+
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr,
+ LINK_KEY link_key);
+
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API extern void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len,
+ UINT8 *p_pin, UINT32 trusted_mask[]);
+
+
+/*******************************************************************************
+**
+** Function BTM_DeviceAuthorized
+**
+** Description This function is called after Security Manager submitted
+** authorization 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
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_DeviceAuthorized (BD_ADDR bd_addr, UINT8 res,
+ UINT32 trusted_mask[]);
+
+
+/*******************************************************************************
+**
+** Function BTM_SecBond
+**
+** Description This function is called to perform bonding with peer device.
+**
+** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, 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
+**
+*******************************************************************************/
+ BTM_API 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).
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+*******************************************************************************/
+ BTM_API extern UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c,
+ BT_OCTET16 r, UINT8 name_len);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern char *BTM_SecReadDevName (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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat,
+ UINT16 min_rmt_to, UINT16 min_loc_to);
+
+/*******************************************************************************
+**
+** Function BTM_IsPowerManagerOn
+**
+** Description This function is called to check if power manager is included.
+** in the BTE version.
+**
+** Returns TRUE if power manager is compiled in, otherwise FALSE.
+**
+*******************************************************************************/
+ BTM_API extern BOOLEAN BTM_IsPowerManagerOn (void);
+
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ BTM_API extern UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda);
+
+
+/*******************************************************************************
+**
+** Function BTM_ReadStoredLinkKey
+**
+** Description This function is called to obtain link key for the specified
+** device from the NVRAM storage attached to the Bluetooth
+** controller.
+**
+** Parameters: bd_addr - Address of the device
+** p_cb - Call back function to be called to return
+** the results
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ReadStoredLinkKey (BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** Function BTM_WriteStoredLinkKey
+**
+** Description This function is called to write link keys for the specified
+** device addresses to the NVRAM storage attached to the Bluetooth
+** controller.
+**
+** Parameters: num_keys - Number of link keys
+** bd_addr - Addresses of the devices
+** link_key - Link Keys to be stored
+** p_cb - Call back function to be called to return
+** the results
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_WriteStoredLinkKey (UINT8 num_keys,
+ BD_ADDR *bd_addr,
+ LINK_KEY *link_key,
+ tBTM_CMPL_CB *p_cb);
+
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+** Returns BTM_SUCCESS - if successful
+** BTM_MODE_UNSUPPORTED - if local device cannot support it
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_WriteEIR( BT_HDR * p_buff );
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results,
+ UINT16 uuid16 );
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API extern void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API extern void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ BTM_API 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
+**
+*******************************************************************************/
+ BTM_API extern UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid,
+ UINT8 *p_uuid_list, UINT8 max_num_uuid);
+
+/*******************************************************************************
+**
+** Function BTM_SyncStack
+**
+** Description For Dual-Stack support. Called to initiate switching to/from
+** main stack (running on phone baseband) to mm stack (light
+** stack running on multi-media chip)
+**
+** Parameters sync_dir: BTM_SW_BB_TO_MM: switch from BB to MM stack
+** BTM_SW_MM_TO_BB: switch from MM to BB stack
+** BTM_SW_RESYNC: resync MM and BB stacks
+**
+** p_sync_cback: callback function for event notification
+** Returns
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_SyncStack(tBTM_SW_DIR sync_dir, tBTM_SYNC_STACK_CBACK p_sync_cback);
+
+/*******************************************************************************
+**
+** Function BTM_SyncBtaRsp
+**
+** Description For Dual-Stack support. Called to indicate that upper layers
+** (e.g. BTA or application) have completed synchronizing bta/app
+** specific layers for switching.
+**
+** Called in response to 'BTM_SYNC_BTA_EVT'
+**
+** Parameters status: BTM_SUCESS: bta/app successfully synchronized
+** otherwise: sync was unsuccessfule. Abort switch.
+**
+** p_btm_sync_info: information from bta/app that will be needed
+** by BTE (avdt and l2cap) for switching.
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_SyncBtaRsp(tBTM_STATUS status, tBTM_SYNC_INFO *p_btm_sync_info);
+
+/*******************************************************************************
+**
+** Function BTM_OpenUIPC
+**
+** Description For Dual-Stack support. Called to open UIPC between
+** main stack (running on phone baseband) to embedded light stack
+** (running on Multimedia or Bluetooth Controller chip)
+**
+** Parameters sync_dir: BTM_SW_BB_TO_MM: switch from BB to MM stack
+** BTM_SW_BB_TO_BTC:switch from BB to BTC stack
+**
+** p_sync_callback: callback function for event notification
+** Returns
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_OpenUIPC(tBTM_SW_DIR sync_dir, tBTM_SYNC_STACK_CBACK p_sync_callback);
+
+/*******************************************************************************
+**
+** Function BTM_CloseUIPC
+**
+** Description For Dual-Stack support. Called to close UIPC between
+** main stack (running on phone baseband) to embedded light stack
+** (running on Multimedia or Bluetooth Controller chip)
+**
+** Parameters
+** p_sync_callback: callback function for event notification
+** Returns
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_CloseUIPC(tBTM_SYNC_STACK_CBACK p_sync_callback);
+
+/*******************************************************************************
+**
+** Function BTM_IpcSend
+**
+** Description For Dual-Stack support. Called to send ipc messages from
+** full stack to lite stack and vice-versa. This API is
+** typically called by bta layers e.g. bta_av.
+**
+**
+** Parameters len: Length of the buffer in the ipc message
+**
+** buffer: Pointer to the buffer to be passed in the IPC message
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_IpcSend(UINT16 len, UINT8* buffer);
+
+/*******************************************************************************
+**
+** Function BTM_IpcSendBuf
+**
+** Description For Dual-Stack support. Called to send ipc messages from
+** full stack to lite stack and vice-versa. This API is
+** typically called by bta layers e.g. bta_av_sync.
+**
+**
+** Parameters p_buf: Pointer to the buffer to be passed in the IPC message
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_IpcSendBuf(BT_HDR* p_buf);
+
+/*******************************************************************************
+**
+** Function BTM_RegIpcEvtHandler
+**
+** Description registers the DM provided handler for IPC events
+**
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_RegIpcEvtHandler(tBTM_IPC_EVT_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTM_RegRTIpcEvtHandler
+**
+** Description registers the RT(Audio Routing) provided handler for IPC events
+**
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_RegRTIpcEvtHandler(tBTM_IPC_EVT_CBACK *p_cback);
+
+/*****************************************************************************
+** N2BT
+*****************************************************************************/
+
+/* Data callback for N2BT */
+ typedef void (tBTM_N2BT_DATA_CB) (BD_ADDR bd_addr, UINT16 handle, UINT8 *p_data, UINT16 datalen);
+
+/*******************************************************************************
+**
+** Function BTM_N2BtAcquire
+**
+** Description Put controller into acquisition mode
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_N2BtAcquire(BD_ADDR bd_addr, UINT16 timeout,
+ UINT8 freq, UINT8 src_addrlen, UINT8 sensor_flags,
+ UINT8 sensor_type, UINT8 sensor_clk_accuracy,
+ UINT16 add_rx_window, UINT16 init_crc,
+ UINT32 ac_low, UINT32 ac_high, UINT16 pkt_hdr,
+ UINT16 list_dur, UINT16 list_int,
+ UINT8 oor_missed_pkts, tBTM_VSC_CMPL_CB *p_cb,
+ tBTM_N2BT_DATA_CB *p_data_cback);
+
+/*******************************************************************************
+**
+** Function BTM_N2BtDisconnect
+**
+** Description Disconnects all N2BT devices
+**
+** Returns void
+**
+*******************************************************************************/
+ BTM_API extern void BTM_N2BtDisconnect(void);
+
+
+/*******************************************************************************
+**
+** Function BTM_ConfigI2SPCM
+**
+** Description This function sends VSC Write_I2SPCM_Interface_Param
+** as to the specified codec_type.
+**
+**
+** Parameter codec_type: codec_type to be used for sco connection.
+** role: master or slave role
+** sample_rate: sampling rate
+** clock_rate:clock rate 128K to 2048K
+**
+**
+** Returns BTM_SUCCESS if the successful.
+** BTM_ILLEGAL_VALUE: wrong codec type
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_ConfigI2SPCM (tBTM_SCO_CODEC_TYPE codec_type, UINT8 role, UINT8 sample_rate, UINT8 clock_rate);
+
+/*****************************************************************************
+** 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.
+**
+**
+*******************************************************************************/
+ BTM_API 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.
+**
+**
+*******************************************************************************/
+ BTM_API extern tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf);
+
+/*******************************************************************************
+**
+** Function BTM_SetARCMode
+**
+** Description Send Audio Routing Control command.
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+BTM_API extern void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p_arc_cb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTM_API_H */
diff --git a/stack/include/btm_ble_api.h b/stack/include/btm_ble_api.h
new file mode 100644
index 0000000..8456b9f
--- /dev/null
+++ b/stack/include/btm_ble_api.h
@@ -0,0 +1,729 @@
+/******************************************************************************
+ *
+ * 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 "btm_api.h"
+
+#define CHNL_MAP_LEN 5
+typedef UINT8 tBTM_BLE_CHNL_MAP[CHNL_MAP_LEN];
+
+#define BTM_BLE_SCAN_MODE_PASS 0
+#define BTM_BLE_SCAN_MODE_ACTI 1
+#define BTM_BLE_SCAN_MODE_NONE 0xff
+typedef UINT8 tBTM_BLE_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 /* accept adv pakt from all, directed adv pkt not directed to me is ignored */
+#define SP_ADV_WL 0x01 /* accept adv pakt from device in white list, directed adv pkt not directed to me is ignored */
+typedef UINT8 tBTM_BLE_SFP;
+
+#ifndef BTM_BLE_DEFAULT_SFP
+#define BTM_BLE_DEFAULT_SFP SP_ADV_ALL
+#endif
+
+/* adv parameter boundary values */
+#define BTM_BLE_ADV_INT_MIN 0x0020
+#define BTM_BLE_ADV_INT_MAX 0x4000
+
+/* connection parameter boundary value */
+#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_CONN_INT_MIN 0x0006
+#define BTM_BLE_CONN_INT_MAX 0x0C80
+#define BTM_BLE_CONN_LATENCY_MAX 500
+#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 */
+
+/* default connection parameters if not configured, use GAP recommend value for auto/selective connection */
+/* default scan interval */
+#ifndef BTM_BLE_CONN_EST_SCAN_INT
+#define BTM_BLE_CONN_EST_SCAN_INT 96 /* 312.5 ms = 500 *0.625 */
+#endif
+/* default scan window for background connection, applicable for auto connection or selective conenction */
+#ifndef BTM_BLE_CONN_EST_SCAN_WIND
+#define BTM_BLE_CONN_EST_SCAN_WIND 48 /* 187.5 ms = 400 *0.625 */
+#endif
+
+/* default scan paramter used in reduced power cycle */
+#ifndef BTM_BLE_CONN_EST_SCAN_INT_LO
+#define BTM_BLE_CONN_EST_SCAN_INT_LO 2048 /* 1.28 s = 500 *0.625 */
+#endif
+#ifndef BTM_BLE_CONN_EST_SCAN_WIND_LO
+#define BTM_BLE_CONN_EST_SCAN_WIND_LO 18 /* 11.25 ms = 400 *0.625 */
+#endif
+
+/* default connection interval min */
+#ifndef BTM_BLE_CONN_INT_MIN_DEF
+#define BTM_BLE_CONN_INT_MIN_DEF 40 /* 50ms = 400 * 1.25 */
+#endif
+/* default connectino interval max */
+#ifndef BTM_BLE_CONN_INT_MAX_DEF
+#define BTM_BLE_CONN_INT_MAX_DEF 56 /* 70ms = 56 * 1.25 */
+#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 2000
+#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 */
+
+/* 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 */
+
+typedef struct
+{
+ UINT8 adv_int_min;
+ UINT8 adv_int_max;
+ tBTM_BLE_CHNL_MAP chnl_map;
+
+}tBTM_BLE_ADV_PARAMS;
+
+/* 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)
+#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 (0x0001 << 0)
+#define BTM_BLE_AD_BIT_FLAGS (0x0001 << 1)
+#define BTM_BLE_AD_BIT_MANU (0x0001 << 2)
+#define BTM_BLE_AD_BIT_TX_PWR (0x0001 << 3)
+#define BTM_BLE_AD_BIT_ATTR (0x0001 << 4)
+#define BTM_BLE_AD_BIT_INT_RANGE (0x0001 << 5)
+#define BTM_BLE_AD_BIT_SERVICE (0x0001 << 6)
+#define BTM_BLE_AD_BIT_SERVICE_SOL (0x0001 << 7)
+#define BTM_BLE_AD_BIT_SERVICE_DATA (0x0001 << 8)
+#define BTM_BLE_AD_BIT_SIGN_DATA (0x0001 << 9)
+#define BTM_BLE_AD_BIT_PROPRIETARY (0x0001 << 15)
+
+typedef UINT16 tBTM_BLE_AD_MASK;
+
+#define BTM_BLE_AD_TYPE_FLAG 0x01
+#define BTM_BLE_AD_TYPE_SRV_PART 0x02
+#define BTM_BLE_AD_TYPE_SRV_CMPL 0x03
+#define BTM_BLE_AD_TYPE_NAME_SHORT 0x08
+#define BTM_BLE_AD_TYPE_NAME_CMPL 0x09
+#define BTM_BLE_AD_TYPE_TX_PWR 0x0A
+#define BTM_BLE_AD_TYPE_DEV_CLASS 0x0D
+#define BTM_BLE_AD_TYPE_ATTR 0x10
+#define BTM_BLE_AD_TYPE_MANU 0xff
+#define BTM_BLE_AD_TYPE_INT_RANGE 0x12
+#define BTM_BLE_AD_TYPE_SOL_SRV_UUID 0x14
+typedef UINT8 tBTM_BLE_AD_TYPE;
+
+/* 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;
+
+/* attribute data */
+typedef struct
+{
+ UINT16 uuid;
+ UINT16 data_len;
+ UINT8 *p_data;
+}tBTM_BLE_ATTR;
+
+#ifndef BTM_BLE_NUM_AD_ATTR_MAX
+#define BTM_BLE_NUM_AD_ATTR_MAX 10
+#endif
+/* attribute list contained in adv data */
+typedef struct
+{
+ UINT8 num_attr;
+ tBTM_BLE_ATTR attr_list[BTM_BLE_NUM_AD_ATTR_MAX];
+}tBTM_BLE_ATTR_DATA;
+
+typedef struct
+{
+ UINT8 len;
+ UINT8 *p_val;
+}tBTM_BLE_MANU;
+
+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_MANU manu; /* manufactuer data */
+ tBTM_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
+ tBTM_BLE_SERVICE services; /* services */
+ tBTM_BLE_ATTR_DATA attr; /* attribute data */
+ UINT8 flag;
+ tBTM_BLE_PROPRIETARY *p_proprietary;
+}tBTM_BLE_ADV_DATA;
+
+/* 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_ATTR_DATA attr_data;
+ 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;
+
+typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
+
+/* 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);
+/*****************************************************************************
+** EXTERNAL FUNCTION DECLARATIONS
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*******************************************************************************
+**
+** 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.
+**
+** Returns TRUE if added OK, else FALSE
+**
+*******************************************************************************/
+BTM_API extern BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name,
+ tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+BTM_API 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_BleWriteAdvData
+**
+** Description This function is called to write advertising data.
+**
+** Parameters: None.
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask,
+ tBTM_BLE_ADV_DATA *p_data);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+BTM_API 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_BleSetScanParams
+**
+** Description This function is called to set Scan parameters.
+**
+** Parameters adv_int_min: minimum advertising interval
+** adv_int_max: maximum advertising interval
+** scan_type: scan mode.
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern void BTM_BleSetScanParams(UINT16 scan_interval, UINT16 scan_window,
+ tBTM_BLE_SCAN_MODE scan_type);
+
+/*******************************************************************************
+**
+** Function BTM_BleWriteScanRsp
+**
+** Description This function is called to write LE scan response.
+**
+** Parameters: p_scan_rsp: scan response.
+**
+** Returns status
+**
+*******************************************************************************/
+BTM_API extern tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
+ tBTM_BLE_ADV_DATA *p_data);
+
+/*******************************************************************************
+**
+** Function BTM_BleReset
+**
+** Description This function is called to reset ULP controller.
+**
+** Parameters None.
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern void BTM_BleReset(void);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+BTM_API extern tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration,
+ tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_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
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+BTM_API 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)).
+**
+*******************************************************************************/
+BTM_API extern void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+BTM_API extern void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data);
+
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+BTM_API 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.
+**
+*******************************************************************************/
+BTM_API extern BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig,
+ UINT16 len, UINT32 counter,
+ UINT8 *p_comp);
+
+/*******************************************************************************
+**
+** Function BTM_SetRandomAddr
+**
+** Description This function is called to set the local device random address
+** .
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern void BTM_SetRandomAddr (tBTM_BLE_RANDOM_SET_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTM_ReadConnectionAddr
+**
+** Description This function is called to set the local device random address
+** .
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern void BTM_ReadConnectionAddr (BD_ADDR conn_addr);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+BTM_API extern BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR remote_bda);
+
+
+/********************************************************
+**
+** 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
+**
+*******************************************************************************/
+BTM_API 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
+**
+*******************************************************************************/
+BTM_API extern void BTM_BleSetConnScanParams (UINT16 scan_interval, UINT16 scan_window);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+BTM_API extern UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+BTM_API extern void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type,
+ tBLE_ADDR_TYPE *p_addr_type);
+
+/*******************************************************************************
+**
+** Function BTM_BleBroadcast
+**
+** Description This function is to start or stop broadcasting.
+**
+** Parameters start: start or stop broadcasting.
+**
+** Returns status.
+**
+*******************************************************************************/
+BTM_API extern tBTM_STATUS BTM_BleBroadcast(BOOLEAN start);
+
+/*******************************************************************************
+**
+** Function BTM_RegisterScanReqEvt
+**
+** Description This function is called to register a scan request callback
+** on the advertiser.
+**
+** Parameters p_scan_req_cback: scan request callback. If NULL, remove the
+** registration.
+**
+** Returns void
+**
+*******************************************************************************/
+BTM_API extern void BTM_RegisterScanReqEvt(tBTM_BLE_SCAN_REQ_CBACK *p_scan_req_cback);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/stack/include/btu.h b/stack/include/btu.h
new file mode 100644
index 0000000..d33f0bb
--- /dev/null
+++ b/stack/include/btu.h
@@ -0,0 +1,310 @@
+/******************************************************************************
+ *
+ * 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 "bt_target.h"
+#include "gki.h"
+
+/* Define the BTU mailbox usage
+*/
+#define BTU_HCI_RCV_MBOX TASK_MBOX_0 /* Messages from HCI */
+#define BTU_BTIF_MBOX TASK_MBOX_1 /* Messages to BTIF */
+
+/* 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
+
+/* OBX */
+#define BTU_TTYPE_OBX_CLIENT_TO 51
+#define BTU_TTYPE_OBX_SERVER_TO 52
+#define BTU_TTYPE_OBX_SVR_SESS_TO 53
+
+
+#define BTU_TTYPE_HSP2_SDP_FAIL_TO 55
+#define BTU_TTYPE_HSP2_SDP_RTRY_TO 56
+
+/* BTU internal */
+/* unused 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
+
+/* BTU internal for BR/EDR and AMP HCI command timeout (reserve up to 3 AMP controller) */
+#define BTU_TTYPE_BTU_CMD_CMPL 80
+#define BTU_TTYPE_BTU_AMP1_CMD_CMPL 81
+#define BTU_TTYPE_BTU_AMP2_CMD_CMPL 82
+#define BTU_TTYPE_BTU_AMP3_CMD_CMPL 83
+
+#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_SCAN_PARAM_IDLE 106
+
+/* Define the BTU_TASK APPL events
+*/
+#if (defined(NFC_SHARED_TRANSPORT_ENABLED) && (NFC_SHARED_TRANSPORT_ENABLED==TRUE))
+#define BTU_NFC_AVAILABLE_EVT EVENT_MASK(APPL_EVT_0) /* Notifies BTU task that NFC is available (used for shared NFC+BT transport) */
+#endif
+
+/* 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 */
+
+/* AMP HCI control block */
+typedef struct
+{
+ BUFFER_Q cmd_xmit_q;
+ BUFFER_Q cmd_cmpl_q;
+ UINT16 cmd_window;
+ TIMER_LIST_ENT cmd_cmpl_timer; /* Command complete timer */
+#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE)
+ BOOLEAN checked_hcisu;
+#endif
+} tHCI_CMD_CB;
+
+/* 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];
+
+ TIMER_LIST_Q quick_timer_queue; /* Timer queue for transport level (100/10 msec)*/
+ TIMER_LIST_Q timer_queue; /* Timer queue for normal BTU task (1 second) */
+
+ TIMER_LIST_ENT cmd_cmpl_timer; /* Command complete timer */
+
+ UINT16 hcit_acl_data_size; /* Max ACL data size across HCI transport */
+ UINT16 hcit_acl_pkt_size; /* Max ACL packet size across HCI transport */
+ /* (this is data size plus 4 bytes overhead) */
+
+#if BLE_INCLUDED == TRUE
+ UINT16 hcit_ble_acl_data_size; /* Max BLE ACL data size across HCI transport */
+ UINT16 hcit_ble_acl_pkt_size; /* Max BLE ACL packet size across HCI transport */
+ /* (this is data size plus 4 bytes overhead) */
+#endif
+
+ BOOLEAN reset_complete; /* TRUE after first ack from device received */
+ UINT8 trace_level; /* Trace level for HCI layer */
+
+ tHCI_CMD_CB hci_cmd_cb[BTU_MAX_LOCAL_CTRLS]; /* including BR/EDR */
+} tBTU_CB;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Global BTU data */
+#if BTU_DYNAMIC_MEMORY == FALSE
+BTU_API extern tBTU_CB btu_cb;
+#else
+BTU_API extern tBTU_CB *btu_cb_ptr;
+#define btu_cb (*btu_cb_ptr)
+#endif
+
+BTU_API extern const BD_ADDR BT_BD_ANY;
+
+/* Functions provided by btu_task.c
+************************************
+*/
+BTU_API extern void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
+BTU_API extern void btu_stop_timer (TIMER_LIST_ENT *p_tle);
+BTU_API extern void btu_register_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout, tBTU_TIMER_CALLBACK timer_cb);
+BTU_API extern void btu_deregister_timer(TIMER_LIST_ENT *p_tle);
+BTU_API extern UINT32 btu_remaining_time (TIMER_LIST_ENT *p_tle);
+
+
+BTU_API extern void btu_register_event_range (UINT16 range, tBTU_EVENT_CALLBACK event_cb);
+BTU_API extern void btu_deregister_event_range (UINT16 range);
+BTU_API extern void btu_uipc_rx_cback(BT_HDR *p_msg);
+
+BTU_API extern void btu_hcif_flush_cmd_queue(void);
+/*
+** Quick Timer
+*/
+#if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0)
+#define QUICK_TIMER_TICKS (GKI_SECS_TO_TICKS (1)/QUICK_TIMER_TICKS_PER_SEC)
+BTU_API extern void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
+BTU_API extern void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle);
+BTU_API extern void btu_process_quick_timer_evt (void);
+BTU_API extern void process_quick_timer_evt (TIMER_LIST_Q *p_tlq);
+#endif
+
+#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
+BTU_API extern void btu_check_bt_sleep (void);
+#endif
+
+/* Functions provided by btu_hcif.c
+************************************
+*/
+BTU_API extern void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf);
+BTU_API extern void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg);
+BTU_API extern void btu_hcif_send_host_rdy_for_data(void);
+BTU_API extern void btu_hcif_cmd_timeout (UINT8 controller_id);
+
+/* Functions provided by btu_core.c
+************************************
+*/
+BTU_API extern void btu_init_core(void);
+BTU_API extern void BTE_Init(void);
+BTU_API extern UINT16 BTU_AclPktSize(void);
+BTU_API extern UINT16 BTU_BleAclPktSize(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/stack/include/dyn_mem.h b/stack/include/dyn_mem.h
new file mode 100644
index 0000000..3ad8361
--- /dev/null
+++ b/stack/include/dyn_mem.h
@@ -0,0 +1,187 @@
+/******************************************************************************
+ *
+ * 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
+
+/****************************************************************************
+** Define memory usage for GKI (if not defined in bdroid_buildcfg.h)
+** The default for GKI is to use static memory allocation for its control
+** block.
+*/
+#ifndef GKI_DYNAMIC_MEMORY
+#define GKI_DYNAMIC_MEMORY FALSE
+#endif
+
+/****************************************************************************
+** 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 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 OBX_DYNAMIC_MEMORY
+#define OBX_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 DUN_DYNAMIC_MEMORY
+#define DUN_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef FTP_DYNAMIC_MEMORY
+#define FTP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef GAP_DYNAMIC_MEMORY
+#define GAP_DYNAMIC_MEMORY FALSE
+#endif
+
+#ifndef GOEP_DYNAMIC_MEMORY
+#define GOEP_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 (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
+
+/****************************************************************************
+** Define memory usage for BT Trace (if not defined in bdroid_buildcfg.h)
+** The default is to use static memory allocations.
+*/
+#ifndef BTTRC_DYNAMIC_MEMORY
+#define BTTRC_DYNAMIC_MEMORY FALSE
+#endif
+
+#endif /* #ifdef DYN_MEM_H */
+
diff --git a/stack/include/gatt_api.h b/stack/include/gatt_api.h
new file mode 100644
index 0000000..2d13e5a
--- /dev/null
+++ b/stack/include/gatt_api.h
@@ -0,0 +1,1128 @@
+/******************************************************************************
+ *
+ * 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 "bt_target.h"
+#include "gattdefs.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+/* Success code and error codes */
+#define GATT_SUCCESS 0x0000
+#define GATT_INVALID_HANDLE 0x0001
+#define GATT_READ_NOT_PERMIT 0x0002
+#define GATT_WRITE_NOT_PERMIT 0x0003
+#define GATT_INVALID_PDU 0x0004
+#define GATT_INSUF_AUTHENTICATION 0x0005
+#define GATT_REQ_NOT_SUPPORTED 0x0006
+#define GATT_INVALID_OFFSET 0x0007
+#define GATT_INSUF_AUTHORIZATION 0x0008
+#define GATT_PREPARE_Q_FULL 0x0009
+#define GATT_NOT_FOUND 0x000a
+#define GATT_NOT_LONG 0x000b
+#define GATT_INSUF_KEY_SIZE 0x000c
+#define GATT_INVALID_ATTR_LEN 0x000d
+#define GATT_ERR_UNLIKELY 0x000e
+#define GATT_INSUF_ENCRYPTION 0x000f
+#define GATT_UNSUPPORT_GRP_TYPE 0x0010
+#define GATT_INSUF_RESOURCE 0x0011
+
+
+#define GATT_ILLEGAL_PARAMETER 0x0087
+#define GATT_NO_RESOURCES 0x0080
+#define GATT_INTERNAL_ERROR 0x0081
+#define GATT_WRONG_STATE 0x0082
+#define GATT_DB_FULL 0x0083
+#define GATT_BUSY 0x0084
+#define GATT_ERROR 0x0085
+#define GATT_CMD_STARTED 0x0086
+#define GATT_PENDING 0x0088
+#define GATT_AUTH_FAIL 0x0089
+#define GATT_MORE 0x008a
+#define GATT_INVALID_CFG 0x008b
+#define GATT_SERVICE_STARTED 0x008c
+#define GATT_ENCRYPED_MITM GATT_SUCCESS
+#define GATT_ENCRYPED_NO_MITM 0x008d
+#define GATT_NOT_ENCRYPTED 0x008e
+
+
+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_SIGN_CMD_WRITE 0xD2 /* changed in V4.0 1101-0010 (signed write) see write cmd above*/
+#define GATT_OP_CODE_MAX GATT_HANDLE_VALUE_CONF + 1 /* 0x1E = 30 + 1 = 31*/
+
+
+#define GATT_HANDLE_IS_VALID(x) ((x) != 0)
+
+#define GATT_CONN_UNKNOWN 0
+#define GATT_CONN_NO_RESOURCES L2CAP_CONN_NO_RESOURCES /* connection fail for l2cap resource 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 legth 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 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 */
+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)
+#define GATT_READ_AUTH_REQUIRED (GATT_PERM_READ_ENC_MITM)
+#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_WRITE_ALLOWED (GATT_PERM_WRITE | GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_ENC_MITM | \
+ GATT_PERM_WRITE_SIGNED | GATT_PERM_WRITE_SIGNED_MITM)
+
+#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)
+
+
+/* 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 UUIUD 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;
+
+#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 offfset 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;
+
+/* 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 */
+enum
+{
+ GATT_TRANSPORT_LE,
+ GATT_TRANSPORT_BR_EDR,
+ GATT_TRANSPORT_LE_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;
+} tGATT_READ_REQ;
+
+/* write request data */
+typedef struct
+{
+ UINT16 handle; /* attribute handle */
+ UINT16 offset; /* attribute value offset, if no offfset 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_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_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; /* characterisitc 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; /* characterisitc 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
+ type of discovery result callback. */
+
+ UINT16 handle; /* When used with GATT_DISC_SRVC_BY_UUID type
+ discovery result, it is the ending handle of a
+ known service to be discovered. 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;
+
+
+typedef UINT8 tGATT_IF;
+#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);
+
+/* 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);
+
+
+
+
+/* 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_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;
+
+/* Attibute 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;
+
+/*
+*********************** 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
+**
+*******************************************************************************/
+ GATT_API 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 sucessfully; otherwise FALSE.
+**
+*******************************************************************************/
+
+ GATT_API 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
+**
+*******************************************************************************/
+ GATT_API extern BOOLEAN GATTS_NVRegister (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 sucessful, otherwise 0.
+**
+*******************************************************************************/
+ GATT_API 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.
+**
+*******************************************************************************/
+ GATT_API 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.
+**
+*******************************************************************************/
+ GATT_API extern UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *char_uuid,
+ tGATT_PERM perm,tGATT_CHAR_PROP property);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ GATT_API extern UINT16 GATTS_AddCharDescriptor (UINT16 service_handle, tGATT_PERM perm,
+ tBT_UUID * p_descr_uuid);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ GATT_API 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 sucessfully started; otherwise error code.
+**
+*******************************************************************************/
+ GATT_API 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.
+**
+*******************************************************************************/
+ GATT_API 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 sucessfully sent or queued; otherwise error code.
+**
+*******************************************************************************/
+ GATT_API 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 sucessfully sent; otherwise error code.
+**
+*******************************************************************************/
+ GATT_API 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 sucessfully sent; otherwise error code.
+**
+*******************************************************************************/
+ GATT_API extern tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
+ tGATT_STATUS status, tGATTS_RSP *p_msg);
+
+
+/*******************************************************************************/
+/* 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.
+**
+*******************************************************************************/
+ GATT_API extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu);
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+ GATT_API 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.
+**
+*******************************************************************************/
+ GATT_API 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.
+**
+*******************************************************************************/
+ GATT_API 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 requet(s)
+**
+** Returns GATT_SUCCESS if command started successfully.
+**
+*******************************************************************************/
+ GATT_API 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.
+**
+*******************************************************************************/
+ GATT_API extern tGATT_STATUS GATTC_SendHandleValueConfirm (UINT16 conn_id, UINT16 handle);
+
+
+/*******************************************************************************
+**
+** 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.
+**
+** Returns void
+**
+*******************************************************************************/
+ GATT_API extern void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout);
+
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+ GATT_API extern tGATT_IF GATT_Register (tBT_UUID *p_app_uuid128, tGATT_CBACK *p_cb_info);
+
+/*******************************************************************************
+**
+** Function GATT_Deregister
+**
+** Description This function deregistered the application from GATT.
+**
+** Parameters gatt_if: applicaiton interface.
+**
+** Returns None.
+**
+*******************************************************************************/
+ GATT_API 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: applicaiton interface.
+**
+** Returns None
+**
+*******************************************************************************/
+ GATT_API extern void GATT_StartIf (tGATT_IF gatt_if);
+
+/*******************************************************************************
+**
+** Function GATT_Connect
+**
+** Description This function initiate a connecttion to a ATT server.
+**
+** Parameters gatt_if: applicaiton interface
+** bd_addr: peer device address.
+** is_direct: is a direct conenection or a background auto connection
+**
+** Returns TRUE if connection started; FALSE if connection start failure.
+**
+*******************************************************************************/
+ GATT_API extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct);
+
+
+/*******************************************************************************
+**
+** Function GATT_CancelConnect
+**
+** Description This function initiate a cancel connecttion to a ATT server.
+**
+** 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 conenection or a background auto connection
+**
+** Returns TRUE if connection started; FALSE if connection start failure.
+**
+*******************************************************************************/
+ GATT_API extern BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct);
+
+/*******************************************************************************
+**
+** Function GATT_Disconnect
+**
+** Description This function disconnect a logic channel.
+**
+** Parameters conn_id: connection identifier.
+**
+** Returns GATT_SUCCESS if disconnected.
+**
+*******************************************************************************/
+ GATT_API extern tGATT_STATUS GATT_Disconnect (UINT16 conn_id);
+
+
+
+/*******************************************************************************
+**
+** Function GATT_GetConnectionInfor
+**
+** Description This function use conn_id to find its associated BD address and applciation
+** interface
+**
+** Parameters conn_id: connection id (input)
+** p_gatt_if: applicaiton interface (output)
+** bd_addr: peer device address. (output)
+**
+** Returns TRUE the ligical link information is found for conn_id
+**
+*******************************************************************************/
+ GATT_API extern BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if, BD_ADDR bd_addr);
+
+
+/*******************************************************************************
+**
+** Function GATT_GetConnIdIfConnected
+**
+** Description This function find the conn_id if the logical link for BD address
+** and applciation interface is connected
+**
+** Parameters gatt_if: applicaiton interface (input)
+** bd_addr: peer device address. (input)
+** p_conn_id: connection id (output)
+**
+** Returns TRUE the ligical link is connected
+**
+*******************************************************************************/
+ GATT_API extern BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, UINT16 *p_conn_id);
+
+#ifdef __cplusplus
+
+}
+#endif
+
+#endif /* GATT_API_H */
diff --git a/stack/include/gattdefs.h b/stack/include/gattdefs.h
new file mode 100644
index 0000000..6eac0f4
--- /dev/null
+++ b/stack/include/gattdefs.h
@@ -0,0 +1,109 @@
+/******************************************************************************
+ *
+ * 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_PRIVACY_FLAG 0x2A02
+#define GATT_UUID_GAP_RECONN_ADDR 0x2A03
+#define GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
+
+/* 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 0x2A40 /* alert status */
+#define GATT_UUID_RINGER_CP 0x2A42 /* 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
+
+#endif
diff --git a/stack/include/goep_fs.h b/stack/include/goep_fs.h
new file mode 100644
index 0000000..c5d054e
--- /dev/null
+++ b/stack/include/goep_fs.h
@@ -0,0 +1,393 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef GOEP_FS_H
+#define GOEP_FS_H
+
+#include "bt_target.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+/* Flags passed to the open function (tGOEP_OPEN_CBACK)
+** Values are OR'd together. (First 3 are
+** mutually exclusive.
+*/
+#define GOEP_O_RDONLY 0x0000
+#define GOEP_O_WRONLY 0x0001
+#define GOEP_O_RDWR 0x0002
+
+#define GOEP_O_CREAT 0x0100
+#define GOEP_O_EXCL 0x0200
+#define GOEP_O_TRUNC 0x1000
+
+
+#define GOEP_LEN_UNKNOWN 0xFFFFFFFF
+#define GOEP_INVALID_FD (-1)
+
+/* Values passed to the access function (tGOEP_ACCESS_CBACK)
+*/
+#define GOEP_ACC_EXIST 0x0
+#define GOEP_ACC_READ 0x4
+#define GOEP_ACC_RDWR 0x6
+
+/* Constants used in directory listing structure */
+#define GOEP_A_RDONLY 0x1
+#define GOEP_A_DIR 0x2 /* Entry is a sub directory */
+
+#define GOEP_CTIME_LEN 17 /* Creation time "yyyymmddTHHMMSSZ" */
+
+/*****************************************************************************
+** Seek Constants
+*****************************************************************************/
+/* Origin for the seek function (tGOEP_SEEK_CBACK) */
+#define GOEP_SEEK_SET 0
+#define GOEP_SEEK_CUR 1
+#define GOEP_SEEK_END 2
+
+
+
+/*****************************************************************************
+** Typedefs
+*****************************************************************************/
+typedef INT32 tGOEP_FD;
+
+enum
+{
+ GOEP_OK,
+ GOEP_FAIL,
+ GOEP_EACCES,
+ GOEP_ENOTEMPTY,
+ GOEP_EOF,
+ GOEP_EODIR,
+ GOEP_ENOSPACE,
+ GOEP_EIS_DIR,
+ GOEP_RESUME,
+ GOEP_NONE
+};
+typedef UINT16 tGOEP_STATUS;
+
+/* Structure passed in Directory Entry Callback to be filled in */
+typedef struct
+{
+ UINT32 refdata; /* holder for OS specific data used to get next entry */
+ UINT32 filesize;
+ char crtime[GOEP_CTIME_LEN]; /* "yyyymmddTHHMMSSZ", or "" if none */
+ char *p_name; /* Contains the addr of memory to copy name into */
+ UINT8 mode; /* GOEP_A_RDONLY and/or GOEP_A_DIR */
+} tGOEP_DIRENTRY;
+
+
+/*****************************************************************************
+** Typedefs for messages from response functions
+*****************************************************************************/
+typedef struct
+{
+ BT_HDR hdr;
+ tGOEP_FD fd;
+ tGOEP_STATUS status;
+ UINT32 file_size;
+} tGOEP_OPEN_RSP;
+
+typedef struct
+{
+ BT_HDR hdr;
+ tGOEP_FD fd;
+ tGOEP_STATUS status;
+ UINT16 bytes_read;
+} tGOEP_READ_RSP;
+
+typedef struct
+{
+ BT_HDR hdr;
+ tGOEP_FD fd;
+ tGOEP_STATUS status;
+} tGOEP_WRITE_RSP;
+
+typedef struct
+{
+ BT_HDR hdr;
+ tGOEP_STATUS status;
+} tGOEP_DIRENTRY_RSP;
+
+/*****************************************************************************
+** Object Store Interface
+*****************************************************************************/
+/*******************************************************************************
+**
+** Callback Function: tGOEP_OPEN_CBACK
+**
+** Description This function is executed by OBX profiles to open
+** a file for reading or writing.
+**
+** Parameters p_path - Fully qualified path and file name.
+** flags - permissions and mode (see constants above)
+** size - size of file to put (0 if unavailable or not applicable)
+** event_id - code that must be passed to the call-in function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, a file descriptor (tGOEP_FD),
+** file size (UINT32), and an status code (tGOEP_STATUS)
+** are returned in GOEP_OpenRsp().
+**
+*******************************************************************************/
+typedef void (tGOEP_OPEN_CBACK) (const UINT8 *p_name, UINT16 flags, UINT32 size,
+ UINT16 event_id, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Callback Function: tGOEP_CLOSE_CBACK
+**
+** Description This function is executed by OBX profiles when the file descriptor
+** is no longer in use.
+**
+** Returns void
+**
+*******************************************************************************/
+typedef void (tGOEP_CLOSE_CBACK) (tGOEP_FD fd, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Callback Function: tGOEP_READ_CBACK
+**
+** Description This function is executed by OBX profiles to read in data from the
+** previously opened file.
+**
+** Returns void
+**
+** Note: Upon completion of the request, GOEP_ReadRsp() is
+** called with the buffer of data, along with the number
+** of bytes read into the buffer, and a status. The
+** call-in function should only be called when ALL requested
+** bytes have been read, the end of file has been detected,
+** or an error has occurred.
+**
+*******************************************************************************/
+typedef void (tGOEP_READ_CBACK) (tGOEP_FD fd, void *p_data, INT16 size,
+ UINT16 event_id, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Callback Function: tGOEP_WRITE_CBACK
+**
+** Description This function is executed by OBX profiles to write the data to the
+** previously opened file.
+**
+** Returns void
+**
+** Note: Upon completion of the request, GOEP_WriteRsp() is
+** called with the file descriptor and the status. The
+** call-in function should only be called when ALL requested
+** bytes have been written, or an error has been detected,
+**
+*******************************************************************************/
+typedef void (tGOEP_WRITE_CBACK) (tGOEP_FD fd, const void *p_data, INT16 size,
+ UINT16 event_id, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Callback Function: tGOEP_SEEK_CBACK
+**
+** Description This function is executed by OBX profiles to Move a file pointer
+** of a previously opened file to the specified location for the
+** next read or write operation.
+**
+** Returns void
+**
+*******************************************************************************/
+typedef void (tGOEP_SEEK_CBACK) (tGOEP_FD fd, INT32 offset, INT16 origin, UINT8 app_id);
+
+
+/*******************************************************************************
+**
+** Callback Function: tGOEP_DIRENTRY_CBACK
+**
+** Description This function is called to retrieve a directory entry for the
+** specified path. The first/next directory should be filled
+** into the location specified by p_entry.
+**
+** Parameters p_path - directory to search (Fully qualified path)
+** first_item - TRUE if first search, FALSE if next search
+** (p_cur contains previous)
+** p_entry (input/output) - Points to last entry data (valid when
+** first_item is FALSE)
+** event_id - event that must be passed into the call-in function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, GOEP_DirentryRsp() is
+** filled in entry and the status.
+** GOEP_OK is returned when p_entry is valid,
+** GOEP_EODIR is returned when no more entries [finished]
+** GOEP_FAIL is returned if an error occurred
+**
+*******************************************************************************/
+typedef void (tGOEP_DIRENTRY_CBACK) (const char *p_path, BOOLEAN first_item,
+ tGOEP_DIRENTRY *p_entry, UINT16 event_id,
+ UINT8 app_id);
+
+/*******************************************************************************
+**
+** Callback Function: tGOEP_ACCESS_CBACK
+**
+** Description This function is called to check the existence of a file or
+** directory.
+**
+** Returns (tGOEP_STATUS) status of the call.
+** [GOEP_OK if it exists]
+** [GOEP_EACCES if permissions are wrong]
+** [GOEP_FAIL if it does not exist]
+**
+*******************************************************************************/
+typedef tGOEP_STATUS (tGOEP_ACCESS_CBACK) (const char *p_path, UINT16 mode,
+ BOOLEAN *p_is_dir, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Callback Function: tGOEP_MKDIR_CBACK
+**
+** Description This function is called to create a directory with
+** the pathname given by path. The pathname is a null terminated
+** string. All components of the path must already exist.
+**
+** Parameters p_path - (input) name of directory to create (fully qualified path).
+**
+** Returns (tGOEP_STATUS) status of the call.
+** [GOEP_OK if successful]
+** [GOEP_FAIL if unsuccessful]
+**
+*******************************************************************************/
+typedef tGOEP_STATUS (tGOEP_MKDIR_CBACK) (const char *p_path, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Callback Function: tGOEP_RMDIR_CBACK
+**
+** Description This function is called to remove a directory whose
+** name is given by path. The directory must be empty.
+**
+** Parameters p_path - (input) name of directory to remove (fully qualified path).
+**
+** Returns (tGOEP_STATUS) status of the call.
+** [GOEP_OK if successful]
+** [GOEP_EACCES if read-only]
+** [GOEP_ENOTEMPTY if directory is not empty]
+** [GOEP_FAIL otherwise]
+**
+*******************************************************************************/
+typedef tGOEP_STATUS (tGOEP_RMDIR_CBACK) (const char *p_path, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Callback Function: tGOEP_UNLINK_CBACK
+**
+** Description This function is called to remove a directory whose
+** name is given by path. The directory must be empty.
+**
+** Parameters p_path - (input) name of file to remove (fully qualified path).
+**
+** Returns (tGOEP_STATUS) status of the call.
+** [GOEP_OK if successful]
+** [GOEP_EACCES if read-only]
+** [GOEP_FAIL otherwise]
+**
+*******************************************************************************/
+typedef tGOEP_STATUS (tGOEP_UNLINK_CBACK) (const char *p_path, UINT8 app_id);
+
+
+/*****************************************************************************
+** Prototypes
+*****************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+**
+** Function: GOEP_OpenRsp
+**
+** Purpose: Report the status of tGOEP_OPEN_CBACK callback function.
+**
+** Parameters: fd - File handle.
+** status - Status of the operation.
+** file_size - total number of bytes in this file.
+** event_id - event id as given in the tGOEP_OPEN_CBACK function.
+**
+** Returns: void
+**
+*****************************************************************************/
+GOEP_API extern void GOEP_OpenRsp (tGOEP_FD fd, tGOEP_STATUS status,
+ UINT32 file_size, UINT16 event_id);
+
+/*****************************************************************************
+**
+** Function: GOEP_ReadRsp
+**
+** Purpose: Report the status of tGOEP_READ_CBACK callback function.
+**
+** Parameters: fd - File handle.
+** status - Status of the operation.
+** bytes_read - total number of bytes read from the file.
+** event_id - event id as given in the tGOEP_READ_CBACK function.
+**
+** Returns: void
+**
+*****************************************************************************/
+GOEP_API extern void GOEP_ReadRsp (tGOEP_FD fd, tGOEP_STATUS status,
+ UINT16 bytes_read, UINT16 event_id);
+
+/*****************************************************************************
+**
+** Function: GOEP_WriteRsp
+**
+** Purpose: Report the status of tGOEP_WRITE_CBACK callback function.
+**
+** Parameters: fd - File handle.
+** status - Status of the operation.
+** event_id - event id as given in the tGOEP_WRITE_CBACK function.
+**
+** Returns: void
+**
+*****************************************************************************/
+GOEP_API extern void GOEP_WriteRsp (tGOEP_FD fd, tGOEP_STATUS status, UINT16 event_id);
+
+/*******************************************************************************
+**
+** Function GOEP_DirentryRsp
+**
+** Description This function is called in response to the
+** tGOEP_DIRENTRY_CBACK function with a filled in directory listing
+** entry.
+**
+** Parameters status - GOEP_OK if p_entry points to a valid entry.
+** GOEP_EODIR if no more entries (p_entry is ignored).
+** GOEP_FAIL if any errors have occurred.
+** event_id - event id as given in the tGOEP_DIRENTRY_CBACK function.
+**
+** Returns void
+**
+*******************************************************************************/
+GOEP_API extern void GOEP_DirentryRsp(tGOEP_STATUS status, UINT16 event_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GOEP_FS_H */
diff --git a/stack/include/hcidefs.h b/stack/include/hcidefs.h
new file mode 100644
index 0000000..1a0b3e8
--- /dev/null
+++ b/stack/include/hcidefs.h
@@ -0,0 +1,2233 @@
+/******************************************************************************
+ *
+ * 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 HCIDEFS_H
+#define HCIDEFS_H
+
+#ifdef BRCM_VS
+#include "brcm_vs_include.h"
+#endif
+
+#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_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)((0xFC00 & (p)) >> 10)
+#define HCI_OCF(p) ( 0x3FF & (p))
+
+/*
+** Defentions 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_RESPONSE (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_LINK_CTRL_CMDS_FIRST HCI_INQUIRY
+#define HCI_LINK_CTRL_CMDS_LAST HCI_FLOW_SPEC_MODIFY
+
+/* 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_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_CONT_BASEBAND_CMDS_FIRST HCI_SET_EVENT_MASK
+#define HCI_CONT_BASEBAND_CMDS_LAST HCI_SHORT_RANGE_MODE
+
+
+/* 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_INFORMATIONAL_CMDS_FIRST HCI_READ_LOCAL_VERSION_INFO
+#define HCI_INFORMATIONAL_CMDS_LAST HCI_READ_BD_ADDR
+
+
+/* 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)
+
+#define HCI_BLE_RESET (0x0020 | HCI_GRP_BLE_CMDS)
+
+/* 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
+
+/*
+** 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
+
+/* ULP HCI Event */
+#define HCI_BLE_EVENT 0x03E
+/* 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_EVENT_RSP_FIRST HCI_INQUIRY_COMP_EVT
+#define HCI_EVENT_RSP_LAST HCI_AMP_STATUS_CHANGE_EVT
+
+#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_PENDING 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_FEATURE 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
+
+#define HCI_ERR_MAX_ERR 0x40
+
+#define HCI_HINT_TO_RECREATE_AMP_PHYS_LINK 0xFF
+
+/*
+** 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
+ */
+
+
+/* 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
+*/
+
+
+/*
+** 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_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 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) */
+
+/* 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
+
+/* 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
+
+
+
+
+/* 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
+
+
+/*
+** Define company IDs (from Bluetooth Assigned Numbers v1.1, section 2.2)
+*/
+#define LMP_COMPID_ERICSSON 0
+#define LMP_COMPID_NOKIA 1
+#define LMP_COMPID_INTEL 2
+#define LMP_COMPID_IBM 3
+#define LMP_COMPID_TOSHIBA 4
+#define LMP_COMPID_3COM 5
+#define LMP_COMPID_MICROSOFT 6
+#define LMP_COMPID_LUCENT 7
+#define LMP_COMPID_MOTOROLA 8
+#define LMP_COMPID_INFINEON 9
+#define LMP_COMPID_CSR 10
+#define LMP_COMPID_SILICON_WAVE 11
+#define LMP_COMPID_DIGIANSWER 12
+#define LMP_COMPID_TEXAS_INSTRUMENTS 13
+#define LMP_COMPID_PARTHUS 14
+#define LMP_COMPID_BROADCOM 15
+#define LMP_COMPID_MITEL_SEMI 16
+#define LMP_COMPID_WIDCOMM 17
+#define LMP_COMPID_ZEEVO 18
+#define LMP_COMPID_ATMEL 19
+#define LMP_COMPID_MITSUBISHI 20
+#define LMP_COMPID_RTX_TELECOM 21
+#define LMP_COMPID_KC_TECH 22
+#define LMP_COMPID_NEWLOGIC 23
+#define LMP_COMPID_TRANSILICA 24
+#define LMP_COMPID_ROHDE_SCHWARZ 25
+#define LMP_COMPID_TTPCOM 26
+#define LMP_COMPID_SIGNIA 27
+#define LMP_COMPID_CONEXANT 28
+#define LMP_COMPID_QUALCOMM 29
+#define LMP_COMPID_INVENTEL 30
+#define LMP_COMPID_AVM 31
+#define LMP_COMPID_BANDSPEED 32
+#define LMP_COMPID_MANSELLA 33
+#define LMP_COMPID_NEC_CORP 34
+#define LMP_COMPID_WAVEPLUS 35
+#define LMP_COMPID_ALCATEL 36
+#define LMP_COMPID_PHILIPS 37
+#define LMP_COMPID_C_TECHNOLOGIES 38
+#define LMP_COMPID_OPEN_INTERFACE 39
+#define LMP_COMPID_RF_MICRO 40
+#define LMP_COMPID_HITACHI 41
+#define LMP_COMPID_SYMBOL_TECH 42
+#define LMP_COMPID_TENOVIS 43
+#define LMP_COMPID_MACRONIX 44
+#define LMP_COMPID_GCT_SEMI 45
+#define LMP_COMPID_NORWOOD_SYSTEMS 46
+#define LMP_COMPID_MEWTEL_TECH 47
+#define LMP_COMPID_STM 48
+#define LMP_COMPID_SYNOPSYS 49
+#define LMP_COMPID_RED_M_LTD 50
+#define LMP_COMPID_COMMIL_LTD 51
+#define LMP_COMPID_CATC 52
+#define LMP_COMPID_ECLIPSE 53
+#define LMP_COMPID_RENESAS_TECH 54
+#define LMP_COMPID_MOBILIAN_CORP 55
+#define LMP_COMPID_TERAX 56
+#define LMP_COMPID_ISSC 57
+#define LMP_COMPID_MATSUSHITA 58
+#define LMP_COMPID_GENNUM_CORP 59
+#define LMP_COMPID_RESEARCH_IN_MOTION 60
+#define LMP_COMPID_IPEXTREME 61
+#define LMP_COMPID_SYSTEMS_AND_CHIPS 62
+#define LMP_COMPID_BLUETOOTH_SIG 63
+#define LMP_COMPID_SEIKO_EPSON_CORP 64
+#define LMP_COMPID_ISS_TAIWAN 65
+#define LMP_COMPID_CONWISE_TECHNOLOGIES 66
+#define LMP_COMPID_PARROT_SA 67
+#define LMP_COMPID_SOCKET_COMM 68
+#define LMP_COMPID_ALTHEROS 69
+#define LMP_COMPID_MEDIATEK 70
+#define LMP_COMPID_BLUEGIGA 71
+#define LMP_COMPID_MARVELL 72
+#define LMP_COMPID_3DSP_CORP 73
+#define LMP_COMPID_ACCEL_SEMICONDUCTOR 74
+#define LMP_COMPID_CONTINENTAL_AUTO 75
+#define LMP_COMPID_APPLE 76
+#define LMP_COMPID_STACCATO 77
+#define LMP_COMPID_AVAGO_TECHNOLOGIES 78
+#define LMP_COMPID_APT_LTD 79
+#define LMP_COMPID_SIRF_TECHNOLOGY 80
+#define LMP_COMPID_TZERO_TECHNOLOGY 81
+#define LMP_COMPID_J_AND_M_CORP 82
+#define LMP_COMPID_FREE_2_MOVE 83
+#define LMP_COMPID_3DIJOY_CORP 84
+#define LMP_COMPID_PLANTRONICS 85
+#define LMP_COMPID_SONY_ERICSSON_MOBILE 86
+#define LMP_COMPID_HARMON_INTL_IND 87
+#define LMP_COMPID_VIZIO 88
+#define LMP_COMPID_NORDIC SEMI 89
+#define LMP_COMPID_EM MICRO 90
+#define LMP_COMPID_RALINK TECH 91
+#define LMP_COMPID_BELKIN INC 92
+#define LMP_COMPID_REALTEK SEMI 93
+#define LMP_COMPID_STONESTREET ONE 94
+#define LMP_COMPID_WICENTRIC 95
+#define LMP_COMPID_RIVIERAWAVES 96
+#define LMP_COMPID_RDA MICRO 97
+#define LMP_COMPID_GIBSON GUITARS 98
+#define LMP_COMPID_MICOMMAND INC 99
+#define LMP_COMPID_BAND XI 100
+#define LMP_COMPID_HP COMPANY 101
+#define LMP_COMPID_9SOLUTIONS OY 102
+#define LMP_COMPID_GN NETCOM 103
+#define LMP_COMPID_GENERAL MOTORS 104
+#define LMP_COMPID_AD ENGINEERING 105
+#define LMP_COMPID_MINDTREE LTD 106
+#define LMP_COMPID_POLAR ELECTRO 107
+#define LMP_COMPID_BEAUTIFUL ENTERPRISE 108
+#define LMP_COMPID_BRIARTEK 109
+#define LMP_COMPID_SUMMIT DATA COMM 110
+#define LMP_COMPID_SOUND ID 111
+#define LMP_COMPID_MONSTER LLC 112
+#define LMP_COMPID_CONNECTBLU 113
+#define LMP_COMPID_MAX_ID 114 /* this is a place holder */
+#define LMP_COMPID_INTERNAL 65535
+
+#define MAX_LMP_COMPID (LMP_COMPID_MAX_ID)
+/*
+** 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
+
+/*
+** Features encoding - page 0
+*/
+#define HCI_NUM_FEATURE_BYTES 8
+#define HCI_FEATURES_KNOWN(x) ((x[0] | x[1] | x[2] | x[3] | x[4] | x[5] | x[6] | x[7]) != 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)
+
+#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)
+
+#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)
+
+#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)
+
+#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
+
+// btla-specific ++
+#ifdef ANDROID_APP_INCLUDED
+/* 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)
+#else
+#define HCI_NON_FLUSHABLE_PB_SUPPORTED(x) ((x)[HCI_FEATURE_NON_FLUSHABLE_PB_OFF] & HCI_FEATURE_NON_FLUSHABLE_PB_MASK)
+#endif
+// btla-specific --
+
+#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)
+
+/*
+** 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)
+
+/*
+** Local Supported Commands encoding
+*/
+#define HCI_NUM_SUPP_COMMANDS_BYTES 64
+
+#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_RESPONSE_MASK 0x80
+#define HCI_SUPP_COMMANDS_IO_CAPABILITY_RESPONSE_OFF 18
+#define HCI_IO_CAPABILITY_RESPONSE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_IO_CAPABILITY_RESPONSE_OFF] & HCI_SUPP_COMMANDS_IO_CAPABILITY_RESPONSE_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)
+*/
+
+/*
+Commands of HCI_GRP_VENDOR_SPECIFIC group for WIDCOMM SW LM Simulator
+*/
+#ifdef _WIDCOMM
+
+#define HCI_SET_HCI_TRACE (0x0001 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_SET_LM_TRACE (0x0002 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_WRITE_COUNTRY_CODE (0x0004 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_READ_LM_HISTORY (0x0005 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_WRITE_BD_ADDR (0x0006 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_DISABLE_ENCRYPTION (0x0007 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_DISABLE_AUTHENTICATION (0x0008 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_GENERIC_LC_CMD (0x000A | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_INCR_POWER (0x000B | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_DECR_POWER (0x000C | HCI_GRP_VENDOR_SPECIFIC)
+
+/* Definitions for the local transactions */
+#define LM_DISCONNECT (0x00D0 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_AUTHENTICATION_REQUESTED (0x00D1 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_SET_CONN_ENCRYPTION (0x00D2 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_START_ENCRYPT_KEY_SIZE (0x00D3 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_START_ENCRYPTION (0x00D4 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_STOP_ENCRYPTION (0x00D5 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_CHANGE_CONN_PACKET_TYPE (0x00D6 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_RMT_NAME_REQUEST (0x00D7 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_READ_RMT_FEATURES (0x00D8 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_READ_RMT_VERSION_INFO (0x00D9 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_READ_RMT_TIMING_INFO (0x00DA | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_READ_RMT_CLOCK_OFFSET (0x00DB | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HOLD_MODE (0x00DC | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_EXIT_PARK_MODE (0x00DD | HCI_GRP_VENDOR_SPECIFIC)
+
+#define LM_SCO_LINK_REQUEST (0x00E0 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_SCO_CHANGE (0x00E4 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_SCO_REMOVE (0x00E8 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_MAX_SLOTS (0x00F1 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_MAX_SLOTS_REQUEST (0x00F2 | HCI_GRP_VENDOR_SPECIFIC)
+
+#ifdef INCLUDE_OPTIONAL_PAGING_SCHEME
+#define LM_OPTIONAL_PAGE_REQUEST (0x00F3 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_OPTIONAL_PAGESCAN_REQUEST (0x00F4 | HCI_GRP_VENDOR_SPECIFIC)
+#endif
+
+#define LM_SETUP_COMPLETE (0x00FF | HCI_GRP_VENDOR_SPECIFIC)
+
+#define LM_HIST_SEND_LMP_FRAME (0x0100 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_RECV_LMP_FRAME (0x0101 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_HCIT_ERROR (0x0102 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_PER_INQ_TOUT (0x0103 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_INQ_SCAN_TOUT (0x0104 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_PAGE_SCAN_TOUT (0x0105 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_RESET_TOUT (0x0106 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_MANDAT_PSCAN_TOUT (0x0107 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_ACL_START_TRANS (0x0108 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_ACL_HOST_REPLY (0x0109 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_ACL_TIMEOUT (0x010A | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_ACL_TX_COMP (0x010B | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_ACL_HCID_SUSPENDED (0x010C | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_ACL_FAILED (0x010D | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_HCI_COMMAND (0x010E | HCI_GRP_VENDOR_SPECIFIC)
+
+#define LM_HIST_HCI_EVENT (0x010F | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_HCI_UPDATA (0x0110 | HCI_GRP_VENDOR_SPECIFIC)
+#define LM_HIST_HCI_DNDATA (0x0111 | HCI_GRP_VENDOR_SPECIFIC)
+
+#define HCI_ENTER_TEST_MODE (0x0300 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_LMP_TEST_CNTRL (0x0301 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_DEBUG_LC_CMD_MIN (0x0300 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_DEBUG_LC_CMD_MAX (0x03FF | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_DEBUG_LC_COMMAND HCI_DEBUG_LC_CMD_MAX
+
+#endif
+
+
+/* AMP VSE events
+*/
+#define AMP_VSE_CHANSPEC_CHAN_MASK 0x00ff
+
+#define AMP_VSE_CHANSPEC_CTL_SB_MASK 0x0300
+#define AMP_VSE_CHANSPEC_CTL_SB_LOWER 0x0100
+#define AMP_VSE_CHANSPEC_CTL_SB_UPPER 0x0200
+#define AMP_VSE_CHANSPEC_CTL_SB_NONE 0x0300
+
+#define AMP_VSE_CHANSPEC_BW_MASK 0x0C00
+#define AMP_VSE_CHANSPEC_BW_10 0x0400
+#define AMP_VSE_CHANSPEC_BW_20 0x0800
+#define AMP_VSE_CHANSPEC_BW_40 0x0C00
+
+#define AMP_VSE_CHANSPEC_BAND_MASK 0xf000
+#define AMP_VSE_CHANSPEC_BAND_5G 0x1000
+#define AMP_VSE_CHANSPEC_BAND_2G 0x2000
+
+
+#endif
+
diff --git a/stack/include/hcimsgs.h b/stack/include/hcimsgs.h
new file mode 100644
index 0000000..3a23dbe
--- /dev/null
+++ b/stack/include/hcimsgs.h
@@ -0,0 +1,1331 @@
+/******************************************************************************
+ *
+ * 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 "bt_target.h"
+#include "hcidefs.h"
+#include "bt_types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Message by message.... */
+
+#define HCIC_GET_UINT8(p, off) (UINT8)(*((UINT8 *)((p) + 1) + p->offset + 3 + (off)))
+
+#define HCIC_GET_UINT16(p, off) (UINT16)((*((UINT8 *)((p) + 1) + p->offset + 3 + (off)) + \
+ (*((UINT8 *)((p) + 1) + p->offset + 3 + (off) + 1) << 8)))
+
+#define HCIC_GET_UINT32(p, off) (UINT32)((*((UINT8 *)((p) + 1) + p->offset + 3 + (off)) + \
+ (*((UINT8 *)((p) + 1) + p->offset + 3 + (off) + 1) << 8) + \
+ (*((UINT8 *)((p) + 1) + p->offset + 3 + (off) + 2) << 16) + \
+ (*((UINT8 *)((p) + 1) + p->offset + 3 + (off) + 3) << 24)))
+
+#define HCIC_GET_ARRAY(p, off, x, len) \
+{ \
+ UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x; \
+ int ii; for (ii = 0; ii < len; ii++) *rr++ = *qq++; \
+}
+
+#define HCIC_GET_ARRAY16(p, off, x) \
+{ \
+ UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x + 15; \
+ int ii; for (ii = 0; ii < 16; ii++) *rr-- = *qq++; \
+}
+
+#define HCIC_GET_BDADDR(p, off, x) \
+{ \
+ UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x + BD_ADDR_LEN - 1; \
+ int ii; for (ii = 0; ii < BD_ADDR_LEN; ii++) *rr-- = *qq++; \
+}
+
+#define HCIC_GET_DEVCLASS(p, off, x) \
+{ \
+ UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x + DEV_CLASS_LEN - 1; \
+ int ii; for (ii = 0; ii < DEV_CLASS_LEN; ii++) *rr-- = *qq++; \
+}
+
+#define HCIC_GET_LAP(p, off, x) \
+{ \
+ UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x + LAP_LEN - 1; \
+ int ii; for (ii = 0; ii < LAP_LEN; ii++) *rr-- = *qq++; \
+}
+
+#define HCIC_GET_POINTER(p, off) ((UINT8 *)((p) + 1) + p->offset + 3 + (off))
+
+
+HCI_API extern 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 */
+HCI_API extern BOOLEAN btsnd_hcic_inq_cancel(void);
+
+#define HCIC_PARAM_SIZE_INQ_CANCEL 0
+
+ /* Periodic Inquiry Mode */
+HCI_API extern 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 */
+HCI_API extern BOOLEAN btsnd_hcic_exit_per_inq(void);
+
+#define HCIC_PARAM_SIZE_EXIT_PER_INQ 0
+ /* Create Connection */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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
+
+HCI_API extern BOOLEAN btsnd_hcic_auth_request (UINT16 handle); /* Authentication Request */
+
+ /* Set Connection Encryption */
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_change_link_key (UINT16 handle); /* Change Connection Link Key */
+
+ /* Master Link Key */
+HCI_API extern BOOLEAN btsnd_hcic_master_link_key (BOOLEAN key_flag);
+
+#define HCIC_PARAM_SIZE_MASTER_LINK_KEY 1
+
+#define HCI_MASTER_KEY_FLAG_OFF 0
+ /* Master Link Key */
+
+ /* Remote Name Request */
+HCI_API extern 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 */
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_rmt_features_req(UINT16 handle); /* Remote Features Request */
+
+ /* Remote Extended Features */
+HCI_API extern 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 */
+
+
+ /* Local Extended Features */
+HCI_API extern BOOLEAN btsnd_hcic_read_local_ext_features (UINT8 page_num);
+
+#define HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES 1
+
+#define HCI_LOCAL_EXT_FEATURES_PAGE_NUM_OFF 0
+ /* Local Extended Features */
+
+
+HCI_API extern BOOLEAN btsnd_hcic_rmt_ver_req(UINT16 handle); /* Remote Version Info Request */
+HCI_API extern BOOLEAN btsnd_hcic_read_rmt_clk_offset(UINT16 handle); /* Remote Clock Offset */
+HCI_API extern BOOLEAN btsnd_hcic_read_lmp_handle(UINT16 handle); /* Remote LMP Handle */
+
+HCI_API extern 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
+
+
+HCI_API extern 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
+
+
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_exit_sniff_mode(UINT16 handle); /* Exit Sniff Mode */
+
+ /* Park Mode */
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_exit_park_mode(UINT16 handle); /* Exit Park Mode */
+
+ /* QoS Setup */
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_role_discovery (UINT16 handle); /* Role Discovery */
+
+ /* Switch Role Request */
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_read_policy_set(UINT16 handle); /* Read Policy Settings */
+
+ /* Write Policy Settings */
+HCI_API extern 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 */
+
+ /* Read Default Policy Settings */
+HCI_API extern BOOLEAN btsnd_hcic_read_def_policy_set(void);
+
+#define HCIC_PARAM_SIZE_READ_DEF_POLICY_SET 0
+ /* Read Default Policy Settings */
+
+ /* Write Default Policy Settings */
+HCI_API extern 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 */
+
+ /* Flow Specification */
+HCI_API extern BOOLEAN btsnd_hcic_flow_specification(UINT16 handle, UINT8 flags,
+ UINT8 flow_direct,
+ UINT8 service_type,
+ UINT32 token_rate,
+ UINT32 token_bucket_size,
+ UINT32 peak, UINT32 latency);
+
+#define HCIC_PARAM_SIZE_FLOW_SPEC 21
+
+#define HCI_FLOW_SPEC_HANDLE_OFF 0
+#define HCI_FLOW_SPEC_FLAGS_OFF 2
+#define HCI_FLOW_SPEC_FLOW_DIRECT_OFF 3
+#define HCI_FLOW_SPEC_SERVICE_TYPE_OFF 4
+#define HCI_FLOW_SPEC_TOKEN_RATE_OFF 5
+#define HCI_FLOW_SPEC_TOKEN_BUCKET_SIZE_OFF 9
+#define HCI_FLOW_SPEC_PEAK_BANDWIDTH_OFF 13
+#define HCI_FLOW_SPEC_LATENCY_OFF 17
+ /* Flow Specification */
+
+/******************************************
+** Lisbon Features
+*******************************************/
+#if BTM_SSR_INCLUDED == TRUE
+ /* Sniff Subrating */
+HCI_API extern 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 */
+#if (BTM_EIR_SERVER_INCLUDED == TRUE)
+HCI_API extern void btsnd_hcic_write_ext_inquiry_response(void *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
+
+HCI_API extern BOOLEAN btsnd_hcic_read_ext_inquiry_response(void); /* Read Extended Inquiry Response */
+#else
+#define btsnd_hcic_write_ext_inquiry_response(buffer, fec_req)
+#define btsnd_hcic_read_ext_inquiry_response() FALSE
+#endif
+ /* Write Simple Pairing Mode */
+/**** Simple Pairing Commands ****/
+HCI_API extern BOOLEAN btsnd_hcic_write_simple_pairing_mode(UINT8 mode);
+
+#define HCIC_PARAM_SIZE_W_SIMP_PAIR 1
+
+#define HCIC_WRITE_SP_MODE_OFF 0
+
+
+HCI_API extern BOOLEAN btsnd_hcic_read_simple_pairing_mode (void);
+
+#define HCIC_PARAM_SIZE_R_SIMP_PAIR 0
+
+ /* Write Simple Pairing Debug Mode */
+HCI_API extern BOOLEAN btsnd_hcic_write_simp_pair_debug_mode(UINT8 debug_mode);
+
+#define HCIC_PARAM_SIZE_SIMP_PAIR_DBUG 1
+
+#define HCIC_WRITE_SP_DBUG_MODE_OFF 0
+
+ /* IO Capabilities Response */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern BOOLEAN btsnd_hcic_read_local_oob_data (void);
+
+#define HCIC_PARAM_SIZE_R_LOCAL_OOB 0
+
+
+HCI_API extern 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
+
+
+HCI_API extern 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
+
+
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern 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 */
+HCI_API extern BOOLEAN btsnd_hcic_read_inq_tx_power (void);
+
+#define HCIC_PARAM_SIZE_R_TX_POWER 0
+
+ /* Write Tx Power Level */
+HCI_API extern BOOLEAN btsnd_hcic_write_inq_tx_power (INT8 level);
+
+#define HCIC_PARAM_SIZE_W_TX_POWER 1
+
+#define HCIC_WRITE_TX_POWER_LEVEL_OFF 0
+ /* Read Default Erroneous Data Reporting */
+HCI_API extern BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void);
+
+#define HCIC_PARAM_SIZE_R_ERR_DATA_RPT 0
+
+ /* Write Default Erroneous Data Reporting */
+HCI_API extern BOOLEAN btsnd_hcic_write_default_erroneous_data_rpt (UINT8 level);
+
+#define HCIC_PARAM_SIZE_W_ERR_DATA_RPT 1
+
+#define HCIC_WRITE_ERR_DATA_RPT_OFF 0
+
+
+#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
+HCI_API extern BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type);
+
+#define HCIC_PARAM_SIZE_ENHANCED_FLUSH 3
+#endif
+
+
+HCI_API extern 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
+
+
+HCI_API extern BOOLEAN btsnd_hcic_refresh_encryption_key(UINT16 handle); /* Refresh Encryption Key */
+
+/**** end of Simple Pairing Commands ****/
+
+
+HCI_API extern BOOLEAN btsnd_hcic_set_event_mask(UINT8 local_controller_id, BT_EVENT_MASK evt_mask);
+
+#define HCIC_PARAM_SIZE_SET_EVENT_MASK 8
+#define HCI_EVENT_MASK_MASK_OFF 0
+ /* Set Event Mask */
+
+ /* Reset */
+HCI_API extern BOOLEAN btsnd_hcic_set_event_mask_page_2 (UINT8 local_controller_id,
+ BT_EVENT_MASK event_mask);
+
+#define HCIC_PARAM_SIZE_SET_EVENT_MASK_PAGE_2 8
+#define HCI_EVENT_MASK_MASK_OFF 0
+ /* Set Event Mask Page 2 */
+
+ /* Reset */
+HCI_API extern BOOLEAN btsnd_hcic_reset(UINT8 local_controller_id);
+
+#define HCIC_PARAM_SIZE_RESET 0
+ /* Reset */
+
+ /* Store Current Settings */
+#define MAX_FILT_COND (sizeof (BD_ADDR) + 1)
+
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_flush(UINT8 local_controller_id, UINT16 handle); /* Flush */
+
+ /* Create New Unit Type */
+HCI_API extern BOOLEAN btsnd_hcic_new_unit_key(void);
+
+#define HCIC_PARAM_SIZE_NEW_UNIT_KEY 0
+ /* Create New Unit Type */
+
+ /* Read Stored Key */
+HCI_API extern BOOLEAN btsnd_hcic_read_stored_key (BD_ADDR bd_addr,
+ BOOLEAN read_all_flag);
+
+#define HCIC_PARAM_SIZE_READ_STORED_KEY 7
+
+#define HCI_READ_KEY_BD_ADDR_OFF 0
+#define HCI_READ_KEY_ALL_FLAG_OFF 6
+ /* Read Stored Key */
+
+#define MAX_WRITE_KEYS 10
+ /* Write Stored Key */
+HCI_API extern BOOLEAN btsnd_hcic_write_stored_key (UINT8 num_keys, BD_ADDR *bd_addr,
+ LINK_KEY *link_key);
+
+#define HCIC_PARAM_SIZE_WRITE_STORED_KEY sizeof(btmsg_hcic_write_stored_key_t)
+
+#define HCI_WRITE_KEY_NUM_KEYS_OFF 0
+#define HCI_WRITE_KEY_BD_ADDR_OFF 1
+#define HCI_WRITE_KEY_KEY_OFF 7
+/* only 0x0b keys cab be sent in one HCI command */
+#define HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD 0x0b
+ /* Write Stored Key */
+
+ /* Delete Stored Key */
+HCI_API extern 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 */
+HCI_API extern BOOLEAN btsnd_hcic_change_name(BD_NAME 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
+
+#define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10
+
+HCI_API extern BOOLEAN btsnd_hcic_read_pin_type(void); /* Read PIN Type */
+HCI_API extern BOOLEAN btsnd_hcic_write_pin_type(UINT8 type); /* Write PIN Type */
+HCI_API extern BOOLEAN btsnd_hcic_read_auto_accept(void); /* Read Auto Accept */
+HCI_API extern BOOLEAN btsnd_hcic_write_auto_accept(UINT8 flag); /* Write Auto Accept */
+HCI_API extern BOOLEAN btsnd_hcic_read_name (void); /* Read Local Name */
+HCI_API extern BOOLEAN btsnd_hcic_read_conn_acc_tout(UINT8 local_controller_id); /* Read Connection Accept Timout */
+HCI_API extern BOOLEAN btsnd_hcic_write_conn_acc_tout(UINT8 local_controller_id, UINT16 tout); /* Write Connection Accept Timout */
+HCI_API extern BOOLEAN btsnd_hcic_read_page_tout(void); /* Read Page Timout */
+HCI_API extern BOOLEAN btsnd_hcic_write_page_tout(UINT16 timeout); /* Write Page Timout */
+HCI_API extern BOOLEAN btsnd_hcic_read_scan_enable(void); /* Read Scan Enable */
+HCI_API extern BOOLEAN btsnd_hcic_write_scan_enable(UINT8 flag); /* Write Scan Enable */
+HCI_API extern BOOLEAN btsnd_hcic_read_pagescan_cfg(void); /* Read Page Scan Activity */
+
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_read_inqscan_cfg(void); /* Read Inquiry Scan Activity */
+
+ /* Write Inquiry Scan Activity */
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_read_auth_enable(void); /* Read Authentication Enable */
+HCI_API extern BOOLEAN btsnd_hcic_write_auth_enable(UINT8 flag); /* Write Authentication Enable */
+HCI_API extern BOOLEAN btsnd_hcic_read_encr_mode (void); /* Read encryption mode */
+HCI_API extern BOOLEAN btsnd_hcic_write_encr_mode (UINT8 mode); /* Write encryption mode */
+HCI_API extern BOOLEAN btsnd_hcic_read_dev_class(void); /* Read Class of Device */
+HCI_API extern BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev); /* Write Class of Device */
+HCI_API extern BOOLEAN btsnd_hcic_read_voice_settings(void); /* Read Voice Settings */
+HCI_API extern 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
+
+HCI_API extern BOOLEAN btsnd_hcic_set_host_flow_ctrl (UINT8 value); /* Enable/disable flow control toward host */
+
+
+HCI_API extern BOOLEAN btsnd_hcic_read_auto_flush_tout(UINT16 handle); /* Read Retransmit Timout */
+
+HCI_API extern 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
+
+HCI_API extern BOOLEAN btsnd_hcic_read_num_bcast_xmit(void); /* Read Num Broadcast Retransmits */
+HCI_API extern BOOLEAN btsnd_hcic_write_num_bcast_xmit(UINT8 num); /* Write Num Broadcast Retransmits */
+HCI_API extern BOOLEAN btsnd_hcic_read_hold_mode_act(void); /* Read Hold Mode Activity */
+HCI_API extern BOOLEAN btsnd_hcic_write_hold_mode_act(UINT8 flags); /* Write Hold Mode Activity */
+
+HCI_API extern 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
+
+HCI_API extern BOOLEAN btsnd_hcic_read_sco_flow_enable(void); /* Read Authentication Enable */
+HCI_API extern BOOLEAN btsnd_hcic_write_sco_flow_enable(UINT8 flag); /* Write Authentication Enable */
+
+ /* Set Host Buffer Size */
+HCI_API extern BOOLEAN btsnd_hcic_set_host_buf_size (UINT16 acl_len,
+ UINT8 sco_len,
+ UINT16 acl_num,
+ UINT16 sco_num);
+
+#define HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE 7
+
+#define HCI_HOST_BUF_SIZE_ACL_LEN_OFF 0
+#define HCI_HOST_BUF_SIZE_SCO_LEN_OFF 2
+#define HCI_HOST_BUF_SIZE_ACL_NUM_OFF 3
+#define HCI_HOST_BUF_SIZE_SCO_NUM_OFF 5
+
+
+HCI_API extern 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
+
+HCI_API extern BOOLEAN btsnd_hcic_read_link_super_tout(UINT8 local_controller_id, UINT16 handle); /* Read Link Supervision Timeout */
+
+ /* Write Link Supervision Timeout */
+HCI_API extern 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 */
+
+HCI_API extern BOOLEAN btsnd_hcic_read_max_iac (void); /* Read Num Supported IAC */
+HCI_API extern BOOLEAN btsnd_hcic_read_cur_iac_lap (void); /* Read Current IAC LAP */
+
+HCI_API extern 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 */
+
+ /* Read Clock */
+HCI_API extern BOOLEAN btsnd_hcic_read_clock (UINT16 handle, UINT8 which_clock);
+
+#define HCIC_PARAM_SIZE_READ_CLOCK 3
+
+#define HCI_READ_CLOCK_HANDLE_OFF 0
+#define HCI_READ_CLOCK_WHICH_CLOCK 2
+ /* Read Clock */
+
+#ifdef TESTER_ENABLE
+
+#define HCIC_PARAM_SIZE_ENTER_TEST_MODE 2
+
+#define HCI_ENTER_TEST_HANDLE_OFF 0
+
+#define HCIC_PARAM_SIZE_TEST_CNTRL 10
+#define HCI_TEST_CNTRL_HANDLE_OFF 0
+#define HCI_TEST_CNTRL_SCENARIO_OFF 2
+#define HCI_TEST_CNTRL_HOPPINGMODE_OFF 3
+#define HCI_TEST_CNTRL_TX_FREQ_OFF 4
+#define HCI_TEST_CNTRL_RX_FREQ_OFF 5
+#define HCI_TEST_CNTRL_PWR_CNTRL_MODE_OFF 6
+#define HCI_TEST_CNTRL_POLL_PERIOD_OFF 7
+#define HCI_TEST_CNTRL_PKT_TYPE_OFF 8
+#define HCI_TEST_CNTRL_LENGTH_OFF 9
+
+#endif
+
+HCI_API extern BOOLEAN btsnd_hcic_read_page_scan_per (void); /* Read Page Scan Period Mode */
+HCI_API extern BOOLEAN btsnd_hcic_write_page_scan_per (UINT8 mode); /* Write Page Scan Period Mode */
+HCI_API extern BOOLEAN btsnd_hcic_read_page_scan_mode (void); /* Read Page Scan Mode */
+HCI_API extern BOOLEAN btsnd_hcic_write_page_scan_mode (UINT8 mode); /* Write Page Scan Mode */
+HCI_API extern BOOLEAN btsnd_hcic_read_local_ver (UINT8 local_controller_id); /* Read Local Version Info */
+HCI_API extern BOOLEAN btsnd_hcic_read_local_supported_cmds (UINT8 local_controller_id); /* Read Local Supported Commands */
+HCI_API extern BOOLEAN btsnd_hcic_read_local_features (void); /* Read Local Supported Features */
+HCI_API extern BOOLEAN btsnd_hcic_read_buffer_size (void); /* Read Local buffer sizes */
+HCI_API extern BOOLEAN btsnd_hcic_read_country_code (void); /* Read Country Code */
+HCI_API extern BOOLEAN btsnd_hcic_read_bd_addr (void); /* Read Local BD_ADDR */
+HCI_API extern BOOLEAN btsnd_hcic_read_fail_contact_count (UINT8 local_controller_id, UINT16 handle); /* Read Failed Contact Counter */
+HCI_API extern BOOLEAN btsnd_hcic_reset_fail_contact_count (UINT8 local_controller_id, UINT16 handle);/* Reset Failed Contact Counter */
+HCI_API extern BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle); /* Get Link Quality */
+HCI_API extern BOOLEAN btsnd_hcic_read_rssi (UINT16 handle); /* Read RSSI */
+HCI_API extern BOOLEAN btsnd_hcic_read_loopback_mode (void); /* Read Loopback Mode */
+HCI_API extern BOOLEAN btsnd_hcic_write_loopback_mode (UINT8 mode); /* Write Loopback Mode */
+HCI_API extern BOOLEAN btsnd_hcic_enable_test_mode (void); /* Enable Device Under Test Mode */
+HCI_API extern BOOLEAN btsnd_hcic_write_pagescan_type(UINT8 type); /* Write Page Scan Type */
+HCI_API extern BOOLEAN btsnd_hcic_read_pagescan_type(void); /* Read Page Scan Type */
+HCI_API extern BOOLEAN btsnd_hcic_write_inqscan_type(UINT8 type); /* Write Inquiry Scan Type */
+HCI_API extern BOOLEAN btsnd_hcic_read_inqscan_type(void); /* Read Inquiry Scan Type */
+HCI_API extern BOOLEAN btsnd_hcic_write_inquiry_mode(UINT8 type); /* Write Inquiry Mode */
+HCI_API extern BOOLEAN btsnd_hcic_read_inquiry_mode(void); /* Read Inquiry Mode */
+HCI_API extern BOOLEAN btsnd_hcic_set_afh_channels (UINT8 first, UINT8 last);
+HCI_API extern BOOLEAN btsnd_hcic_write_afh_channel_assessment_mode (UINT8 mode);
+HCI_API extern BOOLEAN btsnd_hcic_set_afh_host_channel_class (UINT8 *p_afhchannelmap);
+HCI_API extern BOOLEAN btsnd_hcic_read_afh_channel_assessment_mode(void);
+HCI_API extern BOOLEAN btsnd_hcic_read_afh_channel_map (UINT16 handle);
+HCI_API extern BOOLEAN btsnd_hcic_nop(void); /* NOP */
+
+ /* Send HCI Data */
+HCI_API extern void btsnd_hcic_data (BT_HDR *p_buf, UINT16 len, UINT16 handle, UINT8 boundary, UINT8 broadcast);
+
+#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
+ /* Send HCI Data */
+
+#define HCID_GET_SCO_LEN(p) (*((UINT8 *)((p) + 1) + p->offset + 2))
+
+HCI_API extern void btsnd_hcic_vendor_spec_cmd (
+ void *buffer, UINT16 opcode,
+ UINT8 len, UINT8 *p_data,
+ void *p_cmd_cplt_cback);
+
+
+/*********************************************************************************
+** **
+** H C I E V E N T S **
+** **
+*********************************************************************************/
+
+/* Inquiry Complete Event */
+HCI_API extern void btsnd_hcie_inq_comp(void *buffer, UINT8 status);
+
+#define HCIE_PARAM_SIZE_INQ_COMP 1
+
+/* Inquiry Response Event */
+HCI_API extern void btsnd_hcie_inq_res(void *buffer, UINT8 num_resp, UINT8 **bd_addr,
+ UINT8 *page_scan_rep_mode, UINT8 *page_scan_per_mode,
+ UINT8 *page_scan_mode, UINT8 **dev_class,
+ UINT16 *clock_offset);
+
+/* Connection Complete Event */
+HCI_API extern void btsnd_hcie_connection_comp(void *buffer, UINT8 status, UINT16 handle,
+ BD_ADDR bd_addr, UINT8 link_type, UINT8 encr_mode);
+
+#define HCIE_PARAM_SIZE_CONNECTION_COMP 11
+
+
+#define HCI_LINK_TYPE_SCO 0x00
+#define HCI_LINK_TYPE_ACL 0x01
+
+#define HCI_ENCRYPT_MODE_DISABLED 0x00
+#define HCI_ENCRYPT_MODE_POINT_TO_POINT 0x01
+#define HCI_ENCRYPT_MODE_ALL 0x02
+
+
+/* Connection Request Event */
+HCI_API extern void btsnd_hcie_connection_req(void *buffer, BD_ADDR bd_addr, DEV_CLASS dev_class, UINT8 link_type);
+
+#define HCIE_PARAM_SIZE_CONNECTION_REQ 10
+
+#define HCI_LINK_TYPE_SCO 0x00
+#define HCI_LINK_TYPE_ACL 0x01
+
+
+/* Disonnection Complete Event */
+HCI_API extern void btsnd_hcie_disc_comp(void *buffer, UINT8 status, UINT16 handle, UINT8 reason);
+
+#define HCIE_PARAM_SIZE_DISC_COMP 4
+
+
+/* Authentication Complete Event */
+HCI_API extern void btsnd_hcie_auth_comp (void *buffer, UINT8 status, UINT16 handle);
+
+#define HCIE_PARAM_SIZE_AUTH_COMP 3
+
+
+/* Remote Name Request Complete Event */
+HCI_API extern void btsnd_hcie_rmt_name_req_comp(void *buffer, UINT8 status, BD_ADDR bd_addr, BD_NAME name);
+
+#define HCIE_PARAM_SIZE_RMT_NAME_REQ_COMP (1 + BD_ADDR_LEN + BD_NAME_LEN)
+
+
+/* Encryption Change Event */
+HCI_API extern void btsnd_hcie_encryption_change (void *buffer, UINT8 status, UINT16 handle, BOOLEAN enable);
+
+#define HCIE_PARAM_SIZE_ENCR_CHANGE 4
+
+
+/* Connection Link Key Change Event */
+HCI_API extern void btsnd_hcie_conn_link_key_change (void *buffer, UINT8 status, UINT16 handle);
+
+#define HCIE_PARAM_SIZE_LINK_KEY_CHANGE 3
+
+
+/* Encryption Key Refresh Complete Event */
+HCI_API extern void btsnd_hcie_encrypt_key_refresh (void *buffer, UINT8 status, UINT16 handle);
+
+#define HCIE_PARAM_SIZE_ENCRYPT_KEY_REFRESH 3
+
+
+/* Master Link Key Complete Event */
+HCI_API extern void btsnd_hcie_master_link_key (void *buffer, UINT8 status, UINT16 handle, UINT8 flag);
+
+#define HCIE_PARAM_SIZE_MASTER_LINK_KEY 4
+
+
+/* Read Remote Supported Features Complete Event */
+HCI_API extern void btsnd_hcie_read_rmt_features (void *buffer, UINT8 status, UINT16 handle, UINT8 *features);
+
+#define LMP_FEATURES_SIZE 8
+#define HCIE_PARAM_SIZE_READ_RMT_FEATURES 11
+
+
+/* Read Remote Extended Features Complete Event */
+HCI_API extern void btsnd_hcie_read_rmt_ext_features (void *buffer, UINT8 status, UINT16 handle, UINT8 page_num,
+ UINT8 max_page_num, UINT8 *features);
+
+#define EXT_LMP_FEATURES_SIZE 8
+#define HCIE_PARAM_SIZE_READ_RMT_EXT_FEATURES 13
+
+
+/* Read Remote Version Complete Event */
+HCI_API extern void btsnd_hcie_read_rmt_version (void *buffer, UINT8 status, UINT16 handle, UINT8 version,
+ UINT16 comp_name, UINT16 sub_version);
+
+#define HCIE_PARAM_SIZE_READ_RMT_VERSION 8
+
+
+/* QOS setup complete */
+HCI_API extern void btsnd_hcie_qos_setup_compl (void *buffer, UINT8 status, UINT16 handle, UINT8 flags,
+ UINT8 service_type, UINT32 token_rate, UINT32 peak,
+ UINT32 latency, UINT32 delay_var);
+
+#define HCIE_PARAM_SIZE_QOS_SETUP_COMP 21
+
+
+/* Flow Specification complete */
+HCI_API extern void btsnd_hcie_flow_spec_compl (void *buffer, UINT8 status, UINT16 handle, UINT8 flags,
+ UINT8 flow_direction, UINT8 service_type, UINT32 token_rate, UINT32 token_bucket_size,
+ UINT32 peak, UINT32 latency);
+
+#define HCIE_PARAM_SIZE_FLOW_SPEC_COMP 22
+
+
+/* Command Complete Event */
+HCI_API extern void btsnd_hcie_cmd_comp(void *buffer, UINT8 max_host_cmds, UINT16 opcode, UINT8 status);
+
+#define HCIE_PARAM_SIZE_CMD_COMP 4
+
+
+/* Command Complete with pre-filled in parameters */
+HCI_API extern void btsnd_hcie_cmd_comp_params (void *buffer, UINT8 max_host_cmds, UINT16 cmd_opcode, UINT8 status);
+
+#define HCI_CMD_COMPL_PARAM_OFFSET 4
+
+
+/* Command Complete Event with 1-byte param */
+HCI_API extern void btsnd_hcie_cmd_comp_param1(void *buffer, UINT8 max_host_cmds, UINT16 opcode,
+ UINT8 status, UINT8 param1);
+
+#define HCIE_PARAM_SIZE_CMD_COMP_PARAM1 5
+
+/* Command Complete Event with 2-byte param */
+HCI_API extern void btsnd_hcie_cmd_comp_param2(void *buffer, UINT8 max_host_cmds, UINT16 opcode,
+ UINT8 status, UINT16 param2);
+
+#define HCIE_PARAM_SIZE_CMD_COMP_PARAM2 6
+
+
+/* Command Complete Event with BD-addr as param */
+HCI_API extern void btsnd_hcie_cmd_comp_bd_addr(void *buffer, UINT8 max_host_cmds, UINT16 opcode,
+ UINT8 status, BD_ADDR bd_addr);
+
+#define HCIE_PARAM_SIZE_CMD_COMP_BD_ADDR 10
+
+
+/* Command Pending Event */
+HCI_API extern void btsnd_hcie_cmd_status (void *buffer, UINT8 status, UINT8 max_host_cmds, UINT16 opcode);
+
+#define HCIE_PARAM_SIZE_CMD_STATUS 4
+
+
+/* HW failure Event */
+HCI_API extern void btsnd_hcie_hw_failure (void *buffer, UINT8 code);
+
+#define HCIE_PARAM_SIZE_HW_FAILURE 1
+
+
+/* Flush Occured Event */
+HCI_API extern void btsnd_hcie_flush_occured (void *buffer, UINT16 handle);
+
+#define HCIE_PARAM_SIZE_FLUSH_OCCURED 2
+
+
+/* Role Changed Event */
+HCI_API extern void btsnd_hcie_role_change (void *buffer, UINT8 status, BD_ADDR bd_addr, UINT8 role);
+
+#define HCIE_PARAM_SIZE_ROLE_CHANGE 8
+
+
+/* Ready for Data Packets Event */
+HCI_API extern void btsnd_hcie_num_compl_pkts (void *buffer, UINT8 num_handles, UINT16 *p_handle, UINT16 *num_pkts);
+
+#define MAX_DATA_HANDLES 10
+
+
+/* Mode Change Event */
+HCI_API extern void btsnd_hcie_mode_change (void *buffer, UINT8 status, UINT16 handle,
+ UINT8 mode, UINT16 interval);
+
+#define HCIE_PARAM_SIZE_MODE_CHANGE 6
+#define MAX_DATA_HANDLES 10
+
+
+
+/* Return Link Keys Event */
+HCI_API extern void btsnd_hcie_return_link_keys (void *buffer, UINT8 num_keys, BD_ADDR *bd_addr, LINK_KEY *link_key);
+
+/* This should not be more than 0x0b */
+#define MAX_LINK_KEYS 10
+
+
+
+/* PIN Code Request Event */
+HCI_API extern void btsnd_hcie_pin_code_req (void *buffer, BD_ADDR bd_addr);
+
+#define HCIE_PARAM_SIZE_PIN_CODE_REQ 6
+
+
+
+/* Link Key Request Event */
+HCI_API extern void btsnd_hcie_link_key_req (void *buffer, BD_ADDR bd_addr);
+
+#define HCIE_PARAM_SIZE_LINK_KEY_REQ 6
+
+
+
+/* Link Key Notification Event */
+HCI_API extern void btsnd_hcie_link_key_notify (void *buffer, BD_ADDR bd_addr, LINK_KEY link_key, UINT8 key_type);
+
+#define HCIE_PARAM_SIZE_LINK_KEY_NOTIFY 23
+
+
+
+/* Loopback Command Event */
+HCI_API extern void btsnd_hcie_loopback_command (void *buffer, UINT8 data_len, UINT8 *data);
+
+#define HCIE_PARAM_SIZE_LOOPBACK_COMMAND sizeof(btmsg_hcie_loopback_cmd_t)
+
+
+
+/* Data Buffer Overflow Event */
+HCI_API extern void btsnd_hcie_data_buf_overflow (void *buffer, UINT8 link_type);
+
+#define HCIE_PARAM_SIZE_DATA_BUF_OVERFLOW 1
+
+
+
+/* Max Slots Change Event */
+HCI_API extern void btsnd_hcie_max_slots_change(void *buffer, UINT16 handle, UINT8 max_slots);
+
+#define HCIE_PARAM_SIZE_MAX_SLOTS_CHANGE 3
+
+
+/* Read Clock Offset Complet Event */
+HCI_API extern void btsnd_hcie_read_clock_off_comp(void *buffer, UINT8 status, UINT16 handle,
+ UINT16 clock_offset);
+
+#define HCIE_PARAM_SIZE_READ_CLOCK_OFF_COMP 5
+
+
+
+/* Connection Packet Type Change Event */
+HCI_API extern void btsnd_hcie_pkt_type_change (void *buffer, UINT8 status, UINT16 handle, UINT16 pkt_type);
+
+#define HCIE_PARAM_SIZE_PKT_TYPE_CHANGE 5
+
+
+
+/* QOS violation Event */
+HCI_API extern void btsnd_hcie_qos_violation (void *buffer, UINT16 handle);
+
+#define HCIE_PARAM_SIZE_QOS_VIOLATION 2
+
+
+
+/* Page Scan Mode Change Event */
+HCI_API extern void btsnd_hcie_pagescan_mode_chng (void *buffer, BD_ADDR bd_addr, UINT8 mode);
+
+#define HCIE_PARAM_SIZE_PAGE_SCAN_MODE_CHNG 7
+
+
+/* Page Scan Repetition Mode Change Event */
+HCI_API extern void btsnd_hcie_pagescan_rep_mode_chng (void *buffer, BD_ADDR bd_addr, UINT8 mode);
+
+#define HCIE_PARAM_SIZE_PAGE_SCAN_REP_MODE_CHNG 7
+
+
+/* Sniff Sub Rate Event */
+HCI_API extern void btsnd_hcie_sniff_sub_rate(void *buffer, UINT8 status, UINT16 handle, UINT16 max_tx_lat, UINT16 max_rx_lat,
+ UINT16 min_remote_timeout, UINT16 min_local_timeout);
+
+#define HCIE_PARAM_SIZE_SNIFF_SUB_RATE 11
+
+
+
+/* Extended Inquiry Result Event */
+HCI_API extern void btsnd_hcie_ext_inquiry_result(void *buffer, UINT8 num_resp, UINT8 **bd_addr,
+ UINT8 *page_scan_rep_mode, UINT8 *reserved,
+ UINT8 **dev_class, UINT16 *clock_offset, UINT8 *rssi, UINT8 *p_data);
+
+
+#if (BLE_INCLUDED == TRUE)
+/********************************************************************************
+** BLE Commands
+** Note: "local_controller_id" is for transport, not counted in HCI message size
+*********************************************************************************/
+#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
+#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_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
+
+/* ULP HCI command */
+HCI_API extern BOOLEAN btsnd_hcic_ble_reset(void);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_read_buffer_size (void);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_read_local_spt_feat (void);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_addr);
+
+HCI_API extern 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);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
+ UINT16 scan_int, UINT16 scan_win,
+ UINT8 addr_type, UINT8 scan_filter_policy);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate);
+
+HCI_API extern 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);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_create_conn_cancel (void);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_read_white_list_size (void);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_clear_white_list (void);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda);
+
+HCI_API extern 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);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE]);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_read_remote_feat ( UINT16 handle);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_encrypt (UINT8* key, UINT8 key_len, UINT8* plain_text, UINT8 pt_len, void *p_cmd_cplt_cback);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_start_enc ( UINT16 handle,
+ UINT8 rand[HCIC_BLE_RAND_DI_SIZE],
+ UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle);
+
+HCI_API extern BOOLEAN btsnd_hcic_ble_read_supported_states (void);
+
+
+#endif /* BLE_INCLUDED */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/stack/include/hiddefs.h b/stack/include/hiddefs.h
new file mode 100644
index 0000000..e29a4c4
--- /dev/null
+++ b/stack/include/hiddefs.h
@@ -0,0 +1,158 @@
+/******************************************************************************
+ *
+ * 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 "sdp_api.h"
+/*
+** 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_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.*/
+ tSDP_DISC_REC *p_sdp_layer_rec;
+} tHID_DEV_SDP_INFO;
+
+#endif
+
diff --git a/stack/include/hidh_api.h b/stack/include/hidh_api.h
new file mode 100644
index 0000000..4662630
--- /dev/null
+++ b/stack/include/hidh_api.h
@@ -0,0 +1,222 @@
+/******************************************************************************
+ *
+ * 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 "hiddefs.h"
+#include "sdp_api.h"
+
+/*****************************************************************************
+** 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
+
+
+/*****************************************************************************
+** 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,
+ 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
+**
+*******************************************************************************/
+HID_API 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
+**
+*******************************************************************************/
+HID_API 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
+**
+*******************************************************************************/
+HID_API extern tHID_STATUS HID_HostDeregister(void);
+
+/*******************************************************************************
+**
+** Function HID_HostAddDev
+**
+** Description This is called so HID-host may manage this device.
+**
+** Returns tHID_STATUS
+**
+*******************************************************************************/
+HID_API extern tHID_STATUS HID_HostAddDev (BD_ADDR addr, UINT16 attr_mask,
+ UINT8 *handle );
+
+/*******************************************************************************
+**
+** Function HID_HostRemoveDev
+**
+** Description This removes the device from list devices that host has to manage.
+**
+** Returns tHID_STATUS
+**
+*******************************************************************************/
+HID_API 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
+**
+*******************************************************************************/
+HID_API 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
+**
+*******************************************************************************/
+HID_API 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
+**
+*******************************************************************************/
+HID_API extern tHID_STATUS HID_HostCloseDev(UINT8 dev_handle );
+
+/*******************************************************************************
+** Function HID_HostInit
+**
+** Description This function initializes the control block and trace variable
+**
+** Returns void
+*******************************************************************************/
+HID_API extern void HID_HostInit(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
+*******************************************************************************/
+HID_API extern tHID_STATUS HID_HostSetSecurityLevel( char serv_name[], UINT8 sec_lvl );
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+HID_API extern UINT8 HID_HostSetTraceLevel (UINT8 new_level);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HIDH_API_H */
diff --git a/stack/include/l2c_api.h b/stack/include/l2c_api.h
new file mode 100644
index 0000000..618ea8d
--- /dev/null
+++ b/stack/include/l2c_api.h
@@ -0,0 +1,1185 @@
+/******************************************************************************
+ *
+ * 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 "bt_target.h"
+#include "l2cdefs.h"
+#include "hcidefs.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) */
+
+/* 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)
+
+#if (BLE_INCLUDED == TRUE)
+#define L2CAP_LE_INT_MIN 0x0006
+#define L2CAP_LE_INT_MAX 0x0C80
+#define L2CAP_LE_LATENCY_MAX 500
+#define L2CAP_LE_TIMEOUT_MIN 0x000a
+#define L2CAP_LE_TIMEOUT_MAX 0x0C80
+#define L2CAP_LE_TIMEOUT_DEFAULT 0x07D0
+#endif
+
+
+/*****************************************************************************
+** 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;
+
+/* 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;
+ UINT8 user_rx_pool_id;
+ UINT8 user_tx_pool_id;
+ UINT8 fcr_rx_pool_id;
+ UINT8 fcr_tx_pool_id;
+
+} 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
+
+/*******************************************************************************
+**
+** 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().
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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.
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API extern UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr,
+ tL2CAP_ERTM_INFO *p_ertm_info);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_DisconnectReq (UINT16 cid);
+
+/*******************************************************************************
+**
+** Function L2CA_DisconnectRsp
+**
+** Description Higher layers call this function to acknowledge the
+** disconnection of a channel.
+**
+** Returns void
+**
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+L2C_API extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data);
+
+/*******************************************************************************
+**
+** Function L2CA_Ping
+**
+** Description Higher layers call this function to send an echo request.
+**
+** Returns TRUE if echo request sent, else FALSE.
+**
+*******************************************************************************/
+L2C_API 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.
+**
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+L2C_API 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.
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API extern UINT8 L2CA_SetDesireRole (UINT8 new_role);
+
+/*******************************************************************************
+**
+** Function L2CA_LocalLoopbackReq
+**
+** Description This function sets up a CID for local loopback
+**
+** Returns CID of 0 if none.
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_SendTestSFrame (UINT16 cid, BOOLEAN rr_or_rej,
+ UINT8 back_track);
+
+/*******************************************************************************
+**
+** Function L2CA_SetTxPriority
+**
+** Description Sets the transmission priority for a channel. (FCR Mode)
+**
+** Returns TRUE if a valid channel, else FALSE
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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.
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function L2CA_GetChnlFcrMode
+**
+** Description Get the channel FCR mode
+**
+** Parameters: Local CID
+**
+** Return value: Channel mode
+**
+*******************************************************************************/
+L2C_API extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid);
+
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_UCDSetTxPriority ( BD_ADDR rem_bda, tL2CAP_CHNL_PRIORITY priority );
+
+
+/*******************************************************************************
+**
+** Fixed Channel callback prototypes
+**
+*******************************************************************************/
+
+/* Fixed channel connected and disconnected. Parameters are
+** BD Address of remote
+** TRUE if channel is connected, FALSE if disconnected
+** Reason for connection failure
+*/
+typedef void (tL2CA_FIXED_CHNL_CB) (BD_ADDR, BOOLEAN, UINT16);
+
+/* Signalling data received. Parameters are
+** BD Address of remote
+** Pointer to buffer with data
+*/
+typedef void (tL2CA_FIXED_DATA_CB) (BD_ADDR, BT_HDR *);
+
+/* 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;
+ tL2CAP_FCR_OPTS fixed_chnl_opts;
+
+ UINT16 default_idle_tout;
+} 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+** Return value: TRUE if connection started
+**
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT16 idle_tout);
+
+#endif /* (L2CAP_NUM_FIXED_CHNLS > 0) */
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+L2C_API 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);
+
+#if (L2CAP_CORRUPT_ERTM_PKTS == TRUE)
+/*******************************************************************************
+**
+** Function L2CA_SetupErtmTest
+**
+** Description This function is used for testing purposes only.
+** It corrupts or drops one or more packets used with ERTM channels.
+**
+** Parameters
+** cid - channel ID (0 uses RFCOMM PSM's CID)
+**
+** type - type of test to run (L2CAP_FCR_TTYPE_CORR_IFRAMES
+** L2CAP_FCR_TTYPE_CORR_SFRAME
+** L2CAP_FCR_TTYPE_STOP_TEST
+** L2CAP_FCR_TTYPE_GET_CID - returns rfcomm cid only)
+**
+** is_rx - TRUE to corrupt Rx packet, FALSE for Tx packet)
+**
+** freq - L2CAP_FCR_FREQ_RANDOM (turns on random corruptions/drops)
+** L2CAP_FCR_FREQ_NORMAL (turns on test with "count" corruptions/drops)
+**
+** count - number of packets in a row to drop or corrupt
+**
+** Returns CID of channel running test
+**
+*******************************************************************************/
+L2C_API extern UINT16 L2CA_SetupErtmTest (UINT16 cid, UINT8 type, BOOLEAN is_rx, UINT8 freq, UINT16 count);
+
+/*******************************************************************************
+**
+** Function L2CA_SendPolledSFrame
+**
+** Description This function is used for testing purposes only.
+** It Sends a Polled RR or RNR to the peer
+**
+** Parameters
+** cid - channel ID
+**
+** sup_type - (L2CAP_FCR_SUP_RR or L2CAP_FCR_SUP_RNR)
+**
+** Returns void
+**
+*******************************************************************************/
+L2C_API extern void L2CA_SendPolledSFrame (UINT16 cid, UINT16 sup_type);
+
+/*******************************************************************************
+**
+** Function L2CA_BypassSFrame
+**
+** Description This function is used for testing purposes only.
+** It skips sending 'count' S-Frames.
+**
+** Parameters
+** cid - channel ID
+**
+** count - Number of S-Frames to skip sending
+**
+** Returns void
+**
+*******************************************************************************/
+L2C_API extern void L2CA_BypassSFrame (UINT16 cid, UINT8 count);
+
+#endif /* (L2CAP_CORRUPT_ERTM_PKTS == 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API 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
+**
+*******************************************************************************/
+L2C_API extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable);
+
+/*******************************************************************************
+**
+** Function L2CA_GetBleConnRole
+**
+** Description This function returns the connection role.
+**
+** Returns link role.
+**
+*******************************************************************************/
+L2C_API extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function L2CA_GetDisconnectReason
+**
+** Description This function returns the disconnect reason code.
+**
+** Returns disconnect reason
+**
+*******************************************************************************/
+L2C_API extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda);
+
+#endif /* (BLE_INCLUDED == TRUE) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* L2C_API_H */
diff --git a/stack/include/l2cdefs.h b/stack/include/l2cdefs.h
new file mode 100644
index 0000000..fe41476
--- /dev/null
+++ b/stack/include/l2cdefs.h
@@ -0,0 +1,309 @@
+/******************************************************************************
+ *
+ * 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 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 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 (0x0004-0x003E Reserved)
+*/
+#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_AMP_TEST_CID 0x003F
+#define L2CAP_BASE_APPL_CID 0x0040
+
+/* Fixed Channels mask bits
+*/
+#define L2CAP_FIXED_CHNL_SIG_BIT (1 << L2CAP_SIGNALLING_CID) /* Signal Channel Supported (Mandatory) */
+#define L2CAP_FIXED_CHNL_CNCTLESS_BIT (1 << L2CAP_CONNECTIONLESS_CID) /* Connectionless Reception */
+#define L2CAP_FIXED_CHNL_AMP_BIT (1 << L2CAP_AMP_CID) /* AMP Manager Supported */
+#define L2CAP_FIXED_CHNL_ATT_BIT (1 << L2CAP_ATT_CID) /* Attribute protocol Supported */
+#define L2CAP_FIXED_CHNL_BLE_SIG_BIT (1 << L2CAP_BLE_SIGNALLING_CID) /* BLE Signalling Supported */
+#define L2CAP_FIXED_CHNL_SMP_BIT (1 << L2CAP_SMP_CID) /* BLE Security Manager Supported */
+
+
+
+/* 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 locally supported features used in Information Response (default to none) */
+#ifndef L2CAP_EXTFEA_SUPPORTED_MASK
+#define L2CAP_EXTFEA_SUPPORTED_MASK 0
+#endif
+
+/* 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 pool */
+#define L2CAP_DEFAULT_ERM_POOL_ID 0xFF
+/* 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) */
+/* 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) */
+
+/*************************************************************************************************
+** The following definitions are only used for internal testing of ERTM at the application level
+*************************************************************************************************/
+/* L2CA_SetupErtmTest() corruption test types */
+#define L2CAP_FCR_TTYPE_CORR_IFRAME 0 /* Corrupt one or more I-frames, based on count */
+#define L2CAP_FCR_TTYPE_CORR_SFRAME 1 /* Corrupt an S-frame, (acknowledgement) */
+#define L2CAP_FCR_TTYPE_STOP_TEST 2 /* Used when turning off a test */
+#define L2CAP_FCR_TTYPE_GET_CID 3 /* Returns RFCOMM cid when '0' is passed in cid argument */
+
+/* L2CA_SetupErtmTest() Freq */
+#define L2CAP_FCR_FREQ_NORMAL 0 /* A single test is run */
+#define L2CAP_FCR_FREQ_RANDOM 1 /* Randomly loses or corrupts a packet */
+
+#endif
diff --git a/stack/include/mca_api.h b/stack/include/mca_api.h
new file mode 100644
index 0000000..d455e5b
--- /dev/null
+++ b/stack/include/mca_api.h
@@ -0,0 +1,495 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2009-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 Multi-Channel
+ * Adaptation Protocol (MCAP).
+ *
+ ******************************************************************************/
+#ifndef MCA_API_H
+#define MCA_API_H
+
+#include "bt_target.h"
+#include "l2c_api.h"
+
+/* move the following to bt_target.h or other place later */
+#define MCA_NUM_TC_TBL ((MCA_NUM_REGS)*(MCA_NUM_LINKS)*(MCA_NUM_MDLS+1))
+#define MCA_NUM_CCBS ((MCA_NUM_REGS)*(MCA_NUM_LINKS)) /* Number of control channel control blocks */
+#define MCA_NUM_DCBS ((MCA_NUM_REGS)*(MCA_NUM_LINKS)*(MCA_NUM_MDLS)) /* Number of data channel control blocks */
+
+
+/*****************************************************************************
+** constants
+*****************************************************************************/
+/* API function return value result codes. */
+#define MCA_SUCCESS 0 /* Function successful */
+#define MCA_BAD_PARAMS 1 /* Invalid parameters */
+#define MCA_NO_RESOURCES 2 /* Not enough resources */
+#define MCA_BAD_HANDLE 3 /* Bad handle */
+#define MCA_BUSY 4 /* A procedure is already in progress */
+#define MCA_WRITE_FAIL 5 /* Write failed */
+#define MCA_BAD_MDL_ID 6 /* MDL ID is not valid for the current API */
+typedef UINT8 tMCA_RESULT;
+
+/* MDEP data type. */
+#define MCA_TDEP_ECHO 0 /* MDEP for echo test */
+#define MCA_TDEP_DATA 1 /* MDEP for normal data */
+
+/* Control callback events. */
+#define MCA_ERROR_RSP_EVT 0 /* error response */
+#define MCA_CREATE_IND_EVT 1 /* create mdl indication */
+#define MCA_CREATE_CFM_EVT 2 /* create mdl confirm */
+#define MCA_RECONNECT_IND_EVT 3 /* reconnect mdl indication */
+#define MCA_RECONNECT_CFM_EVT 4 /* reconnect mdl confirm */
+#define MCA_ABORT_IND_EVT 5 /* abort mdl indication */
+#define MCA_ABORT_CFM_EVT 6 /* abort mdl confirm */
+#define MCA_DELETE_IND_EVT 7 /* delete mdl indication */
+#define MCA_DELETE_CFM_EVT 8 /* delete mdl confirm */
+
+#define MCA_SYNC_CAP_IND_EVT 0x11 /* request sync capabilities & requirements */
+#define MCA_SYNC_CAP_CFM_EVT 0x12 /* indicate completion */
+#define MCA_SYNC_SET_IND_EVT 0x13 /* request to set the time-stamp clock */
+#define MCA_SYNC_SET_CFM_EVT 0x14 /* indicate completion */
+#define MCA_SYNC_INFO_IND_EVT 0x15 /* update of the actual time-stamp clock instant from the sync slave */
+
+#define MCA_CONNECT_IND_EVT 0x20 /* Control channel connected */
+#define MCA_DISCONNECT_IND_EVT 0x21 /* Control channel disconnected */
+#define MCA_OPEN_IND_EVT 0x22 /* Data channel open indication */
+#define MCA_OPEN_CFM_EVT 0x23 /* Data channel open confirm */
+#define MCA_CLOSE_IND_EVT 0x24 /* Data channel close indication */
+#define MCA_CLOSE_CFM_EVT 0x25 /* Data channel close confirm */
+#define MCA_CONG_CHG_EVT 0x26 /* congestion change event */
+#define MCA_RSP_TOUT_IND_EVT 0x27 /* Control channel message response timeout */
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+typedef UINT8 tMCA_HANDLE; /* the handle for registration. 1 based index to rcb */
+typedef UINT8 tMCA_CL; /* the handle for a control channel; reported at MCA_CONNECT_IND_EVT */
+typedef UINT8 tMCA_DEP; /* the handle for MCA_CreateDep. This is also the local mdep_id */
+typedef UINT16 tMCA_DL; /* the handle for the data channel. This is reported at MCA_OPEN_CFM_EVT or MCA_OPEN_IND_EVT */
+
+/* This is the data callback function. It is executed when MCAP has a data
+** packet ready for the application.
+*/
+typedef void (tMCA_DATA_CBACK)(tMCA_DL mdl, BT_HDR *p_pkt);
+
+
+/* This structure contains parameters which are set at registration. */
+typedef struct {
+ UINT32 rsp_tout; /* MCAP signaling response timeout */
+ UINT16 ctrl_psm; /* L2CAP PSM for the MCAP control channel */
+ UINT16 data_psm; /* L2CAP PSM for the MCAP data channel */
+ UINT16 sec_mask; /* Security mask for BTM_SetSecurityLevel() */
+} tMCA_REG;
+
+/* This structure contains parameters to create a MDEP. */
+typedef struct {
+ UINT8 type; /* MCA_TDEP_DATA, or MCA_TDEP_ECHO. a regiatration may have only one MCA_TDEP_ECHO MDEP */
+ UINT8 max_mdl; /* The maximum number of MDLs for this MDEP (max is MCA_NUM_MDLS) */
+ tMCA_DATA_CBACK *p_data_cback; /* Data callback function */
+} tMCA_CS;
+
+#define MCA_FCS_NONE 0 /* fcs_present=FALSE */
+#define MCA_FCS_BYPASS 0x10 /* fcs_present=TRUE, fcs=L2CAP_CFG_FCS_BYPASS */
+#define MCA_FCS_USE 0x11 /* fcs_present=TRUE, fcs=L2CAP_CFG_FCS_USE */
+#define MCA_FCS_PRESNT_MASK 0x10 /* fcs_present=TRUE */
+#define MCA_FCS_USE_MASK 0x01 /* mask for fcs */
+typedef UINT8 tMCA_FCS_OPT;
+
+/* This structure contains L2CAP configuration parameters for the channel. */
+typedef struct {
+ tL2CAP_FCR_OPTS fcr_opt;
+ UINT8 user_rx_pool_id;
+ UINT8 user_tx_pool_id;
+ UINT8 fcr_rx_pool_id;
+ UINT8 fcr_tx_pool_id;
+ tMCA_FCS_OPT fcs;
+ UINT16 data_mtu; /* L2CAP MTU of the MCAP data channel */
+} tMCA_CHNL_CFG;
+
+
+/* Header structure for callback event parameters. */
+typedef struct {
+ UINT16 mdl_id; /* The associated MDL ID */
+ UINT8 op_code; /* The op (request/response) code */
+} tMCA_EVT_HDR;
+
+/* Response Header structure for callback event parameters. */
+typedef struct {
+ UINT16 mdl_id; /* The associated MDL ID */
+ UINT8 op_code; /* The op (request/response) code */
+ UINT8 rsp_code; /* The response code */
+} tMCA_RSP_EVT;
+
+/* This data structure is associated with the MCA_CREATE_IND_EVT. */
+typedef struct {
+ UINT16 mdl_id; /* The associated MDL ID */
+ UINT8 op_code; /* The op (request/response) code */
+ UINT8 dep_id; /* MDEP ID */
+ UINT8 cfg; /* The configuration to negotiate */
+} tMCA_CREATE_IND;
+
+/* This data structure is associated with the MCA_CREATE_CFM_EVT. */
+typedef struct {
+ UINT16 mdl_id; /* The associated MDL ID */
+ UINT8 op_code; /* The op (request/response) code */
+ UINT8 rsp_code; /* The response code. */
+ UINT8 cfg; /* The configuration to negotiate */
+} tMCA_CREATE_CFM;
+
+/* This data structure is associated with MCA_CONNECT_IND_EVT. */
+typedef struct {
+ BD_ADDR bd_addr; /* The peer address */
+ UINT16 mtu; /* peer mtu */
+} tMCA_CONNECT_IND;
+
+/* This data structure is associated with MCA_DISCONNECT_IND_EVT. */
+typedef struct {
+ BD_ADDR bd_addr; /* The peer address */
+ UINT16 reason; /* disconnect reason given by L2CAP */
+} tMCA_DISCONNECT_IND;
+
+/* This data structure is associated with MCA_OPEN_IND_EVT, and MCA_OPEN_CFM_EVT. */
+typedef struct {
+ UINT16 mdl_id; /* The associated MDL ID */
+ tMCA_DL mdl; /* The handle for the data channel */
+ UINT16 mtu; /* peer mtu */
+} tMCA_DL_OPEN;
+
+/* This data structure is associated with MCA_CLOSE_IND_EVT and MCA_CLOSE_CFM_EVT. */
+typedef struct {
+ UINT16 mdl_id; /* The associated MDL ID */
+ tMCA_DL mdl; /* The handle for the data channel */
+ UINT16 reason; /* disconnect reason given by L2CAP */
+} tMCA_DL_CLOSE;
+
+/* This data structure is associated with MCA_CONG_CHG_EVT. */
+typedef struct {
+ UINT16 mdl_id; /* N/A - This is a place holder */
+ tMCA_DL mdl; /* The handle for the data channel */
+ BOOLEAN cong; /* TRUE, if the channel is congested */
+} tMCA_CONG_CHG;
+
+/* Union of all control callback event data structures */
+typedef union {
+ tMCA_EVT_HDR hdr;
+ tMCA_RSP_EVT rsp;
+ tMCA_CREATE_IND create_ind;
+ tMCA_CREATE_CFM create_cfm;
+ tMCA_EVT_HDR reconnect_ind;
+ tMCA_RSP_EVT reconnect_cfm;
+ tMCA_EVT_HDR abort_ind;
+ tMCA_RSP_EVT abort_cfm;
+ tMCA_EVT_HDR delete_ind;
+ tMCA_RSP_EVT delete_cfm;
+ tMCA_CONNECT_IND connect_ind;
+ tMCA_DISCONNECT_IND disconnect_ind;
+ tMCA_DL_OPEN open_ind;
+ tMCA_DL_OPEN open_cfm;
+ tMCA_DL_CLOSE close_ind;
+ tMCA_DL_CLOSE close_cfm;
+ tMCA_CONG_CHG cong_chg;
+} tMCA_CTRL;
+
+/* This is the control callback function. This function passes control events
+** to the application.
+*/
+typedef void (tMCA_CTRL_CBACK)(tMCA_HANDLE handle, tMCA_CL mcl, UINT8 event,
+ tMCA_CTRL *p_data);
+
+
+/*******************************************************************************
+**
+** Function MCA_Init
+**
+** Description Initialize MCAP internal control blocks.
+** This function is called at stack start up.
+**
+** Returns void
+**
+*******************************************************************************/
+MCA_API extern void MCA_Init(void);
+
+/*******************************************************************************
+**
+** Function MCA_SetTraceLevel
+**
+** Description This function sets the debug trace level for MCA.
+** If 0xff is passed, the current trace level is returned.
+**
+** Input Parameters:
+** level: The level to set the MCA 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.
+**
+*******************************************************************************/
+MCA_API extern UINT8 MCA_SetTraceLevel (UINT8 level);
+
+/*******************************************************************************
+**
+** Function MCA_Register
+**
+** Description This function registers an MCAP implementation.
+** It is assumed that the control channel PSM and data channel
+** PSM are not used by any other instances of the stack.
+** If the given p_reg->ctrl_psm is 0, this handle is INT only.
+**
+** Returns 0, if failed. Otherwise, the MCA handle.
+**
+*******************************************************************************/
+MCA_API extern tMCA_HANDLE MCA_Register(tMCA_REG *p_reg, tMCA_CTRL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function MCA_Deregister
+**
+** Description This function is called to deregister an MCAP implementation.
+** Before this function can be called, all control and data
+** channels must be removed with MCA_DisconnectReq and MCA_CloseReq.
+**
+** Returns void
+**
+*******************************************************************************/
+MCA_API extern void MCA_Deregister(tMCA_HANDLE handle);
+
+/*******************************************************************************
+**
+** Function MCA_CreateDep
+**
+** Description Create a data endpoint. If the MDEP is created successfully,
+** the MDEP ID is returned in *p_dep. After a data endpoint is
+** created, an application can initiate a connection between this
+** endpoint and an endpoint on a peer device.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_CreateDep(tMCA_HANDLE handle, tMCA_DEP *p_dep, tMCA_CS *p_cs);
+
+/*******************************************************************************
+**
+** Function MCA_DeleteDep
+**
+** Description Delete a data endpoint. This function is called when
+** the implementation is no longer using a data endpoint.
+** If this function is called when the endpoint is connected
+** the connection is closed and the data endpoint
+** is removed.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_DeleteDep(tMCA_HANDLE handle, tMCA_DEP dep);
+
+/*******************************************************************************
+**
+** Function MCA_ConnectReq
+**
+** Description This function initiates an MCAP control channel connection
+** to the peer device. When the connection is completed, an
+** MCA_CONNECT_IND_EVT is reported to the application via its
+** control callback function.
+** This control channel is identified by tMCA_CL.
+** If the connection attempt fails, an MCA_DISCONNECT_IND_EVT is
+** reported. The security mask parameter overrides the outgoing
+** security mask set in MCA_Register().
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_ConnectReq(tMCA_HANDLE handle, BD_ADDR bd_addr,
+ UINT16 ctrl_psm,
+ UINT16 sec_mask);
+
+/*******************************************************************************
+**
+** Function MCA_DisconnectReq
+**
+** Description This function disconnect an MCAP control channel
+** to the peer device.
+** If associated data channel exists, they are disconnected.
+** When the MCL is disconnected an MCA_DISCONNECT_IND_EVT is
+** reported to the application via its control callback function.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_DisconnectReq(tMCA_CL mcl);
+
+/*******************************************************************************
+**
+** Function MCA_CreateMdl
+**
+** Description This function sends a CREATE_MDL request to the peer device.
+** When the response is received, a MCA_CREATE_CFM_EVT is reported
+** with the given MDL ID.
+** If the response is successful, a data channel is open
+** with the given p_chnl_cfg
+** When the data channel is open successfully, a MCA_OPEN_CFM_EVT
+** is reported. This data channel is identified as tMCA_DL.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_CreateMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm,
+ UINT16 mdl_id, UINT8 peer_dep_id,
+ UINT8 cfg, const tMCA_CHNL_CFG *p_chnl_cfg);
+
+/*******************************************************************************
+**
+** Function MCA_CreateMdlRsp
+**
+** Description This function sends a CREATE_MDL response to the peer device
+** in response to a received MCA_CREATE_IND_EVT.
+** If the rsp_code is successful, a data channel is open
+** with the given p_chnl_cfg
+** When the data channel is open successfully, a MCA_OPEN_IND_EVT
+** is reported. This data channel is identified as tMCA_DL.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_CreateMdlRsp(tMCA_CL mcl, tMCA_DEP dep,
+ UINT16 mdl_id, UINT8 cfg, UINT8 rsp_code,
+ const tMCA_CHNL_CFG *p_chnl_cfg);
+
+/*******************************************************************************
+**
+** Function MCA_CloseReq
+**
+** Description Close a data channel. When the channel is closed, an
+** MCA_CLOSE_CFM_EVT is sent to the application via the
+** control callback function for this handle.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_CloseReq(tMCA_DL mdl);
+
+/*******************************************************************************
+**
+** Function MCA_ReconnectMdl
+**
+** Description This function sends a RECONNECT_MDL request to the peer device.
+** When the response is received, a MCA_RECONNECT_CFM_EVT is reported.
+** If the response is successful, a data channel is open.
+** When the data channel is open successfully, a MCA_OPEN_CFM_EVT
+** is reported.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_ReconnectMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm,
+ UINT16 mdl_id, const tMCA_CHNL_CFG *p_chnl_cfg);
+
+/*******************************************************************************
+**
+** Function MCA_ReconnectMdlRsp
+**
+** Description This function sends a RECONNECT_MDL response to the peer device
+** in response to a MCA_RECONNECT_IND_EVT event.
+** If the response is successful, a data channel is open.
+** When the data channel is open successfully, a MCA_OPEN_IND_EVT
+** is reported.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_ReconnectMdlRsp(tMCA_CL mcl, tMCA_DEP dep,
+ UINT16 mdl_id, UINT8 rsp_code,
+ const tMCA_CHNL_CFG *p_chnl_cfg);
+
+/*******************************************************************************
+**
+** Function MCA_DataChnlCfg
+**
+** Description This function initiates a data channel connection toward the
+** connected peer device.
+** When the data channel is open successfully, a MCA_OPEN_CFM_EVT
+** is reported. This data channel is identified as tMCA_DL.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_DataChnlCfg(tMCA_CL mcl, const tMCA_CHNL_CFG *p_chnl_cfg);
+
+/*******************************************************************************
+**
+** Function MCA_Abort
+**
+** Description This function sends a ABORT_MDL request to the peer device.
+** When the response is received, a MCA_ABORT_CFM_EVT is reported.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_Abort(tMCA_CL mcl);
+
+/*******************************************************************************
+**
+** Function MCA_Delete
+**
+** Description This function sends a DELETE_MDL request to the peer device.
+** When the response is received, a MCA_DELETE_CFM_EVT is reported.
+**
+** Returns MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_Delete(tMCA_CL mcl, UINT16 mdl_id);
+
+/*******************************************************************************
+**
+** Function MCA_WriteReq
+**
+** Description Send a data packet to the peer device.
+**
+** The application passes the packet using the BT_HDR structure.
+** The offset field must be equal to or greater than L2CAP_MIN_OFFSET.
+** This allows enough space in the buffer for the L2CAP header.
+**
+** 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 MCA_SUCCESS if successful, otherwise error.
+**
+*******************************************************************************/
+MCA_API extern tMCA_RESULT MCA_WriteReq(tMCA_DL mdl, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function MCA_GetL2CapChannel
+**
+** Description Get the L2CAP CID used by the given data channel handle.
+**
+** Returns L2CAP channel ID if successful, otherwise 0.
+**
+*******************************************************************************/
+MCA_API extern UINT16 MCA_GetL2CapChannel (tMCA_DL mdl);
+
+#endif /* MCA_API_H */
diff --git a/stack/include/mca_defs.h b/stack/include/mca_defs.h
new file mode 100644
index 0000000..cca7fe0
--- /dev/null
+++ b/stack/include/mca_defs.h
@@ -0,0 +1,87 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2009-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 contains constants definitions and other information from the MCAP
+ * specification.
+ *
+ ******************************************************************************/
+#ifndef MCA_DEFS_H
+#define MCA_DEFS_H
+
+/*****************************************************************************
+** constants
+*****************************************************************************/
+#define MCA_MIN_MTU 48
+
+/* standard op codes */
+#define MCA_OP_ERROR_RSP 0x00 /* invalid opcode response */
+#define MCA_OP_MDL_CREATE_REQ 0x01 /* create an MDL, wait for an associated data channel connection */
+#define MCA_OP_MDL_CREATE_RSP 0x02 /* response to above request */
+#define MCA_OP_MDL_RECONNECT_REQ 0x03 /* req to prepare to rvc a data channel conn associated with a prev MDL */
+#define MCA_OP_MDL_RECONNECT_RSP 0x04 /* response to above request */
+#define MCA_OP_MDL_ABORT_REQ 0x05 /* stop waiting for a data channel connection */
+#define MCA_OP_MDL_ABORT_RSP 0x06 /* response to above request */
+#define MCA_OP_MDL_DELETE_REQ 0x07 /* delete an MDL */
+#define MCA_OP_MDL_DELETE_RSP 0x08 /* response to above request */
+#define MCA_NUM_STANDARD_OPCODE (1+MCA_OP_MDL_DELETE_RSP)
+
+/* clock synchronization op codes */
+#define MCA_OP_SYNC_CAP_REQ 0x11 /* request sync capabilities & requirements */
+#define MCA_OP_SYNC_CAP_RSP 0x12 /* indicate completion */
+#define MCA_OP_SYNC_SET_REQ 0x13 /* request to set the time-stamp clock */
+#define MCA_OP_SYNC_SET_RSP 0x14 /* indicate completion */
+#define MCA_OP_SYNC_INFO_IND 0x15 /* update of the actual time-stamp clock instant from the sync slave */
+
+#define MCA_FIRST_SYNC_OP MCA_OP_SYNC_CAP_REQ
+#define MCA_LAST_SYNC_OP MCA_OP_SYNC_INFO_IND
+
+/* response code */
+#define MCA_RSP_SUCCESS 0x00 /* The corresponding request was received and processed successfully. */
+#define MCA_RSP_BAD_OPCODE 0x01 /* The Op Code received is not valid (i.e. neither a Standard Op Code nor a Clock Synchronization Protocol Op Code). */
+#define MCA_RSP_BAD_PARAM 0x02 /* One or more of the values in the received request is invalid. */
+/* MCA_RSP_BAD_PARAM shall be used when:
+- The request length is invalid
+- Some of the parameters have invalid values and none of the other defined Response Codes are more appropriate.
+*/
+#define MCA_RSP_BAD_MDEP 0x03 /* The MDEP ID referenced does not exist on this device. */
+#define MCA_RSP_MDEP_BUSY 0x04 /* The requested MDEP currently has as many active MDLs as it can manage simultaneously. */
+#define MCA_RSP_BAD_MDL 0x05 /* The MDL ID referenced is invalid. */
+/* MCA_RSP_BAD_MDL shall be used when:
+- A reserved or invalid value for MDL ID was used.
+- The MDL ID referenced is not available (was never created, has been deleted, or was otherwise lost),
+- The MDL ID referenced in the Abort request is not the same value that was used to initiate the PENDING state
+*/
+#define MCA_RSP_MDL_BUSY 0x06 /* The device is temporarily unable to complete the request. This is intended for reasons not related to the physical sensor (e.g. communication resources unavailable). */
+#define MCA_RSP_BAD_OP 0x07 /* The received request is invalid in the current state. */
+/* MCA_RSP_BAD_OP is used when
+- Abort request was received while not in the PENDING state.
+- Create, Reconnect, or Delete request was received while in the PENDING state.
+- A response is received when a request is expected
+*/
+#define MCA_RSP_NO_RESOURCE 0x08 /* The device is temporarily unable to complete the request. This is intended for reasons relating to the physical sensor (e.g. hardware fault, low battery), or when processing resources are temporarily committed to other processes. */
+#define MCA_RSP_ERROR 0x09 /* An internal error other than those listed in this table was encountered while processing the request. */
+#define MCA_RSP_NO_SUPPORT 0x0A /* The Op Code that was used in this request is not supported. */
+#define MCA_RSP_CFG_REJ 0x0B /* A configuration required by a MD_CREATE_MDL or MD_RECONNECT_MDL operation has been rejected. */
+
+#define MCA_MAX_MDEP_ID 0x7F /* the valid range for MDEP ID is 1-0x7F */
+#define MCA_IS_VALID_MDL_ID(xxx) (((xxx)>0) && ((xxx)<=0xFEFF))
+#define MCA_ALL_MDL_ID 0xFFFF
+
+#endif /* MCA_DEFS_H */
diff --git a/stack/include/obx_api.h b/stack/include/obx_api.h
new file mode 100644
index 0000000..472eeb0
--- /dev/null
+++ b/stack/include/obx_api.h
@@ -0,0 +1,1704 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+#ifndef OBX_API_H
+#define OBX_API_H
+#include "bt_target.h"
+#include "bt_types.h"
+#include "l2c_api.h"
+
+/* 18 is 7/OBX_CONN_HDRS_OFFSET + 5/conn id, 2/ssn, 2/srm 2/srm_param */
+#define OBX_HDR_OFFSET (18 + L2CAP_MIN_OFFSET)
+#define OBX_MAX_TRIPLET 3
+
+#define OBX_MIN_MTU 255 /* per IrOBEX spec */
+#define OBX_MAX_MTU (OBX_LRG_DATA_POOL_SIZE - BT_HDR_SIZE - OBX_HDR_OFFSET)
+
+#define OBX_CONN_ID_SIZE 4
+#define OBX_PKT_LEN_SIZE 2
+
+#define OBX_CONN_HDRS_OFFSET 7
+#define OBX_SESS_HDRS_OFFSET 3
+#define OBX_DISCON_HDRS_OFFSET 3
+#define OBX_PUT_HDRS_OFFSET 3
+#define OBX_GET_HDRS_OFFSET 3
+#define OBX_SETPATH_REQ_HDRS_OFFSET 5
+#define OBX_ABORT_HDRS_OFFSET 3
+#define OBX_ACTION_HDRS_OFFSET 3
+#define OBX_RESPONSE_HDRS_OFFSET 3
+
+/* this is not needed if OBX_HDR_OFFSET is 18+ */
+#define OBX_MAX_CONN_HDR_EXTRA 8 /* 5/conn id, 2/ssn, 2/srm 2/srm_param - (5/setpath + 5/conn_id - 7/conn) */
+
+/* offset for header functions to access fields */
+#define OBX_CONNECT_MTU_OFFSET 5
+#define OBX_SETPATH_FLAG_OFFSET 3
+
+#define OBX_MAX_NUM_AUTH_TRIPLET 3
+#define OBX_UNICODE_SIZE 2 /* sizeof(UINT16) */
+
+#define OBX_INVALID_HDR_LEN 0xFFFF
+
+#define OBX_MIN_NONCE_SIZE 4 /* fixed size per IrOBEX spec */
+#define OBX_NONCE_SIZE 16 /* fixed size per IrOBEX spec */
+#define OBX_DIGEST_SIZE 16 /* fixed size per IrOBEX spec */
+#define OBX_MAX_AUTH_KEY_SIZE 16
+#define OBX_MAX_AUTH_USER_SIZE 20
+#define OBX_SESSION_ID_SIZE 16 /* fixed size per IrOBEX spec */
+#define OBX_SESSION_INFO_SIZE 32 /* OBX_SESSION_ID_SIZE + 4(local nonce) + 4 (connection id) + 4 (timeout) + 2(mtu) + 1(state) + 1(srm) */
+#define OBX_SESSION_INFO_NONCE_IDX 16 /* The index to the (local nonce) in session info */
+#define OBX_SESSION_INFO_ID_IDX 20 /* The index to the (connection id) in session info */
+#define OBX_SESSION_INFO_TO_IDX 24 /* The index to the (timeout) in session info */
+#define OBX_SESSION_INFO_MTU_IDX 28 /* The index to peer MTU in session info */
+#define OBX_SESSION_INFO_ST_IDX 30 /* The index to sr/cl state in session info */
+#define OBX_SESSION_INFO_SRM_IDX 31 /* The index to srm in session info */
+#define OBX_TIMEOUT_SIZE 4
+
+/* handle related definitions */
+#define OBX_SESS_SHIFT 8
+#define OBX_ENC_SESS_HANDLE(oh, os) (((os)<<OBX_SESS_SHIFT)|(oh))
+#define OBX_HANDLE_MASK 0xFF
+#define OBX_SESS_MASK 0x7F00
+#define OBX_DEC_HANDLE(os) ((os) & OBX_HANDLE_MASK)
+#define OBX_DEC_SESS_IND(os) ((os & OBX_SESS_MASK)>>OBX_SESS_SHIFT)
+
+/* Return values for API functions */
+enum
+{
+ OBX_SUCCESS, /* Status is successful. */
+ OBX_BAD_PARAMS, /* Bad parameter(s). */
+ OBX_NO_RESOURCES, /* No resources (GKI buffers, control block) */
+ OBX_BAD_HANDLE /* The OBEX handle is not valid. */
+};
+typedef UINT8 tOBX_STATUS;
+
+
+typedef UINT16 tOBX_HANDLE;
+
+#define OBX_HANDLE_NULL 0
+
+enum
+{
+ OBX_PT_PUT, /* Regular Put request */
+ OBX_PT_DELETE, /* Delete request - a Put request with NO Body or End-of-Body header. */
+ OBX_PT_CREATE /* Create-Empty request - a Put request with an empty End-of-Body header. */
+};
+typedef UINT8 tOBX_PUT_TYPE;
+
+/* SetPath Request Flags - the following definitions can be ORed if both flags are wanted */
+#define OBX_SPF_BACKUP 0x01 /* Backup a level before applying name(equivalent to ../) */
+#define OBX_SPF_NO_CREATE 0x02 /* Don't create directory if it does not exist, return an error instead. */
+typedef UINT8 tOBX_SETPATH_FLAG;
+
+/* Authentication Challenge Options */
+#define OBX_AO_NONE 0x00 /* If this is used in OBX_StartServer and the authenticate
+ * flag is TRUE, the optional Challenge Information (tag 0x01)
+ * will not be sent. */
+#define OBX_AO_USR_ID 0x01 /* Set this bit to make the client respond with the user ID. */
+typedef UINT8 tOBX_AUTH_OPT;
+
+/* CHARSET definition for Authentication Challenge Realm */
+#define OBX_RCS_ASCII 0x00 /* ASCII */
+#define OBX_RCS_8859_1 0x01 /* ISO-8859-1 */
+#define OBX_RCS_8859_2 0x02 /* ISO-8859-2 */
+#define OBX_RCS_8859_3 0x03 /* ISO-8859-3 */
+#define OBX_RCS_8859_4 0x04 /* ISO-8859-4 */
+#define OBX_RCS_8859_5 0x05 /* ISO-8859-5 */
+#define OBX_RCS_8859_6 0x06 /* ISO-8859-6 */
+#define OBX_RCS_8859_7 0x07 /* ISO-8859-7 */
+#define OBX_RCS_8859_8 0x08 /* ISO-8859-8 */
+#define OBX_RCS_8859_9 0x09 /* ISO-8859-9 */
+#define OBX_RCS_UNICODE 0xFF /* Unicode */
+typedef UINT8 tOBX_CHARSET;
+
+typedef struct
+{
+ UINT8 ssn; /* session sequence number */
+ BOOLEAN final; /* TRUE, if this is the final packet of this PUT transaction. */
+ tOBX_PUT_TYPE type; /* The type of PUT request. */
+} tOBX_PUT_EVT;
+
+typedef struct
+{
+ UINT8 ssn; /* session sequence number */
+ BOOLEAN final; /* TRUE, if this is the final packet of this GET transaction. */
+} tOBX_GET_EVT;
+
+typedef struct
+{
+ UINT8 ssn; /* session sequence number */
+ BD_ADDR peer_addr; /* The peer Bluetooth Address. */
+ UINT16 mtu; /* The peer MTU. This element is associated with OBX_CONNECT_REQ_EVT and OBX_CONNECT_RSP_EVT. */
+ tOBX_HANDLE handle; /* the OBX handle returned by OBX_StartServer(), OBX_CreateSession() and OBX_ConnectReq() */
+ BOOLEAN no_rsp; /* TRUE, when the event is generated as a part of RESUME SESSION */
+} tOBX_CONN_EVT;
+
+/* Session Opcode Definitions: */
+#define OBX_SESS_OP_CREATE 0x00 /* Create Session */
+#define OBX_SESS_OP_CLOSE 0x01 /* Close Session */
+#define OBX_SESS_OP_SUSPEND 0x02 /* Suspend Session */
+#define OBX_SESS_OP_RESUME 0x03 /* Resume Session */
+#define OBX_SESS_OP_SET_TIME 0x04 /* Set Timeout */
+#define OBX_SESS_OP_TRANSPORT 0xFF /* transport dropped */
+typedef UINT8 tOBX_SESS_OP;
+
+/* Session States Definitions for external use: */
+enum
+{
+ OBX_SESS_NONE, /* 0x00 session is not engaged/closed */
+ OBX_SESS_ACTIVE, /* 0x01 session is active. */
+ OBX_SESS_SUSPENDED, /* 0x02 session is suspended. */
+ OBX_SESS_EXT_MAX
+};
+typedef UINT8 tOBX_SESS_ST;
+
+
+typedef struct
+{
+ UINT8 ssn; /* session sequence number */
+ tOBX_SESS_OP sess_op; /* the session op code */
+ tOBX_SESS_ST sess_st; /* the session state */
+ BD_ADDR peer_addr; /* The peer Bluetooth Address. */
+ UINT8 *p_sess_info; /* The session ID and the local nonce for a reliable session, a reference to the location in OBEX control block or NULL */
+ UINT32 timeout; /* The number of seconds remaining in suspend. 0xffff if infinite. */
+ UINT32 obj_offset; /* The object offset for resume session. */
+ UINT8 nssn; /* tne next session sequence number the server expects */
+} tOBX_SESS_EVT;
+
+#define OBX_ACT_COPY 0x00 /* Copy object */
+#define OBX_ACT_MOVE 0x01 /* Move/rename object */
+#define OBX_ACT_PERMISSION 0x02 /* Set object permission */
+typedef UINT8 tOBX_ACTION;
+
+typedef struct
+{
+ UINT8 ssn; /* session sequence number */
+ tOBX_ACTION action; /* The action opcode. */
+} tOBX_ACT_EVT;
+
+typedef struct
+{
+ UINT8 ssn; /* session sequence number */
+ tOBX_SETPATH_FLAG flag; /* The set path flags. */
+} tOBX_SETPATH_EVT;
+
+/* permission flags */
+#define OBX_PERMISSION_READ 0x01
+#define OBX_PERMISSION_WRITE 0x02
+#define OBX_PERMISSION_DELETE 0x04
+#define OBX_PERMISSION_MODIFY 0x80
+
+typedef union
+{
+ UINT8 ssn; /* session sequence number */
+ tOBX_CONN_EVT conn; /* This element is associated with OBX_CONNECT_REQ_EVT and OBX_CONNECT_RSP_EVT. */
+ tOBX_SESS_EVT sess; /* This element is associated with OBX_SESSION_RSP_EVT and OBX_SESSION_REQ_EVT. */
+ tOBX_PUT_EVT put; /* This element is associated with OBX_PUT_REQ_EVT. */
+ tOBX_SETPATH_EVT sp; /* This element is associated with OBX_SETPATH_REQ_EVT. */
+ tOBX_ACT_EVT action; /* This element is associated with OBX_ACTION_REQ_EVT */
+ tOBX_GET_EVT get; /* This element is associated with OBX_GET_REQ_EVT. TRUE, if this is the final packet that contains the OBEX headers for this GET request. */
+} tOBX_EVT_PARAM;
+
+
+enum
+{
+ OBX_NULL_EVT,
+ /* server events */
+ OBX_CONNECT_REQ_EVT, /* param = packet MTU */
+ OBX_SESSION_REQ_EVT, /* A Crease Session or Resume Session request is received by the server. Call OBX_SessionRsp(). */
+ OBX_DISCONNECT_REQ_EVT,
+ OBX_PUT_REQ_EVT, /* could have param indicate delete or create? */
+ OBX_GET_REQ_EVT,
+ OBX_SETPATH_REQ_EVT, /* param = flags */
+ OBX_ABORT_REQ_EVT,
+ OBX_ACTION_REQ_EVT, /* An Action request is received by the server. Call OBX_ActionRsp(). */
+
+ /* client events */
+ OBX_CONNECT_RSP_EVT, /* param = packet MTU */
+ OBX_SESSION_RSP_EVT, /* A response for Create Session or Resume Session is received by the client. The client needs to remember the session id. The session id is to be used in calling OBX_ResumeSession, if the current session is terminated prematurely. */
+ OBX_DISCONNECT_RSP_EVT,
+ OBX_PUT_RSP_EVT,
+ OBX_GET_RSP_EVT,
+ OBX_SETPATH_RSP_EVT,
+ OBX_ABORT_RSP_EVT,
+ OBX_ACTION_RSP_EVT, /* An Action response is received by the client. */
+
+ /* common events */
+ OBX_SESSION_INFO_EVT, /* the session information event to resume the session. */
+ OBX_CLOSE_IND_EVT, /* when transport goes down; p_pkt = NULL; no response needed */
+ OBX_TIMEOUT_EVT, /* param = tOBX_EVENT */
+ OBX_PASSWORD_EVT
+};
+typedef UINT8 tOBX_EVENT;
+
+/* this is used by the protocol display function only*/
+enum
+{
+ OBX_NULL_DISP,
+ /* server events */
+ OBX_CONNECT_REQ_DISP,
+ OBX_SESSION_REQ_DISP,
+ OBX_DISCONNECT_REQ_DISP,
+ OBX_PUT_REQ_DISP,
+ OBX_GET_REQ_DISP,
+ OBX_SETPATH_REQ_DISP,
+ OBX_ABORT_REQ_DISP,
+ OBX_ACTION_REQ_DISP,
+ /* client events */
+ OBX_CONNECT_RSP_DISP,
+ OBX_SESSION_RSP_DISP,
+ OBX_DISCONNECT_RSP_DISP,
+ OBX_PUT_RSP_DISP,
+ OBX_GET_RSP_DISP,
+ OBX_SETPATH_RSP_DISP,
+ OBX_ABORT_RSP_DISP,
+ OBX_ACTION_RSP_DISP,
+ /* common events */
+ OBX_CLOSE_IND_DISP,
+ OBX_TIMEOUT_DISP,
+ OBX_PASSWORD_DISP
+};
+#define OBX_DISP_IS_RECV 0x80
+#define OBX_DISP_TYPE_MASK 0x7F
+
+#define OBX_MAX_EVT OBX_PASSWORD_EVT
+#define OBX_MAX_OFFSET_IND OBX_ABORT_RSP_EVT /* This is used to access obx_hdr_start_offset */
+
+/*
+** Define Miscellaneous Constants
+*/
+#define OBX_VERSION 0x10 /* Version 1.0 */
+#define OBX_CONN_FLAGS 0 /* Connect flags per IrOBEX spec */
+#define OBX_SETPATH_CONST 0 /* SetPath Request constants per IrOBEX spec */
+#define OBX_INVALID_CONN_ID 0xFFFFFFFF /* invalid connection ID per IrOBEX spec */
+#define OBX_INFINITE_TIMEOUT 0xFFFFFFFF
+
+/* Header Identifier Data Type Constants */
+#define OBX_HI_TYPE_MASK 0xC0 /* This mask get the encoding (data type) of the header ID. */
+#define OBX_HI_ID_MASK 0x3F /* This mask gets the meaning of the header ID. */
+#define OBX_HI_TYPE_UNIC 0x00 /* Null terminated Unicode text */
+#define OBX_HI_TYPE_ARRAY 0x40 /* Unstructured octet array (byte sequence) */
+#define OBX_HI_TYPE_BYTE 0x80 /* 8-bit integer */
+#define OBX_HI_TYPE_INT 0xC0 /* 32-bit integer */
+
+/*
+** Define OBEX Header Identifiers
+*/
+#define OBX_HI_NULL 0
+#define OBX_HI_COUNT 0xC0
+#define OBX_HI_NAME 0x01
+#define OBX_HI_TYPE 0x42
+#define OBX_HI_LENGTH 0xC3
+#define OBX_HI_TIME 0x44
+#define OBX_HI_DESCRIPTION 0x05
+#define OBX_HI_TARGET 0x46
+#define OBX_HI_HTTP 0x47
+#define OBX_HI_BODY 0x48
+#define OBX_HI_BODY_END 0x49
+#define OBX_HI_WHO 0x4A
+#define OBX_HI_CONN_ID 0xCB
+#define OBX_HI_APP_PARMS 0x4C
+#define OBX_HI_CHALLENGE 0x4D
+#define OBX_HI_AUTH_RSP 0x4E
+#define OBX_HI_CREATOR_ID 0xCF
+#define OBX_HI_WAN_UUID 0x50
+#define OBX_HI_OBJ_CLASS 0x51
+#define OBX_HI_SESSION_PARAM 0x52
+#define OBX_HI_SESSION_SN 0x93
+#define OBX_HI_ACTION_ID 0x94
+#define OBX_HI_DEST_NAME 0x15
+#define OBX_HI_PERMISSION 0xD6
+#define OBX_HI_SRM 0x97
+#define OBX_HI_SRM_PARAM 0x98
+#define OBX_HI_LO_USER 0x30
+#define OBX_HI_HI_USER 0x3F
+
+/* Obex Header Values for the SRM header */
+#define OBX_HV_SRM_DISABLE 0x00 /* SRM header value - disable */
+#define OBX_HV_SRM_ENABLE 0x01 /* SRM header value - enable */
+#define OBX_HV_SRM_IND 0x02 /* SRM header value - indicate support */
+
+/* Obex Header Values for the SRM Parameter header */
+#define OBX_HV_SRM_PARAM_MORE 0x00 /* SRM Param header value - request additional packet */
+#define OBX_HV_SRM_PARAM_WAIT 0x01 /* SRM Param header value - wait for next req/rsp */
+#define OBX_HV_SRM_PARAM_COMBO 0x02 /* SRM Param header value - next and wait */
+
+#define OBX_TAG_SESS_PARAM_ADDR 0x00
+#define OBX_TAG_SESS_PARAM_NONCE 0x01
+#define OBX_TAG_SESS_PARAM_SESS_ID 0x02
+#define OBX_TAG_SESS_PARAM_NSEQNUM 0x03
+#define OBX_TAG_SESS_PARAM_TOUT 0x04
+#define OBX_TAG_SESS_PARAM_SESS_OP 0x05
+#define OBX_TAG_SESS_PARAM_OBJ_OFF 0x06
+#define OBX_MAX_SESS_PARAM_TRIP 7 /* max number of TLV for session operations */
+
+#define OBX_LEN_SESS_PARAM_SESS_OP 1
+#define OBX_LEN_SESS_PARAM_OBJ_OFF 4 /* this value varies, so it needs to be verified on the receiving side */
+
+/*
+** Define OBEX Request Codes
+*/
+#define OBX_REQ_CONNECT 0x00 /* need to set final bit */
+#define OBX_REQ_DISCONNECT 0x01 /* need to set final bit */
+#define OBX_REQ_PUT 0x02
+#define OBX_REQ_GET 0x03
+#define OBX_REQ_SETPATH 0x05 /* need to set final bit */
+#define OBX_REQ_ACTION 0x06
+#define OBX_REQ_SESSION 0x07 /* need to set final bit */
+#define OBX_REQ_ABORT 0x7F /* need to set final bit */
+#define OBX_FINAL 0x80
+
+/* OBEX response code as defined in IrOBEX spec. version 1.2 */
+#define OBX_RSP_DEFAULT 0x00
+#define OBX_RSP_FAILED 0x08 /* OBEX failed - not from spec */
+#define OBX_RSP_CONTINUE 0x10 /* Continue */
+#define OBX_RSP_OK 0x20 /* OK, Success */
+#define OBX_RSP_CREATED 0x21 /* Created */
+#define OBX_RSP_ACCEPTED 0x22 /* Accepted */
+#define OBX_RSP_NON_AUTH_INFO 0x23 /* Non-Authoritative Information */
+#define OBX_RSP_NO_CONTENT 0x24 /* No Content */
+#define OBX_RSP_RESET_CONTENT 0x25 /* Reset Content */
+#define OBX_RSP_PART_CONTENT 0x26 /* Partial Content */
+#define OBX_RSP_MULTI_CHOICES 0x30 /* Multiple Choices */
+#define OBX_RSP_MVD_PERM 0x31 /* Moved Permanently */
+#define OBX_RSP_MVD_TEMP 0x32 /* Moved temporarily */
+#define OBX_RSP_SEE_OTHER 0x33 /* See Other */
+#define OBX_RSP_NOT_MODIFIED 0x34 /* Not modified */
+#define OBX_RSP_USE_PROXY 0x35 /* Use Proxy */
+#define OBX_RSP_BAD_REQUEST 0x40 /* Bad Request - server couldn't understand request */
+#define OBX_RSP_UNAUTHORIZED 0x41 /* Unauthorized */
+#define OBX_RSP_PAYMENT_REQD 0x42 /* Payment required */
+#define OBX_RSP_FORBIDDEN 0x43 /* Forbidden - operation is understood but refused */
+#define OBX_RSP_NOT_FOUND 0x44 /* Not Found */
+#define OBX_RSP_NOT_ALLOWED 0x45 /* Method not allowed */
+#define OBX_RSP_NOT_ACCEPTABLE 0x46 /* Not Acceptable */
+#define OBX_RSP_PROXY_AUTH_REQD 0x47 /* Proxy Authentication required */
+#define OBX_RSP_REQUEST_TIMEOUT 0x48 /* Request Time Out */
+#define OBX_RSP_CONFLICT 0x49 /* Conflict */
+#define OBX_RSP_GONE 0x4A /* Gone */
+#define OBX_RSP_LENGTH_REQD 0x4B /* Length Required */
+#define OBX_RSP_PRECONDTN_FAILED 0x4C /* Precondition failed */
+#define OBX_RSP_REQ_ENT_2_LARGE 0x4D /* Requested entity too large */
+#define OBX_RSP_REQ_URL_2_LARGE 0x4E /* Request URL too large */
+#define OBX_RSP_UNSUPTD_TYPE 0x4F /* Unsupported media type */
+#define OBX_RSP_INTRNL_SRVR_ERR 0x50 /* Internal Server Error */
+#define OBX_RSP_NOT_IMPLEMENTED 0x51 /* Not Implemented */
+#define OBX_RSP_BAD_GATEWAY 0x52 /* Bad Gateway */
+#define OBX_RSP_SERVICE_UNAVL 0x53 /* Service Unavailable */
+#define OBX_RSP_GATEWAY_TIMEOUT 0x54 /* Gateway Timeout */
+#define OBX_RSP_HTTP_VER_NOT_SUPTD 0x55 /* HTTP version not supported */
+#define OBX_RSP_DATABASE_FULL 0x60 /* Database Full */
+#define OBX_RSP_DATABASE_LOCKED 0x61 /* Database Locked */
+
+#define OBX_MAX_OK_RSP OBX_RSP_PART_CONTENT
+
+typedef UINT8 tOBX_RSP_CODE;
+
+/* tags for authentication triplet */
+#define OBX_NONCE_CHLNG_TAG 0
+#define OBX_OPTIONS_CHLNG_TAG 1
+#define OBX_REALM_CHLNG_TAG 2
+
+#define OBX_DIGEST_RSP_TAG 0
+#define OBX_USERID_RSP_TAG 1
+#define OBX_NONCE_RSP_TAG 2
+
+typedef struct
+{
+ UINT8 tag;
+ UINT8 len;
+ UINT8 *p_array;
+} tOBX_TRIPLET;
+
+/* Server Callback type: */
+typedef void (tOBX_SR_CBACK) (tOBX_HANDLE shandle, tOBX_EVENT event, tOBX_EVT_PARAM param, BT_HDR *p_pkt);
+/* Client Callback type: */
+typedef void (tOBX_CL_CBACK) (tOBX_HANDLE handle, tOBX_EVENT event, UINT8 rsp_code, tOBX_EVT_PARAM param, BT_HDR *p_pkt);
+
+
+typedef struct
+{
+ UINT16 len; /* Length of target header. */
+ UINT8 target[OBX_MAX_TARGET_LEN]; /* The byte sequence that describes the target header. */
+} tOBX_TARGET;
+
+
+typedef struct
+{
+ tOBX_TARGET *p_target;
+ tOBX_SR_CBACK *p_cback;
+ UINT16 mtu;
+ UINT8 scn; /* The RFCOMM SCN number that this server listens for incoming requests. 0, if do not wish to listen to connection from RFCOMM. */
+ BOOLEAN authenticate;
+ UINT8 auth_option;
+ UINT8 realm_charset;
+ UINT8 *p_realm;
+ UINT8 realm_len;
+ UINT8 max_sessions;
+ BOOLEAN get_nonf; /* report GET non-final request event. If FALSE, GET response is sent automatically */
+ UINT16 psm; /* The L2CAP PSM number that this server listens for incoming requests. 0, if do not wish to listen to connection from L2CAP. */
+ UINT32 nonce; /* This is converted to UINT8[16] internally before adding to the OBEX header. This value is copied to the server control block and is increased after each use. 0, if only legacy OBEX (unreliable) session is desired. */
+ BOOLEAN srm; /* TRUE, to support single response mode. */
+ UINT8 max_suspend; /* Max number of suspended session. must be less than OBX_MAX_SUSPEND_SESSIONS. ignored, if nonce is 0 */
+} tOBX_StartParams;
+
+
+
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function OBX_Init
+**
+** Description This function is called to initialize the control block for this
+** layer. It must be called before accessing any other of its API
+** functions. It is typically called once during the start up of
+** the stack.
+**
+** Returns void.
+**
+*******************************************************************************/
+OBX_API extern void OBX_Init(void);
+
+/*******************************************************************************
+**
+** Function OBX_SetTraceLevel
+**
+** Description This function sets the debug trace level for OBX.
+** If 0xff is passed, the current trace level is returned.
+**
+** Input Parameters:
+** level: The level to set the OBX 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.
+**
+*******************************************************************************/
+OBX_API extern UINT8 OBX_SetTraceLevel (UINT8 level);
+
+/*******************************************************************************
+** Function OBX_HandleToMtu
+**
+** Description Given an OBEX handle, return the associated peer MTU.
+**
+** Returns MTU.
+**
+*******************************************************************************/
+OBX_API extern UINT16 OBX_HandleToMtu(tOBX_HANDLE handle);
+
+/* Server API's: */
+/*******************************************************************************
+**
+** Function OBX_StartServer
+**
+** Description This function is to register a server entity to OBEX.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_NO_RESOURCES, if OBX does not have resources.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_StartServer(tOBX_StartParams *p_params, tOBX_HANDLE *p_handle);
+
+/*******************************************************************************
+**
+** Function OBX_StopServer
+**
+** Description This function is to stop this OBEX server from receiving any
+** more incoming requests.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_StopServer(tOBX_HANDLE handle);
+
+/*******************************************************************************
+**
+** Function OBX_AddSuspendedSession
+**
+** Description This function is to add the session information for a previously
+** suspended reliable session to the server control block
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_AddSuspendedSession(tOBX_HANDLE shandle, BD_ADDR peer_addr, UINT8 *p_sess_info,
+ UINT32 timeout, UINT8 ssn, UINT32 offset);
+
+/*******************************************************************************
+**
+** Function OBX_ConnectRsp
+**
+** Description This function is called to send the response to a Connect
+** Request from an OBEX client.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_ConnectRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_SessionRsp
+**
+** Description This function is called to respond to a request to create a reliable session.
+**
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_SessionRsp(tOBX_HANDLE shandle, UINT8 rsp_code,
+ UINT8 ssn, UINT32 offset, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_SetPathRsp
+**
+** Description This function is called to send the response to a Set Path
+** Request from an OBEX client.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_SetPathRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_PutRsp
+**
+** Description This function is called to send the response to a Put
+** Request from an OBEX client.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_PutRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_GetRsp
+**
+** Description This function is called to send the response to a Get
+** Request from an OBEX client.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_GetRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_AbortRsp
+**
+** Description This function is called to send the response to an Abort
+** Request from an OBEX client.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_AbortRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_ActionRsp
+**
+** Description This function is called to respond to an Action command Request
+** from an OBEX client.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_ActionRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_DisconnectRsp
+**
+** Description This function is called to send the response to a Disconnect
+** Request from an OBEX client.
+** This function can also be used to force close the transport
+** to a connected client.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_DisconnectRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_Password
+**
+** Description This function is called to respond to an OBX_PASSWORD_EVT event.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_NO_RESOURCES, if OBX does not resources
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_Password(tOBX_HANDLE shandle, UINT8 *p_password, UINT8 password_len,
+ UINT8 *p_userid, UINT8 userid_len);
+
+/*******************************************************************************
+**
+** Function OBX_GetPeerAddr
+**
+** Description This function is called to learn the Bluetooth address of the
+** connected device.
+**
+** Returns L2CAP channel ID.
+**
+*******************************************************************************/
+OBX_API extern UINT16 OBX_GetPeerAddr(tOBX_HANDLE shandle, BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function OBX_GetPortHandle
+**
+** Description This function is called to get the RFCOMM port handle for the obex connection.
+**
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_NO_RESOURCES, if no existing connection.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_GetPortHandle(tOBX_HANDLE handle, UINT16 *port_handle);
+
+/* Client API's: */
+/*******************************************************************************
+**
+** Function OBX_ConnectReq
+**
+** Description This function registers a client entity to OBEX and sends a
+** CONNECT request to the server specified by the API parameters.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_NO_RESOURCES, if OBX does not resources
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_ConnectReq(BD_ADDR bd_addr, UINT8 scn, UINT16 mtu,
+ tOBX_CL_CBACK *p_cback, tOBX_HANDLE *p_handle, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_AllocSession
+**
+** Description This function registers a client entity to OBEX.
+** If p_session_id is not NULL, it tries to find an suspended session
+** with matching session_id.
+** If scn is not 0, it allocates a control block for this new session.
+** Otherwise, it allocates a control block for the given PSM.
+** The associated virtual PSM assigned by L2CAP is returned in p_psm
+** The allocated OBEX handle is returned in p_handle.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_NO_RESOURCES, if OBX does not resources
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_AllocSession (UINT8 *p_session_info, UINT8 scn, UINT16 *p_psm,
+ tOBX_CL_CBACK *p_cback, tOBX_HANDLE *p_handle);
+
+/*******************************************************************************
+**
+** Function OBX_CreateSession
+**
+** Description This function registers a client entity to OBEX.
+** It may send a CreateSession request and wait for CreateSession response.
+** It sends a CONNECT request to the server specified by the API parameters.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_NO_RESOURCES, if OBX does not resources
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_CreateSession (BD_ADDR bd_addr, UINT16 mtu, BOOLEAN srm, UINT32 nonce,
+ tOBX_HANDLE handle, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_ResumeSession
+**
+** Description This function registers a client entity to OBEX and resumes
+** a previously interrupted reliable session.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_NO_RESOURCES, if OBX does not resources
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_ResumeSession (BD_ADDR bd_addr, UINT8 ssn, UINT32 offset, tOBX_HANDLE handle);
+
+/*******************************************************************************
+**
+** Function OBX_SessionReq
+**
+** Description This function is used to Suspend, Resume, or Close a session.
+** For Resume: this function registers a client entity to OBEX and resumes
+** a previously interrupted reliable session.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_NO_RESOURCES, if OBX does not resources
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_SessionReq (tOBX_HANDLE handle, tOBX_SESS_OP opcode, UINT32 timeout);
+
+/*******************************************************************************
+**
+** Function OBX_SetPathReq
+**
+** Description This function sends a Set Path request to the connected server.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_SetPathReq(tOBX_HANDLE handle, UINT8 flags, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_PutReq
+**
+** Description This function sends a Put request to the connected server.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_PutReq(tOBX_HANDLE handle, BOOLEAN final, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_GetReq
+**
+** Description This function sends a Get request to the connected server.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_GetReq(tOBX_HANDLE handle, BOOLEAN final, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_AbortReq
+**
+** Description This function sends an Abort request to the connected server.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_AbortReq(tOBX_HANDLE handle, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_DisconnectReq
+**
+** Description This function sends a Disconnect request to the connected server.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_DisconnectReq(tOBX_HANDLE handle, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_ActionReq
+**
+** Description This function sends a Action request to the connected server.
+** The Name Header and DestName Header must be in p_pkt for
+** the Copy and Move Object action.
+** The Name header and Permission Header must be in p_pkt for
+** the Set Object Permission action.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_BAD_HANDLE, if the handle is not valid.
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_ActionReq(tOBX_HANDLE handle, tOBX_ACTION action_id, BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function OBX_AuthResponse
+**
+** Description This function is called to respond to an OBX_PASSWORD_EVT event.
+**
+** Returns OBX_SUCCESS, if successful.
+** OBX_NO_RESOURCES, if OBX does not resources
+**
+*******************************************************************************/
+OBX_API extern tOBX_STATUS OBX_AuthResponse(tOBX_HANDLE handle,
+ UINT8 *p_password, UINT8 password_len,
+ UINT8 *p_userid, UINT8 userid_len,
+ BOOLEAN authenticate);
+
+
+/*******************************************************************************
+**
+** Function OBX_HdrInit
+**
+** Description This function is called to initialize an OBEX packet. This
+** function takes a GKI buffer and sets the offset in BT_HDR as
+** OBEX_HDR_OFFSET, the len as 0. The layer_specific is set to the
+** length still available. This function compares the given
+** (pkt_size - sizeof(BT_HDR)) with the peer MTU to get the lesser
+** of the two and set the layer_specific to
+** (lesser_size - OBEX_HDR_OFFSET).
+** If composing a header for the CONNECT request (there is no
+** client handle yet), use OBX_HANDLE_NULL as the handle.
+**
+** Returns BT_HDR *.
+**
+*******************************************************************************/
+OBX_API extern BT_HDR * OBX_HdrInit(tOBX_HANDLE handle, UINT16 pkt_size);
+
+/*******************************************************************************
+**
+** Function OBX_AddNameHdr
+**
+** Description This function is called to add an OBEX Name header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddNameHdr(BT_HDR *p_pkt, UINT16 *p_name, UINT16 len);
+
+/*******************************************************************************
+**
+** Function OBX_CharToWchar
+**
+** Description This function is called to convert ASCII to Unicode (UINT16).
+**
+** Returns the length.
+**
+*******************************************************************************/
+OBX_API extern UINT16 OBX_CharToWchar (UINT16 *w_str, char* a_str, UINT16 w_size);
+
+/*******************************************************************************
+**
+** Function OBX_AddAsciiNameHdr
+**
+** Description This function is called to add an OBEX Name header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddAsciiNameHdr(BT_HDR *p_pkt, char *p_name);
+
+/*******************************************************************************
+**
+** Function OBX_AddTypeHdr
+**
+** Description This function is called to add an OBEX Type header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddTypeHdr(BT_HDR *p_pkt, char *p_type);
+
+/*******************************************************************************
+**
+** Function OBX_AddLengthHdr
+**
+** Description This function is called to add an OBEX Length header to an OBEX
+** packet. The Length header describes the total length in bytes of
+** the object.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddLengthHdr(BT_HDR *p_pkt, UINT32 len);
+
+/*******************************************************************************
+**
+** Function OBX_AddTimeHdr
+**
+** Description This function is called to add an OBEX Time header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddTimeHdr(BT_HDR *p_pkt, char *p_time);
+
+/*******************************************************************************
+**
+** Function OBX_AddDescrHdr
+**
+** Description This function is called to add an OBEX Description header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddDescrHdr(BT_HDR *p_pkt, UINT16 *p_descr, UINT16 len);
+
+/*******************************************************************************
+**
+** Function OBX_AddAsciiDescrHdr
+**
+** Description This function is called to add an OBEX Description header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddAsciiDescrHdr(BT_HDR *p_pkt, char *p_descr);
+
+/*******************************************************************************
+**
+** Function OBX_AddTargetHdr
+**
+** Description This function is called to add an OBEX Target header to an OBEX
+** packet. This header is most commonly used in Connect packets.
+**
+** NOTE: The target header must be the first header in an OBEX message.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddTargetHdr(BT_HDR *p_pkt, UINT8 *p_target, UINT16 len);
+
+/*******************************************************************************
+**
+** Function OBX_AddHttpHdr
+**
+** Description This function is called to add an OBEX HTTP header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddHttpHdr(BT_HDR *p_pkt, UINT8 *p_http, UINT16 len);
+
+/*******************************************************************************
+**
+** Function OBX_AddBodyHdr
+**
+** Description This function is called to add an OBEX body header
+** to an OBEX packet.
+**
+** NOTE: The body header must be the last header in an OBEX message.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddBodyHdr(BT_HDR *p_pkt, UINT8 *p_body, UINT16 len, BOOLEAN end);
+
+/* Alternate Body header functions: for non-blocking scenario */
+/*******************************************************************************
+**
+** Function OBX_AddBodyStart
+**
+** Description This function is called to get the address to the beginning of
+** the byte sequence for an OBEX body header in an OBEX packet.
+**
+** Returns The address to add body content.
+**
+*******************************************************************************/
+OBX_API extern UINT8 *OBX_AddBodyStart(BT_HDR *p_pkt, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_AddBodyEnd
+**
+** Description This function is called to add the HI and the length of HV of an
+** OBEX body header to an OBEX packet. If end is TRUE, HI is
+** OBX_HI_BODY_END. If FALSE, HI is OBX_HI_BODY. It is assumed that
+** the actual value of the body has been copied into the OBEX packet.
+**
+** Returns void
+**
+*******************************************************************************/
+OBX_API extern void OBX_AddBodyEnd(BT_HDR *p_pkt, UINT8 *p, UINT16 len, BOOLEAN end);
+
+/*******************************************************************************
+**
+** Function OBX_AddWhoHdr
+**
+** Description This function is called to add an OBEX Who header to an OBEX
+** packet.
+**
+** Note: Who header is typically used in an OBEX CONNECT response packet
+** to indicate the UUID of the service that has accepted the
+** directed connection. If the server calls OBX_StartServer() with
+** specified target header, this OBEX implementation automatically
+** adds this WHO header to the CONNECT response packet. If
+** OBX_StartServer() is called with target header length as 0, the
+** OBEX API user is responsible to add the WHO header.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddWhoHdr(BT_HDR *p_pkt, UINT8 *p_who, UINT16 len);
+
+/*******************************************************************************
+**
+** Function OBX_AddAppParamHdr
+**
+** Description This function is called to add an OBEX Application Parameter
+** header to an OBEX packet. This header is used by the application
+** layer above OBEX to convey application specific information.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddAppParamHdr(BT_HDR *p_pkt, tOBX_TRIPLET *p_triplet, UINT8 num);
+
+/*******************************************************************************
+**
+** Function OBX_AddDestNameHdr
+**
+** Description This function is called to add an OBEX DestName header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddDestNameHdr(BT_HDR *p_pkt, UINT16 *p_dest, UINT16 len);
+
+/*******************************************************************************
+**
+** Function OBX_AddAsciiDestNameHdr
+**
+** Description This function is called to add an OBEX DestName header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddAsciiDestNameHdr(BT_HDR *p_pkt, char *p_descr);
+
+/*******************************************************************************
+**
+** Function OBX_AddPermissionHdr
+**
+** Description This function is called to add an OBEX Permission header to an OBEX
+** packet.
+** bit 0 is set for read permission
+** bit 1 is set for write permission
+** bit 2 is set for delete permission
+** bit 7 is set for modify permission
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddPermissionHdr(BT_HDR *p_pkt, UINT8 user, UINT8 group, UINT8 other);
+
+/*******************************************************************************
+**
+** Function OBX_Add1ByteHdr
+**
+** Description This function is called to add a header with type as UINT8
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_Add1ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT8 data);
+
+/*******************************************************************************
+**
+** Function OBX_Add4ByteHdr
+**
+** Description This function is called to add a header with type as UINT32
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_Add4ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT32 data);
+
+/*******************************************************************************
+**
+** Function OBX_AddByteStrStart
+**
+** Description This function is called to get the address to the beginning of
+** the byte sequence for an OBEX header in an OBEX packet.
+**
+** Returns The address to add the byte sequence.
+**
+*******************************************************************************/
+OBX_API extern UINT8 *OBX_AddByteStrStart(BT_HDR *p_pkt, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_AddByteStrHdr
+**
+** Description This function is called to add a header with type as byte sequence
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddByteStrHdr(BT_HDR *p_pkt, UINT8 id, UINT8 *p_data, UINT16 len);
+
+/*******************************************************************************
+**
+** Function OBX_AddUnicodeHdr
+**
+** Description This function is called to add a header with type as Unicode string
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddUnicodeHdr(BT_HDR *p_pkt, UINT8 id, UINT16 *p_data, UINT16 len);
+
+/*******************************************************************************
+**
+** Function OBX_AddTriplet
+**
+** Description This function is called to add a header with type as byte sequence
+** to an OBEX packet.
+**
+** Note: The byte sequence uses a Tag-Length-Value encoding scheme
+** These headers include: Application Parameters header
+** Authenticate Challenge header
+** Authenticate Response header
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddTriplet(BT_HDR *p_pkt, UINT8 id, tOBX_TRIPLET *p_triplet, UINT8 num);
+
+/*******************************************************************************
+**
+** Function OBX_CheckHdr
+**
+** Description This function is called to check if the given OBEX packet
+** contains the specified header.
+**
+** Returns NULL, if the header is not in the OBEX packet.
+** The pointer to the specified header beginning from HI.
+**
+*******************************************************************************/
+OBX_API extern UINT8 * OBX_CheckHdr(BT_HDR *p_pkt, UINT8 id);
+
+/*******************************************************************************
+**
+** Function OBX_ReadNumHdrs
+**
+** Description This function is called to check the number of headers in the
+** given OBEX packet
+**
+** Returns number of headers.
+**
+*******************************************************************************/
+OBX_API extern UINT8 OBX_ReadNumHdrs(BT_HDR *p_pkt, UINT8 *p_num_body);
+
+/*******************************************************************************
+**
+** Function OBX_ReadHdrLen
+**
+** Description This function is called to check the length of the specified
+** header in the given OBEX packet.
+**
+** Returns OBX_INVALID_HDR_LEN, if the header is not in the OBEX packet.
+** Otherwise the actual length of the header.
+**
+*******************************************************************************/
+OBX_API extern UINT16 OBX_ReadHdrLen(BT_HDR *p_pkt, UINT8 id);
+
+/*******************************************************************************
+**
+** Function OBX_ReadNameHdr
+**
+** Description This function is called to get the Name Header in the given
+** OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadNameHdr(BT_HDR *p_pkt, UINT16 *p_name, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_WcharToChar
+**
+** Description This function is called to convert Unicode (UINT16) to ASCII.
+**
+** Returns void.
+**
+*******************************************************************************/
+OBX_API extern void OBX_WcharToChar (char *a_str, UINT16* w_str, UINT16 a_size) ;
+
+/*******************************************************************************
+**
+** Function OBX_ReadAsciiNameHdr
+**
+** Description This function is called to get the Name Header in the given
+** OBEX packet. If Name header exists in the given OBEX packet,
+** it is converted to ASCII format and copied into p_name.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadAsciiNameHdr(BT_HDR *p_pkt, char *p_name, UINT16 max_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadTypeHdr
+**
+** Description This function is called to get the Type Header in the given
+** OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadTypeHdr(BT_HDR *p_pkt, UINT8 **p_type, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadLengthHdr
+**
+** Description This function is called to get the Length Header in the given
+** OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadLengthHdr(BT_HDR *p_pkt, UINT32 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadTimeHdr
+**
+** Description This function is called to get the Time Header in the given
+** OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadTimeHdr(BT_HDR *p_pkt, UINT8 **p_time, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadDescrHdr
+**
+** Description This function is called to get the Description Header in the
+** given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadDescrHdr(BT_HDR *p_pkt, UINT16 *p_descr, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadDestNameHdr
+**
+** Description This function is called to get the DestName Header in the
+** given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadDestNameHdr(BT_HDR *p_pkt, UINT16 *p_dest, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadAsciiDescrHdr
+**
+** Description This function is called to get the Description Header in the
+** given OBEX packet. If Description header exists in the given
+** OBEX packet, it is converted to ASCII format and copied into
+** p_descr.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadAsciiDescrHdr(BT_HDR *p_pkt, char *p_descr, UINT16 max_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadAsciiDestNameHdr
+**
+** Description This function is called to get the DestName Header in the
+** given OBEX packet. If DestName header exists in the given
+** OBEX packet, it is converted to ASCII format and copied into
+** p_descr.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadAsciiDestNameHdr(BT_HDR *p_pkt, char *p_dest, UINT16 max_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadTargetHdr
+**
+** Description This function is called to get the Target Header in the
+** given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadTargetHdr(BT_HDR *p_pkt, UINT8 **p_target, UINT16 *p_len, UINT8 next);
+
+/*******************************************************************************
+**
+** Function OBX_ReadHttpHdr
+**
+** Description This function is called to get the HTTP Header in the
+** given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadHttpHdr(BT_HDR *p_pkt, UINT8 **p_http, UINT16 *p_len, UINT8 next);
+
+/*******************************************************************************
+**
+** Function OBX_ReadBodyHdr
+**
+** Description This function is called to get the Body Header in the
+** given OBEX packet.
+**
+** Returns 1, if a single header is in the OBEX packet.
+** 2, if a end of body header is in the OBEX packet.
+** 0, (FALSE) otherwise.
+**
+*******************************************************************************/
+OBX_API extern UINT8 OBX_ReadBodyHdr(BT_HDR *p_pkt, UINT8 **p_body, UINT16 *p_len, BOOLEAN *p_end);
+
+/*******************************************************************************
+**
+** Function OBX_ReadWhoHdr
+**
+** Description This function is called to get the Who Header in the
+** given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadWhoHdr(BT_HDR *p_pkt, UINT8 **p_who, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadAppParamHdr
+**
+** Description This function is called to get the Application Parameter Header
+** in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadAppParamHdr(BT_HDR *p_pkt, UINT8 *p_tag, UINT8 **p_app_param, UINT8 *p_len, UINT8 next);
+
+/*******************************************************************************
+**
+** Function OBX_ReadPermissionHdr
+**
+** Description This function is called to get the Application Parameter Header
+** in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadPermissionHdr(BT_HDR *p_pkt, UINT8 *p_user, UINT8 *p_group, UINT8 *p_other);
+
+/*******************************************************************************
+**
+** Function OBX_Read1ByteHdr
+**
+** Description This function is called to get the UINT8 HV of the given HI
+** in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_Read1ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT8 *p_data);
+
+/*******************************************************************************
+**
+** Function OBX_Read4ByteHdr
+**
+** Description This function is called to get the UINT32 HV of the given HI
+** in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_Read4ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT32 *p_data);
+
+/*******************************************************************************
+**
+** Function OBX_ReadByteStrHdr
+**
+** Description This function is called to get the byte sequence HV of the given
+** HI in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadByteStrHdr(BT_HDR *p_pkt, UINT8 id, UINT8 **p_data, UINT16 *p_len, UINT8 next);
+
+/*******************************************************************************
+**
+** Function OBX_ReadUnicodeHdr
+**
+** Description This function is called to get the Unicode HV of the given
+** HI in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadUnicodeHdr(BT_HDR *p_pkt, UINT8 id, UINT16 *p_data, UINT16 *p_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadTriplet
+**
+** Description This function is called to get the Triplet HV of the given
+** HI in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadTriplet(BT_HDR *p_pkt, UINT8 id, tOBX_TRIPLET *p_triplet, UINT8 *p_num);
+
+/*******************************************************************************
+**
+** Function OBX_ReadActionIdHdr
+**
+** Description This function is called to get the HV of the Action ID header
+** in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadActionIdHdr(BT_HDR *p_pkt, UINT8 *p_data);
+
+/*******************************************************************************
+**
+** Function OBX_ReadChallenge
+**
+** Description This function is called to read the Realm and options of the
+** Authentication Challenge Header in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadChallenge(BT_HDR *p_pkt, tOBX_CHARSET *p_charset,
+ UINT8 **p_realm, UINT8 *p_len,
+ tOBX_AUTH_OPT *p_option);
+
+/*******************************************************************************
+**
+** Function OBX_ReadAuthParams
+**
+** Description This function is called to read the User ID of the
+** Authentication Response Header in the given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadAuthParams(BT_HDR *p_pkt, UINT8 **p_userid, UINT8 *p_len,
+ BOOLEAN *is_challenged, tOBX_AUTH_OPT *p_option);
+
+
+/*******************************************************************************
+**
+** Function utfc_16_to_8
+**
+** Description Convert a UTF-16 array to a null-terminated UTF-8 string.
+** Illegal characters are skipped.
+**
+** Returns Length of UTF-8 string in bytes.
+**
+*******************************************************************************/
+OBX_API extern UINT16 utfc_16_to_8(UINT8 *p_utf8, UINT16 utf8_len, UINT16 *p_utf16, UINT16 utf16_len);
+
+/*******************************************************************************
+**
+** Function utfc_8_to_16
+**
+** Description Convert a null-terminated UTF-8 string to a UTF-16 array.
+** Illegal characters are skipped.
+**
+** Returns Length of UTF-16 array.
+**
+*******************************************************************************/
+OBX_API extern UINT16 utfc_8_to_16(UINT16 *p_utf16, UINT16 utf16_len, UINT8 *p_utf8);
+
+/*******************************************************************************
+**
+** Function OBX_AddUtf8NameHdr
+**
+** Description This function is called to add an OBEX Name header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddUtf8NameHdr(BT_HDR *p_pkt, UINT8 *p_name);
+
+/*******************************************************************************
+**
+** Function OBX_AddUtf8DescrHdr
+**
+** Description This function is called to add an OBEX Description header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddUtf8DescrHdr(BT_HDR *p_pkt, UINT8 *p_descr);
+
+/*******************************************************************************
+**
+** Function OBX_AddUtf8DestNameHdr
+**
+** Description This function is called to add an OBEX DestName header
+** to an OBEX packet.
+**
+** Returns TRUE, if the header is added successfully.
+** FALSE, if the operation failed. p_pkt is not altered.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_AddUtf8DestNameHdr(BT_HDR *p_pkt, UINT8 *p_dest);
+
+/*******************************************************************************
+**
+** Function OBX_ReadUtf8NameHdr
+**
+** Description This function is called to get the Name Header in the given
+** OBEX packet. If Name header exists in the given OBEX packet,
+** it is converted to UTF8 format and copied into p_name.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadUtf8NameHdr(BT_HDR *p_pkt, UINT8 *p_name, UINT16 max_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadUtf8DescrHdr
+**
+** Description This function is called to get the Description Header in the
+** given OBEX packet. If Description header exists in the given
+** OBEX packet, it is converted to UTF8 format and copied into
+** p_descr.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadUtf8DescrHdr(BT_HDR *p_pkt, UINT8 *p_descr, UINT16 max_len);
+
+/*******************************************************************************
+**
+** Function OBX_ReadUtf8DestNameHdr
+**
+** Description This function is called to get the DestName Header in the
+** given OBEX packet.
+**
+** Returns TRUE, if the header is in the OBEX packet.
+** FALSE, otherwise.
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_ReadUtf8DestNameHdr(BT_HDR *p_pkt, UINT8 *p_dest, UINT16 max_len);
+
+/*******************************************************************************
+**
+** Function OBX_VerifyResponse
+**
+** Description This function is called by the client to verify the challenge
+** response.
+**
+** Returns TRUE, if successful.
+** FALSE, if authentication failed
+**
+*******************************************************************************/
+OBX_API extern BOOLEAN OBX_VerifyResponse(UINT32 nonce_u32, UINT8 *p_password, UINT8 password_len, UINT8 *p_response);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OBX_API_H */
diff --git a/stack/include/pan_api.h b/stack/include/pan_api.h
new file mode 100644
index 0000000..a604463
--- /dev/null
+++ b/stack/include/pan_api.h
@@ -0,0 +1,459 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2001-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 PAN API definitions
+ *
+ ******************************************************************************/
+#ifndef PAN_API_H
+#define PAN_API_H
+
+#include "bnep_api.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+/* Define the minimum offset needed in a GKI buffer for
+** sending PAN packets. Note, we are currently not sending
+** extension headers, but may in the future, so allow
+** space for them
+*/
+#define PAN_MINIMUM_OFFSET BNEP_MINIMUM_OFFSET
+
+
+/*
+** The handle is passed from BNEP to PAN. The same handle is used
+** between PAN and application as well
+*/
+#define PAN_INVALID_HANDLE BNEP_INVALID_HANDLE
+
+/* Bit map for PAN roles */
+#define PAN_ROLE_CLIENT 0x01 /* PANU role */
+#define PAN_ROLE_GN_SERVER 0x02 /* GN role */
+#define PAN_ROLE_NAP_SERVER 0x04 /* NAP role */
+
+/* Bitmap to indicate the usage of the Data */
+#define PAN_DATA_TO_HOST 0x01
+#define PAN_DATA_TO_LAN 0x02
+
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+/* Define the result codes from PAN */
+enum
+{
+ PAN_SUCCESS, /* Success */
+ PAN_DISCONNECTED = BNEP_CONN_DISCONNECTED, /* Connection terminated */
+ PAN_CONN_FAILED = BNEP_CONN_FAILED, /* Connection failed */
+ PAN_NO_RESOURCES = BNEP_NO_RESOURCES, /* No resources */
+ PAN_MTU_EXCEDED = BNEP_MTU_EXCEDED, /* Attempt to write long data */
+ PAN_INVALID_OFFSET = BNEP_INVALID_OFFSET, /* Insufficient offset in GKI buffer */
+ PAN_CONN_FAILED_CFG = BNEP_CONN_FAILED_CFG, /* Connection failed cos of config */
+ PAN_INVALID_SRC_ROLE = BNEP_CONN_FAILED_SRC_UUID, /* Connection failed wrong source UUID */
+ PAN_INVALID_DST_ROLE = BNEP_CONN_FAILED_DST_UUID, /* Connection failed wrong destination UUID */
+ PAN_CONN_FAILED_UUID_SIZE = BNEP_CONN_FAILED_UUID_SIZE, /* Connection failed wrong size UUID */
+ PAN_Q_SIZE_EXCEEDED = BNEP_Q_SIZE_EXCEEDED, /* Too many buffers to dest */
+ PAN_TOO_MANY_FILTERS = BNEP_TOO_MANY_FILTERS, /* Too many local filters specified */
+ PAN_SET_FILTER_FAIL = BNEP_SET_FILTER_FAIL, /* Set Filter failed */
+ PAN_WRONG_HANDLE = BNEP_WRONG_HANDLE, /* Wrong handle for the connection */
+ PAN_WRONG_STATE = BNEP_WRONG_STATE, /* Connection is in wrong state */
+ PAN_SECURITY_FAIL = BNEP_SECURITY_FAIL, /* Failed because of security */
+ PAN_IGNORE_CMD = BNEP_IGNORE_CMD, /* To ignore the rcvd command */
+ PAN_TX_FLOW_ON = BNEP_TX_FLOW_ON, /* tx data flow enabled */
+ PAN_TX_FLOW_OFF = BNEP_TX_FLOW_OFF, /* tx data flow disabled */
+ PAN_FAILURE /* Failure */
+
+};
+typedef UINT8 tPAN_RESULT;
+
+
+/*****************************************************************
+** Callback Function Prototypes
+*****************************************************************/
+
+/* This is call back function used to report connection status
+** to the application. The second parameter TRUE means
+** to create the bridge and FALSE means to remove it.
+*/
+typedef void (tPAN_CONN_STATE_CB) (UINT16 handle, BD_ADDR bd_addr, tPAN_RESULT state, BOOLEAN is_role_change,
+ UINT8 src_role, UINT8 dst_role);
+
+
+/* This is call back function used to create bridge for the
+** Connected device. The parameter "state" indicates
+** whether to create the bridge or remove it. TRUE means
+** to create the bridge and FALSE means to remove it.
+*/
+typedef void (tPAN_BRIDGE_REQ_CB) (BD_ADDR bd_addr, BOOLEAN state);
+
+
+/* Data received indication callback prototype. Parameters are
+** Source BD/Ethernet Address
+** Dest BD/Ethernet address
+** Protocol
+** Address of buffer (or data if non-GKI)
+** Length of data (non-GKI)
+** ext is flag to indicate whether it has aby extension headers
+** Flag used to indicate to forward on LAN
+** FALSE - Use it for internal stack
+** TRUE - Send it across the ethernet as well
+*/
+typedef void (tPAN_DATA_IND_CB) (UINT16 handle,
+ BD_ADDR src,
+ BD_ADDR dst,
+ UINT16 protocol,
+ UINT8 *p_data,
+ UINT16 len,
+ BOOLEAN ext,
+ BOOLEAN forward);
+
+
+/* Data buffer received indication callback prototype. Parameters are
+** Source BD/Ethernet Address
+** Dest BD/Ethernet address
+** Protocol
+** pointer to the data buffer
+** ext is flag to indicate whether it has aby extension headers
+** Flag used to indicate to forward on LAN
+** FALSE - Use it for internal stack
+** TRUE - Send it across the ethernet as well
+*/
+typedef void (tPAN_DATA_BUF_IND_CB) (UINT16 handle,
+ BD_ADDR src,
+ BD_ADDR dst,
+ UINT16 protocol,
+ BT_HDR *p_buf,
+ BOOLEAN ext,
+ BOOLEAN forward);
+
+
+/* Flow control callback for TX data. Parameters are
+** Handle to the connection
+** Event flow status
+*/
+typedef void (tPAN_TX_DATA_FLOW_CB) (UINT16 handle,
+ tPAN_RESULT event);
+
+/* Filters received indication callback prototype. Parameters are
+** Handle to the connection
+** TRUE if the cb is called for indication
+** Ignore this if it is indication, otherwise it is the result
+** for the filter set operation performed by the local
+** device
+** Number of protocol filters present
+** Pointer to the filters start. Filters are present in pairs
+** of start of the range and end of the range.
+** They will be present in big endian order. First
+** two bytes will be starting of the first range and
+** next two bytes will be ending of the range.
+*/
+typedef void (tPAN_FILTER_IND_CB) (UINT16 handle,
+ BOOLEAN indication,
+ tBNEP_RESULT result,
+ UINT16 num_filters,
+ UINT8 *p_filters);
+
+
+
+/* Multicast Filters received indication callback prototype. Parameters are
+** Handle to the connection
+** TRUE if the cb is called for indication
+** Ignore this if it is indication, otherwise it is the result
+** for the filter set operation performed by the local
+** device
+** Number of multicast filters present
+** Pointer to the filters start. Filters are present in pairs
+** of start of the range and end of the range.
+** First six bytes will be starting of the first range and
+** next six bytes will be ending of the range.
+*/
+typedef void (tPAN_MFILTER_IND_CB) (UINT16 handle,
+ BOOLEAN indication,
+ tBNEP_RESULT result,
+ UINT16 num_mfilters,
+ UINT8 *p_mfilters);
+
+
+
+
+/* This structure is used to register with PAN profile
+** It is passed as a parameter to PAN_Register call.
+*/
+typedef struct
+{
+ tPAN_CONN_STATE_CB *pan_conn_state_cb; /* Connection state callback */
+ tPAN_BRIDGE_REQ_CB *pan_bridge_req_cb; /* Bridge request callback */
+ tPAN_DATA_IND_CB *pan_data_ind_cb; /* Data indication callback */
+ tPAN_DATA_BUF_IND_CB *pan_data_buf_ind_cb; /* Data buffer indication callback */
+ tPAN_FILTER_IND_CB *pan_pfilt_ind_cb; /* protocol filter indication callback */
+ tPAN_MFILTER_IND_CB *pan_mfilt_ind_cb; /* multicast filter indication callback */
+ tPAN_TX_DATA_FLOW_CB *pan_tx_data_flow_cb; /* data flow callback */
+ char *user_service_name; /* Service name for PANU role */
+ char *gn_service_name; /* Service name for GN role */
+ char *nap_service_name; /* Service name for NAP role */
+
+} tPAN_REGISTER;
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function PAN_Register
+**
+** Description This function is called by the application to register
+** its callbacks with PAN profile. The application then
+** should set the PAN role explicitly.
+**
+** Parameters: p_register - contains all callback function pointers
+**
+**
+** Returns none
+**
+*******************************************************************************/
+PAN_API extern void PAN_Register (tPAN_REGISTER *p_register);
+
+
+/*******************************************************************************
+**
+** Function PAN_Deregister
+**
+** Description This function is called by the application to de-register
+** its callbacks with PAN profile. This will make the PAN to
+** become inactive. This will deregister PAN services from SDP
+** and close all active connections
+**
+** Returns none
+**
+*******************************************************************************/
+PAN_API extern void PAN_Deregister (void);
+
+/*******************************************************************************
+**
+** Function PAN_SetRole
+**
+** Description This function is called by the application to set the PAN
+** profile role. This should be called after PAN_Register.
+** This can be called any time to change the PAN role
+**
+** Parameters: role - is bit map of roles to be active
+** PAN_ROLE_CLIENT is for PANU role
+** PAN_ROLE_GN_SERVER is for GN role
+** PAN_ROLE_NAP_SERVER is for NAP role
+** sec_mask - Security mask for different roles
+** It is array of UINT8. The byte represent the
+** security for roles PANU, GN and NAP in order
+** p_user_name - Service name for PANU role
+** p_gn_name - Service name for GN role
+** p_nap_name - Service name for NAP role
+** Can be NULL if user wants it to be default
+**
+** Returns PAN_SUCCESS - if the role is set successfully
+** PAN_FAILURE - if the role is not valid
+**
+*******************************************************************************/
+PAN_API extern tPAN_RESULT PAN_SetRole (UINT8 role,
+ UINT8 *sec_mask,
+ char *p_user_name,
+ char *p_gn_name,
+ char *p_nap_name);
+
+/*******************************************************************************
+**
+** Function PAN_Connect
+**
+** Description This function is called by the application to initiate a
+** connection to the remote device
+**
+** Parameters: rem_bda - BD Addr of the remote device
+** src_role - Role of the local device for the connection
+** dst_role - Role of the remote device for the connection
+** PAN_ROLE_CLIENT is for PANU role
+** PAN_ROLE_GN_SERVER is for GN role
+** PAN_ROLE_NAP_SERVER is for NAP role
+** *handle - Pointer for returning Handle to the connection
+**
+** Returns PAN_SUCCESS - if the connection is initiated successfully
+** PAN_NO_RESOURCES - resources are not sufficent
+** PAN_FAILURE - if the connection cannot be initiated
+** this can be because of the combination of
+** src and dst roles may not be valid or
+** allowed at that point of time
+**
+*******************************************************************************/
+PAN_API extern tPAN_RESULT PAN_Connect (BD_ADDR rem_bda, UINT8 src_role, UINT8 dst_role, UINT16 *handle);
+
+/*******************************************************************************
+**
+** Function PAN_Disconnect
+**
+** Description This is used to disconnect the connection
+**
+** Parameters: handle - handle for the connection
+**
+** Returns PAN_SUCCESS - if the connection is closed successfully
+** PAN_FAILURE - if the connection is not found or
+** there is an error in disconnecting
+**
+*******************************************************************************/
+PAN_API extern tPAN_RESULT PAN_Disconnect (UINT16 handle);
+
+/*******************************************************************************
+**
+** Function PAN_Write
+**
+** Description This sends data over the PAN connections. If this is called
+** on GN or NAP side and the packet is multicast or broadcast
+** it will be sent on all the links. Otherwise the correct link
+** is found based on the destination address and forwarded on it
+** If the return value is not PAN_SUCCESS the application should
+** take care of releasing the message buffer
+**
+** Parameters: dst - MAC or BD Addr of the destination device
+** src - MAC or BD Addr of the source who sent this packet
+** protocol - protocol of the ethernet packet like IP or ARP
+** p_data - pointer to the data
+** len - length of the data
+** ext - to indicate that extension headers present
+**
+** Returns PAN_SUCCESS - if the data is sent successfully
+** PAN_FAILURE - if the connection is not found or
+** there is an error in sending data
+**
+*******************************************************************************/
+PAN_API extern tPAN_RESULT PAN_Write (UINT16 handle,
+ BD_ADDR dst,
+ BD_ADDR src,
+ UINT16 protocol,
+ UINT8 *p_data,
+ UINT16 len,
+ BOOLEAN ext);
+
+/*******************************************************************************
+**
+** Function PAN_WriteBuf
+**
+** Description This sends data over the PAN connections. If this is called
+** on GN or NAP side and the packet is multicast or broadcast
+** it will be sent on all the links. Otherwise the correct link
+** is found based on the destination address and forwarded on it
+** If the return value is not PAN_SUCCESS the application should
+** take care of releasing the message buffer
+**
+** Parameters: dst - MAC or BD Addr of the destination device
+** src - MAC or BD Addr of the source who sent this packet
+** protocol - protocol of the ethernet packet like IP or ARP
+** p_buf - pointer to the data buffer
+** ext - to indicate that extension headers present
+**
+** Returns PAN_SUCCESS - if the data is sent successfully
+** PAN_FAILURE - if the connection is not found or
+** there is an error in sending data
+**
+*******************************************************************************/
+PAN_API extern tPAN_RESULT PAN_WriteBuf (UINT16 handle,
+ BD_ADDR dst,
+ BD_ADDR src,
+ UINT16 protocol,
+ BT_HDR *p_buf,
+ BOOLEAN ext);
+
+/*******************************************************************************
+**
+** Function PAN_SetProtocolFilters
+**
+** Description This function is used to set protocol filters on the peer
+**
+** Parameters: handle - handle for the connection
+** num_filters - number of protocol filter ranges
+** start - array of starting protocol numbers
+** end - array of ending protocol numbers
+**
+**
+** Returns PAN_SUCCESS if protocol filters are set successfully
+** PAN_FAILURE if connection not found or error in setting
+**
+*******************************************************************************/
+PAN_API extern tPAN_RESULT PAN_SetProtocolFilters (UINT16 handle,
+ UINT16 num_filters,
+ UINT16 *p_start_array,
+ UINT16 *p_end_array);
+
+/*******************************************************************************
+**
+** Function PAN_SetMulticastFilters
+**
+** Description This function is used to set multicast filters on the peer
+**
+** Parameters: handle - handle for the connection
+** num_filters - number of multicast filter ranges
+** p_start_array - Pointer to sequence of beginings of all
+** multicast address ranges
+** p_end_array - Pointer to sequence of ends of all
+** multicast address ranges
+**
+**
+** Returns PAN_SUCCESS if multicast filters are set successfully
+** PAN_FAILURE if connection not found or error in setting
+**
+*******************************************************************************/
+PAN_API extern tBNEP_RESULT PAN_SetMulticastFilters (UINT16 handle,
+ UINT16 num_mcast_filters,
+ UINT8 *p_start_array,
+ UINT8 *p_end_array);
+
+/*******************************************************************************
+**
+** Function PAN_SetTraceLevel
+**
+** Description This function sets the trace level for PAN. If called with
+** a value of 0xFF, it simply reads the current trace level.
+**
+** Returns the new (current) trace level
+**
+*******************************************************************************/
+PAN_API extern UINT8 PAN_SetTraceLevel (UINT8 new_level);
+
+/*******************************************************************************
+**
+** Function PAN_Init
+**
+** Description This function initializes the PAN unit. It should be called
+** before accessing any other APIs to initialize the control
+** block.
+**
+** Returns void
+**
+*******************************************************************************/
+PAN_API extern void PAN_Init (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PAN_API_H */
diff --git a/stack/include/port_api.h b/stack/include/port_api.h
new file mode 100644
index 0000000..2f64932
--- /dev/null
+++ b/stack/include/port_api.h
@@ -0,0 +1,635 @@
+/******************************************************************************
+ *
+ * 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 "bt_target.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);
+
+/*
+** 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)
+
+
+/*****************************************************************************
+** 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.
+**
+*******************************************************************************/
+RFC_API extern int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn,
+ BOOLEAN is_server, UINT16 mtu,
+ BD_ADDR bd_addr, UINT16 *p_handle,
+ tPORT_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
+**
+*******************************************************************************/
+RFC_API 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
+**
+*******************************************************************************/
+RFC_API 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.
+**
+*******************************************************************************/
+RFC_API extern int PORT_SetEventCallback (UINT16 port_handle,
+ tPORT_CALLBACK *p_port_cb);
+
+
+/*******************************************************************************
+**
+** 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.
+**
+*******************************************************************************/
+RFC_API extern int PORT_SetDataCallback (UINT16 port_handle,
+ tPORT_DATA_CALLBACK *p_cb);
+
+RFC_API 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.
+**
+*******************************************************************************/
+RFC_API 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
+** bd_addr - OUT bd_addr of the peer
+** p_lcid - OUT L2CAP's LCID
+**
+*******************************************************************************/
+RFC_API extern int PORT_CheckConnection (UINT16 handle, 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
+**
+*******************************************************************************/
+RFC_API 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.
+**
+*******************************************************************************/
+RFC_API 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.
+**
+*******************************************************************************/
+RFC_API 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.
+**
+*******************************************************************************/
+RFC_API 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 */
+
+RFC_API 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
+**
+*******************************************************************************/
+RFC_API extern int PORT_FlowControl (UINT16 handle, BOOLEAN enable);
+
+
+/*******************************************************************************
+**
+** 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)
+
+RFC_API 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;
+
+
+RFC_API 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
+**
+*******************************************************************************/
+RFC_API 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
+**
+*******************************************************************************/
+RFC_API 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
+
+RFC_API 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,
+**
+*******************************************************************************/
+RFC_API 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
+**
+*******************************************************************************/
+RFC_API 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,
+**
+*******************************************************************************/
+RFC_API 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
+**
+*******************************************************************************/
+RFC_API 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
+**
+*******************************************************************************/
+RFC_API extern int PORT_WriteDataCO (UINT16 handle, int* p_len);
+
+/*******************************************************************************
+**
+** 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
+**
+*******************************************************************************/
+RFC_API extern int PORT_Test (UINT16 handle, UINT8 *p_data, UINT16 len);
+
+
+/*******************************************************************************
+**
+** Function RFCOMM_Init
+**
+** Description This function is called to initialize RFCOMM layer
+**
+*******************************************************************************/
+RFC_API extern void RFCOMM_Init (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
+**
+*******************************************************************************/
+RFC_API extern UINT8 PORT_SetTraceLevel (UINT8 new_level);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PORT_API_H */
diff --git a/stack/include/port_ext.h b/stack/include/port_ext.h
new file mode 100644
index 0000000..e25b6d9
--- /dev/null
+++ b/stack/include/port_ext.h
@@ -0,0 +1,32 @@
+/******************************************************************************
+ *
+ * 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
+
+#include "gki.h"
+
+/* Port emulation entity Entry Points */
+extern void rfcomm_process_timeout (TIMER_LIST_ENT *p_tle);
+#endif
diff --git a/stack/include/rfcdefs.h b/stack/include/rfcdefs.h
new file mode 100644
index 0000000..dcc37bc
--- /dev/null
+++ b/stack/include/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/stack/include/sdp_api.h b/stack/include/sdp_api.h
new file mode 100644
index 0000000..dcc813e
--- /dev/null
+++ b/stack/include/sdp_api.h
@@ -0,0 +1,756 @@
+/******************************************************************************
+ *
+ * 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 "bt_target.h"
+#include "sdpdefs.h"
+
+/*****************************************************************************
+** 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
+
+/* these result codes are used only when SDP_FOR_JV_INCLUDED==TRUE */
+#define SDP_EVT_OPEN 0x00F0 /* connected */
+#define SDP_EVT_DATA_IND 0x00F1 /* data ind */
+#define SDP_EVT_CLOSE 0x00F2 /* disconnected */
+
+/* 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
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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_ServiceSearchRequest is that this one does a
+** combined ServiceSearchAttributeRequest SDP function.
+**
+** Returns TRUE if discovery started, FALSE if failed.
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API extern UINT16 SDP_SetLocalDiRecord (tSDP_DI_RECORD *device_info,
+ UINT32 *p_handle);
+
+/*******************************************************************************
+**
+** Function SDP_GetLocalDiRecord
+**
+** Description This function adds a DI record to the local SDP database.
+**
+** Fills in the device information of the record
+** p_handle - if p_handle == NULL, the primary record is returned
+**
+** Returns Returns SDP_SUCCESS if record exists, else error
+**
+*******************************************************************************/
+SDP_API extern UINT16 SDP_GetLocalDiRecord(tSDP_DI_GET_RECORD *p_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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API 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.
+**
+*******************************************************************************/
+SDP_API BOOLEAN SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID *p_uuid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SDP_API_H */
diff --git a/stack/include/sdpdefs.h b/stack/include/sdpdefs.h
new file mode 100644
index 0000000..c290e03
--- /dev/null
+++ b/stack/include/sdpdefs.h
@@ -0,0 +1,319 @@
+/******************************************************************************
+ *
+ * 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_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 */
+
+/* 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 */
+
+/* a temporary value for IOP */
+#ifndef ATTR_ID_OBX_OVR_L2CAP_PSM
+#define ATTR_ID_OBX_OVR_L2CAP_PSM 0x0200
+#endif
+
+
+/* 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_DEVICE_INFO 0x180A /* device info service */
+#define UUID_SERVCLASS_NWA 0x180B /* Network availability */
+#define UUID_SERVCLASS_PHALERT 0x180C /* phone alert service */
+#define UUID_SERVCLASS_GLUCOSE 0xC000 /* Glucose Meter 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/stack/include/smp_api.h b/stack/include/smp_api.h
new file mode 100644
index 0000000..bd7b131
--- /dev/null
+++ b/stack/include/smp_api.h
@@ -0,0 +1,300 @@
+/******************************************************************************
+ *
+ * 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 "bt_target.h"
+
+#define SMP_PIN_CODE_LEN_MAX PIN_CODE_LEN
+#define SMP_PIN_CODE_LEN_MIN 6
+
+/* 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_COMPLT_EVT 6 /* SMP complete 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_PAIR_FAILURE_MAX SMP_REPEATED_ATTEMPTS
+/* self defined error code */
+#define SMP_PAIR_INTERNAL_ERR 0x0A
+#define SMP_UNKNOWN_IO_CAP 0x0B /* unknown IO capability, unable to decide associatino model */
+#define SMP_INIT_FAIL 0x0C
+#define SMP_CONFIRM_FAIL 0x0D
+#define SMP_BUSY 0x0E
+#define SMP_ENC_FAIL 0x0F
+#define SMP_STARTED 0x10
+#define SMP_RSP_TIMEOUT 0x11
+#define SMP_DIV_NOT_AVAIL 0x12
+#define SMP_FAIL 0x13 /* unspecified failed reason */
+#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;
+
+#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_AUTH_MASK (SMP_AUTH_GEN_BOND|SMP_AUTH_YN_BIT)
+
+
+#define SMP_AUTH_BOND SMP_AUTH_GEN_BOND
+
+#define SMP_AUTH_NB_ENC_ONLY 0x00 //(SMP_AUTH_MASK | BTM_AUTH_SP_NO) /* no MITM, No Bonding, Encryptino only */
+#define SMP_AUTH_NB_IOCAP (SMP_AUTH_NO_BOND | SMP_AUTH_YN_BIT) /* MITM, No Bonding, Use IO Capability
+ to detrermine authenticaion procedure */
+#define SMP_AUTH_GB_ENC_ONLY (SMP_AUTH_GEN_BOND ) /* no MITM, General Bonding, Encryptino only */
+#define SMP_AUTH_GB_IOCAP (SMP_AUTH_GEN_BOND | SMP_AUTH_YN_BIT) /* MITM, General Bonding, Use IO Capability
+ to detrermine authenticaion procedure */
+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;
+
+/* 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 */
+typedef UINT8 tSMP_KEYS;
+
+/* 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)
+
+/* 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
+{
+ UINT8 reason;
+ UINT8 sec_level;
+ BOOLEAN is_pair_cancel;
+} tSMP_CMPL;
+
+typedef union
+{
+ UINT32 passkey;
+ tSMP_IO_REQ io_req; /* IO request */
+ tSMP_CMPL cmplt;
+
+}tSMP_EVT_DATA;
+
+
+/* AES Encryption output */
+typedef struct
+{
+ UINT8 status;
+ UINT8 param_len;
+ UINT16 opcode;
+ UINT8 param_buf[BT_OCTET16_LEN];
+} tSMP_ENC;
+
+/* Simple Pairing Events. Called by the stack when Simple Pairing 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
+**
+*******************************************************************************/
+ SMP_API extern void SMP_Init(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
+**
+*******************************************************************************/
+ SMP_API extern UINT8 SMP_SetTraceLevel (UINT8 new_level);
+
+/*******************************************************************************
+**
+** Function SMP_Register
+**
+** Description This function register for the SMP service callback.
+**
+** Returns void
+**
+*******************************************************************************/
+ SMP_API 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.
+**
+*******************************************************************************/
+ SMP_API extern tSMP_STATUS SMP_Pair (BD_ADDR bd_addr);
+/*******************************************************************************
+**
+** Function SMP_PairCancel
+**
+** Description This function is called to cancel a SMP pairing.
+**
+** Returns TRUE - pairing cancelled
+**
+*******************************************************************************/
+ SMP_API 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
+**
+*******************************************************************************/
+ SMP_API 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 BTM_SUCCESS if success
+** passkey - numeric value in the range of
+** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
+**
+*******************************************************************************/
+ SMP_API extern void SMP_PasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey);
+
+/*******************************************************************************
+**
+** Function SMP_OobDataReply
+**
+** Description This function is called to provide the OOB data for
+** Simple Pairing in response to BTM_SP_RMT_OOB_EVT
+**
+** Parameters: bd_addr - Address of the peer device
+** res - result of the operation SMP_SUCCESS if success
+** p_data - simple pairing Randomizer C.
+**
+*******************************************************************************/
+ SMP_API extern void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, UINT8 len,
+ 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
+*******************************************************************************/
+ SMP_API extern BOOLEAN SMP_Encrypt (UINT8 *key, UINT8 key_len,
+ UINT8 *plain_text, UINT8 pt_len,
+ tSMP_ENC *p_out);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* SMP_API_H */
diff --git a/stack/include/uipc_msg.h b/stack/include/uipc_msg.h
new file mode 100644
index 0000000..6a9a4ae
--- /dev/null
+++ b/stack/include/uipc_msg.h
@@ -0,0 +1,884 @@
+/******************************************************************************
+ *
+ * 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 sync message over UIPC
+ *
+ ******************************************************************************/
+
+#ifndef UIPC_MSG_H
+#define UIPC_MSG_H
+
+#include "bt_types.h"
+
+/****************************************************************************/
+/* UIPC version number: 1.0 */
+/****************************************************************************/
+#define UIPC_VERSION_MAJOR 0x0001
+#define UIPC_VERSION_MINOR 0x0000
+
+
+/********************************
+
+ UIPC Management Messages
+
+********************************/
+
+/* tUIPC_STATUS codes*/
+enum
+{
+ UIPC_STATUS_SUCCESS,
+ UIPC_STATUS_FAIL
+};
+typedef UINT8 tUIPC_STATUS;
+
+/* op_code */
+#define UIPC_OPEN_REQ 0x00
+#define UIPC_OPEN_RSP 0x01
+#define UIPC_CLOSE_REQ 0x02
+#define UIPC_CLOSE_RSP 0x03
+
+/* Structure of UIPC_OPEN_REQ message */
+typedef struct
+{
+ UINT8 opcode; /* UIPC_OPEN_REQ */
+} tUIPC_OPEN_REQ;
+#define UIPC_OPEN_REQ_MSGLEN (1)
+
+/* Structure of UIPC_OPEN_RSP message */
+typedef struct
+{
+ UINT8 opcode; /* UIPC_OPEN_RESP */
+ tUIPC_STATUS status; /* UIPC_STATUS */
+ UINT16 version_major; /* UIPC_VERSION_MAJOR */
+ UINT16 version_minor; /* UIPC_VERSION_MINOR */
+ UINT8 num_streams; /* Number of simultaneous streams supported by the light stack */
+} tUIPC_OPEN_RSP;
+#define UIPC_OPEN_RSP_MSGLEN (7)
+
+/* Structure of UIPC_CLOSE_REQ message */
+typedef struct t_uipc_close_req
+{
+ UINT8 opcode; /* UIPC_CLOSE_REQ */
+} tUIPC_CLOSE_REQ;
+#define UIPC_CLOSE_REQ_MSGLEN (1)
+
+/* Structure of UIPC_CLOSE_RSP message, only for BTC, full stack may ignore it */
+typedef struct t_uipc_close_rsp
+{
+ UINT8 opcode; /* UIPC_CLOSE_RSP */
+} tUIPC_CLOSE_RSP;
+#define UIPC_CLOSE_RSP_MSGLEN (1)
+
+/* UIPC management message structures */
+typedef union
+{
+ UINT8 opcode;
+ tUIPC_OPEN_REQ open_req;
+ tUIPC_OPEN_RSP open_resp;
+ tUIPC_CLOSE_REQ close_req;
+} tUIPC_MSG;
+
+#define UIPC_MGMT_MSG_MAXLEN (sizeof(tUIPC_MSG))
+
+#define IPC_LOG_MSG_LEN 100
+typedef struct t_uipc_log_msg
+{
+ UINT32 trace_set_mask;
+ UINT8 msg[IPC_LOG_MSG_LEN];
+} tUIPC_LOG_MSG;
+#define UIPC_LOG_MSGLEN (IPC_LOG_MSG_LEN + 4)
+
+/********************************
+
+ H5 Sync Message
+
+********************************/
+
+/* op_code */
+#define SLIP_SYNC_TO_LITE_REQ 0
+#define SLIP_SYNC_TO_LITE_RESP 1
+#define SLIP_SYNC_TO_FULL_REQ 2
+#define SLIP_SYNC_TO_FULL_RESP 3
+#define SLIP_SYNC_NOTIFY 4
+
+/* status */
+#define SLIP_SYNC_SUCCESS 0
+#define SLIP_SYNC_FAILURE 1
+
+typedef struct
+{
+ UINT8 op_code;
+ UINT8 status;
+ UINT16 acl_pkt_size;
+ UINT8 state;
+ UINT8 lp_state; /* Low Power state */
+ UINT8 next_seqno; /* next send seq */
+ UINT8 ack; /* next ack seq, expected seq from peer */
+ UINT8 sent_ack; /* last sent ack */
+ UINT8 sliding_window_size;/* window size */
+ BOOLEAN oof_flow_control; /* Out of Frame SW Flow Control */
+ BOOLEAN data_integrity_type;/* Level of Data Integrity Check */
+ UINT8 rx_state; /* rx state for incoming packet processing */
+} tSLIP_SYNC_INFO;
+
+/********************************
+
+ L2CAP Sync Message
+
+********************************/
+
+/* op_code */
+#define L2C_SYNC_TO_LITE_REQ 0
+#define L2C_SYNC_TO_LITE_RESP 1
+#define L2C_REMOVE_TO_LITE_REQ 2
+#define L2C_REMOVE_TO_LITE_RESP 3
+#define L2C_FLUSH_TO_FULL_IND 4
+
+/* status */
+#define L2C_SYNC_SUCCESS 0
+#define L2C_SYNC_FAILURE 1
+
+typedef struct t_l2c_stream_info
+{
+ UINT16 local_cid; /* Local CID */
+ UINT16 remote_cid; /* Remote CID */
+ UINT16 out_mtu; /* Max MTU we will send */
+ UINT16 handle; /* The handle used with LM */
+ UINT16 link_xmit_quota; /* Num outstanding pkts allowed */
+ BOOLEAN is_flushable; /* TRUE if flushable channel */
+} tL2C_STREAM_INFO;
+
+typedef struct t_l2c_sync_to_lite_req
+{
+ UINT8 op_code; /* L2C_SYNC_TO_LITE_REQ */
+ UINT16 light_xmit_quota; /* Total quota for light stack */
+ UINT16 acl_data_size; /* Max ACL data size across HCI transport */
+ UINT16 non_flushable_pbf; /* L2CAP_PKT_START_NON_FLUSHABLE if controller supports */
+ /* Otherwise, L2CAP_PKT_START */
+ UINT8 multi_av_data_cong_start; /* Multi-AV queue size to start congestion */
+ UINT8 multi_av_data_cong_end; /* Multi-AV queue size to end congestion */
+ UINT8 multi_av_data_cong_discard; /* Multi-AV queue size to discard */
+ UINT8 num_stream;
+ tL2C_STREAM_INFO stream[BTM_SYNC_INFO_NUM_STR];
+} tL2C_SYNC_TO_LITE_REQ;
+
+typedef struct t_l2c_sync_to_lite_resp_stream
+{
+ UINT16 lcid;
+ UINT8 status;
+} tL2C_SYNC_TO_LITE_RESP_STREAM;
+
+typedef struct t_l2c_sync_to_lite_resp
+{
+ UINT8 op_code; /* L2C_SYNC_TO_LITE_RESP */
+ UINT16 light_xmit_unacked; /* unacked packet more than quota in light stack */
+ UINT8 num_stream;
+ tL2C_SYNC_TO_LITE_RESP_STREAM stream[BTM_SYNC_INFO_NUM_STR];
+} tL2C_SYNC_TO_LITE_RESP;
+
+typedef struct t_l2c_remove_to_lite_req
+{
+ UINT8 op_code; /* L2C_REMOVE_TO_LITE_REQ */
+ UINT16 light_xmit_quota; /* Total quota for light stack */
+ UINT8 num_stream;
+ UINT16 lcid[BTM_SYNC_INFO_NUM_STR];
+} tL2C_REMOVE_TO_LITE_REQ;
+
+typedef tL2C_SYNC_TO_LITE_RESP tL2C_REMOVE_TO_LITE_RESP;
+typedef tL2C_REMOVE_TO_LITE_REQ tL2C_FLUSH_TO_FULL_IND;
+
+typedef union t_l2c_sync_msg
+{
+ UINT8 op_code;
+ tL2C_SYNC_TO_LITE_REQ sync_req;
+ tL2C_SYNC_TO_LITE_RESP sync_resp;
+ tL2C_REMOVE_TO_LITE_REQ remove_req;
+ tL2C_REMOVE_TO_LITE_RESP remove_resp;
+ tL2C_FLUSH_TO_FULL_IND flush_ind;
+} tL2C_SYNC_MSG;
+
+/********************************
+
+ AVDTP Sync Message
+
+********************************/
+
+/* op_code */
+#define AVDT_SYNC_TO_LITE_REQ 0
+#define AVDT_SYNC_TO_LITE_RESP 1
+#define AVDT_RESYNC_TO_LITE_REQ 2
+#define AVDT_RESYNC_TO_LITE_RESP 3
+#define AVDT_SYNC_TO_FULL_REQ 4
+#define AVDT_SYNC_TO_FULL_RESP 5
+#define AVDT_REMOVE_TO_LITE_REQ 6
+#define AVDT_REMOVE_TO_LITE_RESP 7
+#define AVDT_SYNC_TO_BTC_LITE_REQ 8
+#define AVDT_SYNC_TO_BTC_LITE_RESP 9
+
+/* status */
+#define AVDT_SYNC_SUCCESS 0
+#define AVDT_SYNC_FAILURE 1
+
+typedef struct
+{
+ UINT16 lcid;
+ UINT32 ssrc;
+} tAVDT_SYNC_TO_BTC_LITE_REQ_STREAM;
+
+typedef struct
+{
+ UINT8 opcode; /* AVDT_SYNC_TO_BTC_LITE_REQ */
+ UINT8 num_stream;
+ tAVDT_SYNC_TO_BTC_LITE_REQ_STREAM stream[BTM_SYNC_INFO_NUM_STR];
+} tAVDT_SYNC_TO_BTC_LITE_REQ;
+
+typedef struct
+{
+ UINT8 opcode; /* AVDT_SYNC_TO_BTC_LITE_RESP */
+ UINT8 status;
+} tAVDT_SYNC_TO_BTC_LITE_RESP;
+
+typedef struct t_avdt_scb_sync_info
+{
+ UINT8 handle; /* SCB handle */
+ BD_ADDR peer_addr; /* BD address of peer */
+ UINT16 local_cid; /* Local CID */
+ UINT16 peer_mtu; /* L2CAP mtu of the peer device */
+ UINT8 mux_tsid_media; /* TSID for media transport session */
+ UINT16 media_seq; /* media packet sequence number */
+} tAVDT_SCB_SYNC_INFO;
+
+typedef struct t_avdt_sync_info
+{
+ UINT8 op_code;
+ UINT8 status;
+
+ tAVDT_SCB_SYNC_INFO scb_info[BTM_SYNC_INFO_NUM_STR];
+
+} tAVDT_SYNC_INFO;
+
+typedef union t_avdt_sync_msg
+{
+ UINT8 op_code;
+ tAVDT_SYNC_INFO sync_info;
+ tAVDT_SYNC_TO_BTC_LITE_REQ btc_sync_req;
+ tAVDT_SYNC_TO_BTC_LITE_RESP btc_sync_resp;
+} tAVDT_SYNC_MSG;
+
+/********************************
+
+ BTA AV Sync Message
+
+********************************/
+
+/* op_code for MM light stack */
+#define BTA_AV_SYNC_TO_LITE_REQ 0
+#define BTA_AV_SYNC_TO_LITE_RESP 1
+#define BTA_AV_STR_START_TO_LITE_REQ 2
+#define BTA_AV_STR_START_TO_LITE_RESP 3
+#define BTA_AV_STR_STOP_TO_LITE_REQ 4
+#define BTA_AV_STR_STOP_TO_LITE_RESP 5
+#define BTA_AV_STR_CLEANUP_TO_LITE_REQ 6
+#define BTA_AV_STR_CLEANUP_TO_LITE_RESP 7
+#define BTA_AV_STR_SUSPEND_TO_LITE_REQ 8
+#define BTA_AV_STR_SUSPEND_TO_LITE_RESP 9
+#define BTA_AV_SYNC_ERROR_RESP 10
+
+/* op_code for BTC light stack */
+#define A2DP_START_REQ 11
+#define A2DP_START_RESP 12
+#define A2DP_STOP_REQ 13
+#define A2DP_STOP_RESP 14
+#define A2DP_CLEANUP_REQ 15
+#define A2DP_CLEANUP_RESP 16
+#define A2DP_SUSPEND_REQ 17
+#define A2DP_SUSPEND_RESP 18
+
+#define A2DP_JITTER_DONE_IND 41 /* For BTSNK */
+
+#define AUDIO_CODEC_CONFIG_REQ 19
+#define AUDIO_CODEC_CONFIG_RESP 20
+#define AUDIO_CODEC_SET_BITRATE_REQ 21
+#define AUDIO_CODEC_FLUSH_REQ 22
+#define AUDIO_ROUTE_CONFIG_REQ 23
+#define AUDIO_ROUTE_CONFIG_RESP 24
+#define AUDIO_MIX_CONFIG_REQ 25
+#define AUDIO_MIX_CONFIG_RESP 26
+#define AUDIO_BURST_FRAMES_IND 27
+#define AUDIO_BURST_END_IND 28
+#define AUDIO_EQ_MODE_CONFIG_REQ 29
+#define AUDIO_SCALE_CONFIG_REQ 30
+
+/* For TIVO, only applicable for I2S -> DAC */
+#define AUDIO_SUB_ROUTE_REQ 51
+#define AUDIO_SUB_ROUTE_RESP 52
+
+typedef struct
+{
+ UINT8 opcode; /* A2DP_START_REQ */
+ UINT16 lcid;
+ UINT16 curr_mtu;
+}tA2DP_START_REQ;
+
+typedef struct
+{
+ UINT8 opcode; /* A2DP_STOP_REQ */
+ UINT16 lcid;
+}tA2DP_STOP_REQ;
+
+typedef struct
+{
+ UINT8 opcode; /* A2DP_SUSPEND_REQ */
+ UINT16 lcid;
+}tA2DP_SUSPEND_REQ;
+
+typedef struct
+{
+ UINT8 opcode; /* A2DP_CLEANUP_REQ */
+ UINT16 lcid;
+ UINT16 curr_mtu;
+} tA2DP_CLEANUP_REQ;
+
+typedef struct
+{
+ UINT8 opcode; /* A2DP_START_RESP, A2DP_STOP_RESP, A2DP_CLEANUP_RESP, A2DP_SUSPEND_RESP */
+ UINT16 lcid;
+}tA2DP_GENERIC_RESP;
+
+#define AUDIO_CODEC_NONE 0x0000
+#define AUDIO_CODEC_SBC_ENC 0x0001
+#define AUDIO_CODEC_SBC_DEC 0x0002
+#define AUDIO_CODEC_MP3_ENC 0x0004
+#define AUDIO_CODEC_MP3_DEC 0x0008
+#define AUDIO_CODEC_AAC_ENC 0x0010
+#define AUDIO_CODEC_AAC_DEC 0x0020
+#define AUDIO_CODEC_AAC_PLUS_ENC 0x0040
+#define AUDIO_CODEC_AAC_PLUS_DEC 0x0080
+#define AUDIO_CODEC_MP2_ENC 0x0100
+#define AUDIO_CODEC_MP2_DEC 0x0200
+#define AUDIO_CODEC_MP2_5_ENC 0x0400
+#define AUDIO_CODEC_MP2_5_DEC 0x0800
+
+typedef UINT16 tAUDIO_CODEC_TYPE;
+
+/* SBC CODEC Parameters */
+
+#define CODEC_INFO_SBC_SF_16K 0x00
+#define CODEC_INFO_SBC_SF_32K 0x01
+#define CODEC_INFO_SBC_SF_44K 0x02
+#define CODEC_INFO_SBC_SF_48K 0x03
+
+#define CODEC_INFO_SBC_BLOCK_4 0x00
+#define CODEC_INFO_SBC_BLOCK_8 0x01
+#define CODEC_INFO_SBC_BLOCK_12 0x02
+#define CODEC_INFO_SBC_BLOCK_16 0x03
+
+#define CODEC_INFO_SBC_CH_MONO 0x00
+#define CODEC_INFO_SBC_CH_DUAL 0x01
+#define CODEC_INFO_SBC_CH_STEREO 0x02
+#define CODEC_INFO_SBC_CH_JS 0x03
+
+#define CODEC_INFO_SBC_ALLOC_LOUDNESS 0x00
+#define CODEC_INFO_SBC_ALLOC_SNR 0x01
+
+#define CODEC_INFO_SBC_SUBBAND_4 0x00
+#define CODEC_INFO_SBC_SUBBAND_8 0x01
+
+/* MPEG audio version ID */
+#define CODEC_INFO_MP25_ID 0x00
+#define CODEC_INFO_RESERVE 0x01
+#define CODEC_INFO_MP2_ID 0x02
+#define CODEC_INFO_MP3_ID 0x03
+
+#define CODEC_INFO_MP3_PROTECTION_ON 0x00
+#define CODEC_INFO_MP3_PROTECTION_OFF 0x01
+
+#define CODEC_INFO_MP3_BR_IDX_FREE 0x00
+#define CODEC_INFO_MP3_BR_IDX_32K 0x01
+#define CODEC_INFO_MP3_BR_IDX_40K 0x02
+#define CODEC_INFO_MP3_BR_IDX_48K 0x03
+#define CODEC_INFO_MP3_BR_IDX_56K 0x04
+#define CODEC_INFO_MP3_BR_IDX_64K 0x05
+#define CODEC_INFO_MP3_BR_IDX_80K 0x06
+#define CODEC_INFO_MP3_BR_IDX_96K 0x07
+#define CODEC_INFO_MP3_BR_IDX_112K 0x08
+#define CODEC_INFO_MP3_BR_IDX_128K 0x09
+#define CODEC_INFO_MP3_BR_IDX_160K 0x0A
+#define CODEC_INFO_MP3_BR_IDX_192K 0x0B
+#define CODEC_INFO_MP3_BR_IDX_224K 0x0C
+#define CODEC_INFO_MP3_BR_IDX_256K 0x0D
+#define CODEC_INFO_MP3_BR_IDX_320K 0x0E
+
+#define CODEC_INFO_MP3_SF_44K 0x00
+#define CODEC_INFO_MP3_SF_48K 0x01
+#define CODEC_INFO_MP3_SF_32K 0x02
+
+#define CODEC_INFO_MP3_MODE_STEREO 0x00
+#define CODEC_INFO_MP3_MODE_JS 0x01
+#define CODEC_INFO_MP3_MODE_DUAL 0x02
+#define CODEC_INFO_MP3_MODE_SINGLE 0x03
+
+/* layer 3, type of joint stereo coding method (intensity and ms) */
+#define CODEC_INFO_MP3_MODE_EXT_OFF_OFF 0x00
+#define CODEC_INFO_MP3_MODE_EXT_ON_OFF 0x01
+#define CODEC_INFO_MP3_MODE_EXT_OFF_ON 0x02
+#define CODEC_INFO_MP3_MODE_EXT_ON_ON 0x03
+
+
+#define CODEC_INFO_MP2_PROTECTION_ON 0x00
+#define CODEC_INFO_MP2_PROTECTION_OFF 0x01
+
+#define CODEC_INFO_MP2_BR_IDX_FREE 0x00
+#define CODEC_INFO_MP2_BR_IDX_8K 0x01
+#define CODEC_INFO_MP2_BR_IDX_16K 0x02
+#define CODEC_INFO_MP2_BR_IDX_24K 0x03
+#define CODEC_INFO_MP2_BR_IDX_32K 0x04
+#define CODEC_INFO_MP2_BR_IDX_40K 0x05
+#define CODEC_INFO_MP2_BR_IDX_48K 0x06
+#define CODEC_INFO_MP2_BR_IDX_56K 0x07
+#define CODEC_INFO_MP2_BR_IDX_64K 0x08
+#define CODEC_INFO_MP2_BR_IDX_80K 0x09
+#define CODEC_INFO_MP2_BR_IDX_96K 0x0A
+#define CODEC_INFO_MP2_BR_IDX_112K 0x0B
+#define CODEC_INFO_MP2_BR_IDX_128K 0x0C
+#define CODEC_INFO_MP2_BR_IDX_144K 0x0D
+#define CODEC_INFO_MP2_BR_IDX_160K 0x0E
+
+#define CODEC_INFO_MP2_SF_22K 0x00
+#define CODEC_INFO_MP2_SF_24K 0x01
+#define CODEC_INFO_MP2_SF_16K 0x02
+
+#define CODEC_INFO_MP2_MODE_STEREO 0x00
+#define CODEC_INFO_MP2_MODE_JS 0x01
+#define CODEC_INFO_MP2_MODE_DUAL 0x02
+#define CODEC_INFO_MP2_MODE_SINGLE 0x03
+
+/* layer 3, type of joint stereo coding method (intensity and ms) */
+#define CODEC_INFO_MP2_MODE_EXT_OFF_OFF 0x00
+#define CODEC_INFO_MP2_MODE_EXT_ON_OFF 0x01
+#define CODEC_INFO_MP2_MODE_EXT_OFF_ON 0x02
+#define CODEC_INFO_MP2_MODE_EXT_ON_ON 0x03
+
+#define CODEC_INFO_MP2_SAMPLE_PER_FRAME 576
+
+/* mpeg 2.5 layer 3 decoder */
+
+#define CODEC_INFO_MP25_PROTECTION_ON 0x00
+#define CODEC_INFO_MP25_PROTECTION_OFF 0x01
+
+#define CODEC_INFO_MP25_BR_IDX_FREE 0x00
+#define CODEC_INFO_MP25_BR_IDX_8K 0x01
+#define CODEC_INFO_MP25_BR_IDX_16K 0x02
+#define CODEC_INFO_MP25_BR_IDX_24K 0x03
+#define CODEC_INFO_MP25_BR_IDX_32K 0x04
+#define CODEC_INFO_MP25_BR_IDX_40K 0x05
+#define CODEC_INFO_MP25_BR_IDX_48K 0x06
+#define CODEC_INFO_MP25_BR_IDX_56K 0x07
+#define CODEC_INFO_MP25_BR_IDX_64K 0x08
+#define CODEC_INFO_MP25_BR_IDX_80K 0x09
+#define CODEC_INFO_MP25_BR_IDX_96K 0x0A
+#define CODEC_INFO_MP25_BR_IDX_112K 0x0B
+#define CODEC_INFO_MP25_BR_IDX_128K 0x0C
+#define CODEC_INFO_MP25_BR_IDX_144K 0x0D
+#define CODEC_INFO_MP25_BR_IDX_160K 0x0E
+
+#define CODEC_INFO_MP25_SF_11K 0x00
+#define CODEC_INFO_MP25_SF_12K 0x01
+#define CODEC_INFO_MP25_SF_8K 0x02
+
+#define CODEC_INFO_MP25_MODE_STEREO 0x00
+#define CODEC_INFO_MP25_MODE_JS 0x01
+#define CODEC_INFO_MP25_MODE_DUAL 0x02
+#define CODEC_INFO_MP25_MODE_SINGLE 0x03
+
+/* layer 3, type of joint stereo coding method (intensity and ms) */
+#define CODEC_INFO_MP25_MODE_EXT_OFF_OFF 0x00
+#define CODEC_INFO_MP25_MODE_EXT_ON_OFF 0x01
+#define CODEC_INFO_MP25_MODE_EXT_OFF_ON 0x02
+#define CODEC_INFO_MP25_MODE_EXT_ON_ON 0x03
+
+#define CODEC_INFO_MP25_SAMPLE_PER_FRAME 576
+
+/* AAC/AAC+ CODEC Parameters */
+#define CODEC_INFO_AAC_SF_IDX_96K 0x0
+#define CODEC_INFO_AAC_SF_IDX_88K 0x1
+#define CODEC_INFO_AAC_SF_IDX_64K 0x2
+#define CODEC_INFO_AAC_SF_IDX_48K 0x3
+#define CODEC_INFO_AAC_SF_IDX_44K 0x4
+#define CODEC_INFO_AAC_SF_IDX_32K 0x5
+#define CODEC_INFO_AAC_SF_IDX_24K 0x6
+#define CODEC_INFO_AAC_SF_IDX_22K 0x7
+#define CODEC_INFO_AAC_SF_IDX_16K 0x8
+#define CODEC_INFO_AAC_SF_IDX_12K 0x9
+#define CODEC_INFO_AAC_SF_IDX_11K 0xA
+#define CODEC_INFO_AAC_SF_IDX_08K 0xB
+#define CODEC_INFO_AAC_SF_IDX_RESERVE 0xC
+
+#define CODEC_INFO_AAC_BR_RATE_48K 288000
+#define CODEC_INFO_AAC_BR_RATE_44K 264600
+#define CODEC_INFO_AAC_BR_RATE_32K 192000
+
+
+#define CODEC_INFO_AAC_1_CH 1 /*center front speaker */
+#define CODEC_INFO_AAC_2_CH 2 /*left, right front speaker */
+#define CODEC_INFO_AAC_3_CH 3 /*center front speaker, left right front speaker */
+#define CODEC_INFO_AAC_4_CH 4 /*center/rear front speaker, left/right front speaker */
+#define CODEC_INFO_AAC_5_CH 5 /*center, left, right front speaker, left/right surround */
+#define CODEC_INFO_AAC_6_CH 6 /*center, left, right front speaker, left/right surround, LFE */
+#define CODEC_INFO_AAC_7_CH 7 /*(left, right)center/left,right front speaker, left/right surround, LFE */
+
+
+typedef struct
+{
+ UINT8 sampling_freq;
+ UINT8 channel_mode;
+ UINT8 block_length;
+ UINT8 num_subbands;
+ UINT8 alloc_method;
+ UINT8 bitpool_size; /* 2 - 250 */
+} tCODEC_INFO_SBC;
+
+typedef struct
+{
+ UINT8 ch_mode;
+ UINT8 sampling_freq;
+ UINT8 bitrate_index; /* 0 - 14 */
+} tCODEC_INFO_MP3;
+
+typedef struct
+{
+ UINT8 ch_mode;
+ UINT8 sampling_freq;
+ UINT8 bitrate_index; /* 0 - 14 */
+} tCODEC_INFO_MP2;
+
+
+typedef struct
+{
+ UINT8 ch_mode;
+ UINT8 sampling_freq;
+ UINT8 bitrate_index; /* 0 - 14 */
+} tCODEC_INFO_MP2_5;
+
+typedef struct
+{
+ UINT16 sampling_freq;
+ UINT8 channel_mode; /* 0x02:mono, 0x01:dual */
+ UINT32 bitrate; /* 0 - 320K */
+ UINT32 sbr_profile; /* 1: ON, 0: OFF */
+} tCODEC_INFO_AAC;
+
+typedef union
+{
+ tCODEC_INFO_SBC sbc;
+ tCODEC_INFO_MP3 mp3;
+ tCODEC_INFO_MP2 mp2;
+ tCODEC_INFO_MP2_5 mp2_5;
+ tCODEC_INFO_AAC aac;
+} tCODEC_INFO;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_CODEC_CONFIG_REQ */
+ tAUDIO_CODEC_TYPE codec_type;
+ tCODEC_INFO codec_info;
+} tAUDIO_CODEC_CONFIG_REQ;
+
+#define AUDIO_CONFIG_SUCCESS 0x00
+#define AUDIO_CONFIG_NOT_SUPPORTED 0x01
+#define AUDIO_CONFIG_FAIL_OUT_OF_MEMORY 0x02
+#define AUDIO_CONFIG_FAIL_CODEC_USED 0x03
+#define AUDIO_CONFIG_FAIL_ROUTE 0x04
+typedef UINT8 tAUDIO_CONFIG_STATUS;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_CODEC_CONFIG_RESP */
+ tAUDIO_CONFIG_STATUS status;
+} tAUDIO_CODEC_CONFIG_RESP;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_CODEC_SET_BITRATE_REQ */
+ tAUDIO_CODEC_TYPE codec_type;
+ union
+ {
+ UINT8 sbc;
+ UINT8 mp3;
+ UINT32 aac;
+ } codec_bitrate;
+} tAUDIO_CODEC_SET_BITRATE_REQ;
+
+#define AUDIO_ROUTE_SRC_FMRX 0x00
+#define AUDIO_ROUTE_SRC_I2S 0x01
+#define AUDIO_ROUTE_SRC_ADC 0x02
+#define AUDIO_ROUTE_SRC_HOST 0x03
+#define AUDIO_ROUTE_SRC_PTU 0x04
+#define AUDIO_ROUTE_SRC_BTSNK 0x05
+#define AUDIO_ROUTE_SRC_NONE 0x80
+#define MAX_AUDIO_ROUTE_SRC 6
+typedef UINT8 tAUDIO_ROUTE_SRC;
+
+#define AUDIO_ROUTE_MIX_NONE 0x00
+#define AUDIO_ROUTE_MIX_HOST 0x01
+#define AUDIO_ROUTE_MIX_PCM 0x02
+#define AUDIO_ROUTE_MIX_CHIRP 0x03
+#define AUDIO_ROUTE_MIX_I2S 0x04
+#define AUDIO_ROUTE_MIX_ADC 0x05
+#define AUDIO_ROUTE_MIX_RESERVED 0x06
+#define MAX_AUDIO_ROUTE_MIX 7
+typedef UINT8 tAUDIO_ROUTE_MIX;
+
+#define AUDIO_ROUTE_OUT_NONE 0x0000
+#define AUDIO_ROUTE_OUT_BTA2DP 0x0001
+#define AUDIO_ROUTE_OUT_FMTX 0x0002
+#define AUDIO_ROUTE_OUT_BTSCO 0x0004
+#define AUDIO_ROUTE_OUT_HOST 0x0008
+#define AUDIO_ROUTE_OUT_DAC 0x0010
+#define AUDIO_ROUTE_OUT_I2S 0x0020
+#define AUDIO_ROUTE_OUT_BTA2DP_DAC 0x0040
+#define AUDIO_ROUTE_OUT_BTA2DP_I2S 0x0080
+#define AUDIO_ROUTE_OUT_BTSCO_DAC 0x0100
+#define AUDIO_ROUTE_OUT_BTSCO_I2S 0x0200
+#define AUDIO_ROUTE_OUT_HOST_BTA2DP 0x0400
+#define AUDIO_ROUTE_OUT_HOST_BTSCO 0x0800
+#define AUDIO_ROUTE_OUT_HOST_DAC 0x1000
+#define AUDIO_ROUTE_OUT_HOST_I2S 0x2000
+#define AUDIO_ROUTE_OUT_DAC_I2S 0x4000
+#define AUDIO_ROUTE_OUT_RESERVED_2 0x8000
+
+#define MAX_AUDIO_SINGLE_ROUTE_OUT 6
+#define MAX_AUDIO_MULTI_ROUTE_OUT 16
+typedef UINT16 tAUDIO_MULTI_ROUTE_OUT;
+typedef UINT8 tAUDIO_ROUTE_OUT;
+
+#define AUDIO_ROUTE_SF_8K 0x00
+#define AUDIO_ROUTE_SF_16K 0x01
+#define AUDIO_ROUTE_SF_32K 0x02
+#define AUDIO_ROUTE_SF_44_1K 0x03
+#define AUDIO_ROUTE_SF_48K 0x04
+#define AUDIO_ROUTE_SF_11K 0x05
+#define AUDIO_ROUTE_SF_12K 0x06
+#define AUDIO_ROUTE_SF_22K 0x07
+#define AUDIO_ROUTE_SF_24K 0x08
+#define AUDIO_ROUTE_SF_NA 0xFF
+typedef UINT8 tAUDIO_ROUTE_SF;
+
+#define AUDIO_ROUTE_EQ_BASS_BOOST 0x00
+#define AUDIO_ROUTE_EQ_CLASSIC 0x01
+#define AUDIO_ROUTE_EQ_JAZZ 0x02
+#define AUDIO_ROUTE_EQ_LIVE 0x03
+#define AUDIO_ROUTE_EQ_NORMAL 0x04
+#define AUDIO_ROUTE_EQ_ROCK 0x05
+#define AUDIO_ROUTE_EQ_BYPASS 0x06
+
+#define AUDIO_ROUTE_DIGITAL_VOLUME_CONTROL 0x07
+
+#define AUDIO_ROUTE_EQ_CONFIG_GAIN 0xFF /* Custion Gain Config */
+typedef UINT8 tAUDIO_ROUTE_EQ;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_ROUTE_CONFIG_REQ */
+ tAUDIO_ROUTE_SRC src;
+ tAUDIO_ROUTE_SF src_sf;
+ tAUDIO_ROUTE_OUT out;
+ tAUDIO_ROUTE_SF out_codec_sf;
+ tAUDIO_ROUTE_SF out_i2s_sf;
+ tAUDIO_ROUTE_EQ eq_mode;
+} tAUDIO_ROUTE_CONFIG_REQ;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_ROUTE_CONFIG_RESP */
+ tAUDIO_CONFIG_STATUS status;
+} tAUDIO_ROUTE_CONFIG_RESP;
+
+typedef struct
+{
+ UINT16 amp[2]; /* left/right 15 bit amplitude value */
+ UINT16 tone[2]; /* left/right 12 bit frequency 0 - 4096Hz */
+ UINT16 mark[2]; /* left/right 16 bit mark time 0 - 65535ms */
+ UINT16 space[2]; /* left/right 16 bit space time 0 - 65535ms */
+} tCHIRP_CONFIG;
+
+typedef struct
+{
+ UINT8 pri_l; /* Primary Left scale : 0 ~ 255 */
+ UINT8 mix_l; /* Mixing Left scale : 0 ~ 255 */
+ UINT8 pri_r; /* Primary Right scale : 0 ~ 255 */
+ UINT8 mix_r; /* Mixing Right scale : 0 ~ 255 */
+} tMIX_SCALE_CONFIG;
+
+/* For custon equalizer gain configuration */
+typedef struct
+{
+ UINT32 audio_l_g0; /* IIR biquad filter left ch gain 0 */
+ UINT32 audio_l_g1; /* IIR biquad filter left ch gain 1 */
+ UINT32 audio_l_g2; /* IIR biquad filter left ch gain 2 */
+ UINT32 audio_l_g3; /* IIR biquad filter left ch gain 3 */
+ UINT32 audio_l_g4; /* IIR biquad filter left ch gain 4 */
+ UINT32 audio_l_gl; /* IIR biquad filter left ch global gain */
+ UINT32 audio_r_g0; /* IIR biquad filter left ch gain 0 */
+ UINT32 audio_r_g1; /* IIR biquad filter left ch gain 1 */
+ UINT32 audio_r_g2; /* IIR biquad filter left ch gain 2 */
+ UINT32 audio_r_g3; /* IIR biquad filter left ch gain 3 */
+ UINT32 audio_r_g4; /* IIR biquad filter left ch gain 4 */
+ UINT32 audio_r_gl; /* IIR biquad filter left ch global gain */
+} tEQ_GAIN_CONFIG;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_MIX_CONFIG_REQ */
+ tAUDIO_ROUTE_MIX mix_src;
+ tAUDIO_ROUTE_SF mix_src_sf;
+ tMIX_SCALE_CONFIG mix_scale;
+ tCHIRP_CONFIG chirp_config;
+} tAUDIO_MIX_CONFIG_REQ;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_MIX_CONFIG_RESP */
+ tAUDIO_CONFIG_STATUS status;
+} tAUDIO_MIX_CONFIG_RESP;
+
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_BURST_FRAMES_IND */
+ UINT32 burst_size; /* in bytes */
+} tAUDIO_BURST_FRAMES_IND;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_BURST_END_IND */
+} tAUDIO_BURST_END_IND;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_CODEC_FLUSH_REQ */
+} tAUDIO_CODEC_FLUSH_REQ;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_EQ_MODE_CONFIG_REQ */
+ tAUDIO_ROUTE_EQ eq_mode;
+ tEQ_GAIN_CONFIG filter_gain; /* Valid only when eq_mode is 0xFF */
+} tAUDIO_EQ_MODE_CONFIG_REQ;
+
+typedef struct
+{
+ UINT8 opcode; /* AUDIO_SCALE_CONFIG_REQ */
+ tMIX_SCALE_CONFIG mix_scale;
+} tAUDIO_SCALE_CONFIG_REQ;
+
+typedef UINT8 tBTA_AV_DUAL_STACK_EVT;
+
+typedef struct
+{
+ UINT8 avdt_handle; /* AVDTP handle */
+ UINT8 chnl; /* the channel: audio/video */
+ UINT8 codec_type; /* codec type */
+ BOOLEAN cong; /* TRUE if AVDTP congested */
+ UINT8 hdi; /* the index to SCB[] */
+ UINT8 hndl; /* the handle: ((hdi + 1)|chnl) */
+ UINT8 l2c_bufs; /* the number of buffers queued to L2CAP */
+ UINT16 l2c_cid; /* L2CAP channel ID */
+ BD_ADDR peer_addr; /* peer BD address */
+}tBTA_AV_SYNC_INFO;
+
+typedef struct
+{
+ tBTA_AV_DUAL_STACK_EVT event;
+ tBTA_AV_SYNC_INFO sync_info;
+ UINT16 curr_mtu; /* common mtu shared by all active streams */
+ UINT8 multi_av_supported; /* Whether multi-av is supported */
+}tBTA_AV_SYNC_INFO_REQ; /* SYNC_TO_LITE_REQ */
+
+/* Dual stack stream events */
+typedef struct
+{
+ tBTA_AV_DUAL_STACK_EVT event;
+ UINT8 scb_idx;
+}tBTA_AV_SCB_EVT;
+
+/* data type for the Audio Codec Information*/
+typedef struct
+{
+ UINT16 bit_rate; /* SBC encoder bit rate in kbps */
+ UINT16 bit_rate_busy; /* SBC encoder bit rate in kbps */
+ UINT16 bit_rate_swampd; /* SBC encoder bit rate in kbps */
+ UINT8 busy_level; /* Busy level indicating the bit-rate to be used */
+ UINT8 codec_info[AVDT_CODEC_SIZE];
+ UINT8 codec_type; /* Codec type */
+} tBTA_AV_AUDIO_CODEC_SYNC_INFO;
+
+/* Dual stack stream events */
+typedef struct
+{
+ tBTA_AV_DUAL_STACK_EVT event;
+ UINT8 scb_idx;
+ UINT8 audio_open_cnt;
+ tBTA_AV_AUDIO_CODEC_SYNC_INFO p_codec_cfg;
+ UINT8 start_stop_flag;
+}tBTA_AV_SCB_REQ;
+
+typedef struct
+{
+ tBTA_AV_DUAL_STACK_EVT event;
+ UINT8 scb_idx;
+ UINT8 audio_open_cnt;
+ UINT16 curr_mtu; /* common mtu shared by all active streams */
+}tBTA_AV_SCB_CLEANUP_REQ;
+
+/* Add request/response structures if needed ...
+typedef struct
+{
+ event;
+ data;
+}tBTA_AV_SYNC_*_REQ/RESP;
+*/
+
+typedef union
+{
+ /* MM light stack */
+ tBTA_AV_DUAL_STACK_EVT event;
+ tBTA_AV_SYNC_INFO_REQ sync_info_req;
+ tBTA_AV_SCB_EVT scb_evt;
+ tBTA_AV_SCB_REQ scb_req;
+ tBTA_AV_SCB_CLEANUP_REQ scb_cleanup_req;
+
+ /* BTC light stack */
+ UINT8 opcode;
+ tA2DP_START_REQ btc_start_req;
+ tA2DP_STOP_REQ btc_stop_req;
+ tA2DP_CLEANUP_REQ btc_cleanup_req;
+ tA2DP_SUSPEND_REQ btc_suspend_req;
+
+ tAUDIO_CODEC_CONFIG_REQ codec_config_req;
+ tAUDIO_CODEC_SET_BITRATE_REQ codec_bitrate_req;
+ tAUDIO_CODEC_FLUSH_REQ codec_flush_req;
+ tAUDIO_ROUTE_CONFIG_REQ route_config_req;
+ tAUDIO_MIX_CONFIG_REQ mix_config_req;
+ tAUDIO_EQ_MODE_CONFIG_REQ eq_mode_req;
+ tAUDIO_SCALE_CONFIG_REQ scale_config_req;
+}tBTA_DUAL_STACK_MSG;
+
+#endif /* UIPC_MSG_H */
diff --git a/stack/include/utfc.h b/stack/include/utfc.h
new file mode 100644
index 0000000..787efe8
--- /dev/null
+++ b/stack/include/utfc.h
@@ -0,0 +1,61 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * UTF conversion utilities.
+ *
+ ******************************************************************************/
+#ifndef UTFC_H
+#define UTFC_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function utfc_16_to_8
+**
+** Description Convert a UTF-16 array to a null-terminated UTF-8 string.
+** Illegal characters are skipped.
+**
+** Returns Length of UTF-8 string in bytes.
+**
+*******************************************************************************/
+extern UINT16 utfc_16_to_8(UINT8 *p_utf8, UINT16 utf8_len, UINT16 *p_utf16, UINT16 utf16_len);
+
+/*******************************************************************************
+**
+** Function utfc_8_to_16
+**
+** Description Convert a null-terminated UTF-8 string to a UTF-16 array.
+** Illegal characters are skipped. The UTF-16 array is
+** appended with a zero (null) character.
+**
+** Returns Length of UTF-16 array including null character.
+**
+*******************************************************************************/
+extern UINT16 utfc_8_to_16(UINT16 *p_utf16, UINT16 utf16_len, UINT8 *p_utf8);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* UTFC_H */
diff --git a/stack/include/wbt_api.h b/stack/include/wbt_api.h
new file mode 100644
index 0000000..8bfb772
--- /dev/null
+++ b/stack/include/wbt_api.h
@@ -0,0 +1,71 @@
+/******************************************************************************
+ *
+ * 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 file contains definitions and constants used by the Broadcom
+ * Bluetooth Extensions API software.
+ *
+ ******************************************************************************/
+#ifndef WBT_API_H
+#define WBT_API_H
+
+#include "bt_target.h"
+
+/*****************************************************************************
+** Constants and Types
+*****************************************************************************/
+
+/**************************
+* SDP Attribute IDs *
+***************************/
+#define ATTR_ID_EXT_BRCM_VERSION 0x8001 /* UINT16 (0xmmnn - major, minor [0x0001]) mandatory */
+#define ATTR_ID_EXT_PIN_CODE 0x8002 /* UINT32 4 - digit pin */
+
+/**************************
+* SDP Attribute ID Values *
+***************************/
+/* Version Attribute Value */
+#define BRCM_EXT_VERSION 0x0001 /* UINT16 (0xmmnn - major, minor [0x0001]) mandatory */
+
+/* Pin Code Attribute Value */
+#define BRCM_EXT_PIN_CODE 0x00000000 /* UINT32 ('0000') */
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+BT_API extern BOOLEAN WBT_ExtCreateRecord(void);
+
+/*** Features ***/
+BT_API extern BOOLEAN WBT_ExtAddPinCode(void);
+
+
+BT_API extern UINT32 wbt_sdp_show_ext(UINT8 scn, char *service_name,
+ UINT8 pin_code_ext,
+ UINT8 active_sync_ext);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WBT_API_H */
diff --git a/stack/include/wcassert.h b/stack/include/wcassert.h
new file mode 100644
index 0000000..a1d7b47
--- /dev/null
+++ b/stack/include/wcassert.h
@@ -0,0 +1,65 @@
+/******************************************************************************
+ *
+ * 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 WC_ASSERT_H
+#define WC_ASSERT_H
+
+
+#ifdef _DEBUG
+
+#include "bt_target.h"
+
+
+
+/* debug settings*/
+#ifndef WC_DEBUG_LEVEL
+#define WC_DEBUG_LEVEL 0
+#endif
+
+#if WC_DEBUG_LEVEL == 0
+
+#include "stdio.h" /* for printf()*/
+
+#ifdef __cplusplus
+extern "C" wc_assert(char *message, char *file, UINT32 line);
+#else
+void wc_assert(char *message, char *file, UINT32 line);
+#endif
+
+#define WC_ASSERT(_x) if ( !(_x) ) wc_assert("ASSERT at %s line %d\n", __FILE__, __LINE__);
+#define WC_ASSERT_ALWAYS() wc_assert("ASSERT! at %s line %d\n", __FILE__, __LINE__);
+
+#elif WC_DEBUG_LEVEL == 1
+
+#include "assert.h"
+
+#define WC_ASSERT(_x) assert(_x);
+#define WC_ASSERT_ALWAYS() assert(0);
+#endif /* WC_DEBUG_LEVEL*/
+
+#else /* _DEBUG*/
+
+#ifndef WC_ASSERT
+#define WC_ASSERT(_x) ;
+#endif
+
+#ifndef WC_ASSERT_ALWAYS
+#define WC_ASSERT_ALWAYS() ;
+#endif
+
+#endif /* _DEBUG*/
+#endif /* WC_ASSERT_H*/