component/bt: add bluedroid 1st version
1. add bluedroid 1st version 2. alarm adapter 3. task semaphore lock 4. other bugs resolved
This commit is contained in:
Executable
+162
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
LICENSE TERMS
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
1. source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
2. binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation;
|
||||
|
||||
3. the name of the copyright holder is not used to endorse products
|
||||
built using this software without specific written permission.
|
||||
|
||||
DISCLAIMER
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its properties, including, but not limited to, correctness
|
||||
and/or fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue 09/09/2006
|
||||
|
||||
This is an AES implementation that uses only 8-bit byte operations on the
|
||||
cipher state.
|
||||
*/
|
||||
|
||||
#ifndef AES_H
|
||||
#define AES_H
|
||||
|
||||
#if 1
|
||||
# define AES_ENC_PREKEYED /* AES encryption with a precomputed key schedule */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_DEC_PREKEYED /* AES decryption with a precomputed key schedule */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_ENC_128_OTFK /* AES encryption with 'on the fly' 128 bit keying */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_DEC_128_OTFK /* AES decryption with 'on the fly' 128 bit keying */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_ENC_256_OTFK /* AES encryption with 'on the fly' 256 bit keying */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_DEC_256_OTFK /* AES decryption with 'on the fly' 256 bit keying */
|
||||
#endif
|
||||
|
||||
#define N_ROW 4
|
||||
#define N_COL 4
|
||||
#define N_BLOCK (N_ROW * N_COL)
|
||||
#define N_MAX_ROUNDS 14
|
||||
|
||||
typedef unsigned char uint_8t;
|
||||
|
||||
typedef uint_8t return_type;
|
||||
|
||||
/* Warning: The key length for 256 bit keys overflows a byte
|
||||
(see comment below)
|
||||
*/
|
||||
|
||||
typedef uint_8t length_type;
|
||||
|
||||
typedef struct
|
||||
{ uint_8t ksch[(N_MAX_ROUNDS + 1) * N_BLOCK];
|
||||
uint_8t rnd;
|
||||
} aes_context;
|
||||
|
||||
/* The following calls are for a precomputed key schedule
|
||||
|
||||
NOTE: If the length_type used for the key length is an
|
||||
unsigned 8-bit character, a key length of 256 bits must
|
||||
be entered as a length in bytes (valid inputs are hence
|
||||
128, 192, 16, 24 and 32).
|
||||
*/
|
||||
|
||||
#if defined( AES_ENC_PREKEYED ) || defined( AES_DEC_PREKEYED )
|
||||
|
||||
return_type aes_set_key( const unsigned char key[],
|
||||
length_type keylen,
|
||||
aes_context ctx[1] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_PREKEYED )
|
||||
|
||||
return_type bluedroid_aes_encrypt( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
|
||||
return_type aes_cbc_encrypt( const unsigned char *in,
|
||||
unsigned char *out,
|
||||
int n_block,
|
||||
unsigned char iv[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
|
||||
return_type bluedroid_aes_decrypt( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
|
||||
return_type aes_cbc_decrypt( const unsigned char *in,
|
||||
unsigned char *out,
|
||||
int n_block,
|
||||
unsigned char iv[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
#endif
|
||||
|
||||
/* The following calls are for 'on the fly' keying. In this case the
|
||||
encryption and decryption keys are different.
|
||||
|
||||
The encryption subroutines take a key in an array of bytes in
|
||||
key[L] where L is 16, 24 or 32 bytes for key lengths of 128,
|
||||
192, and 256 bits respectively. They then encrypts the input
|
||||
data, in[] with this key and put the reult in the output array
|
||||
out[]. In addition, the second key array, o_key[L], is used
|
||||
to output the key that is needed by the decryption subroutine
|
||||
to reverse the encryption operation. The two key arrays can
|
||||
be the same array but in this case the original key will be
|
||||
overwritten.
|
||||
|
||||
In the same way, the decryption subroutines output keys that
|
||||
can be used to reverse their effect when used for encryption.
|
||||
|
||||
Only 128 and 256 bit keys are supported in these 'on the fly'
|
||||
modes.
|
||||
*/
|
||||
|
||||
#if defined( AES_ENC_128_OTFK )
|
||||
void bluedroid_aes_encrypt_128( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const unsigned char key[N_BLOCK],
|
||||
uint_8t o_key[N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_128_OTFK )
|
||||
void bluedroid_aes_decrypt_128( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const unsigned char key[N_BLOCK],
|
||||
unsigned char o_key[N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_256_OTFK )
|
||||
void bluedroid_aes_encrypt_256( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const unsigned char key[2 * N_BLOCK],
|
||||
unsigned char o_key[2 * N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_256_OTFK )
|
||||
void bluedroid_aes_decrypt_256( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const unsigned char key[2 * N_BLOCK],
|
||||
unsigned char o_key[2 * N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+279
@@ -0,0 +1,279 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This interface file contains the interface to the Audio Video Control
|
||||
* Transport Protocol (AVCTP).
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVCT_API_H
|
||||
#define AVCT_API_H
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* API function return value result codes. */
|
||||
#define AVCT_SUCCESS 0 /* Function successful */
|
||||
#define AVCT_NO_RESOURCES 1 /* Not enough resources */
|
||||
#define AVCT_BAD_HANDLE 2 /* Bad handle */
|
||||
#define AVCT_PID_IN_USE 3 /* PID already in use */
|
||||
#define AVCT_NOT_OPEN 4 /* Connection not open */
|
||||
|
||||
/* PSM for AVCT. */
|
||||
#define AVCT_PSM 0x0017
|
||||
#define AVCT_BR_PSM 0x001B
|
||||
|
||||
/* Protocol revision numbers */
|
||||
#define AVCT_REV_1_0 0x0100
|
||||
#define AVCT_REV_1_2 0x0102
|
||||
#define AVCT_REV_1_3 0x0103
|
||||
#define AVCT_REV_1_4 0x0104
|
||||
|
||||
/* the layer_specific settings */
|
||||
#define AVCT_DATA_CTRL 0x0001 /* for the control channel */
|
||||
#define AVCT_DATA_BROWSE 0x0002 /* for the browsing channel */
|
||||
#define AVCT_DATA_PARTIAL 0x0100 /* Only have room for a partial message */
|
||||
|
||||
#define AVCT_MIN_CONTROL_MTU 48 /* Per the AVRC spec, minimum MTU for the control channel */
|
||||
#define AVCT_MIN_BROWSE_MTU 335 /* Per the AVRC spec, minimum MTU for the browsing channel */
|
||||
|
||||
/* Message offset. The number of bytes needed by the protocol stack for the
|
||||
** protocol headers of an AVCTP message packet.
|
||||
*/
|
||||
#define AVCT_MSG_OFFSET 15
|
||||
#define AVCT_BROWSE_OFFSET 17 /* the default offset for browsing channel */
|
||||
|
||||
/* Connection role. */
|
||||
#define AVCT_INT 0 /* Initiator connection */
|
||||
#define AVCT_ACP 1 /* Acceptor connection */
|
||||
|
||||
/* Control role. */
|
||||
#define AVCT_TARGET 1 /* target */
|
||||
#define AVCT_CONTROL 2 /* controller */
|
||||
#define AVCT_PASSIVE 4 /* If conflict, allow the other side to succeed */
|
||||
|
||||
/* Command/Response indicator. */
|
||||
#define AVCT_CMD 0 /* Command message */
|
||||
#define AVCT_RSP 2 /* Response message */
|
||||
#define AVCT_REJ 3 /* Message rejected */
|
||||
|
||||
/* Control callback events. */
|
||||
#define AVCT_CONNECT_CFM_EVT 0 /* Connection confirm */
|
||||
#define AVCT_CONNECT_IND_EVT 1 /* Connection indication */
|
||||
#define AVCT_DISCONNECT_CFM_EVT 2 /* Disconnect confirm */
|
||||
#define AVCT_DISCONNECT_IND_EVT 3 /* Disconnect indication */
|
||||
#define AVCT_CONG_IND_EVT 4 /* Congestion indication */
|
||||
#define AVCT_UNCONG_IND_EVT 5 /* Uncongestion indication */
|
||||
#define AVCT_BROWSE_CONN_CFM_EVT 6 /* Browse Connection confirm */
|
||||
#define AVCT_BROWSE_CONN_IND_EVT 7 /* Browse Connection indication */
|
||||
#define AVCT_BROWSE_DISCONN_CFM_EVT 8 /* Browse Disconnect confirm */
|
||||
#define AVCT_BROWSE_DISCONN_IND_EVT 9 /* Browse Disconnect indication */
|
||||
#define AVCT_BROWSE_CONG_IND_EVT 10 /* Congestion indication */
|
||||
#define AVCT_BROWSE_UNCONG_IND_EVT 11 /* Uncongestion indication */
|
||||
|
||||
|
||||
/* General purpose failure result code for callback events. */
|
||||
#define AVCT_RESULT_FAIL 5
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
/* Control callback function. */
|
||||
typedef void (tAVCT_CTRL_CBACK)(UINT8 handle, UINT8 event, UINT16 result,
|
||||
BD_ADDR peer_addr);
|
||||
|
||||
/* Message callback function */
|
||||
/* p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE */
|
||||
typedef void (tAVCT_MSG_CBACK)(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
BT_HDR *p_pkt);
|
||||
|
||||
/* Structure used by AVCT_CreateConn. */
|
||||
typedef struct {
|
||||
tAVCT_CTRL_CBACK *p_ctrl_cback; /* Control callback */
|
||||
tAVCT_MSG_CBACK *p_msg_cback; /* Message callback */
|
||||
UINT16 pid; /* Profile ID */
|
||||
UINT8 role; /* Initiator/acceptor role */
|
||||
UINT8 control; /* Control role (Control/Target) */
|
||||
} tAVCT_CC;
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_Register
|
||||
**
|
||||
** Description This is the system level registration function for the
|
||||
** AVCTP protocol. This function initializes AVCTP and
|
||||
** prepares the protocol stack for its use. This function
|
||||
** must be called once by the system or platform using AVCTP
|
||||
** before the other functions of the API an be used.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_Deregister
|
||||
**
|
||||
** Description This function is called to deregister use AVCTP protocol.
|
||||
** It is called when AVCTP is no longer being used by any
|
||||
** application in the system. Before this function can be
|
||||
** called, all connections must be removed with
|
||||
** AVCT_RemoveConn().
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVCT_Deregister(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_CreateConn
|
||||
**
|
||||
** Description Create an AVCTP connection. There are two types of
|
||||
** connections, initiator and acceptor, as determined by
|
||||
** the p_cc->role parameter. When this function is called to
|
||||
** create an initiator connection, an AVCTP connection to
|
||||
** the peer device is initiated if one does not already exist.
|
||||
** If an acceptor connection is created, the connection waits
|
||||
** passively for an incoming AVCTP connection from a peer device.
|
||||
**
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_CreateConn(UINT8 *p_handle, tAVCT_CC *p_cc,
|
||||
BD_ADDR peer_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_RemoveConn
|
||||
**
|
||||
** Description Remove an AVCTP connection. This function is called when
|
||||
** the application is no longer using a connection. If this
|
||||
** is the last connection to a peer the L2CAP channel for AVCTP
|
||||
** will be closed.
|
||||
**
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_RemoveConn(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_CreateBrowse
|
||||
**
|
||||
** Description Create an AVCTP connection. There are two types of
|
||||
** connections, initiator and acceptor, as determined by
|
||||
** the p_cc->role parameter. When this function is called to
|
||||
** create an initiator connection, an AVCTP connection to
|
||||
** the peer device is initiated if one does not already exist.
|
||||
** If an acceptor connection is created, the connection waits
|
||||
** passively for an incoming AVCTP connection from a peer device.
|
||||
**
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_CreateBrowse(UINT8 handle, UINT8 role);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_RemoveBrowse
|
||||
**
|
||||
** Description Remove an AVCTP connection. This function is called when
|
||||
** the application is no longer using a connection. If this
|
||||
** is the last connection to a peer the L2CAP channel for AVCTP
|
||||
** will be closed.
|
||||
**
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_RemoveBrowse(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_GetBrowseMtu
|
||||
**
|
||||
** Description Get the peer_mtu for the AVCTP Browse channel of the given
|
||||
** connection.
|
||||
**
|
||||
** Returns the peer browsing channel MTU.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_GetBrowseMtu (UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_GetPeerMtu
|
||||
**
|
||||
** Description Get the peer_mtu for the AVCTP channel of the given
|
||||
** connection.
|
||||
**
|
||||
** Returns the peer MTU size.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_GetPeerMtu (UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_MsgReq
|
||||
**
|
||||
** Description Send an AVCTP message to a peer device. In calling
|
||||
** AVCT_MsgReq(), the application should keep track of the
|
||||
** congestion state of AVCTP as communicated with events
|
||||
** AVCT_CONG_IND_EVT and AVCT_UNCONG_IND_EVT. If the
|
||||
** application calls AVCT_MsgReq() when AVCTP is congested
|
||||
** the message may be discarded. The application may make its
|
||||
** first call to AVCT_MsgReq() after it receives an
|
||||
** AVCT_CONNECT_CFM_EVT or AVCT_CONNECT_IND_EVT on control channel or
|
||||
** AVCT_BROWSE_CONN_CFM_EVT or AVCT_BROWSE_CONN_IND_EVT on browsing channel.
|
||||
**
|
||||
** p_msg->layer_specific must be set to
|
||||
** AVCT_DATA_CTRL for control channel traffic;
|
||||
** AVCT_DATA_BROWSE for for browse channel traffic.
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* AVCT_API_H */
|
||||
+988
@@ -0,0 +1,988 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This interface file contains the interface to the Audio Video
|
||||
* Distribution Transport Protocol (AVDTP).
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVDT_API_H
|
||||
#define AVDT_API_H
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
#ifndef AVDT_VERSION
|
||||
#define AVDT_VERSION 0x0102
|
||||
#endif
|
||||
#define AVDT_VERSION_SYNC 0x0103
|
||||
|
||||
/* API function return value result codes. */
|
||||
#define AVDT_SUCCESS 0 /* Function successful */
|
||||
#define AVDT_BAD_PARAMS 1 /* Invalid parameters */
|
||||
#define AVDT_NO_RESOURCES 2 /* Not enough resources */
|
||||
#define AVDT_BAD_HANDLE 3 /* Bad handle */
|
||||
#define AVDT_BUSY 4 /* A procedure is already in progress */
|
||||
#define AVDT_WRITE_FAIL 5 /* Write failed */
|
||||
|
||||
/* The index to access the codec type in codec_info[]. */
|
||||
#define AVDT_CODEC_TYPE_INDEX 2
|
||||
|
||||
/* The size in bytes of a Adaptation Layer header. */
|
||||
#define AVDT_AL_HDR_SIZE 3
|
||||
|
||||
/* The size in bytes of a media packet header. */
|
||||
#define AVDT_MEDIA_HDR_SIZE 12
|
||||
|
||||
/* AVDTP 7.5.3 Adaptation Layer Fragmentation
|
||||
* original length of the un-fragmented transport packet should be specified by
|
||||
* two bytes length field of Adaptation Layer Header */
|
||||
#define AVDT_MAX_MEDIA_SIZE (0xFFFF - AVDT_MEDIA_HDR_SIZE)
|
||||
|
||||
/* The handle is used when reporting MULTI_AV specific events */
|
||||
#define AVDT_MULTI_AV_HANDLE 0xFF
|
||||
|
||||
/* The number of bytes needed by the protocol stack for the protocol headers
|
||||
** of a media packet. This is the size of the media packet header, the
|
||||
** L2CAP packet header and HCI header.
|
||||
*/
|
||||
#define AVDT_MEDIA_OFFSET 23
|
||||
|
||||
/* The marker bit is used by the application to mark significant events such
|
||||
** as frame boundaries in the data stream. This constant is used to check or
|
||||
** set the marker bit in the m_pt parameter of an AVDT_WriteReq()
|
||||
** or AVDT_DATA_IND_EVT.
|
||||
*/
|
||||
#define AVDT_MARKER_SET 0x80
|
||||
|
||||
/* SEP Type. This indicates the stream endpoint type. */
|
||||
#define AVDT_TSEP_SRC 0 /* Source SEP */
|
||||
#define AVDT_TSEP_SNK 1 /* Sink SEP */
|
||||
|
||||
/* initiator/acceptor role for adaption */
|
||||
#define AVDT_INT 0 /* initiator */
|
||||
#define AVDT_ACP 1 /* acceptor */
|
||||
|
||||
/* Media Type. This indicates the media type of the stream endpoint. */
|
||||
#define AVDT_MEDIA_AUDIO 0 /* Audio SEP */
|
||||
#define AVDT_MEDIA_VIDEO 1 /* Video SEP */
|
||||
#define AVDT_MEDIA_MULTI 2 /* Multimedia SEP */
|
||||
|
||||
/* for reporting packets */
|
||||
#define AVDT_RTCP_PT_SR 200 /* the packet type - SR (Sender Report) */
|
||||
#define AVDT_RTCP_PT_RR 201 /* the packet type - RR (Receiver Report) */
|
||||
#define AVDT_RTCP_PT_SDES 202 /* the packet type - SDES (Source Description) */
|
||||
typedef UINT8 AVDT_REPORT_TYPE;
|
||||
|
||||
#define AVDT_RTCP_SDES_CNAME 1 /* SDES item CNAME */
|
||||
#ifndef AVDT_MAX_CNAME_SIZE
|
||||
#define AVDT_MAX_CNAME_SIZE 28
|
||||
#endif
|
||||
|
||||
/* Protocol service capabilities. This indicates the protocol service
|
||||
** capabilities of a stream endpoint. This value is a mask.
|
||||
** Multiple values can be combined with a bitwise OR.
|
||||
*/
|
||||
#define AVDT_PSC_TRANS (1<<1) /* Media transport */
|
||||
#define AVDT_PSC_REPORT (1<<2) /* Reporting */
|
||||
#define AVDT_PSC_RECOV (1<<3) /* Recovery */
|
||||
#define AVDT_PSC_HDRCMP (1<<5) /* Header compression */
|
||||
#define AVDT_PSC_MUX (1<<6) /* Multiplexing */
|
||||
#define AVDT_PSC_DELAY_RPT (1<<8) /* Delay Report */
|
||||
|
||||
/* Recovery type. This indicates the recovery type. */
|
||||
#define AVDT_RECOV_RFC2733 1 /* RFC2733 recovery */
|
||||
|
||||
/* Header compression capabilities. This indicates the header compression
|
||||
** capabilities. This value is a mask. Multiple values can be combined
|
||||
** with a bitwise OR.
|
||||
*/
|
||||
#define AVDT_HDRCMP_MEDIA (1<<5) /* Available for media packets */
|
||||
#define AVDT_HDRCMP_RECOV (1<<6) /* Available for recovery packets */
|
||||
#define AVDT_HDRCMP_BACKCH (1<<7) /* Back channel supported */
|
||||
|
||||
/* Multiplexing capabilities mask. */
|
||||
#define AVDT_MUX_FRAG (1<<7) /* Allow Adaptation Layer Fragmentation */
|
||||
|
||||
/* Application service category. This indicates the application
|
||||
** service category.
|
||||
*/
|
||||
#define AVDT_ASC_PROTECT 4 /* Content protection */
|
||||
#define AVDT_ASC_CODEC 7 /* Codec */
|
||||
|
||||
/* Error codes. The following are error codes defined in the AVDTP and GAVDP
|
||||
** specifications. These error codes communicate protocol errors between
|
||||
** AVDTP and the application. More detailed descriptions of the error codes
|
||||
** and their appropriate use can be found in the AVDTP and GAVDP specifications.
|
||||
** These error codes are unrelated to the result values returned by the
|
||||
** AVDTP API functions.
|
||||
*/
|
||||
#define AVDT_ERR_HEADER 0x01 /* Bad packet header format */
|
||||
#define AVDT_ERR_LENGTH 0x11 /* Bad packet length */
|
||||
#define AVDT_ERR_SEID 0x12 /* Invalid SEID */
|
||||
#define AVDT_ERR_IN_USE 0x13 /* The SEP is in use */
|
||||
#define AVDT_ERR_NOT_IN_USE 0x14 /* The SEP is not in use */
|
||||
#define AVDT_ERR_CATEGORY 0x17 /* Bad service category */
|
||||
#define AVDT_ERR_PAYLOAD 0x18 /* Bad payload format */
|
||||
#define AVDT_ERR_NSC 0x19 /* Requested command not supported */
|
||||
#define AVDT_ERR_INVALID_CAP 0x1A /* Reconfigure attempted invalid capabilities */
|
||||
#define AVDT_ERR_RECOV_TYPE 0x22 /* Requested recovery type not defined */
|
||||
#define AVDT_ERR_MEDIA_TRANS 0x23 /* Media transport capability not correct */
|
||||
#define AVDT_ERR_RECOV_FMT 0x25 /* Recovery service capability not correct */
|
||||
#define AVDT_ERR_ROHC_FMT 0x26 /* Header compression service capability not correct */
|
||||
#define AVDT_ERR_CP_FMT 0x27 /* Content protection service capability not correct */
|
||||
#define AVDT_ERR_MUX_FMT 0x28 /* Multiplexing service capability not correct */
|
||||
#define AVDT_ERR_UNSUP_CFG 0x29 /* Configuration not supported */
|
||||
#define AVDT_ERR_BAD_STATE 0x31 /* Message cannot be processed in this state */
|
||||
#define AVDT_ERR_REPORT_FMT 0x65 /* Report service capability not correct */
|
||||
#define AVDT_ERR_SERVICE 0x80 /* Invalid service category */
|
||||
#define AVDT_ERR_RESOURCE 0x81 /* Insufficient resources */
|
||||
#define AVDT_ERR_INVALID_MCT 0xC1 /* Invalid Media Codec Type */
|
||||
#define AVDT_ERR_UNSUP_MCT 0xC2 /* Unsupported Media Codec Type */
|
||||
#define AVDT_ERR_INVALID_LEVEL 0xC3 /* Invalid Level */
|
||||
#define AVDT_ERR_UNSUP_LEVEL 0xC4 /* Unsupported Level */
|
||||
#define AVDT_ERR_INVALID_CP 0xE0 /* Invalid Content Protection Type */
|
||||
#define AVDT_ERR_INVALID_FORMAT 0xE1 /* Invalid Content Protection format */
|
||||
|
||||
/* Additional error codes. This indicates error codes used by AVDTP
|
||||
** in addition to the ones defined in the specifications.
|
||||
*/
|
||||
#define AVDT_ERR_CONNECT 0x07 /* Connection failed. */
|
||||
#define AVDT_ERR_TIMEOUT 0x08 /* Response timeout. */
|
||||
|
||||
/* Control callback events. */
|
||||
#define AVDT_DISCOVER_CFM_EVT 0 /* Discover confirm */
|
||||
#define AVDT_GETCAP_CFM_EVT 1 /* Get capabilities confirm */
|
||||
#define AVDT_OPEN_CFM_EVT 2 /* Open confirm */
|
||||
#define AVDT_OPEN_IND_EVT 3 /* Open indication */
|
||||
#define AVDT_CONFIG_IND_EVT 4 /* Configuration indication */
|
||||
#define AVDT_START_CFM_EVT 5 /* Start confirm */
|
||||
#define AVDT_START_IND_EVT 6 /* Start indication */
|
||||
#define AVDT_SUSPEND_CFM_EVT 7 /* Suspend confirm */
|
||||
#define AVDT_SUSPEND_IND_EVT 8 /* Suspend indication */
|
||||
#define AVDT_CLOSE_CFM_EVT 9 /* Close confirm */
|
||||
#define AVDT_CLOSE_IND_EVT 10 /* Close indication */
|
||||
#define AVDT_RECONFIG_CFM_EVT 11 /* Reconfiguration confirm */
|
||||
#define AVDT_RECONFIG_IND_EVT 12 /* Reconfiguration indication */
|
||||
#define AVDT_SECURITY_CFM_EVT 13 /* Security confirm */
|
||||
#define AVDT_SECURITY_IND_EVT 14 /* Security indication */
|
||||
#define AVDT_WRITE_CFM_EVT 15 /* Write confirm */
|
||||
#define AVDT_CONNECT_IND_EVT 16 /* Signaling channel connected */
|
||||
#define AVDT_DISCONNECT_IND_EVT 17 /* Signaling channel disconnected */
|
||||
#define AVDT_REPORT_CONN_EVT 18 /* Reporting channel connected */
|
||||
#define AVDT_REPORT_DISCONN_EVT 19 /* Reporting channel disconnected */
|
||||
#define AVDT_DELAY_REPORT_EVT 20 /* Delay report received */
|
||||
#define AVDT_DELAY_REPORT_CFM_EVT 21 /* Delay report response received */
|
||||
|
||||
#define AVDT_MAX_EVT (AVDT_DELAY_REPORT_CFM_EVT)
|
||||
|
||||
/* PSM for AVDT */
|
||||
#define AVDT_PSM 0x0019
|
||||
|
||||
/* Nonsupported protocol command messages. This value is used in tAVDT_CS */
|
||||
#define AVDT_NSC_SUSPEND 0x01 /* Suspend command not supported */
|
||||
#define AVDT_NSC_RECONFIG 0x02 /* Reconfigure command not supported */
|
||||
#define AVDT_NSC_SECURITY 0x04 /* Security command not supported */
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 ntp_sec; /* NTP time: seconds relative to 0h UTC on 1 January 1900 */
|
||||
UINT32 ntp_frac; /* NTP time: the fractional part */
|
||||
UINT32 rtp_time; /* timestamp in RTP header */
|
||||
UINT32 pkt_count; /* sender's packet count: since starting transmission
|
||||
* up until the time this SR packet was generated. */
|
||||
UINT32 octet_count; /* sender's octet count: same comment */
|
||||
} tAVDT_SENDER_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 frag_lost; /* fraction lost since last RR */
|
||||
UINT32 packet_lost; /* cumulative number of packets lost since the beginning */
|
||||
UINT32 seq_num_rcvd; /* extended highest sequence number received */
|
||||
UINT32 jitter; /* interarrival jitter */
|
||||
UINT32 lsr; /* last SR timestamp */
|
||||
UINT32 dlsr; /* delay since last SR */
|
||||
} tAVDT_REPORT_BLK;
|
||||
|
||||
typedef union
|
||||
{
|
||||
tAVDT_SENDER_INFO sr;
|
||||
tAVDT_REPORT_BLK rr;
|
||||
UINT8 cname[AVDT_MAX_CNAME_SIZE + 1];
|
||||
} tAVDT_REPORT_DATA;
|
||||
|
||||
/* This structure contains parameters which are set at registration. */
|
||||
typedef struct {
|
||||
UINT16 ctrl_mtu; /* L2CAP MTU of the AVDTP signaling channel */
|
||||
UINT8 ret_tout; /* AVDTP signaling retransmission timeout */
|
||||
UINT8 sig_tout; /* AVDTP signaling message timeout */
|
||||
UINT8 idle_tout; /* AVDTP idle signaling channel timeout */
|
||||
UINT8 sec_mask; /* Security mask for BTM_SetSecurityLevel() */
|
||||
} tAVDT_REG;
|
||||
|
||||
/* This structure contains the SEP information. This information is
|
||||
** transferred during the discovery procedure.
|
||||
*/
|
||||
typedef struct {
|
||||
BOOLEAN in_use; /* TRUE if stream is currently in use */
|
||||
UINT8 seid; /* Stream endpoint identifier */
|
||||
UINT8 media_type; /* Media type */
|
||||
UINT8 tsep; /* SEP type */
|
||||
} tAVDT_SEP_INFO;
|
||||
|
||||
/* This structure contains the SEP configuration. */
|
||||
typedef struct {
|
||||
UINT8 codec_info[AVDT_CODEC_SIZE]; /* Codec capabilities array */
|
||||
UINT8 protect_info[AVDT_PROTECT_SIZE]; /* Content protection capabilities */
|
||||
UINT8 num_codec; /* Number of media codec information elements */
|
||||
UINT8 num_protect; /* Number of content protection information elements */
|
||||
UINT16 psc_mask; /* Protocol service capabilities mask */
|
||||
UINT8 recov_type; /* Recovery type */
|
||||
UINT8 recov_mrws; /* Maximum recovery window size */
|
||||
UINT8 recov_mnmp; /* Recovery maximum number of media packets */
|
||||
UINT8 hdrcmp_mask; /* Header compression capabilities */
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
UINT8 mux_mask; /* Multiplexing capabilities. AVDT_MUX_XXX bits can be combined with a bitwise OR */
|
||||
UINT8 mux_tsid_media; /* TSID for media transport session */
|
||||
UINT8 mux_tcid_media; /* TCID for media transport session */
|
||||
UINT8 mux_tsid_report; /* TSID for reporting transport session */
|
||||
UINT8 mux_tcid_report; /* TCID for reporting transport session */
|
||||
UINT8 mux_tsid_recov; /* TSID for recovery transport session */
|
||||
UINT8 mux_tcid_recov; /* TCID for recovery transport session */
|
||||
#endif
|
||||
} tAVDT_CFG;
|
||||
|
||||
/* Header structure for callback event parameters. */
|
||||
typedef struct {
|
||||
UINT8 err_code; /* Zero if operation succeeded; nonzero if operation failed */
|
||||
UINT8 err_param; /* Error parameter included for some events */
|
||||
UINT8 label; /* Transaction label */
|
||||
UINT8 seid; /* For internal use only */
|
||||
UINT8 sig_id; /* For internal use only */
|
||||
UINT8 ccb_idx; /* For internal use only */
|
||||
} tAVDT_EVT_HDR;
|
||||
|
||||
/* This data structure is associated with the AVDT_GETCAP_CFM_EVT,
|
||||
** AVDT_RECONFIG_IND_EVT, and AVDT_RECONFIG_CFM_EVT.
|
||||
*/
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
tAVDT_CFG *p_cfg; /* Pointer to configuration for this SEP */
|
||||
} tAVDT_CONFIG;
|
||||
|
||||
/* This data structure is associated with the AVDT_CONFIG_IND_EVT. */
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
tAVDT_CFG *p_cfg; /* Pointer to configuration for this SEP */
|
||||
UINT8 int_seid; /* Stream endpoint ID of stream initiating the operation */
|
||||
} tAVDT_SETCONFIG;
|
||||
|
||||
/* This data structure is associated with the AVDT_OPEN_IND_EVT and AVDT_OPEN_CFM_EVT. */
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
UINT16 peer_mtu; /* Transport channel L2CAP MTU of the peer */
|
||||
UINT16 lcid; /* L2CAP LCID for media channel */
|
||||
} tAVDT_OPEN;
|
||||
|
||||
/* This data structure is associated with the AVDT_SECURITY_IND_EVT
|
||||
** and AVDT_SECURITY_CFM_EVT.
|
||||
*/
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
UINT8 *p_data; /* Pointer to security data */
|
||||
UINT16 len; /* Length in bytes of the security data */
|
||||
} tAVDT_SECURITY;
|
||||
|
||||
/* This data structure is associated with the AVDT_DISCOVER_CFM_EVT. */
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
tAVDT_SEP_INFO *p_sep_info; /* Pointer to SEP information */
|
||||
UINT8 num_seps; /* Number of stream endpoints */
|
||||
} tAVDT_DISCOVER;
|
||||
|
||||
/* This data structure is associated with the AVDT_DELAY_REPORT_EVT. */
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
UINT16 delay; /* Delay value */
|
||||
} tAVDT_DELAY_RPT;
|
||||
|
||||
/* Union of all control callback event data structures */
|
||||
typedef union {
|
||||
tAVDT_EVT_HDR hdr;
|
||||
tAVDT_DISCOVER discover_cfm;
|
||||
tAVDT_CONFIG getcap_cfm;
|
||||
tAVDT_OPEN open_cfm;
|
||||
tAVDT_OPEN open_ind;
|
||||
tAVDT_SETCONFIG config_ind;
|
||||
tAVDT_EVT_HDR start_cfm;
|
||||
tAVDT_EVT_HDR suspend_cfm;
|
||||
tAVDT_EVT_HDR close_cfm;
|
||||
tAVDT_CONFIG reconfig_cfm;
|
||||
tAVDT_CONFIG reconfig_ind;
|
||||
tAVDT_SECURITY security_cfm;
|
||||
tAVDT_SECURITY security_ind;
|
||||
tAVDT_EVT_HDR connect_ind;
|
||||
tAVDT_EVT_HDR disconnect_ind;
|
||||
tAVDT_EVT_HDR report_conn;
|
||||
tAVDT_DELAY_RPT delay_rpt_cmd;
|
||||
} tAVDT_CTRL;
|
||||
|
||||
/* This is the control callback function. This function passes control events
|
||||
** to the application. This function is required for all registered stream
|
||||
** endpoints and for the AVDT_DiscoverReq() and AVDT_GetCapReq() functions.
|
||||
**
|
||||
*/
|
||||
typedef void (tAVDT_CTRL_CBACK)(UINT8 handle, BD_ADDR bd_addr, UINT8 event,
|
||||
tAVDT_CTRL *p_data);
|
||||
|
||||
/* This is the data callback function. It is executed when AVDTP has a media
|
||||
** packet ready for the application. This function is required for SNK
|
||||
** endpoints and not applicable for SRC endpoints.
|
||||
*/
|
||||
typedef void (tAVDT_DATA_CBACK)(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
|
||||
UINT8 m_pt);
|
||||
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
/* This is the second version of the data callback function. This version uses
|
||||
** application buffer assigned by AVDT_SetMediaBuf. Caller can assign different
|
||||
** buffer during callback or can leave the current buffer for further using.
|
||||
** This callback is called when AVDTP has a media packet ready for the application.
|
||||
** This function is required for SNK endpoints and not applicable for SRC endpoints.
|
||||
*/
|
||||
typedef void (tAVDT_MEDIA_CBACK)(UINT8 handle, UINT8 *p_payload, UINT32 payload_len,
|
||||
UINT32 time_stamp, UINT16 seq_num, UINT8 m_pt, UINT8 marker);
|
||||
#endif
|
||||
|
||||
#if AVDT_REPORTING == TRUE
|
||||
/* This is the report callback function. It is executed when AVDTP has a reporting
|
||||
** packet ready for the application. This function is required for streams
|
||||
** created with AVDT_PSC_REPORT.
|
||||
*/
|
||||
typedef void (tAVDT_REPORT_CBACK)(UINT8 handle, AVDT_REPORT_TYPE type,
|
||||
tAVDT_REPORT_DATA *p_data);
|
||||
#endif
|
||||
|
||||
typedef UINT16 (tAVDT_GETCAP_REQ) (BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/* This structure contains information required when a stream is created.
|
||||
** It is passed to the AVDT_CreateStream() function.
|
||||
*/
|
||||
typedef struct {
|
||||
tAVDT_CFG cfg; /* SEP configuration */
|
||||
tAVDT_CTRL_CBACK *p_ctrl_cback; /* Control callback function */
|
||||
tAVDT_DATA_CBACK *p_data_cback; /* Data callback function */
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
tAVDT_MEDIA_CBACK *p_media_cback; /* Media callback function. It will be called only if p_data_cback is NULL */
|
||||
#endif
|
||||
#if AVDT_REPORTING == TRUE
|
||||
tAVDT_REPORT_CBACK *p_report_cback;/* Report callback function. */
|
||||
#endif
|
||||
UINT16 mtu; /* The L2CAP MTU of the transport channel */
|
||||
UINT16 flush_to; /* The L2CAP flush timeout of the transport channel */
|
||||
UINT8 tsep; /* SEP type */
|
||||
UINT8 media_type; /* Media type */
|
||||
UINT16 nsc_mask; /* Nonsupported protocol command messages */
|
||||
} tAVDT_CS;
|
||||
|
||||
/* AVDT data option mask is used in the write request */
|
||||
#define AVDT_DATA_OPT_NONE 0x00 /* No option still add RTP header */
|
||||
#define AVDT_DATA_OPT_NO_RTP (0x01 << 0) /* Skip adding RTP header */
|
||||
|
||||
typedef UINT8 tAVDT_DATA_OPT_MASK;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_Register
|
||||
**
|
||||
** Description This is the system level registration function for the
|
||||
** AVDTP protocol. This function initializes AVDTP and
|
||||
** prepares the protocol stack for its use. This function
|
||||
** must be called once by the system or platform using AVDTP
|
||||
** before the other functions of the API an be used.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_Deregister
|
||||
**
|
||||
** Description This function is called to deregister use AVDTP protocol.
|
||||
** It is called when AVDTP is no longer being used by any
|
||||
** application in the system. Before this function can be
|
||||
** called, all streams must be removed with AVDT_RemoveStream().
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_Deregister(void);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SINK_Activate
|
||||
**
|
||||
** Description Activate SEP of A2DP Sink. In Use parameter is adjusted.
|
||||
** In Use will be made false in case of activation. A2DP SRC
|
||||
** will receive in_use as false and can open A2DP Sink
|
||||
** connection
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_SINK_Activate(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SINK_Deactivate
|
||||
**
|
||||
** Description Deactivate SEP of A2DP Sink. In Use parameter is adjusted.
|
||||
** In Use will be made TRUE in case of activation. A2DP SRC
|
||||
** will receive in_use as true and will not open A2DP Sink
|
||||
** connection
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_SINK_Deactivate(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_AbortReq
|
||||
**
|
||||
** Description Trigger Abort request to pass AVDTP Abort related mandatory
|
||||
** PTS Test case.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_AbortReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_CreateStream
|
||||
**
|
||||
** Description Create a stream endpoint. After a stream endpoint is
|
||||
** created an application can initiate a connection between
|
||||
** this endpoint and an endpoint on a peer device. In
|
||||
** addition, a peer device can discover, get the capabilities,
|
||||
** and connect to this endpoint.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_RemoveStream
|
||||
**
|
||||
** Description Remove a stream endpoint. This function is called when
|
||||
** the application is no longer using a stream endpoint.
|
||||
** If this function is called when the endpoint is connected
|
||||
** the connection is closed and then the stream endpoint
|
||||
** is removed.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_RemoveStream(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_DiscoverReq
|
||||
**
|
||||
** Description This function initiates a connection to the AVDTP service
|
||||
** on the peer device, if not already present, and discovers
|
||||
** the stream endpoints on the peer device. (Please note
|
||||
** that AVDTP discovery is unrelated to SDP discovery).
|
||||
** This function can be called at any time regardless of whether
|
||||
** there is an AVDTP connection to the peer device.
|
||||
**
|
||||
** When discovery is complete, an AVDT_DISCOVER_CFM_EVT
|
||||
** is sent to the application via its callback function.
|
||||
** The application must not call AVDT_GetCapReq() or
|
||||
** AVDT_DiscoverReq() again to the same device until
|
||||
** discovery is complete.
|
||||
**
|
||||
** The memory addressed by sep_info is allocated by the
|
||||
** application. This memory is written to by AVDTP as part
|
||||
** of the discovery procedure. This memory must remain
|
||||
** accessible until the application receives the
|
||||
** AVDT_DISCOVER_CFM_EVT.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info,
|
||||
UINT8 max_seps, tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_GetCapReq
|
||||
**
|
||||
** Description This function initiates a connection to the AVDTP service
|
||||
** on the peer device, if not already present, and gets the
|
||||
** capabilities of a stream endpoint on the peer device.
|
||||
** This function can be called at any time regardless of
|
||||
** whether there is an AVDTP connection to the peer device.
|
||||
**
|
||||
** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is
|
||||
** sent to the application via its callback function. The
|
||||
** application must not call AVDT_GetCapReq() or
|
||||
** AVDT_DiscoverReq() again until the procedure is complete.
|
||||
**
|
||||
** The memory pointed to by p_cfg is allocated by the
|
||||
** application. This memory is written to by AVDTP as part
|
||||
** of the get capabilities procedure. This memory must
|
||||
** remain accessible until the application receives
|
||||
** the AVDT_GETCAP_CFM_EVT.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg,
|
||||
tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_GetAllCapReq
|
||||
**
|
||||
** Description This function initiates a connection to the AVDTP service
|
||||
** on the peer device, if not already present, and gets the
|
||||
** capabilities of a stream endpoint on the peer device.
|
||||
** This function can be called at any time regardless of
|
||||
** whether there is an AVDTP connection to the peer device.
|
||||
**
|
||||
** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is
|
||||
** sent to the application via its callback function. The
|
||||
** application must not call AVDT_GetCapReq() or
|
||||
** AVDT_DiscoverReq() again until the procedure is complete.
|
||||
**
|
||||
** The memory pointed to by p_cfg is allocated by the
|
||||
** application. This memory is written to by AVDTP as part
|
||||
** of the get capabilities procedure. This memory must
|
||||
** remain accessible until the application receives
|
||||
** the AVDT_GETCAP_CFM_EVT.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg,
|
||||
tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_DelayReport
|
||||
**
|
||||
** Description This functions sends a Delay Report to the peer device
|
||||
** that is associated with a particular SEID.
|
||||
** This function is called by SNK device.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_OpenReq
|
||||
**
|
||||
** Description This function initiates a connection to the AVDTP service
|
||||
** on the peer device, if not already present, and connects
|
||||
** to a stream endpoint on a peer device. When the connection
|
||||
** is completed, an AVDT_OPEN_CFM_EVT is sent to the
|
||||
** application via the control callback function for this handle.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid,
|
||||
tAVDT_CFG *p_cfg);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_ConfigRsp
|
||||
**
|
||||
** Description Respond to a configure request from the peer device. This
|
||||
** function must be called if the application receives an
|
||||
** AVDT_CONFIG_IND_EVT through its control callback.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code,
|
||||
UINT8 category);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_StartReq
|
||||
**
|
||||
** Description Start one or more stream endpoints. This initiates the
|
||||
** transfer of media packets for the streams. All stream
|
||||
** endpoints must previously be opened. When the streams
|
||||
** are started, an AVDT_START_CFM_EVT is sent to the
|
||||
** application via the control callback function for each stream.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SuspendReq
|
||||
**
|
||||
** Description Suspend one or more stream endpoints. This suspends the
|
||||
** transfer of media packets for the streams. All stream
|
||||
** endpoints must previously be open and started. When the
|
||||
** streams are suspended, an AVDT_SUSPEND_CFM_EVT is sent to
|
||||
** the application via the control callback function for
|
||||
** each stream.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_CloseReq
|
||||
**
|
||||
** Description Close a stream endpoint. This stops the transfer of media
|
||||
** packets and closes the transport channel associated with
|
||||
** this stream endpoint. When the stream is closed, an
|
||||
** AVDT_CLOSE_CFM_EVT is sent to the application via the
|
||||
** control callback function for this handle.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_CloseReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_ReconfigReq
|
||||
**
|
||||
** Description Reconfigure a stream endpoint. This allows the application
|
||||
** to change the codec or content protection capabilities of
|
||||
** a stream endpoint after it has been opened. This function
|
||||
** can only be called if the stream is opened but not started
|
||||
** or if the stream has been suspended. When the procedure
|
||||
** is completed, an AVDT_RECONFIG_CFM_EVT is sent to the
|
||||
** application via the control callback function for this handle.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_ReconfigRsp
|
||||
**
|
||||
** Description Respond to a reconfigure request from the peer device.
|
||||
** This function must be called if the application receives
|
||||
** an AVDT_RECONFIG_IND_EVT through its control callback.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code,
|
||||
UINT8 category);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SecurityReq
|
||||
**
|
||||
** Description Send a security request to the peer device. When the
|
||||
** security procedure is completed, an AVDT_SECURITY_CFM_EVT
|
||||
** is sent to the application via the control callback function
|
||||
** for this handle. (Please note that AVDTP security procedures
|
||||
** are unrelated to Bluetooth link level security.)
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SecurityRsp
|
||||
**
|
||||
** Description Respond to a security request from the peer device.
|
||||
** This function must be called if the application receives
|
||||
** an AVDT_SECURITY_IND_EVT through its control callback.
|
||||
** (Please note that AVDTP security procedures are unrelated
|
||||
** to Bluetooth link level security.)
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code,
|
||||
UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_WriteReq
|
||||
**
|
||||
** Description Send a media packet to the peer device. The stream must
|
||||
** be started before this function is called. Also, this
|
||||
** function can only be called if the stream is a SRC.
|
||||
**
|
||||
** When AVDTP has sent the media packet and is ready for the
|
||||
** next packet, an AVDT_WRITE_CFM_EVT is sent to the
|
||||
** application via the control callback. The application must
|
||||
** wait for the AVDT_WRITE_CFM_EVT before it makes the next
|
||||
** call to AVDT_WriteReq(). If the applications calls
|
||||
** AVDT_WriteReq() before it receives the event the packet
|
||||
** will not be sent. The application may make its first call
|
||||
** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT
|
||||
** or AVDT_START_IND_EVT.
|
||||
**
|
||||
** The application passes the packet using the BT_HDR structure.
|
||||
** This structure is described in section 2.1. The offset
|
||||
** field must be equal to or greater than AVDT_MEDIA_OFFSET.
|
||||
** This allows enough space in the buffer for the L2CAP and
|
||||
** AVDTP headers.
|
||||
**
|
||||
** The memory pointed to by p_pkt must be a GKI buffer
|
||||
** allocated by the application. This buffer will be freed
|
||||
** by the protocol stack; the application must not free
|
||||
** this buffer.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
|
||||
UINT8 m_pt);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_WriteReqOpt
|
||||
**
|
||||
** Description Send a media packet to the peer device. The stream must
|
||||
** be started before this function is called. Also, this
|
||||
** function can only be called if the stream is a SRC
|
||||
**
|
||||
** When AVDTP has sent the media packet and is ready for the
|
||||
** next packet, an AVDT_WRITE_CFM_EVT is sent to the
|
||||
** application via the control callback. The application must
|
||||
** wait for the AVDT_WRITE_CFM_EVT before it makes the next
|
||||
** call to AVDT_WriteReq(). If the applications calls
|
||||
** AVDT_WriteReq() before it receives the event the packet
|
||||
** will not be sent. The application may make its first call
|
||||
** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT
|
||||
** or AVDT_START_IND_EVT.
|
||||
**
|
||||
** The application passes the packet using the BT_HDR structure
|
||||
** This structure is described in section 2.1. The offset
|
||||
** field must be equal to or greater than AVDT_MEDIA_OFFSET
|
||||
** (if NO_RTP is specified, L2CAP_MIN_OFFSET can be used)
|
||||
** This allows enough space in the buffer for the L2CAP and
|
||||
** AVDTP headers.
|
||||
**
|
||||
** The memory pointed to by p_pkt must be a GKI buffer
|
||||
** allocated by the application. This buffer will be freed
|
||||
** by the protocol stack; the application must not free
|
||||
** this buffer.
|
||||
**
|
||||
** The opt parameter allows passing specific options like:
|
||||
** - NO_RTP : do not add the RTP header to buffer
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
|
||||
UINT8 m_pt, tAVDT_DATA_OPT_MASK opt);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_ConnectReq
|
||||
**
|
||||
** Description This function initiates an AVDTP signaling connection
|
||||
** to the peer device. When the connection is completed, an
|
||||
** AVDT_CONNECT_IND_EVT is sent to the application via its
|
||||
** control callback function. If the connection attempt fails
|
||||
** an AVDT_DISCONNECT_IND_EVT is sent. The security mask
|
||||
** parameter overrides the outgoing security mask set in
|
||||
** AVDT_Register().
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask,
|
||||
tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_DisconnectReq
|
||||
**
|
||||
** Description This function disconnect an AVDTP signaling connection
|
||||
** to the peer device. When disconnected an
|
||||
** AVDT_DISCONNECT_IND_EVT is sent to the application via its
|
||||
** control callback function.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_GetL2CapChannel
|
||||
**
|
||||
** Description Get the L2CAP CID used by the handle.
|
||||
**
|
||||
** Returns CID if successful, otherwise 0.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_GetL2CapChannel(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_GetSignalChannel
|
||||
**
|
||||
** Description Get the L2CAP CID used by the signal channel of the given handle.
|
||||
**
|
||||
** Returns CID if successful, otherwise 0.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_WriteDataReq
|
||||
**
|
||||
** Description Send a media packet to the peer device. The stream must
|
||||
** be started before this function is called. Also, this
|
||||
** function can only be called if the stream is a SRC.
|
||||
**
|
||||
** When AVDTP has sent the media packet and is ready for the
|
||||
** next packet, an AVDT_WRITE_CFM_EVT is sent to the
|
||||
** application via the control callback. The application must
|
||||
** wait for the AVDT_WRITE_CFM_EVT before it makes the next
|
||||
** call to AVDT_WriteDataReq(). If the applications calls
|
||||
** AVDT_WriteDataReq() before it receives the event the packet
|
||||
** will not be sent. The application may make its first call
|
||||
** to AVDT_WriteDataReq() after it receives an
|
||||
** AVDT_START_CFM_EVT or AVDT_START_IND_EVT.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
|
||||
UINT32 time_stamp, UINT8 m_pt, UINT8 marker);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SetMediaBuf
|
||||
**
|
||||
** Description Assigns buffer for media packets or forbids using of assigned
|
||||
** buffer if argument p_buf is NULL. This function can only
|
||||
** be called if the stream is a SNK.
|
||||
**
|
||||
** AVDTP uses this buffer to reassemble fragmented media packets.
|
||||
** When AVDTP receives a complete media packet, it calls the
|
||||
** p_media_cback assigned by AVDT_CreateStream().
|
||||
** This function can be called during callback to assign a
|
||||
** different buffer for next media packet or can leave the current
|
||||
** buffer for next packet.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SendReport
|
||||
**
|
||||
** Description
|
||||
**
|
||||
**
|
||||
**
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
|
||||
tAVDT_REPORT_DATA *p_data);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVDT_SetTraceLevel
|
||||
**
|
||||
** Description Sets the trace level for AVDT. If 0xff is passed, the
|
||||
** current trace level is returned.
|
||||
**
|
||||
** Input Parameters:
|
||||
** new_level: The level to set the AVDT tracing to:
|
||||
** 0xff-returns the current setting.
|
||||
** 0-turns off tracing.
|
||||
** >= 1-Errors.
|
||||
** >= 2-Warnings.
|
||||
** >= 3-APIs.
|
||||
** >= 4-Events.
|
||||
** >= 5-Debug.
|
||||
**
|
||||
** Returns The new trace level or current trace level if
|
||||
** the input parameter is 0xff.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT8 AVDT_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* AVDT_API_H */
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 contains constants definitions and other information from the AVDTP
|
||||
* specification. This file is intended for use internal to AVDT only.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVDT_DEFS_H
|
||||
#define AVDT_DEFS_H
|
||||
|
||||
/*****************************************************************************
|
||||
** constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* signalling packet type */
|
||||
#define AVDT_PKT_TYPE_SINGLE 0 /* single packet */
|
||||
#define AVDT_PKT_TYPE_START 1 /* start packet */
|
||||
#define AVDT_PKT_TYPE_CONT 2 /* continue packet */
|
||||
#define AVDT_PKT_TYPE_END 3 /* end packet */
|
||||
|
||||
/* signalling message type */
|
||||
#define AVDT_MSG_TYPE_CMD 0 /* command */
|
||||
#define AVDT_MSG_TYPE_GRJ 1 /* general reject */
|
||||
#define AVDT_MSG_TYPE_RSP 2 /* response accept */
|
||||
#define AVDT_MSG_TYPE_REJ 3 /* response reject */
|
||||
|
||||
/* signalling messages */
|
||||
#define AVDT_SIG_DISCOVER 1 /* discover */
|
||||
#define AVDT_SIG_GETCAP 2 /* get capabilities */
|
||||
#define AVDT_SIG_SETCONFIG 3 /* set configuration */
|
||||
#define AVDT_SIG_GETCONFIG 4 /* get configuration */
|
||||
#define AVDT_SIG_RECONFIG 5 /* reconfigure */
|
||||
#define AVDT_SIG_OPEN 6 /* open */
|
||||
#define AVDT_SIG_START 7 /* start */
|
||||
#define AVDT_SIG_CLOSE 8 /* close */
|
||||
#define AVDT_SIG_SUSPEND 9 /* suspend */
|
||||
#define AVDT_SIG_ABORT 10 /* abort */
|
||||
#define AVDT_SIG_SECURITY 11 /* security control */
|
||||
#define AVDT_SIG_GET_ALLCAP 12 /* get all capabilities */
|
||||
#define AVDT_SIG_DELAY_RPT 13 /* delay report */
|
||||
|
||||
/* maximum signal value */
|
||||
#define AVDT_SIG_MAX AVDT_SIG_DELAY_RPT
|
||||
|
||||
/* used for general reject */
|
||||
#define AVDT_SIG_NONE 0
|
||||
|
||||
/* some maximum and minimum sizes of signalling messages */
|
||||
#define AVDT_DISCOVER_REQ_MIN 1
|
||||
#define AVDT_DISCOVER_REQ_MAX 124
|
||||
|
||||
/* service category information element field values */
|
||||
#define AVDT_CAT_TRANS 1 /* Media Transport */
|
||||
#define AVDT_CAT_REPORT 2 /* Reporting */
|
||||
#define AVDT_CAT_RECOV 3 /* Recovery */
|
||||
#define AVDT_CAT_PROTECT 4 /* Content Protection */
|
||||
#define AVDT_CAT_HDRCMP 5 /* Header Compression */
|
||||
#define AVDT_CAT_MUX 6 /* Multiplexing */
|
||||
#define AVDT_CAT_CODEC 7 /* Media Codec */
|
||||
#define AVDT_CAT_DELAY_RPT 8 /* Delay Reporting */
|
||||
#define AVDT_CAT_MAX_CUR AVDT_CAT_DELAY_RPT
|
||||
|
||||
/* min/max lengths of service category information elements */
|
||||
#define AVDT_LEN_TRANS_MIN 0
|
||||
#define AVDT_LEN_REPORT_MIN 0
|
||||
#define AVDT_LEN_RECOV_MIN 3
|
||||
#define AVDT_LEN_PROTECT_MIN 2
|
||||
#define AVDT_LEN_HDRCMP_MIN 1
|
||||
#define AVDT_LEN_MUX_MIN 3
|
||||
#define AVDT_LEN_CODEC_MIN 2
|
||||
#define AVDT_LEN_DELAY_RPT_MIN 0
|
||||
|
||||
#define AVDT_LEN_TRANS_MAX 0
|
||||
#define AVDT_LEN_REPORT_MAX 0
|
||||
#define AVDT_LEN_RECOV_MAX 3
|
||||
#define AVDT_LEN_PROTECT_MAX 255
|
||||
#define AVDT_LEN_HDRCMP_MAX 1
|
||||
#define AVDT_LEN_MUX_MAX 7
|
||||
#define AVDT_LEN_CODEC_MAX 255
|
||||
#define AVDT_LEN_DELAY_RPT_MAX 0
|
||||
|
||||
/* minimum possible size of configuration or capabilities data */
|
||||
#define AVDT_LEN_CFG_MIN 2
|
||||
|
||||
/* minimum and maximum lengths for different message types */
|
||||
#define AVDT_LEN_SINGLE 1
|
||||
#define AVDT_LEN_SETCONFIG_MIN 2
|
||||
#define AVDT_LEN_RECONFIG_MIN 1
|
||||
#define AVDT_LEN_MULTI_MIN 1
|
||||
#define AVDT_LEN_SECURITY_MIN 1
|
||||
#define AVDT_LEN_DELAY_RPT 3
|
||||
|
||||
/* header lengths for different packet types */
|
||||
#define AVDT_LEN_TYPE_SINGLE 2 /* single packet */
|
||||
#define AVDT_LEN_TYPE_START 3 /* start packet */
|
||||
#define AVDT_LEN_TYPE_CONT 1 /* continue packet */
|
||||
#define AVDT_LEN_TYPE_END 1 /* end packet */
|
||||
|
||||
/* length of general reject message */
|
||||
#define AVDT_LEN_GEN_REJ 2
|
||||
|
||||
/* recovery service capabilities information elements */
|
||||
#define AVDT_RECOV_MRWS_MIN 0x01 /* min value for maximum recovery window */
|
||||
#define AVDT_RECOV_MRWS_MAX 0x18 /* max value for maximum recovery window */
|
||||
#define AVDT_RECOV_MNMP_MIN 0x01 /* min value for maximum number of media packets */
|
||||
#define AVDT_RECOV_MNMP_MAX 0x18 /* max value for maximum number of media packets */
|
||||
|
||||
/* SEID value range */
|
||||
#define AVDT_SEID_MIN 0x01
|
||||
#define AVDT_SEID_MAX 0x3E
|
||||
|
||||
/* first byte of media packet header */
|
||||
#define AVDT_MEDIA_OCTET1 0x80
|
||||
|
||||
/* for adaptation layer header */
|
||||
#define AVDT_ALH_LCODE_MASK 0x03 /* coding of length field */
|
||||
#define AVDT_ALH_LCODE_NONE 0x00 /* No length field present. Take length from l2cap */
|
||||
#define AVDT_ALH_LCODE_16BIT 0x01 /* 16bit length field */
|
||||
#define AVDT_ALH_LCODE_9BITM0 0x02 /* 9 bit length field, MSB = 0, 8 LSBs in 1 octet following */
|
||||
#define AVDT_ALH_LCODE_9BITM1 0x03 /* 9 bit length field, MSB = 1, 8 LSBs in 1 octet following */
|
||||
|
||||
#define AVDT_ALH_FRAG_MASK 0x04 /* set this for continuation packet */
|
||||
|
||||
/*****************************************************************************
|
||||
** message parsing and building macros
|
||||
*****************************************************************************/
|
||||
|
||||
#define AVDT_MSG_PRS_HDR(p, lbl, pkt, msg) \
|
||||
lbl = *(p) >> 4; \
|
||||
pkt = (*(p) >> 2) & 0x03; \
|
||||
msg = *(p)++ & 0x03;
|
||||
|
||||
#define AVDT_MSG_PRS_DISC(p, seid, in_use, type, tsep) \
|
||||
seid = *(p) >> 2; \
|
||||
in_use = (*(p)++ >> 1) & 0x01; \
|
||||
type = *(p) >> 4; \
|
||||
tsep = (*(p)++ >> 3) & 0x01;
|
||||
|
||||
#define AVDT_MSG_PRS_SIG(p, sig) \
|
||||
sig = *(p)++ & 0x3F;
|
||||
|
||||
#define AVDT_MSG_PRS_SEID(p, seid) \
|
||||
seid = *(p)++ >> 2;
|
||||
|
||||
#define AVDT_MSG_PRS_PKT_TYPE(p, pkt) \
|
||||
pkt = (*(p) >> 2) & 0x03;
|
||||
|
||||
#define AVDT_MSG_PRS_OCTET1(p, o_v, o_p, o_x, o_cc) \
|
||||
o_v = *(p) >> 6; \
|
||||
o_p = (*(p) >> 5) & 0x01; \
|
||||
o_x = (*(p) >> 4) & 0x01; \
|
||||
o_cc = *(p)++ & 0x0F;
|
||||
|
||||
#define AVDT_MSG_PRS_RPT_OCTET1(p, o_v, o_p, o_cc) \
|
||||
o_v = *(p) >> 6; \
|
||||
o_p = (*(p) >> 5) & 0x01; \
|
||||
o_cc = *(p)++ & 0x1F;
|
||||
|
||||
#define AVDT_MSG_PRS_M_PT(p, m_pt, marker) \
|
||||
marker = *(p) >> 7; \
|
||||
m_pt = *(p)++ & 0x7F;
|
||||
|
||||
#define AVDT_MSG_BLD_HDR(p, lbl, pkt, msg) \
|
||||
*(p)++ = (UINT8) ((lbl) << 4) | ((pkt) << 2) | (msg);
|
||||
|
||||
#define AVDT_MSG_BLD_DISC(p, seid, in_use, type, tsep) \
|
||||
*(p)++ = (UINT8) (((seid) << 2) | ((in_use) << 1)); \
|
||||
*(p)++ = (UINT8) (((type) << 4) | ((tsep) << 3));
|
||||
|
||||
#define AVDT_MSG_BLD_SIG(p, sig) \
|
||||
*(p)++ = (UINT8) (sig);
|
||||
|
||||
#define AVDT_MSG_BLD_SEID(p, seid) \
|
||||
*(p)++ = (UINT8) ((seid) << 2);
|
||||
|
||||
#define AVDT_MSG_BLD_ERR(p, err) \
|
||||
*(p)++ = (UINT8) (err);
|
||||
|
||||
#define AVDT_MSG_BLD_PARAM(p, param) \
|
||||
*(p)++ = (UINT8) (param);
|
||||
|
||||
#define AVDT_MSG_BLD_NOSP(p, nosp) \
|
||||
*(p)++ = (UINT8) (nosp);
|
||||
|
||||
#endif /* AVDT_DEFS_H */
|
||||
|
||||
+742
@@ -0,0 +1,742 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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"
|
||||
|
||||
#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 */
|
||||
} 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 */
|
||||
} 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 /* AVDT_INT_H */
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This interface file contains the interface AVDTP conformance API. These
|
||||
* additional API functions and callback events are provided for
|
||||
* conformance testing purposes only. They are not intended to be used by
|
||||
* an application.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVDT_CAPI_H
|
||||
#define AVDT_CAPI_H
|
||||
|
||||
#include "avdt_api.h"
|
||||
|
||||
/* start AVDTC events here to distinguish from AVDT events */
|
||||
#define AVDTC_EVT_BEGIN 0x80
|
||||
|
||||
#define AVDTC_DISCOVER_IND_EVT (0 + AVDTC_EVT_BEGIN) /* Discover indication */
|
||||
#define AVDTC_GETCAP_IND_EVT (1 + AVDTC_EVT_BEGIN) /* Get capabilities indication */
|
||||
#define AVDTC_SETCONFIG_CFM_EVT (2 + AVDTC_EVT_BEGIN) /* Set configuration confirm */
|
||||
#define AVDTC_GETCONFIG_IND_EVT (3 + AVDTC_EVT_BEGIN) /* Get configuration indication */
|
||||
#define AVDTC_GETCONFIG_CFM_EVT (4 + AVDTC_EVT_BEGIN) /* Get configuration confirm */
|
||||
#define AVDTC_OPEN_IND_EVT (5 + AVDTC_EVT_BEGIN) /* Open indication */
|
||||
#define AVDTC_START_IND_EVT (6 + AVDTC_EVT_BEGIN) /* Start indication */
|
||||
#define AVDTC_CLOSE_IND_EVT (7 + AVDTC_EVT_BEGIN) /* Close indication */
|
||||
#define AVDTC_SUSPEND_IND_EVT (8 + AVDTC_EVT_BEGIN) /* Suspend indication */
|
||||
#define AVDTC_ABORT_IND_EVT (9 + AVDTC_EVT_BEGIN) /* Abort indication */
|
||||
#define AVDTC_ABORT_CFM_EVT (10 + AVDTC_EVT_BEGIN) /* Abort confirm */
|
||||
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
UINT8 seid_list[AVDT_NUM_SEPS]; /* Array of SEID values */
|
||||
UINT8 num_seps; /* Number of values in array */
|
||||
} tAVDT_MULTI;
|
||||
|
||||
/* Union of all control callback event data structures */
|
||||
typedef union {
|
||||
tAVDT_EVT_HDR hdr;
|
||||
tAVDT_CONFIG getconfig_cfm;
|
||||
tAVDT_MULTI start_ind;
|
||||
tAVDT_MULTI suspend_ind;
|
||||
} tAVDTC_CTRL;
|
||||
|
||||
typedef void tAVDTC_CTRL_CBACK(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDTC_CTRL *p_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_Init
|
||||
**
|
||||
** Description This function is called to begin using the conformance API.
|
||||
** It must be called after AVDT_Register() and before any
|
||||
** other API or conformance API functions are called.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_Init(tAVDTC_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_DiscoverRsp
|
||||
**
|
||||
** Description Send a discover response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_DiscoverRsp(BD_ADDR bd_addr, UINT8 label,
|
||||
tAVDT_SEP_INFO sep_info[], UINT8 num_seps);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_GetCapRsp
|
||||
**
|
||||
** Description Send a get capabilities response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_GetCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_GetAllCapRsp
|
||||
**
|
||||
** Description Send a get all capabilities response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_GetAllCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_GetConfigReq
|
||||
**
|
||||
** Description Send a get configuration request.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_GetConfigReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_GetConfigRsp
|
||||
**
|
||||
** Description Send a get configuration response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_GetConfigRsp(UINT8 handle, UINT8 label, tAVDT_CFG *p_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_OpenReq
|
||||
**
|
||||
** Description Send an open request.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_OpenReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_OpenRsp
|
||||
**
|
||||
** Description Send an open response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_OpenRsp(UINT8 handle, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_StartRsp
|
||||
**
|
||||
** Description Send a start response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_StartRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_CloseRsp
|
||||
**
|
||||
** Description Send a close response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_CloseRsp(UINT8 handle, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_SuspendRsp
|
||||
**
|
||||
** Description Send a suspend response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_SuspendRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_AbortReq
|
||||
**
|
||||
** Description Send an abort request.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_AbortReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_AbortRsp
|
||||
**
|
||||
** Description Send an abort response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_AbortRsp(UINT8 handle, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_Rej
|
||||
**
|
||||
** Description Send a reject message.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_Rej(UINT8 handle, BD_ADDR bd_addr, UINT8 cmd, UINT8 label,
|
||||
UINT8 err_code, UINT8 err_param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AVDT_CAPI_H */
|
||||
+639
@@ -0,0 +1,639 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2006-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* nterface to AVRCP Application Programming Interface
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVRC_API_H
|
||||
#define AVRC_API_H
|
||||
#include "bt_target.h"
|
||||
#include "avct_api.h"
|
||||
#include "sdp_api.h"
|
||||
#include "avrc_defs.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* API function return value result codes. */
|
||||
#define AVRC_SUCCESS AVCT_SUCCESS /* 0 Function successful */
|
||||
#define AVRC_NO_RESOURCES AVCT_NO_RESOURCES /* 1 Not enough resources */
|
||||
#define AVRC_BAD_HANDLE AVCT_BAD_HANDLE /* 2 Bad handle */
|
||||
#define AVRC_PID_IN_USE AVCT_PID_IN_USE /* 3 PID already in use */
|
||||
#define AVRC_NOT_OPEN AVCT_NOT_OPEN /* 4 Connection not open */
|
||||
#define AVRC_MSG_TOO_BIG 5 /* 5 the message length exceed the MTU of the browsing channel */
|
||||
#define AVRC_FAIL 0x10 /* 0x10 generic failure */
|
||||
#define AVRC_BAD_PARAM 0x11 /* 0x11 bad parameter */
|
||||
|
||||
/* Control role - same as AVCT_TARGET/AVCT_CONTROL */
|
||||
#define AVRC_CT_TARGET 1 /* target */
|
||||
#define AVRC_CT_CONTROL 2 /* controller */
|
||||
#define AVRC_CT_PASSIVE 4 /* If conflict, allow the other side to succeed */
|
||||
|
||||
/* Connection role */
|
||||
#define AVRC_CONN_INT AVCT_INT /* initiator */
|
||||
#define AVRC_CONN_ACP AVCT_ACP /* Acceptor */
|
||||
|
||||
|
||||
/* AVRC CTRL events */
|
||||
/* AVRC_OPEN_IND_EVT event is sent when the connection is successfully opened.
|
||||
* This eventis sent in response to an AVRC_Open(). */
|
||||
#define AVRC_OPEN_IND_EVT 0
|
||||
|
||||
/* AVRC_CLOSE_IND_EVT event is sent when a connection is closed.
|
||||
* This event can result from a call to AVRC_Close() or when the peer closes
|
||||
* the connection. It is also sent when a connection attempted through
|
||||
* AVRC_Open() fails. */
|
||||
#define AVRC_CLOSE_IND_EVT 1
|
||||
|
||||
/* AVRC_CONG_IND_EVT event indicates that AVCTP is congested and cannot send
|
||||
* any more messages. */
|
||||
#define AVRC_CONG_IND_EVT 2
|
||||
|
||||
/* AVRC_UNCONG_IND_EVT event indicates that AVCTP is uncongested and ready to
|
||||
* send messages. */
|
||||
#define AVRC_UNCONG_IND_EVT 3
|
||||
|
||||
/* AVRC_BROWSE_OPEN_IND_EVT event is sent when the browse channel is successfully opened.
|
||||
* This eventis sent in response to an AVRC_Open() or AVRC_OpenBrowse() . */
|
||||
#define AVRC_BROWSE_OPEN_IND_EVT 4
|
||||
|
||||
/* AVRC_BROWSE_CLOSE_IND_EVT event is sent when a browse channel is closed.
|
||||
* This event can result from a call to AVRC_Close(), AVRC_CloseBrowse() or when the peer closes
|
||||
* the connection. It is also sent when a connection attempted through
|
||||
* AVRC_OpenBrowse() fails. */
|
||||
#define AVRC_BROWSE_CLOSE_IND_EVT 5
|
||||
|
||||
/* AVRC_BROWSE_CONG_IND_EVT event indicates that AVCTP browse channel is congested and cannot send
|
||||
* any more messages. */
|
||||
#define AVRC_BROWSE_CONG_IND_EVT 6
|
||||
|
||||
/* AVRC_BROWSE_UNCONG_IND_EVT event indicates that AVCTP browse channel is uncongested and ready to
|
||||
* send messages. */
|
||||
#define AVRC_BROWSE_UNCONG_IND_EVT 7
|
||||
|
||||
/* AVRC_CMD_TIMEOUT_EVT event indicates timeout waiting for AVRC command response from the peer */
|
||||
#define AVRC_CMD_TIMEOUT_EVT 8
|
||||
|
||||
/* Supported categories */
|
||||
#define AVRC_SUPF_CT_CAT1 0x0001 /* Category 1 */
|
||||
#define AVRC_SUPF_CT_CAT2 0x0002 /* Category 2 */
|
||||
#define AVRC_SUPF_CT_CAT3 0x0004 /* Category 3 */
|
||||
#define AVRC_SUPF_CT_CAT4 0x0008 /* Category 4 */
|
||||
#define AVRC_SUPF_CT_BROWSE 0x0040 /* Browsing */
|
||||
|
||||
#define AVRC_SUPF_TG_CAT1 0x0001 /* Category 1 */
|
||||
#define AVRC_SUPF_TG_CAT2 0x0002 /* Category 2 */
|
||||
#define AVRC_SUPF_TG_CAT3 0x0004 /* Category 3 */
|
||||
#define AVRC_SUPF_TG_CAT4 0x0008 /* Category 4 */
|
||||
#define AVRC_SUPF_TG_APP_SETTINGS 0x0010 /* Player Application Settings */
|
||||
#define AVRC_SUPF_TG_GROUP_NAVI 0x0020 /* Group Navigation */
|
||||
#define AVRC_SUPF_TG_BROWSE 0x0040 /* Browsing */
|
||||
#define AVRC_SUPF_TG_MULTI_PLAYER 0x0080 /* Muliple Media Player */
|
||||
|
||||
#define AVRC_META_SUCCESS AVRC_SUCCESS
|
||||
#define AVRC_META_FAIL AVRC_FAIL
|
||||
#define AVRC_METADATA_CMD 0x0000
|
||||
#define AVRC_METADATA_RESP 0x0001
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** data type definitions
|
||||
*****************************************************************************/
|
||||
|
||||
/* This data type is used in AVRC_FindService() to initialize the SDP database
|
||||
* to hold the result service search. */
|
||||
typedef struct
|
||||
{
|
||||
UINT32 db_len; /* Length, in bytes, of the discovery database */
|
||||
tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */
|
||||
UINT16 num_attr;/* The number of attributes in p_attrs */
|
||||
UINT16 *p_attrs; /* The attributes filter. If NULL, AVRCP API sets the attribute filter
|
||||
* to be ATTR_ID_SERVICE_CLASS_ID_LIST, ATTR_ID_BT_PROFILE_DESC_LIST,
|
||||
* ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME and ATTR_ID_PROVIDER_NAME.
|
||||
* If not NULL, the input is taken as the filter. */
|
||||
} tAVRC_SDP_DB_PARAMS;
|
||||
|
||||
/* This callback function returns service discovery information to the
|
||||
* application after the AVRC_FindService() API function is called. The
|
||||
* implementation of this callback function must copy the p_service_name
|
||||
* and p_provider_name parameters passed to it as they are not guaranteed
|
||||
* to remain after the callback function exits. */
|
||||
typedef void (tAVRC_FIND_CBACK) (UINT16 status);
|
||||
|
||||
|
||||
/* This is the control callback function. This function passes events
|
||||
* listed in Table 20 to the application. */
|
||||
typedef void (tAVRC_CTRL_CBACK) (UINT8 handle, UINT8 event, UINT16 result,
|
||||
BD_ADDR peer_addr);
|
||||
|
||||
|
||||
/* This is the message callback function. It is executed when AVCTP has
|
||||
* a message packet ready for the application. The implementation of this
|
||||
* callback function must copy the tAVRC_MSG structure passed to it as it
|
||||
* is not guaranteed to remain after the callback function exits. */
|
||||
typedef void (tAVRC_MSG_CBACK) (UINT8 handle, UINT8 label, UINT8 opcode,
|
||||
tAVRC_MSG *p_msg);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tAVRC_CTRL_CBACK *p_ctrl_cback; /* pointer to application control callback */
|
||||
tAVRC_MSG_CBACK *p_msg_cback; /* pointer to application message callback */
|
||||
UINT32 company_id; /* the company ID */
|
||||
UINT8 conn; /* Connection role (Initiator/acceptor) */
|
||||
UINT8 control; /* Control role (Control/Target) */
|
||||
} tAVRC_CONN_CB;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** external function declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_AddRecord
|
||||
**
|
||||
** Description This function is called to build an AVRCP SDP record.
|
||||
** Prior to calling this function the application must
|
||||
** call SDP_CreateRecord() to create an SDP record.
|
||||
**
|
||||
** Input Parameters:
|
||||
** service_uuid: Indicates TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
|
||||
** or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
|
||||
**
|
||||
** p_service_name: Pointer to a null-terminated character
|
||||
** string containing the service name.
|
||||
** If service name is not used set this to NULL.
|
||||
**
|
||||
** p_provider_name: Pointer to a null-terminated character
|
||||
** string containing the provider name.
|
||||
** If provider name is not used set this to NULL.
|
||||
**
|
||||
** categories: Supported categories.
|
||||
**
|
||||
** sdp_handle: SDP handle returned by SDP_CreateRecord().
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_NO_RESOURCES if not enough resources to build the SDP record.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
|
||||
char *p_provider_name, UINT16 categories, UINT32 sdp_handle);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_FindService
|
||||
**
|
||||
** Description This function is called by the application to perform service
|
||||
** discovery and retrieve AVRCP SDP record information from a
|
||||
** peer device. Information is returned for the first service
|
||||
** record found on the server that matches the service UUID.
|
||||
** The callback function will be executed when service discovery
|
||||
** is complete. There can only be one outstanding call to
|
||||
** AVRC_FindService() at a time; the application must wait for
|
||||
** the callback before it makes another call to the function.
|
||||
** The application is responsible for allocating memory for the
|
||||
** discovery database. It is recommended that the size of the
|
||||
** discovery database be at least 300 bytes. The application
|
||||
** can deallocate the memory after the callback function has
|
||||
** executed.
|
||||
**
|
||||
** Input Parameters:
|
||||
** service_uuid: Indicates TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
|
||||
** or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
|
||||
**
|
||||
** bd_addr: BD address of the peer device.
|
||||
**
|
||||
** p_db: SDP discovery database parameters.
|
||||
**
|
||||
** p_cback: Pointer to the callback function.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_PARAMS if discovery database parameters are invalid.
|
||||
** AVRC_NO_RESOURCES if there are not enough resources to
|
||||
** perform the service search.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
|
||||
tAVRC_SDP_DB_PARAMS *p_db, tAVRC_FIND_CBACK *p_cback);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_Open
|
||||
**
|
||||
** Description This function is called to open a connection to AVCTP.
|
||||
** The connection can be either an initiator or acceptor, as
|
||||
** determined by the p_ccb->stream parameter.
|
||||
** The connection can be a target, a controller or for both role,
|
||||
** as determined by the p_ccb->control parameter.
|
||||
** By definition, a target connection is an acceptor connection
|
||||
** that waits for an incoming AVCTP connection from the peer.
|
||||
** The connection remains available to the application until
|
||||
** the application closes it by calling AVRC_Close(). The
|
||||
** application does not need to reopen the connection after an
|
||||
** AVRC_CLOSE_IND_EVT is received.
|
||||
**
|
||||
** Input Parameters:
|
||||
** p_ccb->company_id: Company Identifier.
|
||||
**
|
||||
** p_ccb->p_ctrl_cback: Pointer to control callback function.
|
||||
**
|
||||
** p_ccb->p_msg_cback: Pointer to message callback function.
|
||||
**
|
||||
** p_ccb->conn: AVCTP connection role. This is set to
|
||||
** AVCTP_INT for initiator connections and AVCTP_ACP
|
||||
** for acceptor connections.
|
||||
**
|
||||
** p_ccb->control: Control role. This is set to
|
||||
** AVRC_CT_TARGET for target connections, AVRC_CT_CONTROL
|
||||
** for control connections or (AVRC_CT_TARGET|AVRC_CT_CONTROL)
|
||||
** for connections that support both roles.
|
||||
**
|
||||
** peer_addr: BD address of peer device. This value is
|
||||
** only used for initiator connections; for acceptor
|
||||
** connections it can be set to NULL.
|
||||
**
|
||||
** Output Parameters:
|
||||
** p_handle: Pointer to handle. This parameter is only
|
||||
** valid if AVRC_SUCCESS is returned.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_NO_RESOURCES if there are not enough resources to open
|
||||
** the connection.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb,
|
||||
BD_ADDR_PTR peer_addr);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_Close
|
||||
**
|
||||
** Description Close a connection opened with AVRC_Open().
|
||||
** This function is called when the
|
||||
** application is no longer using a connection.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_Close(UINT8 handle);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_OpenBrowse
|
||||
**
|
||||
** Description This function is called to open a browsing connection to AVCTP.
|
||||
** The connection can be either an initiator or acceptor, as
|
||||
** determined by the conn_role.
|
||||
** The handle is returned by a previous call to AVRC_Open.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_NO_RESOURCES if there are not enough resources to open
|
||||
** the connection.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_OpenBrowse(UINT8 handle, UINT8 conn_role);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_CloseBrowse
|
||||
**
|
||||
** Description Close a connection opened with AVRC_OpenBrowse().
|
||||
** This function is called when the
|
||||
** application is no longer using a connection.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_CloseBrowse(UINT8 handle);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_MsgReq
|
||||
**
|
||||
** Description This function is used to send the AVRCP byte stream in p_pkt
|
||||
** down to AVCTP.
|
||||
**
|
||||
** It is expected that p_pkt->offset is at least AVCT_MSG_OFFSET
|
||||
** p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE
|
||||
** p_pkt->event is AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or AVRC_OP_BROWSING
|
||||
** The above BT_HDR settings are set by the AVRC_Bld* functions.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_UnitCmd
|
||||
**
|
||||
** Description Send a UNIT INFO command to the peer device. This
|
||||
** function can only be called for controller role connections.
|
||||
** Any response message from the peer is passed back through
|
||||
** the tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_SubCmd
|
||||
**
|
||||
** Description Send a SUBUNIT INFO command to the peer device. This
|
||||
** function can only be called for controller role connections.
|
||||
** Any response message from the peer is passed back through
|
||||
** the tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label.
|
||||
**
|
||||
** page: Specifies which part of the subunit type table
|
||||
** is requested. For AVRCP it is typically zero.
|
||||
** Value range is 0-7.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_PassCmd
|
||||
**
|
||||
** Description Send a PASS THROUGH command to the peer device. This
|
||||
** function can only be called for controller role connections.
|
||||
** Any response message from the peer is passed back through
|
||||
** the tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label.
|
||||
**
|
||||
** p_msg: Pointer to PASS THROUGH message structure.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_PassRsp
|
||||
**
|
||||
** Description Send a PASS THROUGH response to the peer device. This
|
||||
** function can only be called for target role connections.
|
||||
** This function must be called when a PASS THROUGH command
|
||||
** message is received from the peer through the
|
||||
** tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label. Must be the same value as
|
||||
** passed with the command message in the callback function.
|
||||
**
|
||||
** p_msg: Pointer to PASS THROUGH message structure.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_PassRsp(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_VendorCmd
|
||||
**
|
||||
** Description Send a VENDOR DEPENDENT command to the peer device. This
|
||||
** function can only be called for controller role connections.
|
||||
** Any response message from the peer is passed back through
|
||||
** the tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label.
|
||||
**
|
||||
** p_msg: Pointer to VENDOR DEPENDENT message structure.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_VendorRsp
|
||||
**
|
||||
** Description Send a VENDOR DEPENDENT response to the peer device. This
|
||||
** function can only be called for target role connections.
|
||||
** This function must be called when a VENDOR DEPENDENT
|
||||
** command message is received from the peer through the
|
||||
** tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label. Must be the same value as
|
||||
** passed with the command message in the callback function.
|
||||
**
|
||||
** p_msg: Pointer to VENDOR DEPENDENT message structure.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_VendorRsp(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_SetTraceLevel
|
||||
**
|
||||
** Description Sets the trace level for AVRC. If 0xff is passed, the
|
||||
** current trace level is returned.
|
||||
**
|
||||
** Input Parameters:
|
||||
** new_level: The level to set the AVRC tracing to:
|
||||
** 0xff-returns the current setting.
|
||||
** 0-turns off tracing.
|
||||
** >= 1-Errors.
|
||||
** >= 2-Warnings.
|
||||
** >= 3-APIs.
|
||||
** >= 4-Events.
|
||||
** >= 5-Debug.
|
||||
**
|
||||
** Returns The new trace level or current trace level if
|
||||
** the input parameter is 0xff.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT8 AVRC_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_Init
|
||||
**
|
||||
** Description This function is called at stack startup to allocate the
|
||||
** control block (if using dynamic memory), and initializes the
|
||||
** control block and tracing level.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVRC_Init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_ParsCommand
|
||||
**
|
||||
** Description This function is used to parse the received command.
|
||||
**
|
||||
** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
|
||||
** Otherwise, the error code defined by AVRCP 1.4
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tAVRC_STS AVRC_ParsCommand (tAVRC_MSG *p_msg, tAVRC_COMMAND *p_result,
|
||||
UINT8 *p_buf, UINT16 buf_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_ParsResponse
|
||||
**
|
||||
** Description This function is used to parse the received response.
|
||||
**
|
||||
** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
|
||||
** Otherwise, the error code defined by AVRCP 1.4
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result,
|
||||
UINT8 *p_buf, UINT16 buf_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_BldCommand
|
||||
**
|
||||
** Description This function builds the given AVRCP command to the given
|
||||
** GKI buffer
|
||||
**
|
||||
** Returns AVRC_STS_NO_ERROR, if the command is built successfully
|
||||
** Otherwise, the error code.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_BldResponse
|
||||
**
|
||||
** Description This function builds the given AVRCP response to the given
|
||||
** GKI buffer
|
||||
**
|
||||
** Returns AVRC_STS_NO_ERROR, if the response is built successfully
|
||||
** Otherwise, the error code.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt);
|
||||
|
||||
/**************************************************************************
|
||||
**
|
||||
** Function AVRC_IsValidAvcType
|
||||
**
|
||||
** Description Check if correct AVC type is specified
|
||||
**
|
||||
** Returns returns TRUE if it is valid
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_IsValidPlayerAttr
|
||||
**
|
||||
** Description Check if the given attrib value is a valid one
|
||||
**
|
||||
**
|
||||
** Returns returns TRUE if it is valid
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AVRC_API_H */
|
||||
+1417
File diff suppressed because it is too large
Load Diff
+464
@@ -0,0 +1,464 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2001-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This interface file contains the interface to the Bluetooth Network
|
||||
* Encapsilation Protocol (BNEP).
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BNEP_API_H
|
||||
#define BNEP_API_H
|
||||
|
||||
#include "l2c_api.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* Define the minimum offset needed in a GKI buffer for
|
||||
** sending BNEP packets. Note, we are currently not sending
|
||||
** extension headers, but may in the future, so allow
|
||||
** space for them
|
||||
*/
|
||||
#define BNEP_MINIMUM_OFFSET (15 + L2CAP_MIN_OFFSET)
|
||||
#define BNEP_INVALID_HANDLE 0xFFFF
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
/* Define the result codes from BNEP
|
||||
*/
|
||||
enum
|
||||
{
|
||||
BNEP_SUCCESS, /* Success */
|
||||
BNEP_CONN_DISCONNECTED, /* Connection terminated */
|
||||
BNEP_NO_RESOURCES, /* No resources */
|
||||
BNEP_MTU_EXCEDED, /* Attempt to write long data */
|
||||
BNEP_INVALID_OFFSET, /* Insufficient offset in GKI buffer */
|
||||
BNEP_CONN_FAILED, /* Connection failed */
|
||||
BNEP_CONN_FAILED_CFG, /* Connection failed cos of config */
|
||||
BNEP_CONN_FAILED_SRC_UUID, /* Connection failed wrong source UUID */
|
||||
BNEP_CONN_FAILED_DST_UUID, /* Connection failed wrong destination UUID */
|
||||
BNEP_CONN_FAILED_UUID_SIZE, /* Connection failed wrong size UUID */
|
||||
BNEP_Q_SIZE_EXCEEDED, /* Too many buffers to dest */
|
||||
BNEP_TOO_MANY_FILTERS, /* Too many local filters specified */
|
||||
BNEP_SET_FILTER_FAIL, /* Set Filter failed */
|
||||
BNEP_WRONG_HANDLE, /* Wrong handle for the connection */
|
||||
BNEP_WRONG_STATE, /* Connection is in wrong state */
|
||||
BNEP_SECURITY_FAIL, /* Failed because of security */
|
||||
BNEP_IGNORE_CMD, /* To ignore the rcvd command */
|
||||
BNEP_TX_FLOW_ON, /* tx data flow enabled */
|
||||
BNEP_TX_FLOW_OFF /* tx data flow disabled */
|
||||
|
||||
}; typedef UINT8 tBNEP_RESULT;
|
||||
|
||||
|
||||
/***************************
|
||||
** Callback Functions
|
||||
****************************/
|
||||
|
||||
/* Connection state change callback prototype. Parameters are
|
||||
** Connection handle
|
||||
** BD Address of remote
|
||||
** Connection state change result
|
||||
** BNEP_SUCCESS indicates connection is success
|
||||
** All values are used to indicate the reason for failure
|
||||
** Flag to indicate if it is just a role change
|
||||
*/
|
||||
typedef void (tBNEP_CONN_STATE_CB) (UINT16 handle,
|
||||
BD_ADDR rem_bda,
|
||||
tBNEP_RESULT result,
|
||||
BOOLEAN is_role_change);
|
||||
|
||||
|
||||
|
||||
|
||||
/* Connection indication callback prototype. Parameters are
|
||||
** BD Address of remote, remote UUID and local UUID
|
||||
** and flag to indicate role change and handle to the connection
|
||||
** When BNEP calls this function profile should
|
||||
** use BNEP_ConnectResp call to accept or reject the request
|
||||
*/
|
||||
typedef void (tBNEP_CONNECT_IND_CB) (UINT16 handle,
|
||||
BD_ADDR bd_addr,
|
||||
tBT_UUID *remote_uuid,
|
||||
tBT_UUID *local_uuid,
|
||||
BOOLEAN is_role_change);
|
||||
|
||||
|
||||
|
||||
/* Data buffer received indication callback prototype. Parameters are
|
||||
** Handle to the connection
|
||||
** Source BD/Ethernet Address
|
||||
** Dest BD/Ethernet address
|
||||
** Protocol
|
||||
** Pointer to the buffer
|
||||
** Flag to indicate whether extension headers to be forwarded are present
|
||||
*/
|
||||
typedef void (tBNEP_DATA_BUF_CB) (UINT16 handle,
|
||||
UINT8 *src,
|
||||
UINT8 *dst,
|
||||
UINT16 protocol,
|
||||
BT_HDR *p_buf,
|
||||
BOOLEAN fw_ext_present);
|
||||
|
||||
|
||||
/* Data received indication callback prototype. Parameters are
|
||||
** Handle to the connection
|
||||
** Source BD/Ethernet Address
|
||||
** Dest BD/Ethernet address
|
||||
** Protocol
|
||||
** Pointer to the beginning of the data
|
||||
** Length of data
|
||||
** Flag to indicate whether extension headers to be forwarded are present
|
||||
*/
|
||||
typedef void (tBNEP_DATA_IND_CB) (UINT16 handle,
|
||||
UINT8 *src,
|
||||
UINT8 *dst,
|
||||
UINT16 protocol,
|
||||
UINT8 *p_data,
|
||||
UINT16 len,
|
||||
BOOLEAN fw_ext_present);
|
||||
|
||||
/* Flow control callback for TX data. Parameters are
|
||||
** Handle to the connection
|
||||
** Event flow status
|
||||
*/
|
||||
typedef void (tBNEP_TX_DATA_FLOW_CB) (UINT16 handle,
|
||||
tBNEP_RESULT event);
|
||||
|
||||
/* Filters received indication callback prototype. Parameters are
|
||||
** Handle to the connection
|
||||
** TRUE if the cb is called for indication
|
||||
** Ignore this if it is indication, otherwise it is the result
|
||||
** for the filter set operation performed by the local
|
||||
** device
|
||||
** Number of protocol filters present
|
||||
** Pointer to the filters start. Filters are present in pairs
|
||||
** of start of the range and end of the range.
|
||||
** They will be present in big endian order. First
|
||||
** two bytes will be starting of the first range and
|
||||
** next two bytes will be ending of the range.
|
||||
*/
|
||||
typedef void (tBNEP_FILTER_IND_CB) (UINT16 handle,
|
||||
BOOLEAN indication,
|
||||
tBNEP_RESULT result,
|
||||
UINT16 num_filters,
|
||||
UINT8 *p_filters);
|
||||
|
||||
|
||||
|
||||
/* Multicast Filters received indication callback prototype. Parameters are
|
||||
** Handle to the connection
|
||||
** TRUE if the cb is called for indication
|
||||
** Ignore this if it is indication, otherwise it is the result
|
||||
** for the filter set operation performed by the local
|
||||
** device
|
||||
** Number of multicast filters present
|
||||
** Pointer to the filters start. Filters are present in pairs
|
||||
** of start of the range and end of the range.
|
||||
** First six bytes will be starting of the first range and
|
||||
** next six bytes will be ending of the range.
|
||||
*/
|
||||
typedef void (tBNEP_MFILTER_IND_CB) (UINT16 handle,
|
||||
BOOLEAN indication,
|
||||
tBNEP_RESULT result,
|
||||
UINT16 num_mfilters,
|
||||
UINT8 *p_mfilters);
|
||||
|
||||
/* This is the structure used by profile to register with BNEP */
|
||||
typedef struct
|
||||
{
|
||||
tBNEP_CONNECT_IND_CB *p_conn_ind_cb; /* To indicate the conn request */
|
||||
tBNEP_CONN_STATE_CB *p_conn_state_cb; /* To indicate conn state change */
|
||||
tBNEP_DATA_IND_CB *p_data_ind_cb; /* To pass the data received */
|
||||
tBNEP_DATA_BUF_CB *p_data_buf_cb; /* To pass the data buffer received */
|
||||
tBNEP_TX_DATA_FLOW_CB *p_tx_data_flow_cb; /* data flow callback */
|
||||
tBNEP_FILTER_IND_CB *p_filter_ind_cb; /* To indicate that peer set protocol filters */
|
||||
tBNEP_MFILTER_IND_CB *p_mfilter_ind_cb; /* To indicate that peer set mcast filters */
|
||||
|
||||
} tBNEP_REGISTER;
|
||||
|
||||
|
||||
|
||||
/* This is the structure used by profile to get the status of BNEP */
|
||||
typedef struct
|
||||
{
|
||||
#define BNEP_STATUS_FAILE 0
|
||||
#define BNEP_STATUS_CONNECTED 1
|
||||
UINT8 con_status;
|
||||
|
||||
UINT16 l2cap_cid;
|
||||
BD_ADDR rem_bda;
|
||||
UINT16 rem_mtu_size;
|
||||
UINT16 xmit_q_depth;
|
||||
|
||||
UINT16 sent_num_filters;
|
||||
UINT16 sent_mcast_filters;
|
||||
UINT16 rcvd_num_filters;
|
||||
UINT16 rcvd_mcast_filters;
|
||||
tBT_UUID src_uuid;
|
||||
tBT_UUID dst_uuid;
|
||||
|
||||
} tBNEP_STATUS;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_Register
|
||||
**
|
||||
** Description This function is called by the upper layer to register
|
||||
** its callbacks with BNEP
|
||||
**
|
||||
** Parameters: p_reg_info - contains all callback function pointers
|
||||
**
|
||||
**
|
||||
** Returns BNEP_SUCCESS if registered successfully
|
||||
** BNEP_FAILURE if connection state callback is missing
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT BNEP_Register (tBNEP_REGISTER *p_reg_info);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_Deregister
|
||||
**
|
||||
** Description This function is called by the upper layer to de-register
|
||||
** its callbacks.
|
||||
**
|
||||
** Parameters: void
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BNEP_Deregister (void);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_Connect
|
||||
**
|
||||
** Description This function creates a BNEP connection to a remote
|
||||
** device.
|
||||
**
|
||||
** Parameters: p_rem_addr - BD_ADDR of the peer
|
||||
** src_uuid - source uuid for the connection
|
||||
** dst_uuid - destination uuid for the connection
|
||||
** p_handle - pointer to return the handle for the connection
|
||||
**
|
||||
** Returns BNEP_SUCCESS if connection started
|
||||
** BNEP_NO_RESOURCES if no resources
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
|
||||
tBT_UUID *src_uuid,
|
||||
tBT_UUID *dst_uuid,
|
||||
UINT16 *p_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_ConnectResp
|
||||
**
|
||||
** Description This function is called in responce to connection indication
|
||||
**
|
||||
**
|
||||
** Parameters: handle - handle given in the connection indication
|
||||
** resp - responce for the connection indication
|
||||
**
|
||||
** Returns BNEP_SUCCESS if connection started
|
||||
** BNEP_WRONG_HANDLE if the connection is not found
|
||||
** BNEP_WRONG_STATE if the responce is not expected
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT BNEP_ConnectResp (UINT16 handle, tBNEP_RESULT resp);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_Disconnect
|
||||
**
|
||||
** Description This function is called to close the specified connection.
|
||||
**
|
||||
** Parameters: handle - handle of the connection
|
||||
**
|
||||
** Returns BNEP_SUCCESS if connection is disconnected
|
||||
** BNEP_WRONG_HANDLE if no connection is not found
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT BNEP_Disconnect (UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_WriteBuf
|
||||
**
|
||||
** Description This function sends data in a GKI buffer on BNEP connection
|
||||
**
|
||||
** Parameters: handle - handle of the connection to write
|
||||
** p_dest_addr - BD_ADDR/Ethernet addr of the destination
|
||||
** p_buf - pointer to address of buffer with data
|
||||
** protocol - protocol type of the packet
|
||||
** p_src_addr - (optional) BD_ADDR/ethernet address of the source
|
||||
** (should be NULL if it is local BD Addr)
|
||||
** fw_ext_present - forwarded extensions present
|
||||
**
|
||||
** Returns: BNEP_WRONG_HANDLE - if passed handle is not valid
|
||||
** BNEP_MTU_EXCEDED - If the data length is greater than MTU
|
||||
** BNEP_IGNORE_CMD - If the packet is filtered out
|
||||
** BNEP_Q_SIZE_EXCEEDED - If the Tx Q is full
|
||||
** BNEP_SUCCESS - If written successfully
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT BNEP_WriteBuf (UINT16 handle,
|
||||
UINT8 *p_dest_addr,
|
||||
BT_HDR *p_buf,
|
||||
UINT16 protocol,
|
||||
UINT8 *p_src_addr,
|
||||
BOOLEAN fw_ext_present);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_Write
|
||||
**
|
||||
** Description This function sends data over a BNEP connection
|
||||
**
|
||||
** Parameters: handle - handle of the connection to write
|
||||
** p_dest_addr - BD_ADDR/Ethernet addr of the destination
|
||||
** p_data - pointer to data start
|
||||
** protocol - protocol type of the packet
|
||||
** p_src_addr - (optional) BD_ADDR/ethernet address of the source
|
||||
** (should be NULL if it is local BD Addr)
|
||||
** fw_ext_present - forwarded extensions present
|
||||
**
|
||||
** Returns: BNEP_WRONG_HANDLE - if passed handle is not valid
|
||||
** BNEP_MTU_EXCEDED - If the data length is greater than MTU
|
||||
** BNEP_IGNORE_CMD - If the packet is filtered out
|
||||
** BNEP_Q_SIZE_EXCEEDED - If the Tx Q is full
|
||||
** BNEP_NO_RESOURCES - If not able to allocate a buffer
|
||||
** BNEP_SUCCESS - If written successfully
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT BNEP_Write (UINT16 handle,
|
||||
UINT8 *p_dest_addr,
|
||||
UINT8 *p_data,
|
||||
UINT16 len,
|
||||
UINT16 protocol,
|
||||
UINT8 *p_src_addr,
|
||||
BOOLEAN fw_ext_present);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_SetProtocolFilters
|
||||
**
|
||||
** Description This function sets the protocol filters on peer device
|
||||
**
|
||||
** Parameters: handle - Handle for the connection
|
||||
** num_filters - total number of filter ranges
|
||||
** p_start_array - Array of beginings of all protocol ranges
|
||||
** p_end_array - Array of ends of all protocol ranges
|
||||
**
|
||||
** Returns BNEP_WRONG_HANDLE - if the connection handle is not valid
|
||||
** BNEP_SET_FILTER_FAIL - if the connection is in wrong state
|
||||
** BNEP_TOO_MANY_FILTERS - if too many filters
|
||||
** BNEP_SUCCESS - if request sent successfully
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle,
|
||||
UINT16 num_filters,
|
||||
UINT16 *p_start_array,
|
||||
UINT16 *p_end_array);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_SetMulticastFilters
|
||||
**
|
||||
** Description This function sets the filters for multicast addresses for BNEP.
|
||||
**
|
||||
** Parameters: handle - Handle for the connection
|
||||
** num_filters - total number of filter ranges
|
||||
** p_start_array - Pointer to sequence of beginings of all
|
||||
** multicast address ranges
|
||||
** p_end_array - Pointer to sequence of ends of all
|
||||
** multicast address ranges
|
||||
**
|
||||
** Returns BNEP_WRONG_HANDLE - if the connection handle is not valid
|
||||
** BNEP_SET_FILTER_FAIL - if the connection is in wrong state
|
||||
** BNEP_TOO_MANY_FILTERS - if too many filters
|
||||
** BNEP_SUCCESS - if request sent successfully
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle,
|
||||
UINT16 num_filters,
|
||||
UINT8 *p_start_array,
|
||||
UINT8 *p_end_array);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_SetTraceLevel
|
||||
**
|
||||
** Description This function sets the trace level for BNEP. If called with
|
||||
** a value of 0xFF, it simply reads the current trace level.
|
||||
**
|
||||
** Returns the new (current) trace level
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 BNEP_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_Init
|
||||
**
|
||||
** Description This function initializes the BNEP unit. It should be called
|
||||
** before accessing any other APIs to initialize the control block
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BNEP_Init (void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BNEP_GetStatus
|
||||
**
|
||||
** Description This function gets the status information for BNEP connection
|
||||
**
|
||||
** Returns BNEP_SUCCESS - if the status is available
|
||||
** BNEP_NO_RESOURCES - if no structure is passed for output
|
||||
** BNEP_WRONG_HANDLE - if the handle is invalid
|
||||
** BNEP_WRONG_STATE - if not in connected state
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT BNEP_GetStatus (UINT16 handle, tBNEP_STATUS *p_status);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2001-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains internally used BNEP definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BNEP_INT_H
|
||||
#define BNEP_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "bnep_api.h"
|
||||
#include "btm_int.h"
|
||||
#include "btu.h"
|
||||
|
||||
|
||||
/* BNEP frame types
|
||||
*/
|
||||
#define BNEP_FRAME_GENERAL_ETHERNET 0x00
|
||||
#define BNEP_FRAME_CONTROL 0x01
|
||||
#define BNEP_FRAME_COMPRESSED_ETHERNET 0x02
|
||||
#define BNEP_FRAME_COMPRESSED_ETHERNET_SRC_ONLY 0x03
|
||||
#define BNEP_FRAME_COMPRESSED_ETHERNET_DEST_ONLY 0x04
|
||||
|
||||
|
||||
/* BNEP filter control message types
|
||||
*/
|
||||
#define BNEP_CONTROL_COMMAND_NOT_UNDERSTOOD 0x00
|
||||
#define BNEP_SETUP_CONNECTION_REQUEST_MSG 0x01
|
||||
#define BNEP_SETUP_CONNECTION_RESPONSE_MSG 0x02
|
||||
#define BNEP_FILTER_NET_TYPE_SET_MSG 0x03
|
||||
#define BNEP_FILTER_NET_TYPE_RESPONSE_MSG 0x04
|
||||
#define BNEP_FILTER_MULTI_ADDR_SET_MSG 0x05
|
||||
#define BNEP_FILTER_MULTI_ADDR_RESPONSE_MSG 0x06
|
||||
|
||||
|
||||
/* BNEP header extension types
|
||||
*/
|
||||
#define BNEP_EXTENSION_FILTER_CONTROL 0x00
|
||||
|
||||
|
||||
/* BNEP Setup Connection response codes
|
||||
*/
|
||||
#define BNEP_SETUP_CONN_OK 0x0000
|
||||
#define BNEP_SETUP_INVALID_DEST_UUID 0x0001
|
||||
#define BNEP_SETUP_INVALID_SRC_UUID 0x0002
|
||||
#define BNEP_SETUP_INVALID_UUID_SIZE 0x0003
|
||||
#define BNEP_SETUP_CONN_NOT_ALLOWED 0x0004
|
||||
|
||||
|
||||
/* BNEP filter control response codes
|
||||
*/
|
||||
#define BNEP_FILTER_CRL_OK 0x0000
|
||||
#define BNEP_FILTER_CRL_UNSUPPORTED 0x0001
|
||||
#define BNEP_FILTER_CRL_BAD_RANGE 0x0002
|
||||
#define BNEP_FILTER_CRL_MAX_REACHED 0x0003
|
||||
#define BNEP_FILTER_CRL_SECURITY_ERR 0x0004
|
||||
|
||||
|
||||
/* 802.1p protocol packet will have actual protocol field in side the payload */
|
||||
#define BNEP_802_1_P_PROTOCOL 0x8100
|
||||
|
||||
/* Timeout definitions.
|
||||
*/
|
||||
#define BNEP_CONN_TIMEOUT 20 /* Connection related timeout */
|
||||
#define BNEP_HOST_TIMEOUT 200 /* host responce timeout */
|
||||
#define BNEP_FILTER_SET_TIMEOUT 10
|
||||
|
||||
/* Define the Out-Flow default values. */
|
||||
#define BNEP_OFLOW_QOS_FLAG 0
|
||||
#define BNEP_OFLOW_SERV_TYPE 0
|
||||
#define BNEP_OFLOW_TOKEN_RATE 0
|
||||
#define BNEP_OFLOW_TOKEN_BUCKET_SIZE 0
|
||||
#define BNEP_OFLOW_PEAK_BANDWIDTH 0
|
||||
#define BNEP_OFLOW_LATENCY 0
|
||||
#define BNEP_OFLOW_DELAY_VARIATION 0
|
||||
|
||||
/* Define the In-Flow default values. */
|
||||
#define BNEP_IFLOW_QOS_FLAG 0
|
||||
#define BNEP_IFLOW_SERV_TYPE 0
|
||||
#define BNEP_IFLOW_TOKEN_RATE 0
|
||||
#define BNEP_IFLOW_TOKEN_BUCKET_SIZE 0
|
||||
#define BNEP_IFLOW_PEAK_BANDWIDTH 0
|
||||
#define BNEP_IFLOW_LATENCY 0
|
||||
#define BNEP_IFLOW_DELAY_VARIATION 0
|
||||
|
||||
#define BNEP_FLUSH_TO 0xFFFF
|
||||
|
||||
#define BNEP_MAX_RETRANSMITS 3
|
||||
|
||||
/* Define the BNEP Connection Control Block
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
#define BNEP_STATE_IDLE 0
|
||||
#define BNEP_STATE_CONN_START 1
|
||||
#define BNEP_STATE_CFG_SETUP 2
|
||||
#define BNEP_STATE_CONN_SETUP 3
|
||||
#define BNEP_STATE_SEC_CHECKING 4
|
||||
#define BNEP_STATE_SETUP_RCVD 5
|
||||
#define BNEP_STATE_CONNECTED 6
|
||||
UINT8 con_state;
|
||||
|
||||
#define BNEP_FLAGS_IS_ORIG 0x01
|
||||
#define BNEP_FLAGS_HIS_CFG_DONE 0x02
|
||||
#define BNEP_FLAGS_MY_CFG_DONE 0x04
|
||||
#define BNEP_FLAGS_L2CAP_CONGESTED 0x08
|
||||
#define BNEP_FLAGS_FILTER_RESP_PEND 0x10
|
||||
#define BNEP_FLAGS_MULTI_RESP_PEND 0x20
|
||||
#define BNEP_FLAGS_SETUP_RCVD 0x40
|
||||
#define BNEP_FLAGS_CONN_COMPLETED 0x80
|
||||
UINT8 con_flags;
|
||||
BT_HDR *p_pending_data;
|
||||
|
||||
UINT16 l2cap_cid;
|
||||
BD_ADDR rem_bda;
|
||||
UINT16 rem_mtu_size;
|
||||
TIMER_LIST_ENT conn_tle;
|
||||
BUFFER_Q xmit_q;
|
||||
|
||||
UINT16 sent_num_filters;
|
||||
UINT16 sent_prot_filter_start[BNEP_MAX_PROT_FILTERS];
|
||||
UINT16 sent_prot_filter_end[BNEP_MAX_PROT_FILTERS];
|
||||
|
||||
UINT16 sent_mcast_filters;
|
||||
BD_ADDR sent_mcast_filter_start[BNEP_MAX_MULTI_FILTERS];
|
||||
BD_ADDR sent_mcast_filter_end[BNEP_MAX_MULTI_FILTERS];
|
||||
|
||||
UINT16 rcvd_num_filters;
|
||||
UINT16 rcvd_prot_filter_start[BNEP_MAX_PROT_FILTERS];
|
||||
UINT16 rcvd_prot_filter_end[BNEP_MAX_PROT_FILTERS];
|
||||
|
||||
UINT16 rcvd_mcast_filters;
|
||||
BD_ADDR rcvd_mcast_filter_start[BNEP_MAX_MULTI_FILTERS];
|
||||
BD_ADDR rcvd_mcast_filter_end[BNEP_MAX_MULTI_FILTERS];
|
||||
|
||||
UINT16 bad_pkts_rcvd;
|
||||
UINT8 re_transmits;
|
||||
UINT16 handle;
|
||||
tBT_UUID prv_src_uuid;
|
||||
tBT_UUID prv_dst_uuid;
|
||||
tBT_UUID src_uuid;
|
||||
tBT_UUID dst_uuid;
|
||||
|
||||
} tBNEP_CONN;
|
||||
|
||||
|
||||
/* The main BNEP control block
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
tL2CAP_CFG_INFO l2cap_my_cfg; /* My L2CAP config */
|
||||
tBNEP_CONN bcb[BNEP_MAX_CONNECTIONS];
|
||||
|
||||
tBNEP_CONNECT_IND_CB *p_conn_ind_cb;
|
||||
tBNEP_CONN_STATE_CB *p_conn_state_cb;
|
||||
tBNEP_DATA_IND_CB *p_data_ind_cb;
|
||||
tBNEP_DATA_BUF_CB *p_data_buf_cb;
|
||||
tBNEP_FILTER_IND_CB *p_filter_ind_cb;
|
||||
tBNEP_MFILTER_IND_CB *p_mfilter_ind_cb;
|
||||
tBNEP_TX_DATA_FLOW_CB *p_tx_data_flow_cb;
|
||||
|
||||
tL2CAP_APPL_INFO reg_info;
|
||||
|
||||
TIMER_LIST_ENT bnep_tle;
|
||||
BOOLEAN profile_registered; /* TRUE when we got our BD addr */
|
||||
UINT8 trace_level;
|
||||
|
||||
} tBNEP_CB;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Global BNEP data
|
||||
*/
|
||||
#if BNEP_DYNAMIC_MEMORY == FALSE
|
||||
extern tBNEP_CB bnep_cb;
|
||||
#else
|
||||
extern tBNEP_CB *bnep_cb_ptr;
|
||||
#define bnep_cb (*bnep_cb_ptr)
|
||||
#endif
|
||||
|
||||
/* Functions provided by bnep_main.c
|
||||
*/
|
||||
extern tBNEP_RESULT bnep_register_with_l2cap (void);
|
||||
extern void bnep_disconnect (tBNEP_CONN *p_bcb, UINT16 reason);
|
||||
extern tBNEP_CONN *bnep_conn_originate (UINT8 *p_bd_addr);
|
||||
extern void bnep_process_timeout (TIMER_LIST_ENT *p_tle);
|
||||
extern void bnep_connected (tBNEP_CONN *p_bcb);
|
||||
|
||||
|
||||
/* Functions provided by bnep_utils.c
|
||||
*/
|
||||
extern tBNEP_CONN *bnepu_find_bcb_by_cid (UINT16 cid);
|
||||
extern tBNEP_CONN *bnepu_find_bcb_by_bd_addr (UINT8 *p_bda);
|
||||
extern tBNEP_CONN *bnepu_allocate_bcb (BD_ADDR p_rem_bda);
|
||||
extern void bnepu_release_bcb (tBNEP_CONN *p_bcb);
|
||||
extern void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb);
|
||||
extern void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb);
|
||||
extern BOOLEAN bnepu_does_dest_support_prot (tBNEP_CONN *p_bcb, UINT16 protocol);
|
||||
extern void bnepu_build_bnep_hdr (tBNEP_CONN *p_bcb, BT_HDR *p_buf, UINT16 protocol,
|
||||
UINT8 *p_src_addr, UINT8 *p_dest_addr, BOOLEAN ext_bit);
|
||||
extern void test_bnepu_build_bnep_hdr (tBNEP_CONN *p_bcb, BT_HDR *p_buf, UINT16 protocol,
|
||||
UINT8 *p_src_addr, UINT8 *p_dest_addr, UINT8 type);
|
||||
|
||||
extern tBNEP_CONN *bnepu_get_route_to_dest (UINT8 *p_bda);
|
||||
extern void bnepu_check_send_packet (tBNEP_CONN *p_bcb, BT_HDR *p_buf);
|
||||
extern void bnep_send_command_not_understood (tBNEP_CONN *p_bcb, UINT8 cmd_code);
|
||||
extern void bnepu_process_peer_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16 len);
|
||||
extern void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data);
|
||||
extern void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data);
|
||||
extern void bnep_send_conn_req (tBNEP_CONN *p_bcb);
|
||||
extern void bnep_send_conn_responce (tBNEP_CONN *p_bcb, UINT16 resp_code);
|
||||
extern void bnep_process_setup_conn_req (tBNEP_CONN *p_bcb, UINT8 *p_setup, UINT8 len);
|
||||
extern void bnep_process_setup_conn_responce (tBNEP_CONN *p_bcb, UINT8 *p_setup);
|
||||
extern UINT8 *bnep_process_control_packet (tBNEP_CONN *p_bcb, UINT8 *p, UINT16 *len,
|
||||
BOOLEAN is_ext);
|
||||
extern void bnep_sec_check_complete (BD_ADDR bd_addr, tBT_TRANSPORT trasnport,
|
||||
void *p_ref_data, UINT8 result);
|
||||
extern tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb, BD_ADDR p_dest_addr, UINT16 protocol,
|
||||
BOOLEAN fw_ext_present, UINT8 *p_data);
|
||||
extern UINT32 bnep_get_uuid32 (tBT_UUID *src_uuid);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
+797
@@ -0,0 +1,797 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BT_TYPES_H
|
||||
#define BT_TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE false
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE true
|
||||
#endif
|
||||
|
||||
typedef uint8_t UINT8;
|
||||
typedef uint16_t UINT16;
|
||||
typedef uint32_t UINT32;
|
||||
typedef uint64_t UINT64;
|
||||
|
||||
typedef int8_t INT8;
|
||||
typedef int16_t INT16;
|
||||
typedef int32_t INT32;
|
||||
typedef bool BOOLEAN;
|
||||
|
||||
#define PACKED __packed
|
||||
#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))
|
||||
|
||||
/* READ WELL !!
|
||||
**
|
||||
** This section defines global events. These are events that cross layers.
|
||||
** Any event that passes between layers MUST be one of these events. Tasks
|
||||
** can use their own events internally, but a FUNDAMENTAL design issue is
|
||||
** that global events MUST be one of these events defined below.
|
||||
**
|
||||
** The convention used is the the event name contains the layer that the
|
||||
** event is going to.
|
||||
*/
|
||||
#define BT_EVT_MASK 0xFF00
|
||||
#define BT_SUB_EVT_MASK 0x00FF
|
||||
/* To Bluetooth Upper Layers */
|
||||
/************************************/
|
||||
#define BT_EVT_TO_BTU_L2C_EVT 0x0900 /* L2CAP event */
|
||||
#define BT_EVT_TO_BTU_HCI_EVT 0x1000 /* HCI Event */
|
||||
#define BT_EVT_TO_BTU_HCI_BR_EDR_EVT (0x0000 | BT_EVT_TO_BTU_HCI_EVT) /* event from BR/EDR controller */
|
||||
#define BT_EVT_TO_BTU_HCI_AMP1_EVT (0x0001 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 1 controller */
|
||||
#define BT_EVT_TO_BTU_HCI_AMP2_EVT (0x0002 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 2 controller */
|
||||
#define BT_EVT_TO_BTU_HCI_AMP3_EVT (0x0003 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 3 controller */
|
||||
|
||||
#define BT_EVT_TO_BTU_HCI_ACL 0x1100 /* ACL Data from HCI */
|
||||
#define BT_EVT_TO_BTU_HCI_SCO 0x1200 /* SCO Data from HCI */
|
||||
#define BT_EVT_TO_BTU_HCIT_ERR 0x1300 /* HCI Transport Error */
|
||||
|
||||
#define BT_EVT_TO_BTU_SP_EVT 0x1400 /* Serial Port Event */
|
||||
#define BT_EVT_TO_BTU_SP_DATA 0x1500 /* Serial Port Data */
|
||||
|
||||
#define BT_EVT_TO_BTU_HCI_CMD 0x1600 /* HCI command from upper layer */
|
||||
|
||||
|
||||
#define BT_EVT_TO_BTU_L2C_SEG_XMIT 0x1900 /* L2CAP segment(s) transmitted */
|
||||
|
||||
#define BT_EVT_PROXY_INCOMING_MSG 0x1A00 /* BlueStackTester event: incoming message from target */
|
||||
|
||||
#define BT_EVT_BTSIM 0x1B00 /* Insight BTSIM event */
|
||||
#define BT_EVT_BTISE 0x1C00 /* Insight Script Engine event */
|
||||
|
||||
/* To LM */
|
||||
/************************************/
|
||||
#define BT_EVT_TO_LM_HCI_CMD 0x2000 /* HCI Command */
|
||||
#define BT_EVT_TO_LM_HCI_ACL 0x2100 /* HCI ACL Data */
|
||||
#define BT_EVT_TO_LM_HCI_SCO 0x2200 /* HCI SCO Data */
|
||||
#define BT_EVT_TO_LM_HCIT_ERR 0x2300 /* HCI Transport Error */
|
||||
#define BT_EVT_TO_LM_LC_EVT 0x2400 /* LC event */
|
||||
#define BT_EVT_TO_LM_LC_LMP 0x2500 /* LC Received LMP command frame */
|
||||
#define BT_EVT_TO_LM_LC_ACL 0x2600 /* LC Received ACL data */
|
||||
#define BT_EVT_TO_LM_LC_SCO 0x2700 /* LC Received SCO data (not used) */
|
||||
#define BT_EVT_TO_LM_LC_ACL_TX 0x2800 /* LMP data transmit complete */
|
||||
#define BT_EVT_TO_LM_LC_LMPC_TX 0x2900 /* LMP Command transmit complete */
|
||||
#define BT_EVT_TO_LM_LOCAL_ACL_LB 0x2a00 /* Data to be locally loopbacked */
|
||||
#define BT_EVT_TO_LM_HCI_ACL_ACK 0x2b00 /* HCI ACL Data ack (not used) */
|
||||
#define BT_EVT_TO_LM_DIAG 0x2c00 /* LM Diagnostics commands */
|
||||
|
||||
|
||||
#define BT_EVT_TO_BTM_CMDS 0x2f00
|
||||
#define BT_EVT_TO_BTM_PM_MDCHG_EVT (0x0001 | BT_EVT_TO_BTM_CMDS)
|
||||
|
||||
#define BT_EVT_TO_TCS_CMDS 0x3000
|
||||
|
||||
#define BT_EVT_TO_CTP_CMDS 0x3300
|
||||
|
||||
/* ftp events */
|
||||
#define BT_EVT_TO_FTP_SRVR_CMDS 0x3600
|
||||
#define BT_EVT_TO_FTP_CLNT_CMDS 0x3700
|
||||
|
||||
#define BT_EVT_TO_BTU_SAP 0x3800 /* SIM Access Profile events */
|
||||
|
||||
/* opp events */
|
||||
#define BT_EVT_TO_OPP_SRVR_CMDS 0x3900
|
||||
#define BT_EVT_TO_OPP_CLNT_CMDS 0x3a00
|
||||
|
||||
/* gap events */
|
||||
#define BT_EVT_TO_GAP_MSG 0x3b00
|
||||
|
||||
/* for NFC */
|
||||
/************************************/
|
||||
#define BT_EVT_TO_NFC_NCI 0x4000 /* NCI Command, Notification or Data*/
|
||||
#define BT_EVT_TO_NFC_INIT 0x4100 /* Initialization message */
|
||||
#define BT_EVT_TO_NCI_LP 0x4200 /* Low power */
|
||||
#define BT_EVT_TO_NFC_ERR 0x4300 /* Error notification to NFC Task */
|
||||
|
||||
#define BT_EVT_TO_NFCCSIM_NCI 0x4a00 /* events to NFCC simulation (NCI packets) */
|
||||
|
||||
/* HCISU Events */
|
||||
|
||||
#define BT_EVT_HCISU 0x5000
|
||||
|
||||
// btla-specific ++
|
||||
#define BT_EVT_TO_HCISU_RECONFIG_EVT (0x0001 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_UPDATE_BAUDRATE_EVT (0x0002 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_ENABLE_EVT (0x0003 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_DISABLE_EVT (0x0004 | BT_EVT_HCISU)
|
||||
// btla-specific --
|
||||
#define BT_EVT_TO_HCISU_LP_APP_SLEEPING_EVT (0x0005 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_ALLOW_BT_SLEEP_EVT (0x0006 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_WAKEUP_HOST_EVT (0x0007 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_RCV_H4IBSS_EVT (0x0008 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_H5_RESET_EVT (0x0009 | BT_EVT_HCISU)
|
||||
#define BT_EVT_HCISU_START_QUICK_TIMER (0x000a | BT_EVT_HCISU)
|
||||
|
||||
#define BT_EVT_DATA_TO_AMP_1 0x5100
|
||||
#define BT_EVT_DATA_TO_AMP_15 0x5f00
|
||||
|
||||
/* HSP Events */
|
||||
|
||||
#define BT_EVT_BTU_HSP2 0x6000
|
||||
|
||||
#define BT_EVT_TO_BTU_HSP2_EVT (0x0001 | BT_EVT_BTU_HSP2)
|
||||
|
||||
/* BPP Events */
|
||||
#define BT_EVT_TO_BPP_PR_CMDS 0x6100 /* Printer Events */
|
||||
#define BT_EVT_TO_BPP_SND_CMDS 0x6200 /* BPP Sender Events */
|
||||
|
||||
/* BIP Events */
|
||||
#define BT_EVT_TO_BIP_CMDS 0x6300
|
||||
|
||||
/* HCRP Events */
|
||||
|
||||
#define BT_EVT_BTU_HCRP 0x7000
|
||||
|
||||
#define BT_EVT_TO_BTU_HCRP_EVT (0x0001 | BT_EVT_BTU_HCRP)
|
||||
#define BT_EVT_TO_BTU_HCRPM_EVT (0x0002 | BT_EVT_BTU_HCRP)
|
||||
|
||||
|
||||
#define BT_EVT_BTU_HFP 0x8000
|
||||
#define BT_EVT_TO_BTU_HFP_EVT (0x0001 | BT_EVT_BTU_HFP)
|
||||
|
||||
#define BT_EVT_BTU_IPC_EVT 0x9000
|
||||
#define BT_EVT_BTU_IPC_LOGMSG_EVT (0x0000 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_ACL_EVT (0x0001 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_BTU_EVT (0x0002 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_L2C_EVT (0x0003 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_L2C_MSG_EVT (0x0004 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_BTM_EVT (0x0005 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_AVDT_EVT (0x0006 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_SLIP_EVT (0x0007 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_MGMT_EVT (0x0008 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_BTTRC_EVT (0x0009 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_BURST_EVT (0x000A | BT_EVT_BTU_IPC_EVT)
|
||||
|
||||
|
||||
/* BTIF Events */
|
||||
#define BT_EVT_BTIF 0xA000
|
||||
#define BT_EVT_CONTEXT_SWITCH_EVT (0x0001 | BT_EVT_BTIF)
|
||||
|
||||
/* Define the header of each buffer used in the Bluetooth stack.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t event;
|
||||
uint16_t len;
|
||||
uint16_t offset;
|
||||
uint16_t layer_specific;
|
||||
uint8_t data[];
|
||||
} BT_HDR;
|
||||
|
||||
#define BT_HDR_SIZE (sizeof (BT_HDR))
|
||||
|
||||
#define BT_PSM_SDP 0x0001
|
||||
#define BT_PSM_RFCOMM 0x0003
|
||||
#define BT_PSM_TCS 0x0005
|
||||
#define BT_PSM_CTP 0x0007
|
||||
#define BT_PSM_BNEP 0x000F
|
||||
#define BT_PSM_HIDC 0x0011
|
||||
#define BT_PSM_HIDI 0x0013
|
||||
#define BT_PSM_UPNP 0x0015
|
||||
#define BT_PSM_AVCTP 0x0017
|
||||
#define BT_PSM_AVDTP 0x0019
|
||||
#define BT_PSM_AVCTP_13 0x001B /* Advanced Control - Browsing */
|
||||
#define BT_PSM_UDI_CP 0x001D /* Unrestricted Digital Information Profile C-Plane */
|
||||
#define BT_PSM_ATT 0x001F /* Attribute Protocol */
|
||||
|
||||
|
||||
/* These macros extract the HCI opcodes from a buffer
|
||||
*/
|
||||
#define HCI_GET_CMD_HDR_OPCODE(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset) + \
|
||||
(*((UINT8 *)((p) + 1) + p->offset + 1) << 8)))
|
||||
#define HCI_GET_CMD_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 2))
|
||||
|
||||
#define HCI_GET_EVT_HDR_OPCODE(p) (UINT8)(*((UINT8 *)((p) + 1) + p->offset))
|
||||
#define HCI_GET_EVT_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 1))
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a stream (Little Endian format).
|
||||
*/
|
||||
#define UINT32_TO_STREAM(p, u32) {*(p)++ = (UINT8)(u32); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 24);}
|
||||
#define UINT24_TO_STREAM(p, u24) {*(p)++ = (UINT8)(u24); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)((u24) >> 16);}
|
||||
#define UINT16_TO_STREAM(p, u16) {*(p)++ = (UINT8)(u16); *(p)++ = (UINT8)((u16) >> 8);}
|
||||
#define UINT8_TO_STREAM(p, u8) {*(p)++ = (UINT8)(u8);}
|
||||
#define INT8_TO_STREAM(p, u8) {*(p)++ = (INT8)(u8);}
|
||||
#define ARRAY32_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 32; ijk++) *(p)++ = (UINT8) a[31 - ijk];}
|
||||
#define ARRAY16_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 16; ijk++) *(p)++ = (UINT8) a[15 - ijk];}
|
||||
#define ARRAY8_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 8; ijk++) *(p)++ = (UINT8) a[7 - ijk];}
|
||||
#define BDADDR_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *(p)++ = (UINT8) a[BD_ADDR_LEN - 1 - ijk];}
|
||||
#define LAP_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < LAP_LEN; ijk++) *(p)++ = (UINT8) a[LAP_LEN - 1 - ijk];}
|
||||
#define DEVCLASS_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < DEV_CLASS_LEN;ijk++) *(p)++ = (UINT8) a[DEV_CLASS_LEN - 1 - ijk];}
|
||||
#define ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];}
|
||||
#define REVERSE_ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[len - 1 - ijk];}
|
||||
|
||||
#define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
|
||||
#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
|
||||
#define STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) ); (p) += 3;}
|
||||
#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
|
||||
#define STREAM_TO_BDADDR(a, p) {register int ijk; register UINT8 *pbda = (UINT8 *)a + BD_ADDR_LEN - 1; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *pbda-- = *p++;}
|
||||
#define STREAM_TO_ARRAY32(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 31; for (ijk = 0; ijk < 32; ijk++) *_pa-- = *p++;}
|
||||
#define STREAM_TO_ARRAY16(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 15; for (ijk = 0; ijk < 16; ijk++) *_pa-- = *p++;}
|
||||
#define STREAM_TO_ARRAY8(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 7; for (ijk = 0; ijk < 8; ijk++) *_pa-- = *p++;}
|
||||
#define STREAM_TO_DEVCLASS(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + DEV_CLASS_LEN - 1; for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) *_pa-- = *p++;}
|
||||
#define STREAM_TO_LAP(a, p) {register int ijk; register UINT8 *plap = (UINT8 *)a + LAP_LEN - 1; for (ijk = 0; ijk < LAP_LEN; ijk++) *plap-- = *p++;}
|
||||
#define STREAM_TO_ARRAY(a, p, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;}
|
||||
#define REVERSE_STREAM_TO_ARRAY(a, p, len) {register int ijk; register UINT8 *_pa = (UINT8 *)a + len - 1; for (ijk = 0; ijk < len; ijk++) *_pa-- = *p++;}
|
||||
|
||||
#define STREAM_SKIP_UINT8(p) do { (p) += 1; } while (0)
|
||||
#define STREAM_SKIP_UINT16(p) do { (p) += 2; } while (0)
|
||||
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a field (Little Endian format).
|
||||
** These are the same as to stream, except the pointer is not incremented.
|
||||
*/
|
||||
#define UINT32_TO_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)(u32); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+3) = (UINT8)((u32) >> 24);}
|
||||
#define UINT24_TO_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)(u24); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u24) >> 16);}
|
||||
#define UINT16_TO_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)(u16); *((UINT8 *)(p)+1) = (UINT8)((u16) >> 8);}
|
||||
#define UINT8_TO_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a stream (Big Endian format)
|
||||
*/
|
||||
#define UINT32_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 24); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
|
||||
#define UINT24_TO_BE_STREAM(p, u24) {*(p)++ = (UINT8)((u24) >> 16); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)(u24);}
|
||||
#define UINT16_TO_BE_STREAM(p, u16) {*(p)++ = (UINT8)((u16) >> 8); *(p)++ = (UINT8)(u16);}
|
||||
#define UINT8_TO_BE_STREAM(p, u8) {*(p)++ = (UINT8)(u8);}
|
||||
#define ARRAY_TO_BE_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];}
|
||||
#define ARRAY_TO_BE_STREAM_REVERSE(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[len - ijk - 1];}
|
||||
|
||||
#define BE_STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
|
||||
#define BE_STREAM_TO_UINT16(u16, p) {u16 = (UINT16)(((UINT16)(*(p)) << 8) + (UINT16)(*((p) + 1))); (p) += 2;}
|
||||
#define BE_STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*((p) + 2))) + ((UINT32)(*((p) + 1)) << 8) + ((UINT32)(*(p)) << 16)); (p) += 3;}
|
||||
#define BE_STREAM_TO_UINT32(u32, p) {u32 = ((UINT32)(*((p) + 3)) + ((UINT32)(*((p) + 2)) << 8) + ((UINT32)(*((p) + 1)) << 16) + ((UINT32)(*(p)) << 24)); (p) += 4;}
|
||||
#define BE_STREAM_TO_ARRAY(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a field (Big Endian format).
|
||||
** These are the same as to stream, except the pointer is not incremented.
|
||||
*/
|
||||
#define UINT32_TO_BE_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)((u32) >> 24); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+3) = (UINT8)(u32); }
|
||||
#define UINT24_TO_BE_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)((u24) >> 16); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)(u24);}
|
||||
#define UINT16_TO_BE_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)((u16) >> 8); *((UINT8 *)(p)+1) = (UINT8)(u16);}
|
||||
#define UINT8_TO_BE_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);}
|
||||
|
||||
|
||||
/* Common Bluetooth field definitions */
|
||||
#define BD_ADDR_LEN 6 /* Device address length */
|
||||
typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */
|
||||
typedef UINT8 *BD_ADDR_PTR; /* Pointer to Device Address */
|
||||
|
||||
#define AMP_KEY_TYPE_GAMP 0
|
||||
#define AMP_KEY_TYPE_WIFI 1
|
||||
#define AMP_KEY_TYPE_UWB 2
|
||||
typedef UINT8 tAMP_KEY_TYPE;
|
||||
|
||||
#define BT_OCTET8_LEN 8
|
||||
typedef UINT8 BT_OCTET8[BT_OCTET8_LEN]; /* octet array: size 16 */
|
||||
|
||||
#define LINK_KEY_LEN 16
|
||||
typedef UINT8 LINK_KEY[LINK_KEY_LEN]; /* Link Key */
|
||||
|
||||
#define AMP_LINK_KEY_LEN 32
|
||||
typedef UINT8 AMP_LINK_KEY[AMP_LINK_KEY_LEN]; /* Dedicated AMP and GAMP Link Keys */
|
||||
|
||||
#define BT_OCTET16_LEN 16
|
||||
typedef UINT8 BT_OCTET16[BT_OCTET16_LEN]; /* octet array: size 16 */
|
||||
|
||||
#define PIN_CODE_LEN 16
|
||||
typedef UINT8 PIN_CODE[PIN_CODE_LEN]; /* Pin Code (upto 128 bits) MSB is 0 */
|
||||
typedef UINT8 *PIN_CODE_PTR; /* Pointer to Pin Code */
|
||||
|
||||
#define BT_OCTET32_LEN 32
|
||||
typedef UINT8 BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */
|
||||
|
||||
#define DEV_CLASS_LEN 3
|
||||
typedef UINT8 DEV_CLASS[DEV_CLASS_LEN]; /* Device class */
|
||||
typedef UINT8 *DEV_CLASS_PTR; /* Pointer to Device class */
|
||||
|
||||
#define EXT_INQ_RESP_LEN 3
|
||||
typedef UINT8 EXT_INQ_RESP[EXT_INQ_RESP_LEN];/* Extended Inquiry Response */
|
||||
typedef UINT8 *EXT_INQ_RESP_PTR; /* Pointer to Extended Inquiry Response */
|
||||
|
||||
#define BD_NAME_LEN 248
|
||||
typedef UINT8 BD_NAME[BD_NAME_LEN + 1]; /* Device name */
|
||||
typedef UINT8 *BD_NAME_PTR; /* Pointer to Device name */
|
||||
|
||||
#define BD_FEATURES_LEN 8
|
||||
typedef UINT8 BD_FEATURES[BD_FEATURES_LEN]; /* LMP features supported by device */
|
||||
|
||||
#define BT_EVENT_MASK_LEN 8
|
||||
typedef UINT8 BT_EVENT_MASK[BT_EVENT_MASK_LEN]; /* Event Mask */
|
||||
|
||||
#define LAP_LEN 3
|
||||
typedef UINT8 LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
|
||||
typedef UINT8 INQ_LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
|
||||
|
||||
#define RAND_NUM_LEN 16
|
||||
typedef UINT8 RAND_NUM[RAND_NUM_LEN];
|
||||
|
||||
#define ACO_LEN 12
|
||||
typedef UINT8 ACO[ACO_LEN]; /* Authenticated ciphering offset */
|
||||
|
||||
#define COF_LEN 12
|
||||
typedef UINT8 COF[COF_LEN]; /* ciphering offset number */
|
||||
|
||||
typedef struct {
|
||||
UINT8 qos_flags; /* TBD */
|
||||
UINT8 service_type; /* see below */
|
||||
UINT32 token_rate; /* bytes/second */
|
||||
UINT32 token_bucket_size; /* bytes */
|
||||
UINT32 peak_bandwidth; /* bytes/second */
|
||||
UINT32 latency; /* microseconds */
|
||||
UINT32 delay_variation; /* microseconds */
|
||||
} FLOW_SPEC;
|
||||
|
||||
/* Values for service_type */
|
||||
#define NO_TRAFFIC 0
|
||||
#define BEST_EFFORT 1
|
||||
#define GUARANTEED 2
|
||||
|
||||
/* Service class of the CoD */
|
||||
#define SERV_CLASS_NETWORKING (1 << 1)
|
||||
#define SERV_CLASS_RENDERING (1 << 2)
|
||||
#define SERV_CLASS_CAPTURING (1 << 3)
|
||||
#define SERV_CLASS_OBJECT_TRANSFER (1 << 4)
|
||||
#define SERV_CLASS_OBJECT_AUDIO (1 << 5)
|
||||
#define SERV_CLASS_OBJECT_TELEPHONY (1 << 6)
|
||||
#define SERV_CLASS_OBJECT_INFORMATION (1 << 7)
|
||||
|
||||
/* Second byte */
|
||||
#define SERV_CLASS_LIMITED_DISC_MODE (0x20)
|
||||
|
||||
/* Field size definitions. Note that byte lengths are rounded up. */
|
||||
#define ACCESS_CODE_BIT_LEN 72
|
||||
#define ACCESS_CODE_BYTE_LEN 9
|
||||
#define SHORTENED_ACCESS_CODE_BIT_LEN 68
|
||||
|
||||
typedef UINT8 ACCESS_CODE[ACCESS_CODE_BYTE_LEN];
|
||||
|
||||
#define SYNTH_TX 1 /* want synth code to TRANSMIT at this freq */
|
||||
#define SYNTH_RX 2 /* want synth code to RECEIVE at this freq */
|
||||
|
||||
#define SYNC_REPS 1 /* repeats of sync word transmitted to start of burst */
|
||||
|
||||
/* Bluetooth CLK27 */
|
||||
#define BT_CLK27 (2 << 26)
|
||||
|
||||
/* Bluetooth CLK12 is 1.28 sec */
|
||||
#define BT_CLK12_TO_MS(x) ((x) * 1280)
|
||||
#define BT_MS_TO_CLK12(x) ((x) / 1280)
|
||||
#define BT_CLK12_TO_SLOTS(x) ((x) << 11)
|
||||
|
||||
/* Bluetooth CLK is 0.625 msec */
|
||||
#define BT_CLK_TO_MS(x) (((x) * 5 + 3) / 8)
|
||||
#define BT_MS_TO_CLK(x) (((x) * 8 + 2) / 5)
|
||||
|
||||
#define BT_CLK_TO_MICROSECS(x) (((x) * 5000 + 3) / 8)
|
||||
#define BT_MICROSECS_TO_CLK(x) (((x) * 8 + 2499) / 5000)
|
||||
|
||||
/* Maximum UUID size - 16 bytes, and structure to hold any type of UUID. */
|
||||
#define MAX_UUID_SIZE 16
|
||||
typedef struct
|
||||
{
|
||||
#define LEN_UUID_16 2
|
||||
#define LEN_UUID_32 4
|
||||
#define LEN_UUID_128 16
|
||||
|
||||
UINT16 len;
|
||||
|
||||
union
|
||||
{
|
||||
UINT16 uuid16;
|
||||
UINT32 uuid32;
|
||||
UINT8 uuid128[MAX_UUID_SIZE];
|
||||
} uu;
|
||||
|
||||
} tBT_UUID;
|
||||
|
||||
#define BT_EIR_FLAGS_TYPE 0x01
|
||||
#define BT_EIR_MORE_16BITS_UUID_TYPE 0x02
|
||||
#define BT_EIR_COMPLETE_16BITS_UUID_TYPE 0x03
|
||||
#define BT_EIR_MORE_32BITS_UUID_TYPE 0x04
|
||||
#define BT_EIR_COMPLETE_32BITS_UUID_TYPE 0x05
|
||||
#define BT_EIR_MORE_128BITS_UUID_TYPE 0x06
|
||||
#define BT_EIR_COMPLETE_128BITS_UUID_TYPE 0x07
|
||||
#define BT_EIR_SHORTENED_LOCAL_NAME_TYPE 0x08
|
||||
#define BT_EIR_COMPLETE_LOCAL_NAME_TYPE 0x09
|
||||
#define BT_EIR_TX_POWER_LEVEL_TYPE 0x0A
|
||||
#define BT_EIR_OOB_BD_ADDR_TYPE 0x0C
|
||||
#define BT_EIR_OOB_COD_TYPE 0x0D
|
||||
#define BT_EIR_OOB_SSP_HASH_C_TYPE 0x0E
|
||||
#define BT_EIR_OOB_SSP_RAND_R_TYPE 0x0F
|
||||
#define BT_EIR_MANUFACTURER_SPECIFIC_TYPE 0xFF
|
||||
|
||||
#define BT_OOB_COD_SIZE 3
|
||||
#define BT_OOB_HASH_C_SIZE 16
|
||||
#define BT_OOB_RAND_R_SIZE 16
|
||||
|
||||
/* Broadcom proprietary UUIDs and reserved PSMs
|
||||
**
|
||||
** The lowest 4 bytes byte of the UUID or GUID depends on the feature. Typically,
|
||||
** the value of those bytes will be the PSM or SCN, but it is up to the features.
|
||||
*/
|
||||
#define BRCM_PROPRIETARY_UUID_BASE 0xDA, 0x23, 0x41, 0x02, 0xA3, 0xBB, 0xC1, 0x71, 0xBA, 0x09, 0x6f, 0x21
|
||||
#define BRCM_PROPRIETARY_GUID_BASE 0xda23, 0x4102, 0xa3, 0xbb, 0xc1, 0x71, 0xba, 0x09, 0x6f, 0x21
|
||||
|
||||
/* We will not allocate a PSM in the reserved range to 3rd party apps
|
||||
*/
|
||||
#define BRCM_RESERVED_PSM_START 0x5AE1
|
||||
#define BRCM_RESERVED_PSM_END 0x5AFF
|
||||
|
||||
#define BRCM_UTILITY_SERVICE_PSM 0x5AE1
|
||||
#define BRCM_MATCHER_PSM 0x5AE3
|
||||
|
||||
/* Connection statistics
|
||||
*/
|
||||
|
||||
/* Structure to hold connection stats */
|
||||
#ifndef BT_CONN_STATS_DEFINED
|
||||
#define BT_CONN_STATS_DEFINED
|
||||
|
||||
/* These bits are used in the bIsConnected field */
|
||||
#define BT_CONNECTED_USING_BREDR 1
|
||||
#define BT_CONNECTED_USING_AMP 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 is_connected;
|
||||
INT32 rssi;
|
||||
UINT32 bytes_sent;
|
||||
UINT32 bytes_rcvd;
|
||||
UINT32 duration;
|
||||
} tBT_CONN_STATS;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Low Energy definitions
|
||||
**
|
||||
** Address types
|
||||
*/
|
||||
#define BLE_ADDR_PUBLIC 0x00
|
||||
#define BLE_ADDR_RANDOM 0x01
|
||||
#define BLE_ADDR_PUBLIC_ID 0x02
|
||||
#define BLE_ADDR_RANDOM_ID 0x03
|
||||
typedef UINT8 tBLE_ADDR_TYPE;
|
||||
#define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC)
|
||||
|
||||
#define BT_TRANSPORT_INVALID 0
|
||||
#define BT_TRANSPORT_BR_EDR 1
|
||||
#define BT_TRANSPORT_LE 2
|
||||
typedef UINT8 tBT_TRANSPORT;
|
||||
|
||||
#define BLE_ADDR_IS_STATIC(x) ((x[0] & 0xC0) == 0xC0)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tBLE_ADDR_TYPE type;
|
||||
BD_ADDR bda;
|
||||
} tBLE_BD_ADDR;
|
||||
|
||||
/* Device Types
|
||||
*/
|
||||
#define BT_DEVICE_TYPE_BREDR 0x01
|
||||
#define BT_DEVICE_TYPE_BLE 0x02
|
||||
#define BT_DEVICE_TYPE_DUMO 0x03
|
||||
typedef UINT8 tBT_DEVICE_TYPE;
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/* Define trace levels */
|
||||
#define BT_TRACE_LEVEL_NONE 0 /* No trace messages to be generated */
|
||||
#define BT_TRACE_LEVEL_ERROR 1 /* Error condition trace messages */
|
||||
#define BT_TRACE_LEVEL_WARNING 2 /* Warning condition trace messages */
|
||||
#define BT_TRACE_LEVEL_API 3 /* API traces */
|
||||
#define BT_TRACE_LEVEL_EVENT 4 /* Debug messages for events */
|
||||
#define BT_TRACE_LEVEL_DEBUG 5 /* Full debug messages */
|
||||
#define BT_TRACE_LEVEL_VERBOSE 6 /* Verbose debug messages */
|
||||
|
||||
#define MAX_TRACE_LEVEL 6
|
||||
|
||||
|
||||
/* Define New Trace Type Definition */
|
||||
/* TRACE_CTRL_TYPE 0x^^000000*/
|
||||
#define TRACE_CTRL_MASK 0xff000000
|
||||
#define TRACE_GET_CTRL(x) ((((UINT32)(x)) & TRACE_CTRL_MASK) >> 24)
|
||||
|
||||
#define TRACE_CTRL_GENERAL 0x00000000
|
||||
#define TRACE_CTRL_STR_RESOURCE 0x01000000
|
||||
#define TRACE_CTRL_SEQ_FLOW 0x02000000
|
||||
#define TRACE_CTRL_MAX_NUM 3
|
||||
|
||||
/* LAYER SPECIFIC 0x00^^0000*/
|
||||
#define TRACE_LAYER_MASK 0x00ff0000
|
||||
#define TRACE_GET_LAYER(x) ((((UINT32)(x)) & TRACE_LAYER_MASK) >> 16)
|
||||
|
||||
#define TRACE_LAYER_NONE 0x00000000
|
||||
#define TRACE_LAYER_USB 0x00010000
|
||||
#define TRACE_LAYER_SERIAL 0x00020000
|
||||
#define TRACE_LAYER_SOCKET 0x00030000
|
||||
#define TRACE_LAYER_RS232 0x00040000
|
||||
#define TRACE_LAYER_TRANS_MAX_NUM 5
|
||||
#define TRACE_LAYER_TRANS_ALL 0x007f0000
|
||||
#define TRACE_LAYER_LC 0x00050000
|
||||
#define TRACE_LAYER_LM 0x00060000
|
||||
#define TRACE_LAYER_HCI 0x00070000
|
||||
#define TRACE_LAYER_L2CAP 0x00080000
|
||||
#define TRACE_LAYER_RFCOMM 0x00090000
|
||||
#define TRACE_LAYER_SDP 0x000a0000
|
||||
#define TRACE_LAYER_TCS 0x000b0000
|
||||
#define TRACE_LAYER_OBEX 0x000c0000
|
||||
#define TRACE_LAYER_BTM 0x000d0000
|
||||
#define TRACE_LAYER_GAP 0x000e0000
|
||||
#define TRACE_LAYER_ICP 0x00110000
|
||||
#define TRACE_LAYER_HSP2 0x00120000
|
||||
#define TRACE_LAYER_SPP 0x00130000
|
||||
#define TRACE_LAYER_CTP 0x00140000
|
||||
#define TRACE_LAYER_BPP 0x00150000
|
||||
#define TRACE_LAYER_HCRP 0x00160000
|
||||
#define TRACE_LAYER_FTP 0x00170000
|
||||
#define TRACE_LAYER_OPP 0x00180000
|
||||
#define TRACE_LAYER_BTU 0x00190000
|
||||
#define TRACE_LAYER_GKI 0x001a0000
|
||||
#define TRACE_LAYER_BNEP 0x001b0000
|
||||
#define TRACE_LAYER_PAN 0x001c0000
|
||||
#define TRACE_LAYER_HFP 0x001d0000
|
||||
#define TRACE_LAYER_HID 0x001e0000
|
||||
#define TRACE_LAYER_BIP 0x001f0000
|
||||
#define TRACE_LAYER_AVP 0x00200000
|
||||
#define TRACE_LAYER_A2D 0x00210000
|
||||
#define TRACE_LAYER_SAP 0x00220000
|
||||
#define TRACE_LAYER_AMP 0x00230000
|
||||
#define TRACE_LAYER_MCA 0x00240000
|
||||
#define TRACE_LAYER_ATT 0x00250000
|
||||
#define TRACE_LAYER_SMP 0x00260000
|
||||
#define TRACE_LAYER_NFC 0x00270000
|
||||
#define TRACE_LAYER_NCI 0x00280000
|
||||
#define TRACE_LAYER_LLCP 0x00290000
|
||||
#define TRACE_LAYER_NDEF 0x002a0000
|
||||
#define TRACE_LAYER_RW 0x002b0000
|
||||
#define TRACE_LAYER_CE 0x002c0000
|
||||
#define TRACE_LAYER_P2P 0x002d0000
|
||||
#define TRACE_LAYER_SNEP 0x002e0000
|
||||
#define TRACE_LAYER_CHO 0x002f0000
|
||||
#define TRACE_LAYER_NFA 0x00300000
|
||||
|
||||
#define TRACE_LAYER_MAX_NUM 0x0031
|
||||
|
||||
|
||||
/* TRACE_ORIGINATOR 0x0000^^00*/
|
||||
#define TRACE_ORG_MASK 0x0000ff00
|
||||
#define TRACE_GET_ORG(x) ((((UINT32)(x)) & TRACE_ORG_MASK) >> 8)
|
||||
|
||||
#define TRACE_ORG_STACK 0x00000000
|
||||
#define TRACE_ORG_HCI_TRANS 0x00000100
|
||||
#define TRACE_ORG_PROTO_DISP 0x00000200
|
||||
#define TRACE_ORG_RPC 0x00000300
|
||||
#define TRACE_ORG_GKI 0x00000400
|
||||
#define TRACE_ORG_APPL 0x00000500
|
||||
#define TRACE_ORG_SCR_WRAPPER 0x00000600
|
||||
#define TRACE_ORG_SCR_ENGINE 0x00000700
|
||||
#define TRACE_ORG_USER_SCR 0x00000800
|
||||
#define TRACE_ORG_TESTER 0x00000900
|
||||
#define TRACE_ORG_MAX_NUM 10 /* 32-bit mask; must be < 32 */
|
||||
#define TRACE_LITE_ORG_MAX_NUM 6
|
||||
#define TRACE_ORG_ALL 0x03ff
|
||||
#define TRACE_ORG_RPC_TRANS 0x04
|
||||
|
||||
#define TRACE_ORG_REG 0x00000909
|
||||
#define TRACE_ORG_REG_SUCCESS 0x0000090a
|
||||
|
||||
/* TRACE_TYPE 0x000000^^*/
|
||||
#define TRACE_TYPE_MASK 0x000000ff
|
||||
#define TRACE_GET_TYPE(x) (((UINT32)(x)) & TRACE_TYPE_MASK)
|
||||
|
||||
#define TRACE_TYPE_ERROR 0x00000000
|
||||
#define TRACE_TYPE_WARNING 0x00000001
|
||||
#define TRACE_TYPE_API 0x00000002
|
||||
#define TRACE_TYPE_EVENT 0x00000003
|
||||
#define TRACE_TYPE_DEBUG 0x00000004
|
||||
#define TRACE_TYPE_STACK_ONLY_MAX TRACE_TYPE_DEBUG
|
||||
#define TRACE_TYPE_TX 0x00000005
|
||||
#define TRACE_TYPE_RX 0x00000006
|
||||
#define TRACE_TYPE_DEBUG_ASSERT 0x00000007
|
||||
#define TRACE_TYPE_GENERIC 0x00000008
|
||||
#define TRACE_TYPE_REG 0x00000009
|
||||
#define TRACE_TYPE_REG_SUCCESS 0x0000000a
|
||||
#define TRACE_TYPE_CMD_TX 0x0000000b
|
||||
#define TRACE_TYPE_EVT_TX 0x0000000c
|
||||
#define TRACE_TYPE_ACL_TX 0x0000000d
|
||||
#define TRACE_TYPE_CMD_RX 0x0000000e
|
||||
#define TRACE_TYPE_EVT_RX 0x0000000f
|
||||
#define TRACE_TYPE_ACL_RX 0x00000010
|
||||
#define TRACE_TYPE_TARGET_TRACE 0x00000011
|
||||
#define TRACE_TYPE_SCO_TX 0x00000012
|
||||
#define TRACE_TYPE_SCO_RX 0x00000013
|
||||
|
||||
|
||||
#define TRACE_TYPE_MAX_NUM 20
|
||||
#define TRACE_TYPE_ALL 0xffff
|
||||
|
||||
/* Define color for script type */
|
||||
#define SCR_COLOR_DEFAULT 0
|
||||
#define SCR_COLOR_TYPE_COMMENT 1
|
||||
#define SCR_COLOR_TYPE_COMMAND 2
|
||||
#define SCR_COLOR_TYPE_EVENT 3
|
||||
#define SCR_COLOR_TYPE_SELECT 4
|
||||
|
||||
/* Define protocol trace flag values */
|
||||
#define SCR_PROTO_TRACE_HCI_SUMMARY 0x00000001
|
||||
#define SCR_PROTO_TRACE_HCI_DATA 0x00000002
|
||||
#define SCR_PROTO_TRACE_L2CAP 0x00000004
|
||||
#define SCR_PROTO_TRACE_RFCOMM 0x00000008
|
||||
#define SCR_PROTO_TRACE_SDP 0x00000010
|
||||
#define SCR_PROTO_TRACE_TCS 0x00000020
|
||||
#define SCR_PROTO_TRACE_OBEX 0x00000040
|
||||
#define SCR_PROTO_TRACE_OAPP 0x00000080 /* OBEX Application Profile */
|
||||
#define SCR_PROTO_TRACE_AMP 0x00000100
|
||||
#define SCR_PROTO_TRACE_BNEP 0x00000200
|
||||
#define SCR_PROTO_TRACE_AVP 0x00000400
|
||||
#define SCR_PROTO_TRACE_MCA 0x00000800
|
||||
#define SCR_PROTO_TRACE_ATT 0x00001000
|
||||
#define SCR_PROTO_TRACE_SMP 0x00002000
|
||||
#define SCR_PROTO_TRACE_NCI 0x00004000
|
||||
#define SCR_PROTO_TRACE_LLCP 0x00008000
|
||||
#define SCR_PROTO_TRACE_NDEF 0x00010000
|
||||
#define SCR_PROTO_TRACE_RW 0x00020000
|
||||
#define SCR_PROTO_TRACE_CE 0x00040000
|
||||
#define SCR_PROTO_TRACE_SNEP 0x00080000
|
||||
#define SCR_PROTO_TRACE_CHO 0x00100000
|
||||
#define SCR_PROTO_TRACE_ALL 0x001fffff
|
||||
#define SCR_PROTO_TRACE_HCI_LOGGING_VSE 0x0800 /* Brcm vs event for logmsg and protocol traces */
|
||||
|
||||
#define MAX_SCRIPT_TYPE 5
|
||||
|
||||
#define TCS_PSM_INTERCOM 5
|
||||
#define TCS_PSM_CORDLESS 7
|
||||
#define BT_PSM_BNEP 0x000F
|
||||
/* Define PSMs HID uses */
|
||||
#define HID_PSM_CONTROL 0x0011
|
||||
#define HID_PSM_INTERRUPT 0x0013
|
||||
|
||||
/* Define a function for logging */
|
||||
typedef void (BT_LOG_FUNC) (int trace_type, const char *fmt_str, ...);
|
||||
|
||||
/* bd addr length and type */
|
||||
#ifndef BD_ADDR_LEN
|
||||
#define BD_ADDR_LEN 6
|
||||
typedef uint8_t BD_ADDR[BD_ADDR_LEN];
|
||||
#endif
|
||||
|
||||
// From bd.c
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* global constant for "any" bd addr */
|
||||
static const BD_ADDR bd_addr_any = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
static const BD_ADDR bd_addr_null= {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
/*****************************************************************************
|
||||
** Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bdcpy
|
||||
**
|
||||
** Description Copy bd addr b to a.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static inline void bdcpy(BD_ADDR a, const BD_ADDR b)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = BD_ADDR_LEN; i != 0; i--)
|
||||
{
|
||||
*a++ = *b++;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bdcmp
|
||||
**
|
||||
** Description Compare bd addr b to a.
|
||||
**
|
||||
**
|
||||
** Returns Zero if b==a, nonzero otherwise (like memcmp).
|
||||
**
|
||||
*******************************************************************************/
|
||||
static inline int bdcmp(const BD_ADDR a, const BD_ADDR b)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = BD_ADDR_LEN; i != 0; i--)
|
||||
{
|
||||
if (*a++ != *b++)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bdcmpany
|
||||
**
|
||||
** Description Compare bd addr to "any" bd addr.
|
||||
**
|
||||
**
|
||||
** Returns Zero if a equals bd_addr_any.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static inline int bdcmpany(const BD_ADDR a)
|
||||
{
|
||||
return bdcmp(a, bd_addr_any);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bdsetany
|
||||
**
|
||||
** Description Set bd addr to "any" bd addr.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static inline void bdsetany(BD_ADDR a)
|
||||
{
|
||||
bdcpy(a, bd_addr_any);
|
||||
}
|
||||
#endif
|
||||
+4100
File diff suppressed because it is too large
Load Diff
+1924
File diff suppressed because it is too large
Load Diff
+486
@@ -0,0 +1,486 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* this file contains the main Bluetooth Manager (BTM) internal
|
||||
* definitions.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BTM_BLE_INT_H
|
||||
#define BTM_BLE_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "hcidefs.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "btm_int.h"
|
||||
|
||||
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
|
||||
#include "smp_api.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* scanning enable status */
|
||||
#define BTM_BLE_SCAN_ENABLE 0x01
|
||||
#define BTM_BLE_SCAN_DISABLE 0x00
|
||||
|
||||
/* advertising enable status */
|
||||
#define BTM_BLE_ADV_ENABLE 0x01
|
||||
#define BTM_BLE_ADV_DISABLE 0x00
|
||||
|
||||
/* use the high 4 bits unused by inquiry mode */
|
||||
#define BTM_BLE_SELECT_SCAN 0x20
|
||||
#define BTM_BLE_NAME_REQUEST 0x40
|
||||
#define BTM_BLE_OBSERVE 0x80
|
||||
|
||||
#define BTM_BLE_MAX_WL_ENTRY 1
|
||||
#define BTM_BLE_AD_DATA_LEN 31
|
||||
|
||||
#define BTM_BLE_ENC_MASK 0x03
|
||||
|
||||
#define BTM_BLE_DUPLICATE_ENABLE 1
|
||||
#define BTM_BLE_DUPLICATE_DISABLE 0
|
||||
|
||||
#define BTM_BLE_GAP_DISC_SCAN_INT 18 /* Interval(scan_int) = 11.25 ms= 0x0010 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_DISC_SCAN_WIN 18 /* scan_window = 11.25 ms= 0x0010 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_ADV_INT 512 /* Tgap(gen_disc) = 1.28 s= 512 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_LIM_TOUT 180 /* Tgap(lim_timeout) = 180s max */
|
||||
#define BTM_BLE_LOW_LATENCY_SCAN_INT 8000 /* Interval(scan_int) = 5s= 8000 * 0.625 ms */
|
||||
#define BTM_BLE_LOW_LATENCY_SCAN_WIN 8000 /* scan_window = 5s= 8000 * 0.625 ms */
|
||||
|
||||
|
||||
#define BTM_BLE_GAP_ADV_FAST_INT_1 48 /* TGAP(adv_fast_interval1) = 30(used) ~ 60 ms = 48 *0.625 */
|
||||
#define BTM_BLE_GAP_ADV_FAST_INT_2 160 /* TGAP(adv_fast_interval2) = 100(used) ~ 150 ms = 160 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_ADV_SLOW_INT 2048 /* Tgap(adv_slow_interval) = 1.28 s= 512 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_ADV_DIR_MAX_INT 800 /* Tgap(dir_conn_adv_int_max) = 500 ms = 800 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_ADV_DIR_MIN_INT 400 /* Tgap(dir_conn_adv_int_min) = 250 ms = 400 * 0.625 ms */
|
||||
|
||||
#define BTM_BLE_GAP_FAST_ADV_TOUT 30
|
||||
|
||||
#define BTM_BLE_SEC_REQ_ACT_NONE 0
|
||||
#define BTM_BLE_SEC_REQ_ACT_ENCRYPT 1 /* encrypt the link using current key or key refresh */
|
||||
#define BTM_BLE_SEC_REQ_ACT_PAIR 2
|
||||
#define BTM_BLE_SEC_REQ_ACT_DISCARD 3 /* discard the sec request while encryption is started but not completed */
|
||||
typedef UINT8 tBTM_BLE_SEC_REQ_ACT;
|
||||
|
||||
#define BLE_STATIC_PRIVATE_MSB_MASK 0x3f
|
||||
#define BLE_RESOLVE_ADDR_MSB 0x40 /* most significant bit, bit7, bit6 is 01 to be resolvable random */
|
||||
#define BLE_RESOLVE_ADDR_MASK 0xc0 /* bit 6, and bit7 */
|
||||
#define BTM_BLE_IS_RESOLVE_BDA(x) ((x[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB)
|
||||
|
||||
/* LE scan activity bit mask, continue with LE inquiry bits */
|
||||
#define BTM_LE_SELECT_CONN_ACTIVE 0x40 /* selection connection is in progress */
|
||||
#define BTM_LE_OBSERVE_ACTIVE 0x80 /* observe is in progress */
|
||||
|
||||
/* BLE scan activity mask checking */
|
||||
#define BTM_BLE_IS_SCAN_ACTIVE(x) ((x) & BTM_BLE_SCAN_ACTIVE_MASK)
|
||||
#define BTM_BLE_IS_INQ_ACTIVE(x) ((x) & BTM_BLE_INQUIRY_MASK)
|
||||
#define BTM_BLE_IS_OBS_ACTIVE(x) ((x) & BTM_LE_OBSERVE_ACTIVE)
|
||||
#define BTM_BLE_IS_SEL_CONN_ACTIVE(x) ((x) & BTM_LE_SELECT_CONN_ACTIVE)
|
||||
|
||||
/* BLE ADDR type ID bit */
|
||||
#define BLE_ADDR_TYPE_ID_BIT 0x02
|
||||
|
||||
#define BTM_VSC_CHIP_CAPABILITY_L_VERSION 55
|
||||
#define BTM_VSC_CHIP_CAPABILITY_M_VERSION 95
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 data_mask;
|
||||
UINT8 *p_flags;
|
||||
UINT8 ad_data[BTM_BLE_AD_DATA_LEN];
|
||||
UINT8 *p_pad;
|
||||
}tBTM_BLE_LOCAL_ADV_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 inq_count; /* Used for determining if a response has already been */
|
||||
/* received for the current inquiry operation. (We do not */
|
||||
/* want to flood the caller with multiple responses from */
|
||||
/* the same device. */
|
||||
BOOLEAN scan_rsp;
|
||||
tBLE_BD_ADDR le_bda;
|
||||
} tINQ_LE_BDADDR;
|
||||
|
||||
#define BTM_BLE_ADV_DATA_LEN_MAX 31
|
||||
#define BTM_BLE_CACHE_ADV_DATA_MAX 62
|
||||
|
||||
#define BTM_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF))
|
||||
|
||||
#define BTM_BLE_PRIVATE_ADDR_INT 900 /* 15 minutes minimum for random address refreshing */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 discoverable_mode;
|
||||
UINT16 connectable_mode;
|
||||
UINT32 scan_window;
|
||||
UINT32 scan_interval;
|
||||
UINT8 scan_type; /* current scan type: active or passive */
|
||||
UINT8 scan_duplicate_filter; /* duplicate filter enabled for scan */
|
||||
UINT16 adv_interval_min;
|
||||
UINT16 adv_interval_max;
|
||||
tBTM_BLE_AFP afp; /* advertising filter policy */
|
||||
tBTM_BLE_SFP sfp; /* scanning filter policy */
|
||||
|
||||
tBLE_ADDR_TYPE adv_addr_type;
|
||||
UINT8 evt_type;
|
||||
UINT8 adv_mode;
|
||||
tBLE_BD_ADDR direct_bda;
|
||||
tBTM_BLE_EVT directed_conn;
|
||||
BOOLEAN fast_adv_on;
|
||||
TIMER_LIST_ENT fast_adv_timer;
|
||||
|
||||
UINT8 adv_len;
|
||||
UINT8 adv_data_cache[BTM_BLE_CACHE_ADV_DATA_MAX];
|
||||
|
||||
/* inquiry BD addr database */
|
||||
UINT8 num_bd_entries;
|
||||
UINT8 max_bd_entries;
|
||||
tBTM_BLE_LOCAL_ADV_DATA adv_data;
|
||||
tBTM_BLE_ADV_CHNL_MAP adv_chnl_map;
|
||||
|
||||
TIMER_LIST_ENT inq_timer_ent;
|
||||
BOOLEAN scan_rsp;
|
||||
UINT8 state; /* Current state that the inquiry process is in */
|
||||
INT8 tx_power;
|
||||
} tBTM_BLE_INQ_CB;
|
||||
|
||||
|
||||
/* random address resolving complete callback */
|
||||
typedef void (tBTM_BLE_RESOLVE_CBACK) (void * match_rec, void *p);
|
||||
|
||||
typedef void (tBTM_BLE_ADDR_CBACK) (BD_ADDR_PTR static_random, void *p);
|
||||
|
||||
/* random address management control block */
|
||||
typedef struct
|
||||
{
|
||||
tBLE_ADDR_TYPE own_addr_type; /* local device LE address type */
|
||||
BD_ADDR private_addr;
|
||||
BD_ADDR random_bda;
|
||||
BOOLEAN busy;
|
||||
UINT16 index;
|
||||
tBTM_BLE_RESOLVE_CBACK *p_resolve_cback;
|
||||
tBTM_BLE_ADDR_CBACK *p_generate_cback;
|
||||
void *p;
|
||||
TIMER_LIST_ENT raddr_timer_ent;
|
||||
} tBTM_LE_RANDOM_CB;
|
||||
|
||||
#define BTM_BLE_MAX_BG_CONN_DEV_NUM 10
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 min_conn_int;
|
||||
UINT16 max_conn_int;
|
||||
UINT16 slave_latency;
|
||||
UINT16 supervision_tout;
|
||||
|
||||
}tBTM_LE_CONN_PRAMS;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BD_ADDR bd_addr;
|
||||
UINT8 attr;
|
||||
BOOLEAN is_connected;
|
||||
BOOLEAN in_use;
|
||||
}tBTM_LE_BG_CONN_DEV;
|
||||
|
||||
/* white list using state as a bit mask */
|
||||
#define BTM_BLE_WL_IDLE 0
|
||||
#define BTM_BLE_WL_INIT 1
|
||||
#define BTM_BLE_WL_SCAN 2
|
||||
#define BTM_BLE_WL_ADV 4
|
||||
typedef UINT8 tBTM_BLE_WL_STATE;
|
||||
|
||||
/* resolving list using state as a bit mask */
|
||||
#define BTM_BLE_RL_IDLE 0
|
||||
#define BTM_BLE_RL_INIT 1
|
||||
#define BTM_BLE_RL_SCAN 2
|
||||
#define BTM_BLE_RL_ADV 4
|
||||
typedef UINT8 tBTM_BLE_RL_STATE;
|
||||
|
||||
/* BLE connection state */
|
||||
#define BLE_CONN_IDLE 0
|
||||
#define BLE_DIR_CONN 1
|
||||
#define BLE_BG_CONN 2
|
||||
#define BLE_CONN_CANCEL 3
|
||||
typedef UINT8 tBTM_BLE_CONN_ST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *p_param;
|
||||
}tBTM_BLE_CONN_REQ;
|
||||
|
||||
/* LE state request */
|
||||
#define BTM_BLE_STATE_INVALID 0
|
||||
#define BTM_BLE_STATE_CONN_ADV 1
|
||||
#define BTM_BLE_STATE_INIT 2
|
||||
#define BTM_BLE_STATE_MASTER 3
|
||||
#define BTM_BLE_STATE_SLAVE 4
|
||||
#define BTM_BLE_STATE_LO_DUTY_DIR_ADV 5
|
||||
#define BTM_BLE_STATE_HI_DUTY_DIR_ADV 6
|
||||
#define BTM_BLE_STATE_NON_CONN_ADV 7
|
||||
#define BTM_BLE_STATE_PASSIVE_SCAN 8
|
||||
#define BTM_BLE_STATE_ACTIVE_SCAN 9
|
||||
#define BTM_BLE_STATE_SCAN_ADV 10
|
||||
#define BTM_BLE_STATE_MAX 11
|
||||
typedef UINT8 tBTM_BLE_STATE;
|
||||
|
||||
#define BTM_BLE_STATE_CONN_ADV_BIT 0x0001
|
||||
#define BTM_BLE_STATE_INIT_BIT 0x0002
|
||||
#define BTM_BLE_STATE_MASTER_BIT 0x0004
|
||||
#define BTM_BLE_STATE_SLAVE_BIT 0x0008
|
||||
#define BTM_BLE_STATE_LO_DUTY_DIR_ADV_BIT 0x0010
|
||||
#define BTM_BLE_STATE_HI_DUTY_DIR_ADV_BIT 0x0020
|
||||
#define BTM_BLE_STATE_NON_CONN_ADV_BIT 0x0040
|
||||
#define BTM_BLE_STATE_PASSIVE_SCAN_BIT 0x0080
|
||||
#define BTM_BLE_STATE_ACTIVE_SCAN_BIT 0x0100
|
||||
#define BTM_BLE_STATE_SCAN_ADV_BIT 0x0200
|
||||
typedef UINT16 tBTM_BLE_STATE_MASK;
|
||||
|
||||
#define BTM_BLE_STATE_ALL_MASK 0x03ff
|
||||
#define BTM_BLE_STATE_ALL_ADV_MASK (BTM_BLE_STATE_CONN_ADV_BIT|BTM_BLE_STATE_LO_DUTY_DIR_ADV_BIT|BTM_BLE_STATE_HI_DUTY_DIR_ADV_BIT|BTM_BLE_STATE_SCAN_ADV_BIT)
|
||||
#define BTM_BLE_STATE_ALL_SCAN_MASK (BTM_BLE_STATE_PASSIVE_SCAN_BIT|BTM_BLE_STATE_ACTIVE_SCAN_BIT)
|
||||
#define BTM_BLE_STATE_ALL_CONN_MASK (BTM_BLE_STATE_MASTER_BIT|BTM_BLE_STATE_SLAVE_BIT)
|
||||
|
||||
#ifndef BTM_LE_RESOLVING_LIST_MAX
|
||||
#define BTM_LE_RESOLVING_LIST_MAX 0x20
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BD_ADDR *resolve_q_random_pseudo;
|
||||
UINT8 *resolve_q_action;
|
||||
UINT8 q_next;
|
||||
UINT8 q_pending;
|
||||
} tBTM_BLE_RESOLVE_Q;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN to_add;
|
||||
BD_ADDR bd_addr;
|
||||
UINT8 attr;
|
||||
}tBTM_BLE_WL_OP;
|
||||
|
||||
/* BLE privacy mode */
|
||||
#define BTM_PRIVACY_NONE 0 /* BLE no privacy */
|
||||
#define BTM_PRIVACY_1_1 1 /* BLE privacy 1.1, do not support privacy 1.0 */
|
||||
#define BTM_PRIVACY_1_2 2 /* BLE privacy 1.2 */
|
||||
#define BTM_PRIVACY_MIXED 3 /* BLE privacy mixed mode, broadcom propietary mode */
|
||||
typedef UINT8 tBTM_PRIVACY_MODE;
|
||||
|
||||
/* data length change event callback */
|
||||
typedef void (tBTM_DATA_LENGTH_CHANGE_CBACK) (UINT16 max_tx_length, UINT16 max_rx_length);
|
||||
|
||||
/* Define BLE Device Management control structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
UINT8 scan_activity; /* LE scan activity mask */
|
||||
|
||||
/*****************************************************
|
||||
** BLE Inquiry
|
||||
*****************************************************/
|
||||
tBTM_BLE_INQ_CB inq_var;
|
||||
|
||||
/* observer callback and timer */
|
||||
tBTM_INQ_RESULTS_CB *p_obs_results_cb;
|
||||
tBTM_CMPL_CB *p_obs_cmpl_cb;
|
||||
TIMER_LIST_ENT obs_timer_ent;
|
||||
|
||||
/* background connection procedure cb value */
|
||||
tBTM_BLE_CONN_TYPE bg_conn_type;
|
||||
UINT32 scan_int;
|
||||
UINT32 scan_win;
|
||||
tBTM_BLE_SEL_CBACK *p_select_cback;
|
||||
|
||||
/* white list information */
|
||||
UINT8 white_list_avail_size;
|
||||
tBTM_BLE_WL_STATE wl_state;
|
||||
|
||||
BUFFER_Q conn_pending_q;
|
||||
tBTM_BLE_CONN_ST conn_state;
|
||||
|
||||
/* random address management control block */
|
||||
tBTM_LE_RANDOM_CB addr_mgnt_cb;
|
||||
|
||||
BOOLEAN enabled;
|
||||
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
BOOLEAN mixed_mode; /* privacy 1.2 mixed mode is on or not */
|
||||
tBTM_PRIVACY_MODE privacy_mode; /* privacy mode */
|
||||
UINT8 resolving_list_avail_size; /* resolving list available size */
|
||||
tBTM_BLE_RESOLVE_Q resolving_list_pend_q; /* Resolving list queue */
|
||||
tBTM_BLE_RL_STATE suspended_rl_state; /* Suspended resolving list state */
|
||||
UINT8 *irk_list_mask; /* IRK list availability mask, up to max entry bits */
|
||||
tBTM_BLE_RL_STATE rl_state; /* Resolving list state */
|
||||
#endif
|
||||
|
||||
tBTM_BLE_WL_OP wl_op_q[BTM_BLE_MAX_BG_CONN_DEV_NUM];
|
||||
|
||||
/* current BLE link state */
|
||||
tBTM_BLE_STATE_MASK cur_states; /* bit mask of tBTM_BLE_STATE */
|
||||
UINT8 link_count[2]; /* total link count master and slave*/
|
||||
} tBTM_BLE_CB;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void btm_ble_timeout(TIMER_LIST_ENT *p_tle);
|
||||
void btm_ble_process_adv_pkt (UINT8 *p);
|
||||
void btm_ble_proc_scan_rsp_rpt (UINT8 *p);
|
||||
tBTM_STATUS btm_ble_read_remote_name(BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, tBTM_CMPL_CB *p_cb);
|
||||
BOOLEAN btm_ble_cancel_remote_name(BD_ADDR remote_bda);
|
||||
|
||||
tBTM_STATUS btm_ble_set_discoverability(UINT16 combined_mode);
|
||||
tBTM_STATUS btm_ble_set_connectability(UINT16 combined_mode);
|
||||
tBTM_STATUS btm_ble_start_inquiry (UINT8 mode, UINT8 duration);
|
||||
void btm_ble_stop_scan(void);
|
||||
void btm_clear_all_pending_le_entry(void);
|
||||
|
||||
void btm_ble_stop_scan();
|
||||
BOOLEAN btm_ble_send_extended_scan_params(UINT8 scan_type, UINT32 scan_int,
|
||||
UINT32 scan_win, UINT8 addr_type_own,
|
||||
UINT8 scan_filter_policy);
|
||||
void btm_ble_stop_inquiry(void);
|
||||
void btm_ble_init (void);
|
||||
void btm_ble_connected (UINT8 *bda, UINT16 handle, UINT8 enc_mode, UINT8 role, tBLE_ADDR_TYPE addr_type, BOOLEAN addr_matched);
|
||||
void btm_ble_read_remote_features_complete(UINT8 *p);
|
||||
void btm_ble_write_adv_enable_complete(UINT8 * p);
|
||||
void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced);
|
||||
void btm_read_ble_local_supported_states_complete(UINT8 *p, UINT16 evt_len);
|
||||
tBTM_BLE_CONN_ST btm_ble_get_conn_st(void);
|
||||
void btm_ble_set_conn_st(tBTM_BLE_CONN_ST new_st);
|
||||
UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
|
||||
tBTM_BLE_ADV_DATA *p_data);
|
||||
tBTM_STATUS btm_ble_start_adv(void);
|
||||
tBTM_STATUS btm_ble_stop_adv(void);
|
||||
tBTM_STATUS btm_ble_start_scan(void);
|
||||
void btm_ble_create_ll_conn_complete (UINT8 status);
|
||||
|
||||
/* LE security function from btm_sec.c */
|
||||
#if SMP_INCLUDED == TRUE
|
||||
void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE_SEC_REQ_ACT *p_sec_req_act);
|
||||
void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk);
|
||||
UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data);
|
||||
tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 link_role);
|
||||
void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv);
|
||||
tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk);
|
||||
void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable);
|
||||
#endif
|
||||
|
||||
/* LE device management functions */
|
||||
void btm_ble_reset_id( void );
|
||||
|
||||
/* security related functions */
|
||||
void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local );
|
||||
BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div);
|
||||
BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types);
|
||||
|
||||
void btm_ble_test_command_complete(UINT8 *p);
|
||||
void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_enc_cplt_cback);
|
||||
|
||||
void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY_VALUE *p_keys, BOOLEAN pass_to_application);
|
||||
void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size);
|
||||
UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr);
|
||||
|
||||
/* white list function */
|
||||
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr);
|
||||
void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy);
|
||||
void btm_update_adv_filter_policy(tBTM_BLE_AFP adv_policy);
|
||||
void btm_ble_clear_white_list (void);
|
||||
void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_add_2_white_list_complete(UINT8 status);
|
||||
void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_clear_white_list_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_white_list_init(UINT8 white_list_size);
|
||||
|
||||
/* background connection function */
|
||||
BOOLEAN btm_ble_suspend_bg_conn(void);
|
||||
BOOLEAN btm_ble_resume_bg_conn(void);
|
||||
void btm_ble_initiate_select_conn(BD_ADDR bda);
|
||||
BOOLEAN btm_ble_start_auto_conn(BOOLEAN start);
|
||||
BOOLEAN btm_ble_start_select_conn(BOOLEAN start,tBTM_BLE_SEL_CBACK *p_select_cback);
|
||||
BOOLEAN btm_ble_renew_bg_conn_params(BOOLEAN add, BD_ADDR bd_addr);
|
||||
void btm_write_dir_conn_wl(BD_ADDR target_addr);
|
||||
void btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bda, UINT8 status);
|
||||
BOOLEAN btm_execute_wl_dev_operation(void);
|
||||
void btm_ble_update_link_topology_mask(UINT8 role, BOOLEAN increase);
|
||||
|
||||
/* direct connection utility */
|
||||
BOOLEAN btm_send_pending_direct_conn(void);
|
||||
void btm_ble_enqueue_direct_conn_req(void *p_param);
|
||||
|
||||
/* BLE address management */
|
||||
void btm_gen_resolvable_private_addr (void *p_cmd_cplt_cback);
|
||||
void btm_gen_non_resolvable_private_addr (tBTM_BLE_ADDR_CBACK *p_cback, void *p);
|
||||
void btm_ble_resolve_random_addr(BD_ADDR random_bda, tBTM_BLE_RESOLVE_CBACK * p_cback, void *p);
|
||||
void btm_gen_resolve_paddr_low(tBTM_RAND_ENC *p);
|
||||
|
||||
/* privacy function */
|
||||
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
|
||||
/* BLE address mapping with CS feature */
|
||||
BOOLEAN btm_identity_addr_to_random_pseudo(BD_ADDR bd_addr, UINT8 *p_addr_type, BOOLEAN refresh);
|
||||
BOOLEAN btm_random_pseudo_to_identity_addr(BD_ADDR random_pseudo, UINT8 *p_static_addr_type);
|
||||
void btm_ble_refresh_peer_resolvable_private_addr(BD_ADDR pseudo_bda, BD_ADDR rra, UINT8 rra_type);
|
||||
void btm_ble_refresh_local_resolvable_private_addr(BD_ADDR pseudo_addr, BD_ADDR local_rpa);
|
||||
void btm_ble_read_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len) ;
|
||||
void btm_ble_remove_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_add_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_clear_resolving_list_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_read_ble_resolving_list_size_complete (UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_enable_resolving_list(UINT8);
|
||||
BOOLEAN btm_ble_disable_resolving_list(UINT8 rl_mask, BOOLEAN to_resume);
|
||||
void btm_ble_enable_resolving_list_for_platform (UINT8 rl_mask);
|
||||
void btm_ble_resolving_list_init(UINT8 max_irk_list_sz);
|
||||
void btm_ble_resolving_list_cleanup(void);
|
||||
#endif
|
||||
|
||||
void btm_ble_multi_adv_configure_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst);
|
||||
void btm_ble_multi_adv_init(void);
|
||||
void* btm_ble_multi_adv_get_ref(UINT8 inst_id);
|
||||
void btm_ble_multi_adv_cleanup(void);
|
||||
void btm_ble_multi_adv_reenable(UINT8 inst_id);
|
||||
void btm_ble_multi_adv_enb_privacy(BOOLEAN enable);
|
||||
char btm_ble_map_adv_tx_power(int tx_power_index);
|
||||
void btm_ble_batchscan_init(void);
|
||||
void btm_ble_batchscan_cleanup(void);
|
||||
void btm_ble_adv_filter_init(void);
|
||||
void btm_ble_adv_filter_cleanup(void);
|
||||
BOOLEAN btm_ble_topology_check(tBTM_BLE_STATE_MASK request);
|
||||
BOOLEAN btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state);
|
||||
BOOLEAN btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state);
|
||||
|
||||
#if BTM_BLE_CONFORMANCE_TESTING == TRUE
|
||||
void btm_ble_set_no_disc_if_pair_fail (BOOLEAN disble_disc);
|
||||
void btm_ble_set_test_mac_value (BOOLEAN enable, UINT8 *p_test_mac_val);
|
||||
void btm_ble_set_test_local_sign_cntr_value(BOOLEAN enable, UINT32 test_local_sign_cntr);
|
||||
void btm_set_random_address(BD_ADDR random_bda);
|
||||
void btm_ble_set_keep_rfu_in_auth_req(BOOLEAN keep_rfu);
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
#endif
|
||||
+1121
File diff suppressed because it is too large
Load Diff
Executable
+284
@@ -0,0 +1,284 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* this file contains the main Bluetooth Upper Layer definitions. The Broadcom
|
||||
* implementations of L2CAP RFCOMM, SDP and the BTIf run as one GKI task. The
|
||||
* btu_task switches between them.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BTU_H
|
||||
#define BTU_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
|
||||
// HACK(zachoverflow): temporary dark magic
|
||||
#define BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK 0x1700 // didn't look used in bt_types...here goes nothing
|
||||
typedef struct {
|
||||
void (*callback)(BT_HDR *);
|
||||
} post_to_task_hack_t;
|
||||
|
||||
typedef struct {
|
||||
void (*callback)(BT_HDR *);
|
||||
BT_HDR *response;
|
||||
void *context;
|
||||
} command_complete_hack_t;
|
||||
|
||||
typedef struct {
|
||||
void (*callback)(BT_HDR *);
|
||||
uint8_t status;
|
||||
BT_HDR *command;
|
||||
void *context;
|
||||
} command_status_hack_t;
|
||||
|
||||
/* callbacks
|
||||
*/
|
||||
typedef void (*tBTU_TIMER_CALLBACK)(TIMER_LIST_ENT *p_tle);
|
||||
typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr);
|
||||
|
||||
|
||||
/* Define the timer types maintained by BTU
|
||||
*/
|
||||
#define BTU_TTYPE_BTM_DEV_CTL 1
|
||||
#define BTU_TTYPE_L2CAP_LINK 2
|
||||
#define BTU_TTYPE_L2CAP_CHNL 3
|
||||
#define BTU_TTYPE_L2CAP_HOLD 4
|
||||
#define BTU_TTYPE_SDP 5
|
||||
#define BTU_TTYPE_BTM_SCO 6
|
||||
#define BTU_TTYPE_BTM_ACL 9
|
||||
#define BTU_TTYPE_BTM_RMT_NAME 10
|
||||
#define BTU_TTYPE_RFCOMM_MFC 11
|
||||
#define BTU_TTYPE_RFCOMM_PORT 12
|
||||
#define BTU_TTYPE_TCS_L2CAP 13
|
||||
#define BTU_TTYPE_TCS_CALL 14
|
||||
#define BTU_TTYPE_TCS_WUG 15
|
||||
#define BTU_TTYPE_AUTO_SYNC 16
|
||||
#define BTU_TTYPE_CTP_RECON 17
|
||||
#define BTU_TTYPE_CTP_T100 18
|
||||
#define BTU_TTYPE_CTP_GUARD 19
|
||||
#define BTU_TTYPE_CTP_DETACH 20
|
||||
|
||||
#define BTU_TTYPE_SPP_CONN_RETRY 21
|
||||
#define BTU_TTYPE_USER_FUNC 22
|
||||
|
||||
#define BTU_TTYPE_FTP_DISC 25
|
||||
#define BTU_TTYPE_OPP_DISC 26
|
||||
|
||||
#define BTU_TTYPE_CTP_TL_DISCVY 28
|
||||
#define BTU_TTYPE_IPFRAG_TIMER 29
|
||||
#define BTU_TTYPE_HSP2_AT_CMD_TO 30
|
||||
#define BTU_TTYPE_HSP2_REPEAT_RING 31
|
||||
|
||||
#define BTU_TTYPE_CTP_GW_INIT 32
|
||||
#define BTU_TTYPE_CTP_GW_CONN 33
|
||||
#define BTU_TTYPE_CTP_GW_IDLE 35
|
||||
|
||||
#define BTU_TTYPE_ICP_L2CAP 36
|
||||
#define BTU_TTYPE_ICP_T100 37
|
||||
|
||||
#define BTU_TTYPE_HSP2_WAIT_OK 38
|
||||
|
||||
/* HCRP Timers */
|
||||
#define BTU_TTYPE_HCRP_NOTIF_REG 39
|
||||
#define BTU_TTYPE_HCRP_PROTO_RSP 40
|
||||
#define BTU_TTYPE_HCRP_CR_GRANT 41
|
||||
#define BTU_TTYPE_HCRP_CR_CHECK 42
|
||||
#define BTU_TTYPE_HCRP_W4_CLOSE 43
|
||||
|
||||
/* HCRPM Timers */
|
||||
#define BTU_TTYPE_HCRPM_NOTIF_REG 44
|
||||
#define BTU_TTYPE_HCRPM_NOTIF_KEEP 45
|
||||
#define BTU_TTYPE_HCRPM_API_RSP 46
|
||||
#define BTU_TTYPE_HCRPM_W4_OPEN 47
|
||||
#define BTU_TTYPE_HCRPM_W4_CLOSE 48
|
||||
|
||||
/* BNEP Timers */
|
||||
#define BTU_TTYPE_BNEP 50
|
||||
|
||||
#define BTU_TTYPE_HSP2_SDP_FAIL_TO 55
|
||||
#define BTU_TTYPE_HSP2_SDP_RTRY_TO 56
|
||||
|
||||
/* BTU internal */
|
||||
/* unused 60 */
|
||||
|
||||
#define BTU_TTYPE_AVDT_CCB_RET 61
|
||||
#define BTU_TTYPE_AVDT_CCB_RSP 62
|
||||
#define BTU_TTYPE_AVDT_CCB_IDLE 63
|
||||
#define BTU_TTYPE_AVDT_SCB_TC 64
|
||||
|
||||
#define BTU_TTYPE_HID_DEV_REPAGE_TO 65
|
||||
#define BTU_TTYPE_HID_HOST_REPAGE_TO 66
|
||||
|
||||
#define BTU_TTYPE_HSP2_DELAY_CKPD_RCV 67
|
||||
|
||||
#define BTU_TTYPE_SAP_TO 68
|
||||
|
||||
/* BPP Timer */
|
||||
#define BTU_TTYPE_BPP_REF_CHNL 72
|
||||
|
||||
/* LP HC idle Timer */
|
||||
#define BTU_TTYPE_LP_HC_IDLE_TO 74
|
||||
|
||||
/* Patch RAM Timer */
|
||||
#define BTU_TTYPE_PATCHRAM_TO 75
|
||||
|
||||
/* eL2CAP Info Request and other proto cmds timer */
|
||||
#define BTU_TTYPE_L2CAP_FCR_ACK 78
|
||||
#define BTU_TTYPE_L2CAP_INFO 79
|
||||
|
||||
#define BTU_TTYPE_MCA_CCB_RSP 98
|
||||
|
||||
/* BTU internal timer for BLE activity */
|
||||
#define BTU_TTYPE_BLE_INQUIRY 99
|
||||
#define BTU_TTYPE_BLE_GAP_LIM_DISC 100
|
||||
#define BTU_TTYPE_ATT_WAIT_FOR_RSP 101
|
||||
#define BTU_TTYPE_SMP_PAIRING_CMD 102
|
||||
#define BTU_TTYPE_BLE_RANDOM_ADDR 103
|
||||
#define BTU_TTYPE_ATT_WAIT_FOR_APP_RSP 104
|
||||
#define BTU_TTYPE_ATT_WAIT_FOR_IND_ACK 105
|
||||
|
||||
#define BTU_TTYPE_BLE_GAP_FAST_ADV 106
|
||||
#define BTU_TTYPE_BLE_OBSERVE 107
|
||||
|
||||
|
||||
#define BTU_TTYPE_UCD_TO 108
|
||||
|
||||
/* This is the inquiry response information held by BTU, and available
|
||||
** to applications.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
BD_ADDR remote_bd_addr;
|
||||
UINT8 page_scan_rep_mode;
|
||||
UINT8 page_scan_per_mode;
|
||||
UINT8 page_scan_mode;
|
||||
DEV_CLASS dev_class;
|
||||
UINT16 clock_offset;
|
||||
} tBTU_INQ_INFO;
|
||||
|
||||
|
||||
|
||||
#define BTU_MAX_REG_TIMER (2) /* max # timer callbacks which may register */
|
||||
#define BTU_MAX_REG_EVENT (6) /* max # event callbacks which may register */
|
||||
#define BTU_DEFAULT_DATA_SIZE (0x2a0)
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
#define BTU_DEFAULT_BLE_DATA_SIZE (27)
|
||||
#endif
|
||||
|
||||
/* structure to hold registered timers */
|
||||
typedef struct
|
||||
{
|
||||
TIMER_LIST_ENT *p_tle; /* timer entry */
|
||||
tBTU_TIMER_CALLBACK timer_cb; /* callback triggered when timer expires */
|
||||
} tBTU_TIMER_REG;
|
||||
|
||||
/* structure to hold registered event callbacks */
|
||||
typedef struct
|
||||
{
|
||||
UINT16 event_range; /* start of event range */
|
||||
tBTU_EVENT_CALLBACK event_cb; /* callback triggered when event is in range */
|
||||
} tBTU_EVENT_REG;
|
||||
|
||||
#define NFC_MAX_LOCAL_CTRLS 0
|
||||
|
||||
/* the index to BTU command queue array */
|
||||
#define NFC_CONTROLLER_ID (1)
|
||||
#define BTU_MAX_LOCAL_CTRLS (1 + NFC_MAX_LOCAL_CTRLS) /* only BR/EDR */
|
||||
|
||||
/* Define structure holding BTU variables
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
tBTU_TIMER_REG timer_reg[BTU_MAX_REG_TIMER];
|
||||
tBTU_EVENT_REG event_reg[BTU_MAX_REG_EVENT];
|
||||
|
||||
BOOLEAN reset_complete; /* TRUE after first ack from device received */
|
||||
UINT8 trace_level; /* Trace level for HCI layer */
|
||||
} tBTU_CB;
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
*/
|
||||
/* Global BTU data */
|
||||
#if BTU_DYNAMIC_MEMORY == FALSE
|
||||
extern tBTU_CB btu_cb;
|
||||
#else
|
||||
extern tBTU_CB *btu_cb_ptr;
|
||||
#define btu_cb (*btu_cb_ptr)
|
||||
#endif
|
||||
|
||||
extern const BD_ADDR BT_BD_ANY;
|
||||
|
||||
/* Functions provided by btu_task.c
|
||||
************************************
|
||||
*/
|
||||
void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
|
||||
void btu_stop_timer (TIMER_LIST_ENT *p_tle);
|
||||
void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
|
||||
void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle);
|
||||
|
||||
void btu_uipc_rx_cback(BT_HDR *p_msg);
|
||||
|
||||
/*
|
||||
** Quick Timer
|
||||
*/
|
||||
#if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0)
|
||||
void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
|
||||
void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle);
|
||||
void btu_process_quick_timer_evt (void);
|
||||
#endif
|
||||
|
||||
#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
|
||||
void btu_check_bt_sleep (void);
|
||||
#endif
|
||||
|
||||
/* Functions provided by btu_hcif.c
|
||||
************************************
|
||||
*/
|
||||
void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf);
|
||||
void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg);
|
||||
void btu_hcif_send_host_rdy_for_data(void);
|
||||
void btu_hcif_cmd_timeout (UINT8 controller_id);
|
||||
|
||||
/* Functions provided by btu_core.c
|
||||
************************************
|
||||
*/
|
||||
void btu_init_core(void);
|
||||
void btu_free_core(void);
|
||||
|
||||
void BTU_StartUp(void);
|
||||
void BTU_ShutDown(void);
|
||||
|
||||
void btu_task_start_up(void);
|
||||
void btu_task_shut_down(void);
|
||||
|
||||
UINT16 BTU_BleAclPktSize(void);
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
#endif
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef DYN_MEM_H
|
||||
#define DYN_MEM_H
|
||||
|
||||
/****************************************************************************
|
||||
** Define memory usage for each CORE component (if not defined in bdroid_buildcfg.h)
|
||||
** The default for each component is to use static memory allocations.
|
||||
*/
|
||||
#ifndef BTU_DYNAMIC_MEMORY
|
||||
#define BTU_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTM_DYNAMIC_MEMORY
|
||||
#define BTM_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SDP_DYNAMIC_MEMORY
|
||||
#define SDP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef L2C_DYNAMIC_MEMORY
|
||||
#define L2C_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef RFC_DYNAMIC_MEMORY
|
||||
#define RFC_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef TCS_DYNAMIC_MEMORY
|
||||
#define TCS_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BNEP_DYNAMIC_MEMORY
|
||||
#define BNEP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef AVDT_DYNAMIC_MEMORY
|
||||
#define AVDT_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef AVCT_DYNAMIC_MEMORY
|
||||
#define AVCT_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef MCA_DYNAMIC_MEMORY
|
||||
#define MCA_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef GATT_DYNAMIC_MEMORY
|
||||
#define GATT_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SMP_DYNAMIC_MEMORY
|
||||
#define SMP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
** Define memory usage for each PROFILE component (if not defined in bdroid_buildcfg.h)
|
||||
** The default for each component is to use static memory allocations.
|
||||
*/
|
||||
#ifndef A2D_DYNAMIC_MEMORY
|
||||
#define A2D_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef VDP_DYNAMIC_MEMORY
|
||||
#define VDP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef AVRC_DYNAMIC_MEMORY
|
||||
#define AVRC_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BIP_DYNAMIC_MEMORY
|
||||
#define BIP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BPP_DYNAMIC_MEMORY
|
||||
#define BPP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef CTP_DYNAMIC_MEMORY
|
||||
#define CTP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef FTP_DYNAMIC_MEMORY
|
||||
#define FTP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HCRP_DYNAMIC_MEMORY
|
||||
#define HCRP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HFP_DYNAMIC_MEMORY
|
||||
#define HFP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HID_DYNAMIC_MEMORY
|
||||
#define HID_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HSP2_DYNAMIC_MEMORY
|
||||
#define HSP2_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef ICP_DYNAMIC_MEMORY
|
||||
#define ICP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef OPP_DYNAMIC_MEMORY
|
||||
#define OPP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef PAN_DYNAMIC_MEMORY
|
||||
#define PAN_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SPP_DYNAMIC_MEMORY
|
||||
#define SPP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SLIP_DYNAMIC_MEMORY
|
||||
#define SLIP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef LLCP_DYNAMIC_MEMORY
|
||||
#define LLCP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
** Define memory usage for BTA (if not defined in bdroid_buildcfg.h)
|
||||
** The default for each component is to use static memory allocations.
|
||||
*/
|
||||
#ifndef BTA_DYNAMIC_MEMORY
|
||||
#define BTA_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#endif /* #ifdef DYN_MEM_H */
|
||||
|
||||
+393
@@ -0,0 +1,393 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2013 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef GAP_API_H
|
||||
#define GAP_API_H
|
||||
|
||||
#include "profiles_api.h"
|
||||
#include "btm_api.h"
|
||||
#include "l2c_api.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
/*** GAP Error and Status Codes ***/
|
||||
#define GAP_UNSUPPORTED (GAP_ERR_GRP + 0x01) /* Unsupported call */
|
||||
#define GAP_EOINQDB (GAP_ERR_GRP + 0x02) /* End of inquiry database marker */
|
||||
#define GAP_ERR_BUSY (GAP_ERR_GRP + 0x03) /* The requested function was busy */
|
||||
#define GAP_ERR_NO_CTRL_BLK (GAP_ERR_GRP + 0x04) /* No control blocks available */
|
||||
#define GAP_ERR_STARTING_CMD (GAP_ERR_GRP + 0x05) /* Error occurred while initiating the command */
|
||||
#define GAP_NO_BDADDR_REC (GAP_ERR_GRP + 0x06) /* No Inquiry DB record for BD_ADDR */
|
||||
#define GAP_ERR_ILL_MODE (GAP_ERR_GRP + 0x07) /* An illegal mode parameter was detected */
|
||||
#define GAP_ERR_ILL_INQ_TIME (GAP_ERR_GRP + 0x08) /* An illegal time parameter was detected */
|
||||
#define GAP_ERR_ILL_PARM (GAP_ERR_GRP + 0x09) /* An illegal parameter was detected */
|
||||
#define GAP_ERR_REM_NAME (GAP_ERR_GRP + 0x0a) /* Error starting the remote device name request */
|
||||
#define GAP_CMD_INITIATED (GAP_ERR_GRP + 0x0b) /* The GAP command was started (result pending) */
|
||||
#define GAP_DEVICE_NOT_UP (GAP_ERR_GRP + 0x0c) /* The device was not up; the request was not executed */
|
||||
#define GAP_BAD_BD_ADDR (GAP_ERR_GRP + 0x0d) /* The bd addr passed in was not found or invalid */
|
||||
|
||||
#define GAP_ERR_BAD_HANDLE (GAP_ERR_GRP + 0x0e) /* Bad GAP handle */
|
||||
#define GAP_ERR_BUF_OFFSET (GAP_ERR_GRP + 0x0f) /* Buffer offset invalid */
|
||||
#define GAP_ERR_BAD_STATE (GAP_ERR_GRP + 0x10) /* Connection is in invalid state */
|
||||
#define GAP_NO_DATA_AVAIL (GAP_ERR_GRP + 0x11) /* No data available */
|
||||
#define GAP_ERR_CONGESTED (GAP_ERR_GRP + 0x12) /* BT stack is congested */
|
||||
#define GAP_ERR_SECURITY (GAP_ERR_GRP + 0x13) /* Security failed */
|
||||
|
||||
#define GAP_ERR_PROCESSING (GAP_ERR_GRP + 0x14) /* General error processing BTM request */
|
||||
#define GAP_ERR_TIMEOUT (GAP_ERR_GRP + 0x15) /* Timeout occurred while processing cmd */
|
||||
#define GAP_EVT_CONN_OPENED 0x0100
|
||||
#define GAP_EVT_CONN_CLOSED 0x0101
|
||||
#define GAP_EVT_CONN_DATA_AVAIL 0x0102
|
||||
#define GAP_EVT_CONN_CONGESTED 0x0103
|
||||
#define GAP_EVT_CONN_UNCONGESTED 0x0104
|
||||
/* Values for 'chan_mode_mask' field */
|
||||
/* GAP_ConnOpen() - optional channels to negotiate */
|
||||
#define GAP_FCR_CHAN_OPT_BASIC L2CAP_FCR_CHAN_OPT_BASIC
|
||||
#define GAP_FCR_CHAN_OPT_ERTM L2CAP_FCR_CHAN_OPT_ERTM
|
||||
#define GAP_FCR_CHAN_OPT_STREAM L2CAP_FCR_CHAN_OPT_STREAM
|
||||
/*** used in connection variables and functions ***/
|
||||
#define GAP_INVALID_HANDLE 0xFFFF
|
||||
|
||||
/* This is used to change the criteria for AMP */
|
||||
#define GAP_PROTOCOL_ID (UUID_PROTOCOL_UDP)
|
||||
|
||||
|
||||
#ifndef GAP_PREFER_CONN_INT_MAX
|
||||
#define GAP_PREFER_CONN_INT_MAX BTM_BLE_CONN_INT_MIN
|
||||
#endif
|
||||
|
||||
#ifndef GAP_PREFER_CONN_INT_MIN
|
||||
#define GAP_PREFER_CONN_INT_MIN BTM_BLE_CONN_INT_MIN
|
||||
#endif
|
||||
|
||||
#ifndef GAP_PREFER_CONN_LATENCY
|
||||
#define GAP_PREFER_CONN_LATENCY 0
|
||||
#endif
|
||||
|
||||
#ifndef GAP_PREFER_CONN_SP_TOUT
|
||||
#define GAP_PREFER_CONN_SP_TOUT 2000
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
/*
|
||||
** Callback function for connection services
|
||||
*/
|
||||
typedef void (tGAP_CONN_CALLBACK) (UINT16 gap_handle, UINT16 event);
|
||||
|
||||
/*
|
||||
** Define the callback function prototypes. Parameters are specific
|
||||
** to each event and are described below
|
||||
*/
|
||||
typedef void (tGAP_CALLBACK) (UINT16 event, void *p_data);
|
||||
|
||||
|
||||
/* Definition of the GAP_FindAddrByName results structure */
|
||||
typedef struct
|
||||
{
|
||||
UINT16 status;
|
||||
BD_ADDR bd_addr;
|
||||
tBTM_BD_NAME devname;
|
||||
} tGAP_FINDADDR_RESULTS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 int_min;
|
||||
UINT16 int_max;
|
||||
UINT16 latency;
|
||||
UINT16 sp_tout;
|
||||
}tGAP_BLE_PREF_PARAM;
|
||||
|
||||
typedef union
|
||||
{
|
||||
tGAP_BLE_PREF_PARAM conn_param;
|
||||
BD_ADDR reconn_bda;
|
||||
UINT16 icon;
|
||||
UINT8 *p_dev_name;
|
||||
UINT8 addr_resolution;
|
||||
|
||||
}tGAP_BLE_ATTR_VALUE;
|
||||
|
||||
typedef void (tGAP_BLE_CMPL_CBACK)(BOOLEAN status, BD_ADDR addr, UINT16 length, char *p_name);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
|
||||
/*** Functions for L2CAP connection interface ***/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnOpen
|
||||
**
|
||||
** Description This function is called to open a generic L2CAP connection.
|
||||
**
|
||||
** Returns handle of the connection if successful, else GAP_INVALID_HANDLE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server,
|
||||
BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg,
|
||||
tL2CAP_ERTM_INFO *ertm_info,
|
||||
UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnClose
|
||||
**
|
||||
** Description This function is called to close a connection.
|
||||
**
|
||||
** Returns BT_PASS - closed OK
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnClose (UINT16 gap_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnReadData
|
||||
**
|
||||
** Description GKI buffer unaware application will call this function
|
||||
** after receiving GAP_EVT_RXDATA event. A data copy is made
|
||||
** into the receive buffer parameter.
|
||||
**
|
||||
** Returns BT_PASS - data read
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
** GAP_NO_DATA_AVAIL - no data available
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data,
|
||||
UINT16 max_len, UINT16 *p_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_GetRxQueueCnt
|
||||
**
|
||||
** Description This function return number of bytes on the rx queue.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the GAP_ConnOpen
|
||||
** p_rx_queue_count - Pointer to return queue count in.
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnBTRead
|
||||
**
|
||||
** Description GKI buffer aware applications will call this function after
|
||||
** receiving an GAP_EVT_RXDATA event to process the incoming
|
||||
** data buffer.
|
||||
**
|
||||
** Returns BT_PASS - data read
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
** GAP_NO_DATA_AVAIL - no data available
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnBTWrite
|
||||
**
|
||||
** Description GKI buffer aware applications can call this function to write data
|
||||
** by passing a pointer to the GKI buffer of data.
|
||||
**
|
||||
** Returns BT_PASS - data read
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
** GAP_ERR_BAD_STATE - connection not established
|
||||
** GAP_INVALID_BUF_OFFSET - buffer offset is invalid
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnWriteData
|
||||
**
|
||||
** Description GKI buffer unaware application will call this function
|
||||
** to send data to the connection. A data copy is made into a GKI
|
||||
** buffer.
|
||||
**
|
||||
** Returns BT_PASS - data read
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
** GAP_ERR_BAD_STATE - connection not established
|
||||
** GAP_CONGESTION - system is congested
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data,
|
||||
UINT16 max_len, UINT16 *p_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnReconfig
|
||||
**
|
||||
** Description Applications can call this function to reconfigure the connection.
|
||||
**
|
||||
** Returns BT_PASS - config process started
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnSetIdleTimeout
|
||||
**
|
||||
** Description Higher layers call this function to set the idle timeout for
|
||||
** a connection, or for all future connections. The "idle timeout"
|
||||
** is the amount of time that a connection can remain up with
|
||||
** no L2CAP channels on it. A timeout of zero means that the
|
||||
** connection will be torn down immediately when the last channel
|
||||
** is removed. A timeout of 0xFFFF means no timeout. Values are
|
||||
** in seconds.
|
||||
**
|
||||
** Returns BT_PASS - config process started
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnGetRemoteAddr
|
||||
**
|
||||
** Description This function is called to get the remote BD address
|
||||
** of a connection.
|
||||
**
|
||||
** Returns BT_PASS - closed OK
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnGetRemMtuSize
|
||||
**
|
||||
** Description Returns the remote device's MTU size.
|
||||
**
|
||||
** Returns UINT16 - maximum size buffer that can be transmitted to the peer
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnGetL2CAPCid
|
||||
**
|
||||
** Description Returns the L2CAP channel id
|
||||
**
|
||||
** Parameters: handle - Handle of the connection
|
||||
**
|
||||
** Returns UINT16 - The L2CAP channel id
|
||||
** 0, if error
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_SetTraceLevel
|
||||
**
|
||||
** Description This function sets the trace level for GAP. If called with
|
||||
** a value of 0xFF, it simply returns the current trace level.
|
||||
**
|
||||
** Returns The new or current trace level
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 GAP_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_Init
|
||||
**
|
||||
** Description Initializes the control blocks used by GAP.
|
||||
** This routine should not be called except once per
|
||||
** stack invocation.
|
||||
**
|
||||
** Returns Nothing
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void GAP_Init(void);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleAttrDBUpdate
|
||||
**
|
||||
** Description update GAP local BLE attribute database.
|
||||
**
|
||||
** Returns Nothing
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleReadPeerPrefConnParams
|
||||
**
|
||||
** Description Start a process to read a connected peripheral's preferred
|
||||
** connection parameters
|
||||
**
|
||||
** Returns TRUE if read started, else FALSE if GAP is busy
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleReadPeerDevName
|
||||
**
|
||||
** Description Start a process to read a connected peripheral's device name.
|
||||
**
|
||||
** Returns TRUE if request accepted
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_CMPL_CBACK *p_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleReadPeerAddressResolutionCap
|
||||
**
|
||||
** Description Start a process to read peer address resolution capability
|
||||
**
|
||||
** Returns TRUE if request accepted
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN GAP_BleReadPeerAddressResolutionCap (BD_ADDR peer_bda,
|
||||
tGAP_BLE_CMPL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleCancelReadPeerDevName
|
||||
**
|
||||
** Description Cancel reading a peripheral's device name.
|
||||
**
|
||||
** Returns TRUE if request accepted
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* GAP_API_H */
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2013 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef GAP_INT_H
|
||||
#define GAP_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gap_api.h"
|
||||
#include "gki.h"
|
||||
#include "gatt_api.h"
|
||||
#define GAP_MAX_BLOCKS 2 /* Concurrent GAP commands pending at a time*/
|
||||
/* Define the Generic Access Profile control structure */
|
||||
typedef struct
|
||||
{
|
||||
void *p_data; /* Pointer to any data returned in callback */
|
||||
tGAP_CALLBACK *gap_cback; /* Pointer to users callback function */
|
||||
tGAP_CALLBACK *gap_inq_rslt_cback; /* Used for inquiry results */
|
||||
UINT16 event; /* Passed back in the callback */
|
||||
UINT8 index; /* Index of this control block and callback */
|
||||
BOOLEAN in_use; /* True when structure is allocated */
|
||||
} tGAP_INFO;
|
||||
|
||||
/* Define the control block for the FindAddrByName operation (Only 1 active at a time) */
|
||||
typedef struct
|
||||
{
|
||||
tGAP_CALLBACK *p_cback;
|
||||
tBTM_INQ_INFO *p_cur_inq; /* Pointer to the current inquiry database entry */
|
||||
tGAP_FINDADDR_RESULTS results;
|
||||
BOOLEAN in_use;
|
||||
} tGAP_FINDADDR_CB;
|
||||
|
||||
/* Define the GAP Connection Control Block.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
#define GAP_CCB_STATE_IDLE 0
|
||||
#define GAP_CCB_STATE_LISTENING 1
|
||||
#define GAP_CCB_STATE_CONN_SETUP 2
|
||||
#define GAP_CCB_STATE_CFG_SETUP 3
|
||||
#define GAP_CCB_STATE_WAIT_SEC 4
|
||||
#define GAP_CCB_STATE_CONNECTED 5
|
||||
UINT8 con_state;
|
||||
|
||||
#define GAP_CCB_FLAGS_IS_ORIG 0x01
|
||||
#define GAP_CCB_FLAGS_HIS_CFG_DONE 0x02
|
||||
#define GAP_CCB_FLAGS_MY_CFG_DONE 0x04
|
||||
#define GAP_CCB_FLAGS_SEC_DONE 0x08
|
||||
#define GAP_CCB_FLAGS_CONN_DONE 0x0E
|
||||
UINT8 con_flags;
|
||||
|
||||
UINT8 service_id; /* Used by BTM */
|
||||
UINT16 gap_handle; /* GAP handle */
|
||||
UINT16 connection_id; /* L2CAP CID */
|
||||
BOOLEAN rem_addr_specified;
|
||||
UINT8 chan_mode_mask; /* Supported channel modes (FCR) */
|
||||
BD_ADDR rem_dev_address;
|
||||
UINT16 psm;
|
||||
UINT16 rem_mtu_size;
|
||||
|
||||
BOOLEAN is_congested;
|
||||
BUFFER_Q tx_queue; /* Queue of buffers waiting to be sent */
|
||||
BUFFER_Q rx_queue; /* Queue of buffers waiting to be read */
|
||||
|
||||
UINT32 rx_queue_size; /* Total data count in rx_queue */
|
||||
|
||||
tGAP_CONN_CALLBACK *p_callback; /* Users callback function */
|
||||
|
||||
tL2CAP_CFG_INFO cfg; /* Configuration */
|
||||
tL2CAP_ERTM_INFO ertm_info; /* Pools and modes for ertm */
|
||||
} tGAP_CCB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if ((defined AMP_INCLUDED) && (AMP_INCLUDED == TRUE))
|
||||
tAMP_APPL_INFO reg_info;
|
||||
#else
|
||||
tL2CAP_APPL_INFO reg_info; /* L2CAP Registration info */
|
||||
#endif
|
||||
tGAP_CCB ccb_pool[GAP_MAX_CONNECTIONS];
|
||||
} tGAP_CONN;
|
||||
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#define GAP_MAX_CHAR_NUM 4
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 handle;
|
||||
UINT16 uuid;
|
||||
tGAP_BLE_ATTR_VALUE attr_value;
|
||||
}tGAP_ATTR;
|
||||
#endif
|
||||
/**********************************************************************
|
||||
** M A I N C O N T R O L B L O C K
|
||||
***********************************************************************/
|
||||
|
||||
#define GAP_MAX_CL GATT_CL_MAX_LCB
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 uuid;
|
||||
tGAP_BLE_CMPL_CBACK *p_cback;
|
||||
} tGAP_BLE_REQ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BD_ADDR bda;
|
||||
tGAP_BLE_CMPL_CBACK *p_cback;
|
||||
UINT16 conn_id;
|
||||
UINT16 cl_op_uuid;
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN connected;
|
||||
BUFFER_Q pending_req_q;
|
||||
|
||||
}tGAP_CLCB;
|
||||
|
||||
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;
|
||||
|
||||
#if GAP_CONN_INCLUDED == TRUE
|
||||
tGAP_CONN conn;
|
||||
#endif
|
||||
|
||||
/* LE GAP attribute database */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tGAP_ATTR gatt_attr[GAP_MAX_CHAR_NUM];
|
||||
tGAP_CLCB clcb[GAP_MAX_CL]; /* connection link*/
|
||||
tGATT_IF gatt_if;
|
||||
#endif
|
||||
} tGAP_CB;
|
||||
|
||||
|
||||
extern tGAP_CB gap_cb;
|
||||
#if (GAP_CONN_INCLUDED == TRUE)
|
||||
extern void gap_conn_init(void);
|
||||
#endif
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern void gap_attr_db_init(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1189
File diff suppressed because it is too large
Load Diff
+710
@@ -0,0 +1,710 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef GATT_INT_H
|
||||
#define GATT_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
|
||||
#include "bt_trace.h"
|
||||
#include "gatt_api.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "btu.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define GATT_CREATE_CONN_ID(tcb_idx, gatt_if) ((UINT16) ((((UINT8)(tcb_idx) ) << 8) | ((UINT8) (gatt_if))))
|
||||
#define GATT_GET_TCB_IDX(conn_id) ((UINT8) (((UINT16) (conn_id)) >> 8))
|
||||
#define GATT_GET_GATT_IF(conn_id) ((tGATT_IF)((UINT8) (conn_id)))
|
||||
|
||||
#define GATT_GET_SR_REG_PTR(index) (&gatt_cb.sr_reg[(UINT8) (index)]);
|
||||
#define GATT_TRANS_ID_MAX 0x0fffffff /* 4 MSB is reserved */
|
||||
|
||||
/* security action for GATT write and read request */
|
||||
#define GATT_SEC_NONE 0
|
||||
#define GATT_SEC_OK 1
|
||||
#define GATT_SEC_SIGN_DATA 2 /* compute the signature for the write cmd */
|
||||
#define GATT_SEC_ENCRYPT 3 /* encrypt the link with current key */
|
||||
#define GATT_SEC_ENCRYPT_NO_MITM 4 /* unauthenticated encryption or better */
|
||||
#define GATT_SEC_ENCRYPT_MITM 5 /* authenticated encryption */
|
||||
#define GATT_SEC_ENC_PENDING 6 /* wait for link encryption pending */
|
||||
typedef UINT8 tGATT_SEC_ACTION;
|
||||
|
||||
|
||||
#define GATT_ATTR_OP_SPT_MTU (0x00000001 << 0)
|
||||
#define GATT_ATTR_OP_SPT_FIND_INFO (0x00000001 << 1)
|
||||
#define GATT_ATTR_OP_SPT_FIND_BY_TYPE (0x00000001 << 2)
|
||||
#define GATT_ATTR_OP_SPT_READ_BY_TYPE (0x00000001 << 3)
|
||||
#define GATT_ATTR_OP_SPT_READ (0x00000001 << 4)
|
||||
#define GATT_ATTR_OP_SPT_MULT_READ (0x00000001 << 5)
|
||||
#define GATT_ATTR_OP_SPT_READ_BLOB (0x00000001 << 6)
|
||||
#define GATT_ATTR_OP_SPT_READ_BY_GRP_TYPE (0x00000001 << 7)
|
||||
#define GATT_ATTR_OP_SPT_WRITE (0x00000001 << 8)
|
||||
#define GATT_ATTR_OP_SPT_WRITE_CMD (0x00000001 << 9)
|
||||
#define GATT_ATTR_OP_SPT_PREP_WRITE (0x00000001 << 10)
|
||||
#define GATT_ATTR_OP_SPT_EXE_WRITE (0x00000001 << 11)
|
||||
#define GATT_ATTR_OP_SPT_HDL_VALUE_CONF (0x00000001 << 12)
|
||||
#define GATT_ATTR_OP_SP_SIGN_WRITE (0x00000001 << 13)
|
||||
|
||||
#define GATT_INDEX_INVALID 0xff
|
||||
|
||||
#define GATT_PENDING_REQ_NONE 0
|
||||
|
||||
|
||||
#define GATT_WRITE_CMD_MASK 0xc0 /*0x1100-0000*/
|
||||
#define GATT_AUTH_SIGN_MASK 0x80 /*0x1000-0000*/
|
||||
#define GATT_AUTH_SIGN_LEN 12
|
||||
|
||||
#define GATT_HDR_SIZE 3 /* 1B opcode + 2B handle */
|
||||
|
||||
/* wait for ATT cmd response timeout value */
|
||||
#define GATT_WAIT_FOR_RSP_TOUT 30
|
||||
#define GATT_WAIT_FOR_DISC_RSP_TOUT 5
|
||||
#define GATT_REQ_RETRY_LIMIT 2
|
||||
|
||||
/* characteristic descriptor type */
|
||||
#define GATT_DESCR_EXT_DSCPTOR 1 /* Characteristic Extended Properties */
|
||||
#define GATT_DESCR_USER_DSCPTOR 2 /* Characteristic User Description */
|
||||
#define GATT_DESCR_CLT_CONFIG 3 /* Client Characteristic Configuration */
|
||||
#define GATT_DESCR_SVR_CONFIG 4 /* Server Characteristic Configuration */
|
||||
#define GATT_DESCR_PRES_FORMAT 5 /* Characteristic Presentation Format */
|
||||
#define GATT_DESCR_AGGR_FORMAT 6 /* Characteristic Aggregate Format */
|
||||
#define GATT_DESCR_VALID_RANGE 7 /* Characteristic Valid Range */
|
||||
#define GATT_DESCR_UNKNOWN 0xff
|
||||
|
||||
#define GATT_SEC_FLAG_LKEY_UNAUTHED BTM_SEC_FLAG_LKEY_KNOWN
|
||||
#define GATT_SEC_FLAG_LKEY_AUTHED BTM_SEC_FLAG_LKEY_AUTHED
|
||||
#define GATT_SEC_FLAG_ENCRYPTED BTM_SEC_FLAG_ENCRYPTED
|
||||
typedef UINT8 tGATT_SEC_FLAG;
|
||||
|
||||
/* Find Information Response Type
|
||||
*/
|
||||
#define GATT_INFO_TYPE_PAIR_16 0x01
|
||||
#define GATT_INFO_TYPE_PAIR_128 0x02
|
||||
|
||||
/* GATT client FIND_TYPE_VALUE_Request data */
|
||||
typedef struct
|
||||
{
|
||||
tBT_UUID uuid; /* type of attribute to be found */
|
||||
UINT16 s_handle; /* starting handle */
|
||||
UINT16 e_handle; /* ending handle */
|
||||
UINT16 value_len; /* length of the attribute value */
|
||||
UINT8 value[GATT_MAX_MTU_SIZE]; /* pointer to the attribute value to be found */
|
||||
} tGATT_FIND_TYPE_VALUE;
|
||||
|
||||
/* client request message to ATT protocol
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
tGATT_READ_BY_TYPE browse; /* read by type request */
|
||||
tGATT_FIND_TYPE_VALUE find_type_value;/* find by type value */
|
||||
tGATT_READ_MULTI read_multi; /* read multiple request */
|
||||
tGATT_READ_PARTIAL read_blob; /* read blob */
|
||||
tGATT_VALUE attr_value; /* write request */
|
||||
/* prepare write */
|
||||
/* write blob */
|
||||
UINT16 handle; /* read, handle value confirmation */
|
||||
UINT16 mtu;
|
||||
tGATT_EXEC_FLAG exec_write; /* execute write */
|
||||
}tGATT_CL_MSG;
|
||||
|
||||
/* error response strucutre */
|
||||
typedef struct
|
||||
{
|
||||
UINT16 handle;
|
||||
UINT8 cmd_code;
|
||||
UINT8 reason;
|
||||
}tGATT_ERROR;
|
||||
|
||||
/* server response message to ATT protocol
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
/* data type member event */
|
||||
tGATT_VALUE attr_value; /* READ, HANDLE_VALUE_IND, PREPARE_WRITE */
|
||||
/* READ_BLOB, READ_BY_TYPE */
|
||||
tGATT_ERROR error; /* ERROR_RSP */
|
||||
UINT16 handle; /* WRITE, WRITE_BLOB */
|
||||
UINT16 mtu; /* exchange MTU request */
|
||||
} tGATT_SR_MSG;
|
||||
|
||||
/* Characteristic declaration attribute value
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
tGATT_CHAR_PROP property;
|
||||
UINT16 char_val_handle;
|
||||
} tGATT_CHAR_DECL;
|
||||
|
||||
/* attribute value maintained in the server database
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
tBT_UUID uuid; /* service declaration */
|
||||
tGATT_CHAR_DECL char_decl; /* characteristic declaration */
|
||||
tGATT_INCL_SRVC incl_handle; /* included service */
|
||||
|
||||
} tGATT_ATTR_VALUE;
|
||||
|
||||
/* Attribute UUID type
|
||||
*/
|
||||
#define GATT_ATTR_UUID_TYPE_16 0
|
||||
#define GATT_ATTR_UUID_TYPE_128 1
|
||||
#define GATT_ATTR_UUID_TYPE_32 2
|
||||
typedef UINT8 tGATT_ATTR_UUID_TYPE;
|
||||
|
||||
/* 16 bits UUID Attribute in server database
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void *p_next; /* pointer to the next attribute,
|
||||
either tGATT_ATTR16 or tGATT_ATTR128 */
|
||||
tGATT_ATTR_VALUE *p_value;
|
||||
tGATT_ATTR_UUID_TYPE uuid_type;
|
||||
tGATT_PERM permission;
|
||||
UINT16 handle;
|
||||
UINT16 uuid;
|
||||
} tGATT_ATTR16;
|
||||
|
||||
/* 32 bits UUID Attribute in server database
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void *p_next; /* pointer to the next attribute,
|
||||
either tGATT_ATTR16, tGATT_ATTR32 or tGATT_ATTR128 */
|
||||
tGATT_ATTR_VALUE *p_value;
|
||||
tGATT_ATTR_UUID_TYPE uuid_type;
|
||||
tGATT_PERM permission;
|
||||
UINT16 handle;
|
||||
UINT32 uuid;
|
||||
} tGATT_ATTR32;
|
||||
|
||||
|
||||
/* 128 bits UUID Attribute in server database
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void *p_next; /* pointer to the next attribute,
|
||||
either tGATT_ATTR16 or tGATT_ATTR128 */
|
||||
tGATT_ATTR_VALUE *p_value;
|
||||
tGATT_ATTR_UUID_TYPE uuid_type;
|
||||
tGATT_PERM permission;
|
||||
UINT16 handle;
|
||||
UINT8 uuid[LEN_UUID_128];
|
||||
} tGATT_ATTR128;
|
||||
|
||||
/* Service Database definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void *p_attr_list; /* pointer to the first attribute,
|
||||
either tGATT_ATTR16 or tGATT_ATTR128 */
|
||||
UINT8 *p_free_mem; /* Pointer to free memory */
|
||||
BUFFER_Q svc_buffer; /* buffer queue used for service database */
|
||||
UINT32 mem_free; /* Memory still available */
|
||||
UINT16 end_handle; /* Last handle number */
|
||||
UINT16 next_handle; /* Next usable handle value */
|
||||
} tGATT_SVC_DB;
|
||||
|
||||
/* Data Structure used for GATT server */
|
||||
/* A GATT registration record consists of a handle, and 1 or more attributes */
|
||||
/* A service registration information record consists of beginning and ending */
|
||||
/* attribute handle, service UUID and a set of GATT server callback. */
|
||||
typedef struct
|
||||
{
|
||||
tGATT_SVC_DB *p_db; /* pointer to the service database */
|
||||
tBT_UUID app_uuid; /* applicatino UUID */
|
||||
UINT32 sdp_handle; /* primamry service SDP handle */
|
||||
UINT16 service_instance; /* service instance number */
|
||||
UINT16 type; /* service type UUID, primary or secondary */
|
||||
UINT16 s_hdl; /* service starting handle */
|
||||
UINT16 e_hdl; /* service ending handle */
|
||||
tGATT_IF gatt_if; /* this service is belong to which application */
|
||||
BOOLEAN in_use;
|
||||
} tGATT_SR_REG;
|
||||
|
||||
#define GATT_LISTEN_TO_ALL 0xff
|
||||
#define GATT_LISTEN_TO_NONE 0
|
||||
|
||||
/* Data Structure used for GATT server */
|
||||
/* An GATT registration record consists of a handle, and 1 or more attributes */
|
||||
/* A service registration information record consists of beginning and ending */
|
||||
/* attribute handle, service UUID and a set of GATT server callback. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tBT_UUID app_uuid128;
|
||||
tGATT_CBACK app_cb;
|
||||
tGATT_IF gatt_if; /* one based */
|
||||
BOOLEAN in_use;
|
||||
UINT8 listening; /* if adv for all has been enabled */
|
||||
} tGATT_REG;
|
||||
|
||||
|
||||
|
||||
|
||||
/* command queue for each connection */
|
||||
typedef struct
|
||||
{
|
||||
BT_HDR *p_cmd;
|
||||
UINT16 clcb_idx;
|
||||
UINT8 op_code;
|
||||
BOOLEAN to_send;
|
||||
}tGATT_CMD_Q;
|
||||
|
||||
|
||||
#if GATT_MAX_SR_PROFILES <= 8
|
||||
typedef UINT8 tGATT_APP_MASK;
|
||||
#elif GATT_MAX_SR_PROFILES <= 16
|
||||
typedef UINT16 tGATT_APP_MASK;
|
||||
#elif GATT_MAX_SR_PROFILES <= 32
|
||||
typedef UINT32 tGATT_APP_MASK;
|
||||
#endif
|
||||
|
||||
/* command details for each connection */
|
||||
typedef struct
|
||||
{
|
||||
BT_HDR *p_rsp_msg;
|
||||
UINT32 trans_id;
|
||||
tGATT_READ_MULTI multi_req;
|
||||
BUFFER_Q multi_rsp_q;
|
||||
UINT16 handle;
|
||||
UINT8 op_code;
|
||||
UINT8 status;
|
||||
UINT8 cback_cnt[GATT_MAX_APPS];
|
||||
} tGATT_SR_CMD;
|
||||
|
||||
#define GATT_CH_CLOSE 0
|
||||
#define GATT_CH_CLOSING 1
|
||||
#define GATT_CH_CONN 2
|
||||
#define GATT_CH_CFG 3
|
||||
#define GATT_CH_OPEN 4
|
||||
|
||||
typedef UINT8 tGATT_CH_STATE;
|
||||
|
||||
#define GATT_GATT_START_HANDLE 1
|
||||
#define GATT_GAP_START_HANDLE 20
|
||||
#define GATT_APP_START_HANDLE 40
|
||||
|
||||
typedef struct hdl_cfg
|
||||
{
|
||||
UINT16 gatt_start_hdl;
|
||||
UINT16 gap_start_hdl;
|
||||
UINT16 app_start_hdl;
|
||||
}tGATT_HDL_CFG;
|
||||
|
||||
typedef struct hdl_list_elem
|
||||
{
|
||||
struct hdl_list_elem *p_next;
|
||||
struct hdl_list_elem *p_prev;
|
||||
tGATTS_HNDL_RANGE asgn_range; /* assigned handle range */
|
||||
tGATT_SVC_DB svc_db;
|
||||
BOOLEAN in_use;
|
||||
}tGATT_HDL_LIST_ELEM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tGATT_HDL_LIST_ELEM *p_first;
|
||||
tGATT_HDL_LIST_ELEM *p_last;
|
||||
UINT16 count;
|
||||
}tGATT_HDL_LIST_INFO;
|
||||
|
||||
|
||||
typedef struct srv_list_elem
|
||||
{
|
||||
struct srv_list_elem *p_next;
|
||||
struct srv_list_elem *p_prev;
|
||||
UINT16 s_hdl;
|
||||
UINT8 i_sreg;
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN is_primary;
|
||||
}tGATT_SRV_LIST_ELEM;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tGATT_SRV_LIST_ELEM *p_last_primary;
|
||||
tGATT_SRV_LIST_ELEM *p_first;
|
||||
tGATT_SRV_LIST_ELEM *p_last;
|
||||
UINT16 count;
|
||||
}tGATT_SRV_LIST_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BUFFER_Q pending_enc_clcb; /* pending encryption channel q */
|
||||
tGATT_SEC_ACTION sec_act;
|
||||
BD_ADDR peer_bda;
|
||||
tBT_TRANSPORT transport;
|
||||
UINT32 trans_id;
|
||||
|
||||
UINT16 att_lcid; /* L2CAP channel ID for ATT */
|
||||
UINT16 payload_size;
|
||||
|
||||
tGATT_CH_STATE ch_state;
|
||||
UINT8 ch_flags;
|
||||
|
||||
tGATT_IF app_hold_link[GATT_MAX_APPS];
|
||||
|
||||
/* server needs */
|
||||
/* server response data */
|
||||
tGATT_SR_CMD sr_cmd;
|
||||
UINT16 indicate_handle;
|
||||
BUFFER_Q pending_ind_q;
|
||||
|
||||
TIMER_LIST_ENT conf_timer_ent; /* peer confirm to indication timer */
|
||||
|
||||
UINT8 prep_cnt[GATT_MAX_APPS];
|
||||
UINT8 ind_count;
|
||||
|
||||
tGATT_CMD_Q cl_cmd_q[GATT_CL_MAX_LCB];
|
||||
TIMER_LIST_ENT ind_ack_timer_ent; /* local app confirm to indication timer */
|
||||
UINT8 pending_cl_req;
|
||||
UINT8 next_slot_inq; /* index of next available slot in queue */
|
||||
|
||||
BOOLEAN in_use;
|
||||
UINT8 tcb_idx;
|
||||
} tGATT_TCB;
|
||||
|
||||
|
||||
/* logic channel */
|
||||
typedef struct
|
||||
{
|
||||
UINT16 next_disc_start_hdl; /* starting handle for the next inc srvv discovery */
|
||||
tGATT_DISC_RES result;
|
||||
BOOLEAN wait_for_read_rsp;
|
||||
} tGATT_READ_INC_UUID128;
|
||||
typedef struct
|
||||
{
|
||||
tGATT_TCB *p_tcb; /* associated TCB of this CLCB */
|
||||
tGATT_REG *p_reg; /* owner of this CLCB */
|
||||
UINT8 sccb_idx;
|
||||
UINT8 *p_attr_buf; /* attribute buffer for read multiple, prepare write */
|
||||
tBT_UUID uuid;
|
||||
UINT16 conn_id; /* connection handle */
|
||||
UINT16 clcb_idx;
|
||||
UINT16 s_handle; /* starting handle of the active request */
|
||||
UINT16 e_handle; /* ending handle of the active request */
|
||||
UINT16 counter; /* used as offset, attribute length, num of prepare write */
|
||||
UINT16 start_offset;
|
||||
tGATT_AUTH_REQ auth_req; /* authentication requirement */
|
||||
UINT8 operation; /* one logic channel can have one operation active */
|
||||
UINT8 op_subtype; /* operation subtype */
|
||||
UINT8 status; /* operation status */
|
||||
BOOLEAN first_read_blob_after_read;
|
||||
tGATT_READ_INC_UUID128 read_uuid128;
|
||||
BOOLEAN in_use;
|
||||
TIMER_LIST_ENT rsp_timer_ent; /* peer response timer */
|
||||
UINT8 retry_count;
|
||||
|
||||
} tGATT_CLCB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tGATT_CLCB *p_clcb;
|
||||
}tGATT_PENDING_ENC_CLCB;
|
||||
|
||||
|
||||
#define GATT_SIGN_WRITE 1
|
||||
#define GATT_VERIFY_SIGN_DATA 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BT_HDR hdr;
|
||||
tGATT_CLCB *p_clcb;
|
||||
}tGATT_SIGN_WRITE_OP;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BT_HDR hdr;
|
||||
tGATT_TCB *p_tcb;
|
||||
BT_HDR *p_data;
|
||||
|
||||
}tGATT_VERIFY_SIGN_OP;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 clcb_idx;
|
||||
BOOLEAN in_use;
|
||||
} tGATT_SCCB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 handle;
|
||||
UINT16 uuid;
|
||||
UINT32 service_change;
|
||||
}tGATT_SVC_CHG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tGATT_IF gatt_if[GATT_MAX_APPS];
|
||||
tGATT_IF listen_gif[GATT_MAX_APPS];
|
||||
BD_ADDR remote_bda;
|
||||
BOOLEAN in_use;
|
||||
}tGATT_BG_CONN_DEV;
|
||||
|
||||
#define GATT_SVC_CHANGED_CONNECTING 1 /* wait for connection */
|
||||
#define GATT_SVC_CHANGED_SERVICE 2 /* GATT service discovery */
|
||||
#define GATT_SVC_CHANGED_CHARACTERISTIC 3 /* service change char discovery */
|
||||
#define GATT_SVC_CHANGED_DESCRIPTOR 4 /* service change CCC discoery */
|
||||
#define GATT_SVC_CHANGED_CONFIGURE_CCCD 5 /* config CCC */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 conn_id;
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN connected;
|
||||
BD_ADDR bda;
|
||||
tBT_TRANSPORT transport;
|
||||
|
||||
/* GATT service change CCC related variables */
|
||||
UINT8 ccc_stage;
|
||||
UINT8 ccc_result;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle;
|
||||
}tGATT_PROFILE_CLCB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tGATT_TCB tcb[GATT_MAX_PHY_CHANNEL];
|
||||
BUFFER_Q sign_op_queue;
|
||||
|
||||
tGATT_SR_REG sr_reg[GATT_MAX_SR_PROFILES];
|
||||
UINT16 next_handle; /* next available handle */
|
||||
tGATT_SVC_CHG gattp_attr; /* GATT profile attribute service change */
|
||||
tGATT_IF gatt_if;
|
||||
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];
|
||||
|
||||
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];
|
||||
tGATT_CLCB clcb[GATT_CL_MAX_LCB]; /* connection link control block*/
|
||||
tGATT_SCCB sccb[GATT_MAX_SCCB]; /* sign complete callback function GATT_MAX_SCCB <= GATT_CL_MAX_LCB */
|
||||
UINT8 trace_level;
|
||||
UINT16 def_mtu_size;
|
||||
|
||||
#if GATT_CONFORMANCE_TESTING == TRUE
|
||||
BOOLEAN enable_err_rsp;
|
||||
UINT8 req_op_code;
|
||||
UINT8 err_status;
|
||||
UINT16 handle;
|
||||
#endif
|
||||
|
||||
tGATT_PROFILE_CLCB profile_clcb[GATT_MAX_APPS];
|
||||
UINT16 handle_of_h_r; /* Handle of the handles reused characteristic value */
|
||||
|
||||
tGATT_APPL_INFO cb_info;
|
||||
|
||||
|
||||
|
||||
tGATT_HDL_CFG hdl_cfg;
|
||||
tGATT_BG_CONN_DEV bgconn_dev[GATT_MAX_BG_CONN_DEV];
|
||||
|
||||
} tGATT_CB;
|
||||
|
||||
|
||||
#define GATT_SIZE_OF_SRV_CHG_HNDL_RANGE 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Global GATT data */
|
||||
#if GATT_DYNAMIC_MEMORY == FALSE
|
||||
extern tGATT_CB gatt_cb;
|
||||
#else
|
||||
extern tGATT_CB *gatt_cb_ptr;
|
||||
#define gatt_cb (*gatt_cb_ptr)
|
||||
#endif
|
||||
|
||||
#if GATT_CONFORMANCE_TESTING == TRUE
|
||||
extern void gatt_set_err_rsp(BOOLEAN enable, UINT8 req_op_code, UINT8 err_status);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* internal functions */
|
||||
extern void gatt_init (void);
|
||||
extern void gatt_free(void);
|
||||
|
||||
/* from gatt_main.c */
|
||||
extern BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb);
|
||||
extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT transport);
|
||||
extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tGATT_TCB *p_tcb, tBT_TRANSPORT transport);
|
||||
extern void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf);
|
||||
extern void gatt_update_app_use_link_flag ( tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link);
|
||||
|
||||
extern void gatt_profile_db_init(void);
|
||||
extern void gatt_set_ch_state(tGATT_TCB *p_tcb, tGATT_CH_STATE ch_state);
|
||||
extern tGATT_CH_STATE gatt_get_ch_state(tGATT_TCB *p_tcb);
|
||||
extern void gatt_init_srv_chg(void);
|
||||
extern void gatt_proc_srv_chg (void);
|
||||
extern void gatt_send_srv_chg_ind (BD_ADDR peer_bda);
|
||||
extern void gatt_chk_srv_chg(tGATTS_SRV_CHG *p_srv_chg_clt);
|
||||
extern void gatt_add_a_bonded_dev_for_srv_chg (BD_ADDR bda);
|
||||
|
||||
/* from gatt_attr.c */
|
||||
extern UINT16 gatt_profile_find_conn_id_by_bd_addr(BD_ADDR bda);
|
||||
|
||||
|
||||
/* Functions provided by att_protocol.c */
|
||||
extern tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code, tGATT_CL_MSG *p_msg);
|
||||
extern BT_HDR *attp_build_sr_msg(tGATT_TCB *p_tcb, UINT8 op_code, tGATT_SR_MSG *p_msg);
|
||||
extern tGATT_STATUS attp_send_sr_msg (tGATT_TCB *p_tcb, BT_HDR *p_msg);
|
||||
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);
|
||||
extern UINT32 gatt_add_sdp_record (tBT_UUID *p_uuid, UINT16 start_hdl, UINT16 end_hdl);
|
||||
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);
|
||||
extern void gatt_convert_uuid32_to_uuid128(UINT8 uuid_128[LEN_UUID_128], UINT32 uuid_32);
|
||||
extern void gatt_sr_get_sec_info(BD_ADDR rem_bda, tBT_TRANSPORT transport, UINT8 *p_sec_flag, UINT8 *p_key_size);
|
||||
extern void gatt_start_rsp_timer(UINT16 clcb_idx);
|
||||
extern void gatt_start_conf_timer(tGATT_TCB *p_tcb);
|
||||
extern void gatt_rsp_timeout(TIMER_LIST_ENT *p_tle);
|
||||
extern void gatt_ind_ack_timeout(TIMER_LIST_ENT *p_tle);
|
||||
extern void gatt_start_ind_ack_timer(tGATT_TCB *p_tcb);
|
||||
extern tGATT_STATUS gatt_send_error_rsp(tGATT_TCB *p_tcb, UINT8 err_code, UINT8 op_code, UINT16 handle, BOOLEAN deq);
|
||||
extern void gatt_dbg_display_uuid(tBT_UUID bt_uuid);
|
||||
extern tGATT_PENDING_ENC_CLCB* gatt_add_pending_enc_channel_clcb(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb );
|
||||
|
||||
extern tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst);
|
||||
|
||||
extern BOOLEAN gatt_is_srv_chg_ind_pending (tGATT_TCB *p_tcb);
|
||||
extern tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda);
|
||||
|
||||
extern BOOLEAN gatt_find_the_connected_bda(UINT8 start_idx, BD_ADDR bda, UINT8 *p_found_idx, tBT_TRANSPORT *p_transport);
|
||||
extern void gatt_set_srv_chg(void);
|
||||
extern void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr);
|
||||
extern tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB *p_tcb, tGATT_VALUE *p_ind);
|
||||
extern tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start( tGATTS_HNDL_RANGE *p_new_srv_start);
|
||||
extern void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id);
|
||||
extern BOOLEAN gatt_update_listen_mode(void);
|
||||
extern BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb);
|
||||
|
||||
/* reserved handle list */
|
||||
extern tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_app_id (tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst);
|
||||
extern tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_handle(UINT16 handle);
|
||||
extern tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void);
|
||||
extern void gatt_free_hdl_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);
|
||||
extern BOOLEAN gatt_remove_a_srv_from_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM *p_remove);
|
||||
extern BOOLEAN gatt_add_an_item_to_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELEM *p_new);
|
||||
extern BOOLEAN gatt_remove_an_item_from_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELEM *p_remove);
|
||||
extern tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg);
|
||||
|
||||
/* for background connection */
|
||||
extern BOOLEAN gatt_update_auto_connect_dev (tGATT_IF gatt_if, BOOLEAN add, BD_ADDR bd_addr, BOOLEAN is_initiator);
|
||||
extern BOOLEAN gatt_is_bg_dev_for_app(tGATT_BG_CONN_DEV *p_dev, tGATT_IF gatt_if);
|
||||
extern BOOLEAN gatt_remove_bg_dev_for_app(tGATT_IF gatt_if, BD_ADDR bd_addr);
|
||||
extern UINT8 gatt_get_num_apps_for_bg_dev(BD_ADDR bd_addr);
|
||||
extern BOOLEAN gatt_find_app_for_bg_dev(BD_ADDR bd_addr, tGATT_IF *p_gatt_if);
|
||||
extern tGATT_BG_CONN_DEV * gatt_find_bg_dev(BD_ADDR remote_bda);
|
||||
extern void gatt_deregister_bgdev_list(tGATT_IF gatt_if);
|
||||
extern void gatt_reset_bgdev_list(void);
|
||||
|
||||
/* server function */
|
||||
extern UINT8 gatt_sr_find_i_rcb_by_handle(UINT16 handle);
|
||||
extern UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst);
|
||||
extern UINT8 gatt_sr_alloc_rcb(tGATT_HDL_LIST_ELEM *p_list);
|
||||
extern tGATT_STATUS gatt_sr_process_app_rsp (tGATT_TCB *p_tcb, tGATT_IF gatt_if, UINT32 trans_id, UINT8 op_code, tGATT_STATUS status, tGATTS_RSP *p_msg);
|
||||
extern void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
|
||||
UINT16 len, UINT8 *p_data);
|
||||
extern void gatt_sr_send_req_callback(UINT16 conn_id, UINT32 trans_id,
|
||||
UINT8 op_code, tGATTS_DATA *p_req_data);
|
||||
extern UINT32 gatt_sr_enqueue_cmd (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 handle);
|
||||
extern BOOLEAN gatt_cancel_open(tGATT_IF gatt_if, BD_ADDR bda);
|
||||
|
||||
/* */
|
||||
|
||||
extern tGATT_REG *gatt_get_regcb (tGATT_IF gatt_if);
|
||||
extern BOOLEAN gatt_is_clcb_allocated (UINT16 conn_id);
|
||||
extern tGATT_CLCB *gatt_clcb_alloc (UINT16 conn_id);
|
||||
extern void gatt_clcb_dealloc (tGATT_CLCB *p_clcb);
|
||||
|
||||
extern void gatt_sr_copy_prep_cnt_to_cback_cnt(tGATT_TCB *p_tcb );
|
||||
extern BOOLEAN gatt_sr_is_cback_cnt_zero(tGATT_TCB *p_tcb );
|
||||
extern BOOLEAN gatt_sr_is_prep_cnt_zero(tGATT_TCB *p_tcb );
|
||||
extern void gatt_sr_reset_cback_cnt(tGATT_TCB *p_tcb );
|
||||
extern void gatt_sr_reset_prep_cnt(tGATT_TCB *p_tcb );
|
||||
extern void gatt_sr_update_cback_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc, BOOLEAN is_reset_first);
|
||||
extern void gatt_sr_update_prep_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc, BOOLEAN is_reset_first);
|
||||
|
||||
extern BOOLEAN gatt_find_app_hold_link(tGATT_TCB *p_tcb, UINT8 start_idx, UINT8 *p_found_idx, tGATT_IF *p_gatt_if);
|
||||
extern UINT8 gatt_num_apps_hold_link(tGATT_TCB *p_tcb);
|
||||
extern UINT8 gatt_num_clcb_by_bd_addr(BD_ADDR bda);
|
||||
extern tGATT_TCB * gatt_find_tcb_by_cid(UINT16 lcid);
|
||||
extern tGATT_TCB * gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport);
|
||||
extern tGATT_TCB * gatt_get_tcb_by_idx(UINT8 tcb_idx);
|
||||
extern tGATT_TCB * gatt_find_tcb_by_addr(BD_ADDR bda, tBT_TRANSPORT transport);
|
||||
extern BOOLEAN gatt_send_ble_burst_data (BD_ADDR remote_bda, BT_HDR *p_buf);
|
||||
|
||||
/* GATT client functions */
|
||||
extern void gatt_dequeue_sr_cmd (tGATT_TCB *p_tcb);
|
||||
extern UINT8 gatt_send_write_msg(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code, UINT16 handle,
|
||||
UINT16 len, UINT16 offset, UINT8 *p_data);
|
||||
extern void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport);
|
||||
extern void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_data);
|
||||
|
||||
extern void gatt_act_discovery(tGATT_CLCB *p_clcb);
|
||||
extern void gatt_act_read(tGATT_CLCB *p_clcb, UINT16 offset);
|
||||
extern void gatt_act_write(tGATT_CLCB *p_clcb, UINT8 sec_act);
|
||||
extern UINT8 gatt_act_send_browse(tGATT_TCB *p_tcb, UINT16 index, UINT8 op, UINT16 s_handle, UINT16 e_handle,
|
||||
tBT_UUID uuid);
|
||||
extern tGATT_CLCB *gatt_cmd_dequeue(tGATT_TCB *p_tcb, UINT8 *p_opcode);
|
||||
extern BOOLEAN gatt_cmd_enq(tGATT_TCB *p_tcb, UINT16 clcb_idx, BOOLEAN to_send, UINT8 op_code, BT_HDR *p_buf);
|
||||
extern void gatt_client_handle_server_rsp (tGATT_TCB *p_tcb, UINT8 op_code,
|
||||
UINT16 len, UINT8 *p_data);
|
||||
extern void gatt_send_queue_write_cancel (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, tGATT_EXEC_FLAG flag);
|
||||
|
||||
/* gatt_auth.c */
|
||||
extern BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb);
|
||||
extern void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf);
|
||||
extern tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb );
|
||||
extern tGATT_STATUS gatt_get_link_encrypt_status(tGATT_TCB *p_tcb);
|
||||
extern tGATT_SEC_ACTION gatt_get_sec_act(tGATT_TCB *p_tcb);
|
||||
extern void gatt_set_sec_act(tGATT_TCB *p_tcb, tGATT_SEC_ACTION sec_act);
|
||||
|
||||
/* gatt_db.c */
|
||||
extern BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID *p_service, BOOLEAN is_pri, UINT16 s_hdl, UINT16 num_handle);
|
||||
extern UINT16 gatts_add_included_service (tGATT_SVC_DB *p_db, UINT16 s_handle, UINT16 e_handle, tBT_UUID service);
|
||||
extern UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm, tGATT_CHAR_PROP property, tBT_UUID *p_char_uuid);
|
||||
extern UINT16 gatts_add_char_descr (tGATT_SVC_DB *p_db, tGATT_PERM perm, tBT_UUID *p_dscp_uuid);
|
||||
extern tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb, tGATT_SVC_DB *p_db, UINT8 op_code, BT_HDR *p_rsp, UINT16 s_handle,
|
||||
UINT16 e_handle, tBT_UUID type, UINT16 *p_len, tGATT_SEC_FLAG sec_flag, UINT8 key_size,UINT32 trans_id, UINT16 *p_cur_handle);
|
||||
extern tGATT_STATUS gatts_read_attr_value_by_handle(tGATT_TCB *p_tcb,tGATT_SVC_DB *p_db, UINT8 op_code, UINT16 handle, UINT16 offset,
|
||||
UINT8 *p_value, UINT16 *p_len, UINT16 mtu,tGATT_SEC_FLAG sec_flag,UINT8 key_size,UINT32 trans_id);
|
||||
extern tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,UINT16 handle, UINT16 offset, UINT8 *p_data,
|
||||
UINT16 len, tGATT_SEC_FLAG sec_flag, UINT8 key_size);
|
||||
extern tGATT_STATUS gatts_read_attr_perm_check(tGATT_SVC_DB *p_db, BOOLEAN is_long, UINT16 handle, tGATT_SEC_FLAG sec_flag,UINT8 key_size);
|
||||
extern void gatts_update_srv_list_elem(UINT8 i_sreg, UINT16 handle, BOOLEAN is_primary);
|
||||
extern tBT_UUID * gatts_get_service_uuid (tGATT_SVC_DB *p_db);
|
||||
|
||||
extern void gatt_reset_bgdev_list(void);
|
||||
#endif
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains internally used ATT definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GATTDEFS_H
|
||||
#define _GATTDEFS_H
|
||||
|
||||
#define GATT_ILLEGAL_UUID 0
|
||||
|
||||
/* GATT attribute types
|
||||
*/
|
||||
#define GATT_UUID_PRI_SERVICE 0x2800
|
||||
#define GATT_UUID_SEC_SERVICE 0x2801
|
||||
#define GATT_UUID_INCLUDE_SERVICE 0x2802
|
||||
#define GATT_UUID_CHAR_DECLARE 0x2803 /* Characteristic Declaration*/
|
||||
|
||||
#define GATT_UUID_CHAR_EXT_PROP 0x2900 /* Characteristic Extended Properties */
|
||||
#define GATT_UUID_CHAR_DESCRIPTION 0x2901 /* Characteristic User Description*/
|
||||
#define GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */
|
||||
#define GATT_UUID_CHAR_SRVR_CONFIG 0x2903 /* Server Characteristic Configuration */
|
||||
#define GATT_UUID_CHAR_PRESENT_FORMAT 0x2904 /* Characteristic Presentation Format*/
|
||||
#define GATT_UUID_CHAR_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
|
||||
#define GATT_UUID_CHAR_VALID_RANGE 0x2906 /* Characteristic Valid Range */
|
||||
#define GATT_UUID_EXT_RPT_REF_DESCR 0x2907
|
||||
#define GATT_UUID_RPT_REF_DESCR 0x2908
|
||||
|
||||
|
||||
/* GAP Profile Attributes
|
||||
*/
|
||||
#define GATT_UUID_GAP_DEVICE_NAME 0x2A00
|
||||
#define GATT_UUID_GAP_ICON 0x2A01
|
||||
#define GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
|
||||
#define GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6
|
||||
|
||||
/* Attribute Profile Attribute UUID */
|
||||
#define GATT_UUID_GATT_SRV_CHGD 0x2A05
|
||||
/* Attribute Protocol Test */
|
||||
|
||||
/* Link Loss Service */
|
||||
#define GATT_UUID_ALERT_LEVEL 0x2A06 /* Alert Level */
|
||||
#define GATT_UUID_TX_POWER_LEVEL 0x2A07 /* TX power level */
|
||||
|
||||
/* Time Profile */
|
||||
/* Current Time Service */
|
||||
#define GATT_UUID_CURRENT_TIME 0x2A2B /* Current Time */
|
||||
#define GATT_UUID_LOCAL_TIME_INFO 0x2A0F /* Local time info */
|
||||
#define GATT_UUID_REF_TIME_INFO 0x2A14 /* reference time information */
|
||||
|
||||
/* NwA Profile */
|
||||
#define GATT_UUID_NW_STATUS 0x2A18 /* network availability status */
|
||||
#define GATT_UUID_NW_TRIGGER 0x2A1A /* Network availability trigger */
|
||||
|
||||
/* phone alert */
|
||||
#define GATT_UUID_ALERT_STATUS 0x2A3F /* alert status */
|
||||
#define GATT_UUID_RINGER_CP 0x2A40 /* ringer control point */
|
||||
#define GATT_UUID_RINGER_SETTING 0x2A41 /* ringer setting */
|
||||
|
||||
/* Glucose Service */
|
||||
#define GATT_UUID_GM_MEASUREMENT 0x2A18
|
||||
#define GATT_UUID_GM_CONTEXT 0x2A34
|
||||
#define GATT_UUID_GM_CONTROL_POINT 0x2A52
|
||||
#define GATT_UUID_GM_FEATURE 0x2A51
|
||||
|
||||
/* device infor characteristic */
|
||||
#define GATT_UUID_SYSTEM_ID 0x2A23
|
||||
#define GATT_UUID_MODEL_NUMBER_STR 0x2A24
|
||||
#define GATT_UUID_SERIAL_NUMBER_STR 0x2A25
|
||||
#define GATT_UUID_FW_VERSION_STR 0x2A26
|
||||
#define GATT_UUID_HW_VERSION_STR 0x2A27
|
||||
#define GATT_UUID_SW_VERSION_STR 0x2A28
|
||||
#define GATT_UUID_MANU_NAME 0x2A29
|
||||
#define GATT_UUID_IEEE_DATA 0x2A2A
|
||||
#define GATT_UUID_PNP_ID 0x2A50
|
||||
|
||||
/* HID characteristics */
|
||||
#define GATT_UUID_HID_INFORMATION 0x2A4A
|
||||
#define GATT_UUID_HID_REPORT_MAP 0x2A4B
|
||||
#define GATT_UUID_HID_CONTROL_POINT 0x2A4C
|
||||
#define GATT_UUID_HID_REPORT 0x2A4D
|
||||
#define GATT_UUID_HID_PROTO_MODE 0x2A4E
|
||||
#define GATT_UUID_HID_BT_KB_INPUT 0x2A22
|
||||
#define GATT_UUID_HID_BT_KB_OUTPUT 0x2A32
|
||||
#define GATT_UUID_HID_BT_MOUSE_INPUT 0x2A33
|
||||
|
||||
/* Battery Service char */
|
||||
#define GATT_UUID_BATTERY_LEVEL 0x2A19
|
||||
|
||||
#define GATT_UUID_SC_CONTROL_POINT 0x2A55
|
||||
#define GATT_UUID_SENSOR_LOCATION 0x2A5D
|
||||
|
||||
/* RUNNERS SPEED AND CADENCE SERVICE */
|
||||
#define GATT_UUID_RSC_MEASUREMENT 0x2A53
|
||||
#define GATT_UUID_RSC_FEATURE 0x2A54
|
||||
|
||||
/* CYCLING SPEED AND CADENCE SERVICE */
|
||||
#define GATT_UUID_CSC_MEASUREMENT 0x2A5B
|
||||
#define GATT_UUID_CSC_FEATURE 0x2A5C
|
||||
|
||||
|
||||
/* Scan Parameter charatceristics */
|
||||
#define GATT_UUID_SCAN_INT_WINDOW 0x2A4F
|
||||
#define GATT_UUID_SCAN_REFRESH 0x2A31
|
||||
|
||||
#endif
|
||||
+2606
File diff suppressed because it is too large
Load Diff
+811
@@ -0,0 +1,811 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef HCIMSGS_H
|
||||
#define HCIMSGS_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "hcidefs.h"
|
||||
#include "bt_types.h"
|
||||
|
||||
void bte_main_hci_send(BT_HDR *p_msg, UINT16 event);
|
||||
void bte_main_lpm_allow_bt_device_sleep(void);
|
||||
|
||||
/* Message by message.... */
|
||||
|
||||
BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration,
|
||||
UINT8 response_cnt);
|
||||
|
||||
#define HCIC_PARAM_SIZE_INQUIRY 5
|
||||
|
||||
|
||||
#define HCIC_INQ_INQ_LAP_OFF 0
|
||||
#define HCIC_INQ_DUR_OFF 3
|
||||
#define HCIC_INQ_RSP_CNT_OFF 4
|
||||
/* Inquiry */
|
||||
|
||||
/* Inquiry Cancel */
|
||||
BOOLEAN btsnd_hcic_inq_cancel(void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_INQ_CANCEL 0
|
||||
|
||||
/* Periodic Inquiry Mode */
|
||||
BOOLEAN btsnd_hcic_per_inq_mode(UINT16 max_period, UINT16 min_period,
|
||||
const LAP inq_lap, UINT8 duration,
|
||||
UINT8 response_cnt);
|
||||
|
||||
#define HCIC_PARAM_SIZE_PER_INQ_MODE 9
|
||||
|
||||
#define HCI_PER_INQ_MAX_INTRVL_OFF 0
|
||||
#define HCI_PER_INQ_MIN_INTRVL_OFF 2
|
||||
#define HCI_PER_INQ_INQ_LAP_OFF 4
|
||||
#define HCI_PER_INQ_DURATION_OFF 7
|
||||
#define HCI_PER_INQ_RSP_CNT_OFF 8
|
||||
/* Periodic Inquiry Mode */
|
||||
|
||||
/* Exit Periodic Inquiry Mode */
|
||||
BOOLEAN btsnd_hcic_exit_per_inq(void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_EXIT_PER_INQ 0
|
||||
/* Create Connection */
|
||||
BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types,
|
||||
UINT8 page_scan_rep_mode,
|
||||
UINT8 page_scan_mode,
|
||||
UINT16 clock_offset,
|
||||
UINT8 allow_switch);
|
||||
|
||||
#define HCIC_PARAM_SIZE_CREATE_CONN 13
|
||||
|
||||
#define HCIC_CR_CONN_BD_ADDR_OFF 0
|
||||
#define HCIC_CR_CONN_PKT_TYPES_OFF 6
|
||||
#define HCIC_CR_CONN_REP_MODE_OFF 8
|
||||
#define HCIC_CR_CONN_PAGE_SCAN_MODE_OFF 9
|
||||
#define HCIC_CR_CONN_CLK_OFF_OFF 10
|
||||
#define HCIC_CR_CONN_ALLOW_SWITCH_OFF 12
|
||||
/* Create Connection */
|
||||
|
||||
/* Disconnect */
|
||||
BOOLEAN btsnd_hcic_disconnect(UINT16 handle, UINT8 reason);
|
||||
|
||||
#define HCIC_PARAM_SIZE_DISCONNECT 3
|
||||
|
||||
#define HCI_DISC_HANDLE_OFF 0
|
||||
#define HCI_DISC_REASON_OFF 2
|
||||
/* Disconnect */
|
||||
|
||||
#if BTM_SCO_INCLUDED == TRUE
|
||||
/* Add SCO Connection */
|
||||
BOOLEAN btsnd_hcic_add_SCO_conn (UINT16 handle, UINT16 packet_types);
|
||||
#endif /* BTM_SCO_INCLUDED */
|
||||
|
||||
#define HCIC_PARAM_SIZE_ADD_SCO_CONN 4
|
||||
|
||||
#define HCI_ADD_SCO_HANDLE_OFF 0
|
||||
#define HCI_ADD_SCO_PACKET_TYPES_OFF 2
|
||||
/* Add SCO Connection */
|
||||
|
||||
/* Create Connection Cancel */
|
||||
BOOLEAN btsnd_hcic_create_conn_cancel(BD_ADDR dest);
|
||||
|
||||
#define HCIC_PARAM_SIZE_CREATE_CONN_CANCEL 6
|
||||
|
||||
#define HCIC_CR_CONN_CANCEL_BD_ADDR_OFF 0
|
||||
/* Create Connection Cancel */
|
||||
|
||||
/* Accept Connection Request */
|
||||
BOOLEAN btsnd_hcic_accept_conn (BD_ADDR bd_addr, UINT8 role);
|
||||
|
||||
#define HCIC_PARAM_SIZE_ACCEPT_CONN 7
|
||||
|
||||
#define HCI_ACC_CONN_BD_ADDR_OFF 0
|
||||
#define HCI_ACC_CONN_ROLE_OFF 6
|
||||
/* Accept Connection Request */
|
||||
|
||||
/* Reject Connection Request */
|
||||
BOOLEAN btsnd_hcic_reject_conn (BD_ADDR bd_addr, UINT8 reason);
|
||||
|
||||
#define HCIC_PARAM_SIZE_REJECT_CONN 7
|
||||
|
||||
#define HCI_REJ_CONN_BD_ADDR_OFF 0
|
||||
#define HCI_REJ_CONN_REASON_OFF 6
|
||||
/* Reject Connection Request */
|
||||
|
||||
/* Link Key Request Reply */
|
||||
BOOLEAN btsnd_hcic_link_key_req_reply (BD_ADDR bd_addr,
|
||||
LINK_KEY link_key);
|
||||
|
||||
#define HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY 22
|
||||
|
||||
#define HCI_LINK_KEY_REPLY_BD_ADDR_OFF 0
|
||||
#define HCI_LINK_KEY_REPLY_LINK_KEY_OFF 6
|
||||
/* Link Key Request Reply */
|
||||
|
||||
/* Link Key Request Neg Reply */
|
||||
BOOLEAN btsnd_hcic_link_key_neg_reply (BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY 6
|
||||
|
||||
#define HCI_LINK_KEY_NEG_REP_BD_ADR_OFF 0
|
||||
/* Link Key Request Neg Reply */
|
||||
|
||||
/* PIN Code Request Reply */
|
||||
BOOLEAN btsnd_hcic_pin_code_req_reply (BD_ADDR bd_addr,
|
||||
UINT8 pin_code_len,
|
||||
PIN_CODE pin_code);
|
||||
|
||||
#define HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY 23
|
||||
|
||||
#define HCI_PIN_CODE_REPLY_BD_ADDR_OFF 0
|
||||
#define HCI_PIN_CODE_REPLY_PIN_LEN_OFF 6
|
||||
#define HCI_PIN_CODE_REPLY_PIN_CODE_OFF 7
|
||||
/* PIN Code Request Reply */
|
||||
|
||||
/* Link Key Request Neg Reply */
|
||||
BOOLEAN btsnd_hcic_pin_code_neg_reply (BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY 6
|
||||
|
||||
#define HCI_PIN_CODE_NEG_REP_BD_ADR_OFF 0
|
||||
/* Link Key Request Neg Reply */
|
||||
|
||||
/* Change Connection Type */
|
||||
BOOLEAN btsnd_hcic_change_conn_type (UINT16 handle, UINT16 packet_types);
|
||||
|
||||
#define HCIC_PARAM_SIZE_CHANGE_CONN_TYPE 4
|
||||
|
||||
#define HCI_CHNG_PKT_TYPE_HANDLE_OFF 0
|
||||
#define HCI_CHNG_PKT_TYPE_PKT_TYPE_OFF 2
|
||||
/* Change Connection Type */
|
||||
|
||||
#define HCIC_PARAM_SIZE_CMD_HANDLE 2
|
||||
|
||||
#define HCI_CMD_HANDLE_HANDLE_OFF 0
|
||||
|
||||
BOOLEAN btsnd_hcic_auth_request (UINT16 handle); /* Authentication Request */
|
||||
|
||||
/* Set Connection Encryption */
|
||||
BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enable);
|
||||
#define HCIC_PARAM_SIZE_SET_CONN_ENCRYPT 3
|
||||
|
||||
|
||||
#define HCI_SET_ENCRYPT_HANDLE_OFF 0
|
||||
#define HCI_SET_ENCRYPT_ENABLE_OFF 2
|
||||
/* Set Connection Encryption */
|
||||
|
||||
/* Remote Name Request */
|
||||
BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr,
|
||||
UINT8 page_scan_rep_mode,
|
||||
UINT8 page_scan_mode,
|
||||
UINT16 clock_offset);
|
||||
|
||||
#define HCIC_PARAM_SIZE_RMT_NAME_REQ 10
|
||||
|
||||
#define HCI_RMT_NAME_BD_ADDR_OFF 0
|
||||
#define HCI_RMT_NAME_REP_MODE_OFF 6
|
||||
#define HCI_RMT_NAME_PAGE_SCAN_MODE_OFF 7
|
||||
#define HCI_RMT_NAME_CLK_OFF_OFF 8
|
||||
/* Remote Name Request */
|
||||
|
||||
/* Remote Name Request Cancel */
|
||||
BOOLEAN btsnd_hcic_rmt_name_req_cancel(BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL 6
|
||||
|
||||
#define HCI_RMT_NAME_CANCEL_BD_ADDR_OFF 0
|
||||
/* Remote Name Request Cancel */
|
||||
|
||||
BOOLEAN btsnd_hcic_rmt_features_req(UINT16 handle); /* Remote Features Request */
|
||||
|
||||
/* Remote Extended Features */
|
||||
BOOLEAN btsnd_hcic_rmt_ext_features(UINT16 handle, UINT8 page_num);
|
||||
|
||||
#define HCIC_PARAM_SIZE_RMT_EXT_FEATURES 3
|
||||
|
||||
#define HCI_RMT_EXT_FEATURES_HANDLE_OFF 0
|
||||
#define HCI_RMT_EXT_FEATURES_PAGE_NUM_OFF 2
|
||||
/* Remote Extended Features */
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_rmt_ver_req(UINT16 handle); /* Remote Version Info Request */
|
||||
BOOLEAN btsnd_hcic_read_rmt_clk_offset(UINT16 handle); /* Remote Clock Offset */
|
||||
BOOLEAN btsnd_hcic_read_lmp_handle(UINT16 handle); /* Remote LMP Handle */
|
||||
|
||||
BOOLEAN btsnd_hcic_setup_esco_conn (UINT16 handle,
|
||||
UINT32 tx_bw, UINT32 rx_bw,
|
||||
UINT16 max_latency, UINT16 voice,
|
||||
UINT8 retrans_effort,
|
||||
UINT16 packet_types);
|
||||
#define HCIC_PARAM_SIZE_SETUP_ESCO 17
|
||||
|
||||
#define HCI_SETUP_ESCO_HANDLE_OFF 0
|
||||
#define HCI_SETUP_ESCO_TX_BW_OFF 2
|
||||
#define HCI_SETUP_ESCO_RX_BW_OFF 6
|
||||
#define HCI_SETUP_ESCO_MAX_LAT_OFF 10
|
||||
#define HCI_SETUP_ESCO_VOICE_OFF 12
|
||||
#define HCI_SETUP_ESCO_RETRAN_EFF_OFF 14
|
||||
#define HCI_SETUP_ESCO_PKT_TYPES_OFF 15
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_accept_esco_conn (BD_ADDR bd_addr,
|
||||
UINT32 tx_bw, UINT32 rx_bw,
|
||||
UINT16 max_latency,
|
||||
UINT16 content_fmt,
|
||||
UINT8 retrans_effort,
|
||||
UINT16 packet_types);
|
||||
#define HCIC_PARAM_SIZE_ACCEPT_ESCO 21
|
||||
|
||||
#define HCI_ACCEPT_ESCO_BDADDR_OFF 0
|
||||
#define HCI_ACCEPT_ESCO_TX_BW_OFF 6
|
||||
#define HCI_ACCEPT_ESCO_RX_BW_OFF 10
|
||||
#define HCI_ACCEPT_ESCO_MAX_LAT_OFF 14
|
||||
#define HCI_ACCEPT_ESCO_VOICE_OFF 16
|
||||
#define HCI_ACCEPT_ESCO_RETRAN_EFF_OFF 18
|
||||
#define HCI_ACCEPT_ESCO_PKT_TYPES_OFF 19
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_reject_esco_conn (BD_ADDR bd_addr, UINT8 reason);
|
||||
#define HCIC_PARAM_SIZE_REJECT_ESCO 7
|
||||
|
||||
#define HCI_REJECT_ESCO_BDADDR_OFF 0
|
||||
#define HCI_REJECT_ESCO_REASON_OFF 6
|
||||
|
||||
/* Hold Mode */
|
||||
BOOLEAN btsnd_hcic_hold_mode(UINT16 handle, UINT16 max_hold_period,
|
||||
UINT16 min_hold_period);
|
||||
|
||||
#define HCIC_PARAM_SIZE_HOLD_MODE 6
|
||||
|
||||
#define HCI_HOLD_MODE_HANDLE_OFF 0
|
||||
#define HCI_HOLD_MODE_MAX_PER_OFF 2
|
||||
#define HCI_HOLD_MODE_MIN_PER_OFF 4
|
||||
/* Hold Mode */
|
||||
|
||||
/* Sniff Mode */
|
||||
BOOLEAN btsnd_hcic_sniff_mode(UINT16 handle,
|
||||
UINT16 max_sniff_period,
|
||||
UINT16 min_sniff_period,
|
||||
UINT16 sniff_attempt,
|
||||
UINT16 sniff_timeout);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SNIFF_MODE 10
|
||||
|
||||
|
||||
#define HCI_SNIFF_MODE_HANDLE_OFF 0
|
||||
#define HCI_SNIFF_MODE_MAX_PER_OFF 2
|
||||
#define HCI_SNIFF_MODE_MIN_PER_OFF 4
|
||||
#define HCI_SNIFF_MODE_ATTEMPT_OFF 6
|
||||
#define HCI_SNIFF_MODE_TIMEOUT_OFF 8
|
||||
/* Sniff Mode */
|
||||
|
||||
BOOLEAN btsnd_hcic_exit_sniff_mode(UINT16 handle); /* Exit Sniff Mode */
|
||||
|
||||
/* Park Mode */
|
||||
BOOLEAN btsnd_hcic_park_mode (UINT16 handle,
|
||||
UINT16 beacon_max_interval,
|
||||
UINT16 beacon_min_interval);
|
||||
|
||||
#define HCIC_PARAM_SIZE_PARK_MODE 6
|
||||
|
||||
#define HCI_PARK_MODE_HANDLE_OFF 0
|
||||
#define HCI_PARK_MODE_MAX_PER_OFF 2
|
||||
#define HCI_PARK_MODE_MIN_PER_OFF 4
|
||||
/* Park Mode */
|
||||
|
||||
BOOLEAN btsnd_hcic_exit_park_mode(UINT16 handle); /* Exit Park Mode */
|
||||
|
||||
/* QoS Setup */
|
||||
BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags,
|
||||
UINT8 service_type,
|
||||
UINT32 token_rate, UINT32 peak,
|
||||
UINT32 latency, UINT32 delay_var);
|
||||
|
||||
#define HCIC_PARAM_SIZE_QOS_SETUP 20
|
||||
|
||||
#define HCI_QOS_HANDLE_OFF 0
|
||||
#define HCI_QOS_FLAGS_OFF 2
|
||||
#define HCI_QOS_SERVICE_TYPE_OFF 3
|
||||
#define HCI_QOS_TOKEN_RATE_OFF 4
|
||||
#define HCI_QOS_PEAK_BANDWIDTH_OFF 8
|
||||
#define HCI_QOS_LATENCY_OFF 12
|
||||
#define HCI_QOS_DELAY_VAR_OFF 16
|
||||
/* QoS Setup */
|
||||
|
||||
/* Switch Role Request */
|
||||
BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SWITCH_ROLE 7
|
||||
|
||||
#define HCI_SWITCH_BD_ADDR_OFF 0
|
||||
#define HCI_SWITCH_ROLE_OFF 6
|
||||
/* Switch Role Request */
|
||||
|
||||
/* Write Policy Settings */
|
||||
BOOLEAN btsnd_hcic_write_policy_set(UINT16 handle, UINT16 settings);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_POLICY_SET 4
|
||||
|
||||
#define HCI_WRITE_POLICY_HANDLE_OFF 0
|
||||
#define HCI_WRITE_POLICY_SETTINGS_OFF 2
|
||||
/* Write Policy Settings */
|
||||
|
||||
/* Write Default Policy Settings */
|
||||
BOOLEAN btsnd_hcic_write_def_policy_set(UINT16 settings);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET 2
|
||||
|
||||
#define HCI_WRITE_DEF_POLICY_SETTINGS_OFF 0
|
||||
/* Write Default Policy Settings */
|
||||
|
||||
/******************************************
|
||||
** Lisbon Features
|
||||
*******************************************/
|
||||
#if BTM_SSR_INCLUDED == TRUE
|
||||
/* Sniff Subrating */
|
||||
BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat,
|
||||
UINT16 min_remote_lat,
|
||||
UINT16 min_local_lat);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SNIFF_SUB_RATE 8
|
||||
|
||||
#define HCI_SNIFF_SUB_RATE_HANDLE_OFF 0
|
||||
#define HCI_SNIFF_SUB_RATE_MAX_LAT_OFF 2
|
||||
#define HCI_SNIFF_SUB_RATE_MIN_REM_LAT_OFF 4
|
||||
#define HCI_SNIFF_SUB_RATE_MIN_LOC_LAT_OFF 6
|
||||
/* Sniff Subrating */
|
||||
|
||||
#else /* BTM_SSR_INCLUDED == FALSE */
|
||||
|
||||
#define btsnd_hcic_sniff_sub_rate(handle, max_lat, min_remote_lat, min_local_lat) FALSE
|
||||
|
||||
#endif /* BTM_SSR_INCLUDED */
|
||||
|
||||
/* Extended Inquiry Response */
|
||||
void btsnd_hcic_write_ext_inquiry_response(void *buffer, UINT8 fec_req);
|
||||
|
||||
#define HCIC_PARAM_SIZE_EXT_INQ_RESP 241
|
||||
|
||||
#define HCIC_EXT_INQ_RESP_FEC_OFF 0
|
||||
#define HCIC_EXT_INQ_RESP_RESPONSE 1
|
||||
/* IO Capabilities Response */
|
||||
BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability,
|
||||
UINT8 oob_present, UINT8 auth_req);
|
||||
|
||||
#define HCIC_PARAM_SIZE_IO_CAP_RESP 9
|
||||
|
||||
#define HCI_IO_CAP_BD_ADDR_OFF 0
|
||||
#define HCI_IO_CAPABILITY_OFF 6
|
||||
#define HCI_IO_CAP_OOB_DATA_OFF 7
|
||||
#define HCI_IO_CAP_AUTH_REQ_OFF 8
|
||||
|
||||
/* IO Capabilities Req Neg Reply */
|
||||
BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 err_code);
|
||||
|
||||
#define HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY 7
|
||||
|
||||
#define HCI_IO_CAP_NR_BD_ADDR_OFF 0
|
||||
#define HCI_IO_CAP_NR_ERR_CODE 6
|
||||
|
||||
/* Read Local OOB Data */
|
||||
BOOLEAN btsnd_hcic_read_local_oob_data (void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_R_LOCAL_OOB 0
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_user_conf_reply (BD_ADDR bd_addr, BOOLEAN is_yes);
|
||||
|
||||
#define HCIC_PARAM_SIZE_UCONF_REPLY 6
|
||||
|
||||
#define HCI_USER_CONF_BD_ADDR_OFF 0
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 value);
|
||||
|
||||
#define HCIC_PARAM_SIZE_U_PKEY_REPLY 10
|
||||
|
||||
#define HCI_USER_PASSKEY_BD_ADDR_OFF 0
|
||||
#define HCI_USER_PASSKEY_VALUE_OFF 6
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_user_passkey_neg_reply (BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY 6
|
||||
|
||||
#define HCI_USER_PASSKEY_NEG_BD_ADDR_OFF 0
|
||||
|
||||
/* Remote OOB Data Request Reply */
|
||||
BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c,
|
||||
UINT8 *p_r);
|
||||
|
||||
#define HCIC_PARAM_SIZE_REM_OOB_REPLY 38
|
||||
|
||||
#define HCI_REM_OOB_DATA_BD_ADDR_OFF 0
|
||||
#define HCI_REM_OOB_DATA_C_OFF 6
|
||||
#define HCI_REM_OOB_DATA_R_OFF 22
|
||||
|
||||
/* Remote OOB Data Request Negative Reply */
|
||||
BOOLEAN btsnd_hcic_rem_oob_neg_reply (BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY 6
|
||||
|
||||
#define HCI_REM_OOB_DATA_NEG_BD_ADDR_OFF 0
|
||||
|
||||
/* Read Tx Power Level */
|
||||
BOOLEAN btsnd_hcic_read_inq_tx_power (void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_R_TX_POWER 0
|
||||
|
||||
/* Read Default Erroneous Data Reporting */
|
||||
BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_R_ERR_DATA_RPT 0
|
||||
|
||||
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
|
||||
BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type);
|
||||
|
||||
#define HCIC_PARAM_SIZE_ENHANCED_FLUSH 3
|
||||
#endif
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF 7
|
||||
|
||||
#define HCI_SEND_KEYPRESS_NOTIF_BD_ADDR_OFF 0
|
||||
#define HCI_SEND_KEYPRESS_NOTIF_NOTIF_OFF 6
|
||||
|
||||
/**** end of Simple Pairing Commands ****/
|
||||
|
||||
/* Store Current Settings */
|
||||
#define MAX_FILT_COND (sizeof (BD_ADDR) + 1)
|
||||
|
||||
BOOLEAN btsnd_hcic_set_event_filter(UINT8 filt_type,
|
||||
UINT8 filt_cond_type,
|
||||
UINT8 *filt_cond,
|
||||
UINT8 filt_cond_len);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SET_EVT_FILTER 9
|
||||
|
||||
#define HCI_FILT_COND_FILT_TYPE_OFF 0
|
||||
#define HCI_FILT_COND_COND_TYPE_OFF 1
|
||||
#define HCI_FILT_COND_FILT_OFF 2
|
||||
/* Set Event Filter */
|
||||
|
||||
/* Delete Stored Key */
|
||||
BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN delete_all_flag);
|
||||
|
||||
#define HCIC_PARAM_SIZE_DELETE_STORED_KEY 7
|
||||
|
||||
#define HCI_DELETE_KEY_BD_ADDR_OFF 0
|
||||
#define HCI_DELETE_KEY_ALL_FLAG_OFF 6
|
||||
/* Delete Stored Key */
|
||||
|
||||
/* Change Local Name */
|
||||
BOOLEAN btsnd_hcic_change_name(BD_NAME name);
|
||||
|
||||
#define HCIC_PARAM_SIZE_CHANGE_NAME BD_NAME_LEN
|
||||
|
||||
#define HCI_CHANGE_NAME_NAME_OFF 0
|
||||
/* Change Local Name */
|
||||
|
||||
|
||||
#define HCIC_PARAM_SIZE_READ_CMD 0
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_PARAM1 1
|
||||
|
||||
#define HCIC_WRITE_PARAM1_PARAM_OFF 0
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_PARAM2 2
|
||||
|
||||
#define HCIC_WRITE_PARAM2_PARAM_OFF 0
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_PARAM3 3
|
||||
|
||||
#define HCIC_WRITE_PARAM3_PARAM_OFF 0
|
||||
|
||||
#define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10
|
||||
|
||||
BOOLEAN btsnd_hcic_write_pin_type(UINT8 type); /* Write PIN Type */
|
||||
BOOLEAN btsnd_hcic_write_auto_accept(UINT8 flag); /* Write Auto Accept */
|
||||
BOOLEAN btsnd_hcic_read_name (void); /* Read Local Name */
|
||||
BOOLEAN btsnd_hcic_write_page_tout(UINT16 timeout); /* Write Page Timout */
|
||||
BOOLEAN btsnd_hcic_write_scan_enable(UINT8 flag); /* Write Scan Enable */
|
||||
BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval,
|
||||
UINT16 window); /* Write Page Scan Activity */
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG 4
|
||||
|
||||
#define HCI_SCAN_CFG_INTERVAL_OFF 0
|
||||
#define HCI_SCAN_CFG_WINDOW_OFF 2
|
||||
/* Write Page Scan Activity */
|
||||
|
||||
/* Write Inquiry Scan Activity */
|
||||
BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG 4
|
||||
|
||||
#define HCI_SCAN_CFG_INTERVAL_OFF 0
|
||||
#define HCI_SCAN_CFG_WINDOW_OFF 2
|
||||
/* Write Inquiry Scan Activity */
|
||||
|
||||
BOOLEAN btsnd_hcic_write_auth_enable(UINT8 flag); /* Write Authentication Enable */
|
||||
BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev); /* Write Class of Device */
|
||||
BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags); /* Write Voice Settings */
|
||||
|
||||
/* Host Controller to Host flow control */
|
||||
#define HCI_HOST_FLOW_CTRL_OFF 0
|
||||
#define HCI_HOST_FLOW_CTRL_ACL_ON 1
|
||||
#define HCI_HOST_FLOW_CTRL_SCO_ON 2
|
||||
#define HCI_HOST_FLOW_CTRL_BOTH_ON 3
|
||||
|
||||
BOOLEAN btsnd_hcic_write_auto_flush_tout(UINT16 handle,
|
||||
UINT16 timeout); /* Write Retransmit Timout */
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT 4
|
||||
|
||||
#define HCI_FLUSH_TOUT_HANDLE_OFF 0
|
||||
#define HCI_FLUSH_TOUT_TOUT_OFF 2
|
||||
|
||||
BOOLEAN btsnd_hcic_read_tx_power(UINT16 handle, UINT8 type); /* Read Tx Power */
|
||||
|
||||
#define HCIC_PARAM_SIZE_READ_TX_POWER 3
|
||||
|
||||
#define HCI_READ_TX_POWER_HANDLE_OFF 0
|
||||
#define HCI_READ_TX_POWER_TYPE_OFF 2
|
||||
|
||||
/* Read transmit power level parameter */
|
||||
#define HCI_READ_CURRENT 0x00
|
||||
#define HCI_READ_MAXIMUM 0x01
|
||||
|
||||
BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles,
|
||||
UINT16 *handle,
|
||||
UINT16 *num_pkts); /* Set Host Buffer Size */
|
||||
|
||||
#define HCIC_PARAM_SIZE_NUM_PKTS_DONE_SIZE sizeof(btmsg_hcic_num_pkts_done_t)
|
||||
|
||||
#define MAX_DATA_HANDLES 10
|
||||
|
||||
#define HCI_PKTS_DONE_NUM_HANDLES_OFF 0
|
||||
#define HCI_PKTS_DONE_HANDLE_OFF 1
|
||||
#define HCI_PKTS_DONE_NUM_PKTS_OFF 3
|
||||
|
||||
/* Write Link Supervision Timeout */
|
||||
BOOLEAN btsnd_hcic_write_link_super_tout(UINT8 local_controller_id, UINT16 handle, UINT16 timeout);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT 4
|
||||
|
||||
#define HCI_LINK_SUPER_TOUT_HANDLE_OFF 0
|
||||
#define HCI_LINK_SUPER_TOUT_TOUT_OFF 2
|
||||
/* Write Link Supervision Timeout */
|
||||
|
||||
BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac,
|
||||
LAP * const iac_lap); /* Write Current IAC LAP */
|
||||
|
||||
#define MAX_IAC_LAPS 0x40
|
||||
|
||||
#define HCI_WRITE_IAC_LAP_NUM_OFF 0
|
||||
#define HCI_WRITE_IAC_LAP_LAP_OFF 1
|
||||
/* Write Current IAC LAP */
|
||||
|
||||
BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle); /* Get Link Quality */
|
||||
BOOLEAN btsnd_hcic_read_rssi (UINT16 handle); /* Read RSSI */
|
||||
BOOLEAN btsnd_hcic_enable_test_mode (void); /* Enable Device Under Test Mode */
|
||||
BOOLEAN btsnd_hcic_write_pagescan_type(UINT8 type); /* Write Page Scan Type */
|
||||
BOOLEAN btsnd_hcic_write_inqscan_type(UINT8 type); /* Write Inquiry Scan Type */
|
||||
BOOLEAN btsnd_hcic_write_inquiry_mode(UINT8 type); /* Write Inquiry Mode */
|
||||
|
||||
#define HCI_DATA_HANDLE_MASK 0x0FFF
|
||||
|
||||
#define HCID_GET_HANDLE_EVENT(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset) + \
|
||||
(*((UINT8 *)((p) + 1) + p->offset + 1) << 8)))
|
||||
|
||||
#define HCID_GET_HANDLE(u16) (UINT16)((u16) & HCI_DATA_HANDLE_MASK)
|
||||
|
||||
#define HCI_DATA_EVENT_MASK 3
|
||||
#define HCI_DATA_EVENT_OFFSET 12
|
||||
#define HCID_GET_EVENT(u16) (UINT8)(((u16) >> HCI_DATA_EVENT_OFFSET) & HCI_DATA_EVENT_MASK)
|
||||
|
||||
#define HCI_DATA_BCAST_MASK 3
|
||||
#define HCI_DATA_BCAST_OFFSET 10
|
||||
#define HCID_GET_BCAST(u16) (UINT8)(((u16) >> HCI_DATA_BCAST_OFFSET) & HCI_DATA_BCAST_MASK)
|
||||
|
||||
#define HCID_GET_ACL_LEN(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset + 2) + \
|
||||
(*((UINT8 *)((p) + 1) + p->offset + 3) << 8)))
|
||||
|
||||
#define HCID_HEADER_SIZE 4
|
||||
|
||||
#define HCID_GET_SCO_LEN(p) (*((UINT8 *)((p) + 1) + p->offset + 2))
|
||||
|
||||
void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode,
|
||||
UINT8 len, UINT8 *p_data,
|
||||
void *p_cmd_cplt_cback);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/********************************************************************************
|
||||
** BLE Commands
|
||||
** Note: "local_controller_id" is for transport, not counted in HCI message size
|
||||
*********************************************************************************/
|
||||
#define HCIC_BLE_RAND_DI_SIZE 8
|
||||
#define HCIC_BLE_ENCRYT_KEY_SIZE 16
|
||||
#define HCIC_BLE_IRK_SIZE 16
|
||||
|
||||
#define HCIC_PARAM_SIZE_SET_USED_FEAT_CMD 8
|
||||
#define HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD 6
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS 15
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP 31
|
||||
#define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE 1
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM 7
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE 2
|
||||
#define HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN 25
|
||||
#define HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL 0
|
||||
#define HCIC_PARAM_SIZE_CLEAR_WHITE_LIST 0
|
||||
#define HCIC_PARAM_SIZE_ADD_WHITE_LIST 7
|
||||
#define HCIC_PARAM_SIZE_REMOVE_WHITE_LIST 7
|
||||
#define HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS 14
|
||||
#define HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS 5
|
||||
#define HCIC_PARAM_SIZE_READ_CHNL_MAP 2
|
||||
#define HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT 2
|
||||
#define HCIC_PARAM_SIZE_BLE_ENCRYPT 32
|
||||
#define HCIC_PARAM_SIZE_BLE_RAND 0
|
||||
#define HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED 2
|
||||
|
||||
#define HCIC_BLE_RAND_DI_SIZE 8
|
||||
#define HCIC_BLE_ENCRYT_KEY_SIZE 16
|
||||
#define HCIC_PARAM_SIZE_BLE_START_ENC (4 + HCIC_BLE_RAND_DI_SIZE + HCIC_BLE_ENCRYT_KEY_SIZE)
|
||||
#define HCIC_PARAM_SIZE_LTK_REQ_REPLY (2 + HCIC_BLE_ENCRYT_KEY_SIZE)
|
||||
#define HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY 2
|
||||
#define HCIC_BLE_CHNL_MAP_SIZE 5
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA 31
|
||||
|
||||
#define HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST (7 + HCIC_BLE_IRK_SIZE * 2)
|
||||
#define HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST 7
|
||||
#define HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST 0
|
||||
#define HCIC_PARAM_SIZE_BLE_READ_RESOLVING_LIST_SIZE 0
|
||||
#define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER 7
|
||||
#define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL 7
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE 1
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT 2
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11
|
||||
|
||||
/* ULP HCI command */
|
||||
BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_buffer_size (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_local_spt_feat (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_addr);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
UINT8 adv_type, UINT8 addr_type_own,
|
||||
UINT8 addr_type_dir, BD_ADDR direct_bda,
|
||||
UINT8 channel_map, UINT8 adv_filter_policy);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
|
||||
UINT16 scan_int, UINT16 scan_win,
|
||||
UINT8 addr_type, UINT8 scan_filter_policy);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win,
|
||||
UINT8 init_filter_policy, UINT8 addr_type_peer, BD_ADDR bda_peer, UINT8 addr_type_own,
|
||||
UINT16 conn_int_min, UINT16 conn_int_max, UINT16 conn_latency, UINT16 conn_timeout,
|
||||
UINT16 min_ce_len, UINT16 max_ce_len);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_create_conn_cancel (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_white_list_size (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_clear_white_list (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_upd_ll_conn_params (UINT16 handle, UINT16 conn_int_min, UINT16 conn_int_max,
|
||||
UINT16 conn_latency, UINT16 conn_timeout, UINT16 min_len, UINT16 max_len);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_remote_feat ( UINT16 handle);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_encrypt (UINT8* key, UINT8 key_len, UINT8* plain_text, UINT8 pt_len, void *p_cmd_cplt_cback);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_start_enc ( UINT16 handle,
|
||||
UINT8 rand[HCIC_BLE_RAND_DI_SIZE],
|
||||
UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_supported_states (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_write_host_supported (UINT8 le_host_spt, UINT8 simul_le_host_spt);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_host_supported (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len,
|
||||
UINT8 payload);
|
||||
BOOLEAN btsnd_hcic_ble_test_end(void);
|
||||
|
||||
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
|
||||
|
||||
#define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY 14
|
||||
BOOLEAN btsnd_hcic_ble_rc_param_req_reply(UINT16 handle,
|
||||
UINT16 conn_int_min, UINT16 conn_int_max,
|
||||
UINT16 conn_latency, UINT16 conn_timeout,
|
||||
UINT16 min_ce_len, UINT16 max_ce_len);
|
||||
|
||||
#define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY 3
|
||||
BOOLEAN btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle, UINT8 reason);
|
||||
|
||||
#endif /* BLE_LLT_INCLUDED */
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_data_length(UINT16 conn_handle, UINT16 tx_octets,
|
||||
UINT16 tx_time);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_add_device_resolving_list (UINT8 addr_type_peer,
|
||||
BD_ADDR bda_peer,
|
||||
UINT8 irk_peer[HCIC_BLE_IRK_SIZE],
|
||||
UINT8 irk_local[HCIC_BLE_IRK_SIZE]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_rm_device_resolving_list (UINT8 addr_type_peer,
|
||||
BD_ADDR bda_peer);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_clear_resolving_list (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_resolvable_addr_peer (UINT8 addr_type_peer,
|
||||
BD_ADDR bda_peer);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_resolvable_addr_local (UINT8 addr_type_peer,
|
||||
BD_ADDR bda_peer);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_addr_resolution_enable (UINT8 addr_resolution_enable);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_rand_priv_addr_timeout (UINT16 rpa_timout);
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
BOOLEAN btsnd_hcic_read_authenticated_payload_tout(UINT16 handle);
|
||||
|
||||
BOOLEAN btsnd_hcic_write_authenticated_payload_tout(UINT16 handle,
|
||||
UINT16 timeout);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4
|
||||
|
||||
#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0
|
||||
#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_TOUT_OFF 2
|
||||
|
||||
#endif
|
||||
+69
@@ -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
|
||||
|
||||
|
||||
/* 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
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains HID protocol definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef HIDDEFS_H
|
||||
#define HIDDEFS_H
|
||||
|
||||
#include "sdp_api.h"
|
||||
/*
|
||||
** tHID_STATUS: HID result codes, returned by HID and device and host functions.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
HID_SUCCESS,
|
||||
HID_ERR_NOT_REGISTERED,
|
||||
HID_ERR_ALREADY_REGISTERED,
|
||||
HID_ERR_NO_RESOURCES,
|
||||
HID_ERR_NO_CONNECTION,
|
||||
HID_ERR_INVALID_PARAM,
|
||||
HID_ERR_UNSUPPORTED,
|
||||
HID_ERR_UNKNOWN_COMMAND,
|
||||
HID_ERR_CONGESTED,
|
||||
HID_ERR_CONN_IN_PROCESS,
|
||||
HID_ERR_ALREADY_CONN,
|
||||
HID_ERR_DISCONNECTING,
|
||||
HID_ERR_SET_CONNABLE_FAIL,
|
||||
/* Device specific error codes */
|
||||
HID_ERR_HOST_UNKNOWN,
|
||||
HID_ERR_L2CAP_FAILED,
|
||||
HID_ERR_AUTH_FAILED,
|
||||
HID_ERR_SDP_BUSY,
|
||||
HID_ERR_GATT,
|
||||
|
||||
HID_ERR_INVALID = 0xFF
|
||||
};
|
||||
|
||||
typedef UINT8 tHID_STATUS;
|
||||
|
||||
#define HID_L2CAP_CONN_FAIL (0x0100) /* Connection Attempt was made but failed */
|
||||
#define HID_L2CAP_REQ_FAIL (0x0200) /* L2CAP_ConnectReq API failed */
|
||||
#define HID_L2CAP_CFG_FAIL (0x0400) /* L2CAP Configuration was rejected by peer */
|
||||
|
||||
|
||||
|
||||
/* Define the HID transaction types
|
||||
*/
|
||||
#define HID_TRANS_HANDSHAKE (0)
|
||||
#define HID_TRANS_CONTROL (1)
|
||||
#define HID_TRANS_GET_REPORT (4)
|
||||
#define HID_TRANS_SET_REPORT (5)
|
||||
#define HID_TRANS_GET_PROTOCOL (6)
|
||||
#define HID_TRANS_SET_PROTOCOL (7)
|
||||
#define HID_TRANS_GET_IDLE (8)
|
||||
#define HID_TRANS_SET_IDLE (9)
|
||||
#define HID_TRANS_DATA (10)
|
||||
#define HID_TRANS_DATAC (11)
|
||||
|
||||
#define HID_GET_TRANS_FROM_HDR(x) ((x >> 4) & 0x0f)
|
||||
#define HID_GET_PARAM_FROM_HDR(x) (x & 0x0f)
|
||||
#define HID_BUILD_HDR(t,p) (UINT8)((t << 4) | (p & 0x0f))
|
||||
|
||||
|
||||
/* Parameters for Handshake
|
||||
*/
|
||||
#define HID_PAR_HANDSHAKE_RSP_SUCCESS (0)
|
||||
#define HID_PAR_HANDSHAKE_RSP_NOT_READY (1)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_INVALID_REP_ID (2)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ (3)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_INVALID_PARAM (4)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_UNKNOWN (14)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_FATAL (15)
|
||||
|
||||
|
||||
/* Parameters for Control
|
||||
*/
|
||||
#define HID_PAR_CONTROL_NOP (0)
|
||||
#define HID_PAR_CONTROL_HARD_RESET (1)
|
||||
#define HID_PAR_CONTROL_SOFT_RESET (2)
|
||||
#define HID_PAR_CONTROL_SUSPEND (3)
|
||||
#define HID_PAR_CONTROL_EXIT_SUSPEND (4)
|
||||
#define HID_PAR_CONTROL_VIRTUAL_CABLE_UNPLUG (5)
|
||||
|
||||
|
||||
/* Different report types in get, set, data
|
||||
*/
|
||||
#define HID_PAR_REP_TYPE_MASK (0x03)
|
||||
#define HID_PAR_REP_TYPE_OTHER (0x00)
|
||||
#define HID_PAR_REP_TYPE_INPUT (0x01)
|
||||
#define HID_PAR_REP_TYPE_OUTPUT (0x02)
|
||||
#define HID_PAR_REP_TYPE_FEATURE (0x03)
|
||||
|
||||
/* Parameters for Get Report
|
||||
*/
|
||||
|
||||
/* Buffer size in two bytes after Report ID */
|
||||
#define HID_PAR_GET_REP_BUFSIZE_FOLLOWS (0x08)
|
||||
|
||||
|
||||
/* Parameters for Protocol Type
|
||||
*/
|
||||
#define HID_PAR_PROTOCOL_MASK (0x01)
|
||||
#define HID_PAR_PROTOCOL_REPORT (0x01)
|
||||
#define HID_PAR_PROTOCOL_BOOT_MODE (0x00)
|
||||
|
||||
#define HID_PAR_REP_TYPE_MASK (0x03)
|
||||
|
||||
/* Descriptor types in the SDP record
|
||||
*/
|
||||
#define HID_SDP_DESCRIPTOR_REPORT (0x22)
|
||||
#define HID_SDP_DESCRIPTOR_PHYSICAL (0x23)
|
||||
|
||||
typedef struct desc_info
|
||||
{
|
||||
UINT16 dl_len;
|
||||
UINT8 *dsc_list;
|
||||
} tHID_DEV_DSCP_INFO;
|
||||
|
||||
#define HID_SSR_PARAM_INVALID 0xffff
|
||||
|
||||
typedef struct sdp_info
|
||||
{
|
||||
char svc_name[HID_MAX_SVC_NAME_LEN]; /*Service Name */
|
||||
char svc_descr[HID_MAX_SVC_DESCR_LEN]; /*Service Description*/
|
||||
char prov_name[HID_MAX_PROV_NAME_LEN]; /*Provider Name.*/
|
||||
UINT16 rel_num; /*Release Number */
|
||||
UINT16 hpars_ver; /*HID Parser Version.*/
|
||||
UINT16 ssr_max_latency; /* HIDSSRHostMaxLatency value, if HID_SSR_PARAM_INVALID not used*/
|
||||
UINT16 ssr_min_tout; /* HIDSSRHostMinTimeout value, if HID_SSR_PARAM_INVALID not used* */
|
||||
UINT8 sub_class; /*Device Subclass.*/
|
||||
UINT8 ctry_code; /*Country Code.*/
|
||||
UINT16 sup_timeout;/* Supervisory Timeout */
|
||||
|
||||
tHID_DEV_DSCP_INFO dscp_info; /* Descriptor list and Report list to be set in the SDP record.
|
||||
This parameter is used if HID_DEV_USE_GLB_SDP_REC is set to FALSE.*/
|
||||
tSDP_DISC_REC *p_sdp_layer_rec;
|
||||
} tHID_DEV_SDP_INFO;
|
||||
|
||||
#endif
|
||||
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef HIDH_API_H
|
||||
#define HIDH_API_H
|
||||
|
||||
#include "hiddefs.h"
|
||||
#include "sdp_api.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
enum {
|
||||
HID_SDP_NO_SERV_UUID = (SDP_ILLEGAL_PARAMETER+1),
|
||||
HID_SDP_MANDATORY_MISSING
|
||||
};
|
||||
|
||||
/* Attributes mask values to be used in HID_HostAddDev API */
|
||||
#define HID_VIRTUAL_CABLE 0x0001
|
||||
#define HID_NORMALLY_CONNECTABLE 0x0002
|
||||
#define HID_RECONN_INIT 0x0004
|
||||
#define HID_SDP_DISABLE 0x0008
|
||||
#define HID_BATTERY_POWER 0x0010
|
||||
#define HID_REMOTE_WAKE 0x0020
|
||||
#define HID_SUP_TOUT_AVLBL 0x0040
|
||||
#define HID_SSR_MAX_LATENCY 0x0080
|
||||
#define HID_SSR_MIN_TOUT 0x0100
|
||||
|
||||
#define HID_SEC_REQUIRED 0x8000
|
||||
#define HID_ATTR_MASK_IGNORE 0
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
typedef void (tHID_HOST_SDP_CALLBACK) (UINT16 result, UINT16 attr_mask,
|
||||
tHID_DEV_SDP_INFO *sdp_rec );
|
||||
|
||||
/* HID-HOST returns the events in the following table to the application via tHID_HOST_DEV_CALLBACK
|
||||
HID_HDEV_EVT_OPEN Connected to device with Interrupt and Control Channels in OPEN state.
|
||||
Data = NA
|
||||
HID_HDEV_EVT_CLOSE Connection with device is closed. Data=reason code.
|
||||
HID_HDEV_EVT_RETRYING Lost connection is being re-connected.
|
||||
Data=Retrial number
|
||||
HID_HDEV_EVT_IN_REPORT Device sent an input report Data=Report Type pdata= pointer to BT_HDR
|
||||
(GKI buffer having report data.)
|
||||
HID_HDEV_EVT_HANDSHAKE Device sent SET_REPORT Data=Result-code pdata=NA.
|
||||
HID_HDEV_EVT_VC_UNPLUG Device sent Virtual Unplug Data=NA. pdata=NA.
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
HID_HDEV_EVT_OPEN,
|
||||
HID_HDEV_EVT_CLOSE,
|
||||
HID_HDEV_EVT_RETRYING,
|
||||
HID_HDEV_EVT_INTR_DATA,
|
||||
HID_HDEV_EVT_INTR_DATC,
|
||||
HID_HDEV_EVT_CTRL_DATA,
|
||||
HID_HDEV_EVT_CTRL_DATC,
|
||||
HID_HDEV_EVT_HANDSHAKE,
|
||||
HID_HDEV_EVT_VC_UNPLUG
|
||||
};
|
||||
typedef void (tHID_HOST_DEV_CALLBACK) (UINT8 dev_handle,
|
||||
BD_ADDR addr,
|
||||
UINT8 event, /* Event from HID-DEVICE. */
|
||||
UINT32 data, /* Integer data corresponding to the event.*/
|
||||
BT_HDR *p_buf ); /* Pointer data corresponding to the event. */
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostGetSDPRecord
|
||||
**
|
||||
** Description This function reads the device SDP record.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostGetSDPRecord (BD_ADDR addr,
|
||||
tSDP_DISCOVERY_DB *p_db,
|
||||
UINT32 db_len,
|
||||
tHID_HOST_SDP_CALLBACK *sdp_cback );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostRegister
|
||||
**
|
||||
** Description This function registers HID-Host with lower layers.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostRegister (tHID_HOST_DEV_CALLBACK *dev_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostDeregister
|
||||
**
|
||||
** Description This function is called when the host is about power down.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostDeregister(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostAddDev
|
||||
**
|
||||
** Description This is called so HID-host may manage this device.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostAddDev (BD_ADDR addr, UINT16 attr_mask,
|
||||
UINT8 *handle );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostRemoveDev
|
||||
**
|
||||
** Description This removes the device from list devices that host has to manage.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostRemoveDev (UINT8 dev_handle );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostOpenDev
|
||||
**
|
||||
** Description This function is called when the user wants to initiate a
|
||||
** connection attempt to a device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostOpenDev (UINT8 dev_handle );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostWriteDev
|
||||
**
|
||||
** Description This function is called when the host has a report to send.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostWriteDev(UINT8 dev_handle, UINT8 t_type,
|
||||
UINT8 param, UINT16 data,
|
||||
UINT8 report_id, BT_HDR *pbuf);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostCloseDev
|
||||
**
|
||||
** Description This function disconnects the device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostCloseDev(UINT8 dev_handle );
|
||||
|
||||
/*******************************************************************************
|
||||
** Function HID_HostInit
|
||||
**
|
||||
** Description This function initializes the control block and trace variable
|
||||
**
|
||||
** Returns void
|
||||
*******************************************************************************/
|
||||
extern void HID_HostInit(void);
|
||||
|
||||
/*******************************************************************************
|
||||
** Function HID_HostSetSecurityLevel
|
||||
**
|
||||
** Description This function sets the security level for the devices which
|
||||
** are marked by application as requiring security
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostSetSecurityLevel( char serv_name[], UINT8 sec_lvl );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function hid_known_hid_device
|
||||
**
|
||||
** Description This function checks if this device is of type HID Device
|
||||
**
|
||||
** Returns TRUE if device exists else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN hid_known_hid_device (BD_ADDR bd_addr);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostSetTraceLevel
|
||||
**
|
||||
** Description This function sets the trace level for HID Host. If called with
|
||||
** a value of 0xFF, it simply reads the current trace level.
|
||||
**
|
||||
** Returns the new (current) trace level
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 HID_HostSetTraceLevel (UINT8 new_level);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HIDH_API_H */
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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"
|
||||
|
||||
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
|
||||
+1143
File diff suppressed because it is too large
Load Diff
+762
@@ -0,0 +1,762 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains L2CAP internal definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef L2C_INT_H
|
||||
#define L2C_INT_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "btm_api.h"
|
||||
#include "gki.h"
|
||||
#include "l2c_api.h"
|
||||
#include "l2cdefs.h"
|
||||
#include "list.h"
|
||||
|
||||
#define L2CAP_MIN_MTU 48 /* Minimum acceptable MTU is 48 bytes */
|
||||
|
||||
/* Timeouts. Since L2CAP works off a 1-second list, all are in seconds.
|
||||
*/
|
||||
#define L2CAP_LINK_ROLE_SWITCH_TOUT 10 /* 10 seconds */
|
||||
#define L2CAP_LINK_CONNECT_TOUT 60 /* 30 seconds */
|
||||
#define L2CAP_LINK_CONNECT_TOUT_EXT 120 /* 120 seconds */
|
||||
#define L2CAP_ECHO_RSP_TOUT 30 /* 30 seconds */
|
||||
#define L2CAP_LINK_FLOW_CONTROL_TOUT 2 /* 2 seconds */
|
||||
#define L2CAP_LINK_DISCONNECT_TOUT 30 /* 30 seconds */
|
||||
|
||||
#ifndef L2CAP_CHNL_CONNECT_TOUT /* BTIF needs to override for internal project needs */
|
||||
#define L2CAP_CHNL_CONNECT_TOUT 60 /* 60 seconds */
|
||||
#endif
|
||||
|
||||
#define L2CAP_CHNL_CONNECT_TOUT_EXT 120 /* 120 seconds */
|
||||
#define L2CAP_CHNL_CFG_TIMEOUT 30 /* 30 seconds */
|
||||
#define L2CAP_CHNL_DISCONNECT_TOUT 10 /* 10 seconds */
|
||||
#define L2CAP_DELAY_CHECK_SM4 2 /* 2 seconds */
|
||||
#define L2CAP_WAIT_INFO_RSP_TOUT 3 /* 3 seconds */
|
||||
#define L2CAP_WAIT_UNPARK_TOUT 2 /* 2 seconds */
|
||||
#define L2CAP_LINK_INFO_RESP_TOUT 2 /* 2 seconds */
|
||||
#define L2CAP_BLE_LINK_CONNECT_TOUT 30 /* 30 seconds */
|
||||
#define L2CAP_BLE_CONN_PARAM_UPD_TOUT 30 /* 30 seconds */
|
||||
|
||||
/* quick timer uses millisecond unit */
|
||||
#define L2CAP_DEFAULT_RETRANS_TOUT 2000 /* 2000 milliseconds */
|
||||
#define L2CAP_DEFAULT_MONITOR_TOUT 12000 /* 12000 milliseconds */
|
||||
#define L2CAP_FCR_ACK_TOUT 200 /* 200 milliseconds */
|
||||
|
||||
/* Define the possible L2CAP channel states. The names of
|
||||
** the states may seem a bit strange, but they are taken from
|
||||
** the Bluetooth specification.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CST_CLOSED, /* Channel is in clodes state */
|
||||
CST_ORIG_W4_SEC_COMP, /* Originator waits security clearence */
|
||||
CST_TERM_W4_SEC_COMP, /* Acceptor waits security clearence */
|
||||
CST_W4_L2CAP_CONNECT_RSP, /* Waiting for peer conenct response */
|
||||
CST_W4_L2CA_CONNECT_RSP, /* Waiting for upper layer connect rsp */
|
||||
CST_CONFIG, /* Negotiating configuration */
|
||||
CST_OPEN, /* Data transfer state */
|
||||
CST_W4_L2CAP_DISCONNECT_RSP, /* Waiting for peer disconnect rsp */
|
||||
CST_W4_L2CA_DISCONNECT_RSP /* Waiting for upper layer disc rsp */
|
||||
} tL2C_CHNL_STATE;
|
||||
|
||||
/* Define the possible L2CAP link states
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LST_DISCONNECTED,
|
||||
LST_CONNECT_HOLDING,
|
||||
LST_CONNECTING_WAIT_SWITCH,
|
||||
LST_CONNECTING,
|
||||
LST_CONNECTED,
|
||||
LST_DISCONNECTING
|
||||
} tL2C_LINK_STATE;
|
||||
|
||||
|
||||
|
||||
/* Define input events to the L2CAP link and channel state machines. The names
|
||||
** of the events may seem a bit strange, but they are taken from
|
||||
** the Bluetooth specification.
|
||||
*/
|
||||
#define L2CEVT_LP_CONNECT_CFM 0 /* Lower layer connect confirm */
|
||||
#define L2CEVT_LP_CONNECT_CFM_NEG 1 /* Lower layer connect confirm (failed) */
|
||||
#define L2CEVT_LP_CONNECT_IND 2 /* Lower layer connect indication */
|
||||
#define L2CEVT_LP_DISCONNECT_IND 3 /* Lower layer disconnect indication */
|
||||
#define L2CEVT_LP_QOS_CFM 4 /* Lower layer QOS confirmation */
|
||||
#define L2CEVT_LP_QOS_CFM_NEG 5 /* Lower layer QOS confirmation (failed)*/
|
||||
#define L2CEVT_LP_QOS_VIOLATION_IND 6 /* Lower layer QOS violation indication */
|
||||
|
||||
#define L2CEVT_SEC_COMP 7 /* Security cleared successfully */
|
||||
#define L2CEVT_SEC_COMP_NEG 8 /* Security procedure failed */
|
||||
|
||||
#define L2CEVT_L2CAP_CONNECT_REQ 10 /* Peer connection request */
|
||||
#define L2CEVT_L2CAP_CONNECT_RSP 11 /* Peer connection response */
|
||||
#define L2CEVT_L2CAP_CONNECT_RSP_PND 12 /* Peer connection response pending */
|
||||
#define L2CEVT_L2CAP_CONNECT_RSP_NEG 13 /* Peer connection response (failed) */
|
||||
#define L2CEVT_L2CAP_CONFIG_REQ 14 /* Peer configuration request */
|
||||
#define L2CEVT_L2CAP_CONFIG_RSP 15 /* Peer configuration response */
|
||||
#define L2CEVT_L2CAP_CONFIG_RSP_NEG 16 /* Peer configuration response (failed) */
|
||||
#define L2CEVT_L2CAP_DISCONNECT_REQ 17 /* Peer disconnect request */
|
||||
#define L2CEVT_L2CAP_DISCONNECT_RSP 18 /* Peer disconnect response */
|
||||
#define L2CEVT_L2CAP_INFO_RSP 19 /* Peer information response */
|
||||
#define L2CEVT_L2CAP_DATA 20 /* Peer data */
|
||||
|
||||
#define L2CEVT_L2CA_CONNECT_REQ 21 /* Upper layer connect request */
|
||||
#define L2CEVT_L2CA_CONNECT_RSP 22 /* Upper layer connect response */
|
||||
#define L2CEVT_L2CA_CONNECT_RSP_NEG 23 /* Upper layer connect response (failed)*/
|
||||
#define L2CEVT_L2CA_CONFIG_REQ 24 /* Upper layer config request */
|
||||
#define L2CEVT_L2CA_CONFIG_RSP 25 /* Upper layer config response */
|
||||
#define L2CEVT_L2CA_CONFIG_RSP_NEG 26 /* Upper layer config response (failed) */
|
||||
#define L2CEVT_L2CA_DISCONNECT_REQ 27 /* Upper layer disconnect request */
|
||||
#define L2CEVT_L2CA_DISCONNECT_RSP 28 /* Upper layer disconnect response */
|
||||
#define L2CEVT_L2CA_DATA_READ 29 /* Upper layer data read */
|
||||
#define L2CEVT_L2CA_DATA_WRITE 30 /* Upper layer data write */
|
||||
#define L2CEVT_L2CA_FLUSH_REQ 31 /* Upper layer flush */
|
||||
|
||||
#define L2CEVT_TIMEOUT 32 /* Timeout */
|
||||
#define L2CEVT_SEC_RE_SEND_CMD 33 /* btm_sec has enough info to proceed */
|
||||
|
||||
#define L2CEVT_ACK_TIMEOUT 34 /* RR delay timeout */
|
||||
|
||||
|
||||
/* Bitmask to skip over Broadcom feature reserved (ID) to avoid sending two
|
||||
successive ID values, '0' id only or both */
|
||||
#define L2CAP_ADJ_BRCM_ID 0x1
|
||||
#define L2CAP_ADJ_ZERO_ID 0x2
|
||||
#define L2CAP_ADJ_ID 0x3
|
||||
|
||||
/* Return values for l2cu_process_peer_cfg_req() */
|
||||
#define L2CAP_PEER_CFG_UNACCEPTABLE 0
|
||||
#define L2CAP_PEER_CFG_OK 1
|
||||
#define L2CAP_PEER_CFG_DISCONNECT 2
|
||||
|
||||
/* eL2CAP option constants */
|
||||
#define L2CAP_MIN_RETRANS_TOUT 2000 /* Min retransmission timeout if no flush timeout or PBF */
|
||||
#define L2CAP_MIN_MONITOR_TOUT 12000 /* Min monitor timeout if no flush timeout or PBF */
|
||||
|
||||
#define L2CAP_MAX_FCR_CFG_TRIES 2 /* Config attempts before disconnecting */
|
||||
|
||||
typedef uint8_t tL2C_BLE_FIXED_CHNLS_MASK;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 next_tx_seq; /* Next sequence number to be Tx'ed */
|
||||
UINT8 last_rx_ack; /* Last sequence number ack'ed by the peer */
|
||||
UINT8 next_seq_expected; /* Next peer sequence number expected */
|
||||
UINT8 last_ack_sent; /* Last peer sequence number ack'ed */
|
||||
UINT8 num_tries; /* Number of retries to send a packet */
|
||||
UINT8 max_held_acks; /* Max acks we can hold before sending */
|
||||
|
||||
BOOLEAN remote_busy; /* TRUE if peer has flowed us off */
|
||||
BOOLEAN local_busy; /* TRUE if we have flowed off the peer */
|
||||
|
||||
BOOLEAN rej_sent; /* Reject was sent */
|
||||
BOOLEAN srej_sent; /* Selective Reject was sent */
|
||||
BOOLEAN wait_ack; /* Transmitter is waiting ack (poll sent) */
|
||||
BOOLEAN rej_after_srej; /* Send a REJ when SREJ clears */
|
||||
|
||||
BOOLEAN send_f_rsp; /* We need to send an F-bit response */
|
||||
|
||||
UINT16 rx_sdu_len; /* Length of the SDU being received */
|
||||
BT_HDR *p_rx_sdu; /* Buffer holding the SDU being received */
|
||||
BUFFER_Q waiting_for_ack_q; /* Buffers sent and waiting for peer to ack */
|
||||
BUFFER_Q srej_rcv_hold_q; /* Buffers rcvd but held pending SREJ rsp */
|
||||
BUFFER_Q retrans_q; /* Buffers being retransmitted */
|
||||
|
||||
TIMER_LIST_ENT ack_timer; /* Timer delaying RR */
|
||||
TIMER_LIST_ENT mon_retrans_timer; /* Timer Monitor or Retransmission */
|
||||
|
||||
#if (L2CAP_ERTM_STATS == TRUE)
|
||||
UINT32 connect_tick_count; /* Time channel was established */
|
||||
UINT32 ertm_pkt_counts[2]; /* Packets sent and received */
|
||||
UINT32 ertm_byte_counts[2]; /* Bytes sent and received */
|
||||
UINT32 s_frames_sent[4]; /* S-frames sent (RR, REJ, RNR, SREJ) */
|
||||
UINT32 s_frames_rcvd[4]; /* S-frames rcvd (RR, REJ, RNR, SREJ) */
|
||||
UINT32 xmit_window_closed; /* # of times the xmit window was closed */
|
||||
UINT32 controller_idle; /* # of times less than 2 packets in controller */
|
||||
/* when the xmit window was closed */
|
||||
UINT32 pkts_retransmitted; /* # of packets that were retransmitted */
|
||||
UINT32 retrans_touts; /* # of retransmission timouts */
|
||||
UINT32 xmit_ack_touts; /* # of xmit ack timouts */
|
||||
|
||||
#define L2CAP_ERTM_STATS_NUM_AVG 10
|
||||
#define L2CAP_ERTM_STATS_AVG_NUM_SAMPLES 100
|
||||
UINT32 ack_delay_avg_count;
|
||||
UINT32 ack_delay_avg_index;
|
||||
UINT32 throughput_start;
|
||||
UINT32 throughput[L2CAP_ERTM_STATS_NUM_AVG];
|
||||
UINT32 ack_delay_avg[L2CAP_ERTM_STATS_NUM_AVG];
|
||||
UINT32 ack_delay_min[L2CAP_ERTM_STATS_NUM_AVG];
|
||||
UINT32 ack_delay_max[L2CAP_ERTM_STATS_NUM_AVG];
|
||||
UINT32 ack_q_count_avg[L2CAP_ERTM_STATS_NUM_AVG];
|
||||
UINT32 ack_q_count_min[L2CAP_ERTM_STATS_NUM_AVG];
|
||||
UINT32 ack_q_count_max[L2CAP_ERTM_STATS_NUM_AVG];
|
||||
#endif
|
||||
} tL2C_FCRB;
|
||||
|
||||
|
||||
/* Define a registration control block. Every application (e.g. RFCOMM, SDP,
|
||||
** TCS etc) that registers with L2CAP is assigned one of these.
|
||||
*/
|
||||
#if (L2CAP_UCD_INCLUDED == TRUE)
|
||||
#define L2C_UCD_RCB_ID 0x00
|
||||
#define L2C_UCD_STATE_UNUSED 0x00
|
||||
#define L2C_UCD_STATE_W4_DATA 0x01
|
||||
#define L2C_UCD_STATE_W4_RECEPTION 0x02
|
||||
#define L2C_UCD_STATE_W4_MTU 0x04
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 state;
|
||||
tL2CAP_UCD_CB_INFO cb_info;
|
||||
} tL2C_UCD_REG;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BOOLEAN in_use;
|
||||
UINT16 psm;
|
||||
UINT16 real_psm; /* This may be a dummy RCB for an o/b connection but */
|
||||
/* this is the real PSM that we need to connect to */
|
||||
#if (L2CAP_UCD_INCLUDED == TRUE)
|
||||
tL2C_UCD_REG ucd;
|
||||
#endif
|
||||
|
||||
tL2CAP_APPL_INFO api;
|
||||
} tL2C_RCB;
|
||||
|
||||
|
||||
/* Define a channel control block (CCB). There may be many channel control blocks
|
||||
** between the same two Bluetooth devices (i.e. on the same link).
|
||||
** Each CCB has unique local and remote CIDs. All channel control blocks on
|
||||
** the same physical link and are chained together.
|
||||
*/
|
||||
typedef struct t_l2c_ccb
|
||||
{
|
||||
BOOLEAN in_use; /* TRUE when in use, FALSE when not */
|
||||
tL2C_CHNL_STATE chnl_state; /* Channel state */
|
||||
|
||||
struct t_l2c_ccb *p_next_ccb; /* Next CCB in the chain */
|
||||
struct t_l2c_ccb *p_prev_ccb; /* Previous CCB in the chain */
|
||||
struct t_l2c_linkcb *p_lcb; /* Link this CCB is assigned to */
|
||||
|
||||
UINT16 local_cid; /* Local CID */
|
||||
UINT16 remote_cid; /* Remote CID */
|
||||
|
||||
TIMER_LIST_ENT timer_entry; /* CCB Timer List Entry */
|
||||
|
||||
tL2C_RCB *p_rcb; /* Registration CB for this Channel */
|
||||
bool should_free_rcb; /* True if RCB was allocated on the heap */
|
||||
|
||||
#define IB_CFG_DONE 0x01
|
||||
#define OB_CFG_DONE 0x02
|
||||
#define RECONFIG_FLAG 0x04 /* True after initial configuration */
|
||||
#define CFG_DONE_MASK (IB_CFG_DONE | OB_CFG_DONE)
|
||||
|
||||
UINT8 config_done; /* Configuration flag word */
|
||||
UINT8 local_id; /* Transaction ID for local trans */
|
||||
UINT8 remote_id; /* Transaction ID for local */
|
||||
|
||||
#define CCB_FLAG_NO_RETRY 0x01 /* no more retry */
|
||||
#define CCB_FLAG_SENT_PENDING 0x02 /* already sent pending response */
|
||||
UINT8 flags;
|
||||
|
||||
tL2CAP_CFG_INFO our_cfg; /* Our saved configuration options */
|
||||
tL2CAP_CH_CFG_BITS peer_cfg_bits; /* Store what peer wants to configure */
|
||||
tL2CAP_CFG_INFO peer_cfg; /* Peer's saved configuration options */
|
||||
|
||||
BUFFER_Q xmit_hold_q; /* Transmit data hold queue */
|
||||
BOOLEAN cong_sent; /* Set when congested status sent */
|
||||
UINT16 buff_quota; /* Buffer quota before sending congestion */
|
||||
|
||||
tL2CAP_CHNL_PRIORITY ccb_priority; /* Channel priority */
|
||||
tL2CAP_CHNL_DATA_RATE tx_data_rate; /* Channel Tx data rate */
|
||||
tL2CAP_CHNL_DATA_RATE rx_data_rate; /* Channel Rx data rate */
|
||||
|
||||
/* Fields used for eL2CAP */
|
||||
tL2CAP_ERTM_INFO ertm_info;
|
||||
tL2C_FCRB fcrb;
|
||||
UINT16 tx_mps; /* TX MPS adjusted based on current controller */
|
||||
UINT16 max_rx_mtu;
|
||||
UINT8 fcr_cfg_tries; /* Max number of negotiation attempts */
|
||||
BOOLEAN peer_cfg_already_rejected; /* If mode rejected once, set to TRUE */
|
||||
BOOLEAN out_cfg_fcr_present; /* TRUE if cfg response shoulkd include fcr options */
|
||||
|
||||
#define L2CAP_CFG_FCS_OUR 0x01 /* Our desired config FCS option */
|
||||
#define L2CAP_CFG_FCS_PEER 0x02 /* Peer's desired config FCS option */
|
||||
#define L2CAP_BYPASS_FCS (L2CAP_CFG_FCS_OUR | L2CAP_CFG_FCS_PEER)
|
||||
UINT8 bypass_fcs;
|
||||
|
||||
#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
|
||||
BOOLEAN is_flushable; /* TRUE if channel is flushable */
|
||||
#endif
|
||||
|
||||
#if (L2CAP_NUM_FIXED_CHNLS > 0) || (L2CAP_UCD_INCLUDED == TRUE)
|
||||
UINT16 fixed_chnl_idle_tout; /* Idle timeout to use for the fixed channel */
|
||||
#endif
|
||||
UINT16 tx_data_len;
|
||||
} tL2C_CCB;
|
||||
|
||||
/***********************************************************************
|
||||
** Define a queue of linked CCBs.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
tL2C_CCB *p_first_ccb; /* The first channel in this queue */
|
||||
tL2C_CCB *p_last_ccb; /* The last channel in this queue */
|
||||
} tL2C_CCB_Q;
|
||||
|
||||
#if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE)
|
||||
|
||||
/* Round-Robin service for the same priority channels */
|
||||
#define L2CAP_NUM_CHNL_PRIORITY 3 /* Total number of priority group (high, medium, low)*/
|
||||
#define L2CAP_CHNL_PRIORITY_WEIGHT 5 /* weight per priority for burst transmission quota */
|
||||
#define L2CAP_GET_PRIORITY_QUOTA(pri) ((L2CAP_NUM_CHNL_PRIORITY - (pri)) * L2CAP_CHNL_PRIORITY_WEIGHT)
|
||||
|
||||
/* CCBs within the same LCB are served in round robin with priority */
|
||||
/* It will make sure that low priority channel (for example, HF signaling on RFCOMM) */
|
||||
/* can be sent to headset even if higher priority channel (for example, AV media channel) */
|
||||
/* is congested. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tL2C_CCB *p_serve_ccb; /* current serving ccb within priority group */
|
||||
tL2C_CCB *p_first_ccb; /* first ccb of priority group */
|
||||
UINT8 num_ccb; /* number of channels in priority group */
|
||||
UINT8 quota; /* burst transmission quota */
|
||||
} tL2C_RR_SERV;
|
||||
|
||||
#endif /* (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE) */
|
||||
|
||||
/* Define a link control block. There is one link control block between
|
||||
** this device and any other device (i.e. BD ADDR).
|
||||
*/
|
||||
typedef struct t_l2c_linkcb
|
||||
{
|
||||
BOOLEAN in_use; /* TRUE when in use, FALSE when not */
|
||||
tL2C_LINK_STATE link_state;
|
||||
|
||||
TIMER_LIST_ENT timer_entry; /* Timer list entry for timeout evt */
|
||||
UINT16 handle; /* The handle used with LM */
|
||||
|
||||
tL2C_CCB_Q ccb_queue; /* Queue of CCBs on this LCB */
|
||||
|
||||
tL2C_CCB *p_pending_ccb; /* ccb of waiting channel during link disconnect */
|
||||
TIMER_LIST_ENT info_timer_entry; /* Timer entry for info resp timeout evt */
|
||||
BD_ADDR remote_bd_addr; /* The BD address of the remote */
|
||||
|
||||
UINT8 link_role; /* Master or slave */
|
||||
UINT8 id;
|
||||
UINT8 cur_echo_id; /* Current id value for echo request */
|
||||
tL2CA_ECHO_RSP_CB *p_echo_rsp_cb; /* Echo response callback */
|
||||
UINT16 idle_timeout; /* Idle timeout */
|
||||
BOOLEAN is_bonding; /* True - link active only for bonding */
|
||||
|
||||
UINT16 link_flush_tout; /* Flush timeout used */
|
||||
|
||||
UINT16 link_xmit_quota; /* Num outstanding pkts allowed */
|
||||
UINT16 sent_not_acked; /* Num packets sent but not acked */
|
||||
|
||||
BOOLEAN partial_segment_being_sent; /* Set TRUE when a partial segment */
|
||||
/* is being sent. */
|
||||
BOOLEAN w4_info_rsp; /* TRUE when info request is active */
|
||||
UINT8 info_rx_bits; /* set 1 if received info type */
|
||||
UINT32 peer_ext_fea; /* Peer's extended features mask */
|
||||
list_t *link_xmit_data_q; /* Link transmit data buffer queue */
|
||||
|
||||
UINT8 peer_chnl_mask[L2CAP_FIXED_CHNL_ARRAY_SIZE];
|
||||
#if (L2CAP_UCD_INCLUDED == TRUE)
|
||||
UINT16 ucd_mtu; /* peer MTU on UCD */
|
||||
BUFFER_Q ucd_out_sec_pending_q; /* Security pending outgoing UCD packet */
|
||||
BUFFER_Q ucd_in_sec_pending_q; /* Security pending incoming UCD packet */
|
||||
#endif
|
||||
|
||||
BT_HDR *p_hcit_rcv_acl; /* Current HCIT ACL buf being rcvd */
|
||||
UINT16 idle_timeout_sv; /* Save current Idle timeout */
|
||||
UINT8 acl_priority; /* L2C_PRIORITY_NORMAL or L2C_PRIORITY_HIGH */
|
||||
tL2CA_NOCP_CB *p_nocp_cb; /* Num Cmpl pkts callback */
|
||||
|
||||
#if (L2CAP_NUM_FIXED_CHNLS > 0)
|
||||
tL2C_CCB *p_fixed_ccbs[L2CAP_NUM_FIXED_CHNLS];
|
||||
UINT16 disc_reason;
|
||||
#endif
|
||||
|
||||
tBT_TRANSPORT transport;
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
tBLE_ADDR_TYPE ble_addr_type;
|
||||
UINT16 tx_data_len; /* tx data length used in data length extension */
|
||||
|
||||
#define L2C_BLE_CONN_UPDATE_DISABLE 0x1 /* disable update connection parameters */
|
||||
#define L2C_BLE_NEW_CONN_PARAM 0x2 /* new connection parameter to be set */
|
||||
#define L2C_BLE_UPDATE_PENDING 0x4 /* waiting for connection update finished */
|
||||
#define L2C_BLE_NOT_DEFAULT_PARAM 0x8 /* not using default connection parameters */
|
||||
UINT8 conn_update_mask;
|
||||
|
||||
UINT16 min_interval; /* parameters as requested by peripheral */
|
||||
UINT16 max_interval;
|
||||
UINT16 latency;
|
||||
UINT16 timeout;
|
||||
|
||||
#endif
|
||||
|
||||
#if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE)
|
||||
/* each priority group is limited burst transmission */
|
||||
/* round robin service for the same priority channels */
|
||||
tL2C_RR_SERV rr_serv[L2CAP_NUM_CHNL_PRIORITY];
|
||||
UINT8 rr_pri; /* current serving priority group */
|
||||
#endif
|
||||
|
||||
} tL2C_LCB;
|
||||
|
||||
/* Define the L2CAP control structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
UINT8 l2cap_trace_level;
|
||||
UINT16 controller_xmit_window; /* Total ACL window for all links */
|
||||
|
||||
UINT16 round_robin_quota; /* Round-robin link quota */
|
||||
UINT16 round_robin_unacked; /* Round-robin unacked */
|
||||
BOOLEAN check_round_robin; /* Do a round robin check */
|
||||
|
||||
BOOLEAN is_cong_cback_context;
|
||||
|
||||
tL2C_LCB lcb_pool[MAX_L2CAP_LINKS]; /* Link Control Block pool */
|
||||
tL2C_CCB ccb_pool[MAX_L2CAP_CHANNELS]; /* Channel Control Block pool */
|
||||
tL2C_RCB rcb_pool[MAX_L2CAP_CLIENTS]; /* Registration info pool */
|
||||
|
||||
tL2C_CCB *p_free_ccb_first; /* Pointer to first free CCB */
|
||||
tL2C_CCB *p_free_ccb_last; /* Pointer to last free CCB */
|
||||
|
||||
UINT8 desire_role; /* desire to be master/slave when accepting a connection */
|
||||
BOOLEAN disallow_switch; /* FALSE, to allow switch at create conn */
|
||||
UINT16 num_lm_acl_bufs; /* # of ACL buffers on controller */
|
||||
UINT16 idle_timeout; /* Idle timeout */
|
||||
|
||||
list_t *rcv_pending_q; /* Recv pending queue */
|
||||
TIMER_LIST_ENT rcv_hold_tle; /* Timer list entry for rcv hold */
|
||||
|
||||
tL2C_LCB *p_cur_hcit_lcb; /* Current HCI Transport buffer */
|
||||
UINT16 num_links_active; /* Number of links active */
|
||||
|
||||
#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
|
||||
UINT16 non_flushable_pbf; /* L2CAP_PKT_START_NON_FLUSHABLE if controller supports */
|
||||
/* Otherwise, L2CAP_PKT_START */
|
||||
BOOLEAN is_flush_active; /* TRUE if an HCI_Enhanced_Flush has been sent */
|
||||
#endif
|
||||
|
||||
#if L2CAP_CONFORMANCE_TESTING == TRUE
|
||||
UINT32 test_info_resp; /* Conformance testing needs a dynamic response */
|
||||
#endif
|
||||
|
||||
#if (L2CAP_NUM_FIXED_CHNLS > 0)
|
||||
tL2CAP_FIXED_CHNL_REG fixed_reg[L2CAP_NUM_FIXED_CHNLS]; /* Reg info for fixed channels */
|
||||
#endif
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
UINT16 num_ble_links_active; /* Number of LE links active */
|
||||
BOOLEAN is_ble_connecting;
|
||||
BD_ADDR ble_connecting_bda;
|
||||
UINT16 controller_le_xmit_window; /* Total ACL window for all links */
|
||||
tL2C_BLE_FIXED_CHNLS_MASK l2c_ble_fixed_chnls_mask; // LE fixed channels mask
|
||||
UINT16 num_lm_ble_bufs; /* # of ACL buffers on controller */
|
||||
UINT16 ble_round_robin_quota; /* Round-robin link quota */
|
||||
UINT16 ble_round_robin_unacked; /* Round-robin unacked */
|
||||
BOOLEAN ble_check_round_robin; /* Do a round robin check */
|
||||
#endif
|
||||
|
||||
tL2CA_ECHO_DATA_CB *p_echo_data_cb; /* Echo data callback */
|
||||
|
||||
#if (defined(L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE) && (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE))
|
||||
UINT16 high_pri_min_xmit_quota; /* Minimum number of ACL credit for high priority link */
|
||||
#endif /* (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE) */
|
||||
|
||||
UINT16 dyn_psm;
|
||||
} tL2C_CB;
|
||||
|
||||
|
||||
|
||||
/* Define a structure that contains the information about a connection.
|
||||
** This structure is used to pass between functions, and not all the
|
||||
** fields will always be filled in.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
BD_ADDR bd_addr; /* Remote BD address */
|
||||
UINT8 status; /* Connection status */
|
||||
UINT16 psm; /* PSM of the connection */
|
||||
UINT16 l2cap_result; /* L2CAP result */
|
||||
UINT16 l2cap_status; /* L2CAP status */
|
||||
UINT16 remote_cid; /* Remote CID */
|
||||
} tL2C_CONN_INFO;
|
||||
|
||||
|
||||
typedef void (tL2C_FCR_MGMT_EVT_HDLR) (UINT8, tL2C_CCB *);
|
||||
|
||||
/* The offset in a buffer that L2CAP will use when building commands.
|
||||
*/
|
||||
#define L2CAP_SEND_CMD_OFFSET 0
|
||||
|
||||
|
||||
/* Number of ACL buffers to use for high priority channel
|
||||
*/
|
||||
#if (!defined(L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE) || (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == FALSE))
|
||||
#define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA_A (L2CAP_HIGH_PRI_MIN_XMIT_QUOTA)
|
||||
#else
|
||||
#define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA_A (l2cb.high_pri_min_xmit_quota)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* L2CAP global data
|
||||
************************************
|
||||
*/
|
||||
#if (!defined L2C_DYNAMIC_MEMORY) || (L2C_DYNAMIC_MEMORY == FALSE)
|
||||
extern tL2C_CB l2cb;
|
||||
#else
|
||||
extern tL2C_CB *l2c_cb_ptr;
|
||||
#define l2cb (*l2c_cb_ptr)
|
||||
#endif
|
||||
|
||||
|
||||
/* Functions provided by l2c_main.c
|
||||
************************************
|
||||
*/
|
||||
void l2c_init(void);
|
||||
void l2c_free(void);
|
||||
|
||||
extern void l2c_process_timeout (TIMER_LIST_ENT *p_tle);
|
||||
extern UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flag);
|
||||
extern void l2c_rcv_acl_data (BT_HDR *p_msg);
|
||||
extern void l2c_process_held_packets (BOOLEAN timed_out);
|
||||
|
||||
/* Functions provided by l2c_utils.c
|
||||
************************************
|
||||
*/
|
||||
extern tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPORT transport);
|
||||
extern BOOLEAN l2cu_start_post_bond_timer (UINT16 handle);
|
||||
extern void l2cu_release_lcb (tL2C_LCB *p_lcb);
|
||||
extern tL2C_LCB *l2cu_find_lcb_by_bd_addr (BD_ADDR p_bd_addr, tBT_TRANSPORT transport);
|
||||
extern tL2C_LCB *l2cu_find_lcb_by_handle (UINT16 handle);
|
||||
extern void l2cu_update_lcb_4_bonding (BD_ADDR p_bd_addr, BOOLEAN is_bonding);
|
||||
|
||||
extern UINT8 l2cu_get_conn_role (tL2C_LCB *p_this_lcb);
|
||||
extern BOOLEAN l2cu_set_acl_priority (BD_ADDR bd_addr, UINT8 priority, BOOLEAN reset_after_rs);
|
||||
|
||||
extern void l2cu_enqueue_ccb (tL2C_CCB *p_ccb);
|
||||
extern void l2cu_dequeue_ccb (tL2C_CCB *p_ccb);
|
||||
extern void l2cu_change_pri_ccb (tL2C_CCB *p_ccb, tL2CAP_CHNL_PRIORITY priority);
|
||||
|
||||
extern tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid);
|
||||
extern void l2cu_release_ccb (tL2C_CCB *p_ccb);
|
||||
extern tL2C_CCB *l2cu_find_ccb_by_cid (tL2C_LCB *p_lcb, UINT16 local_cid);
|
||||
extern tL2C_CCB *l2cu_find_ccb_by_remote_cid (tL2C_LCB *p_lcb, UINT16 remote_cid);
|
||||
extern void l2cu_adj_id (tL2C_LCB *p_lcb, UINT8 adj_mask);
|
||||
extern BOOLEAN l2c_is_cmd_rejected (UINT8 cmd_code, UINT8 id, tL2C_LCB *p_lcb);
|
||||
|
||||
extern void l2cu_send_peer_cmd_reject (tL2C_LCB *p_lcb, UINT16 reason,
|
||||
UINT8 rem_id,UINT16 p1, UINT16 p2);
|
||||
extern void l2cu_send_peer_connect_req (tL2C_CCB *p_ccb);
|
||||
extern void l2cu_send_peer_connect_rsp (tL2C_CCB *p_ccb, UINT16 result, UINT16 status);
|
||||
extern void l2cu_send_peer_config_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
extern void l2cu_send_peer_config_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
extern void l2cu_send_peer_config_rej (tL2C_CCB *p_ccb, UINT8 *p_data, UINT16 data_len, UINT16 rej_len);
|
||||
extern void l2cu_send_peer_disc_req (tL2C_CCB *p_ccb);
|
||||
extern void l2cu_send_peer_disc_rsp (tL2C_LCB *p_lcb, UINT8 remote_id, UINT16 local_cid, UINT16 remote_cid);
|
||||
extern void l2cu_send_peer_echo_req (tL2C_LCB *p_lcb, UINT8 *p_data, UINT16 data_len);
|
||||
extern void l2cu_send_peer_echo_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 data_len);
|
||||
extern void l2cu_send_peer_info_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT16 info_type);
|
||||
extern void l2cu_reject_connection (tL2C_LCB *p_lcb, UINT16 remote_cid, UINT8 rem_id, UINT16 result);
|
||||
extern void l2cu_send_peer_info_req (tL2C_LCB *p_lcb, UINT16 info_type);
|
||||
extern void l2cu_set_acl_hci_header (BT_HDR *p_buf, tL2C_CCB *p_ccb);
|
||||
extern void l2cu_check_channel_congestion (tL2C_CCB *p_ccb);
|
||||
extern void l2cu_disconnect_chnl (tL2C_CCB *p_ccb);
|
||||
|
||||
#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
|
||||
extern void l2cu_set_non_flushable_pbf(BOOLEAN);
|
||||
#endif
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout);
|
||||
extern void l2cu_send_peer_ble_par_rsp (tL2C_LCB *p_lcb, UINT16 reason, UINT8 rem_id);
|
||||
#endif
|
||||
|
||||
extern BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR_OPTS *p_fcr);
|
||||
extern void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb);
|
||||
extern void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb);
|
||||
|
||||
/* Functions provided by l2c_ucd.c
|
||||
************************************
|
||||
*/
|
||||
#if (L2CAP_UCD_INCLUDED == TRUE)
|
||||
void l2c_ucd_delete_sec_pending_q(tL2C_LCB *p_lcb);
|
||||
void l2c_ucd_enqueue_pending_out_sec_q(tL2C_CCB *p_ccb, void *p_data);
|
||||
BOOLEAN l2c_ucd_check_pending_info_req(tL2C_CCB *p_ccb);
|
||||
BOOLEAN l2c_ucd_check_pending_out_sec_q(tL2C_CCB *p_ccb);
|
||||
void l2c_ucd_send_pending_out_sec_q(tL2C_CCB *p_ccb);
|
||||
void l2c_ucd_discard_pending_out_sec_q(tL2C_CCB *p_ccb);
|
||||
BOOLEAN l2c_ucd_check_pending_in_sec_q(tL2C_CCB *p_ccb);
|
||||
void l2c_ucd_send_pending_in_sec_q(tL2C_CCB *p_ccb);
|
||||
void l2c_ucd_discard_pending_in_sec_q(tL2C_CCB *p_ccb);
|
||||
BOOLEAN l2c_ucd_check_rx_pkts(tL2C_LCB *p_lcb, BT_HDR *p_msg);
|
||||
BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data);
|
||||
#endif
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout);
|
||||
extern void l2cu_send_peer_ble_par_rsp (tL2C_LCB *p_lcb, UINT16 reason, UINT8 rem_id);
|
||||
#endif
|
||||
|
||||
extern BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR_OPTS *p_fcr);
|
||||
extern void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb);
|
||||
extern void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb);
|
||||
|
||||
|
||||
/* Functions provided for Broadcom Aware
|
||||
****************************************
|
||||
*/
|
||||
extern BOOLEAN l2cu_check_feature_req (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 data_len);
|
||||
extern void l2cu_check_feature_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 data_len);
|
||||
extern void l2cu_send_feature_req (tL2C_CCB *p_ccb);
|
||||
|
||||
extern tL2C_RCB *l2cu_allocate_rcb (UINT16 psm);
|
||||
extern tL2C_RCB *l2cu_find_rcb_by_psm (UINT16 psm);
|
||||
extern void l2cu_release_rcb (tL2C_RCB *p_rcb);
|
||||
|
||||
extern UINT8 l2cu_process_peer_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
extern void l2cu_process_peer_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
extern void l2cu_process_our_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
extern void l2cu_process_our_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
|
||||
extern void l2cu_device_reset (void);
|
||||
extern tL2C_LCB *l2cu_find_lcb_by_state (tL2C_LINK_STATE state);
|
||||
extern BOOLEAN l2cu_lcb_disconnecting (void);
|
||||
|
||||
extern BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport);
|
||||
extern BOOLEAN l2cu_create_conn_after_switch (tL2C_LCB *p_lcb);
|
||||
extern BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb);
|
||||
extern void l2cu_resubmit_pending_sec_req (BD_ADDR p_bda);
|
||||
extern void l2cu_initialize_amp_ccb (tL2C_LCB *p_lcb);
|
||||
extern void l2cu_adjust_out_mps (tL2C_CCB *p_ccb);
|
||||
|
||||
/* Functions provided by l2c_link.c
|
||||
************************************
|
||||
*/
|
||||
extern BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr);
|
||||
extern BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda);
|
||||
extern BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason);
|
||||
extern BOOLEAN l2c_link_hci_qos_violation (UINT16 handle);
|
||||
extern void l2c_link_timeout (tL2C_LCB *p_lcb);
|
||||
extern void l2c_info_timeout (tL2C_LCB *p_lcb);
|
||||
extern void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf);
|
||||
extern void l2c_link_adjust_allocation (void);
|
||||
extern void l2c_link_process_num_completed_pkts (UINT8 *p);
|
||||
extern void l2c_link_process_num_completed_blocks (UINT8 controller_id, UINT8 *p, UINT16 evt_len);
|
||||
extern void l2c_link_processs_num_bufs (UINT16 num_lm_acl_bufs);
|
||||
extern UINT8 l2c_link_pkts_rcvd (UINT16 *num_pkts, UINT16 *handles);
|
||||
extern void l2c_link_role_changed (BD_ADDR bd_addr, UINT8 new_role, UINT8 hci_status);
|
||||
extern void l2c_link_sec_comp (BD_ADDR p_bda, tBT_TRANSPORT trasnport, void *p_ref_data, UINT8 status);
|
||||
extern void l2c_link_segments_xmitted (BT_HDR *p_msg);
|
||||
extern void l2c_pin_code_request (BD_ADDR bd_addr);
|
||||
extern void l2c_link_adjust_chnl_allocation (void);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern void l2c_link_processs_ble_num_bufs (UINT16 num_lm_acl_bufs);
|
||||
#endif
|
||||
|
||||
#if L2CAP_WAKE_PARKED_LINK == TRUE
|
||||
extern BOOLEAN l2c_link_check_power_mode ( tL2C_LCB *p_lcb );
|
||||
#define L2C_LINK_CHECK_POWER_MODE(x) l2c_link_check_power_mode ((x))
|
||||
#else // L2CAP_WAKE_PARKED_LINK
|
||||
#define L2C_LINK_CHECK_POWER_MODE(x) (FALSE)
|
||||
#endif // L2CAP_WAKE_PARKED_LINK
|
||||
|
||||
#if L2CAP_CONFORMANCE_TESTING == TRUE
|
||||
/* Used only for conformance testing */
|
||||
extern void l2cu_set_info_rsp_mask (UINT32 mask);
|
||||
#endif
|
||||
|
||||
/* Functions provided by l2c_csm.c
|
||||
************************************
|
||||
*/
|
||||
extern void l2c_csm_execute (tL2C_CCB *p_ccb, UINT16 event, void *p_data);
|
||||
|
||||
extern void l2c_enqueue_peer_data (tL2C_CCB *p_ccb, BT_HDR *p_buf);
|
||||
|
||||
|
||||
/* Functions provided by l2c_fcr.c
|
||||
************************************
|
||||
*/
|
||||
extern void l2c_fcr_cleanup (tL2C_CCB *p_ccb);
|
||||
extern void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf);
|
||||
extern void l2c_fcr_proc_tout (tL2C_CCB *p_ccb);
|
||||
extern void l2c_fcr_proc_ack_tout (tL2C_CCB *p_ccb);
|
||||
extern void l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit);
|
||||
extern BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes, UINT8 pool);
|
||||
extern BOOLEAN l2c_fcr_is_flow_controlled (tL2C_CCB *p_ccb);
|
||||
extern BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length);
|
||||
extern void l2c_fcr_start_timer (tL2C_CCB *p_ccb);
|
||||
|
||||
/* Configuration negotiation */
|
||||
extern UINT8 l2c_fcr_chk_chan_modes (tL2C_CCB *p_ccb);
|
||||
extern BOOLEAN l2c_fcr_adj_our_req_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
extern void l2c_fcr_adj_our_rsp_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_peer_cfg);
|
||||
extern BOOLEAN l2c_fcr_renegotiate_chan(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
extern UINT8 l2c_fcr_process_peer_cfg_req(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
extern void l2c_fcr_adj_monitor_retran_timeout (tL2C_CCB *p_ccb);
|
||||
extern void l2c_fcr_stop_timer (tL2C_CCB *p_ccb);
|
||||
|
||||
/* Functions provided by l2c_ble.c
|
||||
************************************
|
||||
*/
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern BOOLEAN l2cble_create_conn (tL2C_LCB *p_lcb);
|
||||
extern void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len);
|
||||
extern void l2cble_conn_comp (UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_TYPE type,
|
||||
UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout);
|
||||
extern BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb);
|
||||
extern void l2cble_notify_le_connection (BD_ADDR bda);
|
||||
extern void l2c_ble_link_adjust_allocation (void);
|
||||
extern void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status);
|
||||
|
||||
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
|
||||
extern void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 int_max,
|
||||
UINT16 latency, UINT16 timeout);
|
||||
#endif
|
||||
|
||||
extern void l2cble_update_data_length(tL2C_LCB *p_lcb);
|
||||
extern void l2cble_set_fixed_channel_tx_data_length(BD_ADDR remote_bda, UINT16 fix_cid,
|
||||
UINT16 tx_mtu);
|
||||
extern void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len,
|
||||
UINT16 rx_data_len);
|
||||
|
||||
#endif
|
||||
extern void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _L2CAP_CLIENT_H_
|
||||
#define _L2CAP_CLIENT_H_
|
||||
|
||||
//#include <hardware/bluetooth.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct buffer_t buffer_t;
|
||||
typedef struct l2cap_client_t l2cap_client_t;
|
||||
|
||||
typedef struct {
|
||||
void (*connected)(l2cap_client_t *client, void *context);
|
||||
void (*disconnected)(l2cap_client_t *client, void *context);
|
||||
void (*read_ready)(l2cap_client_t *client, buffer_t *packet, void *context);
|
||||
void (*write_ready)(l2cap_client_t *client, void *context);
|
||||
} l2cap_client_callbacks_t;
|
||||
|
||||
// Returns a new buffer with enough space for |size| bytes of L2CAP payload.
|
||||
// |size| must be greater than zero. This function returns NULL if the buffer
|
||||
// could not be allocated. The returned buffer must be freed with |buffer_free|
|
||||
// when it is no longer needed.
|
||||
buffer_t *l2cap_buffer_new(size_t size);
|
||||
|
||||
// Creates and returns a new L2CAP client object. |callbacks| must not be NULL and
|
||||
// must specify a set of functions that should be called back when events occur
|
||||
// on the L2CAP connection. |context| may be NULL and will be passed as the argument
|
||||
// to all callbacks in |l2cap_client_callbacks_t|. The returned object must be freed
|
||||
// with |l2cap_client_free|.
|
||||
l2cap_client_t *l2cap_client_new(const l2cap_client_callbacks_t *callbacks, void *context);
|
||||
|
||||
// Frees the L2CAP client object allocated with |l2cap_client_new|. |client| may be NULL.
|
||||
void l2cap_client_free(l2cap_client_t *client);
|
||||
|
||||
// Attempts to connect the |client| to a peer device specified by |remote_bdaddr|
|
||||
// using the |psm| protocol specifier. This function returns true if the connect
|
||||
// operation could be started and will indicate completion with either a 'connected'
|
||||
// callback (success) or a 'disconnected' callback (failure).
|
||||
//
|
||||
// This function must not be called while a connect operation is in progress or
|
||||
// while |l2cap_client_is_connected|. |client| and |remote_bdaddr| must not be NULL.
|
||||
// |psm| must be greater than zero.
|
||||
bool l2cap_client_connect(l2cap_client_t *client, const bt_bdaddr_t *remote_bdaddr, uint16_t psm);
|
||||
|
||||
// Disconnects a connected |client|. This function is asynchronous and idempotent. It
|
||||
// will indicate completion with a 'disconnected' callback. |client| must not be NULL.
|
||||
void l2cap_client_disconnect(l2cap_client_t *client);
|
||||
|
||||
// Returns true if |client| is connected and is ready to accept data written to it.
|
||||
// |client| must not be NULL.
|
||||
bool l2cap_client_is_connected(const l2cap_client_t *client);
|
||||
|
||||
// Writes data contained in |packet| to a connected |client|. This function returns
|
||||
// true if the packet was successfully queued for delivery, false if the client cannot
|
||||
// accept more data at this time. If this function returns false, the caller must wait
|
||||
// for the 'write_ready' callback to write additional data to the client. Neither
|
||||
// |client| nor |packet| may be NULL.
|
||||
bool l2cap_client_write(l2cap_client_t *client, buffer_t *packet);
|
||||
|
||||
#endif /*_L2CAP_CLIENT_H_*/
|
||||
+317
@@ -0,0 +1,317 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef L2CDEFS_H
|
||||
#define L2CDEFS_H
|
||||
|
||||
/* L2CAP command codes
|
||||
*/
|
||||
#define L2CAP_CMD_REJECT 0x01
|
||||
#define L2CAP_CMD_CONN_REQ 0x02
|
||||
#define L2CAP_CMD_CONN_RSP 0x03
|
||||
#define L2CAP_CMD_CONFIG_REQ 0x04
|
||||
#define L2CAP_CMD_CONFIG_RSP 0x05
|
||||
#define L2CAP_CMD_DISC_REQ 0x06
|
||||
#define L2CAP_CMD_DISC_RSP 0x07
|
||||
#define L2CAP_CMD_ECHO_REQ 0x08
|
||||
#define L2CAP_CMD_ECHO_RSP 0x09
|
||||
#define L2CAP_CMD_INFO_REQ 0x0A
|
||||
#define L2CAP_CMD_INFO_RSP 0x0B
|
||||
#define L2CAP_CMD_AMP_CONN_REQ 0x0C
|
||||
#define L2CAP_CMD_AMP_CONN_RSP 0x0D
|
||||
#define L2CAP_CMD_AMP_MOVE_REQ 0x0E
|
||||
#define L2CAP_CMD_AMP_MOVE_RSP 0x0F
|
||||
#define L2CAP_CMD_AMP_MOVE_CFM 0x10
|
||||
#define L2CAP_CMD_AMP_MOVE_CFM_RSP 0x11
|
||||
#define L2CAP_CMD_BLE_UPDATE_REQ 0x12
|
||||
#define L2CAP_CMD_BLE_UPDATE_RSP 0x13
|
||||
|
||||
|
||||
/* Define some packet and header lengths
|
||||
*/
|
||||
#define L2CAP_PKT_OVERHEAD 4 /* Length and CID */
|
||||
#define L2CAP_CMD_OVERHEAD 4 /* Cmd code, Id and length */
|
||||
#define L2CAP_CMD_REJECT_LEN 2 /* Reason (data is optional) */
|
||||
#define L2CAP_CONN_REQ_LEN 4 /* PSM and source CID */
|
||||
#define L2CAP_CONN_RSP_LEN 8 /* Dest CID, source CID, reason, status */
|
||||
#define L2CAP_CONFIG_REQ_LEN 4 /* Dest CID, flags (data is optional) */
|
||||
#define L2CAP_CONFIG_RSP_LEN 6 /* Dest CID, flags, result,data optional*/
|
||||
#define L2CAP_DISC_REQ_LEN 4 /* Dest CID, source CID */
|
||||
#define L2CAP_DISC_RSP_LEN 4 /* Dest CID, source CID */
|
||||
#define L2CAP_ECHO_REQ_LEN 0 /* Data is optional */
|
||||
#define L2CAP_ECHO_RSP_LEN 0 /* Data is optional */
|
||||
#define L2CAP_INFO_REQ_LEN 2 /* Info type */
|
||||
#define L2CAP_INFO_RSP_LEN 4 /* Info type, result (data is optional) */
|
||||
#define L2CAP_BCST_OVERHEAD 2 /* Additional broadcast packet overhead */
|
||||
#define L2CAP_UCD_OVERHEAD 2 /* Additional connectionless packet overhead */
|
||||
|
||||
#define L2CAP_AMP_CONN_REQ_LEN 5 /* PSM, CID, and remote controller ID */
|
||||
#define L2CAP_AMP_MOVE_REQ_LEN 3 /* CID and remote controller ID */
|
||||
#define L2CAP_AMP_MOVE_RSP_LEN 4 /* CID and result */
|
||||
#define L2CAP_AMP_MOVE_CFM_LEN 4 /* CID and result */
|
||||
#define L2CAP_AMP_MOVE_CFM_RSP_LEN 2 /* CID */
|
||||
|
||||
#define L2CAP_CMD_BLE_UPD_REQ_LEN 8 /* Min and max interval, latency, tout */
|
||||
#define L2CAP_CMD_BLE_UPD_RSP_LEN 2 /* Result */
|
||||
|
||||
|
||||
/* Define the packet boundary flags
|
||||
*/
|
||||
#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
|
||||
#define L2CAP_PKT_START_FLUSHABLE 2
|
||||
#define L2CAP_PKT_START_NON_FLUSHABLE 0
|
||||
#endif
|
||||
#define L2CAP_COMPLETE_AMP_PKT 3 /* complete L2CAP packet on AMP HCI */
|
||||
#define L2CAP_PKT_START 2
|
||||
#define L2CAP_PKT_CONTINUE 1
|
||||
#define L2CAP_MASK_FLAG 0x0FFF
|
||||
#define L2CAP_PKT_TYPE_SHIFT 12
|
||||
#define L2CAP_PKT_TYPE_MASK 3
|
||||
|
||||
|
||||
/* Define the L2CAP connection result codes
|
||||
*/
|
||||
#define L2CAP_CONN_OK 0
|
||||
#define L2CAP_CONN_PENDING 1
|
||||
#define L2CAP_CONN_NO_PSM 2
|
||||
#define L2CAP_CONN_SECURITY_BLOCK 3
|
||||
#define L2CAP_CONN_NO_RESOURCES 4
|
||||
#define L2CAP_CONN_BAD_CTLR_ID 5 /* AMP related */
|
||||
#define L2CAP_CONN_TIMEOUT 0xEEEE
|
||||
#define L2CAP_CONN_AMP_FAILED 254
|
||||
#define L2CAP_CONN_NO_LINK 255 /* Add a couple of our own for internal use */
|
||||
#define L2CAP_CONN_CANCEL 256 /* L2CAP connection cancelled */
|
||||
|
||||
|
||||
/* Define L2CAP Move Channel Response result codes
|
||||
*/
|
||||
#define L2CAP_MOVE_OK 0
|
||||
#define L2CAP_MOVE_PENDING 1
|
||||
#define L2CAP_MOVE_CTRL_ID_NOT_SUPPORT 2
|
||||
#define L2CAP_MOVE_SAME_CTRLR_ID 3
|
||||
#define L2CAP_MOVE_CONFIG_NOT_SUPPORTED 4
|
||||
#define L2CAP_MOVE_CHAN_COLLISION 5
|
||||
#define L2CAP_MOVE_NOT_ALLOWED 6
|
||||
|
||||
|
||||
/* Define L2CAP Move Channel Confirmation result codes
|
||||
*/
|
||||
#define L2CAP_MOVE_CFM_OK 0
|
||||
#define L2CAP_MOVE_CFM_REFUSED 1
|
||||
|
||||
|
||||
/* Define the L2CAP command reject reason codes
|
||||
*/
|
||||
#define L2CAP_CMD_REJ_NOT_UNDERSTOOD 0
|
||||
#define L2CAP_CMD_REJ_MTU_EXCEEDED 1
|
||||
#define L2CAP_CMD_REJ_INVALID_CID 2
|
||||
|
||||
|
||||
/* L2CAP Predefined CIDs
|
||||
*/
|
||||
#define L2CAP_SIGNALLING_CID 1
|
||||
#define L2CAP_CONNECTIONLESS_CID 2
|
||||
#define L2CAP_AMP_CID 3
|
||||
#define L2CAP_ATT_CID 4
|
||||
#define L2CAP_BLE_SIGNALLING_CID 5
|
||||
#define L2CAP_SMP_CID 6
|
||||
#define L2CAP_SMP_BR_CID 7
|
||||
#define L2CAP_AMP_TEST_CID 0x003F
|
||||
#define L2CAP_BASE_APPL_CID 0x0040
|
||||
#define L2CAP_BLE_CONN_MAX_CID 0x007F
|
||||
|
||||
/* Fixed Channels mask bits */
|
||||
|
||||
/* Signal channel supported (Mandatory) */
|
||||
#define L2CAP_FIXED_CHNL_SIG_BIT (1 << L2CAP_SIGNALLING_CID)
|
||||
|
||||
/* Connectionless reception */
|
||||
#define L2CAP_FIXED_CHNL_CNCTLESS_BIT (1 << L2CAP_CONNECTIONLESS_CID)
|
||||
|
||||
/* AMP Manager supported */
|
||||
#define L2CAP_FIXED_CHNL_AMP_BIT (1 << L2CAP_AMP_CID)
|
||||
|
||||
/* Attribute protocol supported */
|
||||
#define L2CAP_FIXED_CHNL_ATT_BIT (1 << L2CAP_ATT_CID)
|
||||
|
||||
/* BLE Signalling supported */
|
||||
#define L2CAP_FIXED_CHNL_BLE_SIG_BIT (1 << L2CAP_BLE_SIGNALLING_CID)
|
||||
|
||||
/* BLE Security Mgr supported */
|
||||
#define L2CAP_FIXED_CHNL_SMP_BIT (1 << L2CAP_SMP_CID)
|
||||
|
||||
/* Security Mgr over BR supported */
|
||||
#define L2CAP_FIXED_CHNL_SMP_BR_BIT (1 << L2CAP_SMP_BR_CID)
|
||||
|
||||
|
||||
|
||||
/* Define the L2CAP configuration result codes
|
||||
*/
|
||||
#define L2CAP_CFG_OK 0
|
||||
#define L2CAP_CFG_UNACCEPTABLE_PARAMS 1
|
||||
#define L2CAP_CFG_FAILED_NO_REASON 2
|
||||
#define L2CAP_CFG_UNKNOWN_OPTIONS 3
|
||||
#define L2CAP_CFG_PENDING 4
|
||||
#define L2CAP_CFG_FLOW_SPEC_REJECTED 5
|
||||
|
||||
|
||||
/* Define the L2CAP configuration option types
|
||||
*/
|
||||
#define L2CAP_CFG_TYPE_MTU 0x01
|
||||
#define L2CAP_CFG_TYPE_FLUSH_TOUT 0x02
|
||||
#define L2CAP_CFG_TYPE_QOS 0x03
|
||||
#define L2CAP_CFG_TYPE_FCR 0x04
|
||||
#define L2CAP_CFG_TYPE_FCS 0x05
|
||||
#define L2CAP_CFG_TYPE_EXT_FLOW 0x06
|
||||
#define L2CAP_CFG_TYPE_EXT_WIN_SIZE 0x07
|
||||
|
||||
#define L2CAP_CFG_MTU_OPTION_LEN 2 /* MTU option length */
|
||||
#define L2CAP_CFG_FLUSH_OPTION_LEN 2 /* Flush option len */
|
||||
#define L2CAP_CFG_QOS_OPTION_LEN 22 /* QOS option length */
|
||||
#define L2CAP_CFG_FCR_OPTION_LEN 9 /* FCR option length */
|
||||
#define L2CAP_CFG_FCS_OPTION_LEN 1 /* FCR option length */
|
||||
#define L2CAP_CFG_EXT_FLOW_OPTION_LEN 16 /* Extended Flow Spec */
|
||||
#define L2CAP_CFG_EXT_WIN_SIZE_LEN 2 /* Ext window size length */
|
||||
#define L2CAP_CFG_OPTION_OVERHEAD 2 /* Type and length */
|
||||
|
||||
/* Configuration Cmd/Rsp Flags mask
|
||||
*/
|
||||
#define L2CAP_CFG_FLAGS_MASK_CONT 0x0001 /* Flags mask: Continuation */
|
||||
|
||||
/* FCS Check Option values
|
||||
*/
|
||||
#define L2CAP_CFG_FCS_BYPASS 0 /* Bypass the FCS in streaming or ERTM modes */
|
||||
#define L2CAP_CFG_FCS_USE 1 /* Use the FCS in streaming or ERTM modes [default] */
|
||||
|
||||
/* Default values for configuration
|
||||
*/
|
||||
#define L2CAP_NO_AUTOMATIC_FLUSH 0xFFFF
|
||||
#define L2CAP_NO_RETRANSMISSION 0x0001
|
||||
|
||||
#define L2CAP_DEFAULT_MTU (672)
|
||||
#define L2CAP_DEFAULT_FLUSH_TO L2CAP_NO_AUTOMATIC_FLUSH
|
||||
#define L2CAP_DEFAULT_SERV_TYPE 1
|
||||
#define L2CAP_DEFAULT_TOKEN_RATE 0
|
||||
#define L2CAP_DEFAULT_BUCKET_SIZE 0
|
||||
#define L2CAP_DEFAULT_PEAK_BANDWIDTH 0
|
||||
#define L2CAP_DEFAULT_LATENCY 0xFFFFFFFF
|
||||
#define L2CAP_DEFAULT_DELAY 0xFFFFFFFF
|
||||
#define L2CAP_DEFAULT_FCS L2CAP_CFG_FCS_USE
|
||||
|
||||
|
||||
/* Define the L2CAP disconnect result codes
|
||||
*/
|
||||
#define L2CAP_DISC_OK 0
|
||||
#define L2CAP_DISC_TIMEOUT 0xEEEE
|
||||
|
||||
/* Define the L2CAP info resp result codes
|
||||
*/
|
||||
#define L2CAP_INFO_RESP_RESULT_SUCCESS 0
|
||||
#define L2CAP_INFO_RESP_RESULT_NOT_SUPPORTED 1
|
||||
|
||||
/* Define the info-type fields of information request & response
|
||||
*/
|
||||
#define L2CAP_CONNLESS_MTU_INFO_TYPE 0x0001
|
||||
#define L2CAP_EXTENDED_FEATURES_INFO_TYPE 0x0002 /* Used in Information Req/Response */
|
||||
#define L2CAP_FIXED_CHANNELS_INFO_TYPE 0x0003 /* Used in AMP */
|
||||
|
||||
#define L2CAP_CONNLESS_MTU_INFO_SIZE 2 /* Connectionless MTU size */
|
||||
#define L2CAP_EXTENDED_FEATURES_ARRAY_SIZE 4 /* Extended features array size */
|
||||
#define L2CAP_FIXED_CHNL_ARRAY_SIZE 8 /* Fixed channel array size */
|
||||
|
||||
/* Extended features mask bits
|
||||
*/
|
||||
#define L2CAP_EXTFEA_RTRANS 0x00000001 /* Retransmission Mode (Not Supported) */
|
||||
#define L2CAP_EXTFEA_FC 0x00000002 /* Flow Control Mode (Not Supported) */
|
||||
#define L2CAP_EXTFEA_QOS 0x00000004
|
||||
#define L2CAP_EXTFEA_ENH_RETRANS 0x00000008 /* Enhanced retransmission mode */
|
||||
#define L2CAP_EXTFEA_STREAM_MODE 0x00000010 /* Streaming Mode */
|
||||
#define L2CAP_EXTFEA_NO_CRC 0x00000020 /* Optional FCS (if set No FCS desired) */
|
||||
#define L2CAP_EXTFEA_EXT_FLOW_SPEC 0x00000040 /* Extended flow spec */
|
||||
#define L2CAP_EXTFEA_FIXED_CHNLS 0x00000080 /* Fixed channels */
|
||||
#define L2CAP_EXTFEA_EXT_WINDOW 0x00000100 /* Extended Window Size */
|
||||
#define L2CAP_EXTFEA_UCD_RECEPTION 0x00000200 /* Unicast Connectionless Data Reception */
|
||||
|
||||
/* Mask for locally supported features used in Information Response (default to none) */
|
||||
#ifndef L2CAP_EXTFEA_SUPPORTED_MASK
|
||||
#define L2CAP_EXTFEA_SUPPORTED_MASK 0
|
||||
#endif
|
||||
|
||||
/* Mask for LE supported features used in Information Response (default to none) */
|
||||
#ifndef L2CAP_BLE_EXTFEA_MASK
|
||||
#define L2CAP_BLE_EXTFEA_MASK 0
|
||||
#endif
|
||||
|
||||
/* Define a value that tells L2CAP to use the default HCI ACL buffer pool */
|
||||
#define L2CAP_DEFAULT_ERM_POOL_ID 0xFF
|
||||
/* Define a value that tells L2CAP to use the default MPS */
|
||||
#define L2CAP_DEFAULT_ERM_MPS 0x0000
|
||||
|
||||
#define L2CAP_FCR_OVERHEAD 2 /* Control word */
|
||||
#define L2CAP_FCS_LEN 2 /* FCS takes 2 bytes */
|
||||
#define L2CAP_SDU_LEN_OVERHEAD 2 /* SDU length field is 2 bytes */
|
||||
#define L2CAP_SDU_LEN_OFFSET 2 /* SDU length offset is 2 bytes */
|
||||
#define L2CAP_EXT_CONTROL_OVERHEAD 4 /* Extended Control Field */
|
||||
#define L2CAP_MAX_HEADER_FCS (L2CAP_PKT_OVERHEAD + L2CAP_EXT_CONTROL_OVERHEAD + L2CAP_SDU_LEN_OVERHEAD + L2CAP_FCS_LEN)
|
||||
/* length(2), channel(2), control(4), SDU length(2) FCS(2) */
|
||||
/* To optimize this, it must be a multiplum of the L2CAP PDU length AND match the 3DH5 air
|
||||
* including the l2cap headers in each packet - to match the latter - the -5 is added
|
||||
*/
|
||||
#define L2CAP_MAX_SDU_LENGTH (GKI_BUF4_SIZE - (L2CAP_MIN_OFFSET + L2CAP_MAX_HEADER_FCS) -5)
|
||||
|
||||
/* Part of L2CAP_MIN_OFFSET that is not part of L2CAP
|
||||
*/
|
||||
#define L2CAP_OFFSET_WO_L2HDR (L2CAP_MIN_OFFSET-(L2CAP_PKT_OVERHEAD+L2CAP_FCR_OVERHEAD))
|
||||
|
||||
/* SAR bits in the control word
|
||||
*/
|
||||
#define L2CAP_FCR_UNSEG_SDU 0x0000 /* Control word to begin with for unsegmented PDU*/
|
||||
#define L2CAP_FCR_START_SDU 0x4000 /* ...for Starting PDU of a semented SDU */
|
||||
#define L2CAP_FCR_END_SDU 0x8000 /* ...for ending PDU of a segmented SDU */
|
||||
#define L2CAP_FCR_CONT_SDU 0xc000 /* ...for continuation PDU of a segmented SDU */
|
||||
|
||||
/* Supervisory frame types
|
||||
*/
|
||||
#define L2CAP_FCR_SUP_RR 0x0000 /* Supervisory frame - RR */
|
||||
#define L2CAP_FCR_SUP_REJ 0x0001 /* Supervisory frame - REJ */
|
||||
#define L2CAP_FCR_SUP_RNR 0x0002 /* Supervisory frame - RNR */
|
||||
#define L2CAP_FCR_SUP_SREJ 0x0003 /* Supervisory frame - SREJ */
|
||||
|
||||
#define L2CAP_FCR_SAR_BITS 0xC000 /* Mask to get the SAR bits from control word */
|
||||
#define L2CAP_FCR_SAR_BITS_SHIFT 14 /* Bits to shift right to get the SAR bits from ctrl-word */
|
||||
|
||||
#define L2CAP_FCR_S_FRAME_BIT 0x0001 /* Mask to check if a PDU is S-frame */
|
||||
#define L2CAP_FCR_REQ_SEQ_BITS 0x3F00 /* Mask to get the req-seq from control word */
|
||||
#define L2CAP_FCR_REQ_SEQ_BITS_SHIFT 8 /* Bits to shift right to get the req-seq from ctrl-word */
|
||||
#define L2CAP_FCR_TX_SEQ_BITS 0x007E /* Mask on get the tx-seq from control word */
|
||||
#define L2CAP_FCR_TX_SEQ_BITS_SHIFT 1 /* Bits to shift right to get the tx-seq from ctrl-word */
|
||||
|
||||
#define L2CAP_FCR_F_BIT 0x0080 /* F-bit in the control word (Sup and I frames) */
|
||||
#define L2CAP_FCR_P_BIT 0x0010 /* P-bit in the control word (Sup frames only) */
|
||||
|
||||
#define L2CAP_FCR_F_BIT_SHIFT 7
|
||||
#define L2CAP_FCR_P_BIT_SHIFT 4
|
||||
|
||||
#define L2CAP_FCR_SEG_BITS 0xC000 /* Mask to get the segmentation bits from ctrl-word */
|
||||
#define L2CAP_FCR_SUP_SHIFT 2 /* Bits to shift right to get the S-bits from ctrl-word */
|
||||
#define L2CAP_FCR_SUP_BITS 0x000C /* Mask to get the supervisory bits from ctrl-word */
|
||||
|
||||
#define L2CAP_FCR_INIT_CRC 0 /* Initial state of the CRC register */
|
||||
#define L2CAP_FCR_SEQ_MODULO 0x3F /* Mask for sequence numbers (range 0 - 63) */
|
||||
|
||||
#endif
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2006-2015 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 simple pairing algorithms using Elliptic Curve Cryptography for private public key
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "p_256_multprecision.h"
|
||||
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
typedef struct {
|
||||
DWORD x[KEY_LENGTH_DWORDS_P256];
|
||||
DWORD y[KEY_LENGTH_DWORDS_P256];
|
||||
DWORD z[KEY_LENGTH_DWORDS_P256];
|
||||
} Point;
|
||||
|
||||
typedef struct {
|
||||
// curve's coefficients
|
||||
DWORD a[KEY_LENGTH_DWORDS_P256];
|
||||
DWORD b[KEY_LENGTH_DWORDS_P256];
|
||||
|
||||
//whether a is -3
|
||||
int a_minus3;
|
||||
|
||||
// prime modulus
|
||||
DWORD p[KEY_LENGTH_DWORDS_P256];
|
||||
|
||||
// Omega, p = 2^m -omega
|
||||
DWORD omega[KEY_LENGTH_DWORDS_P256];
|
||||
|
||||
// base point, a point on E of order r
|
||||
Point G;
|
||||
|
||||
} elliptic_curve_t;
|
||||
|
||||
extern elliptic_curve_t curve;
|
||||
extern elliptic_curve_t curve_p256;
|
||||
|
||||
void ECC_PointMult_Bin_NAF(Point *q, Point *p, DWORD *n, uint32_t keyLength);
|
||||
|
||||
#define ECC_PointMult(q, p, n, keyLength) ECC_PointMult_Bin_NAF(q, p, n, keyLength)
|
||||
|
||||
void p_256_init_curve(UINT32 keyLength);
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2006-2015 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 simple pairing algorithms
|
||||
*
|
||||
******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "bt_types.h"
|
||||
|
||||
/* Type definitions */
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
#define DWORD_BITS 32
|
||||
#define DWORD_BYTES 4
|
||||
#define DWORD_BITS_SHIFT 5
|
||||
|
||||
#define KEY_LENGTH_DWORDS_P192 6
|
||||
#define KEY_LENGTH_DWORDS_P256 8
|
||||
/* Arithmetic Operations */
|
||||
|
||||
int multiprecision_compare(DWORD *a, DWORD *b, uint32_t keyLength);
|
||||
int multiprecision_iszero(DWORD *a, uint32_t keyLength);
|
||||
void multiprecision_init(DWORD *c, uint32_t keyLength);
|
||||
void multiprecision_copy(DWORD *c, DWORD *a, uint32_t keyLength);
|
||||
UINT32 multiprecision_dword_bits (DWORD a);
|
||||
UINT32 multiprecision_most_signdwords(DWORD *a, uint32_t keyLength);
|
||||
UINT32 multiprecision_most_signbits(DWORD *a, uint32_t keyLength);
|
||||
void multiprecision_inv_mod(DWORD *aminus, DWORD *a, uint32_t keyLength);
|
||||
DWORD multiprecision_add(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength); // c=a+b
|
||||
void multiprecision_add_mod(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength);
|
||||
DWORD multiprecision_sub(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength); // c=a-b
|
||||
void multiprecision_sub_mod(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength);
|
||||
void multiprecision_rshift(DWORD * c, DWORD * a, uint32_t keyLength); // c=a>>1, return carrier
|
||||
void multiprecision_lshift_mod(DWORD * c, DWORD * a, uint32_t keyLength); // c=a<<b, return carrier
|
||||
DWORD multiprecision_lshift(DWORD * c, DWORD * a, uint32_t keyLength); // c=a<<b, return carrier
|
||||
void multiprecision_mult(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength); // c=a*b
|
||||
void multiprecision_mersenns_mult_mod(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength);
|
||||
void multiprecision_mersenns_squa_mod(DWORD *c, DWORD *a, uint32_t keyLength);
|
||||
DWORD multiprecision_lshift(DWORD * c, DWORD * a, uint32_t keyLength);
|
||||
void multiprecision_mult(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength);
|
||||
void multiprecision_fast_mod(DWORD *c, DWORD *a);
|
||||
void multiprecision_fast_mod_P256(DWORD *c, DWORD *a);
|
||||
|
||||
|
||||
+459
@@ -0,0 +1,459 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2001-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* this file contains the PAN API definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef PAN_API_H
|
||||
#define PAN_API_H
|
||||
|
||||
#include "bnep_api.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* Define the minimum offset needed in a GKI buffer for
|
||||
** sending PAN packets. Note, we are currently not sending
|
||||
** extension headers, but may in the future, so allow
|
||||
** space for them
|
||||
*/
|
||||
#define PAN_MINIMUM_OFFSET BNEP_MINIMUM_OFFSET
|
||||
|
||||
|
||||
/*
|
||||
** The handle is passed from BNEP to PAN. The same handle is used
|
||||
** between PAN and application as well
|
||||
*/
|
||||
#define PAN_INVALID_HANDLE BNEP_INVALID_HANDLE
|
||||
|
||||
/* Bit map for PAN roles */
|
||||
#define PAN_ROLE_CLIENT 0x01 /* PANU role */
|
||||
#define PAN_ROLE_GN_SERVER 0x02 /* GN role */
|
||||
#define PAN_ROLE_NAP_SERVER 0x04 /* NAP role */
|
||||
|
||||
/* Bitmap to indicate the usage of the Data */
|
||||
#define PAN_DATA_TO_HOST 0x01
|
||||
#define PAN_DATA_TO_LAN 0x02
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
/* Define the result codes from PAN */
|
||||
enum
|
||||
{
|
||||
PAN_SUCCESS, /* Success */
|
||||
PAN_DISCONNECTED = BNEP_CONN_DISCONNECTED, /* Connection terminated */
|
||||
PAN_CONN_FAILED = BNEP_CONN_FAILED, /* Connection failed */
|
||||
PAN_NO_RESOURCES = BNEP_NO_RESOURCES, /* No resources */
|
||||
PAN_MTU_EXCEDED = BNEP_MTU_EXCEDED, /* Attempt to write long data */
|
||||
PAN_INVALID_OFFSET = BNEP_INVALID_OFFSET, /* Insufficient offset in GKI buffer */
|
||||
PAN_CONN_FAILED_CFG = BNEP_CONN_FAILED_CFG, /* Connection failed cos of config */
|
||||
PAN_INVALID_SRC_ROLE = BNEP_CONN_FAILED_SRC_UUID, /* Connection failed wrong source UUID */
|
||||
PAN_INVALID_DST_ROLE = BNEP_CONN_FAILED_DST_UUID, /* Connection failed wrong destination UUID */
|
||||
PAN_CONN_FAILED_UUID_SIZE = BNEP_CONN_FAILED_UUID_SIZE, /* Connection failed wrong size UUID */
|
||||
PAN_Q_SIZE_EXCEEDED = BNEP_Q_SIZE_EXCEEDED, /* Too many buffers to dest */
|
||||
PAN_TOO_MANY_FILTERS = BNEP_TOO_MANY_FILTERS, /* Too many local filters specified */
|
||||
PAN_SET_FILTER_FAIL = BNEP_SET_FILTER_FAIL, /* Set Filter failed */
|
||||
PAN_WRONG_HANDLE = BNEP_WRONG_HANDLE, /* Wrong handle for the connection */
|
||||
PAN_WRONG_STATE = BNEP_WRONG_STATE, /* Connection is in wrong state */
|
||||
PAN_SECURITY_FAIL = BNEP_SECURITY_FAIL, /* Failed because of security */
|
||||
PAN_IGNORE_CMD = BNEP_IGNORE_CMD, /* To ignore the rcvd command */
|
||||
PAN_TX_FLOW_ON = BNEP_TX_FLOW_ON, /* tx data flow enabled */
|
||||
PAN_TX_FLOW_OFF = BNEP_TX_FLOW_OFF, /* tx data flow disabled */
|
||||
PAN_FAILURE /* Failure */
|
||||
|
||||
};
|
||||
typedef UINT8 tPAN_RESULT;
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
** Callback Function Prototypes
|
||||
*****************************************************************/
|
||||
|
||||
/* This is call back function used to report connection status
|
||||
** to the application. The second parameter TRUE means
|
||||
** to create the bridge and FALSE means to remove it.
|
||||
*/
|
||||
typedef void (tPAN_CONN_STATE_CB) (UINT16 handle, BD_ADDR bd_addr, tPAN_RESULT state, BOOLEAN is_role_change,
|
||||
UINT8 src_role, UINT8 dst_role);
|
||||
|
||||
|
||||
/* This is call back function used to create bridge for the
|
||||
** Connected device. The parameter "state" indicates
|
||||
** whether to create the bridge or remove it. TRUE means
|
||||
** to create the bridge and FALSE means to remove it.
|
||||
*/
|
||||
typedef void (tPAN_BRIDGE_REQ_CB) (BD_ADDR bd_addr, BOOLEAN state);
|
||||
|
||||
|
||||
/* Data received indication callback prototype. Parameters are
|
||||
** Source BD/Ethernet Address
|
||||
** Dest BD/Ethernet address
|
||||
** Protocol
|
||||
** Address of buffer (or data if non-GKI)
|
||||
** Length of data (non-GKI)
|
||||
** ext is flag to indicate whether it has aby extension headers
|
||||
** Flag used to indicate to forward on LAN
|
||||
** FALSE - Use it for internal stack
|
||||
** TRUE - Send it across the ethernet as well
|
||||
*/
|
||||
typedef void (tPAN_DATA_IND_CB) (UINT16 handle,
|
||||
BD_ADDR src,
|
||||
BD_ADDR dst,
|
||||
UINT16 protocol,
|
||||
UINT8 *p_data,
|
||||
UINT16 len,
|
||||
BOOLEAN ext,
|
||||
BOOLEAN forward);
|
||||
|
||||
|
||||
/* Data buffer received indication callback prototype. Parameters are
|
||||
** Source BD/Ethernet Address
|
||||
** Dest BD/Ethernet address
|
||||
** Protocol
|
||||
** pointer to the data buffer
|
||||
** ext is flag to indicate whether it has aby extension headers
|
||||
** Flag used to indicate to forward on LAN
|
||||
** FALSE - Use it for internal stack
|
||||
** TRUE - Send it across the ethernet as well
|
||||
*/
|
||||
typedef void (tPAN_DATA_BUF_IND_CB) (UINT16 handle,
|
||||
BD_ADDR src,
|
||||
BD_ADDR dst,
|
||||
UINT16 protocol,
|
||||
BT_HDR *p_buf,
|
||||
BOOLEAN ext,
|
||||
BOOLEAN forward);
|
||||
|
||||
|
||||
/* Flow control callback for TX data. Parameters are
|
||||
** Handle to the connection
|
||||
** Event flow status
|
||||
*/
|
||||
typedef void (tPAN_TX_DATA_FLOW_CB) (UINT16 handle,
|
||||
tPAN_RESULT event);
|
||||
|
||||
/* Filters received indication callback prototype. Parameters are
|
||||
** Handle to the connection
|
||||
** TRUE if the cb is called for indication
|
||||
** Ignore this if it is indication, otherwise it is the result
|
||||
** for the filter set operation performed by the local
|
||||
** device
|
||||
** Number of protocol filters present
|
||||
** Pointer to the filters start. Filters are present in pairs
|
||||
** of start of the range and end of the range.
|
||||
** They will be present in big endian order. First
|
||||
** two bytes will be starting of the first range and
|
||||
** next two bytes will be ending of the range.
|
||||
*/
|
||||
typedef void (tPAN_FILTER_IND_CB) (UINT16 handle,
|
||||
BOOLEAN indication,
|
||||
tBNEP_RESULT result,
|
||||
UINT16 num_filters,
|
||||
UINT8 *p_filters);
|
||||
|
||||
|
||||
|
||||
/* Multicast Filters received indication callback prototype. Parameters are
|
||||
** Handle to the connection
|
||||
** TRUE if the cb is called for indication
|
||||
** Ignore this if it is indication, otherwise it is the result
|
||||
** for the filter set operation performed by the local
|
||||
** device
|
||||
** Number of multicast filters present
|
||||
** Pointer to the filters start. Filters are present in pairs
|
||||
** of start of the range and end of the range.
|
||||
** First six bytes will be starting of the first range and
|
||||
** next six bytes will be ending of the range.
|
||||
*/
|
||||
typedef void (tPAN_MFILTER_IND_CB) (UINT16 handle,
|
||||
BOOLEAN indication,
|
||||
tBNEP_RESULT result,
|
||||
UINT16 num_mfilters,
|
||||
UINT8 *p_mfilters);
|
||||
|
||||
|
||||
|
||||
|
||||
/* This structure is used to register with PAN profile
|
||||
** It is passed as a parameter to PAN_Register call.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
tPAN_CONN_STATE_CB *pan_conn_state_cb; /* Connection state callback */
|
||||
tPAN_BRIDGE_REQ_CB *pan_bridge_req_cb; /* Bridge request callback */
|
||||
tPAN_DATA_IND_CB *pan_data_ind_cb; /* Data indication callback */
|
||||
tPAN_DATA_BUF_IND_CB *pan_data_buf_ind_cb; /* Data buffer indication callback */
|
||||
tPAN_FILTER_IND_CB *pan_pfilt_ind_cb; /* protocol filter indication callback */
|
||||
tPAN_MFILTER_IND_CB *pan_mfilt_ind_cb; /* multicast filter indication callback */
|
||||
tPAN_TX_DATA_FLOW_CB *pan_tx_data_flow_cb; /* data flow callback */
|
||||
char *user_service_name; /* Service name for PANU role */
|
||||
char *gn_service_name; /* Service name for GN role */
|
||||
char *nap_service_name; /* Service name for NAP role */
|
||||
|
||||
} tPAN_REGISTER;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_Register
|
||||
**
|
||||
** Description This function is called by the application to register
|
||||
** its callbacks with PAN profile. The application then
|
||||
** should set the PAN role explicitly.
|
||||
**
|
||||
** Parameters: p_register - contains all callback function pointers
|
||||
**
|
||||
**
|
||||
** Returns none
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void PAN_Register (tPAN_REGISTER *p_register);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_Deregister
|
||||
**
|
||||
** Description This function is called by the application to de-register
|
||||
** its callbacks with PAN profile. This will make the PAN to
|
||||
** become inactive. This will deregister PAN services from SDP
|
||||
** and close all active connections
|
||||
**
|
||||
** Returns none
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void PAN_Deregister (void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_SetRole
|
||||
**
|
||||
** Description This function is called by the application to set the PAN
|
||||
** profile role. This should be called after PAN_Register.
|
||||
** This can be called any time to change the PAN role
|
||||
**
|
||||
** Parameters: role - is bit map of roles to be active
|
||||
** PAN_ROLE_CLIENT is for PANU role
|
||||
** PAN_ROLE_GN_SERVER is for GN role
|
||||
** PAN_ROLE_NAP_SERVER is for NAP role
|
||||
** sec_mask - Security mask for different roles
|
||||
** It is array of UINT8. The byte represent the
|
||||
** security for roles PANU, GN and NAP in order
|
||||
** p_user_name - Service name for PANU role
|
||||
** p_gn_name - Service name for GN role
|
||||
** p_nap_name - Service name for NAP role
|
||||
** Can be NULL if user wants it to be default
|
||||
**
|
||||
** Returns PAN_SUCCESS - if the role is set successfully
|
||||
** PAN_FAILURE - if the role is not valid
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tPAN_RESULT PAN_SetRole (UINT8 role,
|
||||
UINT8 *sec_mask,
|
||||
char *p_user_name,
|
||||
char *p_gn_name,
|
||||
char *p_nap_name);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_Connect
|
||||
**
|
||||
** Description This function is called by the application to initiate a
|
||||
** connection to the remote device
|
||||
**
|
||||
** Parameters: rem_bda - BD Addr of the remote device
|
||||
** src_role - Role of the local device for the connection
|
||||
** dst_role - Role of the remote device for the connection
|
||||
** PAN_ROLE_CLIENT is for PANU role
|
||||
** PAN_ROLE_GN_SERVER is for GN role
|
||||
** PAN_ROLE_NAP_SERVER is for NAP role
|
||||
** *handle - Pointer for returning Handle to the connection
|
||||
**
|
||||
** Returns PAN_SUCCESS - if the connection is initiated successfully
|
||||
** PAN_NO_RESOURCES - resources are not sufficent
|
||||
** PAN_FAILURE - if the connection cannot be initiated
|
||||
** this can be because of the combination of
|
||||
** src and dst roles may not be valid or
|
||||
** allowed at that point of time
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tPAN_RESULT PAN_Connect (BD_ADDR rem_bda, UINT8 src_role, UINT8 dst_role, UINT16 *handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_Disconnect
|
||||
**
|
||||
** Description This is used to disconnect the connection
|
||||
**
|
||||
** Parameters: handle - handle for the connection
|
||||
**
|
||||
** Returns PAN_SUCCESS - if the connection is closed successfully
|
||||
** PAN_FAILURE - if the connection is not found or
|
||||
** there is an error in disconnecting
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tPAN_RESULT PAN_Disconnect (UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_Write
|
||||
**
|
||||
** Description This sends data over the PAN connections. If this is called
|
||||
** on GN or NAP side and the packet is multicast or broadcast
|
||||
** it will be sent on all the links. Otherwise the correct link
|
||||
** is found based on the destination address and forwarded on it
|
||||
** If the return value is not PAN_SUCCESS the application should
|
||||
** take care of releasing the message buffer
|
||||
**
|
||||
** Parameters: dst - MAC or BD Addr of the destination device
|
||||
** src - MAC or BD Addr of the source who sent this packet
|
||||
** protocol - protocol of the ethernet packet like IP or ARP
|
||||
** p_data - pointer to the data
|
||||
** len - length of the data
|
||||
** ext - to indicate that extension headers present
|
||||
**
|
||||
** Returns PAN_SUCCESS - if the data is sent successfully
|
||||
** PAN_FAILURE - if the connection is not found or
|
||||
** there is an error in sending data
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tPAN_RESULT PAN_Write (UINT16 handle,
|
||||
BD_ADDR dst,
|
||||
BD_ADDR src,
|
||||
UINT16 protocol,
|
||||
UINT8 *p_data,
|
||||
UINT16 len,
|
||||
BOOLEAN ext);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_WriteBuf
|
||||
**
|
||||
** Description This sends data over the PAN connections. If this is called
|
||||
** on GN or NAP side and the packet is multicast or broadcast
|
||||
** it will be sent on all the links. Otherwise the correct link
|
||||
** is found based on the destination address and forwarded on it
|
||||
** If the return value is not PAN_SUCCESS the application should
|
||||
** take care of releasing the message buffer
|
||||
**
|
||||
** Parameters: dst - MAC or BD Addr of the destination device
|
||||
** src - MAC or BD Addr of the source who sent this packet
|
||||
** protocol - protocol of the ethernet packet like IP or ARP
|
||||
** p_buf - pointer to the data buffer
|
||||
** ext - to indicate that extension headers present
|
||||
**
|
||||
** Returns PAN_SUCCESS - if the data is sent successfully
|
||||
** PAN_FAILURE - if the connection is not found or
|
||||
** there is an error in sending data
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tPAN_RESULT PAN_WriteBuf (UINT16 handle,
|
||||
BD_ADDR dst,
|
||||
BD_ADDR src,
|
||||
UINT16 protocol,
|
||||
BT_HDR *p_buf,
|
||||
BOOLEAN ext);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_SetProtocolFilters
|
||||
**
|
||||
** Description This function is used to set protocol filters on the peer
|
||||
**
|
||||
** Parameters: handle - handle for the connection
|
||||
** num_filters - number of protocol filter ranges
|
||||
** start - array of starting protocol numbers
|
||||
** end - array of ending protocol numbers
|
||||
**
|
||||
**
|
||||
** Returns PAN_SUCCESS if protocol filters are set successfully
|
||||
** PAN_FAILURE if connection not found or error in setting
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tPAN_RESULT PAN_SetProtocolFilters (UINT16 handle,
|
||||
UINT16 num_filters,
|
||||
UINT16 *p_start_array,
|
||||
UINT16 *p_end_array);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_SetMulticastFilters
|
||||
**
|
||||
** Description This function is used to set multicast filters on the peer
|
||||
**
|
||||
** Parameters: handle - handle for the connection
|
||||
** num_filters - number of multicast filter ranges
|
||||
** p_start_array - Pointer to sequence of beginings of all
|
||||
** multicast address ranges
|
||||
** p_end_array - Pointer to sequence of ends of all
|
||||
** multicast address ranges
|
||||
**
|
||||
**
|
||||
** Returns PAN_SUCCESS if multicast filters are set successfully
|
||||
** PAN_FAILURE if connection not found or error in setting
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBNEP_RESULT PAN_SetMulticastFilters (UINT16 handle,
|
||||
UINT16 num_mcast_filters,
|
||||
UINT8 *p_start_array,
|
||||
UINT8 *p_end_array);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_SetTraceLevel
|
||||
**
|
||||
** Description This function sets the trace level for PAN. If called with
|
||||
** a value of 0xFF, it simply reads the current trace level.
|
||||
**
|
||||
** Returns the new (current) trace level
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 PAN_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PAN_Init
|
||||
**
|
||||
** Description This function initializes the PAN unit. It should be called
|
||||
** before accessing any other APIs to initialize the control
|
||||
** block.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void PAN_Init (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PAN_API_H */
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2001-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains internally used PAN definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef PAN_INT_H
|
||||
#define PAN_INT_H
|
||||
|
||||
#include "pan_api.h"
|
||||
|
||||
/*
|
||||
** This role is used to shutdown the profile. Used internally
|
||||
** Applications should call PAN_Deregister to shutdown the profile
|
||||
*/
|
||||
#define PAN_ROLE_INACTIVE 0
|
||||
|
||||
/* Protocols supported by the host internal stack, are registered with SDP */
|
||||
#define PAN_PROTOCOL_IP 0x0800
|
||||
#define PAN_PROTOCOL_ARP 0x0806
|
||||
|
||||
#define PAN_PROFILE_VERSION 0x0100 /* Version 1.00 */
|
||||
|
||||
/* Define the PAN Connection Control Block
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
#define PAN_STATE_IDLE 0
|
||||
#define PAN_STATE_CONN_START 1
|
||||
#define PAN_STATE_CONNECTED 2
|
||||
UINT8 con_state;
|
||||
|
||||
#define PAN_FLAGS_CONN_COMPLETED 0x01
|
||||
UINT8 con_flags;
|
||||
|
||||
UINT16 handle;
|
||||
BD_ADDR rem_bda;
|
||||
|
||||
UINT16 bad_pkts_rcvd;
|
||||
UINT16 src_uuid;
|
||||
UINT16 dst_uuid;
|
||||
UINT16 prv_src_uuid;
|
||||
UINT16 prv_dst_uuid;
|
||||
UINT16 ip_addr_known;
|
||||
UINT32 ip_addr;
|
||||
|
||||
} tPAN_CONN;
|
||||
|
||||
|
||||
/* The main PAN control block
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
UINT8 role;
|
||||
UINT8 active_role;
|
||||
UINT8 prv_active_role;
|
||||
tPAN_CONN pcb[MAX_PAN_CONNS];
|
||||
|
||||
tPAN_CONN_STATE_CB *pan_conn_state_cb; /* Connection state callback */
|
||||
tPAN_BRIDGE_REQ_CB *pan_bridge_req_cb;
|
||||
tPAN_DATA_IND_CB *pan_data_ind_cb;
|
||||
tPAN_DATA_BUF_IND_CB *pan_data_buf_ind_cb;
|
||||
tPAN_FILTER_IND_CB *pan_pfilt_ind_cb; /* protocol filter indication callback */
|
||||
tPAN_MFILTER_IND_CB *pan_mfilt_ind_cb; /* multicast filter indication callback */
|
||||
tPAN_TX_DATA_FLOW_CB *pan_tx_data_flow_cb;
|
||||
|
||||
char *user_service_name;
|
||||
char *gn_service_name;
|
||||
char *nap_service_name;
|
||||
UINT32 pan_user_sdp_handle;
|
||||
UINT32 pan_gn_sdp_handle;
|
||||
UINT32 pan_nap_sdp_handle;
|
||||
UINT8 num_conns;
|
||||
UINT8 trace_level;
|
||||
} tPAN_CB;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Global PAN data
|
||||
*/
|
||||
#if PAN_DYNAMIC_MEMORY == FALSE
|
||||
extern tPAN_CB pan_cb;
|
||||
#else
|
||||
extern tPAN_CB *pan_cb_ptr;
|
||||
#define pan_cb (*pan_cb_ptr)
|
||||
#endif
|
||||
|
||||
/*******************************************************************************/
|
||||
extern void pan_register_with_bnep (void);
|
||||
extern void pan_conn_ind_cb (UINT16 handle,
|
||||
BD_ADDR p_bda,
|
||||
tBT_UUID *remote_uuid,
|
||||
tBT_UUID *local_uuid,
|
||||
BOOLEAN is_role_change);
|
||||
extern void pan_connect_state_cb (UINT16 handle, BD_ADDR rem_bda, tBNEP_RESULT result, BOOLEAN is_role_change);
|
||||
extern void pan_data_ind_cb (UINT16 handle,
|
||||
UINT8 *src,
|
||||
UINT8 *dst,
|
||||
UINT16 protocol,
|
||||
UINT8 *p_data,
|
||||
UINT16 len,
|
||||
BOOLEAN fw_ext_present);
|
||||
extern void pan_data_buf_ind_cb (UINT16 handle,
|
||||
UINT8 *src,
|
||||
UINT8 *dst,
|
||||
UINT16 protocol,
|
||||
BT_HDR *p_buf,
|
||||
BOOLEAN ext);
|
||||
extern void pan_tx_data_flow_cb (UINT16 handle,
|
||||
tBNEP_RESULT event);
|
||||
void pan_proto_filt_ind_cb (UINT16 handle,
|
||||
BOOLEAN indication,
|
||||
tBNEP_RESULT result,
|
||||
UINT16 num_filters,
|
||||
UINT8 *p_filters);
|
||||
void pan_mcast_filt_ind_cb (UINT16 handle,
|
||||
BOOLEAN indication,
|
||||
tBNEP_RESULT result,
|
||||
UINT16 num_filters,
|
||||
UINT8 *p_filters);
|
||||
extern UINT32 pan_register_with_sdp (UINT16 uuid, UINT8 sec_mask, char *p_name, char *p_desc);
|
||||
extern tPAN_CONN *pan_allocate_pcb (BD_ADDR p_bda, UINT16 handle);
|
||||
extern tPAN_CONN *pan_get_pcb_by_handle (UINT16 handle);
|
||||
extern tPAN_CONN *pan_get_pcb_by_addr (BD_ADDR p_bda);
|
||||
extern void pan_close_all_connections (void);
|
||||
extern void pan_release_pcb (tPAN_CONN *p_pcb);
|
||||
extern void pan_dump_status (void);
|
||||
|
||||
/********************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+659
@@ -0,0 +1,659 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* this file contains the PORT API definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef PORT_API_H
|
||||
#define PORT_API_H
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and Types
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
** Define port settings structure send from the application in the
|
||||
** set settings request, or to the application in the set settings indication.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
#define PORT_BAUD_RATE_2400 0x00
|
||||
#define PORT_BAUD_RATE_4800 0x01
|
||||
#define PORT_BAUD_RATE_7200 0x02
|
||||
#define PORT_BAUD_RATE_9600 0x03
|
||||
#define PORT_BAUD_RATE_19200 0x04
|
||||
#define PORT_BAUD_RATE_38400 0x05
|
||||
#define PORT_BAUD_RATE_57600 0x06
|
||||
#define PORT_BAUD_RATE_115200 0x07
|
||||
#define PORT_BAUD_RATE_230400 0x08
|
||||
|
||||
UINT8 baud_rate;
|
||||
|
||||
#define PORT_5_BITS 0x00
|
||||
#define PORT_6_BITS 0x01
|
||||
#define PORT_7_BITS 0x02
|
||||
#define PORT_8_BITS 0x03
|
||||
|
||||
UINT8 byte_size;
|
||||
|
||||
#define PORT_ONESTOPBIT 0x00
|
||||
#define PORT_ONE5STOPBITS 0x01
|
||||
UINT8 stop_bits;
|
||||
|
||||
#define PORT_PARITY_NO 0x00
|
||||
#define PORT_PARITY_YES 0x01
|
||||
UINT8 parity;
|
||||
|
||||
#define PORT_ODD_PARITY 0x00
|
||||
#define PORT_EVEN_PARITY 0x01
|
||||
#define PORT_MARK_PARITY 0x02
|
||||
#define PORT_SPACE_PARITY 0x03
|
||||
|
||||
UINT8 parity_type;
|
||||
|
||||
#define PORT_FC_OFF 0x00
|
||||
#define PORT_FC_XONXOFF_ON_INPUT 0x01
|
||||
#define PORT_FC_XONXOFF_ON_OUTPUT 0x02
|
||||
#define PORT_FC_CTS_ON_INPUT 0x04
|
||||
#define PORT_FC_CTS_ON_OUTPUT 0x08
|
||||
#define PORT_FC_DSR_ON_INPUT 0x10
|
||||
#define PORT_FC_DSR_ON_OUTPUT 0x20
|
||||
|
||||
UINT8 fc_type;
|
||||
|
||||
UINT8 rx_char1;
|
||||
|
||||
#define PORT_XON_DC1 0x11
|
||||
UINT8 xon_char;
|
||||
|
||||
#define PORT_XOFF_DC3 0x13
|
||||
UINT8 xoff_char;
|
||||
|
||||
} tPORT_STATE;
|
||||
|
||||
|
||||
/*
|
||||
** Define the callback function prototypes. Parameters are specific
|
||||
** to each event and are described bellow
|
||||
*/
|
||||
typedef int (tPORT_DATA_CALLBACK) (UINT16 port_handle, void *p_data, UINT16 len);
|
||||
|
||||
#define DATA_CO_CALLBACK_TYPE_INCOMING 1
|
||||
#define DATA_CO_CALLBACK_TYPE_OUTGOING_SIZE 2
|
||||
#define DATA_CO_CALLBACK_TYPE_OUTGOING 3
|
||||
typedef int (tPORT_DATA_CO_CALLBACK) (UINT16 port_handle, UINT8* p_buf, UINT16 len, int type);
|
||||
|
||||
typedef void (tPORT_CALLBACK) (UINT32 code, UINT16 port_handle);
|
||||
|
||||
/*
|
||||
** Define events that registered application can receive in the callback
|
||||
*/
|
||||
|
||||
#define PORT_EV_RXCHAR 0x00000001 /* Any Character received */
|
||||
#define PORT_EV_RXFLAG 0x00000002 /* Received certain character */
|
||||
#define PORT_EV_TXEMPTY 0x00000004 /* Transmitt Queue Empty */
|
||||
#define PORT_EV_CTS 0x00000008 /* CTS changed state */
|
||||
#define PORT_EV_DSR 0x00000010 /* DSR changed state */
|
||||
#define PORT_EV_RLSD 0x00000020 /* RLSD changed state */
|
||||
#define PORT_EV_BREAK 0x00000040 /* BREAK received */
|
||||
#define PORT_EV_ERR 0x00000080 /* Line status error occurred */
|
||||
#define PORT_EV_RING 0x00000100 /* Ring signal detected */
|
||||
#define PORT_EV_CTSS 0x00000400 /* CTS state */
|
||||
#define PORT_EV_DSRS 0x00000800 /* DSR state */
|
||||
#define PORT_EV_RLSDS 0x00001000 /* RLSD state */
|
||||
#define PORT_EV_OVERRUN 0x00002000 /* receiver buffer overrun */
|
||||
#define PORT_EV_TXCHAR 0x00004000 /* Any character transmitted */
|
||||
|
||||
#define PORT_EV_CONNECTED 0x00000200 /* RFCOMM connection established */
|
||||
#define PORT_EV_CONNECT_ERR 0x00008000 /* Was not able to establish connection */
|
||||
/* or disconnected */
|
||||
#define PORT_EV_FC 0x00010000 /* data flow enabled flag changed by remote */
|
||||
#define PORT_EV_FCS 0x00020000 /* data flow enable status true = enabled */
|
||||
|
||||
/*
|
||||
** To register for events application should provide bitmask with
|
||||
** corresponding bit set
|
||||
*/
|
||||
|
||||
#define PORT_MASK_ALL (PORT_EV_RXCHAR | PORT_EV_TXEMPTY | PORT_EV_CTS | \
|
||||
PORT_EV_DSR | PORT_EV_RLSD | PORT_EV_BREAK | \
|
||||
PORT_EV_ERR | PORT_EV_RING | PORT_EV_CONNECT_ERR | \
|
||||
PORT_EV_DSRS | PORT_EV_CTSS | PORT_EV_RLSDS | \
|
||||
PORT_EV_RXFLAG | PORT_EV_TXCHAR | PORT_EV_OVERRUN | \
|
||||
PORT_EV_FC | PORT_EV_FCS | PORT_EV_CONNECTED)
|
||||
|
||||
|
||||
/*
|
||||
** Define port result codes
|
||||
*/
|
||||
#define PORT_SUCCESS 0
|
||||
|
||||
#define PORT_ERR_BASE 0
|
||||
|
||||
#define PORT_UNKNOWN_ERROR (PORT_ERR_BASE + 1)
|
||||
#define PORT_ALREADY_OPENED (PORT_ERR_BASE + 2)
|
||||
#define PORT_CMD_PENDING (PORT_ERR_BASE + 3)
|
||||
#define PORT_APP_NOT_REGISTERED (PORT_ERR_BASE + 4)
|
||||
#define PORT_NO_MEM (PORT_ERR_BASE + 5)
|
||||
#define PORT_NO_RESOURCES (PORT_ERR_BASE + 6)
|
||||
#define PORT_BAD_BD_ADDR (PORT_ERR_BASE + 7)
|
||||
#define PORT_BAD_HANDLE (PORT_ERR_BASE + 9)
|
||||
#define PORT_NOT_OPENED (PORT_ERR_BASE + 10)
|
||||
#define PORT_LINE_ERR (PORT_ERR_BASE + 11)
|
||||
#define PORT_START_FAILED (PORT_ERR_BASE + 12)
|
||||
#define PORT_PAR_NEG_FAILED (PORT_ERR_BASE + 13)
|
||||
#define PORT_PORT_NEG_FAILED (PORT_ERR_BASE + 14)
|
||||
#define PORT_SEC_FAILED (PORT_ERR_BASE + 15)
|
||||
#define PORT_PEER_CONNECTION_FAILED (PORT_ERR_BASE + 16)
|
||||
#define PORT_PEER_FAILED (PORT_ERR_BASE + 17)
|
||||
#define PORT_PEER_TIMEOUT (PORT_ERR_BASE + 18)
|
||||
#define PORT_CLOSED (PORT_ERR_BASE + 19)
|
||||
#define PORT_TX_FULL (PORT_ERR_BASE + 20)
|
||||
#define PORT_LOCAL_CLOSED (PORT_ERR_BASE + 21)
|
||||
#define PORT_LOCAL_TIMEOUT (PORT_ERR_BASE + 22)
|
||||
#define PORT_TX_QUEUE_DISABLED (PORT_ERR_BASE + 23)
|
||||
#define PORT_PAGE_TIMEOUT (PORT_ERR_BASE + 24)
|
||||
#define PORT_INVALID_SCN (PORT_ERR_BASE + 25)
|
||||
|
||||
#define PORT_ERR_MAX (PORT_ERR_BASE + 26)
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function RFCOMM_CreateConnection
|
||||
**
|
||||
** Description RFCOMM_CreateConnection function is used from the application
|
||||
** to establish serial port connection to the peer device,
|
||||
** or allow RFCOMM to accept a connection from the peer
|
||||
** application.
|
||||
**
|
||||
** Parameters: scn - Service Channel Number as registered with
|
||||
** the SDP (server) or obtained using SDP from
|
||||
** the peer device (client).
|
||||
** is_server - TRUE if requesting application is a server
|
||||
** mtu - Maximum frame size the application can accept
|
||||
** bd_addr - BD_ADDR of the peer (client)
|
||||
** mask - specifies events to be enabled. A value
|
||||
** of zero disables all events.
|
||||
** p_handle - OUT pointer to the handle.
|
||||
** p_mgmt_cb - pointer to callback function to receive
|
||||
** connection up/down events.
|
||||
** Notes:
|
||||
**
|
||||
** Server can call this function with the same scn parameter multiple times if
|
||||
** it is ready to accept multiple simulteneous connections.
|
||||
**
|
||||
** DLCI for the connection is (scn * 2 + 1) if client originates connection on
|
||||
** existing none initiator multiplexer channel. Otherwise it is (scn * 2).
|
||||
** For the server DLCI can be changed later if client will be calling it using
|
||||
** (scn * 2 + 1) dlci.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn,
|
||||
BOOLEAN is_server, UINT16 mtu,
|
||||
BD_ADDR bd_addr, UINT16 *p_handle,
|
||||
tPORT_CALLBACK *p_mgmt_cb);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function RFCOMM_RemoveConnection
|
||||
**
|
||||
** Description This function is called to close the specified connection.
|
||||
**
|
||||
** Parameters: handle - Handle of the port returned in the Open
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int RFCOMM_RemoveConnection (UINT16 handle);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function RFCOMM_RemoveServer
|
||||
**
|
||||
** Description This function is called to close the server port.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int RFCOMM_RemoveServer (UINT16 handle);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_SetEventCallback
|
||||
**
|
||||
** Description Set event callback the specified connection.
|
||||
**
|
||||
** Parameters: handle - Handle of the port returned in the Open
|
||||
** p_callback - address of the callback function which should
|
||||
** be called from the RFCOMM when an event
|
||||
** specified in the mask occurs.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_SetEventCallback (UINT16 port_handle,
|
||||
tPORT_CALLBACK *p_port_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_ClearKeepHandleFlag
|
||||
**
|
||||
** Description This function is called to clear the keep handle flag
|
||||
** which will cause not to keep the port handle open when closed
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
**
|
||||
*******************************************************************************/
|
||||
int PORT_ClearKeepHandleFlag (UINT16 port_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_SetEventCallback
|
||||
**
|
||||
** Description Set event data callback the specified connection.
|
||||
**
|
||||
** Parameters: handle - Handle of the port returned in the Open
|
||||
** p_callback - address of the callback function which should
|
||||
** be called from the RFCOMM when a data
|
||||
** packet is received.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_SetDataCallback (UINT16 port_handle,
|
||||
tPORT_DATA_CALLBACK *p_cb);
|
||||
|
||||
extern int PORT_SetDataCOCallback (UINT16 port_handle, tPORT_DATA_CO_CALLBACK *p_port_cb);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_SetEventMask
|
||||
**
|
||||
** Description This function is called to close the specified connection.
|
||||
**
|
||||
** Parameters: handle - Handle of the port returned in the Open
|
||||
** mask - specifies events to be enabled. A value
|
||||
** of zero disables all events.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_SetEventMask (UINT16 port_handle, UINT32 mask);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_CheckConnection
|
||||
**
|
||||
** Description This function returns PORT_SUCCESS if connection referenced
|
||||
** by handle is up and running
|
||||
**
|
||||
** Parameters: handle - Handle of the port returned in the Open
|
||||
** bd_addr - OUT bd_addr of the peer
|
||||
** p_lcid - OUT L2CAP's LCID
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_CheckConnection (UINT16 handle, BD_ADDR bd_addr,
|
||||
UINT16 *p_lcid);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_IsOpening
|
||||
**
|
||||
** Description This function returns TRUE if there is any RFCOMM connection
|
||||
** opening in process.
|
||||
**
|
||||
** Parameters: TRUE if any connection opening is found
|
||||
** bd_addr - bd_addr of the peer
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN PORT_IsOpening (BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_SetState
|
||||
**
|
||||
** Description This function configures connection according to the
|
||||
** specifications in the tPORT_STATE structure.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** p_settings - Pointer to a tPORT_STATE structure containing
|
||||
** configuration information for the connection.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_SetState (UINT16 handle, tPORT_STATE *p_settings);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_GetRxQueueCnt
|
||||
**
|
||||
** Description This function return number of buffers on the rx queue.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** p_rx_queue_count - Pointer to return queue count in.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_GetRxQueueCnt (UINT16 handle, UINT16 *p_rx_queue_count);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_GetState
|
||||
**
|
||||
** Description This function is called to fill tPORT_STATE structure
|
||||
** with the current control settings for the port
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** p_settings - Pointer to a tPORT_STATE structure in which
|
||||
** configuration information is returned.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_GetState (UINT16 handle, tPORT_STATE *p_settings);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_Control
|
||||
**
|
||||
** Description This function directs a specified connection to pass control
|
||||
** control information to the peer device.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** signal - specify the function to be passed
|
||||
**
|
||||
*******************************************************************************/
|
||||
#define PORT_SET_DTRDSR 0x01
|
||||
#define PORT_CLR_DTRDSR 0x02
|
||||
#define PORT_SET_CTSRTS 0x03
|
||||
#define PORT_CLR_CTSRTS 0x04
|
||||
#define PORT_SET_RI 0x05 /* DCE only */
|
||||
#define PORT_CLR_RI 0x06 /* DCE only */
|
||||
#define PORT_SET_DCD 0x07 /* DCE only */
|
||||
#define PORT_CLR_DCD 0x08 /* DCE only */
|
||||
#define PORT_BREAK 0x09 /* Break event */
|
||||
|
||||
extern int PORT_Control (UINT16 handle, UINT8 signal);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_FlowControl
|
||||
**
|
||||
** Description This function directs a specified connection to pass
|
||||
** flow control message to the peer device. Enable flag passed
|
||||
** shows if port can accept more data.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** enable - enables data flow
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_FlowControl (UINT16 handle, BOOLEAN enable);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_GetModemStatus
|
||||
**
|
||||
** Description This function retrieves modem control signals. Normally
|
||||
** application will call this function after a callback
|
||||
** function is called with notification that one of signals
|
||||
** has been changed.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** callback.
|
||||
** p_signal - specify the pointer to control signals info
|
||||
**
|
||||
*******************************************************************************/
|
||||
#define PORT_DTRDSR_ON 0x01
|
||||
#define PORT_CTSRTS_ON 0x02
|
||||
#define PORT_RING_ON 0x04
|
||||
#define PORT_DCD_ON 0x08
|
||||
|
||||
/*
|
||||
** Define default initial local modem signals state set after connection established
|
||||
*/
|
||||
#define PORT_OBEX_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
|
||||
#define PORT_SPP_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
|
||||
#define PORT_PPP_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
|
||||
#define PORT_DUN_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON)
|
||||
|
||||
extern int PORT_GetModemStatus (UINT16 handle, UINT8 *p_control_signal);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_ClearError
|
||||
**
|
||||
** Description This function retreives information about a communications
|
||||
** error and reports current status of a connection. The
|
||||
** function should be called when an error occures to clear
|
||||
** the connection error flag and to enable additional read
|
||||
** and write operations.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** p_errors - pointer of the variable to receive error codes
|
||||
** p_status - pointer to the tPORT_STATUS structur to receive
|
||||
** connection status
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
#define PORT_ERR_BREAK 0x01 /* Break condition occured on the peer device */
|
||||
#define PORT_ERR_OVERRUN 0x02 /* Overrun is reported by peer device */
|
||||
#define PORT_ERR_FRAME 0x04 /* Framing error reported by peer device */
|
||||
#define PORT_ERR_RXOVER 0x08 /* Input queue overflow occured */
|
||||
#define PORT_ERR_TXFULL 0x10 /* Output queue overflow occured */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#define PORT_FLAG_CTS_HOLD 0x01 /* Tx is waiting for CTS signal */
|
||||
#define PORT_FLAG_DSR_HOLD 0x02 /* Tx is waiting for DSR signal */
|
||||
#define PORT_FLAG_RLSD_HOLD 0x04 /* Tx is waiting for RLSD signal */
|
||||
|
||||
UINT16 flags;
|
||||
UINT16 in_queue_size; /* Number of bytes in the input queue */
|
||||
UINT16 out_queue_size; /* Number of bytes in the output queue */
|
||||
UINT16 mtu_size; /* peer MTU size */
|
||||
} tPORT_STATUS;
|
||||
|
||||
|
||||
extern int PORT_ClearError (UINT16 handle, UINT16 *p_errors,
|
||||
tPORT_STATUS *p_status);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_SendError
|
||||
**
|
||||
** Description This function send a communications error to the peer device
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** errors - receive error codes
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_SendError (UINT16 handle, UINT8 errors);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_GetQueueStatus
|
||||
**
|
||||
** Description This function reports current status of a connection.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** p_status - pointer to the tPORT_STATUS structur to receive
|
||||
** connection status
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_GetQueueStatus (UINT16 handle, tPORT_STATUS *p_status);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_Purge
|
||||
**
|
||||
** Description This function discards all the data from the output or
|
||||
** input queues of the specified connection.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** purge_flags - specify the action to take.
|
||||
**
|
||||
*******************************************************************************/
|
||||
#define PORT_PURGE_TXCLEAR 0x01
|
||||
#define PORT_PURGE_RXCLEAR 0x02
|
||||
|
||||
extern int PORT_Purge (UINT16 handle, UINT8 purge_flags);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_Read
|
||||
**
|
||||
** Description This function returns the pointer to the buffer received
|
||||
** from the peer device. Normally application will call this
|
||||
** function after receiving PORT_EVT_RXCHAR event.
|
||||
** Application calling this function is responsible to free
|
||||
** buffer returned.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** callback.
|
||||
** pp_buf - pointer to address of buffer with data,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_Read (UINT16 handle, BT_HDR **pp_buf);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_ReadData
|
||||
**
|
||||
** Description Normally application will call this function after receiving
|
||||
** PORT_EVT_RXCHAR event.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** callback.
|
||||
** p_data - Data area
|
||||
** max_len - Byte count requested
|
||||
** p_len - Byte count received
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len,
|
||||
UINT16 *p_len);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_Write
|
||||
**
|
||||
** Description This function to send BT buffer to the peer device.
|
||||
** Application should not free the buffer.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** p_buf - pointer to the buffer with data,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_Write (UINT16 handle, BT_HDR *p_buf);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_WriteData
|
||||
**
|
||||
** Description This function is called from the legacy application to
|
||||
** send data.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** p_data - Data area
|
||||
** max_len - Byte count to write
|
||||
** p_len - Bytes written
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len,
|
||||
UINT16 *p_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_WriteDataCO
|
||||
**
|
||||
** Description Normally not GKI aware application will call this function
|
||||
** to send data to the port by callout functions.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_WriteDataCO (UINT16 handle, int* p_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_Test
|
||||
**
|
||||
** Description Application can call this function to send RFCOMM Test frame
|
||||
**
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
** p_data - Data area
|
||||
** max_len - Byte count requested
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_Test (UINT16 handle, UINT8 *p_data, UINT16 len);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function RFCOMM_Init
|
||||
**
|
||||
** Description This function is called to initialize RFCOMM layer
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void RFCOMM_Init (void);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_SetTraceLevel
|
||||
**
|
||||
** Description This function sets the trace level for RFCOMM. If called with
|
||||
** a value of 0xFF, it simply reads the current trace level.
|
||||
**
|
||||
** Returns the new (current) trace level
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 PORT_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function PORT_GetResultString
|
||||
**
|
||||
** Description This function returns the human-readable string for a given
|
||||
** result code.
|
||||
**
|
||||
** Returns a pointer to the human-readable string for the given
|
||||
** result. Note that the string returned must not be freed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern const char *PORT_GetResultString (const uint8_t result_code);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PORT_API_H */
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains external definitions of Port Emulation entity unit
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef PORTEXT_H
|
||||
#define PORTEXT_H
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
/* Port emulation entity Entry Points */
|
||||
extern void rfcomm_process_timeout (TIMER_LIST_ENT *p_tle);
|
||||
#endif
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2013 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef PROFILES_API_H
|
||||
#define PROFILES_API_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "btm_api.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
#define BT_PASS 0 /* Used for general successful function returns */
|
||||
|
||||
/*** Port entity passes back 8 bit errors; will use upper byte offset ***/
|
||||
#define PORT_ERR_GRP 0x0000 /* base offset for port entity */
|
||||
#define GAP_ERR_GRP 0x0100 /* base offset for GAP profile */
|
||||
#define SPP_ERR_GRP 0x0200 /* base offset for serial port profile */
|
||||
#define HCRP_ERR_GRP 0x0300 /* base offset for HCRP */
|
||||
#define HCRPM_ERR_GRP 0x0400 /* base offset for HCRPM */
|
||||
|
||||
/* #define HSP2_ERR_GRP 0x0F00 */
|
||||
|
||||
/* security level definitions (tBT_SECURITY) */
|
||||
#define BT_USE_DEF_SECURITY 0
|
||||
#define BT_SEC_MODE_NONE BTM_SEC_MODE_NONE
|
||||
#define BT_SEC_MODE_SERVICE BTM_SEC_MODE_SERVICE
|
||||
#define BT_SEC_MODE_LINK BTM_SEC_MODE_LINK
|
||||
|
||||
/* security mask definitions (tBT_SECURITY) */
|
||||
/* The following definitions are OR'd together to form the security requirements */
|
||||
#define BT_SEC_IN_AUTHORIZE BTM_SEC_IN_AUTHORIZE /* Inbound call requires authorization */
|
||||
#define BT_SEC_IN_AUTHENTICATE BTM_SEC_IN_AUTHENTICATE /* Inbound call requires authentication */
|
||||
#define BT_SEC_IN_ENCRYPT BTM_SEC_IN_ENCRYPT /* Inbound call requires encryption */
|
||||
#define BT_SEC_OUT_AUTHORIZE BTM_SEC_OUT_AUTHORIZE /* Outbound call requires authorization */
|
||||
#define BT_SEC_OUT_AUTHENTICATE BTM_SEC_OUT_AUTHENTICATE /* Outbound call requires authentication */
|
||||
#define BT_SEC_OUT_ENCRYPT BTM_SEC_OUT_ENCRYPT /* Outbound call requires encryption */
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
** Security Definitions
|
||||
** This following definitions are used to indicate the security
|
||||
** requirements for a service.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
UINT8 level;
|
||||
UINT8 mask;
|
||||
} tBT_SECURITY;
|
||||
|
||||
#endif /* PROFILES_API_H */
|
||||
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* This file contains definitions for the RFCOMM protocol
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef RFCDEFS_H
|
||||
#define RFCDEFS_H
|
||||
|
||||
#define PORT_MAX_RFC_PORTS 31
|
||||
|
||||
/*
|
||||
** If nothing is negotiated MTU should be 127
|
||||
*/
|
||||
#define RFCOMM_DEFAULT_MTU 127
|
||||
|
||||
/*
|
||||
** Define used by RFCOMM TS frame types
|
||||
*/
|
||||
#define RFCOMM_SABME 0x2F
|
||||
#define RFCOMM_UA 0x63
|
||||
#define RFCOMM_DM 0x0F
|
||||
#define RFCOMM_DISC 0x43
|
||||
#define RFCOMM_UIH 0xEF
|
||||
|
||||
/*
|
||||
** Defenitions for the TS control frames
|
||||
*/
|
||||
#define RFCOMM_CTRL_FRAME_LEN 3
|
||||
#define RFCOMM_MIN_OFFSET 5 /* ctrl 2 , len 1 or 2 bytes, credit 1 byte */
|
||||
#define RFCOMM_DATA_OVERHEAD (RFCOMM_MIN_OFFSET + 1) /* add 1 for checksum */
|
||||
|
||||
#define RFCOMM_EA 1
|
||||
#define RFCOMM_EA_MASK 0x01
|
||||
#define RFCOMM_CR_MASK 0x02
|
||||
#define RFCOMM_SHIFT_CR 1
|
||||
#define RFCOMM_SHIFT_DLCI 2
|
||||
#define RFCOMM_SHIFT_DLCI2 6
|
||||
#define RFCOMM_PF 0x10
|
||||
#define RFCOMM_PF_MASK 0x10
|
||||
#define RFCOMM_PF_OFFSET 4
|
||||
#define RFCOMM_SHIFT_LENGTH1 1
|
||||
#define RFCOMM_SHIFT_LENGTH2 7
|
||||
#define RFCOMM_SHIFT_MX_CTRL_TYPE 2
|
||||
|
||||
#define RFCOMM_INITIATOR_CMD 1
|
||||
#define RFCOMM_INITIATOR_RSP 0
|
||||
#define RFCOMM_RESPONDER_CMD 0
|
||||
#define RFCOMM_RESPONDER_RSP 1
|
||||
|
||||
#define RFCOMM_PARSE_CTRL_FIELD(ea, cr, dlci, p_data) \
|
||||
{ \
|
||||
ea = *p_data & RFCOMM_EA; \
|
||||
cr = (*p_data & RFCOMM_CR_MASK) >> RFCOMM_SHIFT_CR; \
|
||||
dlci = *p_data++ >> RFCOMM_SHIFT_DLCI; \
|
||||
if (!ea) dlci += *p_data++ << RFCOMM_SHIFT_DLCI2; \
|
||||
}
|
||||
|
||||
#define RFCOMM_FORMAT_CTRL_FIELD(p_data, ea, cr, dlci) \
|
||||
*p_data++ = ea | cr | (dlci << RFCOMM_SHIFT_DLCI)
|
||||
|
||||
#define RFCOMM_PARSE_TYPE_FIELD(type, pf, p_data) \
|
||||
{ \
|
||||
type = *p_data & ~RFCOMM_PF_MASK; \
|
||||
pf = (*p_data++ & RFCOMM_PF_MASK) >> RFCOMM_PF_OFFSET;\
|
||||
}
|
||||
|
||||
#define RFCOMM_FORMAT_TYPE_FIELD(p_data, type, pf) \
|
||||
*p_data++ = (type | (pf << RFCOMM_PF_OFFSET)) \
|
||||
{ \
|
||||
type = *p_data & ~RFCOMM_PF_MASK; \
|
||||
pf = (*p_data++ & RFCOMM_PF_MASK) >> RFCOMM_PF_OFFSET;\
|
||||
}
|
||||
|
||||
#define RFCOMM_PARSE_LEN_FIELD(ea, length, p_data) \
|
||||
{ \
|
||||
ea = (*p_data & RFCOMM_EA); \
|
||||
length = (*p_data++ >> RFCOMM_SHIFT_LENGTH1); \
|
||||
if (!ea) length += (*p_data++ << RFCOMM_SHIFT_LENGTH2); \
|
||||
}
|
||||
|
||||
#define RFCOMM_FRAME_IS_CMD(initiator, cr) \
|
||||
(( (initiator) && !(cr)) || (!(initiator) && (cr)))
|
||||
|
||||
#define RFCOMM_FRAME_IS_RSP(initiator, cr) \
|
||||
(( (initiator) && (cr)) || (!(initiator) && !(cr)))
|
||||
|
||||
#define RFCOMM_CR(initiator, is_command) \
|
||||
(( ( (initiator) && (is_command)) \
|
||||
|| (!(initiator) && !(is_command))) << 1)
|
||||
|
||||
#define RFCOMM_I_CR(is_command) ((is_command) ? 0x02 : 0x00)
|
||||
|
||||
#define RFCOMM_MAX_DLCI 61
|
||||
|
||||
#define RFCOMM_VALID_DLCI(dlci) \
|
||||
(((dlci) == 0) || (((dlci) >= 2) && ((dlci) <= RFCOMM_MAX_DLCI)))
|
||||
|
||||
|
||||
/* Port Negotiation (PN) */
|
||||
#define RFCOMM_PN_DLCI_MASK 0x3F
|
||||
|
||||
#define RFCOMM_PN_FRAM_TYPE_UIH 0x00
|
||||
#define RFCOMM_PN_FRAME_TYPE_MASK 0x0F
|
||||
|
||||
#define RFCOMM_PN_CONV_LAYER_MASK 0xF0
|
||||
#define RFCOMM_PN_CONV_LAYER_TYPE_1 0
|
||||
#define RFCOMM_PN_CONV_LAYER_CBFC_I 0xF0
|
||||
#define RFCOMM_PN_CONV_LAYER_CBFC_R 0xE0
|
||||
|
||||
#define RFCOMM_PN_PRIORITY_MASK 0x3F
|
||||
#define RFCOMM_PN_PRIORITY_0 0
|
||||
|
||||
#define RFCOMM_PN_K_MASK 0x07
|
||||
|
||||
#define RFCOMM_T1_DSEC 0 /* None negotiable in RFCOMM */
|
||||
#define RFCOMM_N2 0 /* Number of retransmissions */
|
||||
#define RFCOMM_K 0 /* Window size */
|
||||
#define RFCOMM_K_MAX 7 /* Max value of K for credit based flow control */
|
||||
|
||||
#define RFCOMM_MSC_FC 0x02 /* Flow control*/
|
||||
#define RFCOMM_MSC_RTC 0x04 /* Ready to communicate*/
|
||||
#define RFCOMM_MSC_RTR 0x08 /* Ready to receive*/
|
||||
#define RFCOMM_MSC_IC 0x40 /* Incomming call indicator*/
|
||||
#define RFCOMM_MSC_DV 0x80 /* Data Valid*/
|
||||
|
||||
#define RFCOMM_MSC_SHIFT_BREAK 4
|
||||
#define RFCOMM_MSC_BREAK_MASK 0xF0
|
||||
#define RFCOMM_MSC_BREAK_PRESENT_MASK 0x02
|
||||
|
||||
#define RFCOMM_BAUD_RATE_2400 0x00
|
||||
#define RFCOMM_BAUD_RATE_4800 0x01
|
||||
#define RFCOMM_BAUD_RATE_7200 0x02
|
||||
#define RFCOMM_BAUD_RATE_9600 0x03
|
||||
#define RFCOMM_BAUD_RATE_19200 0x04
|
||||
#define RFCOMM_BAUD_RATE_38400 0x05
|
||||
#define RFCOMM_BAUD_RATE_57600 0x06
|
||||
#define RFCOMM_BAUD_RATE_115200 0x07
|
||||
#define RFCOMM_BAUD_RATE_230400 0x08
|
||||
|
||||
#define RFCOMM_5_BITS 0x00
|
||||
#define RFCOMM_6_BITS 0x01
|
||||
#define RFCOMM_7_BITS 0x02
|
||||
#define RFCOMM_8_BITS 0x03
|
||||
|
||||
#define RFCOMM_RPN_BITS_MASK 0x03
|
||||
#define RFCOMM_RPN_BITS_SHIFT 0
|
||||
|
||||
#define RFCOMM_ONESTOPBIT 0x00
|
||||
#define RFCOMM_ONE5STOPBITS 0x01
|
||||
|
||||
#define RFCOMM_RPN_STOP_BITS_MASK 0x01
|
||||
#define RFCOMM_RPN_STOP_BITS_SHIFT 2
|
||||
|
||||
#define RFCOMM_PARITY_NO 0x00
|
||||
#define RFCOMM_PARITY_YES 0x01
|
||||
#define RFCOMM_RPN_PARITY_MASK 0x01
|
||||
#define RFCOMM_RPN_PARITY_SHIFT 3
|
||||
|
||||
#define RFCOMM_ODD_PARITY 0x00
|
||||
#define RFCOMM_EVEN_PARITY 0x01
|
||||
#define RFCOMM_MARK_PARITY 0x02
|
||||
#define RFCOMM_SPACE_PARITY 0x03
|
||||
|
||||
#define RFCOMM_RPN_PARITY_TYPE_MASK 0x03
|
||||
#define RFCOMM_RPN_PARITY_TYPE_SHIFT 4
|
||||
|
||||
#define RFCOMM_FC_OFF 0x00
|
||||
#define RFCOMM_FC_XONXOFF_ON_INPUT 0x01
|
||||
#define RFCOMM_FC_XONXOFF_ON_OUTPUT 0x02
|
||||
#define RFCOMM_FC_RTR_ON_INPUT 0x04
|
||||
#define RFCOMM_FC_RTR_ON_OUTPUT 0x08
|
||||
#define RFCOMM_FC_RTC_ON_INPUT 0x10
|
||||
#define RFCOMM_FC_RTC_ON_OUTPUT 0x20
|
||||
#define RFCOMM_FC_MASK 0x3F
|
||||
|
||||
#define RFCOMM_RPN_PM_BIT_RATE 0x0001
|
||||
#define RFCOMM_RPN_PM_DATA_BITS 0x0002
|
||||
#define RFCOMM_RPN_PM_STOP_BITS 0x0004
|
||||
#define RFCOMM_RPN_PM_PARITY 0x0008
|
||||
#define RFCOMM_RPN_PM_PARITY_TYPE 0x0010
|
||||
#define RFCOMM_RPN_PM_XON_CHAR 0x0020
|
||||
#define RFCOMM_RPN_PM_XOFF_CHAR 0x0040
|
||||
#define RFCOMM_RPN_PM_XONXOFF_ON_INPUT 0x0100
|
||||
#define RFCOMM_RPN_PM_XONXOFF_ON_OUTPUT 0x0200
|
||||
#define RFCOMM_RPN_PM_RTR_ON_INPUT 0x0400
|
||||
#define RFCOMM_RPN_PM_RTR_ON_OUTPUT 0x0800
|
||||
#define RFCOMM_RPN_PM_RTC_ON_INPUT 0x1000
|
||||
#define RFCOMM_RPN_PM_RTC_ON_OUTPUT 0x2000
|
||||
#define RFCOMM_RPN_PM_MASK 0x3F7F
|
||||
|
||||
#define RFCOMM_RLS_ERROR 0x01
|
||||
#define RFCOMM_RLS_OVERRUN 0x02
|
||||
#define RFCOMM_RLS_PARITY 0x04
|
||||
#define RFCOMM_RLS_FRAMING 0x08
|
||||
|
||||
/* Multiplexor channel uses DLCI 0 */
|
||||
#define RFCOMM_MX_DLCI 0
|
||||
|
||||
/*
|
||||
** Define RFCOMM Multiplexer message types
|
||||
*/
|
||||
#define RFCOMM_MX_PN 0x80
|
||||
#define RFCOMM_MX_PN_LEN 8
|
||||
|
||||
#define RFCOMM_MX_CLD 0xC0
|
||||
#define RFCOMM_MX_CLD_LEN 0
|
||||
|
||||
#define RFCOMM_MX_TEST 0x20
|
||||
|
||||
#define RFCOMM_MX_FCON 0xA0
|
||||
#define RFCOMM_MX_FCON_LEN 0
|
||||
|
||||
#define RFCOMM_MX_FCOFF 0x60
|
||||
#define RFCOMM_MX_FCOFF_LEN 0
|
||||
|
||||
#define RFCOMM_MX_MSC 0xE0
|
||||
#define RFCOMM_MX_MSC_LEN_NO_BREAK 2
|
||||
#define RFCOMM_MX_MSC_LEN_WITH_BREAK 3
|
||||
|
||||
#define RFCOMM_MX_NSC 0x10
|
||||
#define RFCOMM_MX_NSC_LEN 1
|
||||
|
||||
#define RFCOMM_MX_RPN 0x90
|
||||
#define RFCOMM_MX_RPN_REQ_LEN 1
|
||||
#define RFCOMM_MX_RPN_LEN 8
|
||||
|
||||
#define RFCOMM_MX_RLS 0x50
|
||||
#define RFCOMM_MX_RLS_LEN 2
|
||||
#endif
|
||||
+736
@@ -0,0 +1,736 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef SDP_API_H
|
||||
#define SDP_API_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "sdpdefs.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* Success code and error codes */
|
||||
#define SDP_SUCCESS 0x0000
|
||||
#define SDP_INVALID_VERSION 0x0001
|
||||
#define SDP_INVALID_SERV_REC_HDL 0x0002
|
||||
#define SDP_INVALID_REQ_SYNTAX 0x0003
|
||||
#define SDP_INVALID_PDU_SIZE 0x0004
|
||||
#define SDP_INVALID_CONT_STATE 0x0005
|
||||
#define SDP_NO_RESOURCES 0x0006
|
||||
#define SDP_DI_REG_FAILED 0x0007
|
||||
#define SDP_DI_DISC_FAILED 0x0008
|
||||
#define SDP_NO_DI_RECORD_FOUND 0x0009
|
||||
#define SDP_ERR_ATTR_NOT_PRESENT 0x000A
|
||||
#define SDP_ILLEGAL_PARAMETER 0x000B
|
||||
|
||||
#define SDP_NO_RECS_MATCH 0xFFF0
|
||||
#define SDP_CONN_FAILED 0xFFF1
|
||||
#define SDP_CFG_FAILED 0xFFF2
|
||||
#define SDP_GENERIC_ERROR 0xFFF3
|
||||
#define SDP_DB_FULL 0xFFF4
|
||||
#define SDP_INVALID_PDU 0xFFF5
|
||||
#define SDP_SECURITY_ERR 0xFFF6
|
||||
#define SDP_CONN_REJECTED 0xFFF7
|
||||
#define SDP_CANCEL 0xFFF8
|
||||
|
||||
/* Define the PSM that SDP uses */
|
||||
#define SDP_PSM 0x0001
|
||||
|
||||
/* Legacy #define to avoid code changes - SDP UUID is same as BT UUID */
|
||||
#define tSDP_UUID tBT_UUID
|
||||
|
||||
/* Masks for attr_value field of tSDP_DISC_ATTR */
|
||||
#define SDP_DISC_ATTR_LEN_MASK 0x0FFF
|
||||
#define SDP_DISC_ATTR_TYPE(len_type) (len_type >> 12)
|
||||
#define SDP_DISC_ATTR_LEN(len_type) (len_type & SDP_DISC_ATTR_LEN_MASK)
|
||||
|
||||
/* Maximum number of protocol list items (list_elem in tSDP_PROTOCOL_ELEM) */
|
||||
#define SDP_MAX_LIST_ELEMS 3
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
/* Define a callback function for when discovery is complete. */
|
||||
typedef void (tSDP_DISC_CMPL_CB) (UINT16 result);
|
||||
typedef void (tSDP_DISC_CMPL_CB2) (UINT16 result, void* user_data);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BD_ADDR peer_addr;
|
||||
UINT16 peer_mtu;
|
||||
} tSDP_DR_OPEN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 *p_data;
|
||||
UINT16 data_len;
|
||||
} tSDP_DR_DATA;
|
||||
|
||||
typedef union
|
||||
{
|
||||
tSDP_DR_OPEN open;
|
||||
tSDP_DR_DATA data;
|
||||
} tSDP_DATA;
|
||||
|
||||
/* Define a callback function for when discovery result is received. */
|
||||
typedef void (tSDP_DISC_RES_CB) (UINT16 event, tSDP_DATA *p_data);
|
||||
|
||||
/* Define a structure to hold the discovered service information. */
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
UINT8 u8; /* 8-bit integer */
|
||||
UINT16 u16; /* 16-bit integer */
|
||||
UINT32 u32; /* 32-bit integer */
|
||||
UINT8 array[4]; /* Variable length field */
|
||||
struct t_sdp_disc_attr *p_sub_attr; /* Addr of first sub-attr (list)*/
|
||||
} v;
|
||||
|
||||
} tSDP_DISC_ATVAL;
|
||||
|
||||
typedef struct t_sdp_disc_attr
|
||||
{
|
||||
struct t_sdp_disc_attr *p_next_attr; /* Addr of next linked attr */
|
||||
UINT16 attr_id; /* Attribute ID */
|
||||
UINT16 attr_len_type; /* Length and type fields */
|
||||
tSDP_DISC_ATVAL attr_value; /* Variable length entry data */
|
||||
} tSDP_DISC_ATTR;
|
||||
|
||||
typedef struct t_sdp_disc_rec
|
||||
{
|
||||
tSDP_DISC_ATTR *p_first_attr; /* First attribute of record */
|
||||
struct t_sdp_disc_rec *p_next_rec; /* Addr of next linked record */
|
||||
UINT32 time_read; /* The time the record was read */
|
||||
BD_ADDR remote_bd_addr; /* Remote BD address */
|
||||
} tSDP_DISC_REC;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 mem_size; /* Memory size of the DB */
|
||||
UINT32 mem_free; /* Memory still available */
|
||||
tSDP_DISC_REC *p_first_rec; /* Addr of first record in DB */
|
||||
UINT16 num_uuid_filters; /* Number of UUIds to filter */
|
||||
tSDP_UUID uuid_filters[SDP_MAX_UUID_FILTERS]; /* UUIDs to filter */
|
||||
UINT16 num_attr_filters; /* Number of attribute filters */
|
||||
UINT16 attr_filters[SDP_MAX_ATTR_FILTERS]; /* Attributes to filter */
|
||||
UINT8 *p_free_mem; /* Pointer to free memory */
|
||||
#if (SDP_RAW_DATA_INCLUDED == TRUE)
|
||||
UINT8 *raw_data; /* Received record from server. allocated/released by client */
|
||||
UINT32 raw_size; /* size of raw_data */
|
||||
UINT32 raw_used; /* length of raw_data used */
|
||||
#endif
|
||||
}tSDP_DISCOVERY_DB;
|
||||
|
||||
/* This structure is used to add protocol lists and find protocol elements */
|
||||
typedef struct
|
||||
{
|
||||
UINT16 protocol_uuid;
|
||||
UINT16 num_params;
|
||||
UINT16 params[SDP_MAX_PROTOCOL_PARAMS];
|
||||
} tSDP_PROTOCOL_ELEM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 num_elems;
|
||||
tSDP_PROTOCOL_ELEM list_elem[SDP_MAX_LIST_ELEMS];
|
||||
} tSDP_PROTO_LIST_ELEM;
|
||||
|
||||
/* Device Identification (DI) data structure
|
||||
*/
|
||||
/* Used to set the DI record */
|
||||
typedef struct t_sdp_di_record
|
||||
{
|
||||
UINT16 vendor;
|
||||
UINT16 vendor_id_source;
|
||||
UINT16 product;
|
||||
UINT16 version;
|
||||
BOOLEAN primary_record;
|
||||
char client_executable_url[SDP_MAX_ATTR_LEN]; /* optional */
|
||||
char service_description[SDP_MAX_ATTR_LEN]; /* optional */
|
||||
char documentation_url[SDP_MAX_ATTR_LEN]; /* optional */
|
||||
}tSDP_DI_RECORD;
|
||||
|
||||
/* Used to get the DI record */
|
||||
typedef struct t_sdp_di_get_record
|
||||
{
|
||||
UINT16 spec_id;
|
||||
tSDP_DI_RECORD rec;
|
||||
}tSDP_DI_GET_RECORD;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* API into the SDP layer for service discovery. */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_InitDiscoveryDb
|
||||
**
|
||||
** Description This function is called to initialize a discovery database.
|
||||
**
|
||||
** Returns TRUE if successful, FALSE if one or more parameters are bad
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_InitDiscoveryDb (tSDP_DISCOVERY_DB *p_db, UINT32 len,
|
||||
UINT16 num_uuid,
|
||||
tSDP_UUID *p_uuid_list,
|
||||
UINT16 num_attr,
|
||||
UINT16 *p_attr_list);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_CancelServiceSearch
|
||||
**
|
||||
** Description This function cancels an active query to an SDP server.
|
||||
**
|
||||
** Returns TRUE if discovery cancelled, FALSE if a matching activity is not found.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_CancelServiceSearch (tSDP_DISCOVERY_DB *p_db);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_ServiceSearchRequest
|
||||
**
|
||||
** Description This function queries an SDP server for information.
|
||||
**
|
||||
** Returns TRUE if discovery started, FALSE if failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_ServiceSearchRequest (UINT8 *p_bd_addr,
|
||||
tSDP_DISCOVERY_DB *p_db,
|
||||
tSDP_DISC_CMPL_CB *p_cb);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_ServiceSearchAttributeRequest
|
||||
**
|
||||
** Description This function queries an SDP server for information.
|
||||
**
|
||||
** The difference between this API function and the function
|
||||
** SDP_ServiceSearchRequest is that this one does a
|
||||
** combined ServiceSearchAttributeRequest SDP function.
|
||||
**
|
||||
** Returns TRUE if discovery started, FALSE if failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_ServiceSearchAttributeRequest (UINT8 *p_bd_addr,
|
||||
tSDP_DISCOVERY_DB *p_db,
|
||||
tSDP_DISC_CMPL_CB *p_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_ServiceSearchAttributeRequest2
|
||||
**
|
||||
** Description This function queries an SDP server for information.
|
||||
**
|
||||
** The difference between this API function and the function
|
||||
** SDP_ServiceSearchRequest is that this one does a
|
||||
** combined ServiceSearchAttributeRequest SDP function with the
|
||||
** user data piggyback
|
||||
**
|
||||
** Returns TRUE if discovery started, FALSE if failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_ServiceSearchAttributeRequest2 (UINT8 *p_bd_addr,
|
||||
tSDP_DISCOVERY_DB *p_db,
|
||||
tSDP_DISC_CMPL_CB2 *p_cb, void * user_data);
|
||||
|
||||
/* API of utilities to find data in the local discovery database */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindAttributeInDb
|
||||
**
|
||||
** Description This function queries an SDP database for a specific attribute.
|
||||
** If the p_start_rec pointer is NULL, it looks from the beginning
|
||||
** of the database, else it continues from the next record after
|
||||
** p_start_rec.
|
||||
**
|
||||
** Returns Pointer to matching record, or NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tSDP_DISC_REC *SDP_FindAttributeInDb (tSDP_DISCOVERY_DB *p_db,
|
||||
UINT16 attr_id,
|
||||
tSDP_DISC_REC *p_start_rec);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindAttributeInRec
|
||||
**
|
||||
** Description This function searches an SDP discovery record for a
|
||||
** specific attribute.
|
||||
**
|
||||
** Returns Pointer to matching attribute entry, or NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tSDP_DISC_ATTR *SDP_FindAttributeInRec (tSDP_DISC_REC *p_rec,
|
||||
UINT16 attr_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindServiceInDb
|
||||
**
|
||||
** Description This function queries an SDP database for a specific service.
|
||||
** If the p_start_rec pointer is NULL, it looks from the beginning
|
||||
** of the database, else it continues from the next record after
|
||||
** p_start_rec.
|
||||
**
|
||||
** Returns Pointer to record containing service class, or NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tSDP_DISC_REC *SDP_FindServiceInDb (tSDP_DISCOVERY_DB *p_db,
|
||||
UINT16 service_uuid,
|
||||
tSDP_DISC_REC *p_start_rec);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindServiceUUIDInDb
|
||||
**
|
||||
** Description This function queries an SDP database for a specific service.
|
||||
** If the p_start_rec pointer is NULL, it looks from the beginning
|
||||
** of the database, else it continues from the next record after
|
||||
** p_start_rec.
|
||||
**
|
||||
** NOTE the only difference between this function and the previous
|
||||
** function "SDP_FindServiceInDb()" is that this function takes
|
||||
** a tBT_UUID input.
|
||||
**
|
||||
** Returns Pointer to record containing service class, or NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tSDP_DISC_REC *SDP_FindServiceUUIDInDb (tSDP_DISCOVERY_DB *p_db,
|
||||
tBT_UUID *p_uuid,
|
||||
tSDP_DISC_REC *p_start_rec);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindServiceUUIDInRec_128bit
|
||||
**
|
||||
** Description This function is called to read the 128-bit service UUID within a record
|
||||
** if there is any.
|
||||
**
|
||||
** Parameters: p_rec - pointer to a SDP record.
|
||||
** p_uuid - output parameter to save the UUID found.
|
||||
**
|
||||
** Returns TRUE if found, otherwise FALSE.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindServiceInDb_128bit
|
||||
**
|
||||
** Description This function queries an SDP database for a specific service.
|
||||
** If the p_start_rec pointer is NULL, it looks from the beginning
|
||||
** of the database, else it continues from the next record after
|
||||
** p_start_rec.
|
||||
**
|
||||
** Returns Pointer to record containing service class, or NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tSDP_DISC_REC *SDP_FindServiceInDb_128bit(tSDP_DISCOVERY_DB *p_db,
|
||||
tSDP_DISC_REC *p_start_rec);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindProtocolListElemInRec
|
||||
**
|
||||
** Description This function looks at a specific discovery record for a
|
||||
** protocol list element.
|
||||
**
|
||||
** Returns TRUE if found, FALSE if not
|
||||
** If found, the passed protocol list element is filled in.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_FindProtocolListElemInRec (tSDP_DISC_REC *p_rec,
|
||||
UINT16 layer_uuid,
|
||||
tSDP_PROTOCOL_ELEM *p_elem);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindAddProtoListsElemInRec
|
||||
**
|
||||
** Description This function looks at a specific discovery record for a
|
||||
** protocol list element.
|
||||
**
|
||||
** Returns TRUE if found, FALSE if not
|
||||
** If found, the passed protocol list element is filled in.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_FindAddProtoListsElemInRec (tSDP_DISC_REC *p_rec,
|
||||
UINT16 layer_uuid,
|
||||
tSDP_PROTOCOL_ELEM *p_elem);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindProfileVersionInRec
|
||||
**
|
||||
** Description This function looks at a specific discovery record for the
|
||||
** Profile list descriptor, and pulls out the version number.
|
||||
** The version number consists of an 8-bit major version and
|
||||
** an 8-bit minor version.
|
||||
**
|
||||
** Returns TRUE if found, FALSE if not
|
||||
** If found, the major and minor version numbers that were passed
|
||||
** in are filled in.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_FindProfileVersionInRec (tSDP_DISC_REC *p_rec,
|
||||
UINT16 profile_uuid,
|
||||
UINT16 *p_version);
|
||||
|
||||
|
||||
/* API into SDP for local service database updates */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_CreateRecord
|
||||
**
|
||||
** Description This function is called to create a record in the database.
|
||||
** This would be through the SDP database maintenance API. The
|
||||
** record is created empty, teh application should then call
|
||||
** "add_attribute" to add the record's attributes.
|
||||
**
|
||||
** Returns Record handle if OK, else 0.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT32 SDP_CreateRecord (void);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_DeleteRecord
|
||||
**
|
||||
** Description This function is called to add a record (or all records)
|
||||
** from the database. This would be through the SDP database
|
||||
** maintenance API.
|
||||
**
|
||||
** If a record handle of 0 is passed, all records are deleted.
|
||||
**
|
||||
** Returns TRUE if succeeded, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_DeleteRecord (UINT32 handle);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_ReadRecord
|
||||
**
|
||||
** Description This function is called to get the raw data of the record
|
||||
** with the given handle from the database.
|
||||
**
|
||||
** Returns -1, if the record is not found.
|
||||
** Otherwise, the offset (0 or 1) to start of data in p_data.
|
||||
**
|
||||
** The size of data copied into p_data is in *p_data_len.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern INT32 SDP_ReadRecord(UINT32 handle, UINT8 *p_data, INT32 *p_data_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_AddAttribute
|
||||
**
|
||||
** Description This function is called to add an attribute to a record.
|
||||
** This would be through the SDP database maintenance API.
|
||||
** If the attribute already exists in the record, it is replaced
|
||||
** with the new value.
|
||||
**
|
||||
** NOTE Attribute values must be passed as a Big Endian stream.
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_AddAttribute (UINT32 handle, UINT16 attr_id,
|
||||
UINT8 attr_type, UINT32 attr_len,
|
||||
UINT8 *p_val);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_AddSequence
|
||||
**
|
||||
** Description This function is called to add a sequence to a record.
|
||||
** This would be through the SDP database maintenance API.
|
||||
** If the sequence already exists in the record, it is replaced
|
||||
** with the new sequence.
|
||||
**
|
||||
** NOTE Element values must be passed as a Big Endian stream.
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_AddSequence (UINT32 handle, UINT16 attr_id,
|
||||
UINT16 num_elem, UINT8 type[],
|
||||
UINT8 len[], UINT8 *p_val[]);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_AddUuidSequence
|
||||
**
|
||||
** Description This function is called to add a UUID sequence to a record.
|
||||
** This would be through the SDP database maintenance API.
|
||||
** If the sequence already exists in the record, it is replaced
|
||||
** with the new sequence.
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_AddUuidSequence (UINT32 handle, UINT16 attr_id,
|
||||
UINT16 num_uuids, UINT16 *p_uuids);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_AddProtocolList
|
||||
**
|
||||
** Description This function is called to add a protocol descriptor list to
|
||||
** a record. This would be through the SDP database maintenance API.
|
||||
** If the protocol list already exists in the record, it is replaced
|
||||
** with the new list.
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_AddProtocolList (UINT32 handle, UINT16 num_elem,
|
||||
tSDP_PROTOCOL_ELEM *p_elem_list);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_AddAdditionProtoLists
|
||||
**
|
||||
** Description This function is called to add a protocol descriptor list to
|
||||
** a record. This would be through the SDP database maintenance API.
|
||||
** If the protocol list already exists in the record, it is replaced
|
||||
** with the new list.
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_AddAdditionProtoLists (UINT32 handle, UINT16 num_elem,
|
||||
tSDP_PROTO_LIST_ELEM *p_proto_list);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_AddProfileDescriptorList
|
||||
**
|
||||
** Description This function is called to add a profile descriptor list to
|
||||
** a record. This would be through the SDP database maintenance API.
|
||||
** If the version already exists in the record, it is replaced
|
||||
** with the new one.
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_AddProfileDescriptorList (UINT32 handle,
|
||||
UINT16 profile_uuid,
|
||||
UINT16 version);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_AddLanguageBaseAttrIDList
|
||||
**
|
||||
** Description This function is called to add a language base attr list to
|
||||
** a record. This would be through the SDP database maintenance API.
|
||||
** If the version already exists in the record, it is replaced
|
||||
** with the new one.
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_AddLanguageBaseAttrIDList (UINT32 handle,
|
||||
UINT16 lang, UINT16 char_enc,
|
||||
UINT16 base_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_AddServiceClassIdList
|
||||
**
|
||||
** Description This function is called to add a service list to a record.
|
||||
** This would be through the SDP database maintenance API.
|
||||
** If the service list already exists in the record, it is replaced
|
||||
** with the new list.
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_AddServiceClassIdList (UINT32 handle,
|
||||
UINT16 num_services,
|
||||
UINT16 *p_service_uuids);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_DeleteAttribute
|
||||
**
|
||||
** Description This function is called to delete an attribute from a record.
|
||||
** This would be through the SDP database maintenance API.
|
||||
**
|
||||
** Returns TRUE if deleted OK, else FALSE if not found
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SDP_DeleteAttribute (UINT32 handle, UINT16 attr_id);
|
||||
|
||||
|
||||
/* Device Identification APIs */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_SetLocalDiRecord
|
||||
**
|
||||
** Description This function adds a DI record to the local SDP database.
|
||||
**
|
||||
** Returns Returns SDP_SUCCESS if record added successfully, else error
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 SDP_SetLocalDiRecord (tSDP_DI_RECORD *device_info,
|
||||
UINT32 *p_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_DiDiscover
|
||||
**
|
||||
** Description This function queries a remote device for DI information.
|
||||
**
|
||||
** Returns SDP_SUCCESS if query started successfully, else error
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 SDP_DiDiscover (BD_ADDR remote_device,
|
||||
tSDP_DISCOVERY_DB *p_db, UINT32 len,
|
||||
tSDP_DISC_CMPL_CB *p_cb);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_GetNumDiRecords
|
||||
**
|
||||
** Description Searches specified database for DI records
|
||||
**
|
||||
** Returns number of DI records found
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 SDP_GetNumDiRecords (tSDP_DISCOVERY_DB *p_db);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_GetDiRecord
|
||||
**
|
||||
** Description This function retrieves a remote device's DI record from
|
||||
** the specified database.
|
||||
**
|
||||
** Returns SDP_SUCCESS if record retrieved, else error
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 SDP_GetDiRecord (UINT8 getRecordIndex,
|
||||
tSDP_DI_GET_RECORD *device_info,
|
||||
tSDP_DISCOVERY_DB *p_db);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_SetTraceLevel
|
||||
**
|
||||
** Description This function sets the trace level for SDP. If called with
|
||||
** a value of 0xFF, it simply reads the current trace level.
|
||||
**
|
||||
** Returns the new (current) trace level
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 SDP_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_ConnOpen
|
||||
**
|
||||
** Description This function creates a connection to the SDP server on the
|
||||
** given device.
|
||||
**
|
||||
** Returns 0, if failed to initiate connection. Otherwise, the handle.
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT32 SDP_ConnOpen (UINT8 *p_bd_addr, tSDP_DISC_RES_CB *p_rcb,
|
||||
tSDP_DISC_CMPL_CB *p_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_WriteData
|
||||
**
|
||||
** Description This function sends data to the connected SDP server.
|
||||
**
|
||||
** Returns TRUE if data is sent, FALSE if failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN SDP_WriteData (UINT32 handle, BT_HDR *p_msg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_ConnClose
|
||||
**
|
||||
** Description This function is called to close a SDP connection.
|
||||
**
|
||||
** Parameters: handle - Handle of the connection returned by SDP_ConnOpen
|
||||
**
|
||||
** Returns TRUE if connection is closed, FALSE if failed to find the handle.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN SDP_ConnClose (UINT32 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SDP_FindServiceUUIDInRec
|
||||
**
|
||||
** Description This function is called to read the service UUID within a record
|
||||
** if there is any.
|
||||
**
|
||||
** Parameters: p_rec - pointer to a SDP record.
|
||||
**
|
||||
** Returns TRUE if found, otherwise FALSE.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID *p_uuid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDP_API_H */
|
||||
+327
@@ -0,0 +1,327 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains the definitions for the SDP API
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef SDP_DEFS_H
|
||||
#define SDP_DEFS_H
|
||||
|
||||
/* Define the service attribute IDs.
|
||||
*/
|
||||
#define ATTR_ID_SERVICE_RECORD_HDL 0x0000
|
||||
#define ATTR_ID_SERVICE_CLASS_ID_LIST 0x0001
|
||||
#define ATTR_ID_SERVICE_RECORD_STATE 0x0002
|
||||
#define ATTR_ID_SERVICE_ID 0x0003
|
||||
#define ATTR_ID_PROTOCOL_DESC_LIST 0x0004
|
||||
#define ATTR_ID_BROWSE_GROUP_LIST 0x0005
|
||||
#define ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST 0x0006
|
||||
#define ATTR_ID_SERVICE_INFO_TIME_TO_LIVE 0x0007
|
||||
#define ATTR_ID_SERVICE_AVAILABILITY 0x0008
|
||||
#define ATTR_ID_BT_PROFILE_DESC_LIST 0x0009
|
||||
#define ATTR_ID_DOCUMENTATION_URL 0x000A
|
||||
#define ATTR_ID_CLIENT_EXE_URL 0x000B
|
||||
#define ATTR_ID_ICON_URL 0x000C
|
||||
#define ATTR_ID_ADDITION_PROTO_DESC_LISTS 0x000D
|
||||
|
||||
#define LANGUAGE_BASE_ID 0x0100
|
||||
#define ATTR_ID_SERVICE_NAME LANGUAGE_BASE_ID + 0x0000
|
||||
#define ATTR_ID_SERVICE_DESCRIPTION LANGUAGE_BASE_ID + 0x0001
|
||||
#define ATTR_ID_PROVIDER_NAME LANGUAGE_BASE_ID + 0x0002
|
||||
|
||||
/* Device Identification (DI)
|
||||
*/
|
||||
#define ATTR_ID_SPECIFICATION_ID 0x0200
|
||||
#define ATTR_ID_VENDOR_ID 0x0201
|
||||
#define ATTR_ID_PRODUCT_ID 0x0202
|
||||
#define ATTR_ID_PRODUCT_VERSION 0x0203
|
||||
#define ATTR_ID_PRIMARY_RECORD 0x0204
|
||||
#define ATTR_ID_VENDOR_ID_SOURCE 0x0205
|
||||
|
||||
#define BLUETOOTH_DI_SPECIFICATION 0x0103 /* 1.3 */
|
||||
#define DI_VENDOR_ID_DEFAULT 0xFFFF
|
||||
#define DI_VENDOR_ID_SOURCE_BTSIG 0x0001
|
||||
#define DI_VENDOR_ID_SOURCE_USBIF 0x0002
|
||||
|
||||
|
||||
#define ATTR_ID_IP_SUBNET 0x0200 /* PAN Profile (***) */
|
||||
#define ATTR_ID_VERSION_NUMBER_LIST 0x0200
|
||||
#define ATTR_ID_GOEP_L2CAP_PSM 0x0200
|
||||
#define ATTR_ID_GROUP_ID 0x0200
|
||||
#define ATTR_ID_SERVICE_DATABASE_STATE 0x0201
|
||||
#define ATTR_ID_SERVICE_VERSION 0x0300
|
||||
#define ATTR_ID_HCRP_1284ID 0x0300
|
||||
|
||||
#define ATTR_ID_SUPPORTED_DATA_STORES 0x0301
|
||||
#define ATTR_ID_NETWORK 0x0301
|
||||
#define ATTR_ID_EXTERNAL_NETWORK 0x0301
|
||||
#define ATTR_ID_FAX_CLASS_1_SUPPORT 0x0302
|
||||
#define ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL 0x0302
|
||||
#define ATTR_ID_DEVICE_NAME 0x0302
|
||||
#define ATTR_ID_SUPPORTED_FORMATS_LIST 0x0303
|
||||
#define ATTR_ID_FAX_CLASS_2_0_SUPPORT 0x0303
|
||||
#define ATTR_ID_FAX_CLASS_2_SUPPORT 0x0304
|
||||
#define ATTR_ID_FRIENDLY_NAME 0x0304
|
||||
#define ATTR_ID_AUDIO_FEEDBACK_SUPPORT 0x0305
|
||||
#define ATTR_ID_NETWORK_ADDRESS 0x0306
|
||||
#define ATTR_ID_DEVICE_LOCATION 0x0306
|
||||
#define ATTR_ID_WAP_GATEWAY 0x0307
|
||||
#define ATTR_ID_HOME_PAGE_URL 0x0308
|
||||
#define ATTR_ID_WAP_STACK_TYPE 0x0309
|
||||
#define ATTR_ID_IMG_SUPPORTED_CAPABILITIES 0x0310 /* Imaging Profile */
|
||||
#define ATTR_ID_SUPPORTED_FEATURES 0x0311 /* HFP, BIP */
|
||||
#define ATTR_ID_IMG_SUPPORTED_FUNCTIONS 0x0312 /* Imaging Profile */
|
||||
#define ATTR_ID_IMG_TOT_DATA_CAPABILITY 0x0313 /* Imaging Profile */
|
||||
#define ATTR_ID_SUPPORTED_REPOSITORIES 0x0314 /* Phone book access Profile */
|
||||
#define ATTR_ID_MAS_INSTANCE_ID 0x0315 /* MAP profile */
|
||||
#define ATTR_ID_SUPPORTED_MSG_TYPE 0x0316 /* MAP profile */
|
||||
#define ATTR_ID_MAP_SUPPORTED_FEATURES 0x0317 /* MAP profile */
|
||||
#define ATTR_ID_PBAP_SUPPORTED_FEATURES 0x0317 /* PBAP profile */
|
||||
|
||||
|
||||
/* These values are for the BPP profile */
|
||||
#define ATTR_ID_DOCUMENT_FORMATS_SUPPORTED 0x0350
|
||||
#define ATTR_ID_CHARACTER_REPERTOIRES_SUPPORTED 0x0352
|
||||
#define ATTR_ID_XHTML_IMAGE_FORMATS_SUPPORTED 0x0354
|
||||
#define ATTR_ID_COLOR_SUPPORTED 0x0356
|
||||
#define ATTR_ID_1284ID 0x0358
|
||||
#define ATTR_ID_PRINTER_NAME 0x035A
|
||||
#define ATTR_ID_PRINTER_LOCATION 0x035C
|
||||
#define ATTR_ID_DUPLEX_SUPPORTED 0x035E
|
||||
#define ATTR_ID_MEDIA_TYPES_SUPPORTED 0x0360
|
||||
#define ATTR_ID_MAX_MEDIA_WIDTH 0x0362
|
||||
#define ATTR_ID_MAX_MEDIA_LENGTH 0x0364
|
||||
#define ATTR_ID_ENHANCED_LAYOUT_SUPPORTED 0x0366
|
||||
#define ATTR_ID_RUI_FORMATS_SUPPORTED 0x0368
|
||||
#define ATTR_ID_RUI_REF_PRINTING_SUPPORTED 0x0370 /* Boolean */
|
||||
#define ATTR_ID_RUI_DIRECT_PRINTING_SUPPORTED 0x0372 /* Boolean */
|
||||
#define ATTR_ID_REF_PRINTING_TOP_URL 0x0374
|
||||
#define ATTR_ID_DIRECT_PRINTING_TOP_URL 0x0376
|
||||
#define ATTR_ID_PRINTER_ADMIN_RUI_TOP_URL 0x0378
|
||||
#define ATTR_ID_BPP_DEVICE_NAME 0x037A
|
||||
|
||||
/* These values are for the PAN profile */
|
||||
#define ATTR_ID_SECURITY_DESCRIPTION 0x030A
|
||||
#define ATTR_ID_NET_ACCESS_TYPE 0x030B
|
||||
#define ATTR_ID_MAX_NET_ACCESS_RATE 0x030C
|
||||
#define ATTR_ID_IPV4_SUBNET 0x030D
|
||||
#define ATTR_ID_IPV6_SUBNET 0x030E
|
||||
#define ATTR_ID_PAN_SECURITY 0x0400
|
||||
|
||||
/* These values are for HID profile */
|
||||
#define ATTR_ID_HID_DEVICE_RELNUM 0x0200
|
||||
#define ATTR_ID_HID_PARSER_VERSION 0x0201
|
||||
#define ATTR_ID_HID_DEVICE_SUBCLASS 0x0202
|
||||
#define ATTR_ID_HID_COUNTRY_CODE 0x0203
|
||||
#define ATTR_ID_HID_VIRTUAL_CABLE 0x0204
|
||||
#define ATTR_ID_HID_RECONNECT_INITIATE 0x0205
|
||||
#define ATTR_ID_HID_DESCRIPTOR_LIST 0x0206
|
||||
#define ATTR_ID_HID_LANGUAGE_ID_BASE 0x0207
|
||||
#define ATTR_ID_HID_SDP_DISABLE 0x0208
|
||||
#define ATTR_ID_HID_BATTERY_POWER 0x0209
|
||||
#define ATTR_ID_HID_REMOTE_WAKE 0x020A
|
||||
#define ATTR_ID_HID_PROFILE_VERSION 0x020B
|
||||
#define ATTR_ID_HID_LINK_SUPERVISION_TO 0x020C
|
||||
#define ATTR_ID_HID_NORMALLY_CONNECTABLE 0x020D
|
||||
#define ATTR_ID_HID_BOOT_DEVICE 0x020E
|
||||
#define ATTR_ID_HID_SSR_HOST_MAX_LAT 0x020F
|
||||
#define ATTR_ID_HID_SSR_HOST_MIN_TOUT 0x0210
|
||||
|
||||
/* These values are for the HDP profile */
|
||||
#define ATTR_ID_HDP_SUP_FEAT_LIST 0x0200 /* Supported features list */
|
||||
#define ATTR_ID_HDP_DATA_EXCH_SPEC 0x0301 /* Data exchange specification */
|
||||
#define ATTR_ID_HDP_MCAP_SUP_PROC 0x0302 /* MCAP supported procedures */
|
||||
|
||||
/* Define common 16-bit protocol UUIDs
|
||||
*/
|
||||
#define UUID_PROTOCOL_SDP 0x0001
|
||||
#define UUID_PROTOCOL_UDP 0x0002
|
||||
#define UUID_PROTOCOL_RFCOMM 0x0003
|
||||
#define UUID_PROTOCOL_TCP 0x0004
|
||||
#define UUID_PROTOCOL_TCS_BIN 0x0005
|
||||
#define UUID_PROTOCOL_TCS_AT 0x0006
|
||||
#define UUID_PROTOCOL_OBEX 0x0008
|
||||
#define UUID_PROTOCOL_IP 0x0009
|
||||
#define UUID_PROTOCOL_FTP 0x000A
|
||||
#define UUID_PROTOCOL_HTTP 0x000C
|
||||
#define UUID_PROTOCOL_WSP 0x000E
|
||||
#define UUID_PROTOCOL_BNEP 0x000F
|
||||
#define UUID_PROTOCOL_UPNP 0x0010
|
||||
#define UUID_PROTOCOL_HIDP 0x0011
|
||||
#define UUID_PROTOCOL_HCRP_CTRL 0x0012
|
||||
#define UUID_PROTOCOL_HCRP_DATA 0x0014
|
||||
#define UUID_PROTOCOL_HCRP_NOTIF 0x0016
|
||||
#define UUID_PROTOCOL_AVCTP 0x0017
|
||||
#define UUID_PROTOCOL_AVDTP 0x0019
|
||||
#define UUID_PROTOCOL_CMTP 0x001B
|
||||
#define UUID_PROTOCOL_UDI 0x001D
|
||||
#define UUID_PROTOCOL_MCAP_CTRL 0x001E
|
||||
#define UUID_PROTOCOL_MCAP_DATA 0x001F
|
||||
#define UUID_PROTOCOL_L2CAP 0x0100
|
||||
#define UUID_PROTOCOL_ATT 0x0007
|
||||
|
||||
/* Define common 16-bit service class UUIDs
|
||||
*/
|
||||
#define UUID_SERVCLASS_SERVICE_DISCOVERY_SERVER 0X1000
|
||||
#define UUID_SERVCLASS_BROWSE_GROUP_DESCRIPTOR 0X1001
|
||||
#define UUID_SERVCLASS_PUBLIC_BROWSE_GROUP 0X1002
|
||||
#define UUID_SERVCLASS_SERIAL_PORT 0X1101
|
||||
#define UUID_SERVCLASS_LAN_ACCESS_USING_PPP 0X1102
|
||||
#define UUID_SERVCLASS_DIALUP_NETWORKING 0X1103
|
||||
#define UUID_SERVCLASS_IRMC_SYNC 0X1104
|
||||
#define UUID_SERVCLASS_OBEX_OBJECT_PUSH 0X1105
|
||||
#define UUID_SERVCLASS_OBEX_FILE_TRANSFER 0X1106
|
||||
#define UUID_SERVCLASS_IRMC_SYNC_COMMAND 0X1107
|
||||
#define UUID_SERVCLASS_HEADSET 0X1108
|
||||
#define UUID_SERVCLASS_CORDLESS_TELEPHONY 0X1109
|
||||
#define UUID_SERVCLASS_AUDIO_SOURCE 0X110A
|
||||
#define UUID_SERVCLASS_AUDIO_SINK 0X110B
|
||||
#define UUID_SERVCLASS_AV_REM_CTRL_TARGET 0X110C /* Audio/Video Control profile */
|
||||
#define UUID_SERVCLASS_ADV_AUDIO_DISTRIBUTION 0X110D /* Advanced Audio Distribution profile */
|
||||
#define UUID_SERVCLASS_AV_REMOTE_CONTROL 0X110E /* Audio/Video Control profile */
|
||||
#define UUID_SERVCLASS_AV_REM_CTRL_CONTROL 0X110F /* Audio/Video Control profile */
|
||||
#define UUID_SERVCLASS_INTERCOM 0X1110
|
||||
#define UUID_SERVCLASS_FAX 0X1111
|
||||
#define UUID_SERVCLASS_HEADSET_AUDIO_GATEWAY 0X1112
|
||||
#define UUID_SERVCLASS_WAP 0X1113
|
||||
#define UUID_SERVCLASS_WAP_CLIENT 0X1114
|
||||
#define UUID_SERVCLASS_PANU 0X1115 /* PAN profile */
|
||||
#define UUID_SERVCLASS_NAP 0X1116 /* PAN profile */
|
||||
#define UUID_SERVCLASS_GN 0X1117 /* PAN profile */
|
||||
#define UUID_SERVCLASS_DIRECT_PRINTING 0X1118 /* BPP profile */
|
||||
#define UUID_SERVCLASS_REFERENCE_PRINTING 0X1119 /* BPP profile */
|
||||
#define UUID_SERVCLASS_IMAGING 0X111A /* Imaging profile */
|
||||
#define UUID_SERVCLASS_IMAGING_RESPONDER 0X111B /* Imaging profile */
|
||||
#define UUID_SERVCLASS_IMAGING_AUTO_ARCHIVE 0X111C /* Imaging profile */
|
||||
#define UUID_SERVCLASS_IMAGING_REF_OBJECTS 0X111D /* Imaging profile */
|
||||
#define UUID_SERVCLASS_HF_HANDSFREE 0X111E /* Handsfree profile */
|
||||
#define UUID_SERVCLASS_AG_HANDSFREE 0X111F /* Handsfree profile */
|
||||
#define UUID_SERVCLASS_DIR_PRT_REF_OBJ_SERVICE 0X1120 /* BPP profile */
|
||||
#define UUID_SERVCLASS_REFLECTED_UI 0X1121 /* BPP profile */
|
||||
#define UUID_SERVCLASS_BASIC_PRINTING 0X1122 /* BPP profile */
|
||||
#define UUID_SERVCLASS_PRINTING_STATUS 0X1123 /* BPP profile */
|
||||
#define UUID_SERVCLASS_HUMAN_INTERFACE 0X1124 /* HID profile */
|
||||
#define UUID_SERVCLASS_CABLE_REPLACEMENT 0X1125 /* HCRP profile */
|
||||
#define UUID_SERVCLASS_HCRP_PRINT 0X1126 /* HCRP profile */
|
||||
#define UUID_SERVCLASS_HCRP_SCAN 0X1127 /* HCRP profile */
|
||||
#define UUID_SERVCLASS_COMMON_ISDN_ACCESS 0X1128 /* CAPI Message Transport Protocol*/
|
||||
#define UUID_SERVCLASS_VIDEO_CONFERENCING_GW 0X1129 /* Video Conferencing profile */
|
||||
#define UUID_SERVCLASS_UDI_MT 0X112A /* Unrestricted Digital Information profile */
|
||||
#define UUID_SERVCLASS_UDI_TA 0X112B /* Unrestricted Digital Information profile */
|
||||
#define UUID_SERVCLASS_VCP 0X112C /* Video Conferencing profile */
|
||||
#define UUID_SERVCLASS_SAP 0X112D /* SIM Access profile */
|
||||
#define UUID_SERVCLASS_PBAP_PCE 0X112E /* Phonebook Access - PCE */
|
||||
#define UUID_SERVCLASS_PBAP_PSE 0X112F /* Phonebook Access - PSE */
|
||||
#define UUID_SERVCLASS_PHONE_ACCESS 0x1130
|
||||
#define UUID_SERVCLASS_HEADSET_HS 0x1131 /* Headset - HS, from HSP v1.2 */
|
||||
#define UUID_SERVCLASS_PNP_INFORMATION 0X1200 /* Device Identification */
|
||||
#define UUID_SERVCLASS_GENERIC_NETWORKING 0X1201
|
||||
#define UUID_SERVCLASS_GENERIC_FILETRANSFER 0X1202
|
||||
#define UUID_SERVCLASS_GENERIC_AUDIO 0X1203
|
||||
#define UUID_SERVCLASS_GENERIC_TELEPHONY 0X1204
|
||||
#define UUID_SERVCLASS_UPNP_SERVICE 0X1205 /* UPNP_Service [ESDP] */
|
||||
#define UUID_SERVCLASS_UPNP_IP_SERVICE 0X1206 /* UPNP_IP_Service [ESDP] */
|
||||
#define UUID_SERVCLASS_ESDP_UPNP_IP_PAN 0X1300 /* UPNP_IP_PAN [ESDP] */
|
||||
#define UUID_SERVCLASS_ESDP_UPNP_IP_LAP 0X1301 /* UPNP_IP_LAP [ESDP] */
|
||||
#define UUID_SERVCLASS_ESDP_UPNP_IP_L2CAP 0X1302 /* UPNP_L2CAP [ESDP] */
|
||||
#define UUID_SERVCLASS_VIDEO_SOURCE 0X1303 /* Video Distribution Profile (VDP) */
|
||||
#define UUID_SERVCLASS_VIDEO_SINK 0X1304 /* Video Distribution Profile (VDP) */
|
||||
#define UUID_SERVCLASS_VIDEO_DISTRIBUTION 0X1305 /* Video Distribution Profile (VDP) */
|
||||
#define UUID_SERVCLASS_HDP_PROFILE 0X1400 /* Health Device profile (HDP) */
|
||||
#define UUID_SERVCLASS_HDP_SOURCE 0X1401 /* Health Device profile (HDP) */
|
||||
#define UUID_SERVCLASS_HDP_SINK 0X1402 /* Health Device profile (HDP) */
|
||||
#define UUID_SERVCLASS_MAP_PROFILE 0X1134 /* MAP profile UUID */
|
||||
#define UUID_SERVCLASS_MESSAGE_ACCESS 0X1132 /* Message Access Service UUID */
|
||||
#define UUID_SERVCLASS_MESSAGE_NOTIFICATION 0X1133 /* Message Notification Service UUID */
|
||||
|
||||
#define UUID_SERVCLASS_GAP_SERVER 0x1800
|
||||
#define UUID_SERVCLASS_GATT_SERVER 0x1801
|
||||
#define UUID_SERVCLASS_IMMEDIATE_ALERT 0x1802 /* immediate alert */
|
||||
#define UUID_SERVCLASS_LINKLOSS 0x1803 /* Link Loss Alert */
|
||||
#define UUID_SERVCLASS_TX_POWER 0x1804 /* TX power */
|
||||
#define UUID_SERVCLASS_CURRENT_TIME 0x1805 /* Link Loss Alert */
|
||||
#define UUID_SERVCLASS_DST_CHG 0x1806 /* DST Time change */
|
||||
#define UUID_SERVCLASS_REF_TIME_UPD 0x1807 /* reference time update */
|
||||
#define UUID_SERVCLASS_THERMOMETER 0x1809 /* Thermometer UUID */
|
||||
#define UUID_SERVCLASS_DEVICE_INFO 0x180A /* device info service */
|
||||
#define UUID_SERVCLASS_NWA 0x180B /* Network availability */
|
||||
#define UUID_SERVCLASS_HEART_RATE 0x180D /* Heart Rate service */
|
||||
#define UUID_SERVCLASS_PHALERT 0x180E /* phone alert service */
|
||||
#define UUID_SERVCLASS_BATTERY 0x180F /* battery service */
|
||||
#define UUID_SERVCLASS_BPM 0x1810 /* blood pressure service */
|
||||
#define UUID_SERVCLASS_ALERT_NOTIFICATION 0x1811 /* alert notification service */
|
||||
#define UUID_SERVCLASS_LE_HID 0x1812 /* HID over LE */
|
||||
#define UUID_SERVCLASS_SCAN_PARAM 0x1813 /* Scan Parameter service */
|
||||
#define UUID_SERVCLASS_GLUCOSE 0x1808 /* Glucose Meter Service */
|
||||
#define UUID_SERVCLASS_RSC 0x1814 /* RUNNERS SPEED AND CADENCE SERVICE */
|
||||
#define UUID_SERVCLASS_CSC 0x1816 /* Cycling SPEED AND CADENCE SERVICE */
|
||||
|
||||
#define UUID_SERVCLASS_TEST_SERVER 0x9000 /* Test Group UUID */
|
||||
|
||||
#if (BTM_WBS_INCLUDED == TRUE )
|
||||
#define UUID_CODEC_CVSD 0x0001 /* CVSD */
|
||||
#define UUID_CODEC_MSBC 0x0002 /* mSBC */
|
||||
#endif
|
||||
|
||||
/* Define all the 'Descriptor Type' values.
|
||||
*/
|
||||
#define NULL_DESC_TYPE 0
|
||||
#define UINT_DESC_TYPE 1
|
||||
#define TWO_COMP_INT_DESC_TYPE 2
|
||||
#define UUID_DESC_TYPE 3
|
||||
#define TEXT_STR_DESC_TYPE 4
|
||||
#define BOOLEAN_DESC_TYPE 5
|
||||
#define DATA_ELE_SEQ_DESC_TYPE 6
|
||||
#define DATA_ELE_ALT_DESC_TYPE 7
|
||||
#define URL_DESC_TYPE 8
|
||||
|
||||
/* Define all the "Descriptor Size" values.
|
||||
*/
|
||||
#define SIZE_ONE_BYTE 0
|
||||
#define SIZE_TWO_BYTES 1
|
||||
#define SIZE_FOUR_BYTES 2
|
||||
#define SIZE_EIGHT_BYTES 3
|
||||
#define SIZE_SIXTEEN_BYTES 4
|
||||
#define SIZE_IN_NEXT_BYTE 5
|
||||
#define SIZE_IN_NEXT_WORD 6
|
||||
#define SIZE_IN_NEXT_LONG 7
|
||||
|
||||
/* Language Encoding Constants */
|
||||
#define LANG_ID_CODE_ENGLISH ((UINT16) 0x656e) /* "en" */
|
||||
#define LANG_ID_CHAR_ENCODE_UTF8 ((UINT16) 0x006a) /* UTF-8 */
|
||||
|
||||
/* Constants used for display purposes only. These define ovelapping attribute values */
|
||||
#define ATTR_ID_VERS_OR_GRP_OR_DRELNUM_OR_IPSUB_OR_SPECID 0x0200
|
||||
#define ATTR_ID_VEND_ID_OR_SERVICE_DB_STATE_OR_PARSE_VER 0x0201
|
||||
#define ATTR_ID_PROD_ID_OR_HID_DEV_SUBCLASS 0x0202
|
||||
#define ATTR_ID_PROD_VER_OR_HID_COUNTRY_CODE 0x0203
|
||||
#define ATTR_ID_PRIMARY_REC_OR_HID_VIRTUAL_CABLE 0x0204
|
||||
#define ATTR_ID_DI_VENDOR_ID_SOURCE_OR_HID_INIT_RECONNECT 0x0205
|
||||
#define ATTR_ID_SERV_VERS_OR_1284ID 0x0300
|
||||
#define ATTR_ID_DATA_STORES_OR_NETWORK 0x0301
|
||||
#define ATTR_ID_FAX_1_OR_AUD_VOL_OR_DEV_NAME 0x0302
|
||||
#define ATTR_ID_FORMATS_OR_FAX_2_0 0x0303
|
||||
#define ATTR_ID_FAX_CLASS_2_OR_FRIENDLY_NAME 0x0304
|
||||
#define ATTR_ID_NETADDRESS_OR_DEVLOCATION 0x0306
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+325
@@ -0,0 +1,325 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains internally used SDP definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef SDP_INT_H
|
||||
#define SDP_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "sdp_api.h"
|
||||
#include "l2c_api.h"
|
||||
|
||||
|
||||
/* Continuation length - we use a 2-byte offset */
|
||||
#define SDP_CONTINUATION_LEN 2
|
||||
#define SDP_MAX_CONTINUATION_LEN 16 /* As per the spec */
|
||||
|
||||
/* Timeout definitions. */
|
||||
#define SDP_INACT_TIMEOUT 30 /* Inactivity timeout */
|
||||
|
||||
|
||||
/* Define the Out-Flow default values. */
|
||||
#define SDP_OFLOW_QOS_FLAG 0
|
||||
#define SDP_OFLOW_SERV_TYPE 0
|
||||
#define SDP_OFLOW_TOKEN_RATE 0
|
||||
#define SDP_OFLOW_TOKEN_BUCKET_SIZE 0
|
||||
#define SDP_OFLOW_PEAK_BANDWIDTH 0
|
||||
#define SDP_OFLOW_LATENCY 0
|
||||
#define SDP_OFLOW_DELAY_VARIATION 0
|
||||
|
||||
/* Define the In-Flow default values. */
|
||||
#define SDP_IFLOW_QOS_FLAG 0
|
||||
#define SDP_IFLOW_SERV_TYPE 0
|
||||
#define SDP_IFLOW_TOKEN_RATE 0
|
||||
#define SDP_IFLOW_TOKEN_BUCKET_SIZE 0
|
||||
#define SDP_IFLOW_PEAK_BANDWIDTH 0
|
||||
#define SDP_IFLOW_LATENCY 0
|
||||
#define SDP_IFLOW_DELAY_VARIATION 0
|
||||
|
||||
#define SDP_LINK_TO 0
|
||||
|
||||
/* Define the type of device notification. */
|
||||
/* (Inquiry Scan and Page Scan) */
|
||||
#define SDP_DEVICE_NOTI_LEN sizeof (BT_HDR) + \
|
||||
HCIC_PREAMBLE_SIZE + \
|
||||
HCIC_PARAM_SIZE_WRITE_PARAM1
|
||||
|
||||
#define SDP_DEVICE_NOTI_FLAG 0x03
|
||||
|
||||
/* Define the Protocol Data Unit (PDU) types.
|
||||
*/
|
||||
#define SDP_PDU_ERROR_RESPONSE 0x01
|
||||
#define SDP_PDU_SERVICE_SEARCH_REQ 0x02
|
||||
#define SDP_PDU_SERVICE_SEARCH_RSP 0x03
|
||||
#define SDP_PDU_SERVICE_ATTR_REQ 0x04
|
||||
#define SDP_PDU_SERVICE_ATTR_RSP 0x05
|
||||
#define SDP_PDU_SERVICE_SEARCH_ATTR_REQ 0x06
|
||||
#define SDP_PDU_SERVICE_SEARCH_ATTR_RSP 0x07
|
||||
|
||||
/* Max UUIDs and attributes we support per sequence */
|
||||
#define MAX_UUIDS_PER_SEQ 8
|
||||
#define MAX_ATTR_PER_SEQ 8
|
||||
|
||||
/* Max length we support for any attribute */
|
||||
// btla-specific ++
|
||||
#ifdef SDP_MAX_ATTR_LEN
|
||||
#define MAX_ATTR_LEN SDP_MAX_ATTR_LEN
|
||||
#else
|
||||
#define MAX_ATTR_LEN 256
|
||||
#endif
|
||||
// btla-specific --
|
||||
|
||||
/* Internal UUID sequence representation */
|
||||
typedef struct
|
||||
{
|
||||
UINT16 len;
|
||||
UINT8 value[MAX_UUID_SIZE];
|
||||
} tUID_ENT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 num_uids;
|
||||
tUID_ENT uuid_entry[MAX_UUIDS_PER_SEQ];
|
||||
} tSDP_UUID_SEQ;
|
||||
|
||||
|
||||
/* Internal attribute sequence definitions */
|
||||
typedef struct
|
||||
{
|
||||
UINT16 start;
|
||||
UINT16 end;
|
||||
} tATT_ENT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 num_attr;
|
||||
tATT_ENT attr_entry[MAX_ATTR_PER_SEQ];
|
||||
} tSDP_ATTR_SEQ;
|
||||
|
||||
|
||||
/* Define the attribute element of the SDP database record */
|
||||
typedef struct
|
||||
{
|
||||
UINT32 len; /* Number of bytes in the entry */
|
||||
UINT8 *value_ptr; /* Points to attr_pad */
|
||||
UINT16 id;
|
||||
UINT8 type;
|
||||
} tSDP_ATTRIBUTE;
|
||||
|
||||
/* An SDP record consists of a handle, and 1 or more attributes */
|
||||
typedef struct
|
||||
{
|
||||
UINT32 record_handle;
|
||||
UINT32 free_pad_ptr;
|
||||
UINT16 num_attributes;
|
||||
tSDP_ATTRIBUTE attribute[SDP_MAX_REC_ATTR];
|
||||
UINT8 attr_pad[SDP_MAX_PAD_LEN];
|
||||
} tSDP_RECORD;
|
||||
|
||||
|
||||
/* Define the SDP database */
|
||||
typedef struct
|
||||
{
|
||||
UINT32 di_primary_handle; /* Device ID Primary record or NULL if nonexistent */
|
||||
UINT16 num_records;
|
||||
tSDP_RECORD record[SDP_MAX_RECORDS];
|
||||
} tSDP_DB;
|
||||
|
||||
enum
|
||||
{
|
||||
SDP_IS_SEARCH,
|
||||
SDP_IS_ATTR_SEARCH,
|
||||
};
|
||||
|
||||
#if SDP_SERVER_ENABLED == TRUE
|
||||
/* Continuation information for the SDP server response */
|
||||
typedef struct
|
||||
{
|
||||
UINT16 next_attr_index; /* attr index for next continuation response */
|
||||
UINT16 next_attr_start_id; /* attr id to start with for the attr index in next cont. response */
|
||||
tSDP_RECORD *prev_sdp_rec; /* last sdp record that was completely sent in the response */
|
||||
BOOLEAN last_attr_seq_desc_sent; /* whether attr seq length has been sent previously */
|
||||
UINT16 attr_offset; /* offset within the attr to keep trak of partial attributes in the responses */
|
||||
} tSDP_CONT_INFO;
|
||||
#endif /* SDP_SERVER_ENABLED == TRUE */
|
||||
|
||||
/* Define the SDP Connection Control Block */
|
||||
typedef struct
|
||||
{
|
||||
#define SDP_STATE_IDLE 0
|
||||
#define SDP_STATE_CONN_SETUP 1
|
||||
#define SDP_STATE_CFG_SETUP 2
|
||||
#define SDP_STATE_CONNECTED 3
|
||||
UINT8 con_state;
|
||||
|
||||
#define SDP_FLAGS_IS_ORIG 0x01
|
||||
#define SDP_FLAGS_HIS_CFG_DONE 0x02
|
||||
#define SDP_FLAGS_MY_CFG_DONE 0x04
|
||||
UINT8 con_flags;
|
||||
|
||||
BD_ADDR device_address;
|
||||
TIMER_LIST_ENT timer_entry;
|
||||
UINT16 rem_mtu_size;
|
||||
UINT16 connection_id;
|
||||
UINT16 list_len; /* length of the response in the GKI buffer */
|
||||
UINT8 *rsp_list; /* pointer to GKI buffer holding response */
|
||||
|
||||
#if SDP_CLIENT_ENABLED == TRUE
|
||||
tSDP_DISCOVERY_DB *p_db; /* Database to save info into */
|
||||
tSDP_DISC_CMPL_CB *p_cb; /* Callback for discovery done */
|
||||
tSDP_DISC_CMPL_CB2 *p_cb2; /* Callback for discovery done piggy back with the user data */
|
||||
void *user_data; /* piggy back user data */
|
||||
UINT32 handles[SDP_MAX_DISC_SERVER_RECS]; /* Discovered server record handles */
|
||||
UINT16 num_handles; /* Number of server handles */
|
||||
UINT16 cur_handle; /* Current handle being processed */
|
||||
UINT16 transaction_id;
|
||||
UINT16 disconnect_reason; /* Disconnect reason */
|
||||
#if (defined(SDP_BROWSE_PLUS) && SDP_BROWSE_PLUS == TRUE)
|
||||
UINT16 cur_uuid_idx;
|
||||
#endif
|
||||
|
||||
#define SDP_DISC_WAIT_CONN 0
|
||||
#define SDP_DISC_WAIT_HANDLES 1
|
||||
#define SDP_DISC_WAIT_ATTR 2
|
||||
#define SDP_DISC_WAIT_SEARCH_ATTR 3
|
||||
#define SDP_DISC_WAIT_CANCEL 5
|
||||
|
||||
UINT8 disc_state;
|
||||
UINT8 is_attr_search;
|
||||
#endif /* SDP_CLIENT_ENABLED == TRUE */
|
||||
|
||||
#if SDP_SERVER_ENABLED == TRUE
|
||||
UINT16 cont_offset; /* Continuation state data in the server response */
|
||||
tSDP_CONT_INFO cont_info; /* structure to hold continuation information for the server response */
|
||||
#endif /* SDP_SERVER_ENABLED == TRUE */
|
||||
|
||||
} tCONN_CB;
|
||||
|
||||
|
||||
/* The main SDP control block */
|
||||
typedef struct
|
||||
{
|
||||
tL2CAP_CFG_INFO l2cap_my_cfg; /* My L2CAP config */
|
||||
tCONN_CB ccb[SDP_MAX_CONNECTIONS];
|
||||
#if SDP_SERVER_ENABLED == TRUE
|
||||
tSDP_DB server_db;
|
||||
#endif
|
||||
tL2CAP_APPL_INFO reg_info; /* L2CAP Registration info */
|
||||
UINT16 max_attr_list_size; /* Max attribute list size to use */
|
||||
UINT16 max_recs_per_search; /* Max records we want per seaarch */
|
||||
UINT8 trace_level;
|
||||
} tSDP_CB;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Global SDP data */
|
||||
#if SDP_DYNAMIC_MEMORY == FALSE
|
||||
extern tSDP_CB sdp_cb;
|
||||
#else
|
||||
extern tSDP_CB *sdp_cb_ptr;
|
||||
#define sdp_cb (*sdp_cb_ptr)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Functions provided by sdp_main.c */
|
||||
extern void sdp_init (void);
|
||||
extern void sdp_disconnect (tCONN_CB*p_ccb, UINT16 reason);
|
||||
|
||||
#if (defined(SDP_DEBUG) && SDP_DEBUG == TRUE)
|
||||
extern UINT16 sdp_set_max_attr_list_size (UINT16 max_size);
|
||||
#endif
|
||||
|
||||
/* Functions provided by sdp_conn.c
|
||||
*/
|
||||
extern void sdp_conn_rcv_l2e_conn_ind (BT_HDR *p_msg);
|
||||
extern void sdp_conn_rcv_l2e_conn_cfm (BT_HDR *p_msg);
|
||||
extern void sdp_conn_rcv_l2e_disc (BT_HDR *p_msg);
|
||||
extern void sdp_conn_rcv_l2e_config_ind (BT_HDR *p_msg);
|
||||
extern void sdp_conn_rcv_l2e_config_cfm (BT_HDR *p_msg);
|
||||
extern void sdp_conn_rcv_l2e_conn_failed (BT_HDR *p_msg);
|
||||
extern void sdp_conn_rcv_l2e_connected (BT_HDR *p_msg);
|
||||
extern void sdp_conn_rcv_l2e_conn_failed (BT_HDR *p_msg);
|
||||
extern void sdp_conn_rcv_l2e_data (BT_HDR *p_msg);
|
||||
extern void sdp_conn_timeout (tCONN_CB *p_ccb);
|
||||
|
||||
extern tCONN_CB *sdp_conn_originate (UINT8 *p_bd_addr);
|
||||
|
||||
/* Functions provided by sdp_utils.c
|
||||
*/
|
||||
extern tCONN_CB *sdpu_find_ccb_by_cid (UINT16 cid);
|
||||
extern tCONN_CB *sdpu_find_ccb_by_db (tSDP_DISCOVERY_DB *p_db);
|
||||
extern tCONN_CB *sdpu_allocate_ccb (void);
|
||||
extern void sdpu_release_ccb (tCONN_CB *p_ccb);
|
||||
|
||||
extern UINT8 *sdpu_build_attrib_seq (UINT8 *p_out, UINT16 *p_attr, UINT16 num_attrs);
|
||||
extern UINT8 *sdpu_build_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr);
|
||||
extern void sdpu_build_n_send_error (tCONN_CB *p_ccb, UINT16 trans_num, UINT16 error_code, char *p_error_text);
|
||||
|
||||
extern UINT8 *sdpu_extract_attr_seq (UINT8 *p, UINT16 param_len, tSDP_ATTR_SEQ *p_seq);
|
||||
extern UINT8 *sdpu_extract_uid_seq (UINT8 *p, UINT16 param_len, tSDP_UUID_SEQ *p_seq);
|
||||
|
||||
extern UINT8 *sdpu_get_len_from_type (UINT8 *p, UINT8 type, UINT32 *p_len);
|
||||
extern BOOLEAN sdpu_is_base_uuid (UINT8 *p_uuid);
|
||||
extern BOOLEAN sdpu_compare_uuid_arrays (UINT8 *p_uuid1, UINT32 len1, UINT8 *p_uuid2, UINT16 len2);
|
||||
extern BOOLEAN sdpu_compare_bt_uuids (tBT_UUID *p_uuid1, tBT_UUID *p_uuid2);
|
||||
extern BOOLEAN sdpu_compare_uuid_with_attr (tBT_UUID *p_btuuid, tSDP_DISC_ATTR *p_attr);
|
||||
|
||||
extern void sdpu_sort_attr_list( UINT16 num_attr, tSDP_DISCOVERY_DB *p_db );
|
||||
extern UINT16 sdpu_get_list_len( tSDP_UUID_SEQ *uid_seq, tSDP_ATTR_SEQ *attr_seq );
|
||||
extern UINT16 sdpu_get_attrib_seq_len(tSDP_RECORD *p_rec, tSDP_ATTR_SEQ *attr_seq);
|
||||
extern UINT16 sdpu_get_attrib_entry_len(tSDP_ATTRIBUTE *p_attr);
|
||||
extern UINT8 *sdpu_build_partial_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr, UINT16 len, UINT16 *offset);
|
||||
extern void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8* p_uuid128);
|
||||
|
||||
/* Functions provided by sdp_db.c
|
||||
*/
|
||||
extern tSDP_RECORD *sdp_db_service_search (tSDP_RECORD *p_rec, tSDP_UUID_SEQ *p_seq);
|
||||
extern tSDP_RECORD *sdp_db_find_record (UINT32 handle);
|
||||
extern tSDP_ATTRIBUTE *sdp_db_find_attr_in_rec (tSDP_RECORD *p_rec, UINT16 start_attr, UINT16 end_attr);
|
||||
|
||||
|
||||
/* Functions provided by sdp_server.c
|
||||
*/
|
||||
#if SDP_SERVER_ENABLED == TRUE
|
||||
extern void sdp_server_handle_client_req (tCONN_CB *p_ccb, BT_HDR *p_msg);
|
||||
#else
|
||||
#define sdp_server_handle_client_req(p_ccb, p_msg)
|
||||
#endif
|
||||
|
||||
/* Functions provided by sdp_discovery.c
|
||||
*/
|
||||
#if SDP_CLIENT_ENABLED == TRUE
|
||||
extern void sdp_disc_connected (tCONN_CB *p_ccb);
|
||||
extern void sdp_disc_server_rsp (tCONN_CB *p_ccb, BT_HDR *p_msg);
|
||||
#else
|
||||
#define sdp_disc_connected(p_ccb)
|
||||
#define sdp_disc_server_rsp(p_ccb, p_msg)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+494
@@ -0,0 +1,494 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains the SMP API function external definitions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef SMP_API_H
|
||||
#define SMP_API_H
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#define SMP_PIN_CODE_LEN_MAX PIN_CODE_LEN
|
||||
#define SMP_PIN_CODE_LEN_MIN 6
|
||||
|
||||
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
|
||||
/* SMP command code */
|
||||
#define SMP_OPCODE_PAIRING_REQ 0x01
|
||||
#define SMP_OPCODE_PAIRING_RSP 0x02
|
||||
#define SMP_OPCODE_CONFIRM 0x03
|
||||
#define SMP_OPCODE_RAND 0x04
|
||||
#define SMP_OPCODE_PAIRING_FAILED 0x05
|
||||
#define SMP_OPCODE_ENCRYPT_INFO 0x06
|
||||
#define SMP_OPCODE_MASTER_ID 0x07
|
||||
#define SMP_OPCODE_IDENTITY_INFO 0x08
|
||||
#define SMP_OPCODE_ID_ADDR 0x09
|
||||
#define SMP_OPCODE_SIGN_INFO 0x0A
|
||||
#define SMP_OPCODE_SEC_REQ 0x0B
|
||||
#define SMP_OPCODE_PAIR_PUBLIC_KEY 0x0C
|
||||
#define SMP_OPCODE_PAIR_DHKEY_CHECK 0x0D
|
||||
#define SMP_OPCODE_PAIR_KEYPR_NOTIF 0x0E
|
||||
#define SMP_OPCODE_MAX SMP_OPCODE_PAIR_KEYPR_NOTIF
|
||||
#define SMP_OPCODE_MIN SMP_OPCODE_PAIRING_REQ
|
||||
#define SMP_OPCODE_PAIR_COMMITM 0x0F
|
||||
#endif
|
||||
|
||||
/* SMP event type */
|
||||
#define SMP_IO_CAP_REQ_EVT 1 /* IO capability request event */
|
||||
#define SMP_SEC_REQUEST_EVT 2 /* SMP pairing request */
|
||||
#define SMP_PASSKEY_NOTIF_EVT 3 /* passkey notification event */
|
||||
#define SMP_PASSKEY_REQ_EVT 4 /* passkey request event */
|
||||
#define SMP_OOB_REQ_EVT 5 /* OOB request event */
|
||||
#define SMP_NC_REQ_EVT 6 /* Numeric Comparison request event */
|
||||
#define SMP_COMPLT_EVT 7 /* SMP complete event */
|
||||
#define SMP_PEER_KEYPR_NOT_EVT 8 /* Peer keypress notification received event */
|
||||
#define SMP_SC_OOB_REQ_EVT 9 /* SC OOB request event (both local and peer OOB data */
|
||||
/* can be expected in response) */
|
||||
#define SMP_SC_LOC_OOB_DATA_UP_EVT 10 /* SC OOB local data set is created */
|
||||
/* (as result of SMP_CrLocScOobData(...)) */
|
||||
#define SMP_BR_KEYS_REQ_EVT 12 /* SMP over BR keys request event */
|
||||
typedef UINT8 tSMP_EVT;
|
||||
|
||||
|
||||
/* pairing failure reason code */
|
||||
#define SMP_PASSKEY_ENTRY_FAIL 0x01
|
||||
#define SMP_OOB_FAIL 0x02
|
||||
#define SMP_PAIR_AUTH_FAIL 0x03
|
||||
#define SMP_CONFIRM_VALUE_ERR 0x04
|
||||
#define SMP_PAIR_NOT_SUPPORT 0x05
|
||||
#define SMP_ENC_KEY_SIZE 0x06
|
||||
#define SMP_INVALID_CMD 0x07
|
||||
#define SMP_PAIR_FAIL_UNKNOWN 0x08
|
||||
#define SMP_REPEATED_ATTEMPTS 0x09
|
||||
#define SMP_INVALID_PARAMETERS 0x0A
|
||||
#define SMP_DHKEY_CHK_FAIL 0x0B
|
||||
#define SMP_NUMERIC_COMPAR_FAIL 0x0C
|
||||
#define SMP_BR_PARING_IN_PROGR 0x0D
|
||||
#define SMP_XTRANS_DERIVE_NOT_ALLOW 0x0E
|
||||
#define SMP_MAX_FAIL_RSN_PER_SPEC SMP_XTRANS_DERIVE_NOT_ALLOW
|
||||
|
||||
/* self defined error code */
|
||||
#define SMP_PAIR_INTERNAL_ERR (SMP_MAX_FAIL_RSN_PER_SPEC + 0x01) /* 0x0E */
|
||||
|
||||
/* 0x0F unknown IO capability, unable to decide association model */
|
||||
#define SMP_UNKNOWN_IO_CAP (SMP_MAX_FAIL_RSN_PER_SPEC + 0x02) /* 0x0F */
|
||||
|
||||
#define SMP_INIT_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x03) /* 0x10 */
|
||||
#define SMP_CONFIRM_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x04) /* 0x11 */
|
||||
#define SMP_BUSY (SMP_MAX_FAIL_RSN_PER_SPEC + 0x05) /* 0x12 */
|
||||
#define SMP_ENC_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x06) /* 0x13 */
|
||||
#define SMP_STARTED (SMP_MAX_FAIL_RSN_PER_SPEC + 0x07) /* 0x14 */
|
||||
#define SMP_RSP_TIMEOUT (SMP_MAX_FAIL_RSN_PER_SPEC + 0x08) /* 0x15 */
|
||||
#define SMP_DIV_NOT_AVAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x09) /* 0x16 */
|
||||
|
||||
/* 0x17 unspecified failed reason */
|
||||
#define SMP_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x0A) /* 0x17 */
|
||||
|
||||
#define SMP_CONN_TOUT (SMP_MAX_FAIL_RSN_PER_SPEC + 0x0B)
|
||||
#define SMP_SUCCESS 0
|
||||
|
||||
typedef UINT8 tSMP_STATUS;
|
||||
|
||||
|
||||
/* Device IO capability */
|
||||
#define SMP_IO_CAP_OUT BTM_IO_CAP_OUT /* DisplayOnly */
|
||||
#define SMP_IO_CAP_IO BTM_IO_CAP_IO /* DisplayYesNo */
|
||||
#define SMP_IO_CAP_IN BTM_IO_CAP_IN /* KeyboardOnly */
|
||||
#define SMP_IO_CAP_NONE BTM_IO_CAP_NONE /* NoInputNoOutput */
|
||||
#define SMP_IO_CAP_KBDISP BTM_IO_CAP_KBDISP /* Keyboard Display */
|
||||
#define SMP_IO_CAP_MAX BTM_IO_CAP_MAX
|
||||
typedef UINT8 tSMP_IO_CAP;
|
||||
|
||||
#ifndef SMP_DEFAULT_IO_CAPS
|
||||
#define SMP_DEFAULT_IO_CAPS SMP_IO_CAP_KBDISP
|
||||
#endif
|
||||
|
||||
/* OOB data present or not */
|
||||
enum
|
||||
{
|
||||
SMP_OOB_NONE,
|
||||
SMP_OOB_PRESENT,
|
||||
SMP_OOB_UNKNOWN
|
||||
};
|
||||
typedef UINT8 tSMP_OOB_FLAG;
|
||||
|
||||
/* type of OOB data required from application */
|
||||
enum
|
||||
{
|
||||
SMP_OOB_INVALID_TYPE,
|
||||
SMP_OOB_PEER,
|
||||
SMP_OOB_LOCAL,
|
||||
SMP_OOB_BOTH
|
||||
};
|
||||
typedef UINT8 tSMP_OOB_DATA_TYPE;
|
||||
|
||||
#define SMP_AUTH_NO_BOND 0x00
|
||||
#define SMP_AUTH_GEN_BOND 0x01 //todo sdh change GEN_BOND to BOND
|
||||
|
||||
/* SMP Authentication requirement */
|
||||
#define SMP_AUTH_YN_BIT (1 << 2)
|
||||
#define SMP_SC_SUPPORT_BIT (1 << 3)
|
||||
#define SMP_KP_SUPPORT_BIT (1 << 4)
|
||||
|
||||
#define SMP_AUTH_MASK (SMP_AUTH_GEN_BOND|SMP_AUTH_YN_BIT|SMP_SC_SUPPORT_BIT|SMP_KP_SUPPORT_BIT)
|
||||
|
||||
#define SMP_AUTH_BOND SMP_AUTH_GEN_BOND
|
||||
|
||||
/* no MITM, No Bonding, encryption only */
|
||||
#define SMP_AUTH_NB_ENC_ONLY 0x00 //(SMP_AUTH_MASK | BTM_AUTH_SP_NO)
|
||||
|
||||
/* MITM, No Bonding, Use IO Capability to determine authentication procedure */
|
||||
#define SMP_AUTH_NB_IOCAP (SMP_AUTH_NO_BOND | SMP_AUTH_YN_BIT)
|
||||
|
||||
/* No MITM, General Bonding, Encryption only */
|
||||
#define SMP_AUTH_GB_ENC_ONLY (SMP_AUTH_GEN_BOND )
|
||||
|
||||
/* MITM, General Bonding, Use IO Capability to determine authentication procedure */
|
||||
#define SMP_AUTH_GB_IOCAP (SMP_AUTH_GEN_BOND | SMP_AUTH_YN_BIT)
|
||||
|
||||
/* Secure Connections, no MITM, no Bonding */
|
||||
#define SMP_AUTH_SC_ENC_ONLY (SMP_SC_SUPPORT_BIT)
|
||||
|
||||
/* Secure Connections, no MITM, Bonding */
|
||||
#define SMP_AUTH_SC_GB (SMP_SC_SUPPORT_BIT | SMP_AUTH_GEN_BOND)
|
||||
|
||||
/* Secure Connections, MITM, no Bonding */
|
||||
#define SMP_AUTH_SC_MITM_NB (SMP_SC_SUPPORT_BIT | SMP_AUTH_YN_BIT | SMP_AUTH_NO_BOND)
|
||||
|
||||
/* Secure Connections, MITM, Bonding */
|
||||
#define SMP_AUTH_SC_MITM_GB (SMP_SC_SUPPORT_BIT | SMP_AUTH_YN_BIT | SMP_AUTH_GEN_BOND)
|
||||
|
||||
/* All AuthReq RFU bits are set to 1 - NOTE: reserved bit in Bonding_Flags is not set */
|
||||
#define SMP_AUTH_ALL_RFU_SET 0xF8
|
||||
|
||||
typedef UINT8 tSMP_AUTH_REQ;
|
||||
|
||||
#define SMP_SEC_NONE 0
|
||||
#define SMP_SEC_UNAUTHENTICATE (1 << 0)
|
||||
#define SMP_SEC_AUTHENTICATED (1 << 2)
|
||||
typedef UINT8 tSMP_SEC_LEVEL;
|
||||
|
||||
/* Maximum Encryption Key Size range */
|
||||
#define SMP_ENCR_KEY_SIZE_MIN 7
|
||||
#define SMP_ENCR_KEY_SIZE_MAX 16
|
||||
|
||||
/* SMP key types */
|
||||
#define SMP_SEC_KEY_TYPE_ENC (1 << 0) /* encryption key */
|
||||
#define SMP_SEC_KEY_TYPE_ID (1 << 1) /* identity key */
|
||||
#define SMP_SEC_KEY_TYPE_CSRK (1 << 2) /* slave CSRK */
|
||||
#define SMP_SEC_KEY_TYPE_LK (1 << 3) /* BR/EDR link key */
|
||||
typedef UINT8 tSMP_KEYS;
|
||||
|
||||
#define SMP_BR_SEC_DEFAULT_KEY (SMP_SEC_KEY_TYPE_ENC | SMP_SEC_KEY_TYPE_ID | \
|
||||
SMP_SEC_KEY_TYPE_CSRK)
|
||||
|
||||
/* default security key distribution value */
|
||||
#define SMP_SEC_DEFAULT_KEY (SMP_SEC_KEY_TYPE_ENC | SMP_SEC_KEY_TYPE_ID | \
|
||||
SMP_SEC_KEY_TYPE_CSRK | SMP_SEC_KEY_TYPE_LK)
|
||||
|
||||
#define SMP_SC_KEY_STARTED 0 /* passkey entry started */
|
||||
#define SMP_SC_KEY_ENTERED 1 /* passkey digit entered */
|
||||
#define SMP_SC_KEY_ERASED 2 /* passkey digit erased */
|
||||
#define SMP_SC_KEY_CLEARED 3 /* passkey cleared */
|
||||
#define SMP_SC_KEY_COMPLT 4 /* passkey entry completed */
|
||||
#define SMP_SC_KEY_OUT_OF_RANGE 5 /* out of range */
|
||||
typedef UINT8 tSMP_SC_KEY_TYPE;
|
||||
|
||||
/* data type for BTM_SP_IO_REQ_EVT */
|
||||
typedef struct
|
||||
{
|
||||
tSMP_IO_CAP io_cap; /* local IO capabilities */
|
||||
tSMP_OOB_FLAG oob_data; /* OOB data present (locally) for the peer device */
|
||||
tSMP_AUTH_REQ auth_req; /* Authentication required (for local device) */
|
||||
UINT8 max_key_size; /* max encryption key size */
|
||||
tSMP_KEYS init_keys; /* initiator keys to be distributed */
|
||||
tSMP_KEYS resp_keys; /* responder keys */
|
||||
} tSMP_IO_REQ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tSMP_STATUS reason;
|
||||
tSMP_SEC_LEVEL sec_level;
|
||||
BOOLEAN is_pair_cancel;
|
||||
BOOLEAN smp_over_br;
|
||||
} tSMP_CMPL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BT_OCTET32 x;
|
||||
BT_OCTET32 y;
|
||||
} tSMP_PUBLIC_KEY;
|
||||
|
||||
/* the data associated with the info sent to the peer via OOB interface */
|
||||
typedef struct
|
||||
{
|
||||
BOOLEAN present;
|
||||
BT_OCTET16 randomizer;
|
||||
BT_OCTET16 commitment;
|
||||
|
||||
tBLE_BD_ADDR addr_sent_to;
|
||||
BT_OCTET32 private_key_used; /* is used to calculate: */
|
||||
/* publ_key_used = P-256(private_key_used, curve_p256.G) - send it to the */
|
||||
/* other side */
|
||||
/* dhkey = P-256(private_key_used, publ key rcvd from the other side) */
|
||||
tSMP_PUBLIC_KEY publ_key_used; /* P-256(private_key_used, curve_p256.G) */
|
||||
} tSMP_LOC_OOB_DATA;
|
||||
|
||||
/* the data associated with the info received from the peer via OOB interface */
|
||||
typedef struct
|
||||
{
|
||||
BOOLEAN present;
|
||||
BT_OCTET16 randomizer;
|
||||
BT_OCTET16 commitment;
|
||||
tBLE_BD_ADDR addr_rcvd_from;
|
||||
} tSMP_PEER_OOB_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tSMP_LOC_OOB_DATA loc_oob_data;
|
||||
tSMP_PEER_OOB_DATA peer_oob_data;
|
||||
} tSMP_SC_OOB_DATA;
|
||||
|
||||
|
||||
typedef union
|
||||
{
|
||||
UINT32 passkey;
|
||||
tSMP_IO_REQ io_req; /* IO request */
|
||||
tSMP_CMPL cmplt;
|
||||
tSMP_OOB_DATA_TYPE req_oob_type;
|
||||
tSMP_LOC_OOB_DATA loc_oob_data;
|
||||
}tSMP_EVT_DATA;
|
||||
|
||||
|
||||
/* AES Encryption output */
|
||||
typedef struct
|
||||
{
|
||||
UINT8 status;
|
||||
UINT8 param_len;
|
||||
UINT16 opcode;
|
||||
UINT8 param_buf[BT_OCTET16_LEN];
|
||||
} tSMP_ENC;
|
||||
|
||||
/* Security Manager events - Called by the stack when Security Manager related events occur.*/
|
||||
typedef UINT8 (tSMP_CALLBACK) (tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data);
|
||||
|
||||
/* callback function for CMAC algorithm
|
||||
*/
|
||||
typedef void (tCMAC_CMPL_CBACK)(UINT8 *p_mac, UINT16 tlen, UINT32 sign_counter);
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/* API of SMP */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_Init
|
||||
**
|
||||
** Description This function initializes the SMP unit.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void SMP_Init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_SetTraceLevel
|
||||
**
|
||||
** Description This function sets the trace level for SMP. If called with
|
||||
** a value of 0xFF, it simply returns the current trace level.
|
||||
**
|
||||
** Returns The new or current trace level
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 SMP_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_Register
|
||||
**
|
||||
** Description This function register for the SMP service callback.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SMP_Register (tSMP_CALLBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_Pair
|
||||
**
|
||||
** Description This function is called to start a SMP pairing.
|
||||
**
|
||||
** Returns SMP_STARTED if bond started, else otherwise exception.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tSMP_STATUS SMP_Pair (BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_BR_PairWith
|
||||
**
|
||||
** Description This function is called to start a SMP pairing over BR/EDR.
|
||||
**
|
||||
** Returns SMP_STARTED if pairing started, otherwise reason for failure.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tSMP_STATUS SMP_BR_PairWith (BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_PairCancel
|
||||
**
|
||||
** Description This function is called to cancel a SMP pairing.
|
||||
**
|
||||
** Returns TRUE - pairing cancelled
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SMP_PairCancel (BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_SecurityGrant
|
||||
**
|
||||
** Description This function is called to grant security process.
|
||||
**
|
||||
** Parameters bd_addr - peer device bd address.
|
||||
** res - result of the operation SMP_SUCCESS if success.
|
||||
** Otherwise, SMP_REPEATED_ATTEMPTS is too many attempts.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void SMP_SecurityGrant(BD_ADDR bd_addr, UINT8 res);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_PasskeyReply
|
||||
**
|
||||
** Description This function is called after Security Manager submitted
|
||||
** Passkey request to the application.
|
||||
**
|
||||
** Parameters: bd_addr - Address of the device for which PIN was requested
|
||||
** res - result of the operation SMP_SUCCESS if success
|
||||
** passkey - numeric value in the range of
|
||||
** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void SMP_PasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_ConfirmReply
|
||||
**
|
||||
** Description This function is called after Security Manager submitted
|
||||
** numeric comparison request to the application.
|
||||
**
|
||||
** Parameters: bd_addr - Address of the device with which numeric
|
||||
** comparison was requested
|
||||
** res - comparison result SMP_SUCCESS if success
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void SMP_ConfirmReply (BD_ADDR bd_addr, UINT8 res);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_OobDataReply
|
||||
**
|
||||
** Description This function is called to provide the OOB data for
|
||||
** SMP in response to SMP_OOB_REQ_EVT
|
||||
**
|
||||
** Parameters: bd_addr - Address of the peer device
|
||||
** res - result of the operation SMP_SUCCESS if success
|
||||
** p_data - SM Randomizer C.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, UINT8 len,
|
||||
UINT8 *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_SecureConnectionOobDataReply
|
||||
**
|
||||
** Description This function is called to provide the SC OOB data for
|
||||
** SMP in response to SMP_SC_OOB_REQ_EVT
|
||||
**
|
||||
** Parameters: p_data - pointer to the data
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void SMP_SecureConnectionOobDataReply(UINT8 *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_Encrypt
|
||||
**
|
||||
** Description This function is called to encrypt the data with the specified
|
||||
** key
|
||||
**
|
||||
** Parameters: key - Pointer to key key[0] conatins the MSB
|
||||
** key_len - key length
|
||||
** plain_text - Pointer to data to be encrypted
|
||||
** plain_text[0] conatins the MSB
|
||||
** pt_len - plain text length
|
||||
** p_out - pointer to the encrypted outputs
|
||||
**
|
||||
** Returns Boolean - TRUE: encryption is successful
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SMP_Encrypt (UINT8 *key, UINT8 key_len,
|
||||
UINT8 *plain_text, UINT8 pt_len,
|
||||
tSMP_ENC *p_out);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_KeypressNotification
|
||||
**
|
||||
** Description This function is called to notify SM about Keypress Notification.
|
||||
**
|
||||
** Parameters: bd_addr - Address of the device to send keypress
|
||||
** notification to
|
||||
** value - keypress notification parameter value
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void SMP_KeypressNotification (BD_ADDR bd_addr, UINT8 value);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function SMP_CreateLocalSecureConnectionsOobData
|
||||
**
|
||||
** Description This function is called to start creation of local SC OOB
|
||||
** data set (tSMP_LOC_OOB_DATA).
|
||||
**
|
||||
** Parameters: bd_addr - Address of the device to send OOB data block
|
||||
** to.
|
||||
**
|
||||
** Returns Boolean - TRUE: creation of local SC OOB data set started.
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN SMP_CreateLocalSecureConnectionsOobData (
|
||||
tBLE_BD_ADDR *addr_to_send_to);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* SMP_API_H */
|
||||
+543
@@ -0,0 +1,543 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains internally used SMP definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef SMP_INT_H
|
||||
#define SMP_INT_H
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
|
||||
#include "btu.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "btm_api.h"
|
||||
#include "smp_api.h"
|
||||
|
||||
#define SMP_MODEL_ENCRYPTION_ONLY 0 /* Legacy mode, Just Works model */
|
||||
#define SMP_MODEL_PASSKEY 1 /* Legacy mode, Passkey Entry model, this side inputs the key */
|
||||
#define SMP_MODEL_OOB 2 /* Legacy mode, OOB model */
|
||||
#define SMP_MODEL_KEY_NOTIF 3 /* Legacy mode, Passkey Entry model, this side displays the key */
|
||||
#define SMP_MODEL_SEC_CONN_JUSTWORKS 4 /* Secure Connections mode, Just Works model */
|
||||
#define SMP_MODEL_SEC_CONN_NUM_COMP 5 /* Secure Connections mode, Numeric Comparison model */
|
||||
#define SMP_MODEL_SEC_CONN_PASSKEY_ENT 6 /* Secure Connections mode, Passkey Entry model, */
|
||||
/* this side inputs the key */
|
||||
#define SMP_MODEL_SEC_CONN_PASSKEY_DISP 7 /* Secure Connections mode, Passkey Entry model, */
|
||||
/* this side displays the key */
|
||||
#define SMP_MODEL_SEC_CONN_OOB 8 /* Secure Connections mode, OOB model */
|
||||
#define SMP_MODEL_OUT_OF_RANGE 9
|
||||
typedef UINT8 tSMP_ASSO_MODEL;
|
||||
|
||||
|
||||
#ifndef SMP_MAX_CONN
|
||||
#define SMP_MAX_CONN 2
|
||||
#endif
|
||||
|
||||
#define SMP_WAIT_FOR_RSP_TOUT 30
|
||||
|
||||
#define SMP_OPCODE_INIT 0x04
|
||||
|
||||
/* SMP events */
|
||||
#define SMP_PAIRING_REQ_EVT SMP_OPCODE_PAIRING_REQ
|
||||
#define SMP_PAIRING_RSP_EVT SMP_OPCODE_PAIRING_RSP
|
||||
#define SMP_CONFIRM_EVT SMP_OPCODE_CONFIRM
|
||||
#define SMP_RAND_EVT SMP_OPCODE_RAND
|
||||
#define SMP_PAIRING_FAILED_EVT SMP_OPCODE_PAIRING_FAILED
|
||||
#define SMP_ENCRPTION_INFO_EVT SMP_OPCODE_ENCRYPT_INFO
|
||||
#define SMP_MASTER_ID_EVT SMP_OPCODE_MASTER_ID
|
||||
#define SMP_ID_INFO_EVT SMP_OPCODE_IDENTITY_INFO
|
||||
#define SMP_ID_ADDR_EVT SMP_OPCODE_ID_ADDR
|
||||
#define SMP_SIGN_INFO_EVT SMP_OPCODE_SIGN_INFO
|
||||
#define SMP_SECURITY_REQ_EVT SMP_OPCODE_SEC_REQ
|
||||
|
||||
#define SMP_PAIR_PUBLIC_KEY_EVT SMP_OPCODE_PAIR_PUBLIC_KEY
|
||||
#define SMP_PAIR_KEYPRESS_NOTIFICATION_EVT SMP_OPCODE_PAIR_KEYPR_NOTIF
|
||||
|
||||
#define SMP_PAIR_COMMITM_EVT SMP_OPCODE_PAIR_COMMITM
|
||||
|
||||
#define SMP_SELF_DEF_EVT (SMP_PAIR_COMMITM_EVT + 1)
|
||||
#define SMP_KEY_READY_EVT (SMP_SELF_DEF_EVT)
|
||||
#define SMP_ENCRYPTED_EVT (SMP_SELF_DEF_EVT + 1)
|
||||
#define SMP_L2CAP_CONN_EVT (SMP_SELF_DEF_EVT + 2)
|
||||
#define SMP_L2CAP_DISCONN_EVT (SMP_SELF_DEF_EVT + 3)
|
||||
#define SMP_IO_RSP_EVT (SMP_SELF_DEF_EVT + 4)
|
||||
#define SMP_API_SEC_GRANT_EVT (SMP_SELF_DEF_EVT + 5)
|
||||
#define SMP_TK_REQ_EVT (SMP_SELF_DEF_EVT + 6)
|
||||
#define SMP_AUTH_CMPL_EVT (SMP_SELF_DEF_EVT + 7)
|
||||
#define SMP_ENC_REQ_EVT (SMP_SELF_DEF_EVT + 8)
|
||||
#define SMP_BOND_REQ_EVT (SMP_SELF_DEF_EVT + 9)
|
||||
#define SMP_DISCARD_SEC_REQ_EVT (SMP_SELF_DEF_EVT + 10)
|
||||
|
||||
#define SMP_PAIR_DHKEY_CHCK_EVT SMP_OPCODE_PAIR_DHKEY_CHECK
|
||||
|
||||
#define SMP_PUBL_KEY_EXCH_REQ_EVT (SMP_SELF_DEF_EVT + 11) /* request to start public */
|
||||
/* key exchange */
|
||||
|
||||
#define SMP_LOC_PUBL_KEY_CRTD_EVT (SMP_SELF_DEF_EVT + 12) /* local public key created */
|
||||
|
||||
#define SMP_BOTH_PUBL_KEYS_RCVD_EVT (SMP_SELF_DEF_EVT + 13) /* both local and peer public */
|
||||
/* keys are saved in cb */
|
||||
|
||||
#define SMP_SC_DHKEY_CMPLT_EVT (SMP_SELF_DEF_EVT + 14) /* DHKey computation is completed,*/
|
||||
/* time to start SC phase1 */
|
||||
|
||||
#define SMP_HAVE_LOC_NONCE_EVT (SMP_SELF_DEF_EVT + 15) /* new local nonce is generated */
|
||||
/*and saved in p_cb->rand */
|
||||
|
||||
#define SMP_SC_PHASE1_CMPLT_EVT (SMP_SELF_DEF_EVT + 16) /* time to start SC phase2 */
|
||||
|
||||
#define SMP_SC_CALC_NC_EVT (SMP_SELF_DEF_EVT + 17) /* request to calculate number */
|
||||
/* for user check. Used only in the */
|
||||
/* numeric compare protocol */
|
||||
|
||||
/* Request to display the number for user check to the user.*/
|
||||
/* Used only in the numeric compare protocol */
|
||||
#define SMP_SC_DSPL_NC_EVT (SMP_SELF_DEF_EVT + 18)
|
||||
|
||||
#define SMP_SC_NC_OK_EVT (SMP_SELF_DEF_EVT + 19) /* user confirms 'OK' numeric */
|
||||
/*comparison request */
|
||||
|
||||
/* both local and peer DHKey Checks are already present - it is used on slave to prevent race condition */
|
||||
#define SMP_SC_2_DHCK_CHKS_PRES_EVT (SMP_SELF_DEF_EVT + 20)
|
||||
|
||||
/* same meaning as SMP_KEY_READY_EVT to separate between SC and legacy actions */
|
||||
#define SMP_SC_KEY_READY_EVT (SMP_SELF_DEF_EVT + 21)
|
||||
#define SMP_KEYPRESS_NOTIFICATION_EVENT (SMP_SELF_DEF_EVT + 22)
|
||||
|
||||
#define SMP_SC_OOB_DATA_EVT (SMP_SELF_DEF_EVT + 23) /* SC OOB data from some */
|
||||
/* repository is provided */
|
||||
|
||||
#define SMP_CR_LOC_SC_OOB_DATA_EVT (SMP_SELF_DEF_EVT + 24)
|
||||
#define SMP_MAX_EVT SMP_CR_LOC_SC_OOB_DATA_EVT
|
||||
|
||||
typedef UINT8 tSMP_EVENT;
|
||||
|
||||
/* Assumption it's only using the low 8 bits, if bigger than that, need to expand it to 16 bits */
|
||||
#define SMP_SEC_KEY_MASK 0x00ff
|
||||
|
||||
/* SMP pairing state */
|
||||
enum
|
||||
{
|
||||
SMP_STATE_IDLE,
|
||||
SMP_STATE_WAIT_APP_RSP,
|
||||
SMP_STATE_SEC_REQ_PENDING,
|
||||
SMP_STATE_PAIR_REQ_RSP,
|
||||
SMP_STATE_WAIT_CONFIRM,
|
||||
SMP_STATE_CONFIRM,
|
||||
SMP_STATE_RAND,
|
||||
SMP_STATE_PUBLIC_KEY_EXCH,
|
||||
SMP_STATE_SEC_CONN_PHS1_START,
|
||||
SMP_STATE_WAIT_COMMITMENT,
|
||||
SMP_STATE_WAIT_NONCE,
|
||||
SMP_STATE_SEC_CONN_PHS2_START,
|
||||
SMP_STATE_WAIT_DHK_CHECK,
|
||||
SMP_STATE_DHK_CHECK,
|
||||
SMP_STATE_ENCRYPTION_PENDING,
|
||||
SMP_STATE_BOND_PENDING,
|
||||
SMP_STATE_CREATE_LOCAL_SEC_CONN_OOB_DATA,
|
||||
SMP_STATE_MAX
|
||||
};
|
||||
typedef UINT8 tSMP_STATE;
|
||||
|
||||
/* SMP over BR/EDR events */
|
||||
#define SMP_BR_PAIRING_REQ_EVT SMP_OPCODE_PAIRING_REQ
|
||||
#define SMP_BR_PAIRING_RSP_EVT SMP_OPCODE_PAIRING_RSP
|
||||
#define SMP_BR_CONFIRM_EVT SMP_OPCODE_CONFIRM /* not expected over BR/EDR */
|
||||
#define SMP_BR_RAND_EVT SMP_OPCODE_RAND /* not expected over BR/EDR */
|
||||
#define SMP_BR_PAIRING_FAILED_EVT SMP_OPCODE_PAIRING_FAILED
|
||||
#define SMP_BR_ENCRPTION_INFO_EVT SMP_OPCODE_ENCRYPT_INFO /* not expected over BR/EDR */
|
||||
#define SMP_BR_MASTER_ID_EVT SMP_OPCODE_MASTER_ID /* not expected over BR/EDR */
|
||||
#define SMP_BR_ID_INFO_EVT SMP_OPCODE_IDENTITY_INFO
|
||||
#define SMP_BR_ID_ADDR_EVT SMP_OPCODE_ID_ADDR
|
||||
#define SMP_BR_SIGN_INFO_EVT SMP_OPCODE_SIGN_INFO
|
||||
#define SMP_BR_SECURITY_REQ_EVT SMP_OPCODE_SEC_REQ /* not expected over BR/EDR */
|
||||
#define SMP_BR_PAIR_PUBLIC_KEY_EVT SMP_OPCODE_PAIR_PUBLIC_KEY /* not expected over BR/EDR */
|
||||
#define SMP_BR_PAIR_DHKEY_CHCK_EVT SMP_OPCODE_PAIR_DHKEY_CHECK /* not expected over BR/EDR */
|
||||
#define SMP_BR_PAIR_KEYPR_NOTIF_EVT SMP_OPCODE_PAIR_KEYPR_NOTIF /* not expected over BR/EDR */
|
||||
#define SMP_BR_SELF_DEF_EVT SMP_BR_PAIR_KEYPR_NOTIF_EVT
|
||||
#define SMP_BR_KEY_READY_EVT (SMP_BR_SELF_DEF_EVT + 1)
|
||||
#define SMP_BR_ENCRYPTED_EVT (SMP_BR_SELF_DEF_EVT + 2)
|
||||
#define SMP_BR_L2CAP_CONN_EVT (SMP_BR_SELF_DEF_EVT + 3)
|
||||
#define SMP_BR_L2CAP_DISCONN_EVT (SMP_BR_SELF_DEF_EVT + 4)
|
||||
#define SMP_BR_KEYS_RSP_EVT (SMP_BR_SELF_DEF_EVT + 5)
|
||||
#define SMP_BR_API_SEC_GRANT_EVT (SMP_BR_SELF_DEF_EVT + 6)
|
||||
#define SMP_BR_TK_REQ_EVT (SMP_BR_SELF_DEF_EVT + 7)
|
||||
#define SMP_BR_AUTH_CMPL_EVT (SMP_BR_SELF_DEF_EVT + 8)
|
||||
#define SMP_BR_ENC_REQ_EVT (SMP_BR_SELF_DEF_EVT + 9)
|
||||
#define SMP_BR_BOND_REQ_EVT (SMP_BR_SELF_DEF_EVT + 10)
|
||||
#define SMP_BR_DISCARD_SEC_REQ_EVT (SMP_BR_SELF_DEF_EVT + 11)
|
||||
#define SMP_BR_MAX_EVT (SMP_BR_SELF_DEF_EVT + 12)
|
||||
typedef UINT8 tSMP_BR_EVENT;
|
||||
|
||||
/* SMP over BR/EDR pairing states */
|
||||
enum
|
||||
{
|
||||
SMP_BR_STATE_IDLE = SMP_STATE_IDLE,
|
||||
SMP_BR_STATE_WAIT_APP_RSP,
|
||||
SMP_BR_STATE_PAIR_REQ_RSP,
|
||||
SMP_BR_STATE_BOND_PENDING,
|
||||
SMP_BR_STATE_MAX
|
||||
};
|
||||
typedef UINT8 tSMP_BR_STATE;
|
||||
|
||||
/* random and encrption activity state */
|
||||
enum
|
||||
{
|
||||
SMP_GEN_COMPARE = 1,
|
||||
SMP_GEN_CONFIRM,
|
||||
|
||||
SMP_GEN_DIV_LTK,
|
||||
SMP_GEN_DIV_CSRK,
|
||||
SMP_GEN_RAND_V,
|
||||
SMP_GEN_TK,
|
||||
SMP_GEN_SRAND_MRAND,
|
||||
SMP_GEN_SRAND_MRAND_CONT,
|
||||
SMP_GENERATE_PRIVATE_KEY_0_7,
|
||||
SMP_GENERATE_PRIVATE_KEY_8_15,
|
||||
SMP_GENERATE_PRIVATE_KEY_16_23,
|
||||
SMP_GENERATE_PRIVATE_KEY_24_31,
|
||||
SMP_GEN_NONCE_0_7,
|
||||
SMP_GEN_NONCE_8_15
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SMP_KEY_TYPE_TK,
|
||||
SMP_KEY_TYPE_CFM,
|
||||
SMP_KEY_TYPE_CMP,
|
||||
SMP_KEY_TYPE_PEER_DHK_CHCK,
|
||||
SMP_KEY_TYPE_STK,
|
||||
SMP_KEY_TYPE_LTK
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
UINT8 key_type;
|
||||
UINT8* p_data;
|
||||
}tSMP_KEY;
|
||||
|
||||
typedef union
|
||||
{
|
||||
UINT8 *p_data; /* UINT8 type data pointer */
|
||||
tSMP_KEY key;
|
||||
UINT16 reason;
|
||||
UINT32 passkey;
|
||||
tSMP_OOB_DATA_TYPE req_oob_type;
|
||||
}tSMP_INT_DATA;
|
||||
|
||||
/* internal status mask */
|
||||
#define SMP_PAIR_FLAGS_WE_STARTED_DD (1)
|
||||
#define SMP_PAIR_FLAGS_PEER_STARTED_DD (1 << 1)
|
||||
#define SMP_PAIR_FLAGS_CMD_CONFIRM (1 << SMP_OPCODE_CONFIRM) /* 1 << 3 */
|
||||
#define SMP_PAIR_FLAG_ENC_AFTER_PAIR (1 << 4)
|
||||
#define SMP_PAIR_FLAG_HAVE_PEER_DHK_CHK (1 << 5) /* used on slave to resolve race condition */
|
||||
#define SMP_PAIR_FLAG_HAVE_PEER_PUBL_KEY (1 << 6) /* used on slave to resolve race condition */
|
||||
#define SMP_PAIR_FLAG_HAVE_PEER_COMM (1 << 7) /* used to resolve race condition */
|
||||
#define SMP_PAIR_FLAG_HAVE_LOCAL_PUBL_KEY (1 << 8) /* used on slave to resolve race condition */
|
||||
|
||||
/* check if authentication requirement need MITM protection */
|
||||
#define SMP_NO_MITM_REQUIRED(x) (((x) & SMP_AUTH_YN_BIT) == 0)
|
||||
|
||||
#define SMP_ENCRYT_KEY_SIZE 16
|
||||
#define SMP_ENCRYT_DATA_SIZE 16
|
||||
#define SMP_ECNCRPYT_STATUS HCI_SUCCESS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BD_ADDR bd_addr;
|
||||
BT_HDR* p_copy;
|
||||
} tSMP_REQ_Q_ENTRY;
|
||||
|
||||
/* SMP control block */
|
||||
typedef struct
|
||||
{
|
||||
tSMP_CALLBACK *p_callback;
|
||||
TIMER_LIST_ENT rsp_timer_ent;
|
||||
UINT8 trace_level;
|
||||
BD_ADDR pairing_bda;
|
||||
tSMP_STATE state;
|
||||
BOOLEAN derive_lk;
|
||||
BOOLEAN id_addr_rcvd;
|
||||
tBLE_ADDR_TYPE id_addr_type;
|
||||
BD_ADDR id_addr;
|
||||
BOOLEAN smp_over_br;
|
||||
tSMP_BR_STATE br_state; /* if SMP over BR/ERD has priority over SMP */
|
||||
UINT8 failure;
|
||||
UINT8 status;
|
||||
UINT8 role;
|
||||
UINT16 flags;
|
||||
UINT8 cb_evt;
|
||||
tSMP_SEC_LEVEL sec_level;
|
||||
BOOLEAN connect_initialized;
|
||||
BT_OCTET16 confirm;
|
||||
BT_OCTET16 rconfirm;
|
||||
BT_OCTET16 rrand; /* for SC this is peer nonce */
|
||||
BT_OCTET16 rand; /* for SC this is local nonce */
|
||||
BT_OCTET32 private_key;
|
||||
BT_OCTET32 dhkey;
|
||||
BT_OCTET16 commitment;
|
||||
BT_OCTET16 remote_commitment;
|
||||
BT_OCTET16 local_random; /* local randomizer - passkey or OOB randomizer */
|
||||
BT_OCTET16 peer_random; /* peer randomizer - passkey or OOB randomizer */
|
||||
BT_OCTET16 dhkey_check;
|
||||
BT_OCTET16 remote_dhkey_check;
|
||||
tSMP_PUBLIC_KEY loc_publ_key;
|
||||
tSMP_PUBLIC_KEY peer_publ_key;
|
||||
tSMP_OOB_DATA_TYPE req_oob_type;
|
||||
tSMP_SC_OOB_DATA sc_oob_data;
|
||||
tSMP_IO_CAP peer_io_caps;
|
||||
tSMP_IO_CAP local_io_capability;
|
||||
tSMP_OOB_FLAG peer_oob_flag;
|
||||
tSMP_OOB_FLAG loc_oob_flag;
|
||||
tSMP_AUTH_REQ peer_auth_req;
|
||||
tSMP_AUTH_REQ loc_auth_req;
|
||||
BOOLEAN secure_connections_only_mode_required;/* TRUE if locally SM is required to operate */
|
||||
/* either in Secure Connections mode or not at all */
|
||||
tSMP_ASSO_MODEL selected_association_model;
|
||||
BOOLEAN le_secure_connections_mode_is_used;
|
||||
BOOLEAN le_sc_kp_notif_is_used;
|
||||
tSMP_SC_KEY_TYPE local_keypress_notification;
|
||||
tSMP_SC_KEY_TYPE peer_keypress_notification;
|
||||
UINT8 round; /* authentication stage 1 round for passkey association model */
|
||||
UINT32 number_to_display;
|
||||
BT_OCTET16 mac_key;
|
||||
UINT8 peer_enc_size;
|
||||
UINT8 loc_enc_size;
|
||||
UINT8 peer_i_key;
|
||||
UINT8 peer_r_key;
|
||||
UINT8 local_i_key;
|
||||
UINT8 local_r_key;
|
||||
|
||||
BT_OCTET16 tk;
|
||||
BT_OCTET16 ltk;
|
||||
UINT16 div;
|
||||
BT_OCTET16 csrk; /* storage for local CSRK */
|
||||
UINT16 ediv;
|
||||
BT_OCTET8 enc_rand;
|
||||
UINT8 rand_enc_proc_state;
|
||||
UINT8 addr_type;
|
||||
BD_ADDR local_bda;
|
||||
BOOLEAN is_pair_cancel;
|
||||
BOOLEAN discard_sec_req;
|
||||
UINT8 rcvd_cmd_code;
|
||||
UINT8 rcvd_cmd_len;
|
||||
UINT16 total_tx_unacked;
|
||||
BOOLEAN wait_for_authorization_complete;
|
||||
}tSMP_CB;
|
||||
|
||||
/* Server Action functions are of this type */
|
||||
typedef void (*tSMP_ACT)(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if SMP_DYNAMIC_MEMORY == FALSE
|
||||
extern tSMP_CB smp_cb;
|
||||
#else
|
||||
extern tSMP_CB *smp_cb_ptr;
|
||||
#define smp_cb (*smp_cb_ptr)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Functions provided by att_main.c */
|
||||
extern void smp_init (void);
|
||||
|
||||
/* smp main */
|
||||
extern void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data);
|
||||
|
||||
extern void smp_proc_sec_request(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_set_fail_nc (BOOLEAN enable);
|
||||
extern void smp_set_fail_conf (BOOLEAN enable);
|
||||
extern void smp_set_passk_entry_fail(BOOLEAN enable);
|
||||
extern void smp_set_oob_fail(BOOLEAN enable);
|
||||
extern void smp_set_peer_sc_notif(BOOLEAN enable);
|
||||
extern void smp_aes_cmac_rfc4493_chk (UINT8 *key, UINT8 *msg, UINT8 msg_len,
|
||||
UINT8 mac_len, UINT8 *mac);
|
||||
extern void smp_f4_calc_chk (UINT8 *U, UINT8 *V, UINT8 *X, UINT8 *Z, UINT8 *mac);
|
||||
extern void smp_g2_calc_chk (UINT8 *U, UINT8 *V, UINT8 *X, UINT8 *Y);
|
||||
extern void smp_h6_calc_chk (UINT8 *key, UINT8 *key_id, UINT8 *mac);
|
||||
extern void smp_f5_key_calc_chk (UINT8 *w, UINT8 *mac);
|
||||
extern void smp_f5_mackey_or_ltk_calc_chk(UINT8 *t, UINT8 *counter,
|
||||
UINT8 *key_id, UINT8 *n1,
|
||||
UINT8 *n2, UINT8 *a1, UINT8 *a2,
|
||||
UINT8 *length, UINT8 *mac);
|
||||
extern void smp_f5_calc_chk (UINT8 *w, UINT8 *n1, UINT8 *n2, UINT8 *a1, UINT8 *a2,
|
||||
UINT8 *mac_key, UINT8 *ltk);
|
||||
extern void smp_f6_calc_chk (UINT8 *w, UINT8 *n1, UINT8 *n2, UINT8 *r,
|
||||
UINT8 *iocap, UINT8 *a1, UINT8 *a2, UINT8 *mac);
|
||||
/* smp_main */
|
||||
extern void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data);
|
||||
extern tSMP_STATE smp_get_state(void);
|
||||
extern void smp_set_state(tSMP_STATE state);
|
||||
|
||||
/* smp_br_main */
|
||||
extern void smp_br_state_machine_event(tSMP_CB *p_cb, tSMP_BR_EVENT event, void *p_data);
|
||||
extern tSMP_BR_STATE smp_get_br_state(void);
|
||||
extern void smp_set_br_state(tSMP_BR_STATE state);
|
||||
|
||||
|
||||
/* smp_act.c */
|
||||
extern void smp_send_pair_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_pair_fail(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_rand(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_pair_public_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_commitment(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_keypress_notification(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_pair_fail(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_rand(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_process_pairing_public_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_master_id(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_id_addr(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_sec_grant(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_sec_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_sl_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_start_enc(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_enc_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_discard(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_pairing_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_decide_association_model(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_app_cback(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_compare(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_check_auth_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_process_io_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_csrk_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_ltk_reply(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_pair_cmd(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_pair_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_idle_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_send_pair_rsp(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_key_distribution(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_proc_srk_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_generate_csrk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_fast_conn_param(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_key_pick_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_both_have_public_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_start_secure_connection_phase1(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_process_local_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_process_pairing_commitment(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_process_peer_nonce(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_process_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_match_dhkey_checks(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_process_keypress_notification(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_move_to_secure_connections_phase2(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_phase_2_dhkey_checks_are_present(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_wait_for_both_public_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_start_passkey_verification(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_process_secure_connection_oob_data(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_process_secure_connection_long_term_key(void);
|
||||
extern void smp_set_local_oob_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_set_local_oob_random_commitment(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_set_derive_link_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_derive_link_key_from_long_term_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_br_process_pairing_command(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_br_process_security_grant(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_br_process_slave_keys_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_br_send_pair_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_br_check_authorization_request(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_br_select_next_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_br_process_link_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_key_distribution_by_transport(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_br_pairing_complete(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
|
||||
/* smp_l2c */
|
||||
extern void smp_l2cap_if_init (void);
|
||||
extern void smp_data_ind (BD_ADDR bd_addr, BT_HDR *p_buf);
|
||||
|
||||
/* smp_util.c */
|
||||
extern BOOLEAN smp_send_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
|
||||
extern void smp_cb_cleanup(tSMP_CB *p_cb);
|
||||
extern void smp_reset_control_value(tSMP_CB *p_cb);
|
||||
extern void smp_proc_pairing_cmpl(tSMP_CB *p_cb);
|
||||
extern void smp_convert_string_to_tk(BT_OCTET16 tk, UINT32 passkey);
|
||||
extern void smp_mask_enc_key(UINT8 loc_enc_size, UINT8 * p_data);
|
||||
extern void smp_rsp_timeout(TIMER_LIST_ENT *p_tle);
|
||||
extern void smp_xor_128(BT_OCTET16 a, BT_OCTET16 b);
|
||||
extern BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
|
||||
UINT8 *plain_text, UINT8 pt_len,
|
||||
tSMP_ENC *p_out);
|
||||
extern BOOLEAN smp_command_has_invalid_parameters(tSMP_CB *p_cb);
|
||||
extern void smp_reject_unexpected_pairing_command(BD_ADDR bd_addr);
|
||||
extern tSMP_ASSO_MODEL smp_select_association_model(tSMP_CB *p_cb);
|
||||
extern void smp_reverse_array(UINT8 *arr, UINT8 len);
|
||||
extern UINT8 smp_calculate_random_input(UINT8 *random, UINT8 round);
|
||||
extern void smp_collect_local_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb);
|
||||
extern void smp_collect_peer_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb);
|
||||
extern void smp_collect_local_ble_address(UINT8 *le_addr, tSMP_CB *p_cb);
|
||||
extern void smp_collect_peer_ble_address(UINT8 *le_addr, tSMP_CB *p_cb);
|
||||
extern BOOLEAN smp_check_commitment(tSMP_CB *p_cb);
|
||||
extern void smp_save_secure_connections_long_term_key(tSMP_CB *p_cb);
|
||||
extern BOOLEAN smp_calculate_f5_mackey_and_long_term_key(tSMP_CB *p_cb);
|
||||
extern void smp_remove_fixed_channel(tSMP_CB *p_cb);
|
||||
extern BOOLEAN smp_request_oob_data(tSMP_CB *p_cb);
|
||||
|
||||
/* smp_keys.c */
|
||||
extern void smp_generate_srand_mrand_confirm (tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_generate_compare (tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_generate_stk (tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_generate_ltk(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_generate_passkey (tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_generate_rand_cont(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_create_private_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_use_oob_private_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_compute_dhkey(tSMP_CB *p_cb);
|
||||
extern void smp_calculate_local_commitment(tSMP_CB *p_cb);
|
||||
extern void smp_calculate_peer_commitment(tSMP_CB *p_cb, BT_OCTET16 output_buf);
|
||||
extern void smp_calculate_numeric_comparison_display_number(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_calculate_local_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_calculate_peer_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_start_nonce_generation(tSMP_CB *p_cb);
|
||||
extern BOOLEAN smp_calculate_link_key_from_long_term_key(tSMP_CB *p_cb);
|
||||
extern BOOLEAN smp_calculate_long_term_key_from_link_key(tSMP_CB *p_cb);
|
||||
extern void smp_calculate_f4(UINT8 *u, UINT8 *v, UINT8 *x, UINT8 z, UINT8 *c);
|
||||
extern UINT32 smp_calculate_g2(UINT8 *u, UINT8 *v, UINT8 *x, UINT8 *y);
|
||||
extern BOOLEAN smp_calculate_f5(UINT8 *w, UINT8 *n1, UINT8 *n2, UINT8 *a1, UINT8 *a2,
|
||||
UINT8 *mac_key, UINT8 *ltk);
|
||||
extern BOOLEAN smp_calculate_f5_mackey_or_long_term_key(UINT8 *t, UINT8 *counter,
|
||||
UINT8 *key_id, UINT8 *n1, UINT8 *n2, UINT8 *a1,
|
||||
UINT8 *a2, UINT8 *length, UINT8 *mac);
|
||||
extern BOOLEAN smp_calculate_f5_key(UINT8 *w, UINT8 *t);
|
||||
extern BOOLEAN smp_calculate_f6(UINT8 *w, UINT8 *n1, UINT8 *n2, UINT8 *r, UINT8 *iocap,
|
||||
UINT8 *a1, UINT8 *a2, UINT8 *f3);
|
||||
extern BOOLEAN smp_calculate_h6(UINT8 *w, UINT8 *keyid, UINT8 *h2);
|
||||
#if SMP_DEBUG == TRUE
|
||||
extern void smp_debug_print_nbyte_little_endian (UINT8 *p, const UINT8 *key_name,
|
||||
UINT8 len);
|
||||
#endif
|
||||
|
||||
/* smp_cmac.c */
|
||||
extern BOOLEAN aes_cipher_msg_auth_code(BT_OCTET16 key, UINT8 *input, UINT16 length,
|
||||
UINT16 tlen, UINT8 *p_signature);
|
||||
extern void print128(BT_OCTET16 x, const UINT8 *key_name);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* SMP_INT_H */
|
||||
Reference in New Issue
Block a user