Update IDF to 65acd99 (#358)

* Update IDF to 65acd99

* Update platformio and arduino build paths and libs

* Update esptool binaries
This commit is contained in:
Me No Dev
2017-05-06 20:29:12 +03:00
committed by GitHub
parent 450df7e3f8
commit 376961d168
221 changed files with 14441 additions and 523 deletions

View File

@ -0,0 +1,255 @@
/******************************************************************************
*
* 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"
#if (A2D_INCLUDED == TRUE)
/*****************************************************************************
** 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.
**
******************************************************************************/
extern tA2D_STATUS A2D_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_provider_name,
UINT16 features, UINT32 sdp_handle);
/******************************************************************************
**
** Function A2D_FindService
**
** Description This function is called by a client application to
** perform service discovery and retrieve SRC or SNK SDP
** record information from a server. Information is
** returned for the first service record found on the
** server that matches the service UUID. The callback
** function will be executed when service discovery is
** complete. There can only be one outstanding call to
** A2D_FindService() at a time; the application must wait
** for the callback before it makes another call to
** the function.
**
** Input Parameters:
** service_uuid: Indicates SRC or SNK.
**
** bd_addr: BD address of the peer device.
**
** p_db: Pointer to the information to initialize
** the discovery database.
**
** p_cback: Pointer to the A2D_FindService()
** callback function.
**
** Output Parameters:
** None.
**
** Returns A2D_SUCCESS if function execution succeeded,
** A2D_INVALID_PARAMS if bad parameters are given.
** A2D_BUSY if discovery is already in progress.
** A2D_FAIL if function execution failed.
**
******************************************************************************/
extern tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
tA2D_SDP_DB_PARAMS *p_db, tA2D_FIND_CBACK *p_cback);
/******************************************************************************
**
** Function A2D_SetTraceLevel
**
** Description Sets the trace level for A2D. If 0xff is passed, the
** current trace level is returned.
**
** Input Parameters:
** new_level: The level to set the A2D tracing to:
** 0xff-returns the current setting.
** 0-turns off tracing.
** >= 1-Errors.
** >= 2-Warnings.
** >= 3-APIs.
** >= 4-Events.
** >= 5-Debug.
**
** Returns The new trace level or current trace level if
** the input parameter is 0xff.
**
******************************************************************************/
extern UINT8 A2D_SetTraceLevel (UINT8 new_level);
/******************************************************************************
** Function A2D_BitsSet
**
** Description Check the given num for the number of bits set
** Returns A2D_SET_ONE_BIT, if one and only one bit is set
** A2D_SET_ZERO_BIT, if all bits clear
** A2D_SET_MULTL_BIT, if multiple bits are set
******************************************************************************/
extern UINT8 A2D_BitsSet(UINT8 num);
#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
**
*******************************************************************************/
extern void A2D_Init(void);
#endif ///A2D_INCLUDED
#endif /* A2D_API_H */

View File

@ -0,0 +1,81 @@
/******************************************************************************
*
* 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.
*
******************************************************************************/
/******************************************************************************
*
* 2DP internal header file
*
******************************************************************************/
#ifndef A2D_INT_H
#define A2D_INT_H
#include "a2d_api.h"
#if (A2D_INCLUDED == TRUE)
/*****************************************************************************
** Constants
*****************************************************************************/
#define A2D_VERSION 0x0102
/* Number of attributes in A2D SDP record. */
#define A2D_NUM_ATTR 6
/* Number of protocol elements in protocol element list. */
#define A2D_NUM_PROTO_ELEMS 2
/*****************************************************************************
** Type definitions
*****************************************************************************/
/* Control block used by A2D_FindService(). */
typedef struct {
tA2D_FIND_CBACK *p_cback; /* pointer to application callback */
tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */
UINT16 service_uuid; /* service UUID of search */
} tA2D_FIND_CB;
typedef struct {
tA2D_FIND_CB find; /* find service control block */
UINT8 trace_level;
BOOLEAN use_desc;
UINT16 avdt_sdp_ver; /* AVDTP version */
} tA2D_CB;
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************************************
** Main Control Block
*******************************************************************************/
#if A2D_DYNAMIC_MEMORY == FALSE
extern tA2D_CB a2d_cb;
#else
extern tA2D_CB *a2d_cb_ptr;
#define a2d_cb (*a2d_cb_ptr)
#endif
/* Used only for conformance testing */
extern void a2d_set_avdt_sdp_ver (UINT16 avdt_sdp_ver);
#ifdef __cplusplus
}
#endif
#endif ///A2D_INCLUDED == TRUE
#endif /* A2D_INT_H */

View File

@ -0,0 +1,213 @@
/******************************************************************************
*
* Copyright (C) 2000-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/******************************************************************************
*
* nterface to low complexity subband codec (SBC)
*
******************************************************************************/
#ifndef A2D_SBC_H
#define A2D_SBC_H
#if (A2D_INCLUDED == TRUE)
/*****************************************************************************
** Constants
*****************************************************************************/
/* the length of the SBC Media Payload header. */
#define A2D_SBC_MPL_HDR_LEN 1
/* the LOSC of SBC media codec capabilitiy */
#define A2D_SBC_INFO_LEN 6
/* for Codec Specific Information Element */
#define A2D_SBC_IE_SAMP_FREQ_MSK 0xF0 /* b7-b4 sampling frequency */
#define A2D_SBC_IE_SAMP_FREQ_16 0x80 /* b7:16 kHz */
#define A2D_SBC_IE_SAMP_FREQ_32 0x40 /* b6:32 kHz */
#define A2D_SBC_IE_SAMP_FREQ_44 0x20 /* b5:44.1kHz */
#define A2D_SBC_IE_SAMP_FREQ_48 0x10 /* b4:48 kHz */
#define A2D_SBC_IE_CH_MD_MSK 0x0F /* b3-b0 channel mode */
#define A2D_SBC_IE_CH_MD_MONO 0x08 /* b3: mono */
#define A2D_SBC_IE_CH_MD_DUAL 0x04 /* b2: dual */
#define A2D_SBC_IE_CH_MD_STEREO 0x02 /* b1: stereo */
#define A2D_SBC_IE_CH_MD_JOINT 0x01 /* b0: joint stereo */
#define A2D_SBC_IE_BLOCKS_MSK 0xF0 /* b7-b4 number of blocks */
#define A2D_SBC_IE_BLOCKS_4 0x80 /* 4 blocks */
#define A2D_SBC_IE_BLOCKS_8 0x40 /* 8 blocks */
#define A2D_SBC_IE_BLOCKS_12 0x20 /* 12blocks */
#define A2D_SBC_IE_BLOCKS_16 0x10 /* 16blocks */
#define A2D_SBC_IE_SUBBAND_MSK 0x0C /* b3-b2 number of subbands */
#define A2D_SBC_IE_SUBBAND_4 0x08 /* b3: 4 */
#define A2D_SBC_IE_SUBBAND_8 0x04 /* b2: 8 */
#define A2D_SBC_IE_ALLOC_MD_MSK 0x03 /* b1-b0 allocation mode */
#define A2D_SBC_IE_ALLOC_MD_S 0x02 /* b1: SNR */
#define A2D_SBC_IE_ALLOC_MD_L 0x01 /* b0: loundess */
#define A2D_SBC_IE_MIN_BITPOOL 2
#define A2D_SBC_IE_MAX_BITPOOL 250
/* for media payload header */
#define A2D_SBC_HDR_F_MSK 0x80
#define A2D_SBC_HDR_S_MSK 0x40
#define A2D_SBC_HDR_L_MSK 0x20
#define A2D_SBC_HDR_NUM_MSK 0x0F
/*****************************************************************************
** Type Definitions
*****************************************************************************/
/* data type for the SBC Codec Information Element*/
typedef struct {
UINT8 samp_freq; /* Sampling frequency */
UINT8 ch_mode; /* Channel mode */
UINT8 block_len; /* Block length */
UINT8 num_subbands; /* Number of subbands */
UINT8 alloc_mthd; /* Allocation method */
UINT8 max_bitpool; /* Maximum bitpool */
UINT8 min_bitpool; /* Minimum bitpool */
} tA2D_SBC_CIE;
/*****************************************************************************
** External Function Declarations
*****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************************************
**
** Function A2D_SbcChkFrInit
**
** Description check if need to init the descramble control block.
**
** Returns nothing.
******************************************************************************/
extern void A2D_SbcChkFrInit(UINT8 *p_pkt);
/******************************************************************************
**
** Function A2D_SbcDescramble
**
** Description descramble the packet.
**
** Returns nothing.
******************************************************************************/
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.
******************************************************************************/
extern tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie,
UINT8 *p_result);
/******************************************************************************
**
** Function A2D_ParsSbcInfo
**
** Description This function is called by an application to parse
** the SBC Media Codec Capabilities byte sequence
** beginning from the LOSC octet.
** Input Parameters:
** p_info: the byte sequence to parse.
**
** for_caps: TRUE, if the byte sequence is for get capabilities response.
**
** Output Parameters:
** p_ie: The SBC Codec Information Element information.
**
** Returns A2D_SUCCESS if function execution succeeded.
** Error status code, otherwise.
******************************************************************************/
extern tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info,
BOOLEAN for_caps);
/******************************************************************************
**
** Function A2D_BldSbcMplHdr
**
** Description This function is called by an application to parse
** the SBC Media Payload header.
** Input Parameters:
** frag: 1, if fragmented. 0, otherwise.
**
** start: 1, if the starting packet of a fragmented frame.
**
** last: 1, if the last packet of a fragmented frame.
**
** num: If frag is 1, this is the number of remaining fragments
** (including this fragment) of this frame.
** If frag is 0, this is the number of frames in this packet.
**
** Output Parameters:
** p_dst: the resulting media payload header byte sequence.
**
** Returns void.
******************************************************************************/
extern void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start,
BOOLEAN last, UINT8 num);
/******************************************************************************
**
** Function A2D_ParsSbcMplHdr
**
** Description This function is called by an application to parse
** the SBC Media Payload header.
** Input Parameters:
** p_src: the byte sequence to parse..
**
** Output Parameters:
** frag: 1, if fragmented. 0, otherwise.
**
** start: 1, if the starting packet of a fragmented frame.
**
** last: 1, if the last packet of a fragmented frame.
**
** num: If frag is 1, this is the number of remaining fragments
** (including this fragment) of this frame.
** If frag is 0, this is the number of frames in this packet.
**
** Returns void.
******************************************************************************/
extern void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag,
BOOLEAN *p_start, BOOLEAN *p_last,
UINT8 *p_num);
#ifdef __cplusplus
}
#endif
#endif ///A2D_INCLUDED == TRUE
#endif /* A2D_SBC_H */

View File

@ -26,7 +26,7 @@
typedef uint32_t period_ms_t;
typedef void (*osi_alarm_callback_t)(void *data);
#define ALARM_CBS_NUM 20
#define ALARM_CBS_NUM 30
#define ALARM_ID_BASE 1000
typedef struct alarm_t {
/* timer id point to here */

0
tools/sdk/include/bluedroid/avct_api.h Executable file → Normal file
View File

View File

@ -0,0 +1,62 @@
/******************************************************************************
*
* 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 contains constants definitions and other information from the AVCTP
* specification. This file is intended for use internal to AVCT only.
*
******************************************************************************/
#ifndef AVCT_DEFS_H
#define AVCT_DEFS_H
/*****************************************************************************
** constants
*****************************************************************************/
/* packet type */
#define AVCT_PKT_TYPE_SINGLE 0 /* single packet */
#define AVCT_PKT_TYPE_START 1 /* start packet */
#define AVCT_PKT_TYPE_CONT 2 /* continue packet */
#define AVCT_PKT_TYPE_END 3 /* end packet */
/* header lengths for different packet types */
#define AVCT_HDR_LEN_SINGLE 3
#define AVCT_HDR_LEN_START 4
#define AVCT_HDR_LEN_CONT 1
#define AVCT_HDR_LEN_END 1
/* invalid cr+ipid value */
#define AVCT_CR_IPID_INVALID 1
/*****************************************************************************
** message parsing and building macros
*****************************************************************************/
#define AVCT_BLD_HDR(p, label, type, cr_ipid) \
*(p)++ = ((label) << 4) | ((type) << 2) | (cr_ipid);
#define AVCT_PRS_HDR(p, label, type, cr_ipid) \
label = *(p) >> 4; \
type = (*(p) >> 2) & 3; \
cr_ipid = *(p)++ & 3;
#define AVCT_PRS_PKT_TYPE(p, type) \
type = (*(p) >> 2) & 3;
#endif /* AVCT_DEFS_H */

View File

@ -0,0 +1,237 @@
/******************************************************************************
*
* 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 interfaces which are internal to AVCTP.
*
******************************************************************************/
#ifndef AVCT_INT_H
#define AVCT_INT_H
#include "gki.h"
#include "avct_api.h"
#include "avct_defs.h"
#include "l2c_api.h"
/*****************************************************************************
** constants
*****************************************************************************/
/* lcb state machine events */
enum {
AVCT_LCB_UL_BIND_EVT,
AVCT_LCB_UL_UNBIND_EVT,
AVCT_LCB_UL_MSG_EVT,
AVCT_LCB_INT_CLOSE_EVT,
AVCT_LCB_LL_OPEN_EVT,
AVCT_LCB_LL_CLOSE_EVT,
AVCT_LCB_LL_MSG_EVT,
AVCT_LCB_LL_CONG_EVT
};
/* "states" used for L2CAP channel */
#define AVCT_CH_IDLE 0 /* No connection */
#define AVCT_CH_CONN 1 /* Waiting for connection confirm */
#define AVCT_CH_CFG 2 /* Waiting for configuration complete */
#define AVCT_CH_OPEN 3 /* Channel opened */
/* "no event" indicator used by ccb dealloc */
#define AVCT_NO_EVT 0xFF
/*****************************************************************************
** data types
*****************************************************************************/
/* sub control block type - common data members for tAVCT_LCB and tAVCT_BCB */
typedef struct {
UINT16 peer_mtu; /* peer l2c mtu */
UINT16 ch_result; /* L2CAP connection result value */
UINT16 ch_lcid; /* L2CAP channel LCID */
UINT8 allocated; /* 0, not allocated. index+1, otherwise. */
UINT8 state; /* The state machine state */
UINT8 ch_state; /* L2CAP channel state */
UINT8 ch_flags; /* L2CAP configuration flags */
} tAVCT_SCB;
/* link control block type */
typedef struct {
UINT16 peer_mtu; /* peer l2c mtu */
UINT16 ch_result; /* L2CAP connection result value */
UINT16 ch_lcid; /* L2CAP channel LCID */
UINT8 allocated; /* 0, not allocated. index+1, otherwise. */
UINT8 state; /* The state machine state */
UINT8 ch_state; /* L2CAP channel state */
UINT8 ch_flags; /* L2CAP configuration flags */
BT_HDR *p_rx_msg; /* Message being reassembled */
UINT16 conflict_lcid; /* L2CAP channel LCID */
BD_ADDR peer_addr; /* BD address of peer */
BUFFER_Q tx_q; /* Transmit data buffer queue */
BOOLEAN cong; /* TRUE, if congested */
} tAVCT_LCB;
/* browse control block type */
typedef struct {
UINT16 peer_mtu; /* peer l2c mtu */
UINT16 ch_result; /* L2CAP connection result value */
UINT16 ch_lcid; /* L2CAP channel LCID */
UINT8 allocated; /* 0, not allocated. index+1, otherwise. */
UINT8 state; /* The state machine state */
UINT8 ch_state; /* L2CAP channel state */
UINT8 ch_flags; /* L2CAP configuration flags */
BT_HDR *p_tx_msg; /* Message to be sent - in case the browsing channel is not open when MsgReg is called */
UINT8 ch_close; /* CCB index+1, if CCB initiated channel close */
} tAVCT_BCB;
#define AVCT_ALOC_LCB 0x01
#define AVCT_ALOC_BCB 0x02
/* connection control block */
typedef struct {
tAVCT_CC cc; /* parameters from connection creation */
tAVCT_LCB *p_lcb; /* Associated LCB */
tAVCT_BCB *p_bcb; /* associated BCB */
BOOLEAN ch_close; /* Whether CCB initiated channel close */
UINT8 allocated; /* Whether LCB/BCB is allocated */
} tAVCT_CCB;
/* data type associated with UL_MSG_EVT */
typedef struct {
BT_HDR *p_buf;
tAVCT_CCB *p_ccb;
UINT8 label;
UINT8 cr;
} tAVCT_UL_MSG;
/* union associated with lcb state machine events */
typedef union {
tAVCT_UL_MSG ul_msg;
BT_HDR *p_buf;
tAVCT_CCB *p_ccb;
UINT16 result;
BOOLEAN cong;
UINT8 err_code;
} tAVCT_LCB_EVT;
/* Control block for AVCT */
typedef struct {
tAVCT_LCB lcb[AVCT_NUM_LINKS]; /* link control blocks */
tAVCT_BCB bcb[AVCT_NUM_LINKS]; /* browse control blocks */
tAVCT_CCB ccb[AVCT_NUM_CONN]; /* connection control blocks */
UINT16 mtu; /* our L2CAP MTU */
UINT16 mtu_br; /* our L2CAP MTU for the Browsing channel */
UINT8 trace_level; /* trace level */
} tAVCT_CB;
/*****************************************************************************
** function declarations
*****************************************************************************/
/* LCB function declarations */
extern void avct_lcb_event(tAVCT_LCB *p_lcb, UINT8 event, tAVCT_LCB_EVT *p_data);
#if (AVCT_BROWSE_INCLUDED == TRUE)
extern void avct_bcb_event(tAVCT_BCB *p_bcb, UINT8 event, tAVCT_LCB_EVT *p_data);
extern void avct_close_bcb(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern tAVCT_LCB *avct_lcb_by_bcb(tAVCT_BCB *p_bcb);
extern tAVCT_BCB *avct_bcb_by_lcb(tAVCT_LCB *p_lcb);
extern BOOLEAN avct_bcb_last_ccb(tAVCT_BCB *p_bcb, tAVCT_CCB *p_ccb_last);
extern tAVCT_BCB *avct_bcb_by_lcid(UINT16 lcid);
#endif
extern tAVCT_LCB *avct_lcb_by_bd(BD_ADDR bd_addr);
extern tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr);
extern void avct_lcb_dealloc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern tAVCT_LCB *avct_lcb_by_lcid(UINT16 lcid);
extern tAVCT_CCB *avct_lcb_has_pid(tAVCT_LCB *p_lcb, UINT16 pid);
extern BOOLEAN avct_lcb_last_ccb(tAVCT_LCB *p_lcb, tAVCT_CCB *p_ccb_last);
/* LCB action functions */
extern void avct_lcb_chnl_open(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_unbind_disc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_open_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_open_fail(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_close_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_close_cfm(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_bind_conn(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_chk_disc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_chnl_disc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_bind_fail(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_cong_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_discard_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
extern void avct_lcb_free_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data);
/* BCB action functions */
#if (AVCT_BROWSE_INCLUDED == TRUE)
typedef void (*tAVCT_BCB_ACTION)(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_chnl_open(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_unbind_disc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_open_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_open_fail(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_close_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_close_cfm(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_bind_conn(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_chk_disc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_chnl_disc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_bind_fail(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_cong_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_discard_msg(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_send_msg(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_msg_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_free_msg_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern void avct_bcb_dealloc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data);
extern const tAVCT_BCB_ACTION avct_bcb_action[];
extern const UINT8 avct_lcb_pkt_type_len[];
extern const tL2CAP_FCR_OPTS avct_l2c_br_fcr_opts_def;
#endif
/* CCB function declarations */
extern tAVCT_CCB *avct_ccb_alloc(tAVCT_CC *p_cc);
extern void avct_ccb_dealloc(tAVCT_CCB *p_ccb, UINT8 event, UINT16 result, BD_ADDR bd_addr);
extern UINT8 avct_ccb_to_idx(tAVCT_CCB *p_ccb);
extern tAVCT_CCB *avct_ccb_by_idx(UINT8 idx);
/*****************************************************************************
** global data
*****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/* Main control block */
#if AVCT_DYNAMIC_MEMORY == FALSE
extern tAVCT_CB avct_cb;
#else
extern tAVCT_CB *avct_cb_ptr;
#define avct_cb (*avct_cb_ptr)
#endif
/* L2CAP callback registration structure */
extern const tL2CAP_APPL_INFO avct_l2c_appl;
#if (AVCT_BROWSE_INCLUDED == TRUE)
extern const tL2CAP_APPL_INFO avct_l2c_br_appl;
#endif
#ifdef __cplusplus
}
#endif
#endif /* AVCT_INT_H */

View File

@ -203,6 +203,9 @@ typedef UINT8 AVDT_REPORT_TYPE;
#define AVDT_NSC_RECONFIG 0x02 /* Reconfigure command not supported */
#define AVDT_NSC_SECURITY 0x04 /* Security command not supported */
/* AVDT disconnection reason */
#define AVDT_DISC_RSN_NORMAL 0
#define AVDT_DISC_RSN_ABNORMAL (0xce) /* unintentional disconnection */
/*****************************************************************************
** Type Definitions
*****************************************************************************/

5
tools/sdk/include/bluedroid/avdt_defs.h Executable file → Normal file
View File

@ -24,6 +24,9 @@
******************************************************************************/
#ifndef AVDT_DEFS_H
#define AVDT_DEFS_H
#include "bt_target.h"
#if (AVDT_INCLUDED == TRUE)
/*****************************************************************************
** constants
@ -199,5 +202,7 @@
#define AVDT_MSG_BLD_NOSP(p, nosp) \
*(p)++ = (UINT8) (nosp);
#endif ///AVRC_INCLUDED == TRUE
#endif /* AVDT_DEFS_H */

View File

@ -0,0 +1,748 @@
/******************************************************************************
*
* 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 interfaces which are internal to AVDTP.
*
******************************************************************************/
#ifndef AVDT_INT_H
#define AVDT_INT_H
#include "gki.h"
#include "avdt_api.h"
#include "avdtc_api.h"
#include "avdt_defs.h"
#include "l2c_api.h"
#include "btm_api.h"
#if (AVRC_INCLUDED == TRUE)
#ifndef AVDT_DEBUG
#define AVDT_DEBUG FALSE
#endif
/*****************************************************************************
** constants
*****************************************************************************/
/* channel types */
enum {
AVDT_CHAN_SIG, /* signaling channel */
AVDT_CHAN_MEDIA, /* media channel */
#if AVDT_REPORTING == TRUE
AVDT_CHAN_REPORT, /* reporting channel */
#endif
AVDT_CHAN_NUM_TYPES
};
/* protocol service capabilities of this AVDTP implementation */
/* for now multiplexing will be used only for fragmentation */
#if ((AVDT_MULTIPLEXING == TRUE) && (AVDT_REPORTING == TRUE))
#define AVDT_PSC (AVDT_PSC_TRANS | AVDT_PSC_MUX | AVDT_PSC_REPORT | AVDT_PSC_DELAY_RPT)
#define AVDT_LEG_PSC (AVDT_PSC_TRANS | AVDT_PSC_MUX | AVDT_PSC_REPORT)
#else /* AVDT_MULTIPLEXING && AVDT_REPORTING */
#if (AVDT_MULTIPLEXING == TRUE)
#define AVDT_PSC (AVDT_PSC_TRANS | AVDT_PSC_MUX | AVDT_PSC_DELAY_RPT)
#define AVDT_LEG_PSC (AVDT_PSC_TRANS | AVDT_PSC_MUX)
#else /* AVDT_MULTIPLEXING */
#if (AVDT_REPORTING == TRUE)
#define AVDT_PSC (AVDT_PSC_TRANS | AVDT_PSC_REPORT | AVDT_PSC_DELAY_RPT)
#define AVDT_LEG_PSC (AVDT_PSC_TRANS | AVDT_PSC_REPORT)
#else /* AVDT_REPORTING */
#define AVDT_PSC (AVDT_PSC_TRANS | AVDT_PSC_DELAY_RPT)
#define AVDT_LEG_PSC (AVDT_PSC_TRANS)
#endif /* AVDT_REPORTING */
#endif /* AVDT_MULTIPLEXING */
#endif /* AVDT_MULTIPLEXING && AVDT_REPORTING */
/* initiator/acceptor signaling roles */
#define AVDT_CLOSE_ACP 0
#define AVDT_CLOSE_INT 1
#define AVDT_OPEN_ACP 2
#define AVDT_OPEN_INT 3
/* states for avdt_scb_verify */
#define AVDT_VERIFY_OPEN 0
#define AVDT_VERIFY_STREAMING 1
#define AVDT_VERIFY_SUSPEND 2
#define AVDT_VERIFY_START 3
/* to distinguish CCB events from SCB events */
#define AVDT_CCB_MKR 0x80
/* offset where AVDTP signaling message header starts in message */
#define AVDT_HDR_OFFSET (L2CAP_MIN_OFFSET + AVDT_NUM_SEPS)
/* offset where AVDTP signaling message content starts;
** use the size of a start header since it's the largest possible
** layout of signaling message in a buffer is:
**
** | BT_HDR | SCB handles | L2CAP + HCI header | AVDTP header | data ... |
**
** Note that we "hide" the scb handles at the top of the message buffer.
*/
#define AVDT_MSG_OFFSET (L2CAP_MIN_OFFSET + AVDT_NUM_SEPS + AVDT_LEN_TYPE_START)
/* scb transport channel connect timeout value */
#define AVDT_SCB_TC_CONN_TOUT 10
/* scb transport channel disconnect timeout value */
#define AVDT_SCB_TC_DISC_TOUT 10
/* maximum number of command retransmissions */
#ifndef AVDT_RET_MAX
#define AVDT_RET_MAX 1
#endif
/* ccb state machine states */
enum {
AVDT_CCB_IDLE_ST,
AVDT_CCB_OPENING_ST,
AVDT_CCB_OPEN_ST,
AVDT_CCB_CLOSING_ST
};
/* state machine action enumeration list */
enum {
AVDT_CCB_CHAN_OPEN,
AVDT_CCB_CHAN_CLOSE,
AVDT_CCB_CHK_CLOSE,
AVDT_CCB_HDL_DISCOVER_CMD,
AVDT_CCB_HDL_DISCOVER_RSP,
AVDT_CCB_HDL_GETCAP_CMD,
AVDT_CCB_HDL_GETCAP_RSP,
AVDT_CCB_HDL_START_CMD,
AVDT_CCB_HDL_START_RSP,
AVDT_CCB_HDL_SUSPEND_CMD,
AVDT_CCB_HDL_SUSPEND_RSP,
AVDT_CCB_SND_DISCOVER_CMD,
AVDT_CCB_SND_DISCOVER_RSP,
AVDT_CCB_SND_GETCAP_CMD,
AVDT_CCB_SND_GETCAP_RSP,
AVDT_CCB_SND_START_CMD,
AVDT_CCB_SND_START_RSP,
AVDT_CCB_SND_SUSPEND_CMD,
AVDT_CCB_SND_SUSPEND_RSP,
AVDT_CCB_CLEAR_CMDS,
AVDT_CCB_CMD_FAIL,
AVDT_CCB_FREE_CMD,
AVDT_CCB_CONG_STATE,
AVDT_CCB_RET_CMD,
AVDT_CCB_SND_CMD,
AVDT_CCB_SND_MSG,
AVDT_CCB_SET_RECONN,
AVDT_CCB_CLR_RECONN,
AVDT_CCB_CHK_RECONN,
AVDT_CCB_CHK_TIMER,
AVDT_CCB_SET_CONN,
AVDT_CCB_SET_DISCONN,
AVDT_CCB_DO_DISCONN,
AVDT_CCB_LL_CLOSED,
AVDT_CCB_LL_OPENED,
AVDT_CCB_DEALLOC,
AVDT_CCB_NUM_ACTIONS
};
#define AVDT_CCB_IGNORE AVDT_CCB_NUM_ACTIONS
/* ccb state machine events */
enum {
AVDT_CCB_API_DISCOVER_REQ_EVT,
AVDT_CCB_API_GETCAP_REQ_EVT,
AVDT_CCB_API_START_REQ_EVT,
AVDT_CCB_API_SUSPEND_REQ_EVT,
AVDT_CCB_API_DISCOVER_RSP_EVT,
AVDT_CCB_API_GETCAP_RSP_EVT,
AVDT_CCB_API_START_RSP_EVT,
AVDT_CCB_API_SUSPEND_RSP_EVT,
AVDT_CCB_API_CONNECT_REQ_EVT,
AVDT_CCB_API_DISCONNECT_REQ_EVT,
AVDT_CCB_MSG_DISCOVER_CMD_EVT,
AVDT_CCB_MSG_GETCAP_CMD_EVT,
AVDT_CCB_MSG_START_CMD_EVT,
AVDT_CCB_MSG_SUSPEND_CMD_EVT,
AVDT_CCB_MSG_DISCOVER_RSP_EVT,
AVDT_CCB_MSG_GETCAP_RSP_EVT,
AVDT_CCB_MSG_START_RSP_EVT,
AVDT_CCB_MSG_SUSPEND_RSP_EVT,
AVDT_CCB_RCVRSP_EVT,
AVDT_CCB_SENDMSG_EVT,
AVDT_CCB_RET_TOUT_EVT,
AVDT_CCB_RSP_TOUT_EVT,
AVDT_CCB_IDLE_TOUT_EVT,
AVDT_CCB_UL_OPEN_EVT,
AVDT_CCB_UL_CLOSE_EVT,
AVDT_CCB_LL_OPEN_EVT,
AVDT_CCB_LL_CLOSE_EVT,
AVDT_CCB_LL_CONG_EVT
};
/* scb state machine states; these state values are private to this module so
** the scb state cannot be read or set by actions functions
*/
enum {
AVDT_SCB_IDLE_ST,
AVDT_SCB_CONF_ST,
AVDT_SCB_OPENING_ST,
AVDT_SCB_OPEN_ST,
AVDT_SCB_STREAM_ST,
AVDT_SCB_CLOSING_ST
};
/* state machine action enumeration list */
enum {
AVDT_SCB_HDL_ABORT_CMD,
AVDT_SCB_HDL_ABORT_RSP,
AVDT_SCB_HDL_CLOSE_CMD,
AVDT_SCB_HDL_CLOSE_RSP,
AVDT_SCB_HDL_GETCONFIG_CMD,
AVDT_SCB_HDL_GETCONFIG_RSP,
AVDT_SCB_HDL_OPEN_CMD,
AVDT_SCB_HDL_OPEN_REJ,
AVDT_SCB_HDL_OPEN_RSP,
AVDT_SCB_HDL_PKT,
AVDT_SCB_DROP_PKT,
AVDT_SCB_HDL_RECONFIG_CMD,
AVDT_SCB_HDL_RECONFIG_RSP,
AVDT_SCB_HDL_SECURITY_CMD,
AVDT_SCB_HDL_SECURITY_RSP,
AVDT_SCB_HDL_SETCONFIG_CMD,
AVDT_SCB_HDL_SETCONFIG_REJ,
AVDT_SCB_HDL_SETCONFIG_RSP,
AVDT_SCB_HDL_START_CMD,
AVDT_SCB_HDL_START_RSP,
AVDT_SCB_HDL_SUSPEND_CMD,
AVDT_SCB_HDL_SUSPEND_RSP,
AVDT_SCB_HDL_TC_CLOSE,
#if AVDT_REPORTING == TRUE
AVDT_SCB_HDL_TC_CLOSE_STO,
#endif
AVDT_SCB_HDL_TC_OPEN,
#if AVDT_REPORTING == TRUE
AVDT_SCB_HDL_TC_OPEN_STO,
#endif
AVDT_SCB_SND_DELAY_RPT_REQ,
AVDT_SCB_HDL_DELAY_RPT_CMD,
AVDT_SCB_HDL_DELAY_RPT_RSP,
AVDT_SCB_HDL_WRITE_REQ,
AVDT_SCB_SND_ABORT_REQ,
AVDT_SCB_SND_ABORT_RSP,
AVDT_SCB_SND_CLOSE_REQ,
AVDT_SCB_SND_STREAM_CLOSE,
AVDT_SCB_SND_CLOSE_RSP,
AVDT_SCB_SND_GETCONFIG_REQ,
AVDT_SCB_SND_GETCONFIG_RSP,
AVDT_SCB_SND_OPEN_REQ,
AVDT_SCB_SND_OPEN_RSP,
AVDT_SCB_SND_RECONFIG_REQ,
AVDT_SCB_SND_RECONFIG_RSP,
AVDT_SCB_SND_SECURITY_REQ,
AVDT_SCB_SND_SECURITY_RSP,
AVDT_SCB_SND_SETCONFIG_REQ,
AVDT_SCB_SND_SETCONFIG_REJ,
AVDT_SCB_SND_SETCONFIG_RSP,
AVDT_SCB_SND_TC_CLOSE,
AVDT_SCB_CB_ERR,
AVDT_SCB_CONG_STATE,
AVDT_SCB_REJ_STATE,
AVDT_SCB_REJ_IN_USE,
AVDT_SCB_REJ_NOT_IN_USE,
AVDT_SCB_SET_REMOVE,
AVDT_SCB_FREE_PKT,
AVDT_SCB_CLR_PKT,
AVDT_SCB_CHK_SND_PKT,
AVDT_SCB_TC_TIMER,
AVDT_SCB_CLR_VARS,
AVDT_SCB_DEALLOC,
AVDT_SCB_NUM_ACTIONS
};
#define AVDT_SCB_IGNORE AVDT_SCB_NUM_ACTIONS
/* scb state machine events */
enum {
AVDT_SCB_API_REMOVE_EVT,
AVDT_SCB_API_WRITE_REQ_EVT,
AVDT_SCB_API_GETCONFIG_REQ_EVT,
AVDT_SCB_API_DELAY_RPT_REQ_EVT,
AVDT_SCB_API_SETCONFIG_REQ_EVT,
AVDT_SCB_API_OPEN_REQ_EVT,
AVDT_SCB_API_CLOSE_REQ_EVT,
AVDT_SCB_API_RECONFIG_REQ_EVT,
AVDT_SCB_API_SECURITY_REQ_EVT,
AVDT_SCB_API_ABORT_REQ_EVT,
AVDT_SCB_API_GETCONFIG_RSP_EVT,
AVDT_SCB_API_SETCONFIG_RSP_EVT,
AVDT_SCB_API_SETCONFIG_REJ_EVT,
AVDT_SCB_API_OPEN_RSP_EVT,
AVDT_SCB_API_CLOSE_RSP_EVT,
AVDT_SCB_API_RECONFIG_RSP_EVT,
AVDT_SCB_API_SECURITY_RSP_EVT,
AVDT_SCB_API_ABORT_RSP_EVT,
AVDT_SCB_MSG_SETCONFIG_CMD_EVT,
AVDT_SCB_MSG_GETCONFIG_CMD_EVT,
AVDT_SCB_MSG_OPEN_CMD_EVT,
AVDT_SCB_MSG_START_CMD_EVT,
AVDT_SCB_MSG_SUSPEND_CMD_EVT,
AVDT_SCB_MSG_CLOSE_CMD_EVT,
AVDT_SCB_MSG_ABORT_CMD_EVT,
AVDT_SCB_MSG_RECONFIG_CMD_EVT,
AVDT_SCB_MSG_SECURITY_CMD_EVT,
AVDT_SCB_MSG_DELAY_RPT_CMD_EVT,
AVDT_SCB_MSG_DELAY_RPT_RSP_EVT,
AVDT_SCB_MSG_SETCONFIG_RSP_EVT,
AVDT_SCB_MSG_GETCONFIG_RSP_EVT,
AVDT_SCB_MSG_OPEN_RSP_EVT,
AVDT_SCB_MSG_START_RSP_EVT,
AVDT_SCB_MSG_SUSPEND_RSP_EVT,
AVDT_SCB_MSG_CLOSE_RSP_EVT,
AVDT_SCB_MSG_ABORT_RSP_EVT,
AVDT_SCB_MSG_RECONFIG_RSP_EVT,
AVDT_SCB_MSG_SECURITY_RSP_EVT,
AVDT_SCB_MSG_SETCONFIG_REJ_EVT,
AVDT_SCB_MSG_OPEN_REJ_EVT,
AVDT_SCB_MSG_START_REJ_EVT,
AVDT_SCB_MSG_SUSPEND_REJ_EVT,
AVDT_SCB_TC_TOUT_EVT,
AVDT_SCB_TC_OPEN_EVT,
AVDT_SCB_TC_CLOSE_EVT,
AVDT_SCB_TC_CONG_EVT,
AVDT_SCB_TC_DATA_EVT,
AVDT_SCB_CC_CLOSE_EVT
};
/* adaption layer number of stream routing table entries */
#if AVDT_REPORTING == TRUE
/* 2 channels(1 media, 1 report) for each SEP and one for signalling */
#define AVDT_NUM_RT_TBL ((AVDT_NUM_SEPS<<1) + 1)
#else
#define AVDT_NUM_RT_TBL (AVDT_NUM_SEPS + 1)
#endif
/* adaption layer number of transport channel table entries - moved to target.h
#define AVDT_NUM_TC_TBL (AVDT_NUM_SEPS + AVDT_NUM_LINKS) */
/* "states" used in transport channel table */
#define AVDT_AD_ST_UNUSED 0 /* Unused - unallocated */
#define AVDT_AD_ST_IDLE 1 /* No connection */
#define AVDT_AD_ST_ACP 2 /* Waiting to accept a connection */
#define AVDT_AD_ST_INT 3 /* Initiating a connection */
#define AVDT_AD_ST_CONN 4 /* Waiting for connection confirm */
#define AVDT_AD_ST_CFG 5 /* Waiting for configuration complete */
#define AVDT_AD_ST_OPEN 6 /* Channel opened */
#define AVDT_AD_ST_SEC_INT 7 /* Security process as INT */
#define AVDT_AD_ST_SEC_ACP 8 /* Security process as ACP */
/* Configuration flags. tAVDT_TC_TBL.cfg_flags */
#define AVDT_L2C_CFG_IND_DONE (1<<0)
#define AVDT_L2C_CFG_CFM_DONE (1<<1)
#define AVDT_L2C_CFG_CONN_INT (1<<2)
#define AVDT_L2C_CFG_CONN_ACP (1<<3)
/* result code for avdt_ad_write_req() (L2CA_DataWrite()) */
#define AVDT_AD_FAILED L2CAP_DW_FAILED /* FALSE */
#define AVDT_AD_SUCCESS L2CAP_DW_SUCCESS /* TRUE */
#define AVDT_AD_CONGESTED L2CAP_DW_CONGESTED /* 2 */
/*****************************************************************************
** data types
*****************************************************************************/
/* msg union of all message parameter types */
typedef union {
tAVDT_EVT_HDR hdr;
tAVDT_EVT_HDR single;
tAVDT_SETCONFIG config_cmd;
tAVDT_CONFIG reconfig_cmd;
tAVDT_MULTI multi;
tAVDT_SECURITY security_cmd;
tAVDT_DISCOVER discover_rsp;
tAVDT_CONFIG svccap;
tAVDT_SECURITY security_rsp;
tAVDT_DELAY_RPT delay_rpt_cmd;
} tAVDT_MSG;
/* data type for AVDT_CCB_API_DISCOVER_REQ_EVT */
typedef struct {
tAVDT_CTRL_CBACK *p_cback;
tAVDT_SEP_INFO *p_sep_info;
UINT8 num_seps;
} tAVDT_CCB_API_DISCOVER;
/* data type for AVDT_CCB_API_GETCAP_REQ_EVT */
typedef struct {
tAVDT_EVT_HDR single;
tAVDT_CTRL_CBACK *p_cback;
tAVDT_CFG *p_cfg;
} tAVDT_CCB_API_GETCAP;
/* data type for AVDT_CCB_API_CONNECT_REQ_EVT */
typedef struct {
tAVDT_CTRL_CBACK *p_cback;
UINT8 sec_mask;
} tAVDT_CCB_API_CONNECT;
/* data type for AVDT_CCB_API_DISCONNECT_REQ_EVT */
typedef struct {
tAVDT_CTRL_CBACK *p_cback;
} tAVDT_CCB_API_DISCONNECT;
/* union associated with ccb state machine events */
typedef union {
tAVDT_CCB_API_DISCOVER discover;
tAVDT_CCB_API_GETCAP getcap;
tAVDT_CCB_API_CONNECT connect;
tAVDT_CCB_API_DISCONNECT disconnect;
tAVDT_MSG msg;
BOOLEAN llcong;
UINT8 err_code;
} tAVDT_CCB_EVT;
/* channel control block type */
typedef struct {
BD_ADDR peer_addr; /* BD address of peer */
TIMER_LIST_ENT timer_entry; /* CCB timer list entry */
BUFFER_Q cmd_q; /* Queue for outgoing command messages */
BUFFER_Q rsp_q; /* Queue for outgoing response and reject messages */
tAVDT_CTRL_CBACK *proc_cback; /* Procedure callback function */
tAVDT_CTRL_CBACK *p_conn_cback; /* Connection/disconnection callback function */
void *p_proc_data; /* Pointer to data storage for procedure */
BT_HDR *p_curr_cmd; /* Current command being sent awaiting response */
BT_HDR *p_curr_msg; /* Current message being sent */
BT_HDR *p_rx_msg; /* Current message being received */
BOOLEAN allocated; /* Whether ccb is allocated */
UINT8 state; /* The CCB state machine state */
BOOLEAN ll_opened; /* TRUE if LL is opened */
BOOLEAN proc_busy; /* TRUE when a discover or get capabilities procedure in progress */
UINT8 proc_param; /* Procedure parameter; either SEID for get capabilities or number of SEPS for discover */
BOOLEAN cong; /* Whether signaling channel is congested */
UINT8 label; /* Message header "label" (sequence number) */
BOOLEAN reconn; /* If TRUE, reinitiate connection after transitioning from CLOSING to IDLE state */
UINT8 ret_count; /* Command retransmission count */
UINT8 disc_rsn; /* disconnection reason */
} tAVDT_CCB;
/* type for action functions */
typedef void (*tAVDT_CCB_ACTION)(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
/* type for AVDT_SCB_API_WRITE_REQ_EVT */
typedef struct {
BT_HDR *p_buf;
UINT32 time_stamp;
#if AVDT_MULTIPLEXING == TRUE
BUFFER_Q frag_q; /* Queue for outgoing media fragments. p_buf should be 0 */
UINT8 *p_data;
UINT32 data_len;
#endif
UINT8 m_pt;
tAVDT_DATA_OPT_MASK opt;
} tAVDT_SCB_APIWRITE;
/* type for AVDT_SCB_TC_CLOSE_EVT */
typedef struct {
UINT8 old_tc_state; /* channel state before closed */
UINT8 tcid; /* TCID */
UINT8 type; /* channel type */
UINT8 disc_rsn; /* disconnection reason */
} tAVDT_SCB_TC_CLOSE;
/* type for scb event data */
typedef union {
tAVDT_MSG msg;
tAVDT_SCB_APIWRITE apiwrite;
tAVDT_DELAY_RPT apidelay;
tAVDT_OPEN open;
tAVDT_SCB_TC_CLOSE close;
BOOLEAN llcong;
BT_HDR *p_pkt;
} tAVDT_SCB_EVT;
/* stream control block type */
typedef struct {
tAVDT_CS cs; /* stream creation struct */
tAVDT_CFG curr_cfg; /* current configuration */
tAVDT_CFG req_cfg; /* requested configuration */
TIMER_LIST_ENT timer_entry; /* timer entry */
BT_HDR *p_pkt; /* packet waiting to be sent */
tAVDT_CCB *p_ccb; /* ccb associated with this scb */
UINT16 media_seq; /* media packet sequence number */
BOOLEAN allocated; /* whether scb is allocated or unused */
BOOLEAN in_use; /* whether stream being used by peer */
BOOLEAN sink_activated; /* A2DP Sink activated/de-activated from Application */
UINT8 role; /* initiator/acceptor role in current procedure */
BOOLEAN remove; /* whether CB is marked for removal */
UINT8 state; /* state machine state */
UINT8 peer_seid; /* SEID of peer stream */
UINT8 curr_evt; /* current event; set only by state machine */
BOOLEAN cong; /* Whether media transport channel is congested */
UINT8 close_code; /* Error code received in close response */
#if AVDT_MULTIPLEXING == TRUE
BUFFER_Q frag_q; /* Queue for outgoing media fragments */
UINT32 frag_off; /* length of already received media fragments */
UINT32 frag_org_len; /* original length before fragmentation of receiving media packet */
UINT8 *p_next_frag; /* next fragment to send */
UINT8 *p_media_buf; /* buffer for media packet assigned by AVDT_SetMediaBuf */
UINT32 media_buf_len; /* length of buffer for media packet assigned by AVDT_SetMediaBuf */
#endif
} tAVDT_SCB;
/* type for action functions */
typedef void (*tAVDT_SCB_ACTION)(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
/* adaption layer type for transport channel table */
typedef struct {
UINT16 peer_mtu; /* L2CAP mtu of the peer device */
UINT16 my_mtu; /* Our MTU for this channel */
UINT16 my_flush_to; /* Our flush timeout for this channel */
UINT16 lcid;
UINT8 tcid; /* transport channel id */
UINT8 ccb_idx; /* channel control block associated with this tc */
UINT8 state; /* transport channel state */
UINT8 cfg_flags; /* L2CAP configuration flags */
UINT8 id;
} tAVDT_TC_TBL;
/* adaption layer type for stream routing table */
typedef struct {
UINT16 lcid; /* L2CAP LCID of the associated transport channel */
UINT8 scb_hdl; /* stream control block associated with this tc */
} tAVDT_RT_TBL;
/* adaption layer control block */
typedef struct {
tAVDT_RT_TBL rt_tbl[AVDT_NUM_LINKS][AVDT_NUM_RT_TBL];
tAVDT_TC_TBL tc_tbl[AVDT_NUM_TC_TBL];
UINT8 lcid_tbl[MAX_L2CAP_CHANNELS]; /* map LCID to tc_tbl index */
} tAVDT_AD;
/* Control block for AVDT */
typedef struct {
tAVDT_REG rcb; /* registration control block */
tAVDT_CCB ccb[AVDT_NUM_LINKS]; /* channel control blocks */
tAVDT_SCB scb[AVDT_NUM_SEPS]; /* stream control blocks */
tAVDT_AD ad; /* adaption layer control block */
tAVDTC_CTRL_CBACK *p_conf_cback; /* conformance callback function */
tAVDT_CCB_ACTION *p_ccb_act; /* pointer to CCB action functions */
tAVDT_SCB_ACTION *p_scb_act; /* pointer to SCB action functions */
tAVDT_CTRL_CBACK *p_conn_cback; /* connection callback function */
UINT8 trace_level; /* trace level */
} tAVDT_CB;
/*****************************************************************************
** function declarations
*****************************************************************************/
/* CCB function declarations */
extern void avdt_ccb_init(void);
extern void avdt_ccb_event(tAVDT_CCB *p_ccb, UINT8 event, tAVDT_CCB_EVT *p_data);
extern tAVDT_CCB *avdt_ccb_by_bd(BD_ADDR bd_addr);
extern tAVDT_CCB *avdt_ccb_alloc(BD_ADDR bd_addr);
extern void avdt_ccb_dealloc(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern UINT8 avdt_ccb_to_idx(tAVDT_CCB *p_ccb);
extern tAVDT_CCB *avdt_ccb_by_idx(UINT8 idx);
/* CCB action functions */
extern void avdt_ccb_chan_open(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_chan_close(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_chk_close(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_hdl_discover_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_hdl_discover_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_hdl_getcap_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_hdl_getcap_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_hdl_start_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_hdl_start_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_hdl_suspend_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_hdl_suspend_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_discover_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_discover_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_getcap_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_getcap_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_start_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_start_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_suspend_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_suspend_rsp(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_clear_cmds(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_cmd_fail(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_free_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_cong_state(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_ret_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_snd_msg(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_set_reconn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_clr_reconn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_chk_reconn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_chk_timer(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_set_conn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_set_disconn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_do_disconn(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_ll_closed(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
extern void avdt_ccb_ll_opened(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data);
/* SCB function prototypes */
extern void avdt_scb_event(tAVDT_SCB *p_scb, UINT8 event, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_init(void);
extern tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs);
extern void avdt_scb_dealloc(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern UINT8 avdt_scb_to_hdl(tAVDT_SCB *p_scb);
extern tAVDT_SCB *avdt_scb_by_hdl(UINT8 hdl);
extern UINT8 avdt_scb_verify(tAVDT_CCB *p_ccb, UINT8 state, UINT8 *p_seid, UINT16 num_seid, UINT8 *p_err_code);
extern void avdt_scb_peer_seid_list(tAVDT_MULTI *p_multi);
extern UINT32 avdt_scb_gen_ssrc(tAVDT_SCB *p_scb);
/* SCB action functions */
extern void avdt_scb_hdl_abort_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_abort_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_close_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_close_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_getconfig_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_getconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_open_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_open_rej(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_open_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_drop_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_reconfig_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_reconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_security_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_security_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_setconfig_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_setconfig_rej(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_setconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_start_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_start_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_suspend_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_suspend_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_delay_rpt_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_delay_rpt_cmd(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_delay_rpt_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_tc_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_tc_open(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_tc_close_sto(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_tc_open_sto(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_hdl_write_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_abort_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_abort_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_close_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_stream_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_close_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_getconfig_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_getconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_open_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_open_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_reconfig_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_reconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_security_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_security_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_setconfig_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_setconfig_rej(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_setconfig_rsp(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_snd_tc_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_cb_err(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_cong_state(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_rej_state(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_rej_in_use(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_rej_not_in_use(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_set_remove(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_free_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_clr_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_tc_timer(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_clr_vars(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
extern void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len, BUFFER_Q *pq);
/* msg function declarations */
extern BOOLEAN avdt_msg_send(tAVDT_CCB *p_ccb, BT_HDR *p_msg);
extern void avdt_msg_send_cmd(tAVDT_CCB *p_ccb, void *p_scb, UINT8 sig_id, tAVDT_MSG *p_params);
extern void avdt_msg_send_rsp(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params);
extern void avdt_msg_send_rej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params);
extern void avdt_msg_send_grej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params);
extern void avdt_msg_ind(tAVDT_CCB *p_ccb, BT_HDR *p_buf);
/* adaption layer function declarations */
extern void avdt_ad_init(void);
extern UINT8 avdt_ad_type_to_tcid(UINT8 type, tAVDT_SCB *p_scb);
extern tAVDT_TC_TBL *avdt_ad_tc_tbl_by_st(UINT8 type, tAVDT_CCB *p_ccb, UINT8 state);
extern tAVDT_TC_TBL *avdt_ad_tc_tbl_by_lcid(UINT16 lcid);
extern tAVDT_TC_TBL *avdt_ad_tc_tbl_alloc(tAVDT_CCB *p_ccb);
extern UINT8 avdt_ad_tc_tbl_to_idx(tAVDT_TC_TBL *p_tbl);
extern void avdt_ad_tc_close_ind(tAVDT_TC_TBL *p_tbl, UINT16 reason);
extern void avdt_ad_tc_open_ind(tAVDT_TC_TBL *p_tbl);
extern void avdt_ad_tc_cong_ind(tAVDT_TC_TBL *p_tbl, BOOLEAN is_congested);
extern void avdt_ad_tc_data_ind(tAVDT_TC_TBL *p_tbl, BT_HDR *p_buf);
extern tAVDT_TC_TBL *avdt_ad_tc_tbl_by_type(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb);
extern UINT8 avdt_ad_write_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb, BT_HDR *p_buf);
extern void avdt_ad_open_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb, UINT8 role);
extern void avdt_ad_close_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb);
extern void avdt_process_timeout(TIMER_LIST_ENT *p_tle);
/*****************************************************************************
** macros
*****************************************************************************/
/* we store the scb and the label in the layer_specific field of the
** current cmd
*/
#define AVDT_BLD_LAYERSPEC(ls, msg, label) \
ls = (((label) << 4) | (msg))
#define AVDT_LAYERSPEC_LABEL(ls) ((UINT8)((ls) >> 4))
#define AVDT_LAYERSPEC_MSG(ls) ((UINT8)((ls) & 0x000F))
/*****************************************************************************
** global data
*****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************************************
** Main Control Block
*******************************************************************************/
#if AVDT_DYNAMIC_MEMORY == FALSE
extern tAVDT_CB avdt_cb;
#else
extern tAVDT_CB *avdt_cb_ptr;
#define avdt_cb (*avdt_cb_ptr)
#endif
/* L2CAP callback registration structure */
extern const tL2CAP_APPL_INFO avdt_l2c_appl;
/* reject message event lookup table */
extern const UINT8 avdt_msg_rej_2_evt[];
#ifdef __cplusplus
}
#endif
#endif ///AVRC_INCLUDED == TRUE
#endif /* AVDT_INT_H */

0
tools/sdk/include/bluedroid/avdtc_api.h Executable file → Normal file
View File

View File

@ -27,7 +27,7 @@
#include "avct_api.h"
#include "sdp_api.h"
#include "avrc_defs.h"
#if (AVRC_INCLUDED == TRUE)
/*****************************************************************************
** constants
*****************************************************************************/
@ -634,4 +634,7 @@ extern BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr);
}
#endif
#endif ///AVRC_INCLUDED == TRUE
#endif /* AVRC_API_H */

View File

@ -23,7 +23,9 @@
******************************************************************************/
#ifndef _AVRC_DEFS_H
#define _AVRC_DEFS_H
#include "bt_target.h"
#if (AVRC_INCLUDED == TRUE)
/*****************************************************************************
** constants
*****************************************************************************/
@ -1356,5 +1358,5 @@ typedef union {
tAVRC_RSP add_to_play; /* AddToNowPlaying */
} tAVRC_RESPONSE;
#endif ///AVRC_INCLUDED == TRUE
#endif

View File

@ -0,0 +1,158 @@
/******************************************************************************
*
* 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.
*
******************************************************************************/
/******************************************************************************
*
* VRCP internal header file.
*
******************************************************************************/
#ifndef AVRC_INT_H
#define AVRC_INT_H
#include "avct_defs.h"
#include "avrc_api.h"
#if (AVRC_INCLUDED == TRUE)
/* DEBUG FLAGS
*
* #define META_DEBUG_ENABLED
*/
/*****************************************************************************
** Constants
*****************************************************************************/
/* Number of attributes in AVRC SDP record. */
#define AVRC_NUM_ATTR 6
/* Number of protocol elements in protocol element list. */
#define AVRC_NUM_PROTO_ELEMS 2
#ifndef AVRC_MIN_CMD_LEN
#define AVRC_MIN_CMD_LEN 20
#endif
#define AVRC_UNIT_OPRND_BYTES 5
#define AVRC_SUB_OPRND_BYTES 4
#define AVRC_SUBRSP_OPRND_BYTES 3
#define AVRC_SUB_PAGE_MASK 7
#define AVRC_SUB_PAGE_SHIFT 4
#define AVRC_SUB_EXT_CODE 7
#define AVRC_PASS_OP_ID_MASK 0x7F
#define AVRC_PASS_STATE_MASK 0x80
#define AVRC_CMD_OPRND_PAD 0xFF
#define AVRC_CTYPE_MASK 0x0F
#define AVRC_SUBTYPE_MASK 0xF8
#define AVRC_SUBTYPE_SHIFT 3
#define AVRC_SUBID_MASK 0x07
#define AVRC_SUBID_IGNORE 0x07
#define AVRC_SINGLE_PARAM_SIZE 1
#define AVRC_METADATA_PKT_TYPE_MASK 0x03
#define AVRC_PASS_THOUGH_MSG_MASK 0x80 /* MSB of msg_type indicates the PAS THROUGH msg */
#define AVRC_VENDOR_UNIQUE_MASK 0x70 /* vendor unique id */
/* 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;}
#define AVRC_AVC_HDR_SIZE 3 /* ctype, subunit*, opcode */
#define AVRC_MIN_META_HDR_SIZE 4 /* pdu id(1), packet type(1), param len(2) */
#define AVRC_MIN_BROWSE_HDR_SIZE 3 /* pdu id(1), param len(2) */
#define AVRC_VENDOR_HDR_SIZE 6 /* ctype, subunit*, opcode, CO_ID */
#define AVRC_MSG_VENDOR_OFFSET 23
#define AVRC_MIN_VENDOR_SIZE (AVRC_MSG_VENDOR_OFFSET + BT_HDR_SIZE + AVRC_MIN_META_HDR_SIZE)
#define AVRC_PASS_THRU_SIZE 8
#define AVRC_MSG_PASS_THRU_OFFSET 25
#define AVRC_MIN_PASS_THRU_SIZE (AVRC_MSG_PASS_THRU_OFFSET + BT_HDR_SIZE + 4)
#define AVRC_MIN_BROWSE_SIZE (AVCT_BROWSE_OFFSET + BT_HDR_SIZE + AVRC_MIN_BROWSE_HDR_SIZE)
#define AVRC_CTRL_PKT_LEN(pf, pk) {pf = (UINT8 *)((pk) + 1) + (pk)->offset + 2;}
#define AVRC_MAX_CTRL_DATA_LEN (AVRC_PACKET_LEN)
/*****************************************************************************
** Type definitions
*****************************************************************************/
#if (AVRC_METADATA_INCLUDED == TRUE)
/* type for Metadata fragmentation control block */
typedef struct {
BT_HDR *p_fmsg; /* the fragmented message */
UINT8 frag_pdu; /* the PDU ID for fragmentation */
BOOLEAN frag_enabled; /* fragmentation flag */
} tAVRC_FRAG_CB;
/* type for Metadata re-assembly control block */
typedef struct {
BT_HDR *p_rmsg; /* the received message */
UINT16 rasm_offset; /* re-assembly flag, the offset of the start fragment */
UINT8 rasm_pdu; /* the PDU ID for re-assembly */
} tAVRC_RASM_CB;
#endif
typedef struct {
tAVRC_CONN_CB ccb[AVCT_NUM_CONN];
#if (AVRC_METADATA_INCLUDED == TRUE)
tAVRC_FRAG_CB fcb[AVCT_NUM_CONN];
tAVRC_RASM_CB rcb[AVCT_NUM_CONN];
#endif
tAVRC_FIND_CBACK *p_cback; /* pointer to application callback */
tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */
UINT16 service_uuid; /* service UUID to search */
UINT8 trace_level;
} tAVRC_CB;
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************************************
** Main Control Block
*******************************************************************************/
#if AVRC_DYNAMIC_MEMORY == FALSE
extern tAVRC_CB avrc_cb;
#else
extern tAVRC_CB *avrc_cb_ptr;
#define avrc_cb (*avrc_cb_ptr)
#endif
extern BOOLEAN avrc_is_valid_pdu_id(UINT8 pdu_id);
extern BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value);
extern BT_HDR *avrc_alloc_ctrl_pkt (UINT8 pdu);
extern tAVRC_STS avrc_pars_pass_thru(tAVRC_MSG_PASS *p_msg, UINT16 *p_vendor_unique_id);
extern UINT8 avrc_opcode_from_pdu(UINT8 pdu);
extern BOOLEAN avrc_is_valid_opcode(UINT8 opcode);
#ifdef __cplusplus
}
#endif
#endif ///AVRC_INCLUDED == TRUE
#endif /* AVRC_INT_H */

0
tools/sdk/include/bluedroid/bdaddr.h Executable file → Normal file
View File

View File

@ -92,6 +92,7 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t;
#define BLUFI_TYPE_CTRL_SUBTYPE_GET_WIFI_STATUS 0x05
#define BLUFI_TYPE_CTRL_SUBTYPE_DEAUTHENTICATE_STA 0x06
#define BLUFI_TYPE_CTRL_SUBTYPE_GET_VERSION 0x07
#define BLUFI_TYPE_CTRL_SUBTYPE_DISCONNECT_BLE 0x08
#define BLUFI_TYPE_DATA 0x1
#define BLUFI_TYPE_DATA_SUBTYPE_NEG 0x00

0
tools/sdk/include/bluedroid/bt_common_types.h Executable file → Normal file
View File

0
tools/sdk/include/bluedroid/bt_sdp.h Executable file → Normal file
View File

View File

@ -34,16 +34,87 @@
#include "bdroid_buildcfg.h"
#endif
#include "sdkconfig.h"
#include "bt_types.h" /* This must be defined AFTER buildcfg.h */
/* Include common GKI definitions used by this platform */
#include "gki_target.h"
#include "dyn_mem.h" /* defines static and/or dynamic memory for components */
#if CONFIG_CLASSIC_BT_ENABLED
#define CLASSIC_BT_INCLUDED TRUE
#define BTA_SDP_INCLUDED TRUE
#define BTA_PAN_INCLUDED FALSE
#define BTA_HH_INCLUDED FALSE
#define BTA_AR_INCLUDED TRUE
#define BTA_AV_INCLUDED TRUE
#define BTA_AV_SINK_INCLUDED TRUE
#define SDP_INCLUDED TRUE
#define RFCOMM_INCLUDED FALSE
#define PAN_INCLUDED FALSE
#define HID_HOST_INCLUDED FALSE
#define AVDT_INCLUDED TRUE
#define A2D_INCLUDED TRUE
#define AVCT_INCLUDED TRUE
#define AVRC_INCLUDED TRUE
#define SBC_DEC_INCLUDED TRUE
#define SBC_ENC_INCLUDED FALSE
#define MCA_INCLUDED FALSE
#define BTC_SM_INCLUDED TRUE
#define BTC_PRF_QUEUE_INCLUDED TRUE
#define BTC_GAP_BT_INCLUDED TRUE
#define BTC_AV_INCLUDED TRUE
#ifndef CLASSIC_BT_INCLUDED
#define CLASSIC_BT_INCLUDED TRUE
#endif ///CLASSIC_BT_INCLUDED
#else /* #if CONFIG_CLASSIC_BT_ENABLED */
#define CLASSIC_BT_INCLUDED FALSE
#define BTA_SDP_INCLUDED FALSE
#define BTA_PAN_INCLUDED FALSE
#define BTA_HH_INCLUDED FALSE
#define BTA_AR_INCLUDED FALSE
#define BTA_AV_INCLUDED FALSE
#define BTA_AV_SINK_INCLUDED FALSE
#define SDP_INCLUDED FALSE
#define RFCOMM_INCLUDED FALSE
#define PAN_INCLUDED FALSE
#define HID_HOST_INCLUDED FALSE
#define AVDT_INCLUDED FALSE
#define A2D_INCLUDED FALSE
#define AVCT_INCLUDED FALSE
#define AVRC_INCLUDED FALSE
#define SBC_DEC_INCLUDED FALSE
#define SBC_ENC_INCLUDED FALSE
#define MCA_INCLUDED FALSE
#define BTC_SM_INCLUDED FALSE
#define BTC_PRF_QUEUE_INCLUDED FALSE
#define BTC_GAP_BT_INCLUDED FALSE
#define BTC_AV_INCLUDED FALSE
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
#if (CONFIG_GATTS_ENABLE)
#define GATTS_INCLUDED TRUE
#else
#define GATTS_INCLUDED FALSE
#endif /* CONFIG_GATTS_ENABLE */
#if (CONFIG_GATTC_ENABLE)
#define GATTC_INCLUDED TRUE
#else
#define GATTC_INCLUDED FALSE
#endif /* CONFIG_GATTC_ENABLE */
#if (CONFIG_SMP_ENABLE)
#define SMP_INCLUDED TRUE
#define BLE_PRIVACY_SPT TRUE
#else
#define SMP_INCLUDED FALSE
#define BLE_PRIVACY_SPT FALSE
#endif /* CONFIG_GATTC_ENABLE */
#if (CONFIG_BT_ACL_CONNECTIONS)
#define MAX_ACL_CONNECTIONS CONFIG_BT_ACL_CONNECTIONS
#define GATT_MAX_PHY_CHANNEL CONFIG_BT_ACL_CONNECTIONS
#endif /* CONFIG_BT_ACL_CONNECTIONS */
//------------------Added from bdroid_buildcfg.h---------------------
#ifndef L2CAP_EXTFEA_SUPPORTED_MASK
@ -91,15 +162,15 @@
#endif
#ifndef BTA_AR_INCLUDED
#define BTA_AR_INCLUDED FALSE//TRUE
#define BTA_AR_INCLUDED TRUE//TRUE
#endif
#ifndef BTA_AV_INCLUDED
#define BTA_AV_INCLUDED FALSE//TRUE
#define BTA_AV_INCLUDED TRUE//TRUE
#endif
#ifndef BTA_AV_SINK_INCLUDED
#define BTA_AV_SINK_INCLUDED FALSE//FALSE
#define BTA_AV_SINK_INCLUDED TRUE//FALSE
#endif
#ifndef BTA_DISABLE_DELAY
@ -157,7 +228,7 @@
#endif
#ifndef BT_USE_TRACES
#define BT_USE_TRACES TRUE
#define BT_USE_TRACES FALSE
#endif
#ifndef BT_TRACE_BTIF
@ -431,9 +502,9 @@
#define BTM_SCO_DATA_SIZE_MAX 240
#endif
/* The size in bytes of the BTM inquiry database. 40 As Default */
/* The size in bytes of the BTM inquiry database. 5 As Default */
#ifndef BTM_INQ_DB_SIZE
#define BTM_INQ_DB_SIZE 32
#define BTM_INQ_DB_SIZE 5
#endif
/* The default scan mode */
@ -466,7 +537,7 @@
#define BTM_DEFAULT_DISC_INTERVAL 0x0800
#endif
/* Default class of device
/*
* {SERVICE_CLASS, MAJOR_CLASS, MINOR_CLASS}
*
* SERVICE_CLASS:0x5A (Bit17 -Networking,Bit19 - Capturing,Bit20 -Object Transfer,Bit22 -Telephony)
@ -474,13 +545,29 @@
* MINOR_CLASS:0x0C - SMART_PHONE
*
*/
#define BTA_DM_COD_SMARTPHONE {0x5A, 0x02, 0x0C}
/*
* {SERVICE_CLASS, MAJOR_CLASS, MINOR_CLASS}
*
* SERVICE_CLASS:0x2C (Bit21 - Audio, Bit19 - Capturing)
* MAJOR_CLASS:0x04 - Audio/Video
* MINOR_CLASS:0x05 - LoudSpeaker
*/
#define BTA_DM_COD_LOUDSPEAKER {0x2C, 0x04, 0x14}
/* Default class of device */
#ifndef BTA_DM_COD
#define BTA_DM_COD {0x5A, 0x02, 0x0C}
#define BTA_DM_COD BTA_DM_COD_LOUDSPEAKER
#endif
/* The number of SCO links. */
#ifndef BTM_MAX_SCO_LINKS
#if (CLASSIC_BT_INCLUDED == TRUE)
#define BTM_MAX_SCO_LINKS 1 //3
#else ///CLASSIC_BT_INCLUDED == TRUE
#define BTM_MAX_SCO_LINKS 0
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif
/* The preferred type of SCO links (2-eSCO, 0-SCO). */
@ -573,11 +660,15 @@
/* The IO capability of the local device (for Simple Pairing) */
#ifndef BTM_LOCAL_IO_CAPS
#define BTM_LOCAL_IO_CAPS BTM_IO_CAP_IO
#define BTM_LOCAL_IO_CAPS BTM_IO_CAP_NONE
#endif
#ifndef BTM_LOCAL_IO_CAPS_BLE
#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
#define BTM_LOCAL_IO_CAPS_BLE BTM_IO_CAP_KBDISP
#else
#define BTM_LOCAL_IO_CAPS_BLE 4
#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
#endif
/* The default MITM Protection Requirement (for Simple Pairing)
@ -599,7 +690,7 @@
/* TRUE to include Sniff Subrating */
#ifndef BTM_SSR_INCLUDED
#define BTM_SSR_INCLUDED TRUE
#define BTM_SSR_INCLUDED FALSE
#endif
/*************************
@ -626,22 +717,29 @@
#define L2CAP_CLIENT_INCLUDED FALSE
#endif
/* The maximum number of simultaneous links that L2CAP can support. Up to 7*/
#ifndef MAX_ACL_CONNECTIONS
#define MAX_L2CAP_LINKS 3
#define MAX_L2CAP_LINKS 5
#else
#define MAX_L2CAP_LINKS MAX_ACL_CONNECTIONS
#endif
/* The maximum number of simultaneous channels that L2CAP can support. Up to 16*/
#ifndef MAX_L2CAP_CHANNELS
#if (CLASSIC_BT_INCLUDED == TRUE)
#define MAX_L2CAP_CHANNELS 8
#else
#define MAX_L2CAP_CHANNELS 2 //Not support to create l2cap channels in the BLE only mode in this bluedroid version(6.0)
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif
/* The maximum number of simultaneous applications that can register with L2CAP. */
#ifndef MAX_L2CAP_CLIENTS
#if (CLASSIC_BT_INCLUDED == TRUE)
#define MAX_L2CAP_CLIENTS 8
#else
#define MAX_L2CAP_CLIENTS 1 //Not support to allocate a channel control block in BLE only mode
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif
/* The number of seconds of link inactivity before a link is disconnected. */
@ -727,7 +825,11 @@
/* Used for features using fixed channels; set to zero if no fixed channels supported (BLE, etc.) */
/* Excluding L2CAP signaling channel and UCD */
#ifndef L2CAP_NUM_FIXED_CHNLS
#if (CLASSIC_BT_INCLUDED == TRUE)
#define L2CAP_NUM_FIXED_CHNLS 32
#else
#define L2CAP_NUM_FIXED_CHNLS 3 //There are just three fix channel in the BLE only mode(gatt,signal,smp)
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif
/* First fixed channel supported */
@ -795,7 +897,7 @@
* resolution, local address rotation etc.
*/
#ifndef BLE_PRIVACY_SPT
#define BLE_PRIVACY_SPT TRUE
#define BLE_PRIVACY_SPT FALSE
#endif
/*
@ -907,7 +1009,7 @@
******************************************************************************/
#ifndef GATTC_INCLUDED
#if BLE_INCLUDED == TRUE
#define GATTC_INCLUDED TRUE
#define GATTC_INCLUDED FALSE
#else
#define GATTC_INCLUDED FALSE
#endif
@ -934,7 +1036,7 @@
******************************************************************************/
#ifndef SMP_INCLUDED
#if BLE_INCLUDED == TRUE
#define SMP_INCLUDED TRUE
#define SMP_INCLUDED FALSE
#else
#define SMP_INCLUDED FALSE
#endif
@ -1001,16 +1103,16 @@
/* The maximum number of SDP records the server can support. */
#ifndef SDP_MAX_RECORDS
#define SDP_MAX_RECORDS 15 /*max is 30*/
#define SDP_MAX_RECORDS 6 /*max is 30*/
#endif
/* The maximum number of attributes in each record. */
#ifndef SDP_MAX_REC_ATTR
#define SDP_MAX_REC_ATTR 25
#define SDP_MAX_REC_ATTR 8
#endif
#ifndef SDP_MAX_PAD_LEN
#define SDP_MAX_PAD_LEN 600
#define SDP_MAX_PAD_LEN 300
#endif
/* The maximum length, in bytes, of an attribute. */
@ -1326,17 +1428,17 @@ Range: 2 octets
******************************************************************************/
#ifndef AVDT_INCLUDED
#define AVDT_INCLUDED FALSE//TRUE
#define AVDT_INCLUDED TRUE
#endif
/* Include reporting capability in AVDTP */
#ifndef AVDT_REPORTING
#define AVDT_REPORTING FALSE//TRUE
#define AVDT_REPORTING TRUE
#endif
/* Include multiplexing capability in AVDTP */
#ifndef AVDT_MULTIPLEXING
#define AVDT_MULTIPLEXING FALSE//TRUE
#define AVDT_MULTIPLEXING TRUE
#endif
/* Number of simultaneous links to different peer devices. */
@ -1477,7 +1579,7 @@ Range: 2 octets
/* This is set to enable use of GAP L2CAP connections. */
#ifndef GAP_CONN_INCLUDED
#if GAP_INCLUDED == TRUE
#if (GAP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
#define GAP_CONN_INCLUDED TRUE
#else
#define GAP_CONN_INCLUDED FALSE
@ -1593,7 +1695,7 @@ Range: 2 octets
**
******************************************************************************/
#ifndef AVRC_INCLUDED
#define AVRC_INCLUDED FALSE
#define AVRC_INCLUDED TRUE
#endif
#ifndef AVRC_METADATA_INCLUDED

View File

@ -18,6 +18,7 @@
#ifndef _BT_TRACE_H_
#define _BT_TRACE_H_
#include "sdkconfig.h"
#include <stdio.h>
#include "bt_types.h"
@ -170,7 +171,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
/* Enables or disables all trace messages. */
#ifndef BT_USE_TRACES
#define BT_USE_TRACES TRUE
#define BT_USE_TRACES FALSE
#endif
/******************************************************************************
@ -270,11 +271,13 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
#ifndef LOG_LEVEL
#define LOG_LEVEL LOG_LEVEL_INFO
#endif
#define LOG_ERROR(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_ERROR) BT_PRINTF(fmt,## args);} while(0)
#define LOG_WARN(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_WARN) BT_PRINTF(fmt,## args);} while(0)
#define LOG_INFO(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_INFO) BT_PRINTF(fmt,## args);} while(0)
#define LOG_DEBUG(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_DEBUG) BT_PRINTF(fmt,## args);} while(0)
#define LOG_VERBOSE(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_VERBOSE) BT_PRINTF(fmt,## args);} while(0)
#if !CONFIG_BT_STACK_NO_LOG
#define LOG_ERROR(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_ERROR) BT_PRINTF(fmt,## args);} while(0)
#define LOG_WARN(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_WARN) BT_PRINTF(fmt,## args);} while(0)
#define LOG_INFO(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_INFO) BT_PRINTF(fmt,## args);} while(0)
#define LOG_DEBUG(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_DEBUG) BT_PRINTF(fmt,## args);} while(0)
#define LOG_VERBOSE(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_VERBOSE) BT_PRINTF(fmt,## args);} while(0)
/* Define tracing for the HCI unit
*/
@ -287,7 +290,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
*/
#define BTM_TRACE_ERROR(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define BTM_TRACE_WARNING(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define BTM_TRACE_EVENT(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define BTM_TRACE_DEBUG(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
@ -303,7 +306,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
*/
#define SDP_TRACE_ERROR(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define SDP_TRACE_WARNING(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
#define SDP_TRACE_API(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define SDP_TRACE_API(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define SDP_TRACE_EVENT(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define SDP_TRACE_DEBUG(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
@ -318,7 +321,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
/* Generic Access Profile traces */
#define GAP_TRACE_ERROR(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define GAP_TRACE_EVENT(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define GAP_TRACE_WARNING(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
/* define traces for HID Host */
@ -340,7 +343,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
#define PAN_TRACE_ERROR(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define PAN_TRACE_WARNING(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
#define PAN_TRACE_API(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define PAN_TRACE_API(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define PAN_TRACE_EVENT(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define PAN_TRACE_DEBUG(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
@ -350,7 +353,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
#define A2D_TRACE_WARNING(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
#define A2D_TRACE_EVENT(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define A2D_TRACE_DEBUG(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
#define A2D_TRACE_API(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define A2D_TRACE_API(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
/* AVDTP
*/
@ -382,7 +385,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
#define MCA_TRACE_WARNING(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
#define MCA_TRACE_EVENT(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define MCA_TRACE_DEBUG(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
#define MCA_TRACE_API(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define MCA_TRACE_API(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
/* Define tracing for the ATT/GATT unit
*/
@ -396,7 +399,7 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
*/
#define SMP_TRACE_ERROR(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
#define SMP_TRACE_WARNING(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
#define SMP_TRACE_EVENT(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
#define SMP_TRACE_DEBUG(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
@ -419,6 +422,158 @@ extern UINT8 btif_trace_level;
#define APPL_TRACE_DEBUG(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
#define APPL_TRACE_VERBOSE(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE) BT_PRINTF(fmt, ## args);}
#else
#define LOG_ERROR(fmt, args...)
#define LOG_WARN(fmt, args...)
#define LOG_INFO(fmt, args...)
#define LOG_DEBUG(fmt, args...)
#define LOG_VERBOSE(fmt, args...)
/* Define tracing for the HCI unit
*/
#define HCI_TRACE_ERROR(fmt, args...)
#define HCI_TRACE_WARNING(fmt, args...)
#define HCI_TRACE_EVENT(fmt, args...)
#define HCI_TRACE_DEBUG(fmt, args...)
/* Define tracing for BTM
*/
#define BTM_TRACE_ERROR(fmt, args...)
#define BTM_TRACE_WARNING(fmt, args...)
#define BTM_TRACE_API(fmt, args...)
#define BTM_TRACE_EVENT(fmt, args...)
#define BTM_TRACE_DEBUG(fmt, args...)
/* Define tracing for the L2CAP unit
*/
#define L2CAP_TRACE_ERROR(fmt, args...)
#define L2CAP_TRACE_WARNING(fmt, args...)
#define L2CAP_TRACE_API(fmt, args...)
#define L2CAP_TRACE_EVENT(fmt, args...)
#define L2CAP_TRACE_DEBUG(fmt, args...)
/* Define tracing for the SDP unit
*/
#define SDP_TRACE_ERROR(fmt, args...)
#define SDP_TRACE_WARNING(fmt, args...)
#define SDP_TRACE_API(fmt, args...)
#define SDP_TRACE_EVENT(fmt, args...)
#define SDP_TRACE_DEBUG(fmt, args...)
/* Define tracing for the RFCOMM unit
*/
#define RFCOMM_TRACE_ERROR(fmt, args...)
#define RFCOMM_TRACE_WARNING(fmt, args...)
#define RFCOMM_TRACE_API(fmt, args...)
#define RFCOMM_TRACE_EVENT(fmt, args...)
#define RFCOMM_TRACE_DEBUG(fmt, args...)
/* Generic Access Profile traces */
#define GAP_TRACE_ERROR(fmt, args...)
#define GAP_TRACE_EVENT(fmt, args...)
#define GAP_TRACE_API(fmt, args...)
#define GAP_TRACE_WARNING(fmt, args...)
/* define traces for HID Host */
#define HIDH_TRACE_ERROR(fmt, args...)
#define HIDH_TRACE_WARNING(fmt, args...)
#define HIDH_TRACE_API(fmt, args...)
#define HIDH_TRACE_EVENT(fmt, args...)
#define HIDH_TRACE_DEBUG(fmt, args...)
/* define traces for BNEP */
#define BNEP_TRACE_ERROR(fmt, args...)
#define BNEP_TRACE_WARNING(fmt, args...)
#define BNEP_TRACE_API(fmt, args...)
#define BNEP_TRACE_EVENT(fmt, args...)
#define BNEP_TRACE_DEBUG(fmt, args...)
/* define traces for PAN */
#define PAN_TRACE_ERROR(fmt, args...)
#define PAN_TRACE_WARNING(fmt, args...)
#define PAN_TRACE_API(fmt, args...)
#define PAN_TRACE_EVENT(fmt, args...)
#define PAN_TRACE_DEBUG(fmt, args...)
/* Define tracing for the A2DP profile
*/
#define A2D_TRACE_ERROR(fmt, args...)
#define A2D_TRACE_WARNING(fmt, args...)
#define A2D_TRACE_EVENT(fmt, args...)
#define A2D_TRACE_DEBUG(fmt, args...)
#define A2D_TRACE_API(fmt, args...)
/* AVDTP
*/
#define AVDT_TRACE_ERROR(fmt, args...)
#define AVDT_TRACE_WARNING(fmt, args...)
#define AVDT_TRACE_EVENT(fmt, args...)
#define AVDT_TRACE_DEBUG(fmt, args...)
#define AVDT_TRACE_API(fmt, args...)
/* Define tracing for the AVCTP protocol
*/
#define AVCT_TRACE_ERROR(fmt, args...)
#define AVCT_TRACE_WARNING(fmt, args...)
#define AVCT_TRACE_EVENT(fmt, args...)
#define AVCT_TRACE_DEBUG(fmt, args...)
#define AVCT_TRACE_API(fmt, args...)
/* Define tracing for the AVRCP profile
*/
#define AVRC_TRACE_ERROR(fmt, args...)
#define AVRC_TRACE_WARNING(fmt, args...)
#define AVRC_TRACE_EVENT(fmt, args...)
#define AVRC_TRACE_DEBUG(fmt, args...)
#define AVRC_TRACE_API(fmt, args...)
/* MCAP
*/
#define MCA_TRACE_ERROR(fmt, args...)
#define MCA_TRACE_WARNING(fmt, args...)
#define MCA_TRACE_EVENT(fmt, args...)
#define MCA_TRACE_DEBUG(fmt, args...)
#define MCA_TRACE_API(fmt, args...)
/* Define tracing for the ATT/GATT unit
*/
#define GATT_TRACE_ERROR(fmt, args...)
#define GATT_TRACE_WARNING(fmt, args...)
#define GATT_TRACE_API(fmt, args...)
#define GATT_TRACE_EVENT(fmt, args...)
#define GATT_TRACE_DEBUG(fmt, args...)
/* Define tracing for the SMP unit
*/
#define SMP_TRACE_ERROR(fmt, args...)
#define SMP_TRACE_WARNING(fmt, args...)
#define SMP_TRACE_API(fmt, args...)
#define SMP_TRACE_EVENT(fmt, args...)
#define SMP_TRACE_DEBUG(fmt, args...)
extern UINT8 btif_trace_level;
// define traces for application
#define BTIF_TRACE_ERROR(fmt, args...)
#define BTIF_TRACE_WARNING(fmt, args...)
#define BTIF_TRACE_API(fmt, args...)
#define BTIF_TRACE_EVENT(fmt, args...)
#define BTIF_TRACE_DEBUG(fmt, args...)
#define BTIF_TRACE_VERBOSE(fmt, args...)
/* define traces for application */
#define APPL_TRACE_ERROR(fmt, args...)
#define APPL_TRACE_WARNING(fmt, args...)
#define APPL_TRACE_API(fmt, args...)
#define APPL_TRACE_EVENT(fmt, args...)
#define APPL_TRACE_DEBUG(fmt, args...)
#define APPL_TRACE_VERBOSE(fmt, args...)
#endif ///CONFIG_BT_STACK_NO_LOG
/* Simplified Trace Helper Macro
*/
#define bdld(fmt, args...) \

View File

@ -41,7 +41,7 @@ typedef int32_t INT32;
typedef bool BOOLEAN;
#define PACKED __packed
#define INLINE __inline
// #define INLINE __inline
#define BCM_STRCPY_S(x1,x2,x3) strcpy((x1),(x3))
#define BCM_STRNCPY_S(x1,x2,x3,x4) strncpy((x1),(x3),(x4))

View File

@ -0,0 +1,46 @@
/******************************************************************************
*
* 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.
*
******************************************************************************/
#ifndef BT_UTILS_H
#define BT_UTILS_H
// static const char BT_UTILS_MODULE[] = "bt_utils_module";
/*******************************************************************************
** Type definitions
********************************************************************************/
typedef enum {
TASK_HIGH_MEDIA = 0,
TASK_HIGH_GKI_TIMER,
TASK_HIGH_BTU,
TASK_HIGH_HCI_WORKER,
TASK_HIGH_USERIAL_READ,
TASK_UIPC_READ,
TASK_JAVA_ALARM,
TASK_HIGH_MAX
} tHIGH_PRIORITY_TASK;
/*******************************************************************************
** Functions
********************************************************************************/
void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task);
void adjust_priority_a2dp(int start);
#define UNUSED(x) (void)(x)
#endif /* BT_UTILS_H */

View File

@ -635,7 +635,7 @@ typedef struct {
} tBTA_DM_PIN_REQ;
/* BLE related definition */
#if (SMP_INCLUDED == TRUE)
#define BTA_DM_AUTH_FAIL_BASE (HCI_ERR_MAX_ERR + 10)
#define BTA_DM_AUTH_CONVERT_SMP_CODE(x) (BTA_DM_AUTH_FAIL_BASE + (x))
#define BTA_DM_AUTH_SMP_PASSKEY_FAIL BTA_DM_AUTH_CONVERT_SMP_CODE (SMP_PASSKEY_ENTRY_FAIL)
@ -655,7 +655,7 @@ typedef struct {
#define BTA_DM_AUTH_SMP_BUSY (BTA_DM_AUTH_FAIL_BASE + SMP_BUSY)
#define BTA_DM_AUTH_SMP_ENC_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_FAIL)
#define BTA_DM_AUTH_SMP_RSP_TIMEOUT (BTA_DM_AUTH_FAIL_BASE + SMP_RSP_TIMEOUT)
#endif ///SMP_INCLUDED == TRUE
/* connection parameter boundary value and dummy value */
#define BTA_DM_BLE_SCAN_INT_MIN BTM_BLE_SCAN_INT_MIN
#define BTA_DM_BLE_SCAN_INT_MAX BTM_BLE_SCAN_INT_MAX
@ -668,13 +668,14 @@ typedef struct {
#define BTA_DM_BLE_CONN_SUP_TOUT_MAX BTM_BLE_CONN_SUP_TOUT_MAX
#define BTA_DM_BLE_CONN_PARAM_UNDEF BTM_BLE_CONN_PARAM_UNDEF /* use this value when a specific value not to be overwritten */
#if (SMP_INCLUDED == TRUE)
#define BTA_LE_KEY_PENC BTM_LE_KEY_PENC /* encryption information of peer device */
#define BTA_LE_KEY_PID BTM_LE_KEY_PID /* identity key of the peer device */
#define BTA_LE_KEY_PCSRK BTM_LE_KEY_PCSRK /* peer SRK */
#define BTA_LE_KEY_LENC BTM_LE_KEY_LENC /* master role security information:div */
#define BTA_LE_KEY_LID BTM_LE_KEY_LID /* master device ID key */
#define BTA_LE_KEY_LCSRK BTM_LE_KEY_LCSRK /* local CSRK has been deliver to peer */
#endif ///SMP_INCLUDED == TRUE
typedef UINT8 tBTA_LE_KEY_TYPE; /* can be used as a bit mask */
@ -702,10 +703,11 @@ typedef struct {
BT_OCTET16 irk;
BT_OCTET16 dhk;
} tBTA_BLE_LOCAL_ID_KEYS;
#if (SMP_INCLUDED == TRUE)
#define BTA_DM_SEC_GRANTED BTA_SUCCESS
#define BTA_DM_SEC_PAIR_NOT_SPT BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT
#define BTA_DM_SEC_REP_ATTEMPTS BTA_DM_AUTH_SMP_REPEATED_ATTEMPT
#endif ///SMP_INCLUDED == TRUE
typedef UINT8 tBTA_DM_BLE_SEC_GRANT;
@ -810,6 +812,7 @@ typedef tBTM_AUTH_REQ tBTA_AUTH_REQ;
#define BTA_AUTH_GEN_BOND BTM_AUTH_SPGB_NO /* 4 this bit is set for general bonding */
#define BTA_AUTH_BONDS BTM_AUTH_BONDS /* 6 the general/dedicated bonding bits */
#if (SMP_INCLUDED == TRUE)
#define BTA_LE_AUTH_NO_BOND BTM_LE_AUTH_REQ_NO_BOND /* 0*/
#define BTA_LE_AUTH_BOND BTM_LE_AUTH_REQ_BOND /* 1 << 0 */
#define BTA_LE_AUTH_REQ_MITM BTM_LE_AUTH_REQ_MITM /* 1 << 2 */
@ -818,6 +821,7 @@ typedef tBTM_AUTH_REQ tBTA_AUTH_REQ;
#define BTA_LE_AUTH_REQ_SC_BOND BTM_LE_AUTH_REQ_SC_BOND /* 1001 */
#define BTA_LE_AUTH_REQ_SC_MITM BTM_LE_AUTH_REQ_SC_MITM /* 1100 */
#define BTA_LE_AUTH_REQ_SC_MITM_BOND BTM_LE_AUTH_REQ_SC_MITM_BOND /* 1101 */
#endif ///SMP_INCLUDED == TRUE
typedef tBTM_LE_AUTH_REQ tBTA_LE_AUTH_REQ; /* combination of the above bit pattern */
#define BTA_OOB_NONE BTM_OOB_NONE
@ -1099,7 +1103,9 @@ typedef void (tBTA_BLE_SCAN_SETUP_CBACK) (tBTA_BLE_BATCH_SCAN_EVT evt,
tBTA_DM_BLE_REF_VALUE ref_value,
tBTA_STATUS status);
typedef void (tBTA_START_SCAN_CMPL_CBACK) (tBTA_STATUS status);
typedef void (tBTA_START_STOP_SCAN_CMPL_CBACK) (tBTA_STATUS status);
typedef void (tBTA_START_STOP_ADV_CMPL_CBACK) (tBTA_STATUS status);
typedef void (tBTA_BLE_TRACK_ADV_CMPL_CBACK)(int action, tBTA_STATUS status,
tBTA_DM_BLE_PF_AVBL_SPACE avbl_space,
@ -1283,7 +1289,7 @@ typedef void (tBTA_DM_SWITCH_CBACK)(tBTA_DM_SWITCH_EVT event, tBTA_STATUS status
typedef UINT8 tBTA_DM_ROUTE_PATH;
#if (SDP_INCLUDED == TRUE)
/* Device Identification (DI) data structure
*/
/* Used to set the DI record */
@ -1292,6 +1298,7 @@ typedef tSDP_DI_RECORD tBTA_DI_RECORD;
typedef tSDP_DI_GET_RECORD tBTA_DI_GET_RECORD;
/* SDP discovery database */
typedef tSDP_DISCOVERY_DB tBTA_DISCOVERY_DB;
#endif ///SDP_INCLUDED == TRUE
#ifndef BTA_DI_NUM_MAX
#define BTA_DI_NUM_MAX 3
@ -1444,9 +1451,9 @@ extern void BTA_DmSearchCancel(void);
** Returns void
**
*******************************************************************************/
#if (SDP_INCLUDED == TRUE)
extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
// btla-specific ++
/*******************************************************************************
**
@ -1461,7 +1468,7 @@ extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
*******************************************************************************/
extern void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
#endif ///SDP_INCLUDED == TRUE
/*******************************************************************************
**
** Function BTA_DmGetCachedRemoteName
@ -1617,7 +1624,7 @@ extern void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services );
*******************************************************************************/
extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr );
#if (SDP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTA_DmSetLocalDiRecord
@ -1629,7 +1636,7 @@ extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr );
*******************************************************************************/
extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
UINT32 *p_handle );
#endif ///SDP_INCLUDED == TRUE
/*******************************************************************************
**
**
@ -2004,7 +2011,7 @@ extern void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport,
*******************************************************************************/
extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
tBTA_DM_SEARCH_CBACK *p_results_cb,
tBTA_START_SCAN_CMPL_CBACK *p_start_scan_cb);
tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_stop_scan_cb);
extern void BTA_DmBleStopAdvertising(void);
@ -2111,11 +2118,12 @@ extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_l
** Description This function starts or stops LE broadcasting.
**
** Parameters start: start or stop broadcast.
** p_start_stop_adv_cb: stop broadcast completed event
**
** Returns None
**
*******************************************************************************/
extern void BTA_DmBleBroadcast (BOOLEAN start);
extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p_start_stop_adv_cb);
/*******************************************************************************

View File

@ -0,0 +1,144 @@
/******************************************************************************
*
* Copyright (C) 2004-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 is the public interface file for the simulatenous advanced
* audio/video streaming (AV) source and sink of BTA, Broadcom's Bluetooth
* application layer for mobile phones.
*
******************************************************************************/
#ifndef BTA_AR_API_H
#define BTA_AR_API_H
#include "avdt_api.h"
#include "avct_api.h"
#include "avrc_api.h"
#include "sdp_api.h"
#include "bta_av_api.h"
#include "bta_sys.h"
#if (BTA_AR_INCLUDED == TRUE)
/*****************************************************************************
** Constants and data types
*****************************************************************************/
/* This event signal to AR user that other profile is connected */
#define BTA_AR_AVDT_CONN_EVT (AVDT_MAX_EVT + 1)
/*******************************************************************************
**
** Function bta_ar_init
**
** Description This function is called from bta_sys_init().
** to initialize the control block
**
** Returns void
**
*******************************************************************************/
extern void bta_ar_init(void);
/*******************************************************************************
**
** Function bta_ar_reg_avdt
**
** Description This function is called to register to AVDTP.
**
** Returns void
**
*******************************************************************************/
extern void bta_ar_reg_avdt(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback, tBTA_SYS_ID sys_id);
/*******************************************************************************
**
** Function bta_ar_dereg_avdt
**
** Description This function is called to de-register from AVDTP.
**
** Returns void
**
*******************************************************************************/
extern void bta_ar_dereg_avdt(tBTA_SYS_ID sys_id);
/*******************************************************************************
**
** Function bta_ar_avdt_conn
**
** Description This function is called to let ar know that some AVDTP profile
** is connected for this sys_id.
** If the other sys modules started a timer for PENDING_EVT,
** the timer can be stopped now.
**
** Returns void
**
*******************************************************************************/
extern void bta_ar_avdt_conn(tBTA_SYS_ID sys_id, BD_ADDR bd_addr);
/*******************************************************************************
**
** Function bta_ar_reg_avct
**
** Description This function is called to register to AVCTP.
**
** Returns void
**
*******************************************************************************/
extern void bta_ar_reg_avct(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask, tBTA_SYS_ID sys_id);
/*******************************************************************************
**
** Function bta_ar_dereg_avct
**
** Description This function is called to deregister from AVCTP.
**
** Returns void
**
*******************************************************************************/
extern void bta_ar_dereg_avct(tBTA_SYS_ID sys_id);
/******************************************************************************
**
** Function bta_ar_reg_avrc
**
** Description This function is called to register an SDP record for AVRCP.
**
** Returns void
**
******************************************************************************/
extern void bta_ar_reg_avrc(UINT16 service_uuid, char *p_service_name,
char *p_provider_name, UINT16 categories, tBTA_SYS_ID sys_id);
/******************************************************************************
**
** Function bta_ar_dereg_avrc
**
** Description This function is called to de-register/delete an SDP record for AVRCP.
**
** Returns void
**
******************************************************************************/
extern void bta_ar_dereg_avrc(UINT16 service_uuid, tBTA_SYS_ID sys_id);
#ifdef __cplusplus
}
#endif
#endif ///BTA_AR_INCLUDED == TRUE
#endif /* BTA_AR_API_H */

View File

@ -0,0 +1,812 @@
/******************************************************************************
*
* Copyright (C) 2004-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 is the public interface file for the advanced audio/video streaming
* (AV) subsystem of BTA, Broadcom's Bluetooth application layer for mobile
* phones.
*
******************************************************************************/
#ifndef BTA_AV_API_H
#define BTA_AV_API_H
#include "avrc_api.h"
#include "avdt_api.h"
#include "a2d_api.h"
#include "bta_api.h"
#if (BTA_AV_INCLUDED == TRUE)
/*****************************************************************************
** Constants and data types
*****************************************************************************/
/* Set to TRUE if seperate authorization prompt desired for AVCTP besides A2DP authorization */
/* Typically FALSE when AVRCP is used in conjunction with A2DP */
#ifndef BTA_AV_WITH_AVCTP_AUTHORIZATION
#define BTA_AV_WITH_AVCTP_AUTHORIZATION FALSE
#endif
/* AV status values */
#define BTA_AV_SUCCESS 0 /* successful operation */
#define BTA_AV_FAIL 1 /* generic failure */
#define BTA_AV_FAIL_SDP 2 /* service not found */
#define BTA_AV_FAIL_STREAM 3 /* stream connection failed */
#define BTA_AV_FAIL_RESOURCES 4 /* no resources */
#define BTA_AV_FAIL_ROLE 5 /* failed due to role management related issues */
#define BTA_AV_FAIL_GET_CAP 6 /* get capability failed due to no SEP availale on the peer */
typedef UINT8 tBTA_AV_STATUS;
/* AV features masks */
#define BTA_AV_FEAT_RCTG 0x0001 /* remote control target */
#define BTA_AV_FEAT_RCCT 0x0002 /* remote control controller */
#define BTA_AV_FEAT_PROTECT 0x0004 /* streaming media contect protection */
#define BTA_AV_FEAT_VENDOR 0x0008 /* remote control vendor dependent commands */
#define BTA_AV_FEAT_REPORT 0x0020 /* use reporting service for VDP */
#define BTA_AV_FEAT_METADATA 0x0040 /* remote control Metadata Transfer command/response */
#define BTA_AV_FEAT_MULTI_AV 0x0080 /* use multi-av, if controller supports it */
#define BTA_AV_FEAT_BROWSE 0x0010 /* use browsing channel */
#define BTA_AV_FEAT_MASTER 0x0100 /* stream only as master role */
#define BTA_AV_FEAT_ADV_CTRL 0x0200 /* remote control Advanced Control command/response */
#define BTA_AV_FEAT_DELAY_RPT 0x0400 /* allow delay reporting */
#define BTA_AV_FEAT_ACP_START 0x0800 /* start stream when 2nd SNK was accepted */
/* Internal features */
#define BTA_AV_FEAT_NO_SCO_SSPD 0x8000 /* Do not suspend av streaming as to AG events(SCO or Call) */
typedef UINT16 tBTA_AV_FEAT;
/* AV channel values */
#define BTA_AV_CHNL_MSK 0xC0
#define BTA_AV_CHNL_AUDIO 0x40 /* audio channel */
#define BTA_AV_CHNL_VIDEO 0x80 /* video channel */
typedef UINT8 tBTA_AV_CHNL;
#define BTA_AV_HNDL_MSK 0x3F
typedef UINT8 tBTA_AV_HNDL;
/* handle index to mask */
#define BTA_AV_HNDL_TO_MSK(h) ((UINT8)(1 << (h)))
/* tBTA_AV_HNDL to mask */
#define BTA_AV_HNDL_TYPE_TO_MSK(h) ((UINT8)(1 << (h&BTA_AV_HNDL_MSK)))
/* offset of codec type in codec info byte array */
#define BTA_AV_CODEC_TYPE_IDX AVDT_CODEC_TYPE_INDEX /* 2 */
/* maximum number of streams created: 1 for audio, 1 for video */
#ifndef BTA_AV_NUM_STRS
#define BTA_AV_NUM_STRS 2
#endif
#ifndef BTA_AV_MAX_SEPS
#define BTA_AV_MAX_SEPS 2
#endif
#ifndef BTA_AV_MAX_A2DP_MTU
/*#define BTA_AV_MAX_A2DP_MTU 668 //224 (DM5) * 3 - 4(L2CAP header) */
#define BTA_AV_MAX_A2DP_MTU 1008
#endif
#ifndef BTA_AV_MAX_VDP_MTU
#define BTA_AV_MAX_VDP_MTU 1008
#endif
/* codec type */
#define BTA_AV_CODEC_SBC A2D_MEDIA_CT_SBC /* SBC media codec type */
#define BTA_AV_CODEC_M12 A2D_MEDIA_CT_M12 /* MPEG-1, 2 Audio media codec type */
#define BTA_AV_CODEC_M24 A2D_MEDIA_CT_M24 /* MPEG-2, 4 AAC media codec type */
#define BTA_AV_CODEC_ATRAC A2D_MEDIA_CT_ATRAC /* ATRAC family media codec type */
#define BTA_AV_CODEC_H263_P0 VDP_MEDIA_CT_H263_P0 /* H.263 baseline (profile 0) */
#define BTA_AV_CODEC_MPEG4 VDP_MEDIA_CT_MPEG4 /* MPEG-4 Visual Simple Profile */
#define BTA_AV_CODEC_H263_P3 VDP_MEDIA_CT_H263_P3 /* H.263 profile 3 */
#define BTA_AV_CODEC_H263_P8 VDP_MEDIA_CT_H263_P8 /* H.263 profile 8 */
#define BTA_AV_CODEC_VEND VDP_MEDIA_CT_VEND /* Non-VDP */
typedef UINT8 tBTA_AV_CODEC;
/* Company ID in BT assigned numbers */
#define BTA_AV_BT_VENDOR_ID VDP_BT_VENDOR_ID /* Broadcom Corporation */
/* vendor specific codec ID */
#define BTA_AV_CODEC_ID_H264 VDP_CODEC_ID_H264 /* Non-VDP codec ID - H.264 */
#define BTA_AV_CODEC_ID_IMG VDP_CODEC_ID_IMG /* Non-VDP codec ID - images/slideshow */
/* operation id list for BTA_AvRemoteCmd */
#define BTA_AV_RC_SELECT AVRC_ID_SELECT /* select */
#define BTA_AV_RC_UP AVRC_ID_UP /* up */
#define BTA_AV_RC_DOWN AVRC_ID_DOWN /* down */
#define BTA_AV_RC_LEFT AVRC_ID_LEFT /* left */
#define BTA_AV_RC_RIGHT AVRC_ID_RIGHT /* right */
#define BTA_AV_RC_RIGHT_UP AVRC_ID_RIGHT_UP /* right-up */
#define BTA_AV_RC_RIGHT_DOWN AVRC_ID_RIGHT_DOWN /* right-down */
#define BTA_AV_RC_LEFT_UP AVRC_ID_LEFT_UP /* left-up */
#define BTA_AV_RC_LEFT_DOWN AVRC_ID_LEFT_DOWN /* left-down */
#define BTA_AV_RC_ROOT_MENU AVRC_ID_ROOT_MENU /* root menu */
#define BTA_AV_RC_SETUP_MENU AVRC_ID_SETUP_MENU /* setup menu */
#define BTA_AV_RC_CONT_MENU AVRC_ID_CONT_MENU /* contents menu */
#define BTA_AV_RC_FAV_MENU AVRC_ID_FAV_MENU /* favorite menu */
#define BTA_AV_RC_EXIT AVRC_ID_EXIT /* exit */
#define BTA_AV_RC_0 AVRC_ID_0 /* 0 */
#define BTA_AV_RC_1 AVRC_ID_1 /* 1 */
#define BTA_AV_RC_2 AVRC_ID_2 /* 2 */
#define BTA_AV_RC_3 AVRC_ID_3 /* 3 */
#define BTA_AV_RC_4 AVRC_ID_4 /* 4 */
#define BTA_AV_RC_5 AVRC_ID_5 /* 5 */
#define BTA_AV_RC_6 AVRC_ID_6 /* 6 */
#define BTA_AV_RC_7 AVRC_ID_7 /* 7 */
#define BTA_AV_RC_8 AVRC_ID_8 /* 8 */
#define BTA_AV_RC_9 AVRC_ID_9 /* 9 */
#define BTA_AV_RC_DOT AVRC_ID_DOT /* dot */
#define BTA_AV_RC_ENTER AVRC_ID_ENTER /* enter */
#define BTA_AV_RC_CLEAR AVRC_ID_CLEAR /* clear */
#define BTA_AV_RC_CHAN_UP AVRC_ID_CHAN_UP /* channel up */
#define BTA_AV_RC_CHAN_DOWN AVRC_ID_CHAN_DOWN /* channel down */
#define BTA_AV_RC_PREV_CHAN AVRC_ID_PREV_CHAN /* previous channel */
#define BTA_AV_RC_SOUND_SEL AVRC_ID_SOUND_SEL /* sound select */
#define BTA_AV_RC_INPUT_SEL AVRC_ID_INPUT_SEL /* input select */
#define BTA_AV_RC_DISP_INFO AVRC_ID_DISP_INFO /* display information */
#define BTA_AV_RC_HELP AVRC_ID_HELP /* help */
#define BTA_AV_RC_PAGE_UP AVRC_ID_PAGE_UP /* page up */
#define BTA_AV_RC_PAGE_DOWN AVRC_ID_PAGE_DOWN /* page down */
#define BTA_AV_RC_POWER AVRC_ID_POWER /* power */
#define BTA_AV_RC_VOL_UP AVRC_ID_VOL_UP /* volume up */
#define BTA_AV_RC_VOL_DOWN AVRC_ID_VOL_DOWN /* volume down */
#define BTA_AV_RC_MUTE AVRC_ID_MUTE /* mute */
#define BTA_AV_RC_PLAY AVRC_ID_PLAY /* play */
#define BTA_AV_RC_STOP AVRC_ID_STOP /* stop */
#define BTA_AV_RC_PAUSE AVRC_ID_PAUSE /* pause */
#define BTA_AV_RC_RECORD AVRC_ID_RECORD /* record */
#define BTA_AV_RC_REWIND AVRC_ID_REWIND /* rewind */
#define BTA_AV_RC_FAST_FOR AVRC_ID_FAST_FOR /* fast forward */
#define BTA_AV_RC_EJECT AVRC_ID_EJECT /* eject */
#define BTA_AV_RC_FORWARD AVRC_ID_FORWARD /* forward */
#define BTA_AV_RC_BACKWARD AVRC_ID_BACKWARD /* backward */
#define BTA_AV_RC_ANGLE AVRC_ID_ANGLE /* angle */
#define BTA_AV_RC_SUBPICT AVRC_ID_SUBPICT /* subpicture */
#define BTA_AV_RC_F1 AVRC_ID_F1 /* F1 */
#define BTA_AV_RC_F2 AVRC_ID_F2 /* F2 */
#define BTA_AV_RC_F3 AVRC_ID_F3 /* F3 */
#define BTA_AV_RC_F4 AVRC_ID_F4 /* F4 */
#define BTA_AV_RC_F5 AVRC_ID_F5 /* F5 */
#define BTA_AV_VENDOR AVRC_ID_VENDOR /* vendor unique */
typedef UINT8 tBTA_AV_RC;
/* state flag for pass through command */
#define BTA_AV_STATE_PRESS AVRC_STATE_PRESS /* key pressed */
#define BTA_AV_STATE_RELEASE AVRC_STATE_RELEASE /* key released */
typedef UINT8 tBTA_AV_STATE;
/* command codes for BTA_AvVendorCmd */
#define BTA_AV_CMD_CTRL AVRC_CMD_CTRL
#define BTA_AV_CMD_STATUS AVRC_CMD_STATUS
#define BTA_AV_CMD_SPEC_INQ AVRC_CMD_SPEC_INQ
#define BTA_AV_CMD_NOTIF AVRC_CMD_NOTIF
#define BTA_AV_CMD_GEN_INQ AVRC_CMD_GEN_INQ
typedef UINT8 tBTA_AV_CMD;
/* response codes for BTA_AvVendorRsp */
#define BTA_AV_RSP_NOT_IMPL AVRC_RSP_NOT_IMPL
#define BTA_AV_RSP_ACCEPT AVRC_RSP_ACCEPT
#define BTA_AV_RSP_REJ AVRC_RSP_REJ
#define BTA_AV_RSP_IN_TRANS AVRC_RSP_IN_TRANS
#define BTA_AV_RSP_IMPL_STBL AVRC_RSP_IMPL_STBL
#define BTA_AV_RSP_CHANGED AVRC_RSP_CHANGED
#define BTA_AV_RSP_INTERIM AVRC_RSP_INTERIM
typedef UINT8 tBTA_AV_CODE;
/* error codes for BTA_AvProtectRsp */
#define BTA_AV_ERR_NONE A2D_SUCCESS /* Success, no error */
#define BTA_AV_ERR_BAD_STATE AVDT_ERR_BAD_STATE /* Message cannot be processed in this state */
#define BTA_AV_ERR_RESOURCE AVDT_ERR_RESOURCE /* Insufficient resources */
#define BTA_AV_ERR_BAD_CP_TYPE A2D_BAD_CP_TYPE /* The requested Content Protection Type is not supported */
#define BTA_AV_ERR_BAD_CP_FORMAT A2D_BAD_CP_FORMAT /* The format of Content Protection Data is not correct */
typedef UINT8 tBTA_AV_ERR;
/* AV callback events */
#define BTA_AV_ENABLE_EVT 0 /* AV enabled */
#define BTA_AV_REGISTER_EVT 1 /* registered to AVDT */
#define BTA_AV_OPEN_EVT 2 /* connection opened */
#define BTA_AV_CLOSE_EVT 3 /* connection closed */
#define BTA_AV_START_EVT 4 /* stream data transfer started */
#define BTA_AV_STOP_EVT 5 /* stream data transfer stopped */
#define BTA_AV_PROTECT_REQ_EVT 6 /* content protection request */
#define BTA_AV_PROTECT_RSP_EVT 7 /* content protection response */
#define BTA_AV_RC_OPEN_EVT 8 /* remote control channel open */
#define BTA_AV_RC_CLOSE_EVT 9 /* remote control channel closed */
#define BTA_AV_REMOTE_CMD_EVT 10 /* remote control command */
#define BTA_AV_REMOTE_RSP_EVT 11 /* remote control response */
#define BTA_AV_VENDOR_CMD_EVT 12 /* vendor dependent remote control command */
#define BTA_AV_VENDOR_RSP_EVT 13 /* vendor dependent remote control response */
#define BTA_AV_RECONFIG_EVT 14 /* reconfigure response */
#define BTA_AV_SUSPEND_EVT 15 /* suspend response */
#define BTA_AV_PENDING_EVT 16 /* incoming connection pending:
* signal channel is open and stream is not open
* after BTA_AV_SIG_TIME_VAL ms */
#define BTA_AV_META_MSG_EVT 17 /* metadata messages */
#define BTA_AV_REJECT_EVT 18 /* incoming connection rejected */
#define BTA_AV_RC_FEAT_EVT 19 /* remote control channel peer supported features update */
#define BTA_AV_MEDIA_SINK_CFG_EVT 20 /* command to configure codec */
#define BTA_AV_MEDIA_DATA_EVT 21 /* sending data to Media Task */
/* Max BTA event */
#define BTA_AV_MAX_EVT 22
/* function types for call-out functions */
typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info,
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps,
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
UINT8 *p_num_protect, UINT8 *p_protect_info);
typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
UINT8 num_protect, UINT8 *p_protect_info,
UINT8 t_local_sep, UINT8 avdt_handle);
typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl,
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
UINT16 mtu);
typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu);
typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr);
typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
typedef void *(*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type,
UINT32 *p_len, UINT32 *p_timestamp);
typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay);
/* the call-out functions for one stream */
typedef struct {
tBTA_AV_CO_INIT init;
tBTA_AV_CO_DISC_RES disc_res;
tBTA_AV_CO_GETCFG getcfg;
tBTA_AV_CO_SETCFG setcfg;
tBTA_AV_CO_OPEN open;
tBTA_AV_CO_CLOSE close;
tBTA_AV_CO_START start;
tBTA_AV_CO_STOP stop;
tBTA_AV_CO_DATAPATH data;
tBTA_AV_CO_DELAY delay;
} tBTA_AV_CO_FUNCTS;
typedef UINT8 tBTA_AV_EVT;
/* Event associated with BTA_AV_ENABLE_EVT */
typedef struct {
tBTA_AV_FEAT features;
} tBTA_AV_ENABLE;
/* Event associated with BTA_AV_REGISTER_EVT */
typedef struct {
tBTA_AV_CHNL chnl; /* audio/video */
tBTA_AV_HNDL hndl; /* Handle associated with the stream. */
UINT8 app_id; /* ID associated with call to BTA_AvRegister() */
tBTA_AV_STATUS status;
tBTA_AV_CO_FUNCTS *p_bta_av_cos;
} tBTA_AV_REGISTER;
/* data associated with BTA_AV_OPEN_EVT */
#define BTA_AV_EDR_2MBPS 0x01
#define BTA_AV_EDR_3MBPS 0x02
typedef UINT8 tBTA_AV_EDR;
typedef struct {
tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl;
BD_ADDR bd_addr;
tBTA_AV_STATUS status;
BOOLEAN starting;
tBTA_AV_EDR edr; /* 0, if peer device does not support EDR */
UINT8 sep; /* sep type of peer device */
} tBTA_AV_OPEN;
/* data associated with BTA_AV_CLOSE_EVT */
typedef struct {
tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl;
UINT8 disc_rsn; /* disconnection reason */
} tBTA_AV_CLOSE;
/* data associated with BTA_AV_START_EVT */
typedef struct {
tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl;
tBTA_AV_STATUS status;
BOOLEAN initiator; /* TRUE, if local device initiates the START */
BOOLEAN suspending;
} tBTA_AV_START;
/* data associated with BTA_AV_SUSPEND_EVT */
typedef struct {
tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl;
BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */
tBTA_AV_STATUS status;
} tBTA_AV_SUSPEND;
/* data associated with BTA_AV_RECONFIG_EVT */
typedef struct {
tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl;
tBTA_AV_STATUS status;
} tBTA_AV_RECONFIG;
/* data associated with BTA_AV_PROTECT_REQ_EVT */
typedef struct {
tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl;
UINT8 *p_data;
UINT16 len;
} tBTA_AV_PROTECT_REQ;
/* data associated with BTA_AV_PROTECT_RSP_EVT */
typedef struct {
tBTA_AV_CHNL chnl;
tBTA_AV_HNDL hndl;
UINT8 *p_data;
UINT16 len;
tBTA_AV_ERR err_code;
} tBTA_AV_PROTECT_RSP;
/* data associated with BTA_AV_RC_OPEN_EVT */
typedef struct {
UINT8 rc_handle;
tBTA_AV_FEAT peer_features;
BD_ADDR peer_addr;
tBTA_AV_STATUS status;
} tBTA_AV_RC_OPEN;
/* data associated with BTA_AV_RC_CLOSE_EVT */
typedef struct {
UINT8 rc_handle;
BD_ADDR peer_addr;
} tBTA_AV_RC_CLOSE;
/* data associated with BTA_AV_RC_FEAT_EVT */
typedef struct {
UINT8 rc_handle;
tBTA_AV_FEAT peer_features;
} tBTA_AV_RC_FEAT;
/* data associated with BTA_AV_REMOTE_CMD_EVT */
typedef struct {
UINT8 rc_handle;
tBTA_AV_RC rc_id;
tBTA_AV_STATE key_state;
UINT8 len;
UINT8 *p_data;
tAVRC_HDR hdr; /* Message header. */
UINT8 label;
} tBTA_AV_REMOTE_CMD;
/* data associated with BTA_AV_REMOTE_RSP_EVT */
typedef struct {
UINT8 rc_handle;
tBTA_AV_RC rc_id;
tBTA_AV_STATE key_state;
UINT8 len;
UINT8 *p_data;
tBTA_AV_CODE rsp_code;
UINT8 label;
} tBTA_AV_REMOTE_RSP;
/* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */
typedef struct {
UINT8 rc_handle;
UINT16 len; /* Max vendor dependent message is 512 */
UINT8 label;
tBTA_AV_CODE code;
UINT32 company_id;
UINT8 *p_data;
} tBTA_AV_VENDOR;
/* data associated with BTA_AV_META_MSG_EVT */
typedef struct {
UINT8 rc_handle;
UINT16 len;
UINT8 label;
tBTA_AV_CODE code;
UINT32 company_id;
UINT8 *p_data;
tAVRC_MSG *p_msg;
} tBTA_AV_META_MSG;
/* data associated with BTA_AV_PENDING_EVT */
typedef struct {
BD_ADDR bd_addr;
} tBTA_AV_PEND;
/* data associated with BTA_AV_REJECT_EVT */
typedef struct {
BD_ADDR bd_addr;
tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the connection. */
} tBTA_AV_REJECT;
/* union of data associated with AV callback */
typedef union {
tBTA_AV_CHNL chnl;
tBTA_AV_ENABLE enable;
tBTA_AV_REGISTER registr;
tBTA_AV_OPEN open;
tBTA_AV_CLOSE close;
tBTA_AV_START start;
tBTA_AV_PROTECT_REQ protect_req;
tBTA_AV_PROTECT_RSP protect_rsp;
tBTA_AV_RC_OPEN rc_open;
tBTA_AV_RC_CLOSE rc_close;
tBTA_AV_REMOTE_CMD remote_cmd;
tBTA_AV_REMOTE_RSP remote_rsp;
tBTA_AV_VENDOR vendor_cmd;
tBTA_AV_VENDOR vendor_rsp;
tBTA_AV_RECONFIG reconfig;
tBTA_AV_SUSPEND suspend;
tBTA_AV_PEND pend;
tBTA_AV_META_MSG meta_msg;
tBTA_AV_REJECT reject;
tBTA_AV_RC_FEAT rc_feat;
} tBTA_AV;
/* union of data associated with AV Media callback */
typedef union {
BT_HDR *p_data;
UINT8 *codec_info;
} tBTA_AV_MEDIA;
#define BTA_AVC_PACKET_LEN AVRC_PACKET_LEN
#define BTA_VENDOR_DATA_OFFSET 6
#define BTA_VENDOR_HEADER_LEN 4
#define BTA_MAX_VENDOR_DEPENDENT_DATA_LEN (BTA_AVC_PACKET_LEN-BTA_VENDOR_DATA_OFFSET-BTA_VENDOR_HEADER_LEN)
#define BTA_GROUP_NAVI_MSG_OP_DATA_LEN 5
#define BTA_ERROR_INVALID_CMD AVRC_STS_BAD_CMD
#define BTA_ERROR_INVALID_PARAM AVRC_STS_BAD_PARAM
#define BTA_ERROR_BAD_CONTENTS AVRC_STS_NOT_FOUND
#define BTA_ERROR_INTERNAL AVRC_STS_INTERNAL_ERR
#define BTA_AV_META_SINGLE_PACKET AVRC_PKT_SINGLE
#define BTA_AV_CO_METADATA AVRC_CO_METADATA
/* AV callback */
typedef void (tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV *p_data);
typedef void (tBTA_AV_DATA_CBACK)(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data);
/* type for stream state machine action functions */
typedef void (*tBTA_AV_ACT)(void *p_cb, void *p_data);
/* type for registering VDP */
typedef void (tBTA_AV_REG) (tAVDT_CS *p_cs, char *p_service_name, void *p_data);
/* AV configuration structure */
typedef struct {
UINT32 company_id; /* AVRCP Company ID */
UINT16 avrc_mtu; /* AVRCP MTU at L2CAP for control channel */
UINT16 avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */
UINT16 avrc_ct_cat; /* AVRCP controller categories */
UINT16 avrc_tg_cat; /* AVRCP target categories */
UINT16 sig_mtu; /* AVDTP signaling channel MTU at L2CAP */
UINT16 audio_mtu; /* AVDTP audio transport channel MTU at L2CAP */
const UINT16 *p_audio_flush_to;/* AVDTP audio transport channel flush timeout */
UINT16 audio_mqs; /* AVDTP audio channel max data queue size */
UINT16 video_mtu; /* AVDTP video transport channel MTU at L2CAP */
UINT16 video_flush_to; /* AVDTP video transport channel flush timeout */
BOOLEAN avrc_group; /* TRUE, to accept AVRC 1.3 group nevigation command */
UINT8 num_co_ids; /* company id count in p_meta_co_ids */
UINT8 num_evt_ids; /* event id count in p_meta_evt_ids */
tBTA_AV_CODE rc_pass_rsp; /* the default response code for pass through commands */
const UINT32 *p_meta_co_ids;/* the metadata Get Capabilities response for company id */
const UINT8 *p_meta_evt_ids;/* the the metadata Get Capabilities response for event id */
const tBTA_AV_ACT *p_act_tbl;/* the action function table for VDP stream */
tBTA_AV_REG *p_reg; /* action function to register VDP */
char avrc_controller_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP controller name */
char avrc_target_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP target name*/
} tBTA_AV_CFG;
#ifdef __cplusplus
extern "C"
{
#endif
/*****************************************************************************
** External Function Declarations
*****************************************************************************/
/*******************************************************************************
**
** Function BTA_AvEnable
**
** Description Enable the advanced audio/video service. When the enable
** operation is complete the callback function will be
** called with a BTA_AV_ENABLE_EVT. This function must
** be called before other function in the AV API are
** called.
**
** Returns void
**
*******************************************************************************/
void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features,
tBTA_AV_CBACK *p_cback);
/*******************************************************************************
**
** Function BTA_AvDisable
**
** Description Disable the advanced audio/video service.
**
**
** Returns void
**
*******************************************************************************/
void BTA_AvDisable(void);
/*******************************************************************************
**
** Function BTA_AvRegister
**
** Description Register the audio or video service to stack. When the
** operation is complete the callback function will be
** called with a BTA_AV_REGISTER_EVT. This function must
** be called before AVDT stream is open.
**
**
** Returns void
**
*******************************************************************************/
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name,
UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos);
/*******************************************************************************
**
** Function BTA_AvDeregister
**
** Description Deregister the audio or video service
**
** Returns void
**
*******************************************************************************/
void BTA_AvDeregister(tBTA_AV_HNDL hndl);
/*******************************************************************************
**
** Function BTA_AvOpen
**
** Description Opens an advanced audio/video connection to a peer device.
** When connection is open callback function is called
** with a BTA_AV_OPEN_EVT.
**
** Returns void
**
*******************************************************************************/
void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle,
BOOLEAN use_rc, tBTA_SEC sec_mask, UINT16 uuid);
/*******************************************************************************
**
** Function BTA_AvClose
**
** Description Close the current streams.
**
** Returns void
**
*******************************************************************************/
void BTA_AvClose(tBTA_AV_HNDL handle);
/*******************************************************************************
**
** Function BTA_AvDisconnect
**
** Description Close the connection to the address.
**
** Returns void
**
*******************************************************************************/
void BTA_AvDisconnect(BD_ADDR bd_addr);
/*******************************************************************************
**
** Function BTA_AvEnable_Sink
**
** Description Enable/Disable A2DP Sink.
**
** Returns void
**
*******************************************************************************/
void BTA_AvEnable_Sink(int enable);
/*******************************************************************************
**
** Function BTA_AvStart
**
** Description Start audio/video stream data transfer.
**
** Returns void
**
*******************************************************************************/
void BTA_AvStart(void);
/*******************************************************************************
**
** Function BTA_AvStop
**
** Description Stop audio/video stream data transfer.
** If suspend is TRUE, this function sends AVDT suspend signal
** to the connected peer(s).
**
** Returns void
**
*******************************************************************************/
void BTA_AvStop(BOOLEAN suspend);
/*******************************************************************************
**
** Function BTA_AvReconfig
**
** Description Reconfigure the audio/video stream.
** If suspend is TRUE, this function tries the suspend/reconfigure
** procedure first.
** If suspend is FALSE or when suspend/reconfigure fails,
** this function closes and re-opens the AVDT connection.
**
** Returns void
**
*******************************************************************************/
void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx,
UINT8 *p_codec_info, UINT8 num_protect, UINT8 *p_protect_info);
/*******************************************************************************
**
** Function BTA_AvProtectReq
**
** Description Send a content protection request. This function can only
** be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
**
** Returns void
**
*******************************************************************************/
void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len);
/*******************************************************************************
**
** Function BTA_AvProtectRsp
**
** Description Send a content protection response. This function must
** be called if a BTA_AV_PROTECT_REQ_EVT is received.
** This function can only be used if AV is enabled with
** feature BTA_AV_FEAT_PROTECT.
**
** Returns void
**
*******************************************************************************/
void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data,
UINT16 len);
/*******************************************************************************
**
** Function BTA_AvRemoteCmd
**
** Description Send a remote control command. This function can only
** be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
**
** Returns void
**
*******************************************************************************/
void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id,
tBTA_AV_STATE key_state);
/*******************************************************************************
**
** Function BTA_AvVendorCmd
**
** Description Send a vendor dependent remote control command. This
** function can only be used if AV is enabled with feature
** BTA_AV_FEAT_VENDOR.
**
** Returns void
**
*******************************************************************************/
void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code,
UINT8 *p_data, UINT16 len);
/*******************************************************************************
**
** Function BTA_AvVendorRsp
**
** Description Send a vendor dependent remote control response.
** This function must be called if a BTA_AV_VENDOR_CMD_EVT
** is received. This function can only be used if AV is
** enabled with feature BTA_AV_FEAT_VENDOR.
**
** Returns void
**
*******************************************************************************/
void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
UINT8 *p_data, UINT16 len, UINT32 company_id);
/*******************************************************************************
**
** Function BTA_AvOpenRc
**
** Description Open an AVRCP connection toward the device with the
** specified handle
**
** Returns void
**
*******************************************************************************/
void BTA_AvOpenRc(tBTA_AV_HNDL handle);
/*******************************************************************************
**
** Function BTA_AvCloseRc
**
** Description Close an AVRCP connection
**
** Returns void
**
*******************************************************************************/
void BTA_AvCloseRc(UINT8 rc_handle);
/*******************************************************************************
**
** Function BTA_AvMetaRsp
**
** Description Send a Metadata command/response. The message contained
** in p_pkt can be composed with AVRC utility functions.
** This function can only be used if AV is enabled with feature
** BTA_AV_FEAT_METADATA.
**
** Returns void
**
*******************************************************************************/
void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
BT_HDR *p_pkt);
/*******************************************************************************
**
** Function BTA_AvMetaCmd
**
** Description Send a Metadata/Advanced Control command. The message contained
** in p_pkt can be composed with AVRC utility functions.
** This function can only be used if AV is enabled with feature
** BTA_AV_FEAT_METADATA.
** This message is sent only when the peer supports the TG role.
*8 The only command makes sense right now is the absolute volume command.
**
** Returns void
**
*******************************************************************************/
void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p_pkt);
#ifdef __cplusplus
}
#endif
#endif ///BTA_AV_INCLUDED == TRUE
#endif /* BTA_AV_API_H */

View File

@ -0,0 +1,77 @@
/******************************************************************************
*
* Copyright (C) 2005-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 is the interface file for advanced audio/video call-in functions.
*
******************************************************************************/
#ifndef BTA_AV_CI_H
#define BTA_AV_CI_H
#include "bta_av_api.h"
#if (BTA_AV_INCLUDED == TRUE)
/*****************************************************************************
** Function Declarations
*****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
**
** Function bta_av_ci_src_data_ready
**
** Description This function sends an event to the AV indicating that
** the phone has audio stream data ready to send and AV
** should call bta_av_co_audio_src_data_path() or
** bta_av_co_video_src_data_path().
**
** Returns void
**
*******************************************************************************/
extern void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl);
/*******************************************************************************
**
** Function bta_av_ci_setconfig
**
** Description This function must be called in response to function
** bta_av_co_audio_setconfig() or bta_av_co_video_setconfig.
** Parameter err_code is set to an AVDTP status value;
** AVDT_SUCCESS if the codec configuration is ok,
** otherwise error.
**
** Returns void
**
*******************************************************************************/
extern void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code,
UINT8 category, UINT8 num_seid, UINT8 *p_seid,
BOOLEAN recfg_needed, UINT8 avdt_handle);
#ifdef __cplusplus
}
#endif
#endif ///BTA_AV_INCLUDED == TRUE
#endif /* BTA_AV_CI_H */

View File

@ -0,0 +1,393 @@
/******************************************************************************
*
* 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 is the interface file for advanced audio/video call-out functions.
*
******************************************************************************/
#ifndef BTA_AV_CO_H
#define BTA_AV_CO_H
#include "l2c_api.h"
#include "bta_av_api.h"
#if (BTA_AV_INCLUDED == TRUE)
/*****************************************************************************
** Constants and data types
*****************************************************************************/
/* TRUE to use SCMS-T content protection */
#ifndef BTA_AV_CO_CP_SCMS_T
#define BTA_AV_CO_CP_SCMS_T FALSE
#endif
/* the content protection IDs assigned by BT SIG */
#define BTA_AV_CP_SCMS_T_ID 0x0002
#define BTA_AV_CP_DTCP_ID 0x0001
#define BTA_AV_CP_LOSC 2
#define BTA_AV_CP_INFO_LEN 3
#define BTA_AV_CP_SCMS_COPY_MASK 3
#define BTA_AV_CP_SCMS_COPY_FREE 2
#define BTA_AV_CP_SCMS_COPY_ONCE 1
#define BTA_AV_CP_SCMS_COPY_NEVER 0
#define BTA_AV_CO_DEFAULT_AUDIO_OFFSET AVDT_MEDIA_OFFSET
enum {
BTA_AV_CO_ST_INIT,
BTA_AV_CO_ST_IN,
BTA_AV_CO_ST_OUT,
BTA_AV_CO_ST_OPEN,
BTA_AV_CO_ST_STREAM
};
/* 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_INFO;
/*******************************************************************************
**
** Function bta_av_co_audio_init
**
** Description This callout function is executed by AV when it is
** started by calling BTA_AvEnable(). This function can be
** used by the phone to initialize audio paths or for other
** initialization purposes.
**
**
** Returns Stream codec and content protection capabilities info.
**
*******************************************************************************/
extern BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info,
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
/*******************************************************************************
**
** Function bta_av_co_audio_disc_res
**
** Description This callout function is executed by AV to report the
** number of stream end points (SEP) were found during the
** AVDT stream discovery process.
**
**
** Returns void.
**
*******************************************************************************/
extern void bta_av_co_audio_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps,
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
/*******************************************************************************
**
** Function bta_av_co_video_disc_res
**
** Description This callout function is executed by AV to report the
** number of stream end points (SEP) were found during the
** AVDT stream discovery process.
**
**
** Returns void.
**
*******************************************************************************/
extern void bta_av_co_video_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps,
UINT8 num_snk, BD_ADDR addr);
/*******************************************************************************
**
** Function bta_av_co_audio_getconfig
**
** Description This callout function is executed by AV to retrieve the
** desired codec and content protection configuration for the
** audio stream.
**
**
** Returns Stream codec and content protection configuration info.
**
*******************************************************************************/
extern UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
UINT8 *p_num_protect, UINT8 *p_protect_info);
/*******************************************************************************
**
** Function bta_av_co_video_getconfig
**
** Description This callout function is executed by AV to retrieve the
** desired codec and content protection configuration for the
** video stream.
**
**
** Returns Stream codec and content protection configuration info.
**
*******************************************************************************/
extern UINT8 bta_av_co_video_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
UINT8 *p_num_protect, UINT8 *p_protect_info);
/*******************************************************************************
**
** Function bta_av_co_audio_setconfig
**
** Description This callout function is executed by AV to set the
** codec and content protection configuration of the audio stream.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
UINT8 num_protect, UINT8 *p_protect_info, UINT8 t_local_sep, UINT8 avdt_handle);
/*******************************************************************************
**
** Function bta_av_co_video_setconfig
**
** Description This callout function is executed by AV to set the
** codec and content protection configuration of the video stream.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_video_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
UINT8 num_protect, UINT8 *p_protect_info);
/*******************************************************************************
**
** Function bta_av_co_audio_open
**
** Description This function is called by AV when the audio stream connection
** is opened.
** BTA-AV maintains the MTU of A2DP streams.
** If this is the 2nd audio stream, mtu is the smaller of the 2
** streams.
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_audio_open(tBTA_AV_HNDL hndl,
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
UINT16 mtu);
/*******************************************************************************
**
** Function bta_av_co_video_open
**
** Description This function is called by AV when the video stream connection
** is opened.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_video_open(tBTA_AV_HNDL hndl,
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
UINT16 mtu);
/*******************************************************************************
**
** Function bta_av_co_audio_close
**
** Description This function is called by AV when the audio stream connection
** is closed.
** BTA-AV maintains the MTU of A2DP streams.
** When one stream is closed and no other audio stream is open,
** mtu is reported as 0.
** Otherwise, the MTU remains open is reported.
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_audio_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT16 mtu);
/*******************************************************************************
**
** Function bta_av_co_video_close
**
** Description This function is called by AV when the video stream connection
** is closed.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_video_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT16 mtu);
/*******************************************************************************
**
** Function bta_av_co_audio_start
**
** Description This function is called by AV when the audio streaming data
** transfer is started.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_audio_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr);
/*******************************************************************************
**
** Function bta_av_co_video_start
**
** Description This function is called by AV when the video streaming data
** transfer is started.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_video_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr);
/*******************************************************************************
**
** Function bta_av_co_audio_stop
**
** Description This function is called by AV when the audio streaming data
** transfer is stopped.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_audio_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
/*******************************************************************************
**
** Function bta_av_co_video_stop
**
** Description This function is called by AV when the video streaming data
** transfer is stopped.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_video_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
/*******************************************************************************
**
** Function bta_av_co_audio_src_data_path
**
** Description This function is called to get the next data buffer from
** the audio codec
**
** Returns NULL if data is not ready.
** Otherwise, a GKI buffer (BT_HDR*) containing the audio data.
**
*******************************************************************************/
extern void *bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type,
UINT32 *p_len, UINT32 *p_timestamp);
/*******************************************************************************
**
** Function bta_av_co_video_src_data_path
**
** Description This function is called to get the next data buffer from
** the video codec.
**
** Returns NULL if data is not ready.
** Otherwise, a video data buffer (UINT8*).
**
*******************************************************************************/
extern void *bta_av_co_video_src_data_path(tBTA_AV_CODEC codec_type,
UINT32 *p_len, UINT32 *p_timestamp);
/*******************************************************************************
**
** Function bta_av_co_audio_drop
**
** Description An Audio packet is dropped. .
** It's very likely that the connected headset with this handle
** is moved far away. The implementation may want to reduce
** the encoder bit rate setting to reduce the packet size.
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_audio_drop(tBTA_AV_HNDL hndl);
/*******************************************************************************
**
** Function bta_av_co_video_report_conn
**
** Description This function is called by AV when the reporting channel is
** opened (open=TRUE) or closed (open=FALSE).
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_video_report_conn (BOOLEAN open, UINT8 avdt_handle);
/*******************************************************************************
**
** Function bta_av_co_video_report_rr
**
** Description This function is called by AV when a Receiver Report is
** received
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_video_report_rr (UINT32 packet_lost);
/*******************************************************************************
**
** Function bta_av_co_audio_delay
**
** Description This function is called by AV when the audio stream connection
** needs to send the initial delay report to the connected SRC.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_audio_delay(tBTA_AV_HNDL hndl, UINT16 delay);
/*******************************************************************************
**
** Function bta_av_co_video_delay
**
** Description This function is called by AV when the video stream connection
** needs to send the initial delay report to the connected SRC.
**
**
** Returns void
**
*******************************************************************************/
extern void bta_av_co_video_delay(tBTA_AV_HNDL hndl, UINT16 delay);
#endif ///BTA_AV_INCLUDED == TRUE
#endif /* BTA_AV_CO_H */

View File

@ -0,0 +1,223 @@
/******************************************************************************
*
* Copyright (C) 2004-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 is the interface to utility functions for dealing with SBC data
* frames and codec capabilities.
*
******************************************************************************/
#ifndef BTA_AV_SBC_H
#define BTA_AV_SBC_H
#if (BTA_AV_INCLUDED == TRUE)
/*****************************************************************************
** constants
*****************************************************************************/
/* SBC packet header size */
#define BTA_AV_SBC_HDR_SIZE A2D_SBC_MPL_HDR_LEN
/*******************************************************************************
**
** Function bta_av_sbc_init_up_sample
**
** Description initialize the up sample
**
** src_sps: samples per second (source audio data)
** dst_sps: samples per second (converted audio data)
** bits: number of bits per pcm sample
** n_channels: number of channels (i.e. mono(1), stereo(2)...)
**
** Returns none
**
*******************************************************************************/
extern void bta_av_sbc_init_up_sample (UINT32 src_sps, UINT32 dst_sps,
UINT16 bits, UINT16 n_channels);
/*******************************************************************************
**
** Function bta_av_sbc_up_sample
**
** Description Given the source (p_src) audio data and
** source speed (src_sps, samples per second),
** This function converts it to audio data in the desired format
**
** p_src: the data buffer that holds the source audio data
** p_dst: the data buffer to hold the converted audio data
** src_samples: The number of source samples (number of bytes)
** dst_samples: The size of p_dst (number of bytes)
**
** Note: An AE reported an issue with this function.
** When called with bta_av_sbc_up_sample(src, uint8_array_dst..)
** the byte before uint8_array_dst may get overwritten.
** Using uint16_array_dst avoids the problem.
** This issue is related to endian-ness and is hard to resolve
** in a generic manner.
** **************** Please use uint16 array as dst.
**
** Returns The number of bytes used in p_dst
** The number of bytes used in p_src (in *p_ret)
**
*******************************************************************************/
extern int bta_av_sbc_up_sample (void *p_src, void *p_dst,
UINT32 src_samples, UINT32 dst_samples,
UINT32 *p_ret);
/*******************************************************************************
**
** Function bta_av_sbc_up_sample_16s (16bits-stereo)
**
** Description Given the source (p_src) audio data and
** source speed (src_sps, samples per second),
** This function converts it to audio data in the desired format
**
** p_src: the data buffer that holds the source audio data
** p_dst: the data buffer to hold the converted audio data
** src_samples: The number of source samples (in uint of 4 bytes)
** dst_samples: The size of p_dst (in uint of 4 bytes)
**
** Returns The number of bytes used in p_dst
** The number of bytes used in p_src (in *p_ret)
**
*******************************************************************************/
extern int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst,
UINT32 src_samples, UINT32 dst_samples,
UINT32 *p_ret);
/*******************************************************************************
**
** Function bta_av_sbc_up_sample_16m (16bits-mono)
**
** Description Given the source (p_src) audio data and
** source speed (src_sps, samples per second),
** This function converts it to audio data in the desired format
**
** p_src: the data buffer that holds the source audio data
** p_dst: the data buffer to hold the converted audio data
** src_samples: The number of source samples (in uint of 2 bytes)
** dst_samples: The size of p_dst (in uint of 2 bytes)
**
** Returns The number of bytes used in p_dst
** The number of bytes used in p_src (in *p_ret)
**
*******************************************************************************/
extern int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst,
UINT32 src_samples, UINT32 dst_samples,
UINT32 *p_ret);
/*******************************************************************************
**
** Function bta_av_sbc_up_sample_8s (8bits-stereo)
**
** Description Given the source (p_src) audio data and
** source speed (src_sps, samples per second),
** This function converts it to audio data in the desired format
**
** p_src: the data buffer that holds the source audio data
** p_dst: the data buffer to hold the converted audio data
** src_samples: The number of source samples (in uint of 2 bytes)
** dst_samples: The size of p_dst (in uint of 2 bytes)
**
** Returns The number of bytes used in p_dst
** The number of bytes used in p_src (in *p_ret)
**
*******************************************************************************/
extern int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
UINT32 src_samples, UINT32 dst_samples,
UINT32 *p_ret);
/*******************************************************************************
**
** Function bta_av_sbc_up_sample_8m (8bits-mono)
**
** Description Given the source (p_src) audio data and
** source speed (src_sps, samples per second),
** This function converts it to audio data in the desired format
**
** p_src: the data buffer that holds the source audio data
** p_dst: the data buffer to hold the converted audio data
** src_samples: The number of source samples (number of bytes)
** dst_samples: The size of p_dst (number of bytes)
**
** Returns The number of bytes used in p_dst
** The number of bytes used in p_src (in *p_ret)
**
*******************************************************************************/
extern int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst,
UINT32 src_samples, UINT32 dst_samples,
UINT32 *p_ret);
/*******************************************************************************
**
** Function bta_av_sbc_cfg_for_cap
**
** Description Determine the preferred SBC codec configuration for the
** given codec capabilities. The function is passed the
** preferred codec configuration and the peer codec
** capabilities for the stream. The function attempts to
** match the preferred capabilities with the configuration
** as best it can. The resulting codec configuration is
** returned in the same memory used for the capabilities.
**
** Returns 0 if ok, nonzero if error.
** Codec configuration in p_cap.
**
*******************************************************************************/
extern UINT8 bta_av_sbc_cfg_for_cap(UINT8 *p_peer, tA2D_SBC_CIE *p_cap, tA2D_SBC_CIE *p_pref);
/*******************************************************************************
**
** Function bta_av_sbc_cfg_in_cap
**
** Description This function checks whether an SBC codec configuration
** is allowable for the given codec capabilities.
**
** Returns 0 if ok, nonzero if error.
**
*******************************************************************************/
extern UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap);
/*******************************************************************************
**
** Function bta_av_sbc_cfg_matches_cap
**
** Description This function checks whether an SBC codec configuration
** matched with capabilities. Here we check subset.
**
** Returns 0 if ok, nonzero if error.
**
*******************************************************************************/
extern UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap);
/*******************************************************************************
**
** Function bta_av_sbc_bld_hdr
**
** Description This function builds the packet header for MPF1.
**
** Returns void
**
*******************************************************************************/
extern void bta_av_sbc_bld_hdr(BT_HDR *p_buf, UINT16 fr_per_pkt);
#endif ///BTA_AV_INCLUDED == TRUE
#endif /* BTA_AV_SBC_H */

View File

@ -270,4 +270,13 @@ extern void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
tBTA_LE_KEY_TYPE *p_resp_key );
// btla-specific --
extern void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap);
extern void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req);
extern void bta_dm_co_ble_set_init_key_req(UINT8 init_key);
extern void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key);
extern void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size);
#endif

View File

@ -984,7 +984,7 @@ extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF
** Description This function is called to prepare write a characteristic value.
**
** Parameters conn_id - connection ID.
** p_char_id - GATT characteritic ID of the service.
** p_char_id - GATT characteritic ID of the service.
** offset - offset of the write value.
** len: length of the data to be written.
** p_value - the value to be written.
@ -1001,6 +1001,26 @@ extern void BTA_GATTC_PrepareWrite (UINT16 conn_id,
/*******************************************************************************
**
** Function BTA_GATTC_PrepareWriteCharDescr
**
** Description This function is called to prepare write a characteristic descriptor value.
**
** Parameters conn_id - connection ID.
** p_char_descr_id - GATT characteritic descriptor ID of the service.
** offset - offset of the write value.
** len: length of the data to be written.
** p_value - the value to be written.
**
** Returns None
**
*******************************************************************************/
extern void BTA_GATTC_PrepareWriteCharDescr (UINT16 conn_id,
tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
UINT16 offset,
tBTA_GATT_UNFMT *p_data,
tBTA_GATT_AUTH_REQ auth_req);
/*******************************************************************************
**
** Function BTA_GATTC_ExecuteWrite
**
** Description This function is called to execute write a prepare write sequence.

View File

@ -320,7 +320,7 @@ typedef struct {
} tBTA_GATTC_SERV;
#ifndef BTA_GATTC_NOTIF_REG_MAX
#define BTA_GATTC_NOTIF_REG_MAX 15
#define BTA_GATTC_NOTIF_REG_MAX 7//15
#endif
typedef struct {
@ -398,8 +398,9 @@ typedef struct {
tBTA_GATTC_CLCB clcb[BTA_GATTC_CLCB_MAX];
tBTA_GATTC_SERV known_server[BTA_GATTC_KNOWN_SR_MAX];
#if (SDP_INCLUDED == TRUE)
tSDP_DISCOVERY_DB *p_sdp_db;
#endif ///SDP_INCLUDED == TRUE
UINT16 sdp_conn_id;
} tBTA_GATTC_CB;

View File

@ -20,6 +20,7 @@
#include "bta_api.h"
#include "hidh_api.h"
#if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
#include "gatt_api.h"
@ -538,4 +539,7 @@ extern void bta_hh_le_hid_read_rpt_clt_cfg(BD_ADDR bd_addr, UINT8 rpt_id);
}
#endif
#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
#endif /* BTA_HH_API_H */

View File

@ -30,6 +30,7 @@
#include "bta_api.h"
#include "btm_api.h"
#if (SDP_INCLUDED == TRUE)
/* status values */
#define BTA_SDP_SUCCESS 0 /* Successful operation. */
#define BTA_SDP_FAILURE 1 /* Generic failure. */
@ -70,7 +71,9 @@ typedef void (tBTA_SDP_DM_CBACK)(tBTA_SDP_EVT event, tBTA_SDP *p_data, void *use
/* MCE configuration structure */
typedef struct {
UINT16 sdp_db_size; /* The size of p_sdp_db */
#if (SDP_INCLUDED == TRUE)
tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */
#endif ///SDP_INCLUDED == TRUE
} tBTA_SDP_CFG;
#ifdef __cplusplus
@ -139,4 +142,6 @@ extern tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data);
}
#endif
#endif ///SDP_INCLUDED == TRUE
#endif /* BTA_SDP_API_H */

View File

@ -0,0 +1,30 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __BTC_ALARM_H__
#define __BTC_ALARM_H__
#include <stdint.h>
#include "alarm.h"
/* btc_alarm_args_t */
typedef struct {
osi_alarm_callback_t cb;
void *cb_data;
} btc_alarm_args_t;
void btc_alarm_handler(btc_msg_t *msg);
#endif /* __BTC_ALARM_H__ */

View File

@ -0,0 +1,176 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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.
/*******************************************************************************
*
* Filename: btc_av.h
*
* Description: Main API header file for all BTC AV functions accessed
* from internal stack.
*
*******************************************************************************/
#ifndef __BTC_AV_H__
#define __BTC_AV_H__
#include "esp_a2dp_api.h"
#include "btc_task.h"
#include "btc_common.h"
#include "btc_sm.h"
#include "bta_av_api.h"
#if (BTA_AV_INCLUDED == TRUE)
/*******************************************************************************
** Type definitions for callback functions
********************************************************************************/
typedef enum {
BTC_AV_CONNECT_REQ_EVT = BTA_AV_MAX_EVT,
BTC_AV_DISCONNECT_REQ_EVT,
BTC_AV_START_STREAM_REQ_EVT,
BTC_AV_STOP_STREAM_REQ_EVT,
BTC_AV_SUSPEND_STREAM_REQ_EVT,
BTC_AV_SINK_CONFIG_REQ_EVT,
} btc_av_sm_event_t;
typedef enum {
BTC_AV_SINK_API_INIT_EVT = 0,
BTC_AV_SINK_API_DEINIT_EVT,
BTC_AV_SINK_API_CONNECT_EVT,
BTC_AV_SINK_API_DISCONNECT_EVT,
BTC_AV_SINK_API_REG_DATA_CB_EVT,
} btc_av_act_t;
/* btc_av_args_t */
typedef union {
// BTC_AV_SINK_CONFIG_REQ_EVT -- internal event
esp_a2d_mcc_t mcc;
// BTC_AV_SINK_API_CONNECT_EVT
bt_bdaddr_t connect;
// BTC_AV_SINK_API_REG_DATA_CB_EVT
esp_a2d_data_cb_t data_cb;
} btc_av_args_t;
/*******************************************************************************
** BTC AV API
********************************************************************************/
void btc_a2dp_call_handler(btc_msg_t *msg);
void btc_a2dp_cb_handler(btc_msg_t *msg);
void btc_a2dp_sink_reg_data_cb(esp_a2d_data_cb_t callback);
/*******************************************************************************
**
** Function btc_av_get_sm_handle
**
** Description Fetches current av SM handle
**
** Returns None
**
*******************************************************************************/
btc_sm_handle_t btc_av_get_sm_handle(void);
/*******************************************************************************
**
** Function btc_av_stream_ready
**
** Description Checks whether AV is ready for starting a stream
**
** Returns None
**
*******************************************************************************/
BOOLEAN btc_av_stream_ready(void);
/*******************************************************************************
**
** Function btc_av_stream_started_ready
**
** Description Checks whether AV ready for media start in streaming state
**
** Returns None
**
*******************************************************************************/
BOOLEAN btc_av_stream_started_ready(void);
/*******************************************************************************
**
** Function btc_dispatch_sm_event
**
** Description Send event to AV statemachine
**
** Returns None
**
*******************************************************************************/
/* used to pass events to AV statemachine from other tasks */
void btc_dispatch_sm_event(btc_av_sm_event_t event, void *p_data, int len);
/*******************************************************************************
**
** Function btc_av_init
**
** Description Initializes btc AV if not already done
**
** Returns bt_status_t
**
*******************************************************************************/
bt_status_t btc_av_init(void);
/*******************************************************************************
**
** Function btc_av_is_connected
**
** Description Checks if av has a connected sink
**
** Returns BOOLEAN
**
*******************************************************************************/
BOOLEAN btc_av_is_connected(void);
/*******************************************************************************
**
** Function btc_av_is_peer_edr
**
** Description Check if the connected a2dp device supports
** EDR or not. Only when connected this function
** will accurately provide a true capability of
** remote peer. If not connected it will always be false.
**
** Returns TRUE if remote device is capable of EDR
**
*******************************************************************************/
BOOLEAN btc_av_is_peer_edr(void);
/******************************************************************************
**
** Function btc_av_clear_remote_suspend_flag
**
** Description Clears remote suspended flag
**
** Returns Void
********************************************************************************/
void btc_av_clear_remote_suspend_flag(void);
#endif ///BTA_AV_INCLUDED == TRUE
#endif /* __BTC_AV_H__ */

View File

@ -0,0 +1,203 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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.
/*****************************************************************************
**
** Name: btc_av_api.h
**
** Description: This is the public interface file for the advanced
** audio/video streaming (AV) subsystem of BTC.
**
*****************************************************************************/
#ifndef __BTC_AV_API_H__
#define __BTC_AV_API_H__
#include "bt_target.h"
#include "bta_av_api.h"
#include "btc_media.h"
#include "a2d_api.h"
#include "a2d_sbc.h"
#if (BTC_AV_INCLUDED == TRUE)
/*****************************************************************************
** Constants and data types
*****************************************************************************/
/* Codec type */
#define BTC_AV_CODEC_NONE 0xFF
#define BTC_AV_CODEC_SBC A2D_MEDIA_CT_SBC /* SBC media codec type */
#define BTC_AV_CODEC_PCM 0x5 /* Raw PCM */
typedef UINT8 tBTC_AV_CODEC_ID;
/* AV features masks */
#define BTC_AV_FEAT_RCTG BTA_AV_FEAT_RCTG /* remote control target */
#define BTC_AV_FEAT_RCCT BTA_AV_FEAT_RCCT /* remote control controller */
#define BTC_AV_FEAT_METADATA BTA_AV_FEAT_METADATA /* remote control Metadata Transfer command/response */
typedef UINT16 tBTC_AV_FEAT;
/* AV channel values */
#define BTC_AV_CHNL_MSK BTA_AV_CHNL_MSK
#define BTC_AV_CHNL_AUDIO BTA_AV_CHNL_AUDIO /* audio channel */
#define BTC_AV_CHNL_VIDEO BTA_AV_CHNL_VIDEO /* video channel */
typedef UINT8 tBTC_AV_CHNL;
typedef UINT8 tBTC_AV_HNDL;
/* Operation id list for BTC_AvRemoteCmd */
#define BTC_AV_ID_SELECT 0x00 /* select */
#define BTC_AV_ID_UP 0x01 /* up */
#define BTC_AV_ID_DOWN 0x02 /* down */
#define BTC_AV_ID_LEFT 0x03 /* left */
#define BTC_AV_ID_RIGHT 0x04 /* right */
#define BTC_AV_ID_RIGHT_UP 0x05 /* right-up */
#define BTC_AV_ID_RIGHT_DOWN 0x06 /* right-down */
#define BTC_AV_ID_LEFT_UP 0x07 /* left-up */
#define BTC_AV_ID_LEFT_DOWN 0x08 /* left-down */
#define BTC_AV_ID_ROOT_MENU 0x09 /* root menu */
#define BTC_AV_ID_SETUP_MENU 0x0A /* setup menu */
#define BTC_AV_ID_CONT_MENU 0x0B /* contents menu */
#define BTC_AV_ID_FAV_MENU 0x0C /* favorite menu */
#define BTC_AV_ID_EXIT 0x0D /* exit */
#define BTC_AV_ID_0 0x20 /* 0 */
#define BTC_AV_ID_1 0x21 /* 1 */
#define BTC_AV_ID_2 0x22 /* 2 */
#define BTC_AV_ID_3 0x23 /* 3 */
#define BTC_AV_ID_4 0x24 /* 4 */
#define BTC_AV_ID_5 0x25 /* 5 */
#define BTC_AV_ID_6 0x26 /* 6 */
#define BTC_AV_ID_7 0x27 /* 7 */
#define BTC_AV_ID_8 0x28 /* 8 */
#define BTC_AV_ID_9 0x29 /* 9 */
#define BTC_AV_ID_DOT 0x2A /* dot */
#define BTC_AV_ID_ENTER 0x2B /* enter */
#define BTC_AV_ID_CLEAR 0x2C /* clear */
#define BTC_AV_ID_CHAN_UP 0x30 /* channel up */
#define BTC_AV_ID_CHAN_DOWN 0x31 /* channel down */
#define BTC_AV_ID_PREV_CHAN 0x32 /* previous channel */
#define BTC_AV_ID_SOUND_SEL 0x33 /* sound select */
#define BTC_AV_ID_INPUT_SEL 0x34 /* input select */
#define BTC_AV_ID_DISP_INFO 0x35 /* display information */
#define BTC_AV_ID_HELP 0x36 /* help */
#define BTC_AV_ID_PAGE_UP 0x37 /* page up */
#define BTC_AV_ID_PAGE_DOWN 0x38 /* page down */
#define BTC_AV_ID_POWER 0x40 /* power */
#define BTC_AV_ID_VOL_UP 0x41 /* volume up */
#define BTC_AV_ID_VOL_DOWN 0x42 /* volume down */
#define BTC_AV_ID_MUTE 0x43 /* mute */
#define BTC_AV_ID_PLAY 0x44 /* play */
#define BTC_AV_ID_STOP 0x45 /* stop */
#define BTC_AV_ID_PAUSE 0x46 /* pause */
#define BTC_AV_ID_RECORD 0x47 /* record */
#define BTC_AV_ID_REWIND 0x48 /* rewind */
#define BTC_AV_ID_FAST_FOR 0x49 /* fast forward */
#define BTC_AV_ID_EJECT 0x4A /* eject */
#define BTC_AV_ID_FORWARD 0x4B /* forward */
#define BTC_AV_ID_BACKWARD 0x4C /* backward */
#define BTC_AV_ID_ANGLE 0x50 /* angle */
#define BTC_AV_ID_SUBPICT 0x51 /* subpicture */
#define BTC_AV_ID_F1 0x71 /* F1 */
#define BTC_AV_ID_F2 0x72 /* F2 */
#define BTC_AV_ID_F3 0x73 /* F3 */
#define BTC_AV_ID_F4 0x74 /* F4 */
#define BTC_AV_ID_F5 0x75 /* F5 */
#define BTC_AV_ID_VENDOR 0x7E /* vendor unique */
#define BTC_AV_KEYPRESSED_RELEASE 0x80
typedef UINT8 tBTC_AV_RC;
/* State flag for pass through command */
#define BTC_AV_STATE_PRESS 0 /* key pressed */
#define BTC_AV_STATE_RELEASE 1 /* key released */
typedef UINT8 tBTC_AV_STATE;
typedef UINT8 tBTC_AV_RC_HNDL;
/* Command codes for BTC_AvVendorCmd */
#define BTC_AV_CMD_CTRL 0
#define BTC_AV_CMD_STATUS 1
#define BTC_AV_CMD_SPEC_INQ 2
#define BTC_AV_CMD_NOTIF 3
#define BTC_AV_CMD_GEN_INQ 4
typedef UINT8 tBTC_AV_CMD;
/* AV callback events */
#define BTC_AV_OPEN_EVT 0 /* connection opened */
#define BTC_AV_CLOSE_EVT 1 /* connection closed */
#define BTC_AV_START_EVT 2 /* stream data transfer started */
#define BTC_AV_STOP_EVT 3 /* stream data transfer stopped */
#define BTC_AV_RC_OPEN_EVT 4 /* remote control channel open */
#define BTC_AV_RC_CLOSE_EVT 5 /* remote control channel closed */
#define BTC_AV_REMOTE_CMD_EVT 6 /* remote control command */
#define BTC_AV_REMOTE_RSP_EVT 7 /* remote control response */
#define BTC_AV_META_MSG_EVT 8 /* metadata messages */
typedef UINT8 tBTC_AV_EVT;
#define BTC_AV_FEEDING_ASYNCHRONOUS 0 /* asynchronous feeding, use tx av timer */
#define BTC_AV_FEEDING_SYNCHRONOUS 1 /* synchronous feeding, no av tx timer */
#define BTC_AV_MAX_SYNCHRONOUS_LATENCY 80 /* max latency in ms for BTC_AV_FEEDING_SYNCHRONOUS */
#define BTC_AV_MIN_SYNCHRONOUS_LATENCY 4 /* min latency in ms for BTC_AV_FEEDING_SYNCHRONOUS */
typedef UINT8 tBTC_AV_FEEDING_MODE;
#define BTC_AV_CHANNEL_MODE_MONO A2D_SBC_IE_CH_MD_MONO
#define BTC_AV_CHANNEL_MODE_STEREO A2D_SBC_IE_CH_MD_STEREO
#define BTC_AV_CHANNEL_MODE_JOINT A2D_SBC_IE_CH_MD_JOINT
#define BTC_AV_CHANNEL_MODE_DUAL A2D_SBC_IE_CH_MD_DUAL
typedef UINT8 tBTC_AV_CHANNEL_MODE;
/**
* Structure used to configure the AV codec capabilities/config
*/
typedef struct {
tBTC_AV_CODEC_ID id; /* Codec ID (in terms of BTC) */
UINT8 info[AVDT_CODEC_SIZE]; /* Codec info (can be config or capabilities) */
} tBTC_AV_CODEC_INFO;
/**
* Structure used to configure the AV media feeding
*/
typedef struct {
UINT16 sampling_freq; /* 44100, 48000 etc */
UINT16 num_channel; /* 1 for mono or 2 stereo */
UINT8 bit_per_sample; /* Number of bits per sample (8, 16) */
} tBTC_AV_MEDIA_FEED_CFG_PCM;
typedef union {
tBTC_AV_MEDIA_FEED_CFG_PCM pcm; /* Raw PCM feeding format */
} tBTC_AV_MEDIA_FEED_CFG;
typedef struct {
tBTC_AV_CODEC_ID format; /* Media codec identifier */
tBTC_AV_MEDIA_FEED_CFG cfg; /* Media codec configuration */
} tBTC_AV_MEDIA_FEEDINGS;
#ifdef __cplusplus
}
#endif
#endif ///BTC_AV_INCLUDED == TRUE
#endif /* __BTC_AV_API_H__ */

View File

@ -0,0 +1,172 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __BTC_AV_CO_H__
#define __BTC_AV_CO_H__
#include "btc_media.h"
#if (BTA_AV_INCLUDED == TRUE)
/*******************************************************************************
** Constants & Macros
********************************************************************************/
enum {
BTC_SV_AV_AA_SBC_INDEX = 0,
BTC_SV_AV_AA_SBC_SINK_INDEX,
BTC_SV_AV_AA_SEP_INDEX /* Last index */
};
/*******************************************************************************
** Functions
********************************************************************************/
/*******************************************************************************
**
** Function bta_av_co_cp_is_active
**
** Description Get the current configuration of content protection
**
** Returns TRUE if the current streaming has CP, FALSE otherwise
**
*******************************************************************************/
BOOLEAN bta_av_co_cp_is_active(void);
/*******************************************************************************
**
** Function bta_av_co_cp_get_flag
**
** Description Get content protection flag
** BTA_AV_CP_SCMS_COPY_NEVER
** BTA_AV_CP_SCMS_COPY_ONCE
** BTA_AV_CP_SCMS_COPY_FREE
**
** Returns The current flag value
**
*******************************************************************************/
UINT8 bta_av_co_cp_get_flag(void);
/*******************************************************************************
**
** Function bta_av_co_cp_set_flag
**
** Description Set content protection flag
** BTA_AV_CP_SCMS_COPY_NEVER
** BTA_AV_CP_SCMS_COPY_ONCE
** BTA_AV_CP_SCMS_COPY_FREE
**
** Returns TRUE if setting the SCMS flag is supported else FALSE
**
*******************************************************************************/
BOOLEAN bta_av_co_cp_set_flag(UINT8 cp_flag);
/*******************************************************************************
**
** Function bta_av_co_audio_codec_reset
**
** Description Reset the current codec configuration
**
** Returns void
**
*******************************************************************************/
void bta_av_co_audio_codec_reset(void);
/*******************************************************************************
**
** Function bta_av_co_audio_codec_supported
**
** Description Check if all opened connections are compatible with a codec
** configuration
**
** Returns TRUE if all opened devices support this codec, FALSE otherwise
**
*******************************************************************************/
BOOLEAN bta_av_co_audio_codec_supported(tBTC_STATUS *p_status);
/*******************************************************************************
**
** Function bta_av_co_audio_set_codec
**
** Description Set the current codec configuration from the feeding type.
** This function is starting to modify the configuration, it
** should be protected.
**
** Returns TRUE if successful, FALSE otherwise
**
*******************************************************************************/
BOOLEAN bta_av_co_audio_set_codec(const tBTC_AV_MEDIA_FEEDINGS *p_feeding, tBTC_STATUS *p_status);
/*******************************************************************************
**
** Function bta_av_co_audio_get_sbc_config
**
** Description Retrieves the SBC codec configuration. If the codec in use
** is not SBC, return the default SBC codec configuration.
**
** Returns TRUE if codec is SBC, FALSE otherwise
**
*******************************************************************************/
BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_minmtu);
/*******************************************************************************
**
** Function bta_av_co_audio_discard_config
**
** Description Discard the codec configuration of a connection
**
** Returns Nothing
**
*******************************************************************************/
void bta_av_co_audio_discard_config(tBTA_AV_HNDL hndl);
/*******************************************************************************
**
** Function bta_av_co_init
**
** Description Initialization
**
** Returns Nothing
**
*******************************************************************************/
void bta_av_co_init(void);
/*******************************************************************************
**
** Function bta_av_co_peer_cp_supported
**
** Description Checks if the peer supports CP
**
** Returns TRUE if the peer supports CP
**
*******************************************************************************/
BOOLEAN bta_av_co_peer_cp_supported(tBTA_AV_HNDL hndl);
/*******************************************************************************
**
** Function bta_av_co_get_remote_bitpool_pref
**
** Description Check if remote side did a setconfig within the limits
** of our exported bitpool range. If set we will set the
** remote preference.
**
** Returns TRUE if config set, FALSE otherwize
**
*******************************************************************************/
BOOLEAN bta_av_co_get_remote_bitpool_pref(UINT8 *min, UINT8 *max);
#endif ///BTA_AV_INCLUDED == TRUE
#endif

View File

@ -0,0 +1,77 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* 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 __BTC_AVRC_H__
#define __BTC_AVRC_H__
#include <stdint.h>
#include <stdbool.h>
#include "bt_defs.h"
#include "bt_types.h"
#include "bta_av_api.h"
#if (BTC_AV_INCLUDED == TRUE)
#ifndef BTC_AVRC_TGT_INCLUDED
#define BTC_AVRC_TGT_INCLUDED FALSE
#endif
/* Macros */
typedef enum {
BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */
BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */
BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */
BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */
} btrc_remote_features_t;
typedef enum {
BTC_AVRC_CTRL_API_INIT_EVT = 0,
BTC_AVRC_CTRL_API_DEINIT_EVT,
BTC_AVRC_CTRL_API_SND_PTCMD_EVT
} btc_avrc_act_t;
typedef struct {
uint8_t tl; /* transaction label */
uint8_t key_code;
uint8_t key_state;
} pt_cmd_t;
/* btc_avrc_args_t */
typedef union {
// BTC_AVRC_CTRL_API_SND_PT_CMD_EVT
struct {
uint8_t tl;
uint8_t key_code;
uint8_t key_state;
} pt_cmd;
} btc_avrc_args_t;
/** BT-RC Controller callback structure. */
typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state);
typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr);
void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data);
BOOLEAN btc_rc_get_connected_peer(BD_ADDR peer_addr);
/*******************************************************************************
** BTC AVRC API
********************************************************************************/
void btc_avrc_call_handler(btc_msg_t *msg);
#endif ///BTC_AV_INCLUDED == TRUE
#endif /* __BTC_AVRC_H__ */

View File

@ -0,0 +1,124 @@
// Copyright (C) 2014 The Android Open Source Project
//
// 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.
#include "bt_types.h"
#include "bt_target.h"
#if (SMP_INCLUDED == TRUE)
#define BTC_LE_LOCAL_KEY_IR (1<<0)
#define BTC_LE_LOCAL_KEY_IRK (1<<1)
#define BTC_LE_LOCAL_KEY_DHK (1<<2)
#define BTC_LE_LOCAL_KEY_ER (1<<3)
/************************************************************************************
** Local type definitions
************************************************************************************/
typedef struct
{
uint32_t num_devices;
bt_bdaddr_t devices[BTM_SEC_MAX_DEVICE_RECORDS];
} btc_bonded_devices_t;
typedef struct
{
bool is_penc_key_rcvd;
tBTM_LE_PENC_KEYS penc_key; /* received peer encryption key */
bool is_pcsrk_key_rcvd;
tBTM_LE_PCSRK_KEYS pcsrk_key; /* received peer device SRK */
bool is_pid_key_rcvd;
tBTM_LE_PID_KEYS pid_key; /* peer device ID key */
bool is_lenc_key_rcvd;
tBTM_LE_LENC_KEYS lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
bool is_lcsrk_key_rcvd;
tBTM_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
bool is_lidk_key_rcvd; /* local identity key received */
} btc_dm_ble_cb_t;
typedef struct
{
bt_bdaddr_t static_bdaddr;
BD_ADDR bd_addr;
btc_dm_ble_cb_t ble;
} btc_dm_pairing_cb_t;
typedef struct
{
uint8_t ir[BT_OCTET16_LEN];
uint8_t irk[BT_OCTET16_LEN];
uint8_t dhk[BT_OCTET16_LEN];
}btc_dm_local_key_id_t;
typedef struct
{
bool is_er_rcvd;
uint8_t er[BT_OCTET16_LEN];
bool is_id_keys_rcvd;
btc_dm_local_key_id_t id_keys; /* ID kyes */
}btc_dm_local_key_cb_t;
typedef struct
{
BT_OCTET16 sp_c;
BT_OCTET16 sp_r;
BD_ADDR oob_bdaddr; /* peer bdaddr*/
} btc_dm_oob_cb_t;
extern btc_dm_pairing_cb_t pairing_cb;
extern btc_dm_local_key_cb_t ble_local_key_cb;
bt_status_t btc_storage_load_bonded_ble_devices(void);
bt_status_t btc_in_fetch_bonded_ble_devices(int add);
void btc_dm_remove_ble_bonding_keys(void);
bt_status_t btc_storage_add_ble_bonding_key( bt_bdaddr_t *remote_bd_addr,
char *key,
uint8_t key_type,
uint8_t key_length);
void btc_save_ble_bonding_keys(void);
bt_status_t btc_in_fetch_bonded_ble_device(const char *remote_bd_addr, int add,
btc_bonded_devices_t *p_bonded_devices);
bt_status_t btc_storage_get_ble_bonding_key(bt_bdaddr_t *remote_bd_addr,
uint8_t key_type,
char *key_value,
int key_length);
bt_status_t btc_storage_add_ble_local_key(char *key,
uint8_t key_type,
uint8_t key_length);
bt_status_t btc_storage_remove_ble_bonding_keys(bt_bdaddr_t *remote_bd_addr);
bt_status_t btc_storage_remove_ble_local_keys(void);
bt_status_t btc_storage_get_ble_local_key(uint8_t key_type,
char *key_value,
int key_len);
bt_status_t btc_storage_get_remote_addr_type(bt_bdaddr_t *remote_bd_addr,
int *addr_type);
bt_status_t btc_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr,
uint8_t addr_type);
void btc_dm_load_ble_local_keys(void);
void btc_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er,
tBTA_BLE_LOCAL_ID_KEYS *p_id_keys);
#endif ///SMP_INCLUDED == TRUE

View File

@ -0,0 +1,35 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __BTC_COMMON_H__
#define __BTC_COMMON_H__
#include "bt_trace.h"
#include "bt_types.h"
#include "osi.h"
#define BTC_ASSERTC(cond, msg, val) if (!(cond)) { LOG_ERROR( \
"### ASSERT : %s line %d %s (%d) ###", __FILE__, __LINE__, msg, val);}
#define BTC_HAL_CBACK(P_CB, P_CBACK, ...)\
if (P_CB && P_CB->P_CBACK) { \
LOG_INFO("HAL %s->%s", #P_CB, #P_CBACK); \
P_CB->P_CBACK(__VA_ARGS__); \
} \
else { \
BTC_ASSERTC(0, "Callback is NULL", 0); \
}
#endif /* __BTC_COMMON_H__ */

View File

@ -0,0 +1,54 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __BTC_CONFIG_H__
#define __BTC_CONFIG_H__
#include <stdbool.h>
#include <stddef.h>
#include "bt_types.h"
typedef struct btc_config_section_iter_t btc_config_section_iter_t;
bool btc_config_init(void);
bool btc_config_shut_down(void);
bool btc_config_clean_up(void);
bool btc_config_has_section(const char *section);
bool btc_config_exist(const char *section, const char *key);
bool btc_config_get_int(const char *section, const char *key, int *value);
bool btc_config_set_int(const char *section, const char *key, int value);
bool btc_config_get_str(const char *section, const char *key, char *value, int *size_bytes);
bool btc_config_set_str(const char *section, const char *key, const char *value);
bool btc_config_get_bin(const char *section, const char *key, uint8_t *value, size_t *length);
bool btc_config_set_bin(const char *section, const char *key, const uint8_t *value, size_t length);
bool btc_config_remove(const char *section, const char *key);
size_t btc_config_get_bin_length(const char *section, const char *key);
const btc_config_section_iter_t *btc_config_section_begin(void);
const btc_config_section_iter_t *btc_config_section_end(void);
const btc_config_section_iter_t *btc_config_section_next(const btc_config_section_iter_t *section);
const char *btc_config_section_name(const btc_config_section_iter_t *section);
void btc_config_save(void);
void btc_config_flush(void);
int btc_config_clear(void);
// TODO(zachoverflow): Eww...we need to move these out. These are peer specific, not config general.
bool btc_get_address_type(const BD_ADDR bd_addr, int *p_addr_type);
bool btc_get_device_type(const BD_ADDR bd_addr, int *p_device_type);
#endif

View File

@ -0,0 +1,38 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __BTC_DEV_H__
#define __BTC_DEV_H__
#include "esp_bt_defs.h"
#include "esp_bt_device.h"
#include "btc_task.h"
typedef enum {
BTC_DEV_ACT_SET_DEVICE_NAME
} btc_dev_act_t;
/* btc_dev_args_t */
typedef union {
// BTC_BT_GAP_ACT_SET_DEV_NAME
struct set_bt_dev_name_args {
#define ESP_DEV_DEVICE_NAME_MAX (32)
char device_name[ESP_DEV_DEVICE_NAME_MAX + 1];
} set_dev_name;
} btc_dev_args_t;
void btc_dev_call_handler(btc_msg_t *msg);
#endif /* __BTC_DEV_H__ */

View File

@ -0,0 +1,40 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __BTC_DM_H__
#define __BTC_DM_H__
#include "btc_task.h"
#include "esp_bt_defs.h"
#include "bta_api.h"
typedef enum {
BTC_DM_SEC_ACT
} btc_dm_sec_act_t;
/* btc_dm_args_t */
typedef union {
//BTC_DM_SEC_ACT
tBTA_DM_SEC sec;
} btc_dm_sec_args_t;
// void btc_dm_call_handler(btc_msg_t *msg);
void btc_dm_sec_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *data);
void btc_dm_sec_cb_handler(btc_msg_t *msg);
void btc_dm_sec_arg_deep_copy(btc_msg_t *msg, void *dst, void *src);
bt_status_t btc_dm_enable_service(tBTA_SERVICE_ID service_id);
bt_status_t btc_dm_disable_service(tBTA_SERVICE_ID service_id);
#endif /* __BTC_DM_H__ */

View File

@ -34,6 +34,11 @@ typedef enum {
BTC_GAP_BLE_ACT_SET_DEV_NAME,
BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW,
BTC_GAP_BLE_SET_ENCRYPTION_EVT,
BTC_GAP_BLE_SET_SECURITY_PARAM_EVT,
BTC_GAP_BLE_SECURITY_RSP_EVT,
BTC_GAP_BLE_PASSKEY_REPLY_EVT,
BTC_GAP_BLE_CONFIRM_REPLY_EVT,
} btc_gap_ble_act_t;
/* btc_ble_gap_args_t */
@ -72,12 +77,7 @@ typedef union {
//BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
struct cfg_local_privacy_args {
bool privacy_enable;
} cfg_local_privacy;
//BTC_GAP_BLE_ACT_SET_DEV_NAME,
struct set_dev_name_args {
#define ESP_GAP_DEVICE_NAME_MAX (32)
char device_name[ESP_GAP_DEVICE_NAME_MAX + 1];
} set_dev_name;
} cfg_local_privacy;
//BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
struct config_adv_data_raw_args {
uint8_t *raw_adv;
@ -88,6 +88,33 @@ typedef union {
uint8_t *raw_scan_rsp;
uint32_t raw_scan_rsp_len;
} cfg_scan_rsp_data_raw;
struct set_encryption_args {
esp_bd_addr_t bd_addr;
esp_ble_sec_act_t sec_act;
} set_encryption;
struct set_security_param_args {
esp_ble_sm_param_t param_type;
uint8_t len;
uint8_t *value;
} set_security_param;
struct enc_rsp_args {
esp_bd_addr_t bd_addr;
bool accept;
} sec_rsp;
struct enc_passkey_reply_args {
esp_bd_addr_t bd_addr;
bool accept;
uint32_t passkey;
} enc_passkey_replay;
struct enc_comfirm_reply_args {
esp_bd_addr_t bd_addr;
bool accept;
} enc_comfirm_replay;
} btc_ble_gap_args_t;
void btc_gap_ble_call_handler(btc_msg_t *msg);

View File

@ -15,8 +15,24 @@
#ifndef __BTC_GAP_BT_H__
#define __BTC_GAP_BT_H__
#include "esp_bt_defs.h"
#include "esp_gap_bt_api.h"
#include "btc_task.h"
typedef enum {
BTC_GAP_BT_ACT_SET_SCAN_MODE = 0,
} btc_gap_bt_act_t;
/* btc_bt_gap_args_t */
typedef union {
// BTC_BT_GAP_ACT_SET_SCAN_MODE,
struct set_bt_scan_mode_args {
esp_bt_scan_mode_t mode;
} set_scan_mode;
} btc_gap_bt_args_t;
void btc_gap_bt_call_handler(btc_msg_t *msg);
#define /* __BTC_GAP_BT_H__ */
void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
#endif /* __BTC_GAP_BT_H__ */

View File

@ -38,6 +38,7 @@ typedef enum {
BTC_GATTC_ACT_WRITE_CHAR,
BTC_GATTC_ACT_WRITE_CHAR_DESCR,
BTC_GATTC_ACT_PREPARE_WRITE,
BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR,
BTC_GATTC_ACT_EXECUTE_WRITE,
BTC_GATTC_ACT_REG_FOR_NOTIFY,
BTC_GATTC_ACT_UNREG_FOR_NOTIFY
@ -155,6 +156,17 @@ typedef union {
uint8_t *value;
esp_gatt_auth_req_t auth_req;
} prep_write;
//BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR,
struct prep_write_descr_arg {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
esp_gatt_id_t char_id;
esp_gatt_id_t descr_id;
uint16_t offset;
uint16_t value_len;
uint8_t *value;
esp_gatt_auth_req_t auth_req;
} prep_write_descr;
//BTC_GATTC_ACT_EXECUTE_WRITE,
struct exec_write_arg {
uint16_t conn_id;

View File

@ -123,7 +123,8 @@ typedef union {
} send_rsp;
//BTC_GATTS_SET_ATTR_VALUE
struct set_attr_val_args{
struct set_attr_val_args {
uint16_t handle;
uint16_t length;
uint8_t *value;
} set_attr_val;

View File

@ -0,0 +1,268 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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.
/*******************************************************************************
*
* Filename: btc_media.h
*
* Description: This is the audio module for the BTC system.
*
*******************************************************************************/
#ifndef __BTC_MEDIA_H__
#define __BTC_MEDIA_H__
#include <stdbool.h>
#include "bta_api.h"
#include "gki.h"
#include "btc_av_api.h"
#if (BTA_AV_INCLUDED == TRUE)
/*******************************************************************************
** Constants
*******************************************************************************/
#define BTC_SUCCESS (0)
/**
* AV (Audio Video source) Errors
*/
#define BTC_ERROR_SRV_AV_NOT_ENABLED 700 /* AV is not enabled */
#define BTC_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED 701 /* Requested Feeding not supported */
#define BTC_ERROR_SRV_AV_BUSY 702 /* Another operation ongoing */
#define BTC_ERROR_SRV_AV_NOT_OPENED 703 /* No AV link opened */
#define BTC_ERROR_SRV_AV_NOT_STARTED 704 /* AV is not started */
#define BTC_ERROR_SRV_AV_CP_NOT_SUPPORTED 705 /* Content protection is not supported by all headsets */
/* Transcoding definition for TxTranscoding and RxTranscoding */
#define BTC_MEDIA_TRSCD_OFF 0
#define BTC_MEDIA_TRSCD_PCM_2_SBC 1 /* Tx */
/*******************************************************************************
** Data types
*******************************************************************************/
typedef int tBTC_STATUS;
/* tBTC_MEDIA_INIT_AUDIO msg structure */
typedef struct {
BT_HDR hdr;
UINT16 SamplingFreq; /* 16k, 32k, 44.1k or 48k*/
UINT8 ChannelMode; /* mono, dual, stereo or joint stereo*/
UINT8 NumOfSubBands; /* 4 or 8 */
UINT8 NumOfBlocks; /* 4, 8, 12 or 16*/
UINT8 AllocationMethod; /* loudness or SNR*/
UINT16 MtuSize; /* peer mtu size */
} tBTC_MEDIA_INIT_AUDIO;
#if (BTA_AV_INCLUDED == TRUE)
/* tBTC_MEDIA_UPDATE_AUDIO msg structure */
typedef struct {
BT_HDR hdr;
UINT16 MinMtuSize; /* Minimum peer mtu size */
UINT8 MaxBitPool; /* Maximum peer bitpool */
UINT8 MinBitPool; /* Minimum peer bitpool */
} tBTC_MEDIA_UPDATE_AUDIO;
/* tBTC_MEDIA_INIT_AUDIO_FEEDING msg structure */
typedef struct {
BT_HDR hdr;
tBTC_AV_FEEDING_MODE feeding_mode;
tBTC_AV_MEDIA_FEEDINGS feeding;
} tBTC_MEDIA_INIT_AUDIO_FEEDING;
typedef struct {
BT_HDR hdr;
UINT8 codec_info[AVDT_CODEC_SIZE];
} tBTC_MEDIA_SINK_CFG_UPDATE;
#endif
/*******************************************************************************
** Public functions
*******************************************************************************/
/*******************************************************************************
**
** Function btc_av_task
**
** Description
**
** Returns void
**
*******************************************************************************/
extern void btc_media_task(void);
/*******************************************************************************
**
** Function btc_media_task_enc_init_req
**
** Description Request to initialize the media task encoder
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btc_media_task_enc_init_req(tBTC_MEDIA_INIT_AUDIO *p_msg);
/*******************************************************************************
**
** Function btc_media_task_enc_update_req
**
** Description Request to update the media task encoder
**
** Returns TRUE is success
**
*******************************************************************************/
#if (BTA_AV_INCLUDED == TRUE)
extern BOOLEAN btc_media_task_enc_update_req(tBTC_MEDIA_UPDATE_AUDIO *p_msg);
#endif
/*******************************************************************************
**
** Function btc_media_task_start_aa_req
**
** Description Request to start audio encoding task
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btc_media_task_start_aa_req(void);
/*******************************************************************************
**
** Function btc_media_task_stop_aa_req
**
** Description Request to stop audio encoding task
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btc_media_task_stop_aa_req(void);
/*******************************************************************************
**
** Function btc_media_task_aa_rx_flush_req
**
** Description Request to flush audio decoding pipe
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btc_media_task_aa_rx_flush_req(void);
/*******************************************************************************
**
** Function btc_media_task_aa_tx_flush_req
**
** Description Request to flush audio encoding pipe
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btc_media_task_aa_tx_flush_req(void);
/*******************************************************************************
**
** Function btc_media_aa_readbuf
**
** Description Read an audio GKI buffer from the BTC media TX queue
**
** Returns pointer on a GKI aa buffer ready to send
**
*******************************************************************************/
extern BT_HDR *btc_media_aa_readbuf(void);
/*******************************************************************************
**
** Function btc_media_sink_enque_buf
**
** Description This function is called by the av_co to fill A2DP Sink Queue
**
**
** Returns size of the queue
*******************************************************************************/
UINT8 btc_media_sink_enque_buf(BT_HDR *p_buf);
/*******************************************************************************
**
** Function btc_media_aa_writebuf
**
** Description Enqueue a Advance Audio media GKI buffer to be processed by btc media task.
**
** Returns TRUE is success
**
*******************************************************************************/
extern void btc_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num);
/*******************************************************************************
**
** Function btc_media_av_writebuf
**
** Description Enqueue a video media GKI buffer to be processed by btc media task.
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btc_media_av_writebuf(UINT8 *p_media, UINT32 media_len,
UINT32 timestamp, UINT16 seq_num);
#if (BTA_AV_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btc_media_task_audio_feeding_init_req
**
** Description Request to initialize audio feeding
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btc_media_task_audio_feeding_init_req(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_msg);
#endif
/*******************************************************************************
**
** Function dump_codec_info
**
** Description Decode and display codec_info (for debug)
**
** Returns void
**
*******************************************************************************/
extern void dump_codec_info(unsigned char *p_codec);
/**
* Local adaptation helper functions between btc and media task
*/
bool btc_a2dp_start_media_task(void);
void btc_a2dp_stop_media_task(void);
void btc_a2dp_on_init(void);
void btc_a2dp_setup_codec(void);
void btc_a2dp_on_idle(void);
BOOLEAN btc_a2dp_on_started(tBTA_AV_START *p_av, BOOLEAN pending_start);
void btc_a2dp_on_stop_req(void);
void btc_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av);
void btc_a2dp_on_suspend(void);
void btc_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av);
void btc_a2dp_set_rx_flush(BOOLEAN enable);
void btc_media_check_iop_exceptions(UINT8 *peer_bda);
void btc_reset_decoder(UINT8 *p_av);
int btc_a2dp_get_track_frequency(UINT8 frequency);
int btc_a2dp_get_track_channel_count(UINT8 channeltype);
void btc_a2dp_set_peer_sep(UINT8 sep);
#endif ///BTA_AV_INCLUDED == TRUE
#endif

View File

@ -0,0 +1,55 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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.
/*******************************************************************************
*
* Filename: btc_profile_queue.h
*
* Description: Bluetooth remote device connection queuing
*
*******************************************************************************/
#ifndef __BTC_PROFILE_QUEUE_H__
#define __BTC_PROFILE_QUEUE_H__
#include "bt_defs.h"
#include "btc_task.h"
typedef enum {
BTC_PRF_QUE_CONNECT = 0,
BTC_PRF_QUE_ADVANCE
} btc_prf_que_act_t;
typedef bt_status_t (*btc_connect_cb_t) (bt_bdaddr_t *bda, uint16_t uuid);
typedef struct connect_node_t {
bt_bdaddr_t bda;
uint16_t uuid;
bool busy;
btc_connect_cb_t connect_cb;
} connect_node_t;
/* btc_prf_que_args_t */
typedef union {
// BTC_PRF_QUE_CONNECT
connect_node_t connect_node;
} btc_prf_que_args_t;
bt_status_t btc_queue_connect(uint16_t uuid, const bt_bdaddr_t *bda, btc_connect_cb_t connect_cb);
void btc_queue_advance(void);
bt_status_t btc_queue_connect_next(void);
void btc_queue_release(void);
void btc_profile_queue_handler(btc_msg_t *msg);
#endif /* __BTC_PROFILE_QUEUE_H__ */

View File

@ -1,129 +0,0 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __ESP_SDP_API_H__
#define __ESP_SDP_API_H__
#include <stdint.h>
#include "esp_err.h"
#include "esp_bt_common.h"
#include "bta_sdp_api.h"
#include "bt_sdp.h"
#define BT_SDP_STAT_SUCCESS BTA_SDP_SUCCESS
#define BT_SDP_STAT_FAILURE BTA_SDP_FAILURE
#define BT_SDP_STAT_BUSY BTA_SDP_BUSY
#define BT_SDP_ENABLE_EVT BTA_SDP_ENABLE_EVT
#define BT_SDP_SEARCH_EVT BTA_SDP_SEARCH_EVT
#define BT_SDP_SEARCH_COMP_EVT BTA_SDP_SEARCH_COMP_EVT
#define BT_SDP_CREATE_RECORD_USER_EVT BTA_SDP_CREATE_RECORD_USER_EVT
#define BT_SDP_REMOVE_RECORD_USER_EVT BTA_SDP_REMOVE_RECORD_USER_EVT
#define BT_SDP_MAX_EVT BTA_SDP_MAX_EVT
#define BT_SDP_MAX_RECORDS BTA_SDP_MAX_RECORDS
typedef tBTA_SDP_STATUS bt_sdp_status_t;
typedef tBTA_SDP_EVT bt_sdp_evt_t;
typedef bluetooth_sdp_record bt_sdp_record_t;
/* tBTA_SEARCH_COMP, bta_sdp_api.h */
typedef struct {
bt_sdp_status_t status;
esp_bd_addr_t remote_addr;
esp_bt_uuid_t uuid;
int record_count;
bt_sdp_record_t records[BT_SDP_MAX_RECORDS];
} bt_sdp_search_comp_t;
/* tBTA_SDP, bta_sdp_api.h */
typedef union {
bt_sdp_status_t status;
bt_sdp_search_comp_t sdp_search_comp;
} bt_sdp_t;
typedef void (bt_sdp_cb_t)(bt_sdp_evt_t event, bt_sdp_t *p_data, void *user_data);
esp_err_t esp_bt_sdp_enable(bt_sdp_cb_t *cback);
esp_err_t esp_bt_sdp_search(esp_bd_addr_t bd_addr, esp_bt_uuid_t *uuid);
esp_err_t esp_bt_sdp_create_record_by_user(void *user_data);
esp_err_t esp_bt_sdp_remove_record_by_user(void *user_data);
/**********************************************************************************************/
/**********************************************************************************************/
/* API into SDP for local service database updates
* these APIs are indended to be called in callback function in the context of stack task,
* to handle BT_SDP_CREATE_RECORD_USER_EVT and BT_SDP_REMOVE_RECORD_USER_EVT
*/
/* This structure is used to add protocol lists and find protocol elements */
#define ESP_BT_SDP_MAX_PROTOCOL_PARAMS SDP_MAX_PROTOCOL_PARAMS // bt_target.h
typedef struct {
uint16_t protocol_uuid;
uint16_t num_params;
uint16_t params[ESP_BT_SDP_MAX_PROTOCOL_PARAMS];
} sdp_proto_elem_t; // tSDP_PROTOCOL_ELEM, sdp_api.h
#define ESP_BT_SDP_MAX_LIST_ELEMS SDP_MAX_LIST_ELEMS // sdp_api.h
typedef struct {
uint16_t num_elems;
sdp_proto_elem_t list_elem[ESP_BT_SDP_MAX_LIST_ELEMS];
} sdp_proto_list_elem_t; // tSDP_PROTO_LIST_ELEM, sdp_api.h
uint32_t esp_bt_sdp_create_record(void);
bool esp_bt_sdp_delete_record(uint32_t handle);
int32_t esp_bt_sdp_read_record(uint32_t handle, uint8_t *data, int32_t *data_len);
bool esp_bt_sdp_add_attribute (uint32_t handle, uint16_t attr_id,
uint8_t attr_type, uint32_t attr_len,
uint8_t *p_val);
bool esp_bt_sdp_add_sequence (uint32_t handle, uint16_t attr_id,
uint16_t num_elem, uint8_t type[],
uint8_t len[], uint8_t *p_val[]);
bool esp_bt_sdp_add_uuid_sequence (uint32_t handle, uint16_t attr_id,
uint16_t num_uuids, uint16_t *p_uuids);
bool esp_bt_sdp_add_protocol_list (uint32_t handle, uint16_t num_elem,
sdp_proto_elem_t *p_elem_list);
bool esp_bt_sdp_add_addition_protocol_lists(uint32_t handle, uint16_t num_elem,
sdp_proto_list_elem_t *p_proto_list);
bool esp_bt_sdp_add_profile_dscp_list (uint32_t handle,
uint16_t profile_uuid,
uint16_t version);
bool esp_bt_sdp_add_lang_base_attr_id_list(uint32_t handle,
uint16_t lang, uint16_t char_enc,
uint16_t base_id);
bool esp_bt_sdp_add_service_class_id_list(uint32_t handle,
uint16_t num_services,
uint16_t *p_service_uuids);
bool esp_bt_sdp_delete_attribute(uint32_t handle, uint16_t attr_id);
#endif /* __ESP_SDP_API_H__ */

View File

@ -0,0 +1,115 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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.
/*****************************************************************************
*
* Filename: btc_sm.h
*
* Description: Generic BTC state machine API
*
*****************************************************************************/
#ifndef __BTC_SM_H__
#define __BTC_SM_H__
/*****************************************************************************
** Constants & Macros
******************************************************************************/
/* Generic Enter/Exit state machine events */
#define BTC_SM_ENTER_EVT 0xFFFF
#define BTC_SM_EXIT_EVT 0xFFFE
/*****************************************************************************
** Type definitions and return values
******************************************************************************/
typedef UINT32 btc_sm_state_t;
typedef UINT32 btc_sm_event_t;
typedef void *btc_sm_handle_t;
typedef BOOLEAN (* btc_sm_handler_t)(btc_sm_event_t event, void *data);
/*****************************************************************************
** Functions
**
** NOTE: THESE APIs SHOULD BE INVOKED ONLY IN THE BTC CONTEXT
**
******************************************************************************/
/*****************************************************************************
**
** Function btc_sm_init
**
** Description Initializes the state machine with the state handlers
** The caller should ensure that the table and the corresponding
** states match. The location that 'p_handlers' points to shall
** be available until the btc_sm_shutdown API is invoked.
**
** Returns Returns a pointer to the initialized state machine handle.
**
******************************************************************************/
btc_sm_handle_t btc_sm_init(const btc_sm_handler_t *p_handlers,
btc_sm_state_t initial_state);
/*****************************************************************************
**
** Function btc_sm_shutdown
**
** Description Tears down the state machine
**
** Returns None
**
******************************************************************************/
void btc_sm_shutdown(btc_sm_handle_t handle);
/*****************************************************************************
**
** Function btc_sm_get_state
**
** Description Fetches the current state of the state machine
**
** Returns Current state
**
******************************************************************************/
btc_sm_state_t btc_sm_get_state(btc_sm_handle_t handle);
/*****************************************************************************
**
** Function btc_sm_dispatch
**
** Description Dispatches the 'event' along with 'data' to the current state handler
**
** Returns Returns BT_STATUS_OK on success, BT_STATUS_FAIL otherwise
**
******************************************************************************/
bt_status_t btc_sm_dispatch(btc_sm_handle_t handle, btc_sm_event_t event,
void *data);
/*****************************************************************************
**
** Function btc_sm_change_state
**
** Description Make a transition to the new 'state'. The 'BTC_SM_EXIT_EVT'
** shall be invoked before exiting the current state. The
** 'BTC_SM_ENTER_EVT' shall be invoked before entering the new state
**
**
** Returns Returns BT_STATUS_OK on success, BT_STATUS_FAIL otherwise
**
******************************************************************************/
bt_status_t btc_sm_change_state(btc_sm_handle_t handle, btc_sm_state_t state);
#endif /* __BTC_SM_H__ */

View File

@ -0,0 +1,62 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __BTC_STORAGE_H__
#define __BTC_STORAGE_H__
#include <stdint.h>
#include "bt_defs.h"
#include "bt_types.h"
/*******************************************************************************
**
** Function btc_storage_add_bonded_device
**
** Description BTC storage API - Adds the newly bonded device to NVRAM
** along with the link-key, Key type and Pin key length
**
** Returns BT_STATUS_SUCCESS if the store was successful,
** BT_STATUS_FAIL otherwise
**
*******************************************************************************/
bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
LINK_KEY link_key,
uint8_t key_type,
uint8_t pin_length);
/*******************************************************************************
**
** Function btc_storage_remove_bonded_device
**
** Description BTC storage API - Deletes the bonded device from NVRAM
**
** Returns BT_STATUS_SUCCESS if the deletion was successful,
** BT_STATUS_FAIL otherwise
**
*******************************************************************************/
bt_status_t btc_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr);
/*******************************************************************************
**
** Function btc_storage_remove_bonded_device
**
** Description BTC storage API - Deletes the bonded device from NVRAM
**
** Returns BT_STATUS_SUCCESS if the deletion was successful,
** BT_STATUS_FAIL otherwise
**
*******************************************************************************/
bt_status_t btc_storage_load_bonded_devices(void);
#endif /* BTC_STORAGE_H */

View File

@ -16,6 +16,7 @@
#define __BTC_TASK_H__
#include <stdint.h>
#include "bt_target.h"
#include "bt_defs.h"
#include "thread.h"
@ -35,16 +36,23 @@ typedef enum {
typedef enum {
BTC_PID_MAIN_INIT = 0,
BTC_PID_DEV,
BTC_PID_GATTS,
#if (GATTC_INCLUDED == TRUE)
BTC_PID_GATTC,
#endif ///GATTC_INCLUDED == TRUE
BTC_PID_GAP_BLE,
BTC_PID_GAP_BT,
BTC_PID_SDP,
BTC_PID_BLE_HID,
BTC_PID_BT_HID,
BTC_PID_SPP,
BTC_PID_SPPLIKE,
BTC_PID_BLUFI,
BTC_PID_DM_SEC,
BTC_PID_ALARM,
#if CONFIG_CLASSIC_BT_ENABLED
BTC_PID_GAP_BT,
BTC_PID_PRF_QUE,
BTC_PID_A2DP,
BTC_PID_AVRC,
#endif /* CONFIG_CLASSIC_BT_ENABLED */
BTC_PID_NUM,
} btc_pid_t; //btc profile id

View File

@ -0,0 +1,47 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __BTC_UTIL_H__
#define __BTC_UTIL_H__
#include <stdbool.h>
#include "bt_types.h"
#include "bt_defs.h"
/*******************************************************************************
** Constants & Macros
********************************************************************************/
#define CASE_RETURN_STR(const) case const: return #const;
/*******************************************************************************
** Type definitions for callback functions
********************************************************************************/
typedef char bdstr_t[18];
/*******************************************************************************
** Functions
********************************************************************************/
const char *dump_rc_event(UINT8 event);
const char *dump_rc_notification_event_id(UINT8 event_id);
const char *dump_rc_pdu(UINT8 pdu);
UINT32 devclass2uint(DEV_CLASS dev_class);
void uint2devclass(UINT32 dev, DEV_CLASS dev_class);
void uuid16_to_uuid128(uint16_t uuid16, bt_uuid_t *uuid128);
void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str);
void string_to_uuid(char *str, bt_uuid_t *p_uuid);
#endif /* __BTC_UTIL_H__ */

0
tools/sdk/include/bluedroid/bte_appl.h Executable file → Normal file
View File

View File

@ -1383,6 +1383,11 @@ typedef UINT8 tBTM_IO_CAP;
#define BTM_AUTH_BONDS 6 /* the general/dedicated bonding bits */
#define BTM_AUTH_YN_BIT 1 /* this is the Yes or No bit */
#define BTM_BLE_ENC_KEY_MASK (1 << 0)
#define BTM_BLE_ID_KEY_MASK (1 << 1)
#define BTM_BLE_CSR_KEY_MASK (1 << 2)
#define BTM_BLE_LINK_KEY_MASK (1 << 3)
#define BTM_BLE_INITIATOR_KEY_SIZE 15
#define BTM_BLE_RESPONDER_KEY_SIZE 15
#define BTM_BLE_MAX_KEY_SIZE 16
@ -1526,6 +1531,7 @@ typedef void (tBTM_BOND_CANCEL_CMPL_CALLBACK) (tBTM_STATUS result);
/* LE related event and data structure
*/
#if (SMP_INCLUDED == TRUE)
#define BTM_LE_IO_REQ_EVT SMP_IO_CAP_REQ_EVT /* received IO_CAPABILITY_REQUEST event */
#define BTM_LE_SEC_REQUEST_EVT SMP_SEC_REQUEST_EVT /* security request event */
#define BTM_LE_KEY_NOTIF_EVT SMP_PASSKEY_NOTIF_EVT /* received USER_PASSKEY_NOTIFY event */
@ -1541,8 +1547,10 @@ typedef void (tBTM_BOND_CANCEL_CMPL_CALLBACK) (tBTM_STATUS result);
#define BTM_LE_COMPLT_EVT SMP_COMPLT_EVT /* SMP complete event */
#define BTM_LE_LAST_FROM_SMP BTM_LE_BR_KEYS_REQ_EVT
#define BTM_LE_KEY_EVT BTM_LE_LAST_FROM_SMP + 1 /* KEY update event */
#endif ///SMP_INCLUDED == TRUE
typedef UINT8 tBTM_LE_EVT;
#if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
#define BTM_LE_KEY_NONE 0
#define BTM_LE_KEY_PENC SMP_SEC_KEY_TYPE_ENC /* encryption information of peer device */
#define BTM_LE_KEY_PID SMP_SEC_KEY_TYPE_ID /* identity key of the peer device */
@ -1552,12 +1560,15 @@ typedef UINT8 tBTM_LE_EVT;
#define BTM_LE_KEY_LENC (SMP_SEC_KEY_TYPE_ENC << 4) /* master role security information:div */
#define BTM_LE_KEY_LID (SMP_SEC_KEY_TYPE_ID << 4) /* master device ID key */
#define BTM_LE_KEY_LCSRK (SMP_SEC_KEY_TYPE_CSRK << 4) /* local CSRK has been deliver to peer */
#endif ///BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
typedef UINT8 tBTM_LE_KEY_TYPE;
#if (SMP_INCLUDED == TRUE)
#define BTM_LE_AUTH_REQ_NO_BOND SMP_AUTH_NO_BOND /* 0 */
#define BTM_LE_AUTH_REQ_BOND SMP_AUTH_GEN_BOND /* 1 << 0 */
#define BTM_LE_AUTH_REQ_MITM SMP_AUTH_YN_BIT /* 1 << 2 */
#endif ///SMP_INCLUDED == TRUE
typedef UINT8 tBTM_LE_AUTH_REQ;
#if (SMP_INCLUDED == TRUE)
#define BTM_LE_SC_SUPPORT_BIT SMP_SC_SUPPORT_BIT /* (1 << 3) */
#define BTM_LE_KP_SUPPORT_BIT SMP_KP_SUPPORT_BIT /* (1 << 4) */
@ -1571,6 +1582,7 @@ typedef UINT8 tBTM_LE_AUTH_REQ;
#define BTM_LE_SEC_NONE SMP_SEC_NONE
#define BTM_LE_SEC_UNAUTHENTICATE SMP_SEC_UNAUTHENTICATE /* 1 */
#define BTM_LE_SEC_AUTHENTICATED SMP_SEC_AUTHENTICATED /* 4 */
#endif ///SMP_INCLUDED == TRUE
typedef UINT8 tBTM_LE_SEC;
@ -2020,6 +2032,7 @@ tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode,
**
*******************************************************************************/
//extern
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 BTM_AllocateSCN(void);
// btla-specific ++
@ -2048,6 +2061,7 @@ BOOLEAN BTM_TryAllocateSCN(UINT8 scn);
*******************************************************************************/
//extern
BOOLEAN BTM_FreeSCN(UINT8 scn);
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
@ -3677,6 +3691,17 @@ UINT8 *BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len);
//extern
char *BTM_SecReadDevName (BD_ADDR bd_addr);
/*******************************************************************************
**
** Function BTM_SecClearSecurityFlags
**
** Description Reset the security flags (mark as not-paired) for a given
** remove device.
**
*******************************************************************************/
extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr);
/*****************************************************************************
** POWER MANAGEMENT FUNCTIONS

View File

@ -759,7 +759,9 @@ typedef struct {
** ACL Management
****************************************************/
tACL_CONN acl_db[MAX_L2CAP_LINKS];
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 btm_scn[BTM_MAX_SCN]; /* current SCNs: TRUE if SCN is in use */
#endif ///CLASSIC_BT_INCLUDED == TRUE
UINT16 btm_def_link_policy;
UINT16 btm_def_link_super_tout;
@ -815,9 +817,11 @@ typedef struct {
tBTM_APPL_INFO api;
#define BTM_SEC_MAX_RMT_NAME_CALLBACKS 2
tBTM_RMT_NAME_CALLBACK *p_rmt_name_callback[BTM_SEC_MAX_RMT_NAME_CALLBACKS];
tBTM_RMT_NAME_CALLBACK *p_rmt_name_callback[BTM_SEC_MAX_RMT_NAME_CALLBACKS];
#if (SMP_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_collided_dev_rec;
#endif ///SMP_INCLUDED == TRUE
TIMER_LIST_ENT sec_collision_tle;
UINT32 collision_start_time;
UINT32 max_collision_delay;
@ -828,6 +832,7 @@ typedef struct {
BOOLEAN security_mode_changed; /* mode changed during bonding */
BOOLEAN pin_type_changed; /* pin type changed during bonding */
BOOLEAN sec_req_pending; /* TRUE if a request is pending */
#if (SMP_INCLUDED == TRUE)
// btla-specific ++
#ifdef PORCHE_PAIRING_CONFLICT
UINT8 pin_code_len_saved; /* for legacy devices */
@ -843,6 +848,7 @@ typedef struct {
UINT16 disc_handle; /* for legacy devices */
UINT8 disc_reason; /* for legacy devices */
tBTM_SEC_SERV_REC sec_serv_rec[BTM_SEC_MAX_SERVICE_RECORDS];
#endif ///SMP_INCLUDED == TRUE
tBTM_SEC_DEV_REC sec_dev_rec[BTM_SEC_MAX_DEVICE_RECORDS];
tBTM_SEC_SERV_REC *p_out_serv;
tBTM_MKEY_CALLBACK *mkey_cback;
@ -859,7 +865,6 @@ typedef struct {
BOOLEAN paging;
BOOLEAN discing;
BUFFER_Q sec_pending_q; /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */
#if (!defined(BT_TRACE_VERBOSE) || (BT_TRACE_VERBOSE == FALSE))
char state_temp_buffer[BTM_STATE_BUFFER_SIZE];
#endif

0
tools/sdk/include/bluedroid/buffer.h Executable file → Normal file
View File

0
tools/sdk/include/bluedroid/buffer_allocator.h Executable file → Normal file
View File

View File

@ -0,0 +1,144 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __CONFIG_H__
#define __CONFIG_H__
// This module implements a configuration parser. Clients can query the
// contents of a configuration file through the interface provided here.
// The current implementation is read-only; mutations are only kept in
// memory. This parser supports the INI file format.
// Implementation notes:
// - Key/value pairs that are not within a section are assumed to be under
// the |CONFIG_DEFAULT_SECTION| section.
// - Multiple sections with the same name will be merged as if they were in
// a single section.
// - Empty sections with no key/value pairs will be treated as if they do
// not exist. In other words, |config_has_section| will return false for
// empty sections.
// - Duplicate keys in a section will overwrite previous values.
// - All strings are case sensitive.
#include <stdbool.h>
// The default section name to use if a key/value pair is not defined within
// a section.
#define CONFIG_DEFAULT_SECTION "Global"
typedef struct config_t config_t;
typedef struct config_section_node_t config_section_node_t;
// Creates a new config object with no entries (i.e. not backed by a file).
// This function returns a config object or NULL on error. Clients must call
// |config_free| on the returned handle when it is no longer required.
config_t *config_new_empty(void);
// Loads the specified file and returns a handle to the config file. If there
// was a problem loading the file or allocating memory, this function returns
// NULL. Clients must call |config_free| on the returned handle when it is no
// longer required. |filename| must not be NULL and must point to a readable
// file on the filesystem.
config_t *config_new(const char *filename);
// Frees resources associated with the config file. No further operations may
// be performed on the |config| object after calling this function. |config|
// may be NULL.
void config_free(config_t *config);
// Returns true if the config file contains a section named |section|. If
// the section has no key/value pairs in it, this function will return false.
// |config| and |section| must not be NULL.
bool config_has_section(const config_t *config, const char *section);
// Returns true if the config file has a key named |key| under |section|.
// Returns false otherwise. |config|, |section|, and |key| must not be NULL.
bool config_has_key(const config_t *config, const char *section, const char *key);
// Returns the integral value for a given |key| in |section|. If |section|
// or |key| do not exist, or the value cannot be fully converted to an integer,
// this function returns |def_value|. |config|, |section|, and |key| must not
// be NULL.
int config_get_int(const config_t *config, const char *section, const char *key, int def_value);
// Returns the boolean value for a given |key| in |section|. If |section|
// or |key| do not exist, or the value cannot be converted to a boolean, this
// function returns |def_value|. |config|, |section|, and |key| must not be NULL.
bool config_get_bool(const config_t *config, const char *section, const char *key, bool def_value);
// Returns the string value for a given |key| in |section|. If |section| or
// |key| do not exist, this function returns |def_value|. The returned string
// is owned by the config module and must not be freed. |config|, |section|,
// and |key| must not be NULL. |def_value| may be NULL.
const char *config_get_string(const config_t *config, const char *section, const char *key, const char *def_value);
// Sets an integral value for the |key| in |section|. If |key| or |section| do
// not already exist, this function creates them. |config|, |section|, and |key|
// must not be NULL.
void config_set_int(config_t *config, const char *section, const char *key, int value);
// Sets a boolean value for the |key| in |section|. If |key| or |section| do
// not already exist, this function creates them. |config|, |section|, and |key|
// must not be NULL.
void config_set_bool(config_t *config, const char *section, const char *key, bool value);
// Sets a string value for the |key| in |section|. If |key| or |section| do
// not already exist, this function creates them. |config|, |section|, |key|, and
// |value| must not be NULL.
void config_set_string(config_t *config, const char *section, const char *key, const char *value, bool insert_back);
// Removes |section| from the |config| (and, as a result, all keys in the section).
// Returns true if |section| was found and removed from |config|, false otherwise.
// Neither |config| nor |section| may be NULL.
bool config_remove_section(config_t *config, const char *section);
// Removes one specific |key| residing in |section| of the |config|. Returns true
// if the section and key were found and the key was removed, false otherwise.
// None of |config|, |section|, or |key| may be NULL.
bool config_remove_key(config_t *config, const char *section, const char *key);
// Returns an iterator to the first section in the config file. If there are no
// sections, the iterator will equal the return value of |config_section_end|.
// The returned pointer must be treated as an opaque handle and must not be freed.
// The iterator is invalidated on any config mutating operation. |config| may not
// be NULL.
const config_section_node_t *config_section_begin(const config_t *config);
// Returns an iterator to one past the last section in the config file. It does not
// represent a valid section, but can be used to determine if all sections have been
// iterated over. The returned pointer must be treated as an opaque handle and must
// not be freed and must not be iterated on (must not call |config_section_next| on
// it). |config| may not be NULL.
const config_section_node_t *config_section_end(const config_t *config);
// Moves |iter| to the next section. If there are no more sections, |iter| will
// equal the value of |config_section_end|. |iter| may not be NULL and must be
// a pointer returned by either |config_section_begin| or |config_section_next|.
const config_section_node_t *config_section_next(const config_section_node_t *iter);
// Returns the name of the section referred to by |iter|. The returned pointer is
// owned by the config module and must not be freed by the caller. The pointer will
// remain valid until |config_free| is called. |iter| may not be NULL and must not
// equal the value returned by |config_section_end|.
const char *config_section_name(const config_section_node_t *iter);
// Saves |config| to a file given by |filename|. Note that this could be a destructive
// operation: if |filename| already exists, it will be overwritten. The config
// module does not preserve comments or formatting so if a config file was opened
// with |config_new| and subsequently overwritten with |config_save|, all comments
// and special formatting in the original file will be lost. Neither |config| nor
// |filename| may be NULL.
bool config_save(const config_t *config, const char *filename);
#endif /* #ifndef __CONFIG_H__ */

59
tools/sdk/include/bluedroid/dyn_mem.h Executable file → Normal file
View File

@ -18,6 +18,62 @@
#ifndef DYN_MEM_H
#define DYN_MEM_H
#include "sdkconfig.h"
#if CONFIG_CLASSIC_BT_ENABLED
#define SDP_DYNAMIC_MEMORY FALSE
#define RFC_DYNAMIC_MEMORY FALSE
#define TCS_DYNAMIC_MEMORY FALSE
#define BNEP_DYNAMIC_MEMORY FALSE
#define AVDT_DYNAMIC_MEMORY FALSE
#define AVCT_DYNAMIC_MEMORY FALSE
#define MCA_DYNAMIC_MEMORY FALSE
#define A2D_DYNAMIC_MEMORY FALSE
#define VDP_DYNAMIC_MEMORY FALSE
#define AVRC_DYNAMIC_MEMORY FALSE
#define BIP_DYNAMIC_MEMORY FALSE
#define BPP_DYNAMIC_MEMORY FALSE
#define CTP_DYNAMIC_MEMORY FALSE
#define FTP_DYNAMIC_MEMORY FALSE
#define HCRP_DYNAMIC_MEMORY FALSE
#define HFP_DYNAMIC_MEMORY FALSE
#define HID_DYNAMIC_MEMORY FALSE
#define HSP2_DYNAMIC_MEMORY FALSE
#define ICP_DYNAMIC_MEMORY FALSE
#define OPP_DYNAMIC_MEMORY FALSE
#define PAN_DYNAMIC_MEMORY FALSE
#define SPP_DYNAMIC_MEMORY FALSE
#define SLIP_DYNAMIC_MEMORY FALSE
#define LLCP_DYNAMIC_MEMORY FALSE
#else /* #if CONFIG_CLASSIC_BT_ENABLED */
#define SDP_DYNAMIC_MEMORY TRUE
#define RFC_DYNAMIC_MEMORY TRUE
#define TCS_DYNAMIC_MEMORY TRUE
#define BNEP_DYNAMIC_MEMORY TRUE
#define AVDT_DYNAMIC_MEMORY TRUE
#define AVCT_DYNAMIC_MEMORY TRUE
#define MCA_DYNAMIC_MEMORY TRUE
#define A2D_DYNAMIC_MEMORY TRUE
#define VDP_DYNAMIC_MEMORY TRUE
#define AVRC_DYNAMIC_MEMORY TRUE
#define BIP_DYNAMIC_MEMORY TRUE
#define BPP_DYNAMIC_MEMORY TRUE
#define CTP_DYNAMIC_MEMORY TRUE
#define FTP_DYNAMIC_MEMORY TRUE
#define HCRP_DYNAMIC_MEMORY TRUE
#define HFP_DYNAMIC_MEMORY TRUE
#define HID_DYNAMIC_MEMORY TRUE
#define HSP2_DYNAMIC_MEMORY TRUE
#define ICP_DYNAMIC_MEMORY TRUE
#define OPP_DYNAMIC_MEMORY TRUE
#define PAN_DYNAMIC_MEMORY TRUE
#define SPP_DYNAMIC_MEMORY TRUE
#define SLIP_DYNAMIC_MEMORY TRUE
#define LLCP_DYNAMIC_MEMORY TRUE
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
/****************************************************************************
** 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.
@ -31,8 +87,7 @@
#endif
#ifndef SDP_DYNAMIC_MEMORY
//#define SDP_DYNAMIC_MEMORY FALSE
#define SDP_DYNAMIC_MEMORY TRUE
#define SDP_DYNAMIC_MEMORY FALSE
#endif
#ifndef L2C_DYNAMIC_MEMORY

View File

@ -0,0 +1,216 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __ESP_A2DP_API_H__
#define __ESP_A2DP_API_H__
#include "esp_err.h"
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Media codec types supported by A2DP
#define ESP_A2D_MCT_SBC (0) /*!< SBC */
#define ESP_A2D_MCT_M12 (0x01) /*!< MPEG-1, 2 Audio */
#define ESP_A2D_MCT_M24 (0x02) /*!< MPEG-2, 4 AAC */
#define ESP_A2D_MCT_ATRAC (0x04) /*!< ATRAC family */
#define ESP_A2D_MCT_NON_A2DP (0xff)
typedef uint8_t esp_a2d_mct_t;
/// A2DP media codec capabilities union
typedef struct {
esp_a2d_mct_t type; /*!< A2DP media codec type */
#define ESP_A2D_CIE_LEN_SBC (4)
#define ESP_A2D_CIE_LEN_M12 (4)
#define ESP_A2D_CIE_LEN_M24 (6)
#define ESP_A2D_CIE_LEN_ATRAC (7)
union {
uint8_t sbc[ESP_A2D_CIE_LEN_SBC];
uint8_t m12[ESP_A2D_CIE_LEN_M12];
uint8_t m24[ESP_A2D_CIE_LEN_M24];
uint8_t atrac[ESP_A2D_CIE_LEN_ATRAC];
} cie; /*!< A2DP codec information element */
} __attribute__((packed)) esp_a2d_mcc_t;
/// Bluetooth A2DP connection states
typedef enum {
ESP_A2D_CONNECTION_STATE_DISCONNECTED = 0, /*!< connection released */
ESP_A2D_CONNECTION_STATE_CONNECTING, /*!< connecting remote device */
ESP_A2D_CONNECTION_STATE_CONNECTED, /*!< connection established */
ESP_A2D_CONNECTION_STATE_DISCONNECTING /*!< disconnecting remote device */
} esp_a2d_connection_state_t;
/// Bluetooth A2DP disconnection reason
typedef enum {
ESP_A2D_DISC_RSN_NORMAL = 0, /*!< Finished disconnection that is initiated by local or remote device */
ESP_A2D_DISC_RSN_ABNORMAL /*!< Abnormal disconnection caused by signal loss */
} esp_a2d_disc_rsn_t;
/// Bluetooth A2DP datapath states
typedef enum {
ESP_A2D_AUDIO_STATE_REMOTE_SUSPEND = 0, /*!< audio stream datapath suspended by remote device */
ESP_A2D_AUDIO_STATE_STOPPED, /*!< audio stream datapath stopped */
ESP_A2D_AUDIO_STATE_STARTED, /*!< audio stream datapath started */
} esp_a2d_audio_state_t;
/// A2DP callback events
typedef enum {
ESP_A2D_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
ESP_A2D_AUDIO_STATE_EVT = 1, /*!< audio stream transmission state changed event */
ESP_A2D_AUDIO_CFG_EVT = 2 /*!< audio codec is configured */
} esp_a2d_cb_event_t;
/// A2DP state callback parameters
typedef union {
/**
* @brief ESP_A2D_CONNECTION_STATE_EVT
*/
struct a2d_conn_stat_param {
esp_a2d_connection_state_t state; /*!< one of values from esp_a2d_connection_state_t */
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
esp_a2d_disc_rsn_t disc_rsn; /*!< reason of disconnection for "DISCONNECTED" */
} conn_stat; /*!< A2DP connection status */
/**
* @brief ESP_A2D_AUDIO_STATE_EVT
*/
struct a2d_audio_stat_param {
esp_a2d_audio_state_t state; /*!< one of the values from esp_a2d_audio_state_t */
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
} audio_stat; /*!< audio stream playing state */
/**
* @brief ESP_A2D_AUDIO_CFG_EVT
*/
struct a2d_audio_cfg_param {
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
esp_a2d_mcc_t mcc; /*!< A2DP media codec capability information */
} audio_cfg; /*!< media codec configuration infomation */
} esp_a2d_cb_param_t;
/**
* @brief A2DP profile callback function type
* @param event : Event type
* @param param : Pointer to callback parameter
*/
typedef void (* esp_a2d_cb_t)(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param);
/**
* @brief A2DP profile data callback function
*
* @param[in] buf : data received from A2DP source device and is PCM format decoder from SBC decoder;
* buf references to a static memory block and can be overwritten by upcoming data
*
* @param[in] len : size(in bytes) in buf
*
*/
typedef void (* esp_a2d_data_cb_t)(const uint8_t *buf, uint32_t len);
/**
* @brief Register application callback function to A2DP module. This function should be called
* only after esp_bluedroid_enable() completes successfully
*
* @param[in] callback: A2DP sink event callback function
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: if callback is a NULL function pointer
*
*/
esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback);
/**
* @brief Register A2DP sink data output function; For now the output is PCM data stream decoded
* from SBC format. This function should be called only after esp_bluedroid_enable()
* completes successfully
*
* @param[in] callback: A2DP data callback function
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: if callback is a NULL function pointer
*
*/
esp_err_t esp_a2d_register_data_callback(esp_a2d_data_cb_t callback);
/**
*
* @brief Initialize the bluetooth A2DP sink module. This function should be called
* after esp_bluedroid_enable() completes successfully
*
* @return
* - ESP_OK: if the initialization request is sent successfully
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_a2d_sink_init(void);
/**
*
* @brief De-initialize for A2DP sink module. This function
* should be called only after esp_bluedroid_enable() completes successfully
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_a2d_sink_deinit(void);
/**
*
* @brief Connect the remote bluetooth device bluetooth, must after esp_a2d_sink_init()
*
* @param[in] remote_bda: remote bluetooth device address
*
* @return
* - ESP_OK: connect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_a2d_sink_connect(esp_bd_addr_t remote_bda);
/**
*
* @brief Disconnect the remote bluetooth device
*
* @param[in] remote_bda: remote bluetooth device address
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t remote_bda);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_A2DP_API_H__ */

View File

@ -0,0 +1,153 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __ESP_AVRC_API_H__
#define __ESP_AVRC_API_H__
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/// AVRC feature bit mask
typedef enum {
ESP_AVRC_FEAT_RCTG = 0x0001, /*!< remote control target */
ESP_AVRC_FEAT_RCCT = 0x0002, /*!< remote control controller */
ESP_AVRC_FEAT_VENDOR = 0x0008, /*!< remote control vendor dependent commands */
ESP_AVRC_FEAT_BROWSE = 0x0010, /*!< use browsing channel */
ESP_AVRC_FEAT_META_DATA = 0x0040, /*!< remote control metadata transfer command/response */
ESP_AVRC_FEAT_ADV_CTRL = 0x0200, /*!< remote control advanced control commmand/response */
} esp_avrc_features_t;
/// AVRC passthrough command code
typedef enum {
ESP_AVRC_PT_CMD_PLAY = 0x44, /*!< play */
ESP_AVRC_PT_CMD_STOP = 0x45, /*!< stop */
ESP_AVRC_PT_CMD_PAUSE = 0x46, /*!< pause */
ESP_AVRC_PT_CMD_FORWARD = 0x4B, /*!< forward */
ESP_AVRC_PT_CMD_BACKWARD = 0x4C /*!< backward */
} esp_avrc_pt_cmd_t;
/// AVRC passthrough command state
typedef enum {
ESP_AVRC_PT_CMD_STATE_PRESSED = 0, /*!< key pressed */
ESP_AVRC_PT_CMD_STATE_RELEASED = 1 /*!< key released */
} esp_avrc_pt_cmd_state_t;
/// AVRC Controller callback events
typedef enum {
ESP_AVRC_CT_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
ESP_AVRC_CT_PASSTHROUGH_RSP_EVT = 1, /*!< passthrough response event */
ESP_AVRC_CT_MAX_EVT
} esp_avrc_ct_cb_event_t;
/// AVRC controller callback parameters
typedef union {
/**
* @brief ESP_AVRC_CT_CONNECTION_STATE_EVT
*/
struct avrc_ct_conn_stat_param {
bool connected; /*!< whether AVRC connection is set up */
uint32_t feat_mask; /*!< AVRC feature mask of remote device */
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
} conn_stat; /*!< AVRC connection status */
/**
* @brief ESP_AVRC_CT_PASSTHROUGH_RSP_EVT
*/
struct avrc_ct_psth_rsp_param {
uint8_t tl; /*!< transaction label, 0 to 15 */
uint8_t key_code; /*!< passthrough command code */
uint8_t key_state; /*!< 0 for PRESSED, 1 for RELEASED */
} psth_rsp; /*!< passthrough command response */
} esp_avrc_ct_cb_param_t;
/**
* @brief AVRCP controller callback function type
* @param event : Event type
* @param param : Pointer to callback parameter union
*/
typedef void (* esp_avrc_ct_cb_t)(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param);
/**
* @brief Register application callbacks to AVRCP module; for now only AVRCP Controller
* role is supported. This function should be called after esp_bluedroid_enable()
* completes successfully
*
* @param[in] callback: AVRCP controller callback function
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_avrc_ct_register_callback(esp_avrc_ct_cb_t callback);
/**
*
* @brief Initialize the bluetooth AVRCP controller module, This function should be called
* after esp_bluedroid_enable() completes successfully
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_avrc_ct_init(void);
/**
*
* @brief De-initialize AVRCP controller module. This function should be called after
* after esp_bluedroid_enable() completes successfully
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_avrc_ct_deinit(void);
/**
* @brief Send passthrough command to AVRCP target, This function should be called after
* ESP_AVRC_CT_CONNECTION_STATE_EVT is received and AVRCP connection is established
*
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
* @param[in] key_code : passthrough command code, e.g. ESP_AVRC_PT_CMD_PLAY, ESP_AVRC_PT_CMD_STOP, etc.
* @param[in] key_state : passthrough command key state, ESP_AVRC_PT_CMD_STATE_PRESSED or
* ESP_AVRC_PT_CMD_STATE_PRESSED
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code, uint8_t key_state);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_AVRC_API_H__ */

View File

@ -49,6 +49,7 @@ typedef enum {
ESP_BLUFI_EVENT_RECV_SERVER_CERT, /*<! When Phone send Server certificate to ESP32, this event happen */
ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY, /*<! When Phone send Client Private key to ESP32, this event happen */
ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY, /*<! When Phone send Server Private key to ESP32, this event happen */
ESP_BLUFI_EVENT_RECV_SLAVE_DISCONNECT_BLE, /*<! When Phone send Disconnect key to ESP32, this event happen */
} esp_blufi_cb_event_t;
/// BLUFI config status
@ -122,6 +123,8 @@ typedef union {
*/
struct blufi_connect_evt_param {
esp_bd_addr_t remote_bda; /*!< Blufi Remote bluetooth device address */
uint8_t server_if; /*!< server interface */
uint16_t conn_id; /*!< Connection id */
} connect; /*!< Blufi callback param of ESP_BLUFI_EVENT_CONNECT */
/**
@ -353,6 +356,18 @@ esp_err_t esp_blufi_send_wifi_conn_report(wifi_mode_t opmode, esp_blufi_sta_conn
*/
uint16_t esp_blufi_get_version(void);
/**
* @brief Close a connection a remote device.
*
* @param[in] gatts_if: GATT server access interface
* @param[in] conn_id: connection ID to be closed.
*
* @return
* - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_blufi_close(esp_gatt_if_t gatts_if, uint16_t conn_id);
#ifdef __cplusplus
}
#endif

View File

@ -32,6 +32,16 @@ typedef enum {
ESP_BT_STATUS_WRONG_MODE = 5,
} esp_bt_status_t;
/*Define the bt octet 16 bit size*/
#define ESP_BT_OCTET16_LEN 16
typedef uint8_t esp_bt_octet16_t[ESP_BT_OCTET16_LEN]; /* octet array: size 16 */
#define ESP_BT_OCTET8_LEN 8
typedef uint8_t esp_bt_octet8_t[ESP_BT_OCTET8_LEN]; /* octet array: size 8 */
typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */
/// Default GATT interface id
#define ESP_DEFAULT_GATT_IF 0xff
@ -67,22 +77,6 @@ typedef enum {
/// Bluetooth device address
typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN];
/// Own BD address source of the device
typedef enum {
/// Public Address
BD_ADDR_PUBLIC,
/// Provided random address
BD_ADDR_PROVIDED_RND,
/// Provided static random address
BD_ADDR_GEN_STATIC_RND,
/// Generated resolvable private random address
BD_ADDR_GEN_RSLV,
/// Generated non-resolvable private random address
BD_ADDR_GEN_NON_RSLV,
/// Provided Reconnection address
BD_ADDR_PROVIDED_RECON,
} esp_bd_addr_type_t;
/// BLE device address type
typedef enum {
BLE_ADDR_TYPE_PUBLIC = 0x00,
@ -91,6 +85,15 @@ typedef enum {
BLE_ADDR_TYPE_RPA_RANDOM = 0x03,
} esp_ble_addr_type_t;
/// Used to exchange the encrytyption key in the init key & response key
#define ESP_BLE_ENC_KEY_MASK (1 << 0)
/// Used to exchange the IRK key in the init key & response key
#define ESP_BLE_ID_KEY_MASK (1 << 1)
/// Used to exchange the CSRK key in the init key & response key
#define ESP_BLE_CSR_KEY_MASK (1 << 2)
/// Used to exchange the link key(this key just used in the BLE & BR/EDR coexist mode) in the init key & response key
#define ESP_BLE_LINK_KEY_MASK (1 << 3)
/// Minimum of the application id
#define ESP_APP_ID_MIN 0x0000
/// Maximum of the application id

View File

@ -17,6 +17,8 @@
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
@ -30,6 +32,21 @@ extern "C" {
*/
const uint8_t *esp_bt_dev_get_address(void);
/**
* @brief Set bluetooth device name. This function should be called after esp_bluedroid_enable()
* completes successfully
*
* @param[in] name : device name to be set
*
* @return
* - ESP_OK : Succeed
* - ESP_ERR_INVALID_ARG : if name is NULL pointer or empty, or string length out of limit
* - ESP_INVALID_STATE : if bluetooth stack is not yet enabled
* - ESP_FAIL : others
*/
esp_err_t esp_bt_dev_set_device_name(const char *name);
#ifdef __cplusplus
}
#endif

View File

@ -38,6 +38,34 @@ extern "C" {
* @}
*/
#define ESP_LE_KEY_NONE 0
#define ESP_LE_KEY_PENC (1 << 0) /*!< encryption key, encryption information of peer device */
#define ESP_LE_KEY_PID (1 << 1) /*!< identity key of the peer device */
#define ESP_LE_KEY_PCSRK (1 << 2) /*!< peer SRK */
#define ESP_LE_KEY_PLK (1 << 3) /*!< Link key*/
#define ESP_LE_KEY_LLK (ESP_LE_KEY_PLK << 4)
#define ESP_LE_KEY_LENC (ESP_LE_KEY_PENC << 4) /*!< master role security information:div */
#define ESP_LE_KEY_LID (ESP_LE_KEY_PID << 4) /*!< master device ID key */
#define ESP_LE_KEY_LCSRK (ESP_LE_KEY_PCSRK << 4) /*!< local CSRK has been deliver to peer */
typedef uint8_t esp_ble_key_type_t;
#define ESP_LE_AUTH_NO_BOND 0x00 /*!< 0*/
#define ESP_LE_AUTH_BOND 0x01 /*!< 1 << 0 */
#define ESP_LE_AUTH_REQ_MITM (1 << 2) /*!< 1 << 2 */
#define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3) /*!< 1 << 3 */
#define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1001 */
#define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1100 */
#define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND) /*!< 1101 */
typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit pattern */
#define ESP_IO_CAP_OUT 0 /*!< DisplayOnly */
#define ESP_IO_CAP_IO 1 /*!< DisplayYesNo */
#define ESP_IO_CAP_IN 2 /*!< KeyboardOnly */
#define ESP_IO_CAP_NONE 3 /*!< NoInputNoOutput */
#define ESP_IO_CAP_KBDISP 4 /*!< Keyboard display */
typedef uint8_t esp_ble_io_cap_t; /*!< combination of the io capability */
/// GAP BLE callback event type
typedef enum {
ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT = 0, /*!< When advertising data set complete, the event comes */
@ -48,6 +76,17 @@ typedef enum {
ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
ESP_GAP_BLE_ADV_START_COMPLETE_EVT, /*!< When start advertising complete, the event comes */
ESP_GAP_BLE_SCAN_START_COMPLETE_EVT, /*!< When start scan complete, the event comes */
ESP_GAP_BLE_AUTH_CMPL_EVT, /* Authentication complete indication. */
ESP_GAP_BLE_KEY_EVT, /* BLE key event for peer device keys */
ESP_GAP_BLE_SEC_REQ_EVT, /* BLE security request */
ESP_GAP_BLE_PASSKEY_NOTIF_EVT, /* passkey notification event */
ESP_GAP_BLE_PASSKEY_REQ_EVT, /* passkey request event */
ESP_GAP_BLE_OOB_REQ_EVT, /* OOB request event */
ESP_GAP_BLE_LOCAL_IR_EVT, /* BLE local IR event */
ESP_GAP_BLE_LOCAL_ER_EVT, /* BLE local ER event */
ESP_GAP_BLE_NC_REQ_EVT, /* Numeric Comparison request event */
ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */
ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, /*!< When stop scan complete, the event comes */
} esp_gap_ble_cb_event_t;
/// Advertising data maximum length
@ -113,6 +152,23 @@ typedef enum {
///Enumeration end value for advertising filter policy value check
} esp_ble_adv_filter_t;
typedef enum {
ESP_BLE_SEC_NONE,
ESP_BLE_SEC_ENCRYPT,
ESP_BLE_SEC_ENCRYPT_NO_MITM,
ESP_BLE_SEC_ENCRYPT_MITM,
}esp_ble_sec_act_t;
typedef enum {
ESP_BLE_SM_PASSKEY,
ESP_BLE_SM_AUTHEN_REQ_MODE,
ESP_BLE_SM_IOCAP_MODE,
ESP_BLE_SM_SET_INIT_KEY,
ESP_BLE_SM_SET_RSP_KEK,
ESP_BLE_SM_MAX_KEY_SIZE,
} esp_ble_sm_param_t;
/// Advertising parameters
typedef struct {
uint16_t adv_int_min; /*!< Minimum advertising interval for
@ -148,22 +204,6 @@ typedef struct {
uint8_t flag; /*!< Advertising flag of discovery mode, see BLE_ADV_DATA_FLAG detail */
} esp_ble_adv_data_t;
/// Own BD address source of the device
typedef enum {
/// Public Address
ESP_PUBLIC_ADDR,
/// Provided random address
ESP_PROVIDED_RND_ADDR,
/// Provided static random address
ESP_GEN_STATIC_RND_ADDR,
/// Generated resolvable private random address
ESP_GEN_RSLV_ADDR,
/// Generated non-resolvable private random address
ESP_GEN_NON_RSLV_ADDR,
/// Provided Reconnection address
ESP_PROVIDED_RECON_ADDR,
} esp_ble_own_addr_src_t;
/// Ble scan type
typedef enum {
BLE_SCAN_TYPE_PASSIVE = 0x0, /*!< Passive scan */
@ -215,6 +255,137 @@ typedef struct {
Time Range: 100 msec to 32 seconds */
} esp_ble_conn_update_params_t;
/**
* @brief BLE encryption keys
*/
typedef struct
{
esp_bt_octet16_t ltk; /*!< The long term key*/
esp_bt_octet8_t rand; /*!< The random number*/
uint16_t ediv; /*!< The ediv value*/
uint8_t sec_level; /*!< The security level of the security link*/
uint8_t key_size; /*!< The key size(7~16) of the security link*/
}esp_ble_penc_keys_t; /*!< The key type*/
/**
* @brief BLE CSRK keys
*/
typedef struct
{
uint32_t counter; /*!< The counter */
esp_bt_octet16_t csrk; /*!< The csrk key */
uint8_t sec_level; /*!< The security level */
}esp_ble_pcsrk_keys_t; /*!< The pcsrk key type */
/**
* @brief BLE pid keys
*/
typedef struct
{
esp_bt_octet16_t irk; /*!< The irk value */
esp_ble_addr_type_t addr_type; /*!< The address type */
esp_bd_addr_t static_addr; /*!< The static address */
}esp_ble_pid_keys_t; /*!< The pid key type */
/**
* @brief BLE Encryption reproduction keys
*/
typedef struct
{
esp_bt_octet16_t ltk; /*!< The long term key */
uint16_t div; /*!< The div value */
uint8_t key_size; /*!< The key size of the security link */
uint8_t sec_level; /*!< The security level of the security link */
}esp_ble_lenc_keys_t; /*!< The key type */
/**
* @brief BLE SRK keys
*/
typedef struct
{
uint32_t counter; /*!< The counter value */
uint16_t div; /*!< The div value */
uint8_t sec_level; /*!< The security level of the security link */
esp_bt_octet16_t csrk; /*!< The csrk key value */
}esp_ble_lcsrk_keys; /*!< The csrk key type */
/**
* @brief Structure associated with ESP_KEY_NOTIF_EVT
*/
typedef struct
{
esp_bd_addr_t bd_addr; /*!< peer address */
uint32_t passkey; /*!< the numeric value for comparison. If just_works, do not show this number to UI */
} esp_ble_sec_key_notif_t; /*!< BLE key notify type*/
/**
* @brief Structure of the security request
*/
typedef struct
{
esp_bd_addr_t bd_addr; /*!< peer address */
}esp_ble_sec_req_t; /*!< BLE security request type*/
/**
* @brief union type of the security key value
*/
typedef union
{
esp_ble_penc_keys_t penc_key; /*!< received peer encryption key */
esp_ble_pcsrk_keys_t pcsrk_key; /*!< received peer device SRK */
esp_ble_pid_keys_t pid_key; /*!< peer device ID key */
esp_ble_lenc_keys_t lenc_key; /*!< local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
esp_ble_lcsrk_keys lcsrk_key; /*!< local device CSRK = d1(ER,DIV,1)*/
}esp_ble_key_value_t; /*!< ble key value type*/
/**
* @brief union type of the security key value
*/
typedef struct
{
esp_bd_addr_t bd_addr; /*!< peer address */
esp_ble_key_type_t key_type; /*!< key type of the security link */
esp_ble_key_value_t p_key_value; /*!< the pointer to the key value */
}esp_ble_key_t; /*!< the union to the ble key value type*/
/**
* @brief structure type of the ble local id keys value
*/
typedef struct {
esp_bt_octet16_t ir; /*!< the 16 bits of the ir value */
esp_bt_octet16_t irk; /*!< the 16 bits of the ir key value */
esp_bt_octet16_t dhk; /*!< the 16 bits of the dh key value */
}esp_ble_local_id_keys_t; /*!< the structure of the ble local id keys value type*/
/**
* @brief Structure associated with ESP_AUTH_CMPL_EVT
*/
typedef struct
{
esp_bd_addr_t bd_addr; /*!< BD address peer device. */
bool key_present; /*!< Valid link key value in key element */
esp_link_key key; /*!< Link key associated with peer device. */
uint8_t key_type; /*!< The type of Link Key */
bool success; /*!< TRUE of authentication succeeded, FALSE if failed. */
uint8_t fail_reason; /*!< The HCI reason/error code for when success=FALSE */
esp_ble_addr_type_t addr_type; /*!< Peer device address type */
esp_bt_dev_type_t dev_type; /*!< Device type */
}esp_ble_auth_cmpl_t; /*!< The ble authentication complite cb type */
/**
* @brief union associated with ble security
*/
typedef union
{
esp_ble_sec_key_notif_t key_notif; /*!< passkey notification */
esp_ble_sec_req_t ble_req; /*!< BLE SMP related request */
esp_ble_key_t ble_key; /*!< BLE SMP keys used when pairing */
esp_ble_local_id_keys_t ble_id_keys; /*!< BLE IR event */
esp_ble_auth_cmpl_t auth_cmpl; /*!< Authentication complete indication. */
}esp_ble_sec_t; /*!< Ble secutity type */
/// Sub Event of ESP_GAP_BLE_SCAN_RESULT_EVT
typedef enum {
ESP_GAP_SEARCH_INQ_RES_EVT = 0, /*!< Inquiry result for a peer device. */
@ -300,6 +471,20 @@ typedef union {
struct ble_scan_start_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate scan start operation success status */
} scan_start_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_START_COMPLETE_EVT */
esp_ble_sec_t ble_security; /*!< ble gap security union type */
/**
* @brief ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT
*/
struct ble_scan_stop_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate scan stop operation success status */
} scan_stop_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT
*/
struct ble_adv_stop_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate adv stop operation success status */
} adv_stop_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT */
} esp_ble_gap_cb_param_t;
/**
@ -505,6 +690,76 @@ esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_l
*/
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len);
/**
* @brief Set a GAP security parameter value. Overrides the default value.
*
* @param[in] param_type :L the type of the param which to be set
* @param[in] value : the param value
* @param[out] len : the length of the param value
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
void *value, uint8_t len);
/**
* @brief Grant security request access.
*
* @param[in] bd_addr : BD address of the peer
* @param[in] accept : accept the security request or not
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_security_rsp(esp_bd_addr_t bd_addr, bool accept);
/**
* @brief Set a gap parameter value. Use this function to change
* the default GAP parameter values.
*
* @param[in] bd_addr : the address of the peer device need to encryption
* @param[in] sec_act : This is the security action to indicate
* what kind of BLE security level is required for
* the BLE link if the BLE is supported
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_set_encryption(esp_bd_addr_t bd_addr, esp_ble_sec_act_t sec_act);
/**
* @brief Reply the key value to the peer device in the lagecy connection stage.
*
* @param[in] bd_addr : BD address of the peer
* @param[in] accept : passkey entry sucessful or declined.
* @param[in] passkey : passkey value, must be a 6 digit number,
* can be lead by 0.
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t passkey);
/**
* @brief Reply the comfirm value to the peer device in the lagecy connection stage.
*
* @param[in] bd_addr : BD address of the peer device
* @param[in] accept : numbers to compare are the same or different.
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,52 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __ESP_GAP_BT_API_H__
#define __ESP_GAP_BT_API_H__
#include <stdint.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Discoverability and Connectability mode
typedef enum {
ESP_BT_SCAN_MODE_NONE = 0, /*!< Neither discoverable nor connectable */
ESP_BT_SCAN_MODE_CONNECTABLE, /*!< Connectable but not discoverable */
ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE /*!< both discoverable and connectaable */
} esp_bt_scan_mode_t;
/**
* @brief Set discoverability and connectability mode for legacy bluetooth. This function should
* be called after esp_bluedroid_enable() completes successfully
*
* @param[in] mode : one of the enums of bt_scan_mode_t
*
* @return
* - ESP_OK : Succeed
* - ESP_ERR_INVALID_ARG: if argument invalid
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_GAP_BT_API_H__ */

View File

@ -297,13 +297,17 @@ typedef enum {
/**
* @brief attribute auto respose flag
* @brief attribute auto response flag
*/
typedef struct
{
#define ESP_GATT_RSP_BY_APP 0
#define ESP_GATT_AUTO_RSP 1
uint8_t auto_rsp; /*!< need the app response to the client if need_rsp set to 1*/
/**
* @brief if auto_rsp set to ESP_GATT_RSP_BY_APP, means the response of Write/Read operation will by replied by application.
if auto_rsp set to ESP_GATT_AUTO_RSP, means the response of Write/Read operation will be replied by GATT stack automatically.
*/
uint8_t auto_rsp;
} esp_attr_control_t;
@ -312,8 +316,8 @@ typedef struct
*/
typedef struct
{
esp_attr_control_t attr_control; /*!< The attribue control type*/
esp_attr_desc_t att_desc; /*!< The attribue type*/
esp_attr_control_t attr_control; /*!< The attribute control type*/
esp_attr_desc_t att_desc; /*!< The attribute type*/
} esp_gatts_attr_db_t;

View File

@ -510,15 +510,15 @@ esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if,
* - other: failed
*
*/
esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
uint16_t conn_id,
esp_gatt_srvc_id_t *srvc_id,
esp_gatt_id_t *char_id,
esp_gatt_id_t *descr_id,
uint16_t value_len,
uint8_t *value,
esp_gatt_write_type_t write_type,
esp_gatt_auth_req_t auth_req);
esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
uint16_t conn_id,
esp_gatt_srvc_id_t *srvc_id,
esp_gatt_id_t *char_id,
esp_gatt_id_t *descr_id,
uint16_t value_len,
uint8_t *value,
esp_gatt_write_type_t write_type,
esp_gatt_auth_req_t auth_req);
/**
@ -548,6 +548,35 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
esp_gatt_auth_req_t auth_req);
/**
* @brief This function is called to prepare write a characteristic descriptor value.
*
* @param[in] gattc_if: Gatt client access interface.
* @param[in] conn_id : connection ID.
* @param[in] srvc_id : service ID.
* @param[in] char_id : GATT characteristic ID of the service.
* @param[in] descr_id : characteristic descriptor ID to write.
* @param[in] offset : offset of the write value.
* @param[in] value_len: length of the value to be written.
* @param[in] value : the value to be written.
* @param[in] auth_req : authentication request.
*
* @return
* - ESP_OK: success
* - other: failed
*
*/
esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if,
uint16_t conn_id,
esp_gatt_srvc_id_t *srvc_id,
esp_gatt_id_t *char_id,
esp_gatt_id_t *descr_id,
uint16_t offset,
uint16_t value_len,
uint8_t *value,
esp_gatt_auth_req_t auth_req);
/**
* @brief This function is called to execute write a prepare write sequence.
*

View File

@ -0,0 +1,79 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 __ESP_SEC_API_H__
#define __ESP_SEC_API_H__
#include "bt_types.h"
#define APP_SEC_IRK_FLAG (0)
#define RAND_NB_LEN 0x08
#define SEC_KEY_LEN 0x10
/*
* STRUCTURES DEFINITIONS
****************************************************************************************
*/
/// Generic Security key structure
typedef struct {
/// Key value MSB -> LSB
UINT8 key[SEC_KEY_LEN];
} smp_sec_key;
///Random number structure
typedef struct {
///8-byte array for random number
UINT8 nb[RAND_NB_LEN];
} rand_nb;
typedef struct {
// LTK
smp_sec_key ltk;
// Random Number
rand_nb rand_nb;
// EDIV
UINT16 ediv;
// LTK key size
UINT8 key_size;
// Last paired peer address type
UINT8 peer_addr_type;
// Last paired peer address
BD_ADDR peer_addr;
// authentication level
UINT8 auth;
} tAPP_SEC_ENV;
extern tAPP_SEC_ENV app_sec_env;
/*
* GLOBAL FUNCTIONS DECLARATIONS
****************************************************************************************
*/
void app_ble_sec_init(void);
void app_ble_sec_pairing_cmp_evt_send(UINT8);
UINT32 app_ble_sec_gen_tk(void);
void app_ble_sec_gen_ltk(UINT8 key_size);
void app_ble_security_start(void);
#endif /* __ESP_SEC_API_H__ */

0
tools/sdk/include/bluedroid/fixed_queue.h Executable file → Normal file
View File

View File

@ -49,4 +49,6 @@ void future_ready(future_t *future, void *value);
// Frees the future before return. |future| may not be NULL.
void *future_await(future_t *async_result);
//Free the future if this "future" is not used
void future_free(future_t *future);
#endif /* __FUTURE_H__ */

View File

@ -127,15 +127,15 @@ typedef struct {
tGAP_INFO blk[GAP_MAX_BLOCKS];
tBTM_CMPL_CB *btm_cback[GAP_MAX_BLOCKS];
UINT8 trace_level;
tGAP_FINDADDR_CB findaddr_cb; /* Contains the control block for finding a device addr */
tBTM_INQ_INFO *cur_inqptr;
//tGAP_FINDADDR_CB findaddr_cb; /* Contains the control block for finding a device addr */
//tBTM_INQ_INFO *cur_inqptr;
#if GAP_CONN_INCLUDED == TRUE
tGAP_CONN conn;
#endif
/* LE GAP attribute database */
#if BLE_INCLUDED == TRUE
#if BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE
tGAP_ATTR gatt_attr[GAP_MAX_CHAR_NUM];
tGAP_CLCB clcb[GAP_MAX_CL]; /* connection link*/
tGATT_IF gatt_if;
@ -147,7 +147,7 @@ extern tGAP_CB gap_cb;
#if (GAP_CONN_INCLUDED == TRUE)
extern void gap_conn_init(void);
#endif
#if (BLE_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE)
extern void gap_attr_db_init(void);
#endif

View File

@ -326,6 +326,10 @@ typedef struct{
uint8_t auto_rsp;
}tGATTS_ATTR_CONTROL;
/* Mask for gatt server attribute */
#define GATT_ATTR_VALUE_ALLOCATED 0x01
typedef UINT8 tGATT_ATTR_MASK;
/* Union of the event data which is used in the server respond API to carry the server response information
*/
typedef union {

View File

@ -185,6 +185,7 @@ typedef struct {
tGATT_ATTR_UUID_TYPE uuid_type;
tGATT_PERM permission;
tGATTS_ATTR_CONTROL control;
tGATT_ATTR_MASK mask;
UINT16 handle;
UINT16 uuid;
} tGATT_ATTR16;
@ -197,6 +198,7 @@ typedef struct {
tGATT_ATTR_UUID_TYPE uuid_type;
tGATT_PERM permission;
tGATTS_ATTR_CONTROL control;
tGATT_ATTR_MASK mask;
UINT16 handle;
UINT32 uuid;
} tGATT_ATTR32;
@ -210,6 +212,7 @@ typedef struct {
tGATT_ATTR_UUID_TYPE uuid_type;
tGATT_PERM permission;
tGATTS_ATTR_CONTROL control;
tGATT_ATTR_MASK mask;
UINT16 handle;
UINT8 uuid[LEN_UUID_128];
} tGATT_ATTR128;
@ -382,7 +385,9 @@ typedef struct {
/* server needs */
/* server response data */
#if (GATTS_INCLUDED == TRUE)
tGATT_SR_CMD sr_cmd;
#endif ///GATTS_INCLUDED == TRUE
UINT16 indicate_handle;
BUFFER_Q pending_ind_q;
@ -499,11 +504,12 @@ typedef struct {
UINT16 next_handle; /* next available handle */
tGATT_SVC_CHG gattp_attr; /* GATT profile attribute service change */
tGATT_IF gatt_if;
#if (GATTS_INCLUDED == TRUE)
tGATT_HDL_LIST_INFO hdl_list_info;
tGATT_HDL_LIST_ELEM hdl_list[GATT_MAX_SR_PROFILES];
tGATT_SRV_LIST_INFO srv_list_info;
tGATT_SRV_LIST_ELEM srv_list[GATT_MAX_SR_PROFILES];
#endif ///GATTS_INCLUDED == TRUE
BUFFER_Q srv_chg_clt_q; /* service change clients queue */
BUFFER_Q pending_new_srv_start_q; /* pending new service start queue */
tGATT_REG cl_rcb[GATT_MAX_APPS];
@ -518,8 +524,9 @@ typedef struct {
UINT8 err_status;
UINT16 handle;
#endif
#if (GATTS_INCLUDED == TRUE)
tGATT_PROFILE_CLCB profile_clcb[GATT_MAX_APPS];
#endif ///GATTS_INCLUDED == TRUE
UINT16 handle_of_h_r; /* Handle of the handles reused characteristic value */
tGATT_APPL_INFO cb_info;
@ -586,7 +593,9 @@ extern tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP);
/* utility functions */
extern UINT8 *gatt_dbg_op_name(UINT8 op_code);
#if (SDP_INCLUDED == TRUE)
extern UINT32 gatt_add_sdp_record (tBT_UUID *p_uuid, UINT16 start_hdl, UINT16 end_hdl);
#endif ///SDP_INCLUDED == TRUE
extern BOOLEAN gatt_parse_uuid_from_cmd(tBT_UUID *p_uuid, UINT16 len, UINT8 **p_data);
extern UINT8 gatt_build_uuid_to_stream(UINT8 **p_dst, tBT_UUID uuid);
extern BOOLEAN gatt_uuid_compare(tBT_UUID src, tBT_UUID tar);
@ -621,6 +630,7 @@ extern tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_handle(UINT16 handle);
extern tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_attr_handle(UINT16 attr_handle);
extern tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void);
extern void gatt_free_hdl_buffer(tGATT_HDL_LIST_ELEM *p);
extern void gatt_free_attr_value_buffer(tGATT_HDL_LIST_ELEM *p);
extern BOOLEAN gatt_is_last_attribute(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM *p_start, tBT_UUID value);
extern void gatt_update_last_pri_srv_info(tGATT_SRV_LIST_INFO *p_list);
extern BOOLEAN gatt_add_a_srv_to_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM *p_new);

0
tools/sdk/include/bluedroid/gki_target.h Executable file → Normal file
View File

0
tools/sdk/include/bluedroid/hash_functions.h Executable file → Normal file
View File

0
tools/sdk/include/bluedroid/hci_internals.h Executable file → Normal file
View File

View File

@ -0,0 +1,69 @@
/******************************************************************************
*
* 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 connection internal definitions
*
******************************************************************************/
#ifndef HID_CONN_H
#define HID_CONN_H
#if (HID_HOST_INCLUDED == TRUE)
/* Define the HID Connection Block
*/
typedef struct hid_conn {
#define HID_CONN_STATE_UNUSED (0)
#define HID_CONN_STATE_CONNECTING_CTRL (1)
#define HID_CONN_STATE_CONNECTING_INTR (2)
#define HID_CONN_STATE_CONFIG (3)
#define HID_CONN_STATE_CONNECTED (4)
#define HID_CONN_STATE_DISCONNECTING (5)
#define HID_CONN_STATE_SECURITY (6)
UINT8 conn_state;
#define HID_CONN_FLAGS_IS_ORIG (0x01)
#define HID_CONN_FLAGS_HIS_CTRL_CFG_DONE (0x02)
#define HID_CONN_FLAGS_MY_CTRL_CFG_DONE (0x04)
#define HID_CONN_FLAGS_HIS_INTR_CFG_DONE (0x08)
#define HID_CONN_FLAGS_MY_INTR_CFG_DONE (0x10)
#define HID_CONN_FLAGS_ALL_CONFIGURED (0x1E) /* All the config done */
#define HID_CONN_FLAGS_CONGESTED (0x20)
#define HID_CONN_FLAGS_INACTIVE (0x40)
UINT8 conn_flags;
UINT8 ctrl_id;
UINT16 ctrl_cid;
UINT16 intr_cid;
UINT16 rem_mtu_size;
UINT16 disc_reason; /* Reason for disconnecting (for HID_HDEV_EVT_CLOSE) */
TIMER_LIST_ENT timer_entry;
} tHID_CONN;
#define HID_SEC_CHN 1
#define HID_NOSEC_CHN 2
#define HIDD_SEC_CHN 3
#define HIDD_NOSEC_CHN 4
#endif ///HID_HOST_INCLUDED == TRUE
#endif

View File

@ -24,8 +24,12 @@
#ifndef HIDDEFS_H
#define HIDDEFS_H
#include "bt_target.h"
#if (HID_HOST_INCLUDED == TRUE)
#if (SDP_INCLUDED == TRUE)
#include "sdp_api.h"
#endif ///SDP_INCLUDED == TRUE
/*
** tHID_STATUS: HID result codes, returned by HID and device and host functions.
*/
@ -149,8 +153,11 @@ typedef struct sdp_info {
tHID_DEV_DSCP_INFO dscp_info; /* Descriptor list and Report list to be set in the SDP record.
This parameter is used if HID_DEV_USE_GLB_SDP_REC is set to FALSE.*/
#if(SDP_INCLUDED == TRUE)
tSDP_DISC_REC *p_sdp_layer_rec;
#endif ///SDP_INCLUDED == TRUE
} tHID_DEV_SDP_INFO;
#endif ///HID_HOST_INCLUDED == TRUE
#endif

View File

@ -21,6 +21,7 @@
#include "hiddefs.h"
#include "sdp_api.h"
#if (HID_HOST_INCLUDED == TRUE)
/*****************************************************************************
** Constants
*****************************************************************************/
@ -232,4 +233,6 @@ extern UINT8 HID_HostSetTraceLevel (UINT8 new_level);
}
#endif
#endif ///HID_HOST_INCLUDED == TRUE
#endif /* HIDH_API_H */

View File

@ -0,0 +1,95 @@
/******************************************************************************
*
* 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 HOST internal definitions
*
******************************************************************************/
#ifndef HIDH_INT_H
#define HIDH_INT_H
#include "hidh_api.h"
#include "hid_conn.h"
#include "l2c_api.h"
#if (HID_HOST_INCLUDED == TRUE)
enum {
HID_DEV_NO_CONN,
HID_DEV_CONNECTED
};
typedef struct per_device_ctb {
BOOLEAN in_use;
BD_ADDR addr; /* BD-Addr of the host device */
UINT16 attr_mask; /* 0x01- virtual_cable; 0x02- normally_connectable; 0x03- reconn_initiate;
0x04- sdp_disable; */
UINT8 state; /* Device state if in HOST-KNOWN mode */
UINT8 conn_substate;
UINT8 conn_tries; /* Remembers to the number of connection attempts while CONNECTING */
tHID_CONN conn; /* L2CAP channel info */
} tHID_HOST_DEV_CTB;
typedef struct host_ctb {
tHID_HOST_DEV_CTB devices[HID_HOST_MAX_DEVICES];
tHID_HOST_DEV_CALLBACK *callback; /* Application callbacks */
tL2CAP_CFG_INFO l2cap_cfg;
#define MAX_SERVICE_DB_SIZE 4000
BOOLEAN sdp_busy;
tHID_HOST_SDP_CALLBACK *sdp_cback;
tSDP_DISCOVERY_DB *p_sdp_db;
tHID_DEV_SDP_INFO sdp_rec;
BOOLEAN reg_flag;
UINT8 trace_level;
} tHID_HOST_CTB;
extern tHID_STATUS hidh_conn_snd_data(UINT8 dhandle, UINT8 trans_type, UINT8 param, \
UINT16 data, UINT8 rpt_id, BT_HDR *buf);
extern tHID_STATUS hidh_conn_reg (void);
extern void hidh_conn_dereg( void );
extern tHID_STATUS hidh_conn_disconnect (UINT8 dhandle);
extern tHID_STATUS hidh_conn_initiate (UINT8 dhandle);
extern void hidh_proc_repage_timeout (TIMER_LIST_ENT *p_tle);
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************************************
** Main Control Block
*******************************************************************************/
#if HID_DYNAMIC_MEMORY == FALSE
extern tHID_HOST_CTB hh_cb;
#else
extern tHID_HOST_CTB *hidh_cb_ptr;
#define hh_cb (*hidh_cb_ptr)
#endif
#ifdef __cplusplus
}
#endif
#endif ///HID_HOST_INCLUDED == TRUE
#endif

View File

@ -21,6 +21,7 @@
#include <stdbool.h>
#include "bt_defs.h"
#include "bt_target.h"
typedef enum {
// Disable secure connections

View File

@ -331,6 +331,7 @@ extern "C"
{
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function L2CA_Register
@ -483,6 +484,8 @@ extern BOOLEAN L2CA_DisconnectReq (UINT16 cid);
**
*******************************************************************************/
extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
@ -497,6 +500,8 @@ extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
*******************************************************************************/
extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data);
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function L2CA_Ping
@ -519,6 +524,8 @@ extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb);
**
*******************************************************************************/
extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback);
#endif ///CLASSIC_BT_INCLUDED == TRUE
// Given a local channel identifier, |lcid|, this function returns the bound remote
// channel identifier, |rcid|, and the ACL link handle, |handle|. If |lcid| is not
@ -544,6 +551,7 @@ bool L2CA_GetIdentifiers(uint16_t lcid, uint16_t *rcid, uint16_t *handle);
extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout,
BOOLEAN is_global);
/*******************************************************************************
**
** Function L2CA_SetIdleTimeoutByBdAddr
@ -566,6 +574,7 @@ extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout,
extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout,
tBT_TRANSPORT transport);
/*******************************************************************************
**
** Function L2CA_SetTraceLevel
@ -578,6 +587,7 @@ extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout,
*******************************************************************************/
extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level);
/*******************************************************************************
**
** Function L2CA_SetDesireRole
@ -595,7 +605,7 @@ extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level);
**
*******************************************************************************/
extern UINT8 L2CA_SetDesireRole (UINT8 new_role);
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function L2CA_LocalLoopbackReq
@ -722,6 +732,7 @@ typedef void (tL2CA_RESERVE_CMPL_CBACK) (void);
** ACL link.
*******************************************************************************/
extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout);
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
@ -780,6 +791,8 @@ extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat, UINT8
*******************************************************************************/
extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr);
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function L2CA_GetChnlFcrMode
@ -792,6 +805,7 @@ extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr);
**
*******************************************************************************/
extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid);
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
@ -1044,6 +1058,7 @@ extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT
#endif /* (L2CAP_NUM_FIXED_CHNLS > 0) */
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function L2CA_GetCurrentConfig
@ -1060,6 +1075,8 @@ extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT
extern BOOLEAN L2CA_GetCurrentConfig (UINT16 lcid,
tL2CAP_CFG_INFO **pp_our_cfg, tL2CAP_CH_CFG_BITS *p_our_cfg_bits,
tL2CAP_CFG_INFO **pp_peer_cfg, tL2CAP_CH_CFG_BITS *p_peer_cfg_bits);
#endif ///CLASSIC_BT_INCLUDED == TRUE
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************

View File

@ -18,6 +18,7 @@
#ifndef _L2CAP_CLIENT_H_
#define _L2CAP_CLIENT_H_
#if (defined(L2CAP_CLIENT_INCLUDED) && L2CAP_CLIENT_INCLUDED == TRUE)
//#include <hardware/bluetooth.h>
#include <stdbool.h>
@ -74,4 +75,6 @@ bool l2cap_client_is_connected(const l2cap_client_t *client);
// |client| nor |packet| may be NULL.
bool l2cap_client_write(l2cap_client_t *client, buffer_t *packet);
#endif ///(defined(L2CAP_CLIENT_INCLUDED) && L2CAP_CLIENT_INCLUDED == TRUE)
#endif /*_L2CAP_CLIENT_H_*/

0
tools/sdk/include/bluedroid/list.h Executable file → Normal file
View File

View File

@ -0,0 +1,86 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_ASSERT_H
#define _OI_ASSERT_H
/** @file
This file provides macros and functions for compile-time and run-time assertions.
When the OI_DEBUG preprocessor value is defined, the macro OI_ASSERT is compiled into
the program, providing for a runtime assertion failure check.
C_ASSERT is a macro that can be used to perform compile time checks.
*/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
/** \addtogroup Debugging Debugging APIs */
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef OI_DEBUG
/** The macro OI_ASSERT takes a condition argument. If the asserted condition
does not evaluate to true, the OI_ASSERT macro calls the host-dependent function,
OI_AssertFail(), which reports the failure and generates a runtime error.
*/
void OI_AssertFail(char *file, int line, char *reason);
#define OI_ASSERT(condition) \
{ if (!(condition)) OI_AssertFail(__FILE__, __LINE__, #condition); }
#define OI_ASSERT_FAIL(msg) \
{ OI_AssertFail(__FILE__, __LINE__, msg); }
#else
#define OI_ASSERT(condition)
#define OI_ASSERT_FAIL(msg)
#endif
/**
C_ASSERT() can be used to perform many compile-time assertions: type sizes, field offsets, etc.
An assertion failure results in compile time error C2118: negative subscript.
Unfortunately, this elegant macro doesn't work with GCC, so it's all commented out
for now. Perhaps later.....
*/
#ifndef C_ASSERT
// #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
// #define C_ASSERT(e)
#endif
/*****************************************************************************/
#ifdef __cplusplus
}
#endif
/**@}*/
#endif /* _OI_ASSERT_H */

View File

@ -0,0 +1,123 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_BITSTREAM_H
#define _OI_BITSTREAM_H
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
/**
@file
Function prototypes and macro definitions for manipulating input and output
bitstreams.
@ingroup codec_internal
*/
/**
@addtogroup codec_internal
@{
*/
#include "oi_codec_sbc_private.h"
#include "oi_stddefs.h"
INLINE void OI_BITSTREAM_ReadInit(OI_BITSTREAM *bs, const OI_BYTE *buffer);
INLINE void OI_BITSTREAM_WriteInit(OI_BITSTREAM *bs, OI_BYTE *buffer);
INLINE OI_UINT32 OI_BITSTREAM_ReadUINT(OI_BITSTREAM *bs, OI_UINT bits);
INLINE OI_UINT8 OI_BITSTREAM_ReadUINT4Aligned(OI_BITSTREAM *bs);
INLINE OI_UINT8 OI_BITSTREAM_ReadUINT8Aligned(OI_BITSTREAM *bs);
INLINE void OI_BITSTREAM_WriteUINT(OI_BITSTREAM *bs,
OI_UINT16 value,
OI_UINT bits);
/*
* Use knowledge that the bitstream is aligned to optimize the write of a byte
*/
PRIVATE void OI_BITSTREAM_WriteUINT8Aligned(OI_BITSTREAM *bs,
OI_UINT8 datum);
/*
* Use knowledge that the bitstream is aligned to optimize the write pair of nibbles
*/
PRIVATE void OI_BITSTREAM_Write2xUINT4Aligned(OI_BITSTREAM *bs,
OI_UINT8 datum1,
OI_UINT8 datum2);
/** Internally the bitstream looks ahead in the stream. When
* OI_SBC_ReadScalefactors() goes to temporarily break the abstraction, it will
* need to know where the "logical" pointer is in the stream.
*/
#define OI_BITSTREAM_GetWritePtr(bs) ((bs)->ptr.w - 3)
#define OI_BITSTREAM_GetReadPtr(bs) ((bs)->ptr.r - 3)
/** This is declared here as a macro because decoder.c breaks the bitsream
* encapsulation for efficiency reasons.
*/
#define OI_BITSTREAM_READUINT(result, bits, ptr, value, bitPtr) \
do { \
OI_ASSERT((bits) <= 16); \
OI_ASSERT((bitPtr) < 16); \
OI_ASSERT((bitPtr) >= 8); \
\
result = (value) << (bitPtr); \
result >>= 32 - (bits); \
\
bitPtr += (bits); \
while (bitPtr >= 16) { \
value = ((value) << 8) | *ptr++; \
bitPtr -= 8; \
} \
OI_ASSERT((bits == 0) || (result < (1u << (bits)))); \
} while (0)
#define OI_BITSTREAM_WRITEUINT(ptr, value, bitPtr, datum, bits) \
do {\
bitPtr -= bits;\
value |= datum << bitPtr;\
\
while (bitPtr <= 16) {\
bitPtr += 8;\
*ptr++ = (OI_UINT8)(value >> 24);\
value <<= 8;\
}\
} while (0)
#define OI_BITSTREAM_WRITEFLUSH(ptr, value, bitPtr) \
do {\
while (bitPtr < 32) {\
bitPtr += 8;\
*ptr++ = (OI_UINT8)(value >> 24);\
value <<= 8;\
}\
} while (0)
/**
@}
*/
#endif /* _OI_BITSTREAM_H */

View File

@ -0,0 +1,229 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_BT_SPEC_H
#define _OI_BT_SPEC_H
/**
* @file
*
* This file contains common definitions from the Bluetooth specification.
*
*/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
#include "oi_stddefs.h"
/** \addtogroup Misc Miscellaneous APIs */
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
/** The maximum number of active slaves in a piconet. */
#define OI_BT_MAX_ACTIVE_SLAVES 7
/** the number of bytes in a Bluetooth device address (BD_ADDR) */
#define OI_BD_ADDR_BYTE_SIZE 6
/**
* 48-bit Bluetooth device address
*
* Because 48-bit integers may not be supported on all platforms, the
* address is defined as an array of bytes. This array is big-endian,
* meaning that
* - array[0] contains bits 47-40,
* - array[1] contains bits 39-32,
* - array[2] contains bits 31-24,
* - array[3] contains bits 23-16,
* - array[4] contains bits 15-8, and
* - array[5] contains bits 7-0.
*/
typedef struct {
OI_UINT8 addr[OI_BD_ADDR_BYTE_SIZE] ; /**< Bluetooth device address represented as an array of 8-bit values */
} OI_BD_ADDR ;
/**
* @name Data types for working with UUIDs
* UUIDs are 16 bytes (128 bits).
*
* To avoid having to pass around 128-bit values all the time, 32-bit and 16-bit
* UUIDs are defined, along with a mapping from the shorter versions to the full
* version.
*
* @{
*/
/**
* 16-bit representation of a 128-bit UUID
*/
typedef OI_UINT16 OI_UUID16;
/**
* 32-bit representation of a 128-bit UUID
*/
typedef OI_UINT32 OI_UUID32;
/**
* number of bytes in a 128 bit UUID
*/
#define OI_BT_UUID128_SIZE 16
/**
* number of bytes in IPv6 style addresses
*/
#define OI_BT_IPV6ADDR_SIZE 16
/**
* type definition for a 128-bit UUID
*
* To simplify conversion between 128-bit UUIDs and 16-bit and 32-bit UUIDs,
* the most significant 32 bits are stored with the same endian-ness as is
* native on the target (local) device. The remainder of the 128-bit UUID is
* stored as bytes in big-endian order.
*/
typedef struct {
OI_UINT32 ms32bits; /**< most significant 32 bits of 128-bit UUID */
OI_UINT8 base[OI_BT_UUID128_SIZE - sizeof(OI_UINT32)]; /**< remainder of 128-bit UUID, array of 8-bit values */
} OI_UUID128;
/** @} */
/** number of bytes in a link key */
#define OI_BT_LINK_KEY_SIZE 16
/**
* type definition for a baseband link key
*
* Because 128-bit integers may not be supported on all platforms, we define
* link keys as an array of bytes. Unlike the Bluetooth device address,
* the link key is stored in little-endian order, meaning that
* - array[0] contains bits 0 - 7,
* - array[1] contains bits 8 - 15,
* - array[2] contains bits 16 - 23,
* - array[3] contains bits 24 - 31,
* - array[4] contains bits 32 - 39,
* - array[5] contains bits 40 - 47,
* - array[6] contains bits 48 - 55,
* - array[7] contains bits 56 - 63,
* - array[8] contains bits 64 - 71,
* - array[9] contains bits 72 - 79,
* - array[10] contains bits 80 - 87,
* - array[11] contains bits 88 - 95,
* - array[12] contains bits 96 - 103,
* - array[13] contains bits 104- 111,
* - array[14] contains bits 112- 119, and
* - array[15] contains bits 120- 127.
*/
typedef struct {
OI_UINT8 key[OI_BT_LINK_KEY_SIZE] ; /**< link key represented as an array of 8-bit values */
} OI_LINK_KEY ;
/** Out-of-band data size - C and R values are 16-bytes each */
#define OI_BT_OOB_NUM_BYTES 16
typedef struct {
OI_UINT8 value[OI_BT_OOB_NUM_BYTES] ; /**< same struct used for C and R values */
} OI_OOB_DATA ;
/**
* link key types
*/
typedef enum {
OI_LINK_KEY_TYPE_COMBO = 0, /**< combination key */
OI_LINK_KEY_TYPE_LOCAL_UNIT = 1, /**< local unit key */
OI_LINK_KEY_TYPE_REMOTE_UNIT = 2, /**< remote unit key */
OI_LINK_KEY_TYPE_DEBUG_COMBO = 3, /**< debug combination key */
OI_LINK_KEY_TYPE_UNAUTHENTICATED = 4, /**< Unauthenticated */
OI_LINK_KEY_TYPE_AUTHENTICATED = 5, /**< Authenticated */
OI_LINK_KEY_TYPE_CHANGED_COMBO = 6 /**< Changed */
} OI_BT_LINK_KEY_TYPE ;
/** amount of space allocated for a PIN (personal indentification number) in bytes */
#define OI_BT_PIN_CODE_SIZE 16
/** data type for a PIN (PINs are treated as strings, so endianness does not apply.) */
typedef struct {
OI_UINT8 pin[OI_BT_PIN_CODE_SIZE] ; /**< PIN represented as an array of 8-bit values */
} OI_PIN_CODE ;
/** maximum number of SCO connections per device, which is 3 as of version 2.0+EDR
of the Bluetooth specification (see sec 4.3 of vol 2 part B) */
#define OI_BT_MAX_SCO_CONNECTIONS 3
/** data type for clock offset */
typedef OI_UINT16 OI_BT_CLOCK_OFFSET ;
/** data type for a LM handle */
typedef OI_UINT16 OI_HCI_LM_HANDLE;
/** opaque data type for a SCO or ACL connection handle */
typedef struct _OI_HCI_CONNECTION *OI_HCI_CONNECTION_HANDLE;
/** data type for HCI Error Code, as defined in oi_hcispec.h */
typedef OI_UINT8 OI_HCI_ERROR_CODE ;
/**
* The Bluetooth device type is indicated by a 24-bit bitfield, represented as a
* 32-bit number in the stack. The bit layout and values for device class are specified
* in the file oi_bt_assigned_nos.h and in the Bluetooth "Assigned Numbers" specification
* at http://www.bluetooth.org/assigned-numbers/.
*/
typedef OI_UINT32 OI_BT_DEVICE_CLASS ;
#define OI_BT_DEV_CLASS_FORMAT_MASK 0x000003 /**< Bits 0-1 contain format type. */
#define OI_BT_DEV_CLASS_MINOR_DEVICE_MASK 0x0000FC /**< Bits 2-7 contain minor device class value. */
#define OI_BT_DEV_CLASS_MAJOR_DEVICE_MASK 0x001F00 /**< Bits 8-12 contain major device class value. */
#define OI_BT_DEV_CLASS_MAJOR_SERVICE_MASK 0xFFE000 /**< Bits 13-23 contain major service class value. */
/** There is currently only one device class format defined, type 00. */
#define OI_BT_DEV_CLASS_FORMAT_TYPE 00
/** Bit 13 in device class indicates limited discoverability mode (GAP v2.0+EDR, section 4.1.2.2) */
#define OI_BT_DEV_CLASS_LIMITED_DISCO_BIT BIT13
/** macro to test validity of the Device Class Format */
#define OI_BT_VALID_DEVICE_CLASS_FORMAT(class) (OI_BT_DEV_CLASS_FORMAT_TYPE == ((class) & OI_BT_DEV_CLASS_FORMAT_MASK))
/** the time between baseband clock ticks, currently 625 microseconds (one slot) */
#define OI_BT_TICK 625
/** some macros to convert to/from baseband clock ticks - use no floating point! */
#define OI_SECONDS_TO_BT_TICKS(secs) ((secs)*1600)
#define OI_BT_TICKS_TO_SECONDS(ticks) ((ticks)/1600)
#define OI_MSECS_TO_BT_TICKS(msecs) (((msecs)*8)/5)
#define OI_BT_TICKS_TO_MSECS(ticks) (((ticks)*5)/8)
/** EIR byte order */
#define OI_EIR_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
#ifdef __cplusplus
}
#endif
/**@}*/
/*****************************************************************************/
#endif /* _OI_BT_SPEC_H */

View File

@ -0,0 +1,484 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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.
*
******************************************************************************/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
#ifndef _OI_CODEC_SBC_CORE_H
#define _OI_CODEC_SBC_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
/**
@file
Declarations of codec functions, data types, and macros.
@ingroup codec_lib
*/
/**
@addtogroup codec_lib
@{
*/
/* Non-BM3 users of of the codec must include oi_codec_sbc_bm3defs.h prior to
* including this file, or else these includes will fail because the BM3 SDK is
* not in the include path */
#ifndef _OI_CODEC_SBC_BM3DEFS_H
#include "oi_stddefs.h"
#include "oi_status.h"
#endif
#include <stdint.h>
#define SBC_MAX_CHANNELS 2
#define SBC_MAX_BANDS 8
#define SBC_MAX_BLOCKS 16
#define SBC_MIN_BITPOOL 2 /**< Minimum size of the bit allocation pool used to encode the stream */
#define SBC_MAX_BITPOOL 250 /**< Maximum size of the bit allocation pool used to encode the stream */
#define SBC_MAX_ONE_CHANNEL_BPS 320000
#define SBC_MAX_TWO_CHANNEL_BPS 512000
#define SBC_WBS_BITRATE 62000
#define SBC_WBS_BITPOOL 27
#define SBC_WBS_NROF_BLOCKS 16
#define SBC_WBS_FRAME_LEN 62
#define SBC_WBS_SAMPLES_PER_FRAME 128
#define SBC_HEADER_LEN 4
#define SBC_MAX_FRAME_LEN (SBC_HEADER_LEN + \
((SBC_MAX_BANDS * SBC_MAX_CHANNELS / 2) + \
(SBC_MAX_BANDS + SBC_MAX_BLOCKS * SBC_MAX_BITPOOL + 7)/8))
#define SBC_MAX_SAMPLES_PER_FRAME (SBC_MAX_BANDS * SBC_MAX_BLOCKS)
#define SBC_MAX_SCALEFACTOR_BYTES ((4*(SBC_MAX_CHANNELS * SBC_MAX_BANDS) + 7)/8)
#define OI_SBC_SYNCWORD 0x9c
#define OI_SBC_ENHANCED_SYNCWORD 0x9d
/**@name Sampling frequencies */
/**@{*/
#define SBC_FREQ_16000 0 /**< The sampling frequency is 16 kHz. One possible value for the @a frequency parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_FREQ_32000 1 /**< The sampling frequency is 32 kHz. One possible value for the @a frequency parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_FREQ_44100 2 /**< The sampling frequency is 44.1 kHz. One possible value for the @a frequency parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_FREQ_48000 3 /**< The sampling frequency is 48 kHz. One possible value for the @a frequency parameter of OI_CODEC_SBC_EncoderConfigure() */
/**@}*/
/**@name Channel modes */
/**@{*/
#define SBC_MONO 0 /**< The mode of the encoded channel is mono. One possible value for the @a mode parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_DUAL_CHANNEL 1 /**< The mode of the encoded channel is dual-channel. One possible value for the @a mode parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_STEREO 2 /**< The mode of the encoded channel is stereo. One possible value for the @a mode parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_JOINT_STEREO 3 /**< The mode of the encoded channel is joint stereo. One possible value for the @a mode parameter of OI_CODEC_SBC_EncoderConfigure() */
/**@}*/
/**@name Subbands */
/**@{*/
#define SBC_SUBBANDS_4 0 /**< The encoded stream has 4 subbands. One possible value for the @a subbands parameter of OI_CODEC_SBC_EncoderConfigure()*/
#define SBC_SUBBANDS_8 1 /**< The encoded stream has 8 subbands. One possible value for the @a subbands parameter of OI_CODEC_SBC_EncoderConfigure() */
/**@}*/
/**@name Block lengths */
/**@{*/
#define SBC_BLOCKS_4 0 /**< A block size of 4 blocks was used to encode the stream. One possible value for the @a blocks parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_BLOCKS_8 1 /**< A block size of 8 blocks was used to encode the stream is. One possible value for the @a blocks parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_BLOCKS_12 2 /**< A block size of 12 blocks was used to encode the stream. One possible value for the @a blocks parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_BLOCKS_16 3 /**< A block size of 16 blocks was used to encode the stream. One possible value for the @a blocks parameter of OI_CODEC_SBC_EncoderConfigure() */
/**@}*/
/**@name Bit allocation methods */
/**@{*/
#define SBC_LOUDNESS 0 /**< The bit allocation method. One possible value for the @a loudness parameter of OI_CODEC_SBC_EncoderConfigure() */
#define SBC_SNR 1 /**< The bit allocation method. One possible value for the @a loudness parameter of OI_CODEC_SBC_EncoderConfigure() */
/**@}*/
/**
@}
@addtogroup codec_internal
@{
*/
typedef OI_INT16 SBC_BUFFER_T;
/** Used internally. */
typedef struct {
OI_UINT16 frequency; /**< The sampling frequency. Input parameter. */
OI_UINT8 freqIndex;
OI_UINT8 nrof_blocks; /**< The block size used to encode the stream. Input parameter. */
OI_UINT8 blocks;
OI_UINT8 nrof_subbands; /**< The number of subbands of the encoded stream. Input parameter. */
OI_UINT8 subbands;
OI_UINT8 mode; /**< The mode of the encoded channel. Input parameter. */
OI_UINT8 nrof_channels; /**< The number of channels of the encoded stream. */
OI_UINT8 alloc; /**< The bit allocation method. Input parameter. */
OI_UINT8 bitpool; /**< Size of the bit allocation pool used to encode the stream. Input parameter. */
OI_UINT8 crc; /**< Parity check byte used for error detection. */
OI_UINT8 join; /**< Whether joint stereo has been used. */
OI_UINT8 enhanced;
OI_UINT8 min_bitpool; /**< This value is only used when encoding. SBC_MAX_BITPOOL if variable
bitpools are disallowed, otherwise the minimum bitpool size that will
be used by the bit allocator. */
OI_UINT8 cachedInfo; /**< Information about the previous frame */
} OI_CODEC_SBC_FRAME_INFO;
/** Used internally. */
typedef struct {
const OI_CHAR *codecInfo;
OI_CODEC_SBC_FRAME_INFO frameInfo;
OI_INT8 scale_factor[SBC_MAX_CHANNELS * SBC_MAX_BANDS];
OI_UINT32 frameCount;
OI_INT32 *subdata;
SBC_BUFFER_T *filterBuffer[SBC_MAX_CHANNELS];
OI_INT32 filterBufferLen;
OI_UINT filterBufferOffset;
union {
OI_UINT8 uint8[SBC_MAX_CHANNELS * SBC_MAX_BANDS];
OI_UINT32 uint32[SBC_MAX_CHANNELS * SBC_MAX_BANDS / 4];
} bits;
OI_UINT8 maxBitneed; /**< Running maximum bitneed */
OI_BYTE formatByte;
OI_UINT8 pcmStride;
OI_UINT8 maxChannels;
} OI_CODEC_SBC_COMMON_CONTEXT;
/*
* A smaller value reduces RAM usage at the expense of increased CPU usage. Values in the range
* 27..50 are recommended, beyond 50 there is a diminishing return on reduced CPU usage.
*/
#define SBC_CODEC_MIN_FILTER_BUFFERS 16
#define SBC_CODEC_FAST_FILTER_BUFFERS 27
/* Expands to the number of OI_UINT32s needed to ensure enough memory to encode
* or decode streams of numChannels channels, using numBuffers buffers.
* Example:
* OI_UINT32 decoderData[CODEC_DATA_WORDS(SBC_MAX_CHANNELS, SBC_DECODER_FAST_SYNTHESIS_BUFFERS)];
* */
#define CODEC_DATA_WORDS(numChannels, numBuffers) \
((\
(sizeof(OI_INT32) * SBC_MAX_BLOCKS * numChannels * SBC_MAX_BANDS) \
+ (sizeof(SBC_BUFFER_T) * SBC_MAX_CHANNELS * SBC_MAX_BANDS * numBuffers) \
+ (sizeof (OI_UINT32) - 1) \
) / sizeof(OI_UINT32))
/** Opaque parameter to decoding functions; maintains decoder context. */
typedef struct {
OI_CODEC_SBC_COMMON_CONTEXT common;
OI_UINT8 limitFrameFormat; /* Boolean, set by OI_CODEC_SBC_DecoderLimit() */
OI_UINT8 restrictSubbands;
OI_UINT8 enhancedEnabled;
OI_UINT8 bufferedBlocks;
} OI_CODEC_SBC_DECODER_CONTEXT;
typedef struct {
OI_UINT32 data[CODEC_DATA_WORDS(1, SBC_CODEC_FAST_FILTER_BUFFERS)];
} OI_CODEC_SBC_CODEC_DATA_MONO;
typedef struct {
OI_UINT32 data[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)];
} OI_CODEC_SBC_CODEC_DATA_STEREO;
/**
@}
@addtogroup codec_lib
@{
*/
/**
* This function resets the decoder. The context must be reset when
* changing streams, or if the following stream parameters change:
* number of subbands, stereo mode, or frequency.
*
* @param context Pointer to the decoder context structure to be reset.
*
* @param enhanced If true, enhanced SBC operation is enabled. If enabled,
* the codec will recognize the alternative syncword for
* decoding an enhanced SBC stream. Enhancements should not
* be enabled unless the stream is known to be generated
* by an enhanced encoder, or there is a small possibility
* for decoding glitches if synchronization were to be lost.
*/
OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
OI_UINT32 *decoderData,
OI_UINT32 decoderDataBytes,
OI_UINT8 maxChannels,
OI_UINT8 pcmStride,
OI_BOOL enhanced);
/**
* This function restricts the kind of SBC frames that the Decoder will
* process. Its use is optional. If used, it must be called after
* calling OI_CODEC_SBC_DecoderReset(). After it is called, any calls
* to OI_CODEC_SBC_DecodeFrame() with SBC frames that do not conform
* to the Subband and Enhanced SBC setting will be rejected with an
* OI_STATUS_INVALID_PARAMETERS return.
*
* @param context Pointer to the decoder context structure to be limited.
*
* @param enhanced If true, all frames passed to the decoder must be
* Enhanced SBC frames. If false, all frames must be
* standard SBC frames.
*
* @param subbands May be set to SBC_SUBBANDS_4 or SBC_SUBBANDS_8. All
* frames passed to the decoder must be encoded with
* the requested number of subbands.
*
*/
OI_STATUS OI_CODEC_SBC_DecoderLimit(OI_CODEC_SBC_DECODER_CONTEXT *context,
OI_BOOL enhanced,
OI_UINT8 subbands);
/**
* This function sets the decoder parameters for a raw decode where the decoder parameters are not
* available in the sbc data stream. OI_CODEC_SBC_DecoderReset must be called
* prior to calling this function.
*
* @param context Decoder context structure. This must be the context must be
* used each time a frame is decoded.
*
* @param enhanced Set to TRUE to enable Qualcomm proprietary
* quality enhancements.
*
* @param frequency One of SBC_FREQ_16000, SBC_FREQ_32000, SBC_FREQ_44100,
* SBC_FREQ_48000
*
* @param mode One of SBC_MONO, SBC_DUAL_CHANNEL, SBC_STEREO,
* SBC_JOINT_STEREO
*
* @param subbands One of SBC_SUBBANDS_4, SBC_SUBBANDS_8
*
* @param blocks One of SBC_BLOCKS_4, SBC_BLOCKS_8, SBC_BLOCKS_12,
* SBC_BLOCKS_16
*
* @param alloc One of SBC_LOUDNESS, SBC_SNR
*
* @param maxBitpool The maximum bitpool size for this context
*/
OI_STATUS OI_CODEC_SBC_DecoderConfigureRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
OI_BOOL enhanced,
OI_UINT8 frequency,
OI_UINT8 mode,
OI_UINT8 subbands,
OI_UINT8 blocks,
OI_UINT8 alloc,
OI_UINT8 maxBitpool);
/**
* Decode one SBC frame. The frame has no header bytes. The context must have been previously
* initialized by calling OI_CODEC_SBC_DecoderConfigureRaw().
*
* @param context Pointer to a decoder context structure. The same context
* must be used each time when decoding from the same stream.
*
* @param bitpool The actual bitpool size for this frame. Must be <= the maxbitpool specified
* in the call to OI_CODEC_SBC_DecoderConfigureRaw(),
*
* @param frameData Address of a pointer to the SBC data to decode. This
* value will be updated to point to the next frame after
* successful decoding.
*
* @param frameBytes Pointer to a UINT32 containing the number of available
* bytes of frame data. This value will be updated to reflect
* the number of bytes remaining after a decoding operation.
*
* @param pcmData Address of an array of OI_INT16 pairs, which will be
* populated with the decoded audio data. This address
* is not updated.
*
* @param pcmBytes Pointer to a UINT32 in/out parameter. On input, it
* should contain the number of bytes available for pcm
* data. On output, it will contain the number of bytes
* written. Note that this differs from the semantics of
* frameBytes.
*/
OI_STATUS OI_CODEC_SBC_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
OI_UINT8 bitpool,
const OI_BYTE **frameData,
OI_UINT32 *frameBytes,
OI_INT16 *pcmData,
OI_UINT32 *pcmBytes);
/**
* Decode one SBC frame.
*
* @param context Pointer to a decoder context structure. The same context
* must be used each time when decoding from the same stream.
*
* @param frameData Address of a pointer to the SBC data to decode. This
* value will be updated to point to the next frame after
* successful decoding.
*
* @param frameBytes Pointer to a UINT32 containing the number of available
* bytes of frame data. This value will be updated to reflect
* the number of bytes remaining after a decoding operation.
*
* @param pcmData Address of an array of OI_INT16 pairs, which will be
* populated with the decoded audio data. This address
* is not updated.
*
* @param pcmBytes Pointer to a UINT32 in/out parameter. On input, it
* should contain the number of bytes available for pcm
* data. On output, it will contain the number of bytes
* written. Note that this differs from the semantics of
* frameBytes.
*/
OI_STATUS OI_CODEC_SBC_DecodeFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
const OI_BYTE **frameData,
OI_UINT32 *frameBytes,
OI_INT16 *pcmData,
OI_UINT32 *pcmBytes);
/**
* Calculate the number of SBC frames but don't decode. CRC's are not checked,
* but the Sync word is found prior to count calculation.
*
* @param frameData Pointer to the SBC data.
*
* @param frameBytes Number of bytes avaiable in the frameData buffer
*
*/
OI_UINT8 OI_CODEC_SBC_FrameCount(OI_BYTE *frameData,
OI_UINT32 frameBytes);
/**
* Analyze an SBC frame but don't do the decode.
*
* @param context Pointer to a decoder context structure. The same context
* must be used each time when decoding from the same stream.
*
* @param frameData Address of a pointer to the SBC data to decode. This
* value will be updated to point to the next frame after
* successful decoding.
*
* @param frameBytes Pointer to a UINT32 containing the number of available
* bytes of frame data. This value will be updated to reflect
* the number of bytes remaining after a decoding operation.
*
*/
OI_STATUS OI_CODEC_SBC_SkipFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
const OI_BYTE **frameData,
OI_UINT32 *frameBytes);
/* Common functions */
/**
Calculate the frame length.
@param frame The frame whose length to calculate
@return the length of an individual encoded frame in
bytes
*/
OI_UINT16 OI_CODEC_SBC_CalculateFramelen(OI_CODEC_SBC_FRAME_INFO *frame);
/**
* Calculate the maximum bitpool size that fits within a given frame length.
*
* @param frame The frame to calculate the bitpool size for
* @param frameLen The frame length to fit the bitpool to
*
* @return the maximum bitpool that will fit in the specified frame length
*/
OI_UINT16 OI_CODEC_SBC_CalculateBitpool(OI_CODEC_SBC_FRAME_INFO *frame,
OI_UINT16 frameLen);
/**
Calculate the bit rate.
@param frame The frame whose bit rate to calculate
@return the approximate bit rate in bits per second,
assuming that stream parameters are constant
*/
OI_UINT32 OI_CODEC_SBC_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame);
/**
Calculate decoded audio data length for one frame.
@param frame The frame whose audio data length to calculate
@return length of decoded audio data for a
single frame, in bytes
*/
OI_UINT16 OI_CODEC_SBC_CalculatePcmBytes(OI_CODEC_SBC_COMMON_CONTEXT *common);
/**
* Get the codec version text.
*
* @return pointer to text string containing codec version text
*
*/
OI_CHAR *OI_CODEC_Version(void);
/**
@}
@addtogroup codec_internal
@{
*/
extern const OI_CHAR *const OI_CODEC_SBC_FreqText[];
extern const OI_CHAR *const OI_CODEC_SBC_ModeText[];
extern const OI_CHAR *const OI_CODEC_SBC_SubbandsText[];
extern const OI_CHAR *const OI_CODEC_SBC_BlocksText[];
extern const OI_CHAR *const OI_CODEC_SBC_AllocText[];
/**
@}
@addtogroup codec_lib
@{
*/
#ifdef OI_DEBUG
void OI_CODEC_SBC_DumpConfig(OI_CODEC_SBC_FRAME_INFO *frameInfo);
#else
#define OI_CODEC_SBC_DumpConfig(f)
#endif
/**
@}
*/
#ifdef __cplusplus
}
#endif
#endif /* _OI_CODEC_SBC_CORE_H */

View File

@ -0,0 +1,229 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_CODEC_SBC_PRIVATE_H
#define _OI_CODEC_SBC_PRIVATE_H
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
/**
@file
Function prototypes and macro definitions used internally by the codec.
@ingroup codec_internal
*/
/**
@addtogroup codec_internal
@{
*/
#ifdef USE_RESTRICT_KEYWORD
#define RESTRICT restrict
#else
#define RESTRICT
#endif
#ifdef CODEC_DEBUG
#include <stdio.h>
#define ERROR(x) do { printf x; printf("\n"); } while (0)
#else
#define ERROR(x)
#endif
#ifdef TRACE_EXECUTION
#define TRACE(x) do { printf x; printf("\n"); } while (0)
#else
#define TRACE(x)
#endif
#ifndef PRIVATE
#define PRIVATE
#endif
#ifndef INLINE
#define INLINE
#endif
#include "oi_assert.h"
#include "oi_codec_sbc.h"
#ifndef OI_SBC_SYNCWORD
#define OI_SBC_SYNCWORD 0x9c
#endif
#ifndef DIVIDE
#define DIVIDE(a, b) ((a) / (b))
#endif
typedef union {
OI_UINT8 uint8[SBC_MAX_BANDS];
OI_UINT32 uint32[SBC_MAX_BANDS / 4];
} BITNEED_UNION1;
typedef union {
OI_UINT8 uint8[2 * SBC_MAX_BANDS];
OI_UINT32 uint32[2 * SBC_MAX_BANDS / 4];
} BITNEED_UNION2;
static const OI_UINT16 freq_values[] = { 16000, 32000, 44100, 48000 };
static const OI_UINT8 block_values[] = { 4, 8, 12, 16 };
static const OI_UINT8 channel_values[] = { 1, 2, 2, 2 };
static const OI_UINT8 band_values[] = { 4, 8 };
#define TEST_MODE_SENTINEL "OINA"
#define TEST_MODE_SENTINEL_LENGTH 4
/** Used internally. */
typedef struct {
union {
const OI_UINT8 *r;
OI_UINT8 *w;
} ptr;
OI_UINT32 value;
OI_UINT bitPtr;
} OI_BITSTREAM;
#define VALID_INT16(x) (((x) >= OI_INT16_MIN) && ((x) <= OI_INT16_MAX))
#define VALID_INT32(x) (((x) >= OI_INT32_MIN) && ((x) <= OI_INT32_MAX))
#define DCTII_8_SHIFT_IN 0
#define DCTII_8_SHIFT_OUT 16-DCTII_8_SHIFT_IN
#define DCTII_8_SHIFT_0 (DCTII_8_SHIFT_OUT)
#define DCTII_8_SHIFT_1 (DCTII_8_SHIFT_OUT)
#define DCTII_8_SHIFT_2 (DCTII_8_SHIFT_OUT)
#define DCTII_8_SHIFT_3 (DCTII_8_SHIFT_OUT)
#define DCTII_8_SHIFT_4 (DCTII_8_SHIFT_OUT)
#define DCTII_8_SHIFT_5 (DCTII_8_SHIFT_OUT)
#define DCTII_8_SHIFT_6 (DCTII_8_SHIFT_OUT-1)
#define DCTII_8_SHIFT_7 (DCTII_8_SHIFT_OUT-2)
#define DCT_SHIFT 15
#define DCTIII_4_SHIFT_IN 2
#define DCTIII_4_SHIFT_OUT 15
#define DCTIII_8_SHIFT_IN 3
#define DCTIII_8_SHIFT_OUT 14
OI_UINT computeBitneed(OI_CODEC_SBC_COMMON_CONTEXT *common,
OI_UINT8 *bitneeds,
OI_UINT ch,
OI_UINT *preferredBitpool);
void oneChannelBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common,
BITNEED_UNION1 *bitneeds,
OI_UINT ch,
OI_UINT bitcount);
OI_INT adjustToFitBitpool(const OI_UINT bitpool,
OI_UINT32 *bitneeds,
const OI_UINT subbands,
OI_UINT bitcount,
OI_UINT *excess);
INLINE OI_INT allocAdjustedBits(OI_UINT8 *dest,
OI_INT bits,
OI_INT excess);
INLINE OI_INT allocExcessBits(OI_UINT8 *dest,
OI_INT excess);
PRIVATE OI_UINT32 internal_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame);
PRIVATE OI_UINT16 internal_CalculateFramelen(OI_CODEC_SBC_FRAME_INFO *frame);
void monoBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *common);
typedef void (*BIT_ALLOC)(OI_CODEC_SBC_COMMON_CONTEXT *common);
PRIVATE OI_STATUS internal_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
OI_UINT8 bitpool,
const OI_BYTE **frameData,
OI_UINT32 *frameBytes,
OI_INT16 *pcmData,
OI_UINT32 *pcmBytes);
INLINE OI_STATUS internal_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
OI_UINT32 *decoderData,
OI_UINT32 decoderDataBytes,
OI_BYTE maxChannels,
OI_BYTE pcmStride,
OI_BOOL enhanced);
INLINE OI_UINT16 OI_SBC_CalculateFrameAndHeaderlen(OI_CODEC_SBC_FRAME_INFO *frame, OI_UINT *headerLen_);
PRIVATE OI_UINT32 OI_SBC_MaxBitpool(OI_CODEC_SBC_FRAME_INFO *frame);
PRIVATE void OI_SBC_ComputeBitAllocation(OI_CODEC_SBC_COMMON_CONTEXT *frame);
PRIVATE OI_UINT8 OI_SBC_CalculateChecksum(OI_CODEC_SBC_FRAME_INFO *frame, OI_BYTE const *data);
/* Transform functions */
PRIVATE void shift_buffer(SBC_BUFFER_T *dest, SBC_BUFFER_T *src, OI_UINT wordCount);
PRIVATE void cosineModulateSynth4(SBC_BUFFER_T *RESTRICT out, OI_INT32 const *RESTRICT in);
PRIVATE void SynthWindow40_int32_int32_symmetry_with_sum(OI_INT16 *pcm, SBC_BUFFER_T buffer[80], OI_UINT strideShift);
INLINE void dct3_4(OI_INT32 *RESTRICT out, OI_INT32 const *RESTRICT in);
PRIVATE void analyze4_generated(SBC_BUFFER_T analysisBuffer[RESTRICT 40],
OI_INT16 *pcm,
OI_UINT strideShift,
OI_INT32 subband[4]);
INLINE void dct3_8(OI_INT32 *RESTRICT out, OI_INT32 const *RESTRICT in);
PRIVATE void analyze8_generated(SBC_BUFFER_T analysisBuffer[RESTRICT 80],
OI_INT16 *pcm,
OI_UINT strideShift,
OI_INT32 subband[8]);
#ifdef SBC_ENHANCED
PRIVATE void analyze8_enhanced_generated(SBC_BUFFER_T analysisBuffer[RESTRICT 112],
OI_INT16 *pcm,
OI_UINT strideShift,
OI_INT32 subband[8]);
#endif
/* Decoder functions */
INLINE void OI_SBC_ReadHeader(OI_CODEC_SBC_COMMON_CONTEXT *common, const OI_BYTE *data);
PRIVATE void OI_SBC_ReadScalefactors(OI_CODEC_SBC_COMMON_CONTEXT *common, const OI_BYTE *b, OI_BITSTREAM *bs);
PRIVATE void OI_SBC_ReadSamples(OI_CODEC_SBC_DECODER_CONTEXT *common, OI_BITSTREAM *ob);
PRIVATE void OI_SBC_ReadSamplesJoint(OI_CODEC_SBC_DECODER_CONTEXT *common, OI_BITSTREAM *global_bs);
PRIVATE void OI_SBC_SynthFrame(OI_CODEC_SBC_DECODER_CONTEXT *context, OI_INT16 *pcm, OI_UINT start_block, OI_UINT nrof_blocks);
INLINE OI_INT32 OI_SBC_Dequant(OI_UINT32 raw, OI_UINT scale_factor, OI_UINT bits);
PRIVATE OI_BOOL OI_SBC_ExamineCommandPacket(OI_CODEC_SBC_DECODER_CONTEXT *context, const OI_BYTE *data, OI_UINT32 len);
PRIVATE void OI_SBC_GenerateTestSignal(OI_INT16 pcmData[][2], OI_UINT32 sampleCount);
PRIVATE void OI_SBC_ExpandFrameFields(OI_CODEC_SBC_FRAME_INFO *frame);
PRIVATE OI_STATUS OI_CODEC_SBC_Alloc(OI_CODEC_SBC_COMMON_CONTEXT *common,
OI_UINT32 *codecDataAligned,
OI_UINT32 codecDataBytes,
OI_UINT8 maxChannels,
OI_UINT8 pcmStride);
/**
@}
*/
#endif /* _OI_CODEC_SBC_PRIVATE_H */

View File

@ -0,0 +1,43 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_COMMON_H
#define _OI_COMMON_H
/**
* @file
*
* This file is used to group commonly used BLUEmagic 3.0 software
* header files.
*
* This file should be included in application source code along with the header
* files for the specific modules of the protocol stack being used.
*/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
#include "oi_bt_spec.h"
#include "oi_stddefs.h"
#include "oi_status.h"
#include "oi_time.h"
#include "oi_osinterface.h"
/*****************************************************************************/
#endif /* _OI_COMMON_H */

View File

@ -0,0 +1,505 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_CPU_DEP_H
#define _OI_CPU_DEP_H
/**
* @file
* This file contains definitions for characteristics of the target CPU and
* compiler, including primitive data types and endianness.
*
* This file defines the byte order and primitive data types for various
* CPU families. The preprocessor symbol 'CPU' must be defined to be an
* appropriate value or this header will generate a compile-time error.
*
* @note The documentation for this header file uses the x86 family of processors
* as an illustrative example for CPU/compiler-dependent data type definitions.
* Go to the source code of this header file to see the details of primitive type
* definitions for each platform.
*
* Additional information is available in the @ref data_types_docpage section.
*/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/** \addtogroup Misc Miscellaneous APIs */
/**@{*/
/** @name Definitions indicating family of target OI_CPU_TYPE
* @{
*/
#define OI_CPU_X86 1 /**< x86 processor family */
#define OI_CPU_ARM 2 /**< ARM processor family.
@deprecated Use #OI_CPU_ARM7_LEND or
#OI_CPU_ARM7_BEND. */
#define OI_CPU_ARC 3 /**< ARC processor family.
@deprecated Use #OI_CPU_ARC_LEND or
#OI_CPU_ARC_BEND. */
#define OI_CPU_SH3 4 /**< Hitachi SH-3 processor family */
#define OI_CPU_H8 5 /**< Hitachi H8 processor family */
#define OI_CPU_MIPS 6 /**< MIPS processor family */
#define OI_CPU_SPARC 7 /**< SPARC processor family */
#define OI_CPU_M68000 8 /**< Motorola M68000 processor family */
#define OI_CPU_PPC 9 /**< PowerPC (PPC) processor family */
#define OI_CPU_SH4_7750 10 /**< Hitachi SH7750 series in SH-4 processor family */
#define OI_CPU_SH2 11 /**< Hitachi SH-2 processor family */
#define OI_CPU_ARM7_LEND 12 /**< ARM7, little-endian */
#define OI_CPU_ARM7_BEND 13 /**< ARM7, big-endian */
#define OI_CPU_GDM1202 14 /**< GCT GDM1202 */
#define OI_CPU_ARC_LEND 15 /**< ARC processor family, little-endian */
#define OI_CPU_ARC_BEND 16 /**< ARC processor family, big-endian */
#define OI_CPU_M30833F 17 /**< Mitsubishi M308 processor family */
#define OI_CPU_CR16C 18 /**< National Semiconductor 16 bit processor family */
#define OI_CPU_M64111 19 /**< Renesas M64111 processor (M32R family) */
#define OI_CPU_ARMV5_LEND 20 //*< ARM5, little-endian */
#define OI_CPU_TYPE 12
#ifndef OI_CPU_TYPE
#error "OI_CPU_TYPE type not defined"
#endif
/**@}*/
/** @name Definitions indicating byte-wise endianness of target CPU
* @{
*/
#define OI_BIG_ENDIAN_BYTE_ORDER 0 /**< Multiple-byte values are stored in memory beginning with the most significant byte at the lowest address. */
#define OI_LITTLE_ENDIAN_BYTE_ORDER 1 /**< Multiple-byte values are stored in memory beginning with the least significant byte at the lowest address. */
/**@}*/
/** @name CPU/compiler-independent primitive data type definitions
* @{
*/
typedef int OI_BOOL; /**< Boolean values use native integer data type for target CPU. */
typedef int OI_INT; /**< Integer values use native integer data type for target CPU. */
typedef unsigned int OI_UINT; /**< Unsigned integer values use native unsigned integer data type for target CPU. */
typedef unsigned char OI_BYTE; /**< Raw bytes type uses native character data type for target CPU. */
/**@}*/
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_X86
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER /**< x86 platform byte ordering is little-endian */
/** @name CPU/compiler-dependent primitive data type definitions for x86 processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for x86 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for x86 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for x86 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for x86 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for x86 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for x86 processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_ARM
/* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARM7_LEND or OI_CPU_ARM7_BEND for
little-endian or big-endian configurations of the ARM7, respectively. */
#error OI_CPU_ARM is deprecated
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_ARC
/* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARC_LEND or OI_CPU_ARC_BEND for
little-endian or big-endian configurations of the ARC, respectively. */
#error OI_CPU_ARC is deprecated
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_SH3
/* The Hitachi SH C compiler defines _LIT or _BIG, depending on the endianness
specified to the compiler on the command line. */
#if defined(_LIT)
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER /**< If _LIT is defined, SH-3 platform byte ordering is little-endian. */
#elif defined(_BIG)
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER /**< If _BIG is defined, SH-3 platform byte ordering is big-endian. */
#else
#error SH compiler endianness undefined
#endif
/** @name CPU/compiler-dependent primitive data type definitions for SH-3 processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for SH-3 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for SH-3 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for SH-3 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for SH-3 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for SH-3 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for SH-3 processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_SH2
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER /**< SH-2 platform byte ordering is big-endian. */
/** @name CPU/compiler-dependent primitive data type definitions for SH-2 processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for SH-2 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for SH-2 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for SH-2 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for SH-2 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for SH-2 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for SH-2 processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_H8
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
#error basic types not defined
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_MIPS
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
/** @name CPU/compiler-dependent primitive data type definitions for MIPS processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARM7 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARM7 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARM7 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARM7 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARM7 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARM7 processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_SPARC
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
#error basic types not defined
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_M68000
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER /**< M68000 platform byte ordering is big-endian. */
/** @name CPU/compiler-dependent primitive data type definitions for M68000 processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for M68000 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for M68000 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for M68000 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for M68000 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for M68000 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for M68000 processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_PPC
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
/** @name CPU/compiler-dependent primitive data type definitions for PPC 8XX processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for PPC8XX processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for PPC8XX processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for PPC8XX processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for PPC8XX processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for PPC8XX processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for PPC8XX processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_SH4_7750
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER /**< SH7750 platform byte ordering is big-endian. */
/** @name CPU/compiler-dependent primitive data type definitions for SH7750 processor series of the SH-4 processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for SH7750 SH-4 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for SH7750 SH-4 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for SH7750 SH-4 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for SH7750 SH-4 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for SH7750 SH-4 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for SH7750 SH-4 processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_ARM7_LEND
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
/** @name little-endian CPU/compiler-dependent primitive data type definitions for the ARM7 processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARM7 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARM7 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARM7 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARM7 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARM7 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARM7 processor. */
typedef void *OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_ARM7_BEND
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
/** @name big-endian CPU/compiler-dependent primitive data type definitions for the ARM7 processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARM7 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARM7 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARM7 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARM7 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARM7 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARM7 processor. */
typedef void *OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_GDM1202
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
typedef signed char OI_INT8; /**< 8-bit signed integer. */
typedef signed short OI_INT16; /**< 16-bit signed integer. */
typedef signed long OI_INT32; /**< 32-bit signed integer. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_ARC_LEND
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
/** @name CPU/compiler-dependent primitive data type definitions for ARC processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARC processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARC processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARC processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARC processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARC processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARC processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_ARC_BEND
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
/** @name CPU/compiler-dependent primitive data type definitions for ARC processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARC processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARC processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARC processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARC processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARC processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARC processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_M30833F
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
/** @name CPU/compiler-dependent primitive data type definitions for Mitsubishi M308 processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for M308 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for M308 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for M308 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for M308 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for M308 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for M308 processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_CR16C
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
/** @name CPU/compiler-dependent primitive data type definitions for National Semicnductor processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for CR16C processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for CR16C processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for CR16C processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for CR16C processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for CR16C processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for CR16C processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_M64111
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
/** @name CPU/compiler-dependent primitive data type definitions for Renesas M32R processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for M64111 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for M64111 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for M64111 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for M64111 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for M64111 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for M64111 processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#if OI_CPU_TYPE==OI_CPU_ARMV5_LEND
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
/** @name little-endian CPU/compiler-dependent primitive data type definitions for the ARM7 processor family
* @{
*/
typedef signed char OI_INT8; /**< 8-bit signed integer values use native signed character data type for ARM7 processor. */
typedef signed short OI_INT16; /**< 16-bit signed integer values use native signed short integer data type for ARM7 processor. */
typedef signed long OI_INT32; /**< 32-bit signed integer values use native signed long integer data type for ARM7 processor. */
typedef unsigned char OI_UINT8; /**< 8-bit unsigned integer values use native unsigned character data type for ARM7 processor. */
typedef unsigned short OI_UINT16; /**< 16-bit unsigned integer values use native unsigned short integer data type for ARM7 processor. */
typedef unsigned long OI_UINT32; /**< 32-bit unsigned integer values use native unsigned long integer data type for ARM7 processor. */
typedef OI_UINT32 OI_ELEMENT_UNION; /**< Type for first element of a union to support all data types up to pointer width. */
/**@}*/
#endif
/*********************************************************************************/
#ifndef OI_CPU_BYTE_ORDER
#error "Byte order (endian-ness) not defined"
#endif
/**@}*/
#ifdef __cplusplus
}
#endif
/*********************************************************************************/
#endif /* _OI_CPU_DEP_H */

View File

@ -0,0 +1,171 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_MODULES_H
#define _OI_MODULES_H
/**
* @file
*
* Enumeration type defining the inidivual stack components.
*
*/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
/** \addtogroup Misc Miscellaneous APIs */
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* This enumeration lists constants for referencing the components of
* the BLUEmagic 3.0 protocol stack, profiles, and other functionalities.
*
* In order to distinguish types of modules, items are grouped with markers to
* delineate start and end of the groups
*
* The module type is used for various purposes:
* identification in debug print statements
* access to initialization flags
* access to the configuration table
*/
typedef enum {
/* profiles and protocols --> Updates to oi_debug.c and oi_config_table.c */
/* XX --> Keep Enum values up-to-date! */
OI_MODULE_AT, /**< 00 AT command processing */
OI_MODULE_A2DP, /**< 01 Advanced Audio Distribution Profile */
OI_MODULE_AVCTP, /**< 02 Audio-Visual Control Transport Profile */
OI_MODULE_AVDTP, /**< 03 Audio-Visual Distribution Protocol */
OI_MODULE_AVRCP, /**< 04 Audio-Visual Remote Control Profile */
OI_MODULE_BIP_CLI, /**< 05 Basic Imaging Profile protocol client */
OI_MODULE_BIP_SRV, /**< 06 Basic Imaging Profile protocol server */
OI_MODULE_BNEP, /**< 07 Bluetooth Network Encapsulation Protocol */
OI_MODULE_BPP_SENDER, /**< 08 Basic Printing Profile */
OI_MODULE_BPP_PRINTER, /**< 09 Basic Printing Profile */
OI_MODULE_CTP, /**< 10 Cordless Telephony Profile */
OI_MODULE_DUN, /**< 11 Dial-Up Networking Profile */
OI_MODULE_FAX, /**< 12 Fax Profile */
OI_MODULE_FTP_CLI, /**< 13 File Transfer Profile protocol client */
OI_MODULE_FTP_SRV, /**< 14 File Transfer Profile protocol server */
OI_MODULE_HANDSFREE, /**< 15 Hands-Free Profile */
OI_MODULE_HANDSFREE_AG, /**< 16 Hands-Free Profile */
OI_MODULE_HCRP_CLI, /**< 17 Hardcopy Cable Replacement Profile */
OI_MODULE_HCRP_SRV, /**< 18 Hardcopy Cable Replacement Profile */
OI_MODULE_HEADSET, /**< 19 Headset Profile */
OI_MODULE_HEADSET_AG, /**< 20 Headset Profile */
OI_MODULE_HID, /**< 21 Human Interface Device profile */
OI_MODULE_INTERCOM, /**< 22 Intercom Profile */
OI_MODULE_OBEX_CLI, /**< 23 OBEX protocol client, Generic Object Exchange Profile */
OI_MODULE_OBEX_SRV, /**< 24 OBEX protocol server, Generic Object Exchange Profile */
OI_MODULE_OPP_CLI, /**< 25 Object Push Profile protocol client */
OI_MODULE_OPP_SRV, /**< 26 Object Push Profile protocol server */
OI_MODULE_PAN, /**< 27 PAN profile */
OI_MODULE_PBAP_CLI, /**< 28 Phonebook Access Profile client */
OI_MODULE_PBAP_SRV, /**< 29 Phonebook Access Profile server */
OI_MODULE_SAP_CLI, /**< 30 SIM Access Profile */
OI_MODULE_SAP_SRV, /**< 31 SIM Access Profile */
OI_MODULE_SPP, /**< 32 Serial Port Profile */
OI_MODULE_SYNC_CLI, /**< 33 Synchronization Profile */
OI_MODULE_SYNC_SRV, /**< 34 Synchronization Profile */
OI_MODULE_SYNC_CMD_CLI, /**< 35 Synchronization Profile */
OI_MODULE_SYNC_CMD_SRV, /**< 36 Synchronization Profile */
OI_MODULE_SYNCML, /**< 37 SyncML Profile */
OI_MODULE_TCS, /**< 38 TCS Binary */
OI_MODULE_VDP, /**< 39 Video Distribution Profile */
/* corestack components --> Updates to oi_debug.c and oi_config_table.c */
OI_MODULE_COMMON_CONFIG, /**< 40 Common configuration, module has no meaning other than for config struct */
OI_MODULE_CMDCHAIN, /**< 41 Command chaining utility */
OI_MODULE_DISPATCH, /**< 42 Dispatcher */
OI_MODULE_DATAELEM, /**< 43 Data Elements, marshaller */
OI_MODULE_DEVMGR, /**< 44 Device Manager */
OI_MODULE_DEVMGR_MODES, /**< 45 Device Manager connectability/discoverability modes */
OI_MODULE_HCI, /**< 46 Host Controller Interface command layer */
OI_MODULE_L2CAP, /**< 47 L2CAP */
OI_MODULE_MEMMGR, /**< 48 modules that do memory management */
OI_MODULE_POLICYMGR, /**< 49 Policy Manager */
OI_MODULE_RFCOMM, /**< 50 RFCOMM */
OI_MODULE_RFCOMM_SD, /**< 51 RFCOMM Service discovery */
OI_MODULE_SDP_CLI, /**< 52 Service Discovery Protocol client */
OI_MODULE_SDP_SRV, /**< 53 Service Discovery Protocol server */
OI_MODULE_SDPDB, /**< 54 Service Discovery Protocol database */
OI_MODULE_SECMGR, /**< 55 Security Manager */
OI_MODULE_SNIFFLOG, /**< 56 sniff log */
OI_MODULE_SUPPORT, /**< 57 support functions, including CThru Dispatcher, time functions, and stack initialization */
OI_MODULE_TRANSPORT, /**< 58 transport layer between HCI command layer and driver */
OI_MODULE_TEST, /**< 59 used to debug output from internal test programs */
OI_MODULE_XML, /**< 60 XML/CSS parser */
OI_MODULE_DI, /**< 61 Device Identification Profile */
// bhapi components --> Updates to oi_debug.c
OI_MODULE_BHAPI, /**< 62 BLUEmagic Host API generic */
OI_MODULE_BHCLI, /**< 63 BLUEmagic Host API client side */
OI_MODULE_BHSRV, /**< 64 BLUEmagic Host API server side */
OI_MODULE_MSGQ, /**< 65 module that handles message queuing */
OI_MODULE_BHAPI_TRANSPORT, /**< 66 module that handles message queuing */
OI_MODULE_BLST_SRV, /**< 67 module that provides server side BHAPI Lightweight Serial Transport */
OI_MODULE_BLST_CLI, /**< 68 module that provides client side BHAPI Lightweight Serial Transport */
// OEM files --> Updates to oi_debug.c
OI_MODULE_OEM, /**< 69 Application Memory allocation */
// Application glue --> Updates to oi_debug.c
OI_MODULE_APP, /**< 70 Application Memory allocation */
/* various pieces of code depend on these last 2 elements occuring in a specific order:
OI_MODULE_ALL must be the 2nd to last element
OI_MODULE_UNKNOWN must be the last element
*/
OI_MODULE_ALL, /**< 71 special value identifying all modules - used for control of debug print statements */
OI_MODULE_UNKNOWN /**< 72 special value - used for debug print statements */
} OI_MODULE;
/**
* This constant is the number of actual modules in the list. ALL and UNKNOWN are
* special values that are not actually modules.
* Used for debug print and memmgr profiling
*/
#define OI_NUM_MODULES OI_MODULE_ALL
/**
* This constant is the number of profile and core components. It is used to size
* the initialization and configuration tables.
*/
#define OI_NUM_STACK_MODULES OI_MODULE_BHAPI
#ifdef __cplusplus
}
#endif
/**@}*/
#endif /* _OI_MODULES_H */

View File

@ -0,0 +1,197 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_OSINTERFACE_H
#define _OI_OSINTERFACE_H
/**
@file
* This file provides the platform-independent interface for functions for which
* implementation is platform-specific.
*
* The functions in this header file define the operating system or hardware
* services needed by the BLUEmagic 3.0 protocol stack. The
* actual implementation of these services is platform-dependent.
*
*/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
#include "oi_stddefs.h"
#include "oi_time.h"
#include "oi_status.h"
#include "oi_modules.h"
/** \addtogroup Misc Miscellaneous APIs */
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* Terminates execution.
*
* @param reason Reason for termination
*/
void OI_FatalError(OI_STATUS reason);
/**
* This function logs an error.
*
* When built for release mode, BLUEmagic 3 errors are logged to
* this function. (in debug mode, errors are logged via
* OI_Print()).
*
* @param module Module in which the error was detected (see
* oi_modules.h)
* @param lineno Line number of the C file OI_SLOG_ERROR called
* @param status Status code associated with the error event
*/
void OI_LogError(OI_MODULE module, OI_INT lineno, OI_STATUS status);
/**
* This function initializes the debug code handling.
*
* When built for debug mode, this function performs platform
* dependent initialization to handle message codes passed in
* via OI_SetMsgCode().
*/
void OI_InitDebugCodeHandler(void);
/**
* This function reads the time from the real time clock.
*
* All timing in BM3 is relative, typically a granularity
* of 5 or 10 msecs is adequate.
*
* @param[out] now Pointer to the buffer to which the current
* time will be returned
*/
void OI_Time_Now(OI_TIME *now);
/**
* This function causes the current thread to sleep for the
* specified amount of time. This function must be called
* without the stack access token.
*
* @note BM3 corestack and profiles never suspend and never call
* OI_Sleep. The use of OI_Sleep is limited to applications and
* platform-specific code.
*
* If your port and applications never use OI_Sleep, this function can be left unimplemented.
*
* @param milliseconds Number of milliseconds to sleep
*/
void OI_Sleep(OI_UINT32 milliseconds);
/**
* Defines for message type codes.
*/
#define OI_MSG_CODE_APPLICATION 0 /**< Application output */
#define OI_MSG_CODE_ERROR 1 /**< Error message output */
#define OI_MSG_CODE_WARNING 2 /**< Warning message output */
#define OI_MSG_CODE_TRACE 3 /**< User API function trace output */
#define OI_MSG_CODE_PRINT1 4 /**< Catagory 1 debug print output */
#define OI_MSG_CODE_PRINT2 5 /**< Catagory 2 debug print output */
#define OI_MSG_CODE_HEADER 6 /**< Error/Debug output header */
/**
* This function is used to indicate the type of text being output with
* OI_Print(). For the Linux and Win32 platforms, it will set
* the color of the text. Other possible uses could be to insert
* HTML style tags, add some other message type indication, or
* be completely ignored altogether.
*
* @param code OI_MSG_CODE_* indicating setting the message type.
*/
void OI_SetMsgCode(OI_UINT8 code);
/**
* All output from OI_Printf() and all debug output is sent to OI_Print.
* Typically, if the platform has a console, OI_Print() is sent to stdout.
* Embedded platforms typically send OI_Print() output to a serial port.
*
* @param str String to print
*/
void OI_Print(OI_CHAR const *str);
/**
* In cases where OI_Print() is sending output to a logfile in addition to console,
* it is desirable to also put console input into the logfile.
* This function can be called by the console input process.
*
* @note This is an optional API which is strictly
* between the platform-specific stack_console and osinterface
* modules. This API need only be implemented on those
* platforms where is serves a useful purpose, e.g., win32.
*
* @param str Console input string
*/
void OI_Print_ConsoleInput(OI_CHAR const *str);
/**
* This function computes the CRC16 of the program image.
*/
OI_UINT16 OI_ProgramImageCRC16(void);
/**
* Writes an integer to stdout in hex. This macro is intended
* for selective use when debugging in small memory
* configurations or other times when it is not possible to use
* OI_DBGPRINT.
*
* @param n the integer to print
*/
#define OI_Print_Int(n) \
{ \
static const OI_CHAR _digits[] = "0123456789ABCDEF"; \
OI_CHAR _buf[9]; \
OI_CHAR *_str = &_buf[8]; \
OI_UINT32 _i = n; \
*_str = 0; \
do { *(--_str) = _digits[(_i & 0xF)]; _i >>= 4; } while (_i); \
OI_Print(_str); \
}
/**
* Application Dynamic Memory allocation.
*
* These APIs are provided for application use on those
* platforms which have no dynamic memory support. Memory is
* allocated from the pool-based heap managed by the stack's
* internal memory manager.
*/
void *OI_APP_Malloc(OI_INT32 size);
void OI_APP_Free(void *ptr);
/*****************************************************************************/
#ifdef __cplusplus
}
#endif
/**@}*/
#endif /* _OI_OSINTERFACE_H */

View File

@ -0,0 +1,579 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_STATUS_H
#define _OI_STATUS_H
/**
* @file
* This file contains status codes for BLUEmagic 3.0 software.
*/
#include "oi_stddefs.h"
/** \addtogroup Misc Miscellaneous APIs */
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
/** test it **/
/**
* OI_STATUS must fit in 16 bits, so status codes can range from 0 to 66535, inclusive.
*/
typedef enum {
OI_STATUS_SUCCESS = 0, /**< function call succeeded alias for #OI_OK */
OI_OK = 0, /**< function call succeeded alias for #OI_STATUS_SUCCESS */
OI_STATUS_INVALID_PARAMETERS = 101, /**< invalid function input parameters */
OI_STATUS_NOT_IMPLEMENTED = 102, /**< attempt to use an unimplemented function */
OI_STATUS_NOT_INITIALIZED = 103, /**< data not initialized */
OI_STATUS_NO_RESOURCES = 104, /**< generic resource allocation failure status */
OI_STATUS_INTERNAL_ERROR = 105, /**< internal inconsistency */
OI_STATUS_OUT_OF_MEMORY = 106, /**< generally, OI_Malloc failed */
OI_ILLEGAL_REENTRANT_CALL = 107, /**< violation of non-reentrant module policy */
OI_STATUS_INITIALIZATION_FAILED = 108, /**< module initialization failed */
OI_STATUS_INITIALIZATION_PENDING = 109, /**< inititialization not yet complete */
OI_STATUS_NO_SCO_SUPPORT = 110, /**< SCO operation rejected; system not configured for SCO */
OI_STATUS_OUT_OF_STATIC_MEMORY = 111, /**< static malloc failed */
OI_TIMEOUT = 112, /**< generic timeout */
OI_OS_ERROR = 113, /**< some operating system error */
OI_FAIL = 114, /**< generic failure */
OI_STRING_FORMAT_ERROR = 115, /**< error in VarString formatting string */
OI_STATUS_PENDING = 116, /**< The operation is pending. */
OI_STATUS_INVALID_COMMAND = 117, /**< The command was invalid. */
OI_BUSY_FAIL = 118, /**< command rejected due to busy */
OI_STATUS_ALREADY_REGISTERED = 119, /**< The registration has already been performed. */
OI_STATUS_NOT_FOUND = 120, /**< The referenced resource was not found. */
OI_STATUS_NOT_REGISTERED = 121, /**< not registered */
OI_STATUS_NOT_CONNECTED = 122, /**< not connected */
OI_CALLBACK_FUNCTION_REQUIRED = 123, /**< A callback function parameter was required. */
OI_STATUS_MBUF_OVERFLOW = 124, /**< There is no room to add another buffer to an mbuf. */
OI_STATUS_MBUF_UNDERFLOW = 125, /**< There was an attempt to pull too many bytes from an mbuf. */
OI_STATUS_CONNECTION_EXISTS = 126, /**< connection exists */
OI_STATUS_NOT_CONFIGURED = 127, /**< module not configured */
OI_LOWER_STACK_ERROR = 128, /**< An error was reported by lower stack API. This is used for embedded platforms. */
OI_STATUS_RESET_IN_PROGRESS = 129, /**< Request failed/rejected because we're busy resetting. */
OI_STATUS_ACCESS_DENIED = 130, /**< Generic access denied error. */
OI_STATUS_DATA_ERROR = 131, /**< Generic data error. */
OI_STATUS_INVALID_ROLE = 132, /**< The requested role was invalid. */
OI_STATUS_ALREADY_CONNECTED = 133, /**< The requested connection is already established. */
OI_STATUS_PARSE_ERROR = 134, /**< Parse error */
OI_STATUS_END_OF_FILE = 135, /**< End of file */
OI_STATUS_READ_ERROR = 136, /**< Generic read error */
OI_STATUS_WRITE_ERROR = 137, /**< Generic write error */
OI_STATUS_NEGOTIATION_FAILURE = 138, /**< Error in negotiation */
OI_STATUS_READ_IN_PROGRESS = 139, /**< A read is already in progress */
OI_STATUS_ALREADY_INITIALIZED = 140, /**< Initialization has already been done */
OI_STATUS_STILL_CONNECTED = 141, /**< The service cannot be shutdown because there are still active connections. */
OI_STATUS_MTU_EXCEEDED = 142, /**< The packet is too big */
OI_STATUS_LINK_TERMINATED = 143, /**< The link was terminated */
OI_STATUS_PIN_CODE_TOO_LONG = 144, /**< Application gave us a pin code that is too long */
OI_STATUS_STILL_REGISTERED = 145, /**< The service cannot be shutdown because there are still active registrations. */
OI_STATUS_SPEC_VIOLATION = 146, /**< Some application behavior contrary to BT specifications */
OI_STATUS_PSM_ALREADY_REGISTERED = 402, /**< L2CAP: The specified PSM has already been registered. */
OI_STATUS_INVALID_CID = 403, /**< L2CAP: CID is invalid or no longer valid (connection terminated) */
OI_STATUS_CID_NOT_FOUND = 404, /**< L2CAP: CID does not represent a current connection */
OI_STATUS_CHANNEL_NOT_FOUND = 406, /**< L2CAP: CID does not represent a current connection */
OI_STATUS_PSM_NOT_FOUND = 407, /**< L2CAP: PSM not found */
OI_STATUS_INVALID_STATE = 408, /**< L2CAP: invalid state */
OI_STATUS_WRITE_IN_PROGRESS = 410, /**< L2CAP: write in progress */
OI_STATUS_INVALID_PACKET = 411, /**< L2CAP: invalid packet */
OI_STATUS_SEND_COMPLETE = 412, /**< L2CAP: send is complete */
OI_STATUS_INVALID_HANDLE = 414, /**< L2CAP: handle is invalid */
OI_STATUS_GROUP_FULL = 418, /**< L2CAP: No more members can be added to the specified group. */
OI_STATUS_DEVICE_ALREADY_IN_GROUP = 423, /**< L2CAP: The device already exists in the group. */
OI_STATUS_DUPLICATE_GROUP = 425, /**< L2CAP: attempt to add more than one group */
OI_STATUS_EMPTY_GROUP = 426, /**< L2CAP: group is empty */
OI_STATUS_PACKET_NOT_FOUND = 427, /**< L2CAP: packet not found */
OI_STATUS_BUFFER_TOO_SMALL = 428, /**< L2CAP: The buffer size is too small. */
OI_STATUS_IDENTIFIER_NOT_FOUND = 429, /**< L2CAP: identifier not found */
OI_L2CAP_DISCONNECT_LOWER_LAYER = 430, /**< L2CAP: The lower level forced a disconnect. */
OI_L2CAP_DISCONNECT_REMOTE_REQUEST = 431, /**< L2CAP: The remote device requested a disconnect. */
OI_L2CAP_GROUP_ADD_CONNECT_FAIL = 433, /**< L2CAP: Group add connect faiL */
OI_L2CAP_GROUP_REMOVE_FAILURE = 434, /**< L2CAP: Group remove failure */
OI_L2CAP_DATA_WRITE_ERROR_LINK_TERM = 435, /**< L2CAP: Data write error LINK_TERM */
OI_L2CAP_DISCONNECT_LOCAL_REQUEST = 436, /**< L2CAP: Disconnect local request */
OI_L2CAP_CONNECT_TIMEOUT = 437, /**< L2CAP: Connect timeout */
OI_L2CAP_DISCONNECT_TIMEOUT = 439, /**< L2CAP: Disconnect timeout */
OI_L2CAP_PING_TIMEOUT = 440, /**< L2CAP: Ping timeout */
OI_L2CAP_GET_INFO_TIMEOUT = 441, /**< L2CAP: Get info timeout */
OI_L2CAP_INVALID_ADDRESS = 444, /**< L2CAP: Invalid address */
OI_L2CAP_CMD_REJECT_RCVD = 445, /**< L2CAP: remote sent us 'command reject' response */
OI_L2CAP_CONNECT_BASE = 450, /**< L2CAP: Connect base */
OI_L2CAP_CONNECT_PENDING = 451, /**< L2CAP: Connect pending */
OI_L2CAP_CONNECT_REFUSED_INVALID_PSM = 452, /**< L2CAP: Connect refused invalid PSM */
OI_L2CAP_CONNECT_REFUSED_SECURITY = 453, /**< L2CAP: Connect refused security */
OI_L2CAP_CONNECT_REFUSED_NO_RESOURCES = 454, /**< L2CAP: Connect refused no resources */
OI_L2CAP_CONFIG_BASE = 460, /**< L2CAP: Config base */
OI_L2CAP_CONFIG_FAIL_INVALID_PARAMETERS = 461, /**< L2CAP: Config fail invalid parameters */
OI_L2CAP_CONFIG_FAIL_NO_REASON = 462, /**< L2CAP: Config fail no reason */
OI_L2CAP_CONFIG_FAIL_UNKNOWN_OPTIONS = 463, /**< L2CAP: Config fail unknown options */
OI_L2CAP_GET_INFO_BASE = 470, /**< L2CAP: Get info base */
OI_L2CAP_GET_INFO_NOT_SUPPORTED = 471, /**< L2CAP: Get info not supported */
OI_L2CAP_MTU_EXCEEDED = 472, /**< L2CAP: The MTU of the channel was exceeded */
OI_L2CAP_INVALID_PSM = 482, /**< L2CAP: Invalid PSM */
OI_L2CAP_INVALID_MTU = 483, /**< L2CAP: Invalid MTU */
OI_L2CAP_INVALID_FLUSHTO = 484, /**< L2CAP: Invalid flush timeout */
OI_HCI_NO_SUCH_CONNECTION = 601, /**< HCI: caller specified a non-existent connection handle */
OI_HCI_CB_LIST_FULL = 603, /**< HCI: callback list is full, cannot attempt to send command */
OI_HCI_EVENT_UNDERRUN = 605, /**< HCI: parsing event packet, premature end-of-parameters */
OI_HCI_UNKNOWN_EVENT_CODE = 607, /**< HCI: event received - event code is unknown */
OI_HCI_BAD_EVENT_PARM_LEN = 608, /**< HCI: event - parameter length is incorrect */
OI_HCI_CMD_QUEUE_FULL = 611, /**< HCI: command queue is full */
OI_HCI_SHORT_EVENT = 612, /**< HCI: event received, missing event code and/or parm len */
OI_HCI_TRANSMIT_NOT_READY = 613, /**< HCI: ACL/SCO transmit request failed - busy or no buffers available */
OI_HCI_ORPHAN_SENT_EVENT = 614, /**< HCI: got spurious 'sent' event from transport layer */
OI_HCI_CMD_TABLE_ERROR = 615, /**< HCI: inconsistency in the internal command table */
OI_HCI_UNKNOWN_CMD_ID = 616, /**< HCI: HciApi Command - unknown command id */
OI_HCI_UNEXPECTED_EVENT = 619, /**< HCI: event received which only occurs in response to our cmd */
OI_HCI_EVENT_TABLE_ERROR = 620, /**< HCI: inconsistency in the internal event table */
OI_HCI_EXPECTED_EVENT_TIMOUT = 621, /**< HCI: timed out waiting for an expected event */
OI_HCI_NO_CMD_DESC_FOR_OPCODE = 622, /**< HCI: event opcode is not known */
OI_HCI_INVALID_OPCODE_ERROR = 623, /**< HCI: command opcode is invalid */
OI_HCI_FLOW_CONTROL_DISABLED = 624, /**< HCI: can not use host flow control APIs if disabled in configuration */
OI_HCI_TX_COMPLETE = 625, /**< HCI: packet delivery to Host Controler complete */
OI_HCI_TX_ERROR = 626, /**< HCI: failed to deliver packet to Host Controler */
OI_HCI_DEVICE_NOT_INITIALIZED = 627, /**< HCI: commands from upper layers disallowed until device is up and running */
OI_HCI_UNSUPPORTED_COMMAND = 628, /**< HCI: command requested is not supported by local device */
OI_HCI_PASSTHROUGH_ERROR = 629, /**< HCI: Error processing passthrough command */
OI_HCI_PASSTHROUGH_ALREADY_SET = 630, /**< HCI: Passthrough mode already enabled */
OI_HCI_RESET_FAILURE = 631, /**< HCI: failed to reset the device/baseband */
OI_HCI_TRANSPORT_RESET = 632, /**< HCI: some operation failed because of a reset in the transport */
OI_HCIERR_HCIIFC_INIT_FAILURE = 633, /**< HCI: failed to initialize transport layer interface */
OI_HCIERR_FIRST_ERROR_VALUE = 701, /**< marker for first HCI protocol error */
OI_HCIERR_UNKNOWN_HCI_COMMAND = 701, /**< HCI: protocol error 0x01 */
OI_HCIERR_NO_CONNECTION = 702, /**< HCI: protocol error 0x02 */
OI_HCIERR_HARDWARE_FAILURE = 703, /**< HCI: protocol error 0x03 */
OI_HCIERR_PAGE_TIMEOUT = 704, /**< HCI: protocol error 0x04 */
OI_HCIERR_AUTHENTICATION_FAILURE = 705, /**< HCI: protocol error 0x05 */
OI_HCIERR_KEY_MISSING = 706, /**< HCI: protocol error 0x06 */
OI_HCIERR_MEMORY_FULL = 707, /**< HCI: protocol error 0x07 */
OI_HCIERR_CONNECTION_TIMEOUT = 708, /**< HCI: protocol error 0x08 */
OI_HCIERR_MAX_NUM_OF_CONNECTIONS = 709, /**< HCI: protocol error 0x09 */
OI_HCIERR_MAX_NUM_OF_SCO_CONNECTIONS = 710, /**< HCI: protocol error 0x0A */
OI_HCIERR_ACL_CONNECTION_ALREADY_EXISTS = 711, /**< HCI: protocol error 0x0B */
OI_HCIERR_COMMAND_DISALLOWED = 712, /**< HCI: protocol error 0x0C */
OI_HCIERR_HOST_REJECTED_RESOURCES = 713, /**< HCI: protocol error 0x0D */
OI_HCIERR_HOST_REJECTED_SECURITY = 714, /**< HCI: protocol error 0x0E */
OI_HCIERR_HOST_REJECTED_PERSONAL_DEVICE = 715, /**< HCI: protocol error 0x0F */
OI_HCIERR_HOST_TIMEOUT = 716, /**< HCI: protocol error 0x10 */
OI_HCIERR_UNSUPPORTED = 717, /**< HCI: protocol error 0x11 */
OI_HCIERR_INVALID_PARAMETERS = 718, /**< HCI: protocol error 0x12 */
OI_HCIERR_OTHER_END_USER_DISCONNECT = 719, /**< HCI: protocol error 0x13 */
OI_HCIERR_OTHER_END_LOW_RESOURCES = 720, /**< HCI: protocol error 0x14 */
OI_HCIERR_OTHER_END_POWERING_OFF = 721, /**< HCI: protocol error 0x15 */
OI_HCIERR_CONNECTION_TERMINATED_LOCALLY = 722, /**< HCI: protocol error 0x16 */
OI_HCIERR_REPEATED_ATTEMPTS = 723, /**< HCI: protocol error 0x17 */
OI_HCIERR_PAIRING_NOT_ALLOWED = 724, /**< HCI: protocol error 0x18 */
OI_HCIERR_UNKNOWN_LMP_PDU = 725, /**< HCI: protocol error 0x19 */
OI_HCIERR_UNSUPPORTED_REMOTE_FEATURE = 726, /**< HCI: protocol error 0x1A */
OI_HCIERR_SCO_OFFSET_REJECTED = 727, /**< HCI: protocol error 0x1B */
OI_HCIERR_SCO_INTERVAL_REJECTED = 728, /**< HCI: protocol error 0x1C */
OI_HCIERR_SCO_AIR_MODE_REJECTED = 729, /**< HCI: protocol error 0x1D */
OI_HCIERR_INVALID_LMP_PARMS = 730, /**< HCI: protocol error 0x1E */
OI_HCIERR_UNSPECIFIED_ERROR = 731, /**< HCI: protocol error 0x1F */
OI_HCIERR_UNSUPPORTED_LMP_PARAMETERS = 732, /**< HCI: protocol error 0x20 */
OI_HCIERR_ROLE_CHANGE_NOT_ALLOWED = 733, /**< HCI: protocol error 0x21 */
OI_HCIERR_LMP_RESPONSE_TIMEOUT = 734, /**< HCI: protocol error 0x22 */
OI_HCIERR_LMP_ERROR_TRANS_COLLISION = 735, /**< HCI: protocol error 0x23 */
OI_HCIERR_LMP_PDU_NOT_ALLOWED = 736, /**< HCI: protocol error 0x24 */
OI_HCIERR_ENCRYPTION_MODE_NOT_ACCEPTABLE = 737, /**< HCI: protocol error 0x25 */
OI_HCIERR_UNIT_KEY_USED = 738, /**< HCI: protocol error 0x26 */
OI_HCIERR_QOS_NOT_SUPPORTED = 739, /**< HCI: protocol error 0x27 */
OI_HCIERR_INSTANT_PASSED = 740, /**< HCI: protocol error 0x28 */
OI_HCIERR_UNIT_KEY_PAIRING_UNSUPPORTED = 741, /**< HCI: protocol error 0x29 */
OI_HCIERR_DIFFERENT_TRANS_COLLISION = 742, /**< HCI: protocol error 0x2A */
OI_HCIERR_RESERVED_2B = 743, /**< HCI: protocol error 0x2B */
OI_HCIERR_QOS_UNACCEPTABLE_PARAMETER = 744, /**< HCI: protocol error 0x2C */
OI_HCIERR_QOS_REJECTED = 745, /**< HCI: protocol error 0x2D */
OI_HCIERR_CHANNEL_CLASSIFICATION_NS = 746, /**< HCI: protocol error 0x2E */
OI_HCIERR_INSUFFICIENT_SECURITY = 747, /**< HCI: protocol error 0x2F */
OI_HCIERR_PARM_OUT_OF_MANDATORY_RANGE = 748, /**< HCI: protocol error 0x30 */
OI_HCIERR_RESERVED_31 = 749, /**< HCI: protocol error 0x31 */
OI_HCIERR_ROLE_SWITCH_PENDING = 750, /**< HCI: protocol error 0x32 */
OI_HCIERR_RESERVED_33 = 751, /**< HCI: protocol error 0x33 */
OI_HCIERR_RESERVED_SLOT_VIOLATION = 752, /**< HCI: protocol error 0x34 */
OI_HCIERR_ROLE_SWITCH_FAILED = 753, /**< HCI: protocol error 0x35 */
OI_HCIERR_EIR_TOO_LARGE = 754, /**< HCI: protocol error 0x36 */
OI_HCIERR_SSP_NOT_SUPPORTED_BY_HOST = 755, /**< HCI: protocol error 0x37 */
OI_HCIERR_HOST_BUSY_PAIRING = 756, /**< HCI: protocol error 0x38 */
OI_HCIERR_UNKNOWN_ERROR = 757, /**< HCI: unknown error code */
OI_HCIERR_LAST_ERROR_VALUE = 757, /**< marker for last HCI protocol error */
OI_SDP_SPEC_ERROR = 800, /**< SDP: Base error status for mapping OI_STATUS codes to SDP errors */
OI_SDP_INVALID_SERVICE_RECORD_HANDLE = (OI_SDP_SPEC_ERROR + 2), /**< SDP: protocol error Invalid Service Record Handle */
OI_SDP_INVALID_REQUEST_SYNTAX = (OI_SDP_SPEC_ERROR + 3), /**< SDP: protocol error Invalid Request Syntax */
OI_SDP_INVALID_PDU_SIZE = (OI_SDP_SPEC_ERROR + 4), /**< SDP: protocol error Invalid PDU Size */
OI_SDP_INVALID_CONTINUATION_STATE = (OI_SDP_SPEC_ERROR + 5), /**< SDP: protocol error Invalid Continuation State */
OI_SDP_INSUFFICIENT_RESOURCES = (OI_SDP_SPEC_ERROR + 6), /**< SDP: protocol error Insufficient Resources */
OI_SDP_ERROR = 807, /**< SDP: server returned an error code */
OI_SDP_CORRUPT_DATA_ELEMENT = 808, /**< SDP: Invalid or corrupt data element representation */
OI_SDP_SERVER_NOT_CONNECTED = 810, /**< SDP: Attempt to disconnect from an unconnected server */
OI_SDP_ACCESS_DENIED = 811, /**< SDP: Server denied access to server */
OI_SDP_ATTRIBUTES_OUT_OF_ORDER = 812, /**< SDP: Attributes in attribute list not in ascending order */
OI_SDP_DEVICE_DOES_NOT_SUPPORT_SDP = 813, /**< SDP: Tried to connect to a device that does not support SDP */
OI_SDP_NO_MORE_DATA = 815, /**< SDP: Server does not have more continuation data */
OI_SDP_REQUEST_PARAMS_TOO_LONG = 816, /**< SDP: Parameters for a request exceed the L2CAP buffer size */
OI_SDP_REQUEST_PENDING = 817, /**< SDP: Cannot make a request when another request is being processed */
OI_SDP_SERVER_CONNECT_FAILED = 819, /**< SDP: Failed attempt to connect to an SDP server */
OI_SDP_SERVER_TOO_MANY_CONNECTIONS = 821, /**< SDP: Exceeded maximum number of simultaneous server connections */
OI_SDP_NO_MATCHING_SERVICE_RECORD = 823, /**< SDP: No service record matched the UUID list */
OI_SDP_PARTIAL_RESPONSE = 824, /**< SDP: Internal use only */
OI_SDP_ILLEGAL_ARGUMENT = 825, /**< SDP: Illegal argument passed to an SDP function */
OI_SDP_ATTRIBUTE_NOT_FOUND = 826, /**< SDP: A requested attribute was not found in a service record */
OI_SDP_DATABASE_OUT_OF_RESOURCES = 827, /**< SDP: server database is out of memory */
OI_SDP_SHORT_PDU = 829, /**< SDP: Not enough bytes in the packet */
OI_SDP_TRANSACTION_ID_MISMATCH = 830, /**< SDP: Transaction Id was not as expected */
OI_SDP_UNEXPECTED_RESPONSE_PDU_ID = 831, /**< SDP: Did not expect this response PDU */
OI_SDP_REQUEST_TIMEOUT = 832, /**< SDP: Did not get a response within the timeout period */
OI_SDP_INVALID_RESPONSE_SYNTAX = 833, /**< SDP: Response is not correctly formatted */
OI_SDP_CONNECTION_TIMEOUT = 834, /**< SDP: Connection attempt timed out at a lower layer */
OI_SDP_RESPONSE_DATA_ERROR = 835, /**< SDP: Response to a service request appears to be corrupt */
OI_SDP_TOO_MANY_ATTRIBUTE_BYTES = 836, /**< SDP: Response contained more bytes than requested. */
OI_SDP_TOO_MANY_SERVICE_RECORDS = 837, /**< SDP: Response contained more service records than requested. */
OI_SDP_INVALID_CONNECTION_ID = 838, /**< SDP: Invalid connection ID in an SDP request */
OI_SDP_CANNOT_SET_ATTRIBUTE = 839, /**< SDP: Attempt to set a dynamic attribute value failed */
OI_SDP_BADLY_FORMED_ATTRIBUTE_VALUE = 840, /**< SDP: An attribute value has the wrong type or structure */
OI_SDP_NO_ATTRIBUTE_LIST_TO_REMOVE = 841, /**< SDP: Attempt to remove a non-existent attribute list from a service record */
OI_SDP_ATTRIBUTE_LIST_ALREADY_ADDED = 842, /**< SDP: An attribute list has already been added to the service record */
OI_SDP_DATA_ELEMENT_TRUNCATED = 843, /**< SDP: Data element truncated (too few bytes) */
OI_RFCOMM_WRITE_IN_PROGRESS = 901, /**< RFCOMM: Write in progress */
OI_RFCOMM_INVALID_BAUDRATE = 903, /**< RFCOMM: Invalid baudrate */
OI_RFCOMM_INVALID_DATABIT = 904, /**< RFCOMM: Invalid databit */
OI_RFCOMM_INVALID_STOPBIT = 905, /**< RFCOMM: Invalid stopbit */
OI_RFCOMM_INVALID_PARITY = 906, /**< RFCOMM: Invalid parity */
OI_RFCOMM_INVALID_PARITYTYPE = 907, /**< RFCOMM: Invalid paritytype */
OI_RFCOMM_INVALID_FLOWCONTROL = 908, /**< RFCOMM: Invalid flowcontrol */
OI_RFCOMM_SESSION_EXISTS = 909, /**< RFCOMM: Session exists */
OI_RFCOMM_INVALID_CHANNEL = 910, /**< RFCOMM: Invalid channel */
OI_RFCOMM_DLCI_EXISTS = 911, /**< RFCOMM: DLCI exists */
OI_RFCOMM_LINK_NOT_FOUND = 912, /**< RFCOMM: Link not found */
OI_RFCOMM_REMOTE_REJECT = 913, /**< RFCOMM: Remote reject */
OI_RFCOMM_TEST_IN_PROGRESS = 915, /**< RFCOMM: Test in progress */
OI_RFCOMM_SESSION_NOT_FOUND = 916, /**< RFCOMM: Session not found */
OI_RFCOMM_INVALID_PACKET = 917, /**< RFCOMM: Invalid packet */
OI_RFCOMM_FRAMESIZE_EXCEEDED = 918, /**< RFCOMM: Framesize exceeded */
OI_RFCOMM_INVALID_DLCI = 920, /**< RFCOMM: Invalid dlci */
OI_RFCOMM_SERVER_NOT_REGISTERED = 921, /**< RFCOMM: Server not registered */
OI_RFCOMM_CREDIT_ERROR = 922, /**< RFCOMM: Credit error */
OI_RFCOMM_NO_CHANNEL_NUMBER = 923, /**< RFCOMM: No channel number */
OI_RFCOMM_QUERY_IN_PROGRESS = 924, /**< RFCOMM: Query in progress */
OI_RFCOMM_SESSION_SHUTDOWN = 925, /**< RFCOMM: Session shutdown */
OI_RFCOMM_LOCAL_DEVICE_DISCONNECTED = 926, /**< RFCOMM: Local device disconnected */
OI_RFCOMM_REMOTE_DEVICE_DISCONNECTED = 927, /**< RFCOMM: Remote device disconnected */
OI_RFCOMM_OUT_OF_SERVER_CHANNELS = 928, /**< RFCOMM: Out of server channels */
OI_DISPATCH_INVALID_CB_HANDLE = 1001, /**< Dispatcher was handed an invalid callback handle */
OI_DISPATCH_TABLE_OVERFLOW = 1002, /**< Dispatcher table is full */
OI_TEST_UNKNOWN_TEST = 1101, /**< TEST: Unknown test */
OI_TEST_FAIL = 1102, /**< TEST: Fail */
OI_HCITRANS_CANNOT_CONNECT_TO_DEVICE = 1201, /**< TRANSPORT: Cannot connect to device */
OI_HCITRANS_BUFFER_TOO_SMALL = 1203, /**< TRANSPORT: Buffer too small */
OI_HCITRANS_NULL_DEVICE_HANDLE = 1204, /**< TRANSPORT: Null device handle */
OI_HCITRANS_IO_ERROR = 1205, /**< TRANSPORT: IO error */
OI_HCITRANS_DEVICE_NOT_READY = 1206, /**< TRANSPORT: Device not ready */
OI_HCITRANS_FUNCTION_NOT_SUPPORTED = 1207, /**< TRANSPORT: Function not supporteD */
OI_HCITRANS_ACCESS_DENIED = 1209, /**< TRANSPORT: win32 */
OI_HCITRANS_ACL_DATA_ERROR = 1210, /**< TRANSPORT: ACL data error */
OI_HCITRANS_SCO_DATA_ERROR = 1211, /**< TRANSPORT: SCO data error */
OI_HCITRANS_EVENT_DATA_ERROR = 1212, /**< TRANSPORT: HCI event data error */
OI_HCITRANS_INTERNAL_ERROR = 1214, /**< TRANSPORT: Internal error in the transport */
OI_HCITRANS_LINK_NOT_ACTIVE = 1215, /**< TRANSPORT: Link to the device is not currently active */
OI_HCITRANS_INITIALIZING = 1216, /**< TRANSPORT: Transport is initializing */
OI_DEVMGR_NO_CONNECTION = 1301, /**< DEVMGR: No connection */
OI_DEVMGR_HARDWARE_ERROR = 1305, /**< DEVMGR: error reported by HCI */
OI_DEVMGR_PENDING_CONNECT_LIST_FULL = 1307, /**< DEVMGR: Pending connect list full */
OI_DEVMGR_CONNECTION_LIST_FULL = 1309, /**< DEVMGR: Connection list full */
OI_DEVMGR_NO_SUCH_CONNECTION = 1310, /**< DEVMGR: No such connection */
OI_DEVMGR_INQUIRY_IN_PROGRESS = 1311, /**< DEVMGR: Inquiry in progress */
OI_DEVMGR_PERIODIC_INQUIRY_ACTIVE = 1312, /**< DEVMGR: Periodic inquiry active */
OI_DEVMGR_NO_INQUIRIES_ACTIVE = 1313, /**< DEVMGR: can not cancel/exit if not active */
OI_DEVMGR_DUPLICATE_CONNECTION = 1314, /**< DEVMGR: internal error */
OI_DEVMGR_DUPLICATE_EVENT_CALLBACK = 1316, /**< DEVMGR: attempt to register same callback twice */
OI_DEVMGR_EVENT_CALLBACK_LIST_FULL = 1317, /**< DEVMGR: can not register event callback, list is full */
OI_DEVMGR_EVENT_CALLBACK_NOT_FOUND = 1318, /**< DEVMGR: attempt to unregister callback failed */
OI_DEVMGR_BUSY = 1319, /**< DEVMGR: some operations can only execute one at a time */
OI_DEVMGR_ENUM_UNEXPECTED_INQ_COMPLETE = 1320, /**< DEVMGR: inquiry complete event in inappropriate enumeration state */
OI_DEVMGR_ENUM_UNEXPECTED_INQ_RESULT = 1321, /**< DEVMGR: inquiry result event in inappropriate enumeration state */
OI_DEVMGR_ENUM_DATABASE_FULL = 1322, /**< DEVMGR: device enumeration, database is full, couldn't add a new device */
OI_DEVMGR_ENUM_INQUIRIES_OVERLAP = 1323, /**< DEVMGR: device enumeration, periodic inquiries occurring too close together */
OI_DEVMGR_UNKNOWN_LINK_TYPE = 1324, /**< DEVMGR: HCI connect request with unkown link type */
OI_DEVMGR_PARAM_IO_ACTIVE = 1325, /**< DEVMGR: request for parameter read/write while param read/write active */
OI_DEVMGR_UNKNOWN_IAC_LAP = 1326, /**< DEVMGR: unrecognized IAC LAP */
OI_DEVMGR_SCO_ALREADY_REGISTERED = 1327, /**< DEVMGR: only one application can use SCO */
OI_DEVMGR_SCO_NOT_REGISTERED = 1328, /**< DEVMGR: SCO applications must register before using the API */
OI_DEVMGR_SCO_WITHOUT_ACL = 1329, /**< DEVMGR: Got SCO connection but there is no underlying ACL connection */
OI_DEVMGR_NO_SUPPORT = 1330, /**< DEVMGR: Request is not supported by the device */
OI_DEVMGR_WRITE_POLICY_FAILED = 1331, /**< DEVMGR: connection attempt failed - unable to write link policy */
OI_DEVMGR_NOT_IN_MASTER_MODE = 1332, /**< DEVMGR: OI_DEVMGR EndMasterMode without prior OI_DEVMGR_BeginMasterMode */
OI_DEVMGR_POLICY_VIOLATION = 1333, /**< DEVMGR: low-power request is rejected - link policy does not allow it */
OI_DEVMGR_BUSY_TIMEOUT = 1334, /**< DEVMGR: queued operation timed out while in the queue; \n
timeout configurable via @ref OI_CONFIG_DEVMGR::connectQueueTimeoutSecs "connectQueueTimeoutSecs" */
OI_DEVMGR_REENCRYPT_FAILED = 1335, /**< DEVMGR: failed to re-encrypt link after role switch */
OI_DEVMGR_ROLE_POLICY_CONFLICT = 1336, /**< DEVMGR: requested role conflicts with current policy */
OI_DEVMGR_BAD_INTERVAL = 1337, /**< DEVMGR: current linkTO outside range of requested min/max interval */
OI_DEVMGR_INVALID_SCO_HANDLE = 1338, /**< DEVMGR: HCI SCO event, invalid handle */
OI_DEVMGR_CONNECTION_OVERLAP = 1339, /**< DEVMGR: Connection failed due to race condition with remote side */
OI_DEVMGR_ORPHAN_SUBRATE_COMPLETE = 1340, /**< DEVMGR: sniff subrate complete, but no callback */
OI_DEVMGR_EIR_RESPONSE_2_LARGE = 1341, /**< DEVMGR: eir builder, response length would exceed spec max */
OI_SECMGR_NO_POLICY = 1401, /**< SECMGR: no security policy has been established */
OI_SECMGR_INTERNAL_ERROR = 1402, /**< SECMGR: internal inconsistency */
OI_SECMGR_ORPHANED_CALLBACK = 1403, /**< SECMGR: we've been called back, but CB context is gone */
OI_SECMGR_BUSY = 1404, /**< SECMGR: configure and access request cannot be concurrent */
OI_SECMGR_DEVICE_NOT_TRUSTED = 1405, /**< SECMGR: l2cap access denied - device is not trusted */
OI_SECMGR_DEVICE_ENCRYPT_FAIL = 1407, /**< SECMGR: l2cap access denied - failed to start encryption */
OI_SECMGR_DISCONNECTED_FAIL = 1408, /**< SECMGR: l2cap access denied - disconnected */
OI_SECMGR_ACCESS_PENDING = 1409, /**< SECMGR: l2cap access request is still pending */
OI_SECMGR_PIN_CODE_TOO_SHORT = 1410, /**< SECMGR: Higher-layer process gave us a pin code that is too short */
OI_SECMGR_UNKNOWN_ENCRYPT_VALUE = 1411, /**< SECMGR: got EncryptionChange event, unknown encryption enable value */
OI_SECMGR_INVALID_POLICY = 1412, /**< SECMGR: the specified security policy is not valid for security mode */
OI_SECMGR_AUTHORIZATION_FAILED = 1413, /**< SECMGR: device authorization failed */
OI_SECMGR_ENCRYPTION_FAILED = 1414, /**< SECMGR: device encryption failed */
OI_SECMGR_UNIT_KEY_UNSUPPORTED = 1415, /**< SECMGR: authentication failed due to non-support of unit keys */
OI_SECMGR_NOT_REGISTERED = 1416, /**< SECMGR: required registrations have not yet occurred */
OI_SECMGR_ILLEGAL_WRITE_SSP_MODE = 1417, /**< SECMGR: 2.1 HCI spec does not allow SSP mode to be disabled */
OI_SECMGR_INVALID_SEC_LEVEL = 1418, /**< SECMGR: security level for a service is not a valid value */
OI_SECMGR_INSUFFICIENT_LINK_KEY = 1419, /**< SECMGR: link key type is not sufficient to meet service requirements */
OI_SECMGR_INVALID_KEY_TYPE = 1420, /**< SECMGR: link key type is not a valid value */
OI_SECMGR_SSP_NOT_ENCRYPTED = 1421, /**< SECMGR: ssp required encryption on incoming link */
OI_SECMGR_ORPHAN_EVENT = 1422, /**< SECMGR: some HCI security event unrelated to current processes */
OI_SECMGR_NOT_BONDABLE = 1423, /**< SECMGR: not in bondable mode */
OI_TCS_INVALID_ELEMENT_TYPE = 1602, /**< TCS: element type is invalid */
OI_TCS_INVALID_PACKET = 1603, /**< TCS: packet is invalide */
OI_TCS_CALL_IN_PROGRESS = 1604, /**< TCS: call is in progress */
OI_TCS_NO_CALL_IN_PROGRESS = 1605, /**< TCS: no call in progress */
OI_OBEX_CONTINUE = 1701, /**< OBEX: Continue processing OBEX request */
OI_OBEX_COMMAND_ERROR = 1702, /**< OBEX: An unrecognized OBEX command opcode */
OI_OBEX_CONNECTION_TIMEOUT = 1703, /**< OBEX: Timeout waiting for a response to a request */
OI_OBEX_CONNECT_FAILED = 1704, /**< OBEX: An OBEX connection request did not succeed */
OI_OBEX_DISCONNECT_FAILED = 1705, /**< OBEX: A disconnect failed probably because the connection did not exist */
OI_OBEX_ERROR = 1706, /**< OBEX: Unspecified OBEX error */
OI_OBEX_INCOMPLETE_PACKET = 1707, /**< OBEX: Packet too short or corrupt */
OI_OBEX_LENGTH_REQUIRED = 1708, /**< OBEX: Length header required in OBEX command */
OI_OBEX_NOT_CONNECTED = 1709, /**< OBEX: No connection to OBEX server */
OI_OBEX_NO_MORE_CONNECTIONS = 1710, /**< OBEX: Reached max connections limit */
OI_OBEX_OPERATION_IN_PROGRESS = 1711, /**< OBEX: Another operation is still in progress on a connection */
OI_OBEX_PUT_RESPONSE_ERROR = 1712, /**< OBEX: An error in the response to a PUT command */
OI_OBEX_GET_RESPONSE_ERROR = 1713, /**< OBEX: An error in the response to a GET command */
OI_OBEX_REQUIRED_HEADER_NOT_FOUND = 1714, /**< OBEX: packet was missing a required header */
OI_OBEX_SERVICE_UNAVAILABLE = 1715, /**< OBEX: Unown OBEX target or required service */
OI_OBEX_TOO_MANY_HEADER_BYTES = 1716, /**< OBEX: Headers will not fit in single OBEX packet */
OI_OBEX_UNKNOWN_COMMAND = 1717, /**< OBEX: Unrecognized OBEX command */
OI_OBEX_UNSUPPORTED_VERSION = 1718, /**< OBEX: Version mismatch */
OI_OBEX_CLIENT_ABORTED_COMMAND = 1719, /**< OBEX: server received abort command */
OI_OBEX_BAD_PACKET = 1720, /**< OBEX: Any malformed OBEX packet */
OI_OBEX_BAD_REQUEST = 1721, /**< OBEX: Maps to OBEX response of the same name */
OI_OBEX_OBJECT_OVERFLOW = 1723, /**< OBEX: Too many bytes received. */
OI_OBEX_NOT_FOUND = 1724, /**< OBEX: Maps to obex response of same name */
OI_OBEX_ACCESS_DENIED = 1735, /**< OBEX: Object could not be read or written. */
OI_OBEX_VALUE_NOT_ACCEPTABLE = 1736, /**< OBEX: Value in a command was not in the acceptable range. */
OI_OBEX_PACKET_OVERFLOW = 1737, /**< OBEX: Buffer will not fit in a single OBEX packet. */
OI_OBEX_NO_SUCH_FOLDER = 1738, /**< OBEX: Error returned by a setpath operation. */
OI_OBEX_NAME_REQUIRED = 1739, /**< OBEX: Name must be non-null and non-empty. */
OI_OBEX_PASSWORD_TOO_LONG = 1740, /**< OBEX: Password exceeds implementation imposed length limit. */
OI_OBEX_PRECONDITION_FAILED = 1741, /**< OBEX: response Precondition Failed */
OI_OBEX_UNAUTHORIZED = 1742, /**< OBEX: authentication was not successful. */
OI_OBEX_NOT_IMPLEMENTED = 1743, /**< OBEX: Unimplemented feature. */
OI_OBEX_INVALID_AUTH_DIGEST = 1744, /**< OBEX: An authentication digest was bad. */
OI_OBEX_INVALID_OPERATION = 1745, /**< OBEX: Operation not allowed at this time. */
OI_OBEX_DATABASE_FULL = 1746, /**< OBEX: Sync database full. */
OI_OBEX_DATABASE_LOCKED = 1747, /**< OBEX: Sync database locked. */
OI_OBEX_INTERNAL_SERVER_ERROR = 1748, /**< OBEX: response Internal Server Error */
OI_OBEX_UNSUPPORTED_MEDIA_TYPE = 1749, /**< OBEX: response Unsupported Media Type */
OI_OBEX_PARTIAL_CONTENT = 1750, /**< OBEX: response Partial Content */
OI_OBEX_METHOD_NOT_ALLOWED = 1751, /**< OBEX: response Method Not Allowed */
OI_OBEXSRV_INCOMPLETE_GET = 1752, /**< OBEX: Indicates to a GET handler that the request phase is still in progress */
OI_OBEX_FOLDER_BROWSING_NOT_ALLOWED = 1753, /**< OBEX: Indicates that an FTP server does not allow folder browsing */
OI_OBEX_SERVER_FORCED_DISCONNECT = 1754, /**< OBEX: connection was forcibly terminated by the server */
OI_OBEX_OFS_ERROR = 1755, /**< OBEX: OPP object file system error occurred */
OI_OBEX_FILEOP_ERROR = 1756, /**< OBEX: FTP/PBAP file operation system error occurred */
OI_OBEX_USERID_TOO_LONG = 1757, /**< OBEX: User Id exceeds spec limited length limit. */
OI_HANDSFREE_EVENT_REPORTING_DISABLED = 1801, /**< HANDSFREE: Event reporting disabled */
OI_HANDSFREE_NOT_CONNECTED = 1802, /**< HANDSFREE: Not connected */
OI_HANDSFREE_SERVICE_NOT_STARTED = 1803, /**< HANDSFREE: Cannot connect to handsfree AG if handsfree service not started */
OI_HANDSFREE_AG_SERVICE_NOT_STARTED = 1804, /**< HANDSFREE: Cannot connect to handsfree device if handsfree AG service not started */
OI_HANDSFREE_COMMAND_IN_PROGRESS = 1805, /**< HANDSFREE: Cannot accept a command at this time */
OI_HANDSFREE_AUDIO_ALREADY_CONNECTED = 1806, /**< HANDSFREE: Audio is already connected */
OI_HANDSFREE_AUDIO_NOT_CONNECTED = 1807, /**< HANDSFREE: Audio is not connected */
OI_HANDSFREE_FEATURE_NOT_SUPPORTED = 1808, /**< HANDSFREE: Local or remote feature not supported for requested command */
OI_HEADSET_SERVICE_NOT_STARTED = 1901, /**< HEADSET: Cannot connect to headset AG if headset service not started */
OI_HEADSET_AG_SERVICE_NOT_STARTED = 1902, /**< HEADSET: Cannot connect to headset device if headset AG service not started */
OI_HEADSET_COMMAND_IN_PROGRESS = 1903, /**< HEADSET: Cannot accept a command at this time */
OI_BNEP_INVALID_MTU = 2001, /**< BNEP: The remote device cannot support the minimum BNEP MTU */
OI_BNEP_SETUP_TIMEOUT = 2002, /**< BNEP: The setup request timed out. */
OI_BNEP_SERVICE_NOT_REGISTERED = 2003, /**< BNEP: The requested service was not found. */
OI_BNEP_INVALID_HANDLE = 2004, /**< BNEP: The specified connection handle is not valid. */
OI_BNEP_RESPONSE_TIMEOUT = 2005, /**< BNEP: The timer for receiving a response has expired. */
OI_BNEP_INVALID_CONNECTION = 2006, /**< BNEP: Invalid connection */
OI_BNEP_INVALID_FILTER = 2007, /**< BNEP: The supplied filter was invalid. */
OI_BNEP_CONNECTION_EXISTS = 2008, /**< BNEP: An attempt was made to create a duplicate connection. */
OI_BNEP_NOT_INITIALIZED = 2009, /**< BNEP: Init has not been called */
OI_BNEP_CONNECT_BASE = 2010, /**< BNEP: connection response codes */
OI_BNEP_CONNECT_FAILED_INVALID_DEST_UUID = 2011, /**< BNEP: connect response code Invalid Dest UUID */
OI_BNEP_CONNECT_FAILED_INVALID_SOURCE_UUID = 2012, /**< BNEP: connect response code Invalid Source UUID */
OI_BNEP_CONNECT_FAILED_INVALID_UUID_SIZE = 2013, /**< BNEP: connect response code Invalid UUID Size */
OI_BNEP_CONNECT_FAILED_NOT_ALLOWED = 2014, /**< BNEP: connect response code Not Allowed */
OI_BNEP_FILTER_NET_BASE = 2020, /**< BNEP: filter response codes */
OI_BNEP_FILTER_NET_UNSUPPORTED_REQUEST = 2021, /**< BNEP: filter response code Unsupported Request */
OI_BNEP_FILTER_NET_FAILED_INVALID_PROTOCOL_TYPE = 2022, /**< BNEP: filter response code Invalid Protocol Type */
OI_BNEP_FILTER_NET_FAILED_MAX_LIMIT_REACHED = 2023, /**< BNEP: filter response code Max Limit Reached */
OI_BNEP_FILTER_NET_FAILED_SECURITY = 2024, /**< BNEP: filter response code Security */
OI_BNEP_FILTER_MULTI_BASE = 2030, /**< BNEP: multicast response codes */
OI_BNEP_FILTER_MULTI_UNSUPPORTED_REQUEST = 2031, /**< BNEP: multicast response code Unsupported Request */
OI_BNEP_FILTER_MULTI_FAILED_INVALID_ADDRESS = 2032, /**< BNEP: multicast response code Invalid Address */
OI_BNEP_FILTER_MULTI_FAILED_MAX_LIMIT_REACHED = 2033, /**< BNEP: multicast response code Max Limit Reached */
OI_BNEP_FILTER_MULTI_FAILED_SECURITY = 2034, /**< BNEP: multicast response code Security */
OI_BNEP_LOCAL_DEVICE_MUST_BE_MASTER = 2040, /**< BNEP: Device must be master of the piconet for this function */
OI_BNEP_PACKET_FILTERED_OUT = 2041, /**< BNEP: Packet did not pass current filters */
OI_NETIFC_UP_FAILED = 2101, /**< NETIFC: Could not bring up network interface */
OI_NETIFC_COULD_NOT_CREATE_THREAD = 2102, /**< NETIFC: Network interface could not create a read thread */
OI_NETIFC_INITIALIZATION_FAILED = 2103, /**< NETIFC: Error in network interface initialization */
OI_NETIFC_INTERFACE_ALREADY_UP = 2104, /**< NETIFC: Network interface is already up */
OI_NETIFC_INTERFACE_NOT_UP = 2105, /**< NETIFC: Network interface is not up */
OI_NETIFC_PACKET_TOO_BIG = 2106, /**< NETIFC: The packet is too big */
OI_PAN_ROLE_ALREADY_REGISTERED = 2201, /**< PAN: This PAN role was already registered */
OI_PAN_ROLE_NOT_ALLOWED = 2202, /**< PAN: The PAN role is not currently allowed */
OI_PAN_INCOMPATIBLE_ROLES = 2203, /**< PAN: Only certain local and remote role combinations are permitted */
OI_PAN_INVALID_ROLE = 2204, /**< PAN: Role specified is not one the defined PAN roles */
OI_PAN_CONNECTION_IN_PROGRESS = 2205, /**< PAN: A PAN connection is currently being established */
OI_PAN_USER_ALREADY_CONNECTED = 2206, /**< PAN: PAN user role only allows a single connection */
OI_PAN_DEVICE_CONNECTED = 2207, /**< PAN: A PAN connection already exists to specified device */
OI_CODEC_SBC_NO_SYNCWORD = 2301, /**< CODEC: Couldn't find an SBC SYNCWORD */
OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA = 2302, /**< CODEC: Not enough data provided to decode an SBC header */
OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA = 2303, /**< CODEC: Decoded the header, but not enough data to contain the rest of the frame */
OI_CODEC_SBC_NOT_ENOUGH_AUDIO_DATA = 2304, /**< CODEC: Not enough audio data for this frame */
OI_CODEC_SBC_CHECKSUM_MISMATCH = 2305, /**< CODEC: The frame header didn't match the checksum */
OI_CODEC_SBC_PARTIAL_DECODE = 2306, /**< CODEC: Decoding was successful, but frame data still remains. Next call will provide audio without consuming input data. */
OI_FIFOQ_QUEUE_NOT_ALIGNED = 2401, /**< FIFOQ: queue must be 32-bit aligned */
OI_FIFOQ_INVALID_Q = 2402, /**< FIFOQ: queue parameter is not a valid queue */
OI_FIFOQ_BUF_TOO_LARGE = 2403, /**< FIFOQ: attempt to queue a buffer which is too large */
OI_FIFOQ_FULL = 2404, /**< FIFOQ: enqueue() failed, queue is full */
OI_FIFOQ_NOT_ALLOCATED = 2405, /**< FIFOQ: Enqueue QBuf() failed, buffer not allocated */
OI_FIFOQ_INVALID_DATA_PTR = 2406, /**< FIFOQ: Enqueue QBuf() failed, data pointer does not match */
OI_HID_HOST_SERVICE_NOT_STARTED = 2601, /**< HID: Cannot connect to a HID device unless HID host is started */
OI_HID_DEVICE_SERVICE_NOT_STARTED = 2602, /**< HID: Cannot connect to a HID host unless HID device is started */
OI_AT_ERROR = 2701, /**< AT: ERROR response */
OI_AT_NO_CARRIER = 2702, /**< AT: NO CARRIER response */
OI_AT_BUSY = 2703, /**< AT: BUSY response */
OI_AT_NO_ANSWER = 2704, /**< AT: NO ANSWER response */
OI_AT_DELAYED = 2705, /**< AT: DELAYED response */
OI_AT_BLACKLISTED = 2706, /**< AT: BLACKLISTED response */
OI_AT_CME_ERROR = 2707, /**< AT: +CME ERROR response */
OI_AT_CMS_ERROR = 2708, /**< AT: +CMS ERROR response */
OI_BLST_CHARACTER_TIMEOUT = 2801, /**< BLST: Timeout expired while waiting for a character from the client. */
OI_BLST_ACKNOWLDGE_TIMEOUT = 2802, /**< BLST: Timeout expired while waiting for event acknowledgment from the client */
OI_BLST_TX_NOT_READY = 2803, /**< BLST: BLST is not ready to send a BHAPI message to the client. */
OI_BLST_TX_BUSY = 2804, /**< BLST: BLST transmit buffer is in use. */
OI_AVDTP_CONNECTION_SEQ_ERROR = 2901, /**< AVDTP: sequencing of signalling/media channel connections broken. */
OI_AVDTP_OUT_OF_RESOURCES = 2902, /**< AVDTP: Tried to allocate too many endpoints or signalling channels. */
OI_PBAP_REPOSITORY_NOT_SET = 3001, /**< PBAP: Phonebook repository must be set for operation to complete. */
OI_PBAP_PHONEBOOK_NOT_SET = 3002, /**< PBAP: Phonebook be set for operation to complete. */
OI_AADP_BAD_ENDPOINT = 3101, /**< AADP: Invalid local endpoint specified */
OI_AADP_BAD_STATE = 3102, /**< AADP: AADP State is not correct for this operation. */
OI_UNICODE_INVALID_SOURCE = 3200, /**< Unicode Conversion: Source string has invalid character encoding. */
OI_UNICODE_SOURCE_EXHAUSTED = 3201, /**< Unicode Conversion: Incomplete Unicode character at end of source buffer. */
OI_UNICODE_DESTINATION_EXHAUSTED = 3202, /**< Unicode Conversion: Destination buffer not large enough to hold resulting Unicode string. */
OI_AVRCP_TOO_MANY_CONNECTIONS = 3300, /**< AVRCP: Exceeded maximum number of simultaneous AVCTP connections. */
OI_AVRCP_NOT_IMPLEMENTED = 3301, /**< AVRCP: The target does not implement the command specified by the opcode and operand. */
OI_AVRCP_REJECTED = 3302, /**< AVRCP: The target cannot respond because of invalid operands in command packet. */
OI_AVRCP_INVALID_RESPONSE = 3303, /**< AVRCP: The controller received the response with invalid parameters */
OI_AVRCP_RESPONSE_PACKET_OVERFLOW = 3304, /**< AVRCP: The response message does not fir in one AVRCP packet (512 bytes), has to be fragmented. */
OI_AVRCP_RESPONSE_INVALID_PDU = 3305, /**< AVRCP: Command rejected: target received a PDU that it did not understand. */
OI_AVRCP_RESPONSE_INVALID_PARAMETER = 3306, /**< AVRCP: Command rejected: target received a PDU with a parameter ID that it did not understand. */
OI_AVRCP_RESPONSE_PARAMETER_NOT_FOUND = 3307, /**< AVRCP: Command rejected: specified parameter not found, sent if the parameter ID is understood, but content is wrong or corrupted.*/
OI_AVRCP_RESPONSE_INTERNAL_ERROR = 3308, /**< AVRCP: Command rejected: target detected other error conditions. */
OI_MAX_BM3_STATUS_VAL, /* Maximum BM3 status code */
/* Status code values reserved for BM3 SDK platform-specific implementations */
OI_STATUS_RESERVED_FOR_BCOT = 9000,
/* Status code values reserved for BHAPI products */
OI_STATUS_RESERVED_FOR_BHAPI = 9200,
/* Status code values reserved for Soundabout products */
OI_STATUS_RESERVED_FOR_SOUNDABOUT = 9400,
/*
* Status code values greater than or equal to this value are reserved for use by applications.
* However, because of differences between compilers, and differences between 16-bit and 32-bit
* platforms custom status codes should be in the 16-bit range, so status codes can range from 0
* to 65534, inclusive (65535 is reserved)
*/
OI_STATUS_RESERVED_FOR_APPS = 10000,
OI_STATUS_NONE = 0xffff /**< Special status code to indicate that there is no status. (Only to be used for special cases involving OI_SLOG_ERROR() and OI_SLOG_WARNING().) */
} OI_STATUS;
/* Remeber to update the #define below when new reserved blocks are added to
* the list above. */
#define OI_NUM_RESERVED_STATUS_BLOCKS 4 /**< Number of status code blocks reserved, including user apps */
/**
* Test for success
*/
#define OI_SUCCESS(x) ((x) == OI_OK)
/*****************************************************************************/
#ifdef __cplusplus
}
#endif
/**@}*/
#endif /* _OI_STATUS_H */

View File

@ -0,0 +1,232 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 OI_STDDEFS_H
#define OI_STDDEFS_H
/**
* @file
* This file contains BM3 standard type definitions.
*
*/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
#include "oi_cpu_dep.h"
/** \addtogroup Misc Miscellaneous APIs */
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef FALSE
#define FALSE 0 /**< This define statement sets FALSE as a preprocessor alias for 0. */
#endif
#ifndef TRUE
#define TRUE (!FALSE) /**< This define statement sets TRUE as a preprocessor alias for !FALSE. */
#endif
#ifdef HEW_TOOLCHAIN
#ifdef NULL
#undef NULL /**< Override HEW toolchain NULL definition */
#endif
#define NULL 0 /**< HEW toolchain does not allow us to compare (void*) type to function pointer */
#else
#ifndef NULL
#define NULL ((void*)0) /**< This define statement sets NULL as a preprocessor alias for (void*)0 */
#endif
#endif
/**
* @name Maximum and minimum values for basic types
* @{
*/
#define OI_INT8_MIN ((OI_INT8)0x80) /**< decimal value: -128 */
#define OI_INT8_MAX ((OI_INT8)0x7F) /**< decimal value: 127 */
#define OI_INT16_MIN ((OI_INT16)0x8000) /**< decimal value: -32768 */
#define OI_INT16_MAX ((OI_INT16)0x7FFF) /**< decimal value: 32767 */
#define OI_INT32_MIN ((OI_INT32)0x80000000) /**< decimal value: -2,147,483,648 */
#define OI_INT32_MAX ((OI_INT32)0x7FFFFFFF) /**< decimal value: 2,147,483,647 */
#define OI_UINT8_MIN ((OI_UINT8)0) /**< decimal value: 0 */
#define OI_UINT8_MAX ((OI_UINT8)0xFF) /**< decimal value: 255 */
#define OI_UINT16_MIN ((OI_UINT16)0) /**< decimal value: 0 */
#define OI_UINT16_MAX ((OI_UINT16)0xFFFF) /**< decimal value: 65535 */
#define OI_UINT32_MIN ((OI_UINT32)0) /**< decimal value: 0 */
#define OI_UINT32_MAX ((OI_UINT32)0xFFFFFFFF) /**< decimal value: 4,294,967,295 */
/**
* @}
*/
/**
* @name Integer types required by the Service Discovery Protocol
* @{
*/
/** unsigned 64-bit integer as a structure of two unsigned 32-bit integers */
typedef struct {
OI_UINT32 I1; /**< most significant 32 bits */
OI_UINT32 I2; /**< least significant 32 bits */
} OI_UINT64;
#define OI_UINT64_MIN { (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
#define OI_UINT64_MAX { (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
/** signed 64-bit integer as a structure of one unsigned 32-bit integer and one signed 32-bit integer */
typedef struct {
OI_INT32 I1; /**< most significant 32 bits as a signed integer */
OI_UINT32 I2; /**< least significant 32 bits as an unsigned integer */
} OI_INT64;
#define OI_INT64_MIN { (OI_INT32)0x80000000, (OI_UINT32)0x00000000 }
#define OI_INT64_MAX { (OI_INT32)0X7FFFFFFF, (OI_UINT32)0XFFFFFFFF }
/** unsigned 128-bit integer as a structure of four unsigned 32-bit integers */
typedef struct {
OI_UINT32 I1; /**< most significant 32 bits */
OI_UINT32 I2; /**< second-most significant 32 bits */
OI_UINT32 I3; /**< third-most significant 32 bits */
OI_UINT32 I4; /**< least significant 32 bits */
} OI_UINT128;
#define OI_UINT128_MIN { (OI_UINT32)0x00000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
#define OI_UINT128_MAX { (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
/** signed 128-bit integer as a structure of three unsigned 32-bit integers and one signed 32-bit integer */
typedef struct {
OI_INT32 I1; /**< most significant 32 bits as a signed integer */
OI_UINT32 I2; /**< second-most significant 32 bits as an unsigned integer */
OI_UINT32 I3; /**< third-most significant 32 bits as an unsigned integer */
OI_UINT32 I4; /**< least significant 32 bits as an unsigned integer */
} OI_INT128;
#define OI_INT128_MIN { (OI_UINT32)0x80000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
#define OI_INT128_MAX { (OI_UINT32)0X7FFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
/**
* @}
*/
/**
* type for ASCII character data items
*/
typedef char OI_CHAR;
/**
* type for double-byte character data items
*/
typedef OI_UINT16 OI_CHAR16;
/**
* types for UTF encoded strings.
*/
typedef OI_UINT8 OI_UTF8;
typedef OI_UINT16 OI_UTF16;
typedef OI_UINT32 OI_UTF32;
/**
* @name Single-bit operation macros
* @{
* In these macros, x is the data item for which a bit is to be tested or set and y specifies which bit
* is to be tested or set.
*/
/** This macro's value is TRUE if the bit specified by y is set in data item x. */
#define OI_BIT_TEST(x,y) ((x) & (y))
/** This macro's value is TRUE if the bit specified by y is not set in data item x. */
#define OI_BIT_CLEAR_TEST(x,y) (((x) & (y)) == 0)
/** This macro sets the bit specified by y in data item x. */
#define OI_BIT_SET(x,y) ((x) |= (y))
/** This macro clears the bit specified by y in data item x. */
#define OI_BIT_CLEAR(x,y) ((x) &= ~(y))
/** @} */
/**
* The OI_ARRAYSIZE macro is set to the number of elements in an array
* (instead of the number of bytes, which is returned by sizeof()).
*/
#ifndef OI_ARRAYSIZE
#define OI_ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
#endif
/**
* @name Preprocessor aliases for individual bit positions
* Bits are defined here only if they are not already defined.
* @{
*/
#ifndef BIT0
#define BIT0 0x00000001 /**< preprocessor alias for 32-bit value with bit 0 set, used to specify this single bit */
#define BIT1 0x00000002 /**< preprocessor alias for 32-bit value with bit 1 set, used to specify this single bit */
#define BIT2 0x00000004 /**< preprocessor alias for 32-bit value with bit 2 set, used to specify this single bit */
#define BIT3 0x00000008 /**< preprocessor alias for 32-bit value with bit 3 set, used to specify this single bit */
#define BIT4 0x00000010 /**< preprocessor alias for 32-bit value with bit 4 set, used to specify this single bit */
#define BIT5 0x00000020 /**< preprocessor alias for 32-bit value with bit 5 set, used to specify this single bit */
#define BIT6 0x00000040 /**< preprocessor alias for 32-bit value with bit 6 set, used to specify this single bit */
#define BIT7 0x00000080 /**< preprocessor alias for 32-bit value with bit 7 set, used to specify this single bit */
#define BIT8 0x00000100 /**< preprocessor alias for 32-bit value with bit 8 set, used to specify this single bit */
#define BIT9 0x00000200 /**< preprocessor alias for 32-bit value with bit 9 set, used to specify this single bit */
#define BIT10 0x00000400 /**< preprocessor alias for 32-bit value with bit 10 set, used to specify this single bit */
#define BIT11 0x00000800 /**< preprocessor alias for 32-bit value with bit 11 set, used to specify this single bit */
#define BIT12 0x00001000 /**< preprocessor alias for 32-bit value with bit 12 set, used to specify this single bit */
#define BIT13 0x00002000 /**< preprocessor alias for 32-bit value with bit 13 set, used to specify this single bit */
#define BIT14 0x00004000 /**< preprocessor alias for 32-bit value with bit 14 set, used to specify this single bit */
#define BIT15 0x00008000 /**< preprocessor alias for 32-bit value with bit 15 set, used to specify this single bit */
#define BIT16 0x00010000 /**< preprocessor alias for 32-bit value with bit 16 set, used to specify this single bit */
#define BIT17 0x00020000 /**< preprocessor alias for 32-bit value with bit 17 set, used to specify this single bit */
#define BIT18 0x00040000 /**< preprocessor alias for 32-bit value with bit 18 set, used to specify this single bit */
#define BIT19 0x00080000 /**< preprocessor alias for 32-bit value with bit 19 set, used to specify this single bit */
#define BIT20 0x00100000 /**< preprocessor alias for 32-bit value with bit 20 set, used to specify this single bit */
#define BIT21 0x00200000 /**< preprocessor alias for 32-bit value with bit 21 set, used to specify this single bit */
#define BIT22 0x00400000 /**< preprocessor alias for 32-bit value with bit 22 set, used to specify this single bit */
#define BIT23 0x00800000 /**< preprocessor alias for 32-bit value with bit 23 set, used to specify this single bit */
#define BIT24 0x01000000 /**< preprocessor alias for 32-bit value with bit 24 set, used to specify this single bit */
#define BIT25 0x02000000 /**< preprocessor alias for 32-bit value with bit 25 set, used to specify this single bit */
#define BIT26 0x04000000 /**< preprocessor alias for 32-bit value with bit 26 set, used to specify this single bit */
#define BIT27 0x08000000 /**< preprocessor alias for 32-bit value with bit 27 set, used to specify this single bit */
#define BIT28 0x10000000 /**< preprocessor alias for 32-bit value with bit 28 set, used to specify this single bit */
#define BIT29 0x20000000 /**< preprocessor alias for 32-bit value with bit 29 set, used to specify this single bit */
#define BIT30 0x40000000 /**< preprocessor alias for 32-bit value with bit 30 set, used to specify this single bit */
#define BIT31 0x80000000 /**< preprocessor alias for 32-bit value with bit 31 set, used to specify this single bit */
#endif /* BIT0 et al */
/** @} */
#ifdef __cplusplus
}
#endif
/**@}*/
/*****************************************************************************/
#endif /* OI_STDDEFS_H */

View File

@ -0,0 +1,208 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 OI_STRING_H
#define OI_STRING_H
/**
* @file
* This file contains BM3 supplied portable string.h functions
*
*/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
#include "oi_cpu_dep.h"
#include "oi_stddefs.h"
#if defined(USE_NATIVE_MEMCPY) || defined(USE_NATIVE_MALLOC)
#include <string.h>
#endif
/** \addtogroup Misc Miscellaneous APIs */
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* If we are using Native malloc(), we must also use
* native Ansi string.h functions for memory manipulation.
*/
#ifdef USE_NATIVE_MALLOC
#ifndef USE_NATIVE_MEMCPY
#define USE_NATIVE_MEMCPY
#endif
#endif
#ifdef USE_NATIVE_MEMCPY
#define OI_MemCopy(to, from, size) memcpy((to), (from), (size))
#define OI_MemSet(block, val, size) memset((block), (val), (size))
#define OI_MemZero(block, size) memset((block), 0, (size))
#define OI_MemCmp(s1, s2, n) memcmp((s1), (s2), (n))
#define OI_Strcpy(dest, src) strcpy((dest),(src))
#define OI_Strcat(dest, src) strcat((dest),(src))
#define OI_StrLen(str) strlen((str))
#define OI_Strcmp(s1, s2) strcmp((s1), (s2))
#define OI_Strncmp(s1, s2, n) strncmp((s1), (s2), (n))
#else
/*
* OI_MemCopy
*
* Copy an arbitrary number of bytes from one memory address to another.
* The underlying implementation is the ANSI memmove() or equivalant, so
* overlapping memory copies will work correctly.
*/
void OI_MemCopy(void *To, void const *From, OI_UINT32 Size);
/*
* OI_MemSet
*
* Sets all bytes in a block of memory to the same value
*/
void OI_MemSet(void *Block, OI_UINT8 Val, OI_UINT32 Size);
/*
* OI_MemZero
*
* Sets all bytes in a block of memory to zero
*/
void OI_MemZero(void *Block, OI_UINT32 Size);
/*
* OI_MemCmp
*
* Compare two blocks of memory
*
* Returns:
* 0, if s1 == s2
* < 0, if s1 < s2
* > 0, if s2 > s2
*/
OI_INT OI_MemCmp(void const *s1, void const *s2, OI_UINT32 n);
/*
* OI_Strcpy
*
* Copies the Null terminated string from pStr to pDest, and
* returns pDest.
*/
OI_CHAR *OI_Strcpy(OI_CHAR *pDest,
OI_CHAR const *pStr);
/*
* OI_Strcat
*
* Concatonates the pStr string to the end of pDest, and
* returns pDest.
*/
OI_CHAR *OI_Strcat(OI_CHAR *pDest,
OI_CHAR const *pStr) ;
/*
* OI_StrLen
*
* Calculates the number of OI_CHARs in pStr (not including
* the Null terminator) and returns the value.
*/
OI_UINT OI_StrLen(OI_CHAR const *pStr) ;
/*
* OI_Strcmp
*
* Compares two Null terminated strings
*
* Returns:
* 0, if s1 == s2
* < 0, if s1 < s2
* > 0, if s2 > s2
*/
OI_INT OI_Strcmp(OI_CHAR const *s1,
OI_CHAR const *s2);
/*
* OI_Strncmp
*
* Compares the first "len" OI_CHARs of strings s1 and s2.
*
* Returns:
* 0, if s1 == s2
* < 0, if s1 < s2
* > 0, if s2 > s2
*/
OI_INT OI_Strncmp(OI_CHAR const *s1,
OI_CHAR const *s2,
OI_UINT32 len);
#endif /* USE_NATIVE_MEMCPY */
/*
* OI_StrcmpInsensitive
*
* Compares two Null terminated strings, treating
* the Upper and Lower case of 'A' through 'Z' as
* equivilent.
*
* Returns:
* 0, if s1 == s2
* < 0, if s1 < s2
* > 0, if s2 > s2
*/
OI_INT OI_StrcmpInsensitive(OI_CHAR const *s1,
OI_CHAR const *s2);
/*
* OI_StrncmpInsensitive
*
* Compares the first "len" OI_CHARs of strings s1 and s2,
* treating the Upper and Lower case of 'A' through 'Z' as
* equivilent.
*
*
* Returns:
* 0, if s1 == s2
* < 0, if s1 < s2
* > 0, if s2 > s2
*/
OI_INT OI_StrncmpInsensitive(OI_CHAR const *s1,
OI_CHAR const *s2,
OI_UINT len);
#ifdef __cplusplus
}
#endif
/** @} */
/*****************************************************************************/
#endif /* OI_STRING_H */

View File

@ -0,0 +1,200 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
*
* 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 _OI_TIME_H
#define _OI_TIME_H
/** @file
*
* This file provides time type definitions and interfaces to time-related functions.
*
* The stack maintains a 64-bit real-time millisecond clock. The choice of
* milliseconds is for convenience, not accuracy.
*
* Timeouts are specified as tenths of seconds in a 32-bit value. Timeout values
* specified by the Bluetooth specification are usually muliple seconds, so
* accuracy to a tenth of a second is more than adequate.
*
* This file also contains macros to convert between seconds and the Link
* Manager's 1.28-second units.
*
*/
/**********************************************************************************
$Revision: #1 $
***********************************************************************************/
#include "oi_stddefs.h"
/** \addtogroup Misc Miscellaneous APIs */
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* Within the core stack timeouts are specified in intervals of tenths of seconds
*/
typedef OI_UINT16 OI_INTERVAL;
#define OI_INTERVALS_PER_SECOND 10
#define MSECS_PER_OI_INTERVAL (1000 / OI_INTERVALS_PER_SECOND)
/** maximum interval (54 min 36.7 sec) */
#define OI_MAX_INTERVAL 0x7fff
/**
* Macro to convert seconds to OI_INTERVAL time units
*/
#define OI_SECONDS(n) ((OI_INTERVAL) ((n) * OI_INTERVALS_PER_SECOND))
/**
* Macro to convert milliseconds to OI_INTERVAL time units (Rounded Up)
*/
#define OI_MSECONDS(n) ((OI_INTERVAL) ((n + MSECS_PER_OI_INTERVAL - 1) / MSECS_PER_OI_INTERVAL))
/**
* Macro to convert minutes to OI_INTERVAL time units
*/
#define OI_MINUTES(n) ((OI_INTERVAL) ((n) * OI_SECONDS(60)))
/** Convert an OI_INTERVAL to milliseconds. */
#define OI_INTERVAL_TO_MILLISECONDS(i) ((i) * MSECS_PER_OI_INTERVAL)
/**
* The stack depends on relative not absolute time. Any mapping between the
* stack's real-time clock and absolute time and date is implementation-dependent.
*/
typedef struct {
OI_INT32 seconds;
OI_INT16 mseconds;
} OI_TIME;
/**
* Convert an OI_TIME to milliseconds.
*
* @param t the time to convert
*
* @return the time in milliseconds
*/
OI_UINT32 OI_Time_ToMS(OI_TIME *t);
/**
* This function compares two time values.
*
* @param T1 first time to compare.
*
* @param T2 second time to compare.
*
* @return
@verbatim
-1 if t1 < t2
0 if t1 = t2
+1 if t1 > t2
@endverbatim
*/
OI_INT16 OI_Time_Compare(OI_TIME *T1,
OI_TIME *T2);
/**
* This function returns the interval between two times to a granularity of 0.1 seconds.
*
* @param Sooner a time value more recent that Later
*
* @param Later a time value later than Sooner
*
* @note The result is an OI_INTERVAL value so this function only works for time intervals
* that are less than about 71 minutes.
*
* @return the time interval between the two times = (Later - Sooner)
*/
OI_INTERVAL OI_Time_Interval(OI_TIME *Sooner,
OI_TIME *Later);
/**
* This function returns the interval between two times to a granularity of milliseconds.
*
* @param Sooner a time value more recent that Later
*
* @param Later a time value later than Sooner
*
* @note The result is an OI_UINT32 value so this function only works for time intervals
* that are less than about 50 days.
*
* @return the time interval between the two times = (Later - Sooner)
*/
OI_UINT32 OI_Time_IntervalMsecs(OI_TIME *Sooner,
OI_TIME *Later);
/**
* This function answers the question, Have we reached or gone past the target time?
*
* @param pTargetTime target time
*
* @return TRUE means time now is at or past target time
* FALSE means target time is still some time in the future
*/
OI_BOOL OI_Time_NowReachedTime(OI_TIME *pTargetTime);
/**
* Convert seconds to the Link Manager 1.28-second units
* Approximate by using 1.25 conversion factor.
*/
#define OI_SECONDS_TO_LM_TIME_UNITS(lmUnits) ((lmUnits)<4?(lmUnits):(lmUnits)-((lmUnits)>>2))
/**
* Convert Link Manager 1.28-second units to seconds.
* Approximate by using 1.25 conversion factor.
*/
#define OI_LM_TIME_UNITS_TO_SECONDS(lmUnits) ((lmUnits) + ((lmUnits)>>2))
#ifdef __cplusplus
}
#endif
/**@}*/
/* Include for OI_Time_Now() prototype
* Must be included at end to obtain OI_TIME typedef
*/
#include "oi_osinterface.h"
/*****************************************************************************/
#endif /* _OI_TIME_H */

Some files were not shown because too many files have changed in this diff Show More