summaryrefslogtreecommitdiffstats
path: root/bta/include
diff options
context:
space:
mode:
authorAndre Eisenbach <andre@broadcom.com>2012-02-22 13:18:21 -0800
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:11 -0700
commite448862a47c08eb23185aaed574b39264f5005fc (patch)
tree2bc6246e3091315e77224fd798ea2fe8074ef972 /bta/include
parenta2ca4b83ab8bbbfd8d5f6693e927ed4b82094624 (diff)
downloadexternal_bluetooth_bluedroid-e448862a47c08eb23185aaed574b39264f5005fc.zip
external_bluetooth_bluedroid-e448862a47c08eb23185aaed574b39264f5005fc.tar.gz
external_bluetooth_bluedroid-e448862a47c08eb23185aaed574b39264f5005fc.tar.bz2
Initial Bluedroid stack commit
Diffstat (limited to 'bta/include')
-rw-r--r--bta/include/bd.h89
-rw-r--r--bta/include/bta_ag_api.h496
-rw-r--r--bta/include/bta_ag_ci.h70
-rw-r--r--bta/include/bta_ag_co.h100
-rw-r--r--bta/include/bta_api.h1712
-rw-r--r--bta/include/bta_av_api.h753
-rw-r--r--bta/include/bta_av_ci.h62
-rw-r--r--bta/include/bta_av_co.h400
-rw-r--r--bta/include/bta_dg_api.h198
-rw-r--r--bta/include/bta_dg_ci.h107
-rw-r--r--bta/include/bta_dg_co.h198
-rw-r--r--bta/include/bta_dm_ci.h69
-rw-r--r--bta/include/bta_dm_co.h262
-rw-r--r--bta/include/bta_fs_api.h32
-rw-r--r--bta/include/bta_fs_ci.h244
-rw-r--r--bta/include/bta_fs_co.h690
-rw-r--r--bta/include/bta_ft_api.h724
-rw-r--r--bta/include/bta_gatt_api.h1206
-rw-r--r--bta/include/bta_gattc_ci.h108
-rw-r--r--bta/include/bta_gattc_co.h89
-rw-r--r--bta/include/bta_gatts_co.h70
-rw-r--r--bta/include/bta_hd_api.h289
-rw-r--r--bta/include/bta_hh_api.h444
-rw-r--r--bta/include/bta_hh_co.h60
-rw-r--r--bta/include/bta_hl_api.h895
-rw-r--r--bta/include/bta_hl_ci.h112
-rw-r--r--bta/include/bta_hl_co.h219
-rw-r--r--bta/include/bta_ma_api.h691
-rw-r--r--bta/include/bta_ma_co.h91
-rw-r--r--bta/include/bta_ma_def.h479
-rw-r--r--bta/include/bta_mse_api.h470
-rw-r--r--bta/include/bta_mse_ci.h146
-rw-r--r--bta/include/bta_mse_co.h330
-rw-r--r--bta/include/bta_op_api.h621
-rw-r--r--bta/include/bta_pan_api.h187
-rw-r--r--bta/include/bta_pan_ci.h139
-rw-r--r--bta/include/bta_pan_co.h189
-rw-r--r--bta/include/bta_pbs_api.h298
-rw-r--r--bta/include/bta_pbs_ci.h93
-rw-r--r--bta/include/bta_pbs_co.h160
-rw-r--r--bta/include/bta_prm_api.h57
-rw-r--r--bta/include/bta_sc_api.h193
-rw-r--r--bta/include/bta_sc_ci.h111
-rw-r--r--bta/include/bta_sc_co.h153
-rw-r--r--bta/include/bta_sys_ci.h57
-rw-r--r--bta/include/bta_sys_co.h47
-rw-r--r--bta/include/ptim.h86
-rw-r--r--bta/include/utl.h156
48 files changed, 14452 insertions, 0 deletions
diff --git a/bta/include/bd.h b/bta/include/bd.h
new file mode 100644
index 0000000..0fd0cf8
--- /dev/null
+++ b/bta/include/bd.h
@@ -0,0 +1,89 @@
+/*****************************************************************************
+**
+** Name: bd.h
+**
+** Description: BD address services.
+**
+** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BD_H
+#define BD_H
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* bd addr length and type */
+#ifndef BD_ADDR_LEN
+#define BD_ADDR_LEN 6
+typedef UINT8 BD_ADDR[BD_ADDR_LEN];
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* global constant for "any" bd addr */
+extern const BD_ADDR bd_addr_any;
+extern const BD_ADDR bd_addr_null;
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function bdcpy
+**
+** Description Copy bd addr b to a.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+extern void bdcpy(BD_ADDR a, const BD_ADDR b);
+
+/*******************************************************************************
+**
+** Function bdcmp
+**
+** Description Compare bd addr b to a.
+**
+**
+** Returns Zero if b==a, nonzero otherwise (like memcmp).
+**
+*******************************************************************************/
+extern int bdcmp(const BD_ADDR a, const BD_ADDR b);
+
+/*******************************************************************************
+**
+** Function bdcmpany
+**
+** Description Compare bd addr to "any" bd addr.
+**
+**
+** Returns Zero if a equals bd_addr_any.
+**
+*******************************************************************************/
+extern int bdcmpany(const BD_ADDR a);
+
+/*******************************************************************************
+**
+** Function bdsetany
+**
+** Description Set bd addr to "any" bd addr.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+extern void bdsetany(BD_ADDR a);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BD_H */
+
diff --git a/bta/include/bta_ag_api.h b/bta/include/bta_ag_api.h
new file mode 100644
index 0000000..32473ed
--- /dev/null
+++ b/bta/include/bta_ag_api.h
@@ -0,0 +1,496 @@
+/*****************************************************************************
+**
+** Name: bta_ag_api.h
+**
+** Description: This is the public interface file for the audio gateway
+** (AG) subsystem of BTA, Widcomm's Bluetooth application
+** layer for mobile phones.
+**
+** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_AG_API_H
+#define BTA_AG_API_H
+
+#include "bta_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* AG feature masks */
+#define BTA_AG_FEAT_3WAY 0x00000001 /* Three-way calling */
+#define BTA_AG_FEAT_ECNR 0x00000002 /* Echo cancellation and/or noise reduction */
+#define BTA_AG_FEAT_VREC 0x00000004 /* Voice recognition */
+#define BTA_AG_FEAT_INBAND 0x00000008 /* In-band ring tone */
+#define BTA_AG_FEAT_VTAG 0x00000010 /* Attach a phone number to a voice tag */
+#define BTA_AG_FEAT_REJECT 0x00000020 /* Ability to reject incoming call */
+#define BTA_AG_FEAT_ECS 0x00000040 /* Enhanced Call Status */
+#define BTA_AG_FEAT_ECC 0x00000080 /* Enhanced Call Control */
+#define BTA_AG_FEAT_EXTERR 0x00000100 /* Extended error codes */
+#define BTA_AG_FEAT_CODEC 0x00000200 /* Codec Negotiation */
+#define BTA_AG_FEAT_VOIP 0x00000400 /* VoIP call */
+/* Proprietary features: using 31 ~ 16 bits */
+#define BTA_AG_FEAT_BTRH 0x00010000 /* CCAP incoming call hold */
+#define BTA_AG_FEAT_UNAT 0x00020000 /* Pass unknown AT commands to application */
+#define BTA_AG_FEAT_NOSCO 0x00040000 /* No SCO control performed by BTA AG */
+#define BTA_AG_FEAT_NO_ESCO 0x00080000 /* Do not allow or use eSCO */
+
+typedef UINT32 tBTA_AG_FEAT;
+
+/* AG parse mode */
+#define BTA_AG_PARSE 0 /* Perform AT command parsing in AG */
+#define BTA_AG_PASS_THROUGH 1 /* Pass data directly to phone’s AT command interpreter */
+
+typedef UINT8 tBTA_AG_PARSE_MODE;
+
+/* AG open status */
+#define BTA_AG_SUCCESS 0 /* Connection successfully opened */
+#define BTA_AG_FAIL_SDP 1 /* Open failed due to SDP */
+#define BTA_AG_FAIL_RFCOMM 2 /* Open failed due to RFCOMM */
+#define BTA_AG_FAIL_RESOURCES 3 /* out of resources failure */
+
+typedef UINT8 tBTA_AG_STATUS;
+
+/* handle values used with BTA_AgResult */
+#define BTA_AG_HANDLE_NONE 0
+#define BTA_AG_HANDLE_ALL 0xFFFF
+
+/* AG result codes used with BTA_AgResult */
+#define BTA_AG_SPK_RES 0 /* Update speaker volume */
+#define BTA_AG_MIC_RES 1 /* Update microphone volume */
+#define BTA_AG_INBAND_RING_RES 2 /* Update inband ring state */
+#define BTA_AG_CIND_RES 3 /* Send indicator response for AT+CIND */
+#define BTA_AG_BINP_RES 4 /* Send phone number for voice tag for AT+BINP */
+#define BTA_AG_IND_RES 5 /* Update an indicator value */
+#define BTA_AG_BVRA_RES 6 /* Update voice recognition state */
+#define BTA_AG_CNUM_RES 7 /* Send subscriber number response for AT+CNUM */
+#define BTA_AG_BTRH_RES 8 /* Send CCAP incoming call hold */
+#define BTA_AG_CLCC_RES 9 /* Query list of calls */
+#define BTA_AG_COPS_RES 10 /* Read network operator */
+#define BTA_AG_IN_CALL_RES 11 /* Indicate incoming phone call */
+#define BTA_AG_IN_CALL_CONN_RES 12 /* Incoming phone call connected */
+#define BTA_AG_CALL_WAIT_RES 13 /* Call waiting notification */
+#define BTA_AG_OUT_CALL_ORIG_RES 14 /* Outgoing phone call origination */
+#define BTA_AG_OUT_CALL_ALERT_RES 15 /* Outgoing phone call alerting remote party */
+#define BTA_AG_OUT_CALL_CONN_RES 16 /* Outgoing phone call connected */
+#define BTA_AG_CALL_CANCEL_RES 17 /* Incoming/outgoing 3-way canceled before connected */
+#define BTA_AG_END_CALL_RES 18 /* End call */
+#define BTA_AG_IN_CALL_HELD_RES 19 /* Incoming call held */
+#define BTA_AG_UNAT_RES 20 /* Response to unknown AT command event */
+
+typedef UINT8 tBTA_AG_RES;
+
+/* HFP peer features */
+#define BTA_AG_PEER_FEAT_ECNR 0x0001 /* Echo cancellation and/or noise reduction */
+#define BTA_AG_PEER_FEAT_3WAY 0x0002 /* Call waiting and three-way calling */
+#define BTA_AG_PEER_FEAT_CLI 0x0004 /* Caller ID presentation capability */
+#define BTA_AG_PEER_FEAT_VREC 0x0008 /* Voice recognition activation */
+#define BTA_AG_PEER_FEAT_VOL 0x0010 /* Remote volume control */
+#define BTA_AG_PEER_FEAT_ECS 0x0020 /* Enhanced Call Status */
+#define BTA_AG_PEER_FEAT_ECC 0x0040 /* Enhanced Call Control */
+#define BTA_AG_PEER_FEAT_CODEC 0x0080 /* Codec Negotiation */
+#define BTA_AG_PEER_FEAT_VOIP 0x0100 /* VoIP call */
+
+typedef UINT16 tBTA_AG_PEER_FEAT;
+
+/* HFP peer supported codec masks */
+#define BTA_AG_CODEC_NONE BTM_SCO_CODEC_NONE
+#define BTA_AG_CODEC_CVSD BTM_SCO_CODEC_CVSD /* CVSD */
+#define BTA_AG_CODEC_MSBC BTM_SCO_CODEC_MSBC /* mSBC */
+typedef UINT16 tBTA_AG_PEER_CODEC;
+
+/* HFP errcode - Set when BTA_AG_OK_ERROR is returned in 'ok_flag' */
+#define BTA_AG_ERR_PHONE_FAILURE 0 /* Phone Failure */
+#define BTA_AG_ERR_NO_CONN_PHONE 1 /* No connection to phone */
+#define BTA_AG_ERR_OP_NOT_ALLOWED 3 /* Operation not allowed */
+#define BTA_AG_ERR_OP_NOT_SUPPORTED 4 /* Operation not supported */
+#define BTA_AG_ERR_PHSIM_PIN_REQ 5 /* PH-SIM PIN required */
+#define BTA_AG_ERR_SIM_NOT_INSERTED 10 /* SIM not inserted */
+#define BTA_AG_ERR_SIM_PIN_REQ 11 /* SIM PIN required */
+#define BTA_AG_ERR_SIM_PUK_REQ 12 /* SIM PUK required */
+#define BTA_AG_ERR_SIM_FAILURE 13 /* SIM failure */
+#define BTA_AG_ERR_SIM_BUSY 14 /* SIM busy */
+#define BTA_AG_ERR_INCORRECT_PWD 16 /* Incorrect password */
+#define BTA_AG_ERR_SIM_PIN2_REQ 17 /* SIM PIN2 required */
+#define BTA_AG_ERR_SIM_PUK2_REQ 18 /* SIM PUK2 required */
+#define BTA_AG_ERR_MEMORY_FULL 20 /* Memory full */
+#define BTA_AG_ERR_INVALID_INDEX 21 /* Invalid index */
+#define BTA_AG_ERR_MEMORY_FAILURE 23 /* Memory failure */
+#define BTA_AG_ERR_TEXT_TOO_LONG 24 /* Text string too long */
+#define BTA_AG_ERR_INV_CHAR_IN_TSTR 25 /* Invalid characters in text string */
+#define BTA_AG_ERR_DSTR_TOO_LONG 26 /* Dial string too long */
+#define BTA_AG_ERR_INV_CHAR_IN_DSTR 27 /* Invalid characters in dial string */
+#define BTA_AG_ERR_NO_NETWORK_SERV 30 /* No network service */
+#define BTA_AG_ERR_NETWORK_TIME_OUT 31 /* Network timeout */
+#define BTA_AG_ERR_NO_NET_EMG_ONLY 32 /* Network not allowed - emergency service only */
+#define BTA_AG_ERR_VOIP_CS_CALLS 33 /* AG cannot create simultaneous VoIP and CS calls */
+#define BTA_AG_ERR_NOT_FOR_VOIP 34 /* Not supported on this call type(VoIP) */
+#define BTA_AG_ERR_SIP_RESP_CODE 35 /* SIP 3 digit response code */
+
+#if 0 /* Not Used in Bluetooth HFP 1.5 Specification */
+#define BTA_AG_ERR_PHADAP_LNK_RES 2 /* Phone-adapter link reserved */
+#define BTA_AG_ERR_PHFSIM_PIN_REQ 6 /* PH-FSIM PIN required */
+#define BTA_AG_ERR_PHFSIM_PUK_REQ 7 /* PH-FSIM PUK required */
+#define BTA_AG_ERR_SIM_WRONG 15 /* SIM wrong */
+#define BTA_AG_ERR_NOT_FOUND 22 /* Not found */
+#define BTA_AG_ERR_NETWORK_TIMEOUT 31 /* Network timeout */
+#define BTA_AG_ERR_NET_PIN_REQ 40 /* Network personalization PIN required */
+#define BTA_AG_ERR_NET_PUK_REQ 41 /* Network personalization PUK required */
+#define BTA_AG_ERR_SUBSET_PIN_REQ 42 /* Network subset personalization PIN required */
+#define BTA_AG_ERR_SUBSET_PUK_REQ 43 /* Network subset personalization PUK required */
+#define BTA_AG_ERR_SERVPRO_PIN_REQ 44 /* Service provider personalization PIN required */
+#define BTA_AG_ERR_SERVPRO_PUK_REQ 45 /* Service provider personalization PUK required */
+#define BTA_AG_ERR_CORP_PIN_REQ 46 /* Corporate personalization PIN required */
+#define BTA_AG_ERR_CORP_PUK_REQ 47 /* Corporate personalization PUK required */
+#define BTA_AG_ERR_UNKNOWN 100 /* Unknown error */
+/* GPRS-related errors */
+#define BTA_AG_ERR_ILL_MS 103 /* Illegal MS (#3) */
+#define BTA_AG_ERR_ILL_ME 106 /* Illegal ME (#6) */
+#define BTA_AG_ERR_GPRS_NOT_ALLOWED 107 /* GPRS services not allowed (#7) */
+#define BTA_AG_ERR_PLMN_NOT_ALLOWED 111 /* PLMN services not allowed (#11) */
+#define BTA_AG_ERR_LOC_NOT_ALLOWED 112 /* Location area not allowed (#12) */
+#define BTA_AG_ERR_ROAM_NOT_ALLOWED 113 /* Roaming not allowed in this location area (#13) */
+/* Errors related to a failure to Activate a Context */
+#define BTA_AG_ERR_OPT_NOT_SUPP 132 /* Service option not supported (#32) */
+#define BTA_AG_ERR_OPT_NOT_SUBSCR 133 /* Requested service option not subscribed (#33) */
+#define BTA_AG_ERR_OPT_OUT_OF_ORDER 134 /* Service option temporarily out of order (#34) */
+#define BTA_AG_ERR_PDP_AUTH_FAILURE 149 /* PDP authentication failure */
+/* Other GPRS errors */
+#define BTA_AG_ERR_INV_MOBILE_CLASS 150 /* Invalid mobile class */
+#define BTA_AG_ERR_UNSPEC_GPRS_ERR 148 /* Unspecified GPRS error */
+#endif /* Unused error codes */
+
+
+/* HFP result data 'ok_flag' */
+#define BTA_AG_OK_CONTINUE 0 /* Send out response (more responses coming) */
+#define BTA_AG_OK_DONE 1 /* Send out response followed by OK (finished) */
+#define BTA_AG_OK_ERROR 2 /* Error response */
+
+/* BTRH values */
+#define BTA_AG_BTRH_SET_HOLD 0 /* Put incoming call on hold */
+#define BTA_AG_BTRH_SET_ACC 1 /* Accept incoming call on hold */
+#define BTA_AG_BTRH_SET_REJ 2 /* Reject incoming call on hold */
+#define BTA_AG_BTRH_READ 3 /* Read the current value */
+#define BTA_AG_BTRH_NO_RESP 4 /* Not in RH States (reply to read) */
+
+/* ASCII character string of arguments to the AT command or result */
+#ifndef BTA_AG_AT_MAX_LEN
+#define BTA_AG_AT_MAX_LEN 256
+#endif
+
+/* data associated with BTA_AG_IND_RES */
+typedef struct
+{
+ UINT16 id;
+ UINT16 value;
+} tBTA_AG_IND;
+
+/* data type for BTA_AgResult() */
+typedef struct
+{
+ char str[BTA_AG_AT_MAX_LEN+1];
+ tBTA_AG_IND ind;
+ UINT16 num;
+ UINT16 audio_handle;
+ UINT16 errcode; /* Valid only if 'ok_flag' is set to BTA_AG_OK_ERROR */
+ UINT8 ok_flag; /* Indicates if response is finished, and if error occurred */
+ BOOLEAN state;
+} tBTA_AG_RES_DATA;
+
+/* AG callback events */
+#define BTA_AG_ENABLE_EVT 0 /* AG enabled */
+#define BTA_AG_REGISTER_EVT 1 /* AG registered */
+#define BTA_AG_OPEN_EVT 2 /* AG connection open */
+#define BTA_AG_CLOSE_EVT 3 /* AG connection closed */
+#define BTA_AG_CONN_EVT 4 /* Service level connection opened */
+#define BTA_AG_AUDIO_OPEN_EVT 5 /* Audio connection open */
+#define BTA_AG_AUDIO_CLOSE_EVT 6 /* Audio connection closed */
+#define BTA_AG_SPK_EVT 7 /* Speaker volume changed */
+#define BTA_AG_MIC_EVT 8 /* Microphone volume changed */
+#define BTA_AG_AT_CKPD_EVT 9 /* CKPD from the HS */
+#define BTA_AG_DISABLE_EVT 30 /* AG disabled */
+
+/* Values below are for HFP only */
+#define BTA_AG_AT_A_EVT 10 /* Answer a call */
+#define BTA_AG_AT_D_EVT 11 /* Place a call using number or memory dial */
+#define BTA_AG_AT_CHLD_EVT 12 /* Call hold */
+#define BTA_AG_AT_CHUP_EVT 13 /* Hang up a call */
+#define BTA_AG_AT_CIND_EVT 14 /* Read indicator settings */
+#define BTA_AG_AT_VTS_EVT 15 /* Transmit DTMF tone */
+#define BTA_AG_AT_BINP_EVT 16 /* Retrieve number from voice tag */
+#define BTA_AG_AT_BLDN_EVT 17 /* Place call to last dialed number */
+#define BTA_AG_AT_BVRA_EVT 18 /* Enable/disable voice recognition */
+#define BTA_AG_AT_NREC_EVT 19 /* Disable echo canceling */
+#define BTA_AG_AT_CNUM_EVT 20 /* Retrieve subscriber number */
+#define BTA_AG_AT_BTRH_EVT 21 /* CCAP-style incoming call hold */
+#define BTA_AG_AT_CLCC_EVT 22 /* Query list of current calls */
+#define BTA_AG_AT_COPS_EVT 23 /* Query list of current calls */
+#define BTA_AG_AT_UNAT_EVT 24 /* Unknown AT command */
+#define BTA_AG_AT_CBC_EVT 25 /* Battery Level report from HF */
+#define BTA_AG_AT_BAC_EVT 26 /* Codec select */
+#define BTA_AG_AT_BCS_EVT 27 /* Codec select */
+
+typedef UINT8 tBTA_AG_EVT;
+
+/* data associated with most non-AT events */
+typedef struct
+{
+ UINT16 handle;
+ UINT8 app_id;
+} tBTA_AG_HDR;
+
+/* data associated with BTA_AG_REGISTER_EVT */
+typedef struct
+{
+ tBTA_AG_HDR hdr;
+ tBTA_AG_STATUS status;
+} tBTA_AG_REGISTER;
+
+/* data associated with BTA_AG_OPEN_EVT */
+typedef struct
+{
+ tBTA_AG_HDR hdr;
+ BD_ADDR bd_addr;
+ tBTA_SERVICE_ID service_id;
+ tBTA_AG_STATUS status;
+} tBTA_AG_OPEN;
+
+/* data associated with BTA_AG_CONN_EVT */
+typedef struct
+{
+ tBTA_AG_HDR hdr;
+ tBTA_AG_PEER_FEAT peer_feat;
+ tBTA_AG_PEER_CODEC peer_codec;
+} tBTA_AG_CONN;
+
+/* data associated with AT command event */
+typedef struct
+{
+ tBTA_AG_HDR hdr;
+ char str[BTA_AG_AT_MAX_LEN+1];
+ UINT16 num;
+ UINT8 idx; /* call number used by CLCC and CHLD */
+} tBTA_AG_VAL;
+
+/* union of data associated with AG callback */
+typedef union
+{
+ tBTA_AG_HDR hdr;
+ tBTA_AG_REGISTER reg;
+ tBTA_AG_OPEN open;
+ tBTA_AG_CONN conn;
+ tBTA_AG_VAL val;
+} tBTA_AG;
+
+/* AG callback */
+typedef void (tBTA_AG_CBACK)(tBTA_AG_EVT event, tBTA_AG *p_data);
+
+/* indicator constants HFP 1.1 and later */
+#define BTA_AG_IND_CALL 1 /* position of call indicator */
+#define BTA_AG_IND_CALLSETUP 2 /* position of callsetup indicator */
+#define BTA_AG_IND_SERVICE 3 /* position of service indicator */
+
+/* indicator constants HFP 1.5 and later */
+#define BTA_AG_IND_SIGNAL 4 /* position of signal strength indicator */
+#define BTA_AG_IND_ROAM 5 /* position of roaming indicator */
+#define BTA_AG_IND_BATTCHG 6 /* position of battery charge indicator */
+#define BTA_AG_IND_CALLHELD 7 /* position of callheld indicator */
+#define BTA_AG_IND_BEARER 8 /* position of bearer indicator */
+
+/* call indicator values */
+#define BTA_AG_CALL_INACTIVE 0 /* Phone call inactive */
+#define BTA_AG_CALL_ACTIVE 1 /* Phone call active */
+
+/* callsetup indicator values */
+#define BTA_AG_CALLSETUP_NONE 0 /* Not currently in call set up */
+#define BTA_AG_CALLSETUP_INCOMING 1 /* Incoming call process ongoing */
+#define BTA_AG_CALLSETUP_OUTGOING 2 /* Outgoing call set up is ongoing */
+#define BTA_AG_CALLSETUP_ALERTING 3 /* Remote party being alerted in an outgoing call */
+
+/* service indicator values */
+#define BTA_AG_SERVICE_NONE 0 /* Neither CS nor VoIP service is available */
+#define BTA_AG_SERVICE_CS 1 /* Only CS service is available */
+#define BTA_AG_SERVICE_VOIP 2 /* Only VoIP service is available */
+#define BTA_AG_SERVICE_CS_VOIP 3 /* Both CS and VoIP services available */
+
+/* callheld indicator values */
+#define BTA_AG_CALLHELD_INACTIVE 0 /* No held calls */
+#define BTA_AG_CALLHELD_ACTIVE 1 /* Call held and call active */
+#define BTA_AG_CALLHELD_NOACTIVE 2 /* Call held and no call active */
+
+/* signal strength indicator values */
+#define BTA_AG_ROAMING_INACTIVE 0 /* Phone call inactive */
+#define BTA_AG_ROAMING_ACTIVE 1 /* Phone call active */
+
+/* bearer indicator values */
+#define BTA_AG_BEARER_WLAN 0 /* WLAN */
+#define BTA_AG_BEARER_BLUETOOTH 1 /* Bluetooth */
+#define BTA_AG_BEARER_WIRED 2 /* Wired */
+#define BTA_AG_BEARER_2G3G 3 /* 2G 3G */
+#define BTA_AG_BEARER_WIMAX 4 /* WIMAX */
+#define BTA_AG_BEARER_RES1 5 /* Reserved */
+#define BTA_AG_BEARER_RES2 6 /* Reserved */
+#define BTA_AG_BEARER_RES3 7 /* Reserved */
+
+/* AG configuration structure */
+typedef struct
+{
+ char *cind_info;
+ INT32 conn_tout;
+ UINT16 sco_pkt_types;
+ char *chld_val_ecc;
+ char *chld_val;
+} tBTA_AG_CFG;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function BTA_AgEnable
+**
+** Description Enable the audio gateway service. When the enable
+** operation is complete the callback function will be
+** called with a BTA_AG_ENABLE_EVT. This function must
+** be called before other function in the AG API are
+** called.
+**
+** Returns BTA_SUCCESS if OK, BTA_FAILURE otherwise.
+**
+*******************************************************************************/
+BTA_API tBTA_STATUS BTA_AgEnable(tBTA_AG_PARSE_MODE parse_mode, tBTA_AG_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_AgDisable
+**
+** Description Disable the audio gateway service
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AgDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_AgRegister
+**
+** Description Register an Audio Gateway service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AgRegister(tBTA_SERVICE_MASK services, tBTA_SEC sec_mask,
+ tBTA_AG_FEAT features, char *p_service_names[], UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_AgDeregister
+**
+** Description Deregister an audio gateway service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AgDeregister(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BTA_AgOpen
+**
+** Description Opens a connection to a headset or hands-free device.
+** When connection is open callback function is called
+** with a BTA_AG_OPEN_EVT. Only the data connection is
+** opened. The audio connection is not opened.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AgOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask, tBTA_SERVICE_MASK services);
+
+/*******************************************************************************
+**
+** Function BTA_AgClose
+**
+** Description Close the current connection to a headset or a handsfree
+** Any current audio connection will also be closed
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AgClose(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BTA_AgAudioOpen
+**
+** Description Opens an audio connection to the currently connected
+** headset or hnadsfree
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AgAudioOpen(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BTA_AgAudioClose
+**
+** Description Close the currently active audio connection to a headset
+** or hnadsfree. The data connection remains open
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AgAudioClose(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BTA_AgResult
+**
+** Description Send an AT result code to a headset or hands-free device.
+** This function is only used when the AG parse mode is set
+** to BTA_AG_PARSE.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AgResult(UINT16 handle, tBTA_AG_RES result, tBTA_AG_RES_DATA *p_data);
+
+/*******************************************************************************
+**
+** Function BTA_AgSetCodec
+**
+** Description Specify the codec type to be used for the subsequent
+** audio connection.
+**
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_AG_API_H */
+
+
diff --git a/bta/include/bta_ag_ci.h b/bta/include/bta_ag_ci.h
new file mode 100644
index 0000000..5fc5a61
--- /dev/null
+++ b/bta/include/bta_ag_ci.h
@@ -0,0 +1,70 @@
+/*****************************************************************************
+**
+** Name: bta_ag_ci.h
+**
+** Description: This is the interface file for audio gateway call-in
+** functions.
+**
+** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_AG_CI_H
+#define BTA_AG_CI_H
+
+#include "bta_ag_api.h"
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_ag_ci_rx_write
+**
+** Description This function is called to send data to the AG when the AG
+** is configured for AT command pass-through. The function
+** copies data to an event buffer and sends it.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_ag_ci_rx_write(UINT16 handle, char *p_data, UINT16 len);
+
+/******************************************************************************
+**
+** Function bta_ag_ci_slc_ready
+**
+** Description This function is called to notify AG that SLC is up at
+** the application. This funcion is only used when the app
+** is running in pass-through mode.
+**
+** Returns void
+**
+******************************************************************************/
+BTA_API extern void bta_ag_ci_slc_ready(UINT16 handle);
+
+// btla-specific ++
+/******************************************************************************
+**
+** Function bta_ag_ci_wbs_command
+**
+** Description This function is called to notify AG that a WBS command is
+** received
+**
+** Returns void
+**
+******************************************************************************/
+BTA_API extern void bta_ag_ci_wbs_command (UINT16 handle, char *p_data, UINT16 len);
+// btla-specific --
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_AG_CI_H */
+
diff --git a/bta/include/bta_ag_co.h b/bta/include/bta_ag_co.h
new file mode 100644
index 0000000..81927aa
--- /dev/null
+++ b/bta/include/bta_ag_co.h
@@ -0,0 +1,100 @@
+/*****************************************************************************
+**
+** Name: bta_ag_co.h
+**
+** Description: This is the interface file for audio gateway call-out
+** functions.
+**
+** Copyright (c) 2003-2006, Broadcom Corp., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_AG_CO_H
+#define BTA_AG_CO_H
+
+#include "bta_ag_api.h"
+
+/* Definitions for audio state callout function "state" parameter */
+#define BTA_AG_CO_AUD_STATE_OFF 0
+#define BTA_AG_CO_AUD_STATE_OFF_XFER 1 /* Closed pending transfer of audio */
+#define BTA_AG_CO_AUD_STATE_ON 2
+#define BTA_AG_CO_AUD_STATE_SETUP 3
+
+/*******************************************************************************
+**
+** Function bta_ag_co_init
+**
+** Description This callout function is executed by AG when it is
+** started by calling BTA_AgEnable(). This function can be
+** used by the phone to initialize audio paths or for other
+** initialization purposes.
+**
+**
+** Returns Void.
+**
+*******************************************************************************/
+BTA_API extern void bta_ag_co_init(void);
+
+/*******************************************************************************
+**
+** Function bta_ag_co_audio_state
+**
+** Description This function is called by the AG before the audio connection
+** is brought up, after it comes up, and after it goes down.
+**
+** Parameters handle - handle of the AG instance
+** state - Audio state
+** BTA_AG_CO_AUD_STATE_OFF - Audio has been turned off
+** BTA_AG_CO_AUD_STATE_OFF_XFER - Audio is closed pending transfer
+** BTA_AG_CO_AUD_STATE_ON - Audio has been turned on
+** BTA_AG_CO_AUD_STATE_SETUP - Audio is about to be turned on
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_ag_co_audio_state(UINT16 handle, UINT8 app_id, UINT8 state);
+
+/*******************************************************************************
+**
+** Function bta_ag_co_data_open
+**
+** Description This function is executed by AG when a service level connection
+** is opened. The phone can use this function to set
+** up data paths or perform any required initialization or
+** set up particular to the connected service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_ag_co_data_open(UINT16 handle, tBTA_SERVICE_ID service);
+
+/*******************************************************************************
+**
+** Function bta_ag_co_data_close
+**
+** Description This function is called by AG when a service level
+** connection is closed
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_ag_co_data_close(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function bta_ag_co_tx_write
+**
+** Description This function is called by the AG to send data to the
+** phone when the AG is configured for AT command pass-through.
+** The implementation of this function must copy the data to
+** the phone’s memory.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_ag_co_tx_write(UINT16 handle, UINT8 *p_data, UINT16 len);
+
+#endif /* BTA_AG_CO_H */
+
diff --git a/bta/include/bta_api.h b/bta/include/bta_api.h
new file mode 100644
index 0000000..8d7b71b
--- /dev/null
+++ b/bta/include/bta_api.h
@@ -0,0 +1,1712 @@
+/*****************************************************************************
+**
+** Name: bta_api.h
+**
+** Description: This is the public interface file for BTA, Widcomm's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2003-2010, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_API_H
+#define BTA_API_H
+
+#include "data_types.h"
+#include "bt_target.h"
+#include "bt_types.h"
+#include "btm_api.h"
+#include "uipc_msg.h"
+
+#if BLE_INCLUDED == TRUE
+#include "btm_ble_api.h"
+#endif
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* Status Return Value */
+#define BTA_SUCCESS 0 /* Successful operation. */
+#define BTA_FAILURE 1 /* Generic failure. */
+#define BTA_PENDING 2 /* API cannot be completed right now */
+#define BTA_BUSY 3
+#define BTA_NO_RESOURCES 4
+#define BTA_WRONG_MODE 5
+
+typedef UINT8 tBTA_STATUS;
+
+/*
+ * Service ID
+ *
+ * NOTES: When you add a new Service ID for BTA AND require to change the value of BTA_MAX_SERVICE_ID,
+ * make sure that the correct security ID of the new service from Security service definitions (btm_api.h)
+ * should be added to bta_service_id_to_btm_srv_id_lkup_tbl table in bta_dm_act.c.
+ */
+
+#define BTA_RES_SERVICE_ID 0 /* Reserved */
+#define BTA_SPP_SERVICE_ID 1 /* Serial port profile. */
+#define BTA_DUN_SERVICE_ID 2 /* Dial-up networking profile. */
+#define BTA_FAX_SERVICE_ID 3 /* Fax profile. */
+#define BTA_LAP_SERVICE_ID 4 /* LAN access profile. */
+#define BTA_HSP_SERVICE_ID 5 /* Headset profile. */
+#define BTA_HFP_SERVICE_ID 6 /* Hands-free profile. */
+#define BTA_OPP_SERVICE_ID 7 /* Object push */
+#define BTA_FTP_SERVICE_ID 8 /* File transfer */
+#define BTA_CTP_SERVICE_ID 9 /* Cordless Terminal */
+#define BTA_ICP_SERVICE_ID 10 /* Intercom Terminal */
+#define BTA_SYNC_SERVICE_ID 11 /* Synchronization */
+#define BTA_BPP_SERVICE_ID 12 /* Basic printing profile */
+#define BTA_BIP_SERVICE_ID 13 /* Basic Imaging profile */
+#define BTA_PANU_SERVICE_ID 14 /* PAN User */
+#define BTA_NAP_SERVICE_ID 15 /* PAN Network access point */
+#define BTA_GN_SERVICE_ID 16 /* PAN Group Ad-hoc networks */
+#define BTA_SAP_SERVICE_ID 17 /* SIM Access profile */
+#define BTA_A2DP_SERVICE_ID 18 /* Advanced audio distribution */
+#define BTA_AVRCP_SERVICE_ID 19 /* A/V remote control */
+#define BTA_HID_SERVICE_ID 20 /* HID */
+#define BTA_VDP_SERVICE_ID 21 /* Video distribution */
+#define BTA_PBAP_SERVICE_ID 22 /* PhoneBook Access Server*/
+#define BTA_HSP_HS_SERVICE_ID 23 /* HFP HS role */
+#define BTA_HFP_HS_SERVICE_ID 24 /* HSP HS role */
+#define BTA_MAP_SERVICE_ID 25 /* Message Access Profile */
+#define BTA_MN_SERVICE_ID 26 /* Message Notification Service */
+#define BTA_HDP_SERVICE_ID 27 /* Health Device Profile */
+#define BTA_PCE_SERVICE_ID 28 /* PhoneBook Access Client*/
+
+#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
+/* BLE profile service ID */
+#define BTA_BLE_SERVICE_ID 29 /* GATT profile */
+
+// btla-specific ++
+#define BTA_USER_SERVICE_ID 30 /* User requested UUID */
+
+#define BTA_MAX_SERVICE_ID 31
+// btla-specific --
+#else
+#define BTA_USER_SERVICE_ID 29 /* User requested UUID */
+#define BTA_MAX_SERVICE_ID 30
+#endif
+/* service IDs (BTM_SEC_SERVICE_FIRST_EMPTY + 1) to (BTM_SEC_MAX_SERVICES - 1)
+ * are used by BTA JV */
+#define BTA_FIRST_JV_SERVICE_ID (BTM_SEC_SERVICE_FIRST_EMPTY + 1)
+#define BTA_LAST_JV_SERVICE_ID (BTM_SEC_MAX_SERVICES - 1)
+
+typedef UINT8 tBTA_SERVICE_ID;
+
+/* Service ID Mask */
+#define BTA_RES_SERVICE_MASK 0x00000001 /* Reserved */
+#define BTA_SPP_SERVICE_MASK 0x00000002 /* Serial port profile. */
+#define BTA_DUN_SERVICE_MASK 0x00000004 /* Dial-up networking profile. */
+#define BTA_FAX_SERVICE_MASK 0x00000008 /* Fax profile. */
+#define BTA_LAP_SERVICE_MASK 0x00000010 /* LAN access profile. */
+#define BTA_HSP_SERVICE_MASK 0x00000020 /* HSP AG role. */
+#define BTA_HFP_SERVICE_MASK 0x00000040 /* HFP AG role */
+#define BTA_OPP_SERVICE_MASK 0x00000080 /* Object push */
+#define BTA_FTP_SERVICE_MASK 0x00000100 /* File transfer */
+#define BTA_CTP_SERVICE_MASK 0x00000200 /* Cordless Terminal */
+#define BTA_ICP_SERVICE_MASK 0x00000400 /* Intercom Terminal */
+#define BTA_SYNC_SERVICE_MASK 0x00000800 /* Synchronization */
+#define BTA_BPP_SERVICE_MASK 0x00001000 /* Print server */
+#define BTA_BIP_SERVICE_MASK 0x00002000 /* Basic Imaging */
+#define BTA_PANU_SERVICE_MASK 0x00004000 /* PAN User */
+#define BTA_NAP_SERVICE_MASK 0x00008000 /* PAN Network access point */
+#define BTA_GN_SERVICE_MASK 0x00010000 /* PAN Group Ad-hoc networks */
+#define BTA_SAP_SERVICE_MASK 0x00020000 /* PAN Group Ad-hoc networks */
+#define BTA_A2DP_SERVICE_MASK 0x00040000 /* Advanced audio distribution */
+#define BTA_AVRCP_SERVICE_MASK 0x00080000 /* A/V remote control */
+#define BTA_HID_SERVICE_MASK 0x00100000 /* HID */
+#define BTA_VDP_SERVICE_MASK 0x00200000 /* Video distribution */
+#define BTA_PBAP_SERVICE_MASK 0x00400000 /* Phone Book Server */
+#define BTA_HSP_HS_SERVICE_MASK 0x00800000 /* HFP HS role */
+#define BTA_HFP_HS_SERVICE_MASK 0x01000000 /* HSP HS role */
+#define BTA_MAS_SERVICE_MASK 0x02000000 /* Message Access Profile */
+#define BTA_MN_SERVICE_MASK 0x04000000 /* Message Notification Profile */
+#define BTA_HL_SERVICE_MASK 0x08000000 /* Health Device Profile */
+#define BTA_PCE_SERVICE_MASK 0x10000000 /* Phone Book Client */
+
+#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
+#define BTA_BLE_SERVICE_MASK 0x20000000 /* GATT based service */
+// btla-specific ++
+#define BTA_USER_SERVICE_MASK 0x40000000 /* Message Notification Profile */
+// btla-specific --
+#else
+// btla-specific ++
+#define BTA_USER_SERVICE_MASK 0x20000000 /* Message Notification Profile */
+// btla-specific --
+#endif
+
+#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
+#define BTA_ALL_SERVICE_MASK 0x3FFFFFFF /* All services supported by BTA. */
+#else
+#define BTA_ALL_SERVICE_MASK 0x1FFFFFFF /* All services supported by BTA. */
+#endif
+
+typedef UINT32 tBTA_SERVICE_MASK;
+
+/* extended service mask, including mask with one or more GATT UUID */
+typedef struct
+{
+ tBTA_SERVICE_MASK srvc_mask;
+ UINT8 num_uuid;
+ tBT_UUID *p_uuid;
+}tBTA_SERVICE_MASK_EXT;
+
+/* Security Setting Mask */
+#define BTA_SEC_NONE BTM_SEC_NONE /* No security. */
+#define BTA_SEC_AUTHORIZE (BTM_SEC_IN_AUTHORIZE ) /* Authorization required (only needed for out going connection )*/
+#define BTA_SEC_AUTHENTICATE (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_OUT_AUTHENTICATE) /* Authentication required. */
+#define BTA_SEC_ENCRYPT (BTM_SEC_IN_ENCRYPT | BTM_SEC_OUT_ENCRYPT) /* Encryption required. */
+
+typedef UINT8 tBTA_SEC;
+
+/* Ignore for Discoverable, Connectable, Pairable and Connectable Paired only device modes */
+
+#define BTA_DM_IGNORE 0xFF
+
+
+/* Discoverable Modes */
+#define BTA_DM_NON_DISC BTM_NON_DISCOVERABLE /* Device is not discoverable. */
+#define BTA_DM_GENERAL_DISC BTM_GENERAL_DISCOVERABLE /* General discoverable. */
+#define BTA_DM_LIMITED_DISC BTM_LIMITED_DISCOVERABLE /* Limited discoverable. */
+
+// btla-specific ++
+typedef UINT16 tBTA_DM_DISC;
+// btla-specific --
+
+/* Connectable Modes */
+#define BTA_DM_NON_CONN BTM_NON_CONNECTABLE /* Device is not connectable. */
+#define BTA_DM_CONN BTM_CONNECTABLE /* Device is connectable. */
+
+// btla-specific ++
+typedef UINT16 tBTA_DM_CONN;
+// btla-specific --
+
+/* Pairable Modes */
+#define BTA_DM_PAIRABLE 1
+#define BTA_DM_NON_PAIRABLE 0
+
+/* Connectable Paired Only Mode */
+#define BTA_DM_CONN_ALL 0
+#define BTA_DM_CONN_PAIRED 1
+
+/* Inquiry Modes */
+#define BTA_DM_GENERAL_INQUIRY BTM_GENERAL_INQUIRY /* Perform general inquiry. */
+#define BTA_DM_LIMITED_INQUIRY BTM_LIMITED_INQUIRY /* Perform limited inquiry. */
+
+#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
+#define BTA_BLE_INQUIRY_NONE BTM_BLE_INQUIRY_NONE
+#define BTA_BLE_GENERAL_INQUIRY BTM_BLE_GENERAL_INQUIRY /* Perform LE general inquiry. */
+#define BTA_BLE_LIMITED_INQUIRY BTM_BLE_LIMITED_INQUIRY /* Perform LE limited inquiry. */
+#endif
+typedef UINT8 tBTA_DM_INQ_MODE;
+
+/* Inquiry Filter Type */
+#define BTA_DM_INQ_CLR BTM_CLR_INQUIRY_FILTER /* Clear inquiry filter. */
+#define BTA_DM_INQ_DEV_CLASS BTM_FILTER_COND_DEVICE_CLASS /* Filter on device class. */
+#define BTA_DM_INQ_BD_ADDR BTM_FILTER_COND_BD_ADDR /* Filter on a specific BD address. */
+
+typedef UINT8 tBTA_DM_INQ_FILT;
+
+/* Authorize Response */
+#define BTA_DM_AUTH_PERM 0 /* Authorized for future connections to the service */
+#define BTA_DM_AUTH_TEMP 1 /* Authorized for current connection only */
+#define BTA_DM_NOT_AUTH 2 /* Not authorized for the service */
+
+typedef UINT8 tBTA_AUTH_RESP;
+
+/* M/S preferred roles */
+#define BTA_ANY_ROLE 0x00
+#define BTA_MASTER_ROLE_PREF 0x01
+#define BTA_MASTER_ROLE_ONLY 0x02
+
+typedef UINT8 tBTA_PREF_ROLES;
+
+enum
+{
+
+ BTA_DM_NO_SCATTERNET, /* Device doesn't support scatternet, it might
+ support "role switch during connection" for
+ an incoming connection, when it already has
+ another connection in master role */
+ BTA_DM_PARTIAL_SCATTERNET, /* Device supports partial scatternet. It can have
+ simulateous connection in Master and Slave roles
+ for short period of time */
+ BTA_DM_FULL_SCATTERNET /* Device can have simultaneous connection in master
+ and slave roles */
+
+};
+
+
+/* Inquiry filter device class condition */
+typedef struct
+{
+ DEV_CLASS dev_class; /* device class of interest */
+ DEV_CLASS dev_class_mask; /* mask to determine the bits of device class of interest */
+} tBTA_DM_COD_COND;
+
+
+/* Inquiry Filter Condition */
+typedef union
+{
+ BD_ADDR bd_addr; /* BD address of device to filter. */
+ tBTA_DM_COD_COND dev_class_cond; /* Device class filter condition */
+} tBTA_DM_INQ_COND;
+
+/* Inquiry Parameters */
+typedef struct
+{
+ tBTA_DM_INQ_MODE mode; /* Inquiry mode, limited or general. */
+ UINT8 duration; /* Inquiry duration in 1.28 sec units. */
+ UINT8 max_resps; /* Maximum inquiry responses. Set to zero for unlimited responses. */
+ BOOLEAN report_dup; /* report duplicated inquiry response with higher RSSI value */
+ tBTA_DM_INQ_FILT filter_type; /* Filter condition type. */
+ tBTA_DM_INQ_COND filter_cond; /* Filter condition data. */
+} tBTA_DM_INQ;
+
+typedef struct
+{
+ UINT8 bta_dm_eir_min_name_len; /* minimum length of local name when it is shortened */
+#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
+ UINT8 bta_dm_eir_uuid16_len; /* length of 16-bit UUIDs */
+ UINT8 *bta_dm_eir_uuid16; /* 16-bit UUIDs */
+#else
+ UINT32 uuid_mask[BTM_EIR_SERVICE_ARRAY_SIZE]; /* mask of UUID list in EIR */
+#endif
+ INT8 *bta_dm_eir_inq_tx_power; /* Inquiry TX power */
+ UINT8 bta_dm_eir_flag_len; /* length of flags in bytes */
+ UINT8 *bta_dm_eir_flags; /* flags for EIR */
+ UINT8 bta_dm_eir_manufac_spec_len; /* length of manufacturer specific in bytes */
+ UINT8 *bta_dm_eir_manufac_spec; /* manufacturer specific */
+} tBTA_DM_EIR_CONF;
+
+#if BLE_INCLUDED == TRUE
+/* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */
+#define BTA_BLE_LIMIT_DISC_FLAG BTM_BLE_LIMIT_DISC_FLAG
+#define BTA_BLE_GEN_DISC_FLAG BTM_BLE_GEN_DISC_FLAG
+#define BTA_BLE_BREDR_NOT_SPT BTM_BLE_BREDR_NOT_SPT
+#define BTA_BLE_NON_LIMIT_DISC_FLAG BTM_BLE_NON_LIMIT_DISC_FLAG
+#define BTA_BLE_ADV_FLAG_MASK BTM_BLE_ADV_FLAG_MASK
+#define BTA_BLE_LIMIT_DISC_MASK BTM_BLE_LIMIT_DISC_MASK
+
+#define BTA_BLE_AD_BIT_DEV_NAME BTM_BLE_AD_BIT_DEV_NAME
+#define BTA_BLE_AD_BIT_FLAGS BTM_BLE_AD_BIT_FLAGS
+#define BTA_BLE_AD_BIT_MANU BTM_BLE_AD_BIT_MANU
+#define BTA_BLE_AD_BIT_TX_PWR BTM_BLE_AD_BIT_TX_PWR
+#define BTA_BLE_AD_BIT_ATTR BTM_BLE_AD_BIT_ATTR
+#define BTA_BLE_AD_BIT_INT_RANGE BTM_BLE_AD_BIT_INT_RANGE
+#define BTA_BLE_AD_BIT_SERVICE BTM_BLE_AD_BIT_SERVICE
+#define BTA_BLE_AD_BIT_SERVICE_SOL BTM_BLE_AD_BIT_SERVICE_SOL
+#define BTA_BLE_AD_BIT_SERVICE_DATA BTM_BLE_AD_BIT_SERVICE_DATA
+#define BTA_BLE_AD_BIT_SIGN_DATA BTM_BLE_AD_BIT_SIGN_DATA
+typedef UINT16 tBTA_BLE_AD_MASK;
+
+/* slave preferred connection interval range */
+typedef struct
+{
+ UINT16 low;
+ UINT16 hi;
+
+}tBTA_BLE_INT_RANGE;
+
+/* Service tag supported in the device */
+typedef struct
+{
+ UINT8 num_service;
+ BOOLEAN list_cmpl;
+ UINT16 *p_uuid;
+}tBTA_BLE_SERVICE;
+
+/* attribute data */
+typedef struct
+{
+ UINT16 uuid;
+ UINT16 data_len;
+ UINT8 *p_data;
+}tBTA_BLE_ATTR;
+
+#define BTA_BLE_NUM_AD_ATTR_MAX BTM_BLE_NUM_AD_ATTR_MAX
+
+/* attribute list contained in adv data */
+typedef struct
+{
+ UINT8 num_attr;
+ tBTA_BLE_ATTR attr_list[BTA_BLE_NUM_AD_ATTR_MAX];
+}tBTA_BLE_ATTR_DATA;
+
+typedef struct
+{
+ UINT8 len;
+ UINT8 *p_val;
+}tBTA_BLE_MANU;
+
+typedef struct
+{
+ tBTA_BLE_MANU manu; /* manufactuer data */
+ tBTA_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
+ tBTA_BLE_SERVICE services; /* services */
+ tBTA_BLE_ATTR_DATA attr; /* attribute data */
+ UINT8 flag;
+}tBTA_BLE_ADV_DATA;
+
+/* These are the fields returned in each device adv packet. It
+** is returned in the results callback if registered.
+*/
+typedef struct
+{
+ UINT8 conn_mode;
+ tBTA_BLE_AD_MASK ad_mask; /* mask of the valid adv data field */
+ UINT8 flag;
+ UINT8 tx_power_level;
+ UINT8 remote_name_len;
+ UINT8 *p_remote_name;
+ tBTA_BLE_ATTR_DATA attr_data;
+ tBTA_BLE_SERVICE service;
+} tBTA_BLE_INQ_DATA;
+#endif
+
+typedef INT8 tBTA_DM_RSSI_VALUE;
+typedef UINT8 tBTA_DM_LINK_QUALITY_VALUE;
+
+
+/* signal strength mask */
+#define BTA_SIG_STRENGTH_RSSI_MASK 1
+#define BTA_SIG_STRENGTH_LINK_QUALITY_MASK 2
+
+typedef UINT8 tBTA_SIG_STRENGTH_MASK;
+
+
+/* Security Callback Events */
+#define BTA_DM_ENABLE_EVT 0 /* Enable Event */
+#define BTA_DM_DISABLE_EVT 1 /* Disable Event */
+#define BTA_DM_PIN_REQ_EVT 2 /* PIN request. */
+#define BTA_DM_AUTH_CMPL_EVT 3 /* Authentication complete indication. */
+#define BTA_DM_AUTHORIZE_EVT 4 /* Authorization request. */
+#define BTA_DM_LINK_UP_EVT 5 /* Connection UP event */
+#define BTA_DM_LINK_DOWN_EVT 6 /* Connection DOWN event */
+#define BTA_DM_SIG_STRENGTH_EVT 7 /* Signal strength for bluetooth connection */
+#define BTA_DM_BUSY_LEVEL_EVT 8 /* System busy level */
+#define BTA_DM_BOND_CANCEL_CMPL_EVT 9 /* Bond cancel complete indication */
+#define BTA_DM_SP_CFM_REQ_EVT 10 /* Simple Pairing User Confirmation request. */
+#define BTA_DM_SP_KEY_NOTIF_EVT 11 /* Simple Pairing Passkey Notification */
+#define BTA_DM_SP_RMT_OOB_EVT 12 /* Simple Pairing Remote OOB Data request. */
+#define BTA_DM_SP_KEYPRESS_EVT 13 /* Key press notification event. */
+#define BTA_DM_ROLE_CHG_EVT 14 /* Role Change event. */
+#define BTA_DM_BLE_KEY_EVT 15 /* BLE SMP key event for peer device keys */
+#define BTA_DM_BLE_SEC_REQ_EVT 16 /* BLE SMP security request */
+#define BTA_DM_BLE_PASSKEY_NOTIF_EVT 17 /* SMP passkey notification event */
+#define BTA_DM_BLE_PASSKEY_REQ_EVT 18 /* SMP passkey request event */
+#define BTA_DM_BLE_OOB_REQ_EVT 19 /* SMP OOB request event */
+#define BTA_DM_BLE_LOCAL_IR_EVT 20 /* BLE local IR event */
+#define BTA_DM_BLE_LOCAL_ER_EVT 21 /* BLE local ER event */
+// btla-specific ++
+#define BTA_DM_BLE_AUTH_CMPL_EVT 22 /* BLE Auth complete */
+// btla-specific --
+
+typedef UINT8 tBTA_DM_SEC_EVT;
+
+/* Structure associated with BTA_DM_ENABLE_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address of local device. */
+ tBTA_STATUS status;
+} tBTA_DM_ENABLE;
+
+/* Structure associated with BTA_DM_PIN_REQ_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ BD_NAME bd_name; /* Name of peer device. */
+ DEV_CLASS dev_class; /* Class of Device */
+} tBTA_DM_PIN_REQ;
+
+/* BLE related definition */
+
+#define BTA_DM_AUTH_FAIL_BASE (HCI_ERR_MAX_ERR + 10)
+#define BTA_DM_AUTH_CONVERT_SMP_CODE(x) (BTA_DM_AUTH_FAIL_BASE + (x))
+#define BTA_DM_AUTH_SMP_PASSKEY_FAIL BTA_DM_AUTH_CONVERT_SMP_CODE (SMP_PASSKEY_ENTRY_FAIL)
+#define BTA_DM_AUTH_SMP_OOB_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_OOB_FAIL)
+#define BTA_DM_AUTH_SMP_PAIR_AUTH_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_AUTH_FAIL)
+#define BTA_DM_AUTH_SMP_CONFIRM_VALUE_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_VALUE_ERR)
+#define BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_NOT_SUPPORT)
+#define BTA_DM_AUTH_SMP_ENC_KEY_SIZE (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_KEY_SIZE)
+#define BTA_DM_AUTH_SMP_INVALID_CMD (BTA_DM_AUTH_FAIL_BASE + SMP_INVALID_CMD)
+#define BTA_DM_AUTH_SMP_UNKNOWN_ERR (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_FAIL_UNKNOWN)
+#define BTA_DM_AUTH_SMP_REPEATED_ATTEMPT (BTA_DM_AUTH_FAIL_BASE + SMP_REPEATED_ATTEMPTS)
+#define BTA_DM_AUTH_SMP_INTERNAL_ERR (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_INTERNAL_ERR)
+#define BTA_DM_AUTH_SMP_UNKNOWN_IO (BTA_DM_AUTH_FAIL_BASE + SMP_UNKNOWN_IO_CAP)
+#define BTA_DM_AUTH_SMP_INIT_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_INIT_FAIL)
+#define BTA_DM_AUTH_SMP_CONFIRM_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_FAIL)
+#define BTA_DM_AUTH_SMP_BUSY (BTA_DM_AUTH_FAIL_BASE + SMP_BUSY)
+#define BTA_DM_AUTH_SMP_ENC_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_FAIL)
+#define BTA_DM_AUTH_SMP_RSP_TIMEOUT (BTA_DM_AUTH_FAIL_BASE + SMP_RSP_TIMEOUT)
+
+/* connection parameter boundary value and dummy value */
+#define BTA_DM_BLE_SCAN_INT_MIN BTM_BLE_SCAN_INT_MIN
+#define BTA_DM_BLE_SCAN_INT_MAX BTM_BLE_SCAN_INT_MAX
+#define BTA_DM_BLE_SCAN_WIN_MIN BTM_BLE_SCAN_WIN_MIN
+#define BTA_DM_BLE_SCAN_WIN_MAX BTM_BLE_SCAN_WIN_MAX
+#define BTA_DM_BLE_CONN_INT_MIN BTM_BLE_CONN_INT_MIN
+#define BTA_DM_BLE_CONN_INT_MAX BTM_BLE_CONN_INT_MAX
+#define BTA_DM_BLE_CONN_LATENCY_MAX BTM_BLE_CONN_LATENCY_MAX
+#define BTA_DM_BLE_CONN_SUP_TOUT_MIN BTM_BLE_CONN_SUP_TOUT_MIN
+#define BTA_DM_BLE_CONN_SUP_TOUT_MAX BTM_BLE_CONN_SUP_TOUT_MAX
+#define BTA_DM_BLE_CONN_PARAM_UNDEF BTM_BLE_CONN_PARAM_UNDEF /* use this value when a specific value not to be overwritten */
+
+
+#define BTA_LE_KEY_PENC BTM_LE_KEY_PENC /* encryption information of peer device */
+#define BTA_LE_KEY_PID BTM_LE_KEY_PID /* identity key of the peer device */
+#define BTA_LE_KEY_PCSRK BTM_LE_KEY_PCSRK /* peer SRK */
+#define BTA_LE_KEY_LENC BTM_LE_KEY_LENC /* master role security information:div */
+#define BTA_LE_KEY_LID BTM_LE_KEY_LID /* master device ID key */
+#define BTA_LE_KEY_LCSRK BTM_LE_KEY_LCSRK /* local CSRK has been deliver to peer */
+typedef UINT8 tBTA_LE_KEY_TYPE; /* can be used as a bit mask */
+
+
+typedef tBTM_LE_PENC_KEYS tBTA_LE_PENC_KEYS ;
+typedef tBTM_LE_PCSRK_KEYS tBTA_LE_PCSRK_KEYS;
+typedef tBTM_LE_LENC_KEYS tBTA_LE_LENC_KEYS ;
+typedef tBTM_LE_LCSRK_KEYS tBTA_LE_LCSRK_KEYS ;
+
+typedef union
+{
+ tBTA_LE_PENC_KEYS penc_key; /* received peer encryption key */
+ tBTA_LE_PCSRK_KEYS psrk_key; /* received peer device SRK */
+ BT_OCTET16 pid_key; /* peer device ID key */
+ tBTA_LE_LENC_KEYS lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
+ tBTA_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
+}tBTA_LE_KEY_VALUE;
+
+#define BTA_BLE_LOCAL_KEY_TYPE_ID 1
+#define BTA_BLE_LOCAL_KEY_TYPE_ER 2
+typedef UINT8 tBTA_DM_BLE_LOCAL_KEY_MASK;
+
+typedef struct
+{
+ BT_OCTET16 ir;
+ BT_OCTET16 irk;
+ BT_OCTET16 dhk;
+}tBTA_BLE_LOCAL_ID_KEYS;
+
+#define BTA_DM_SEC_GRANTED BTA_SUCCESS
+#define BTA_DM_SEC_PAIR_NOT_SPT BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT
+#define BTA_DM_SEC_REP_ATTEMPTS BTA_DM_AUTH_SMP_REPEATED_ATTEMPT
+typedef UINT8 tBTA_DM_BLE_SEC_GRANT;
+
+
+#define BTA_DM_BLE_ONN_NONE BTM_BLE_CONN_NONE
+#define BTA_DM_BLE_CONN_AUTO BTM_BLE_CONN_AUTO
+#define BTA_DM_BLE_CONN_SELECTIVE BTM_BLE_CONN_SELECTIVE
+typedef UINT8 tBTA_DM_BLE_CONN_TYPE;
+
+typedef BOOLEAN (tBTA_DM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
+
+/* Structure associated with BTA_DM_BLE_SEC_REQ_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* peer address */
+ BD_NAME bd_name; /* peer device name */
+} tBTA_DM_BLE_SEC_REQ;
+
+typedef struct
+{
+ BD_ADDR bd_addr; /* peer address */
+ tBTM_LE_KEY_TYPE key_type;
+ tBTM_LE_KEY_VALUE key_value;
+}tBTA_DM_BLE_KEY;
+
+/* Structure associated with BTA_DM_AUTH_CMPL_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ BD_NAME bd_name; /* Name of peer device. */
+ BOOLEAN key_present; /* Valid link key value in key element */
+ LINK_KEY key; /* Link key associated with peer device. */
+ UINT8 key_type; /* The type of Link Key */
+ BOOLEAN success; /* TRUE of authentication succeeded, FALSE if failed. */
+ UINT8 fail_reason; /* The HCI reason/error code for when success=FALSE */
+
+} tBTA_DM_AUTH_CMPL;
+
+
+/* Structure associated with BTA_DM_AUTHORIZE_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ BD_NAME bd_name; /* Name of peer device. */
+ tBTA_SERVICE_ID service; /* Service ID to authorize. */
+// btla-specific ++
+ DEV_CLASS dev_class;
+// btla-specific --
+} tBTA_DM_AUTHORIZE;
+
+/* Structure associated with BTA_DM_LINK_UP_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+} tBTA_DM_LINK_UP;
+
+/* Structure associated with BTA_DM_LINK_DOWN_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ UINT8 status; /* connection open/closed */
+} tBTA_DM_LINK_DOWN;
+
+/* Structure associated with BTA_DM_ROLE_CHG_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ UINT8 new_role; /* the new connection role */
+} tBTA_DM_ROLE_CHG;
+
+/* Structure associated with BTA_DM_SIG_STRENGTH_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ tBTA_SIG_STRENGTH_MASK mask; /* mask for the values that are valid */
+ tBTA_DM_RSSI_VALUE rssi_value;
+ tBTA_DM_LINK_QUALITY_VALUE link_quality_value;
+
+} tBTA_DM_SIG_STRENGTH;
+
+/* Structure associated with BTA_DM_BUSY_LEVEL_EVT */
+typedef struct
+{
+ UINT8 level; /* when paging or inquiring, level is 10.
+ Otherwise, the number of ACL links */
+} tBTA_DM_BUSY_LEVEL;
+
+#define BTA_IO_CAP_OUT BTM_IO_CAP_OUT /* DisplayOnly */
+#define BTA_IO_CAP_IO BTM_IO_CAP_IO /* DisplayYesNo */
+#define BTA_IO_CAP_IN BTM_IO_CAP_IN /* KeyboardOnly */
+#define BTA_IO_CAP_NONE BTM_IO_CAP_NONE /* NoInputNoOutput */
+typedef tBTM_IO_CAP tBTA_IO_CAP;
+
+#define BTA_AUTH_SP_NO BTM_AUTH_SP_NO /* 0 MITM Protection Not Required - Single Profile/non-bonding
+ Numeric comparison with automatic accept allowed */
+#define BTA_AUTH_SP_YES BTM_AUTH_SP_YES /* 1 MITM Protection Required - Single Profile/non-bonding
+ Use IO Capabilities to determine authentication procedure */
+#define BTA_AUTH_AP_NO BTM_AUTH_AP_NO /* 2 MITM Protection Not Required - All Profiles/dedicated bonding
+ Numeric comparison with automatic accept allowed */
+#define BTA_AUTH_AP_YES BTM_AUTH_AP_YES /* 3 MITM Protection Required - All Profiles/dedicated bonding
+ Use IO Capabilities to determine authentication procedure */
+#define BTA_AUTH_SPGB_NO BTM_AUTH_SPGB_NO /* 4 MITM Protection Not Required - Single Profiles/general bonding
+ Numeric comparison with automatic accept allowed */
+#define BTA_AUTH_SPGB_YES BTM_AUTH_SPGB_YES /* 5 MITM Protection Required - Single Profiles/general bonding
+ Use IO Capabilities to determine authentication procedure */
+typedef tBTM_AUTH_REQ tBTA_AUTH_REQ;
+
+#define BTA_AUTH_DD_BOND BTM_AUTH_DD_BOND /* 2 this bit is set for dedicated bonding */
+#define BTA_AUTH_GEN_BOND BTM_AUTH_SPGB_NO /* 4 this bit is set for general bonding */
+#define BTA_AUTH_BONDS BTM_AUTH_BONDS /* 6 the general/dedicated bonding bits */
+
+#define BTA_LE_AUTH_NO_BOND BTM_LE_AUTH_REQ_NO_BOND /* 0*/
+#define BTA_LE_AUTH_BOND BTM_LE_AUTH_REQ_BOND /* 1 << 0 */
+#define BTA_LE_AUTH_REQ_MITM BTM_LE_AUTH_REQ_MITM /* 1 << 2 */
+typedef tBTM_LE_AUTH_REQ tBTA_LE_AUTH_REQ; /* combination of the above bit pattern */
+
+#define BTA_OOB_NONE BTM_OOB_NONE
+#define BTA_OOB_PRESENT BTM_OOB_PRESENT
+#if BTM_OOB_INCLUDED == TRUE
+#define BTA_OOB_UNKNOWN BTM_OOB_UNKNOWN
+#endif
+typedef tBTM_OOB_DATA tBTA_OOB_DATA;
+
+/* Structure associated with BTA_DM_SP_CFM_REQ_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* peer address */
+ DEV_CLASS dev_class; /* peer CoD */
+ BD_NAME bd_name; /* peer device name */
+ UINT32 num_val; /* the numeric value for comparison. If just_works, do not show this number to UI */
+ BOOLEAN just_works; /* TRUE, if "Just Works" association model */
+ tBTA_AUTH_REQ loc_auth_req; /* Authentication required for local device */
+ tBTA_AUTH_REQ rmt_auth_req; /* Authentication required for peer device */
+} tBTA_DM_SP_CFM_REQ;
+
+enum
+{
+ BTA_SP_KEY_STARTED, /* passkey entry started */
+ BTA_SP_KEY_ENTERED, /* passkey digit entered */
+ BTA_SP_KEY_ERASED, /* passkey digit erased */
+ BTA_SP_KEY_CLEARED, /* passkey cleared */
+ BTA_SP_KEY_COMPLT /* passkey entry completed */
+};
+typedef UINT8 tBTA_SP_KEY_TYPE;
+
+/* Structure associated with BTA_DM_SP_KEYPRESS_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* peer address */
+ tBTA_SP_KEY_TYPE notif_type;
+}tBTA_DM_SP_KEY_PRESS;
+
+/* Structure associated with BTA_DM_SP_KEY_NOTIF_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* peer address */
+ DEV_CLASS dev_class; /* peer CoD */
+ BD_NAME bd_name; /* peer device name */
+ UINT32 passkey; /* the numeric value for comparison. If just_works, do not show this number to UI */
+} tBTA_DM_SP_KEY_NOTIF;
+
+/* Structure associated with BTA_DM_SP_RMT_OOB_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* peer address */
+ DEV_CLASS dev_class; /* peer CoD */
+ BD_NAME bd_name; /* peer device name */
+} tBTA_DM_SP_RMT_OOB;
+
+/* Structure associated with BTA_DM_BOND_CANCEL_CMPL_EVT */
+typedef struct
+{
+ tBTA_STATUS result; /* TRUE of bond cancel succeeded, FALSE if failed. */
+} tBTA_DM_BOND_CANCEL_CMPL;
+
+/* Union of all security callback structures */
+typedef union
+{
+ tBTA_DM_ENABLE enable; /* BTA enabled */
+ tBTA_DM_PIN_REQ pin_req; /* PIN request. */
+ tBTA_DM_AUTH_CMPL auth_cmpl; /* Authentication complete indication. */
+ tBTA_DM_AUTHORIZE authorize; /* Authorization request. */
+ tBTA_DM_LINK_UP link_up; /* ACL connection down event */
+ tBTA_DM_LINK_DOWN link_down; /* ACL connection down event */
+ tBTA_DM_SIG_STRENGTH sig_strength; /* rssi and link quality value */
+ tBTA_DM_BUSY_LEVEL busy_level; /* System busy level */
+ tBTA_DM_SP_CFM_REQ cfm_req; /* user confirm request */
+ tBTA_DM_SP_KEY_NOTIF key_notif; /* passkey notification */
+ tBTA_DM_SP_RMT_OOB rmt_oob; /* remote oob */
+ tBTA_DM_BOND_CANCEL_CMPL bond_cancel_cmpl; /* Bond Cancel Complete indication */
+ tBTA_DM_SP_KEY_PRESS key_press; /* key press notification event */
+ tBTA_DM_ROLE_CHG role_chg; /* role change event */
+ tBTA_DM_BLE_SEC_REQ ble_req; /* BLE SMP related request */
+ tBTA_DM_BLE_KEY ble_key; /* BLE SMP keys used when pairing */
+ tBTA_BLE_LOCAL_ID_KEYS ble_id_keys; /* IR event */
+ BT_OCTET16 ble_er; /* ER event data */
+} tBTA_DM_SEC;
+
+/* Security callback */
+typedef void (tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data);
+
+/* Vendor Specific Command Callback */
+typedef tBTM_VSC_CMPL_CB tBTA_VENDOR_CMPL_CBACK;
+
+/* Search callback events */
+#define BTA_DM_INQ_RES_EVT 0 /* Inquiry result for a peer device. */
+#define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */
+#define BTA_DM_DISC_RES_EVT 2 /* Discovery result for a peer device. */
+#define BTA_DM_DISC_BLE_RES_EVT 3 /* Discovery result for BLE GATT based servoce on a peer device. */
+#define BTA_DM_DISC_CMPL_EVT 4 /* Discovery complete. */
+#define BTA_DM_DI_DISC_CMPL_EVT 5 /* Discovery complete. */
+#define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
+
+typedef UINT8 tBTA_DM_SEARCH_EVT;
+
+#define BTA_DM_INQ_RES_IGNORE_RSSI BTM_INQ_RES_IGNORE_RSSI /* 0x7f RSSI value not supplied (ignore it) */
+
+/* Structure associated with BTA_DM_INQ_RES_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ DEV_CLASS dev_class; /* Device class of peer device. */
+ BOOLEAN remt_name_not_required; /* Application sets this flag if it already knows the name of the device */
+ /* If the device name is known to application BTA skips the remote name request */
+ BOOLEAN is_limited; /* TRUE, if the limited inquiry bit is set in the CoD */
+ INT8 rssi; /* The rssi value */
+ UINT8 *p_eir; /* received EIR */
+#if (BLE_INCLUDED == TRUE)
+ UINT8 inq_result_type;
+ UINT8 ble_addr_type;
+ tBTM_BLE_EVT_TYPE ble_evt_type;
+ tBT_DEVICE_TYPE device_type;
+#endif
+
+} tBTA_DM_INQ_RES;
+
+/* Structure associated with BTA_DM_INQ_CMPL_EVT */
+typedef struct
+{
+ UINT8 num_resps; /* Number of inquiry responses. */
+} tBTA_DM_INQ_CMPL;
+
+/* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ UINT8 num_record; /* Number of DI record */
+ tBTA_STATUS result;
+} tBTA_DM_DI_DISC_CMPL;
+
+/* Structure associated with BTA_DM_DISC_RES_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ BD_NAME bd_name; /* Name of peer device. */
+ tBTA_SERVICE_MASK services; /* Services found on peer device. */
+// btla-specific ++
+ UINT8 * p_raw_data; /* Raw data for discovery DB */
+ UINT32 raw_data_size; /* size of raw data */
+ tBT_DEVICE_TYPE device_type; /* device type in case it is BLE device */
+// btla-specific --
+ tBTA_STATUS result;
+} tBTA_DM_DISC_RES;
+
+/* Structure associated with tBTA_DM_DISC_BLE_RES */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address peer device. */
+ BD_NAME bd_name; /* Name of peer device. */
+ tBT_UUID service; /* GATT based Services UUID found on peer device. */
+} tBTA_DM_DISC_BLE_RES;
+
+
+/* Union of all search callback structures */
+typedef union
+{
+ tBTA_DM_INQ_RES inq_res; /* Inquiry result for a peer device. */
+ tBTA_DM_INQ_CMPL inq_cmpl; /* Inquiry complete. */
+ tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
+ tBTA_DM_DISC_BLE_RES disc_ble_res; /* discovery result for GATT based service */
+ tBTA_DM_DI_DISC_CMPL di_disc; /* DI discovery result for a peer device */
+
+} tBTA_DM_SEARCH;
+
+/* Search callback */
+typedef void (tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data);
+
+/* Execute call back */
+typedef void (tBTA_DM_EXEC_CBACK) (void * p_param);
+
+/* Encryption callback*/
+typedef void (tBTA_DM_ENCRYPT_CBACK) (BD_ADDR bd_addr, tBTA_STATUS result);
+
+#if BLE_INCLUDED == TRUE
+#define BTA_DM_BLE_SEC_NONE BTM_BLE_SEC_NONE
+#define BTA_DM_BLE_SEC_ENCRYPT BTM_BLE_SEC_ENCRYPT
+#define BTA_DM_BLE_SEC_NO_MITM BTM_BLE_SEC_ENCRYPT_NO_MITM
+#define BTA_DM_BLE_SEC_MITM BTM_BLE_SEC_ENCRYPT_MITM
+typedef tBTM_BLE_SEC_ACT tBTA_DM_BLE_SEC_ACT;
+#else
+typedef UINT8 tBTA_DM_BLE_SEC_ACT;
+#endif
+
+/* Maximum service name length */
+#define BTA_SERVICE_NAME_LEN 35
+#define BTA_SERVICE_DESP_LEN BTA_SERVICE_NAME_LEN
+#define BTA_PROVIDER_NAME_LEN BTA_SERVICE_NAME_LEN
+
+
+/* link policy masks */
+#define BTA_DM_LP_SWITCH HCI_ENABLE_MASTER_SLAVE_SWITCH
+#define BTA_DM_LP_HOLD HCI_ENABLE_HOLD_MODE
+#define BTA_DM_LP_SNIFF HCI_ENABLE_SNIFF_MODE
+#define BTA_DM_LP_PARK HCI_ENABLE_PARK_MODE
+typedef UINT16 tBTA_DM_LP_MASK;
+
+/* power mode actions */
+#define BTA_DM_PM_NO_ACTION 0x00 /* no change to the current pm setting */
+#define BTA_DM_PM_PARK 0x10 /* prefers park mode */
+#define BTA_DM_PM_SNIFF 0x20 /* prefers sniff mode */
+#define BTA_DM_PM_SNIFF1 0x21 /* prefers sniff1 mode */
+#define BTA_DM_PM_SNIFF2 0x22 /* prefers sniff2 mode */
+#define BTA_DM_PM_SNIFF3 0x23 /* prefers sniff3 mode */
+#define BTA_DM_PM_SNIFF4 0x24 /* prefers sniff4 mode */
+#define BTA_DM_PM_SNIFF5 0x25 /* prefers sniff5 mode */
+#define BTA_DM_PM_SNIFF6 0x26 /* prefers sniff6 mode */
+#define BTA_DM_PM_SNIFF7 0x27 /* prefers sniff7 mode */
+#define BTA_DM_PM_SNIFF_USER0 0x28 /* prefers user-defined sniff0 mode (testtool only) */
+#define BTA_DM_PM_SNIFF_USER1 0x29 /* prefers user-defined sniff1 mode (testtool only) */
+#define BTA_DM_PM_ACTIVE 0x40 /* prefers active mode */
+#define BTA_DM_PM_RETRY 0x80 /* retry power mode based on current settings */
+#define BTA_DM_PM_NO_PREF 0x01 /* service has no prefernce on power mode setting. eg. connection to service got closed */
+
+typedef UINT8 tBTA_DM_PM_ACTTION;
+
+/* index to bta_dm_ssr_spec */
+#define BTA_DM_PM_SSR0 0
+#define BTA_DM_PM_SSR1 1
+#define BTA_DM_PM_SSR2 2
+#define BTA_DM_PM_SSR3 3
+#define BTA_DM_PM_SSR4 4
+#define BTA_DM_PM_SSR5 5
+#define BTA_DM_PM_SSR6 6
+
+#define BTA_DM_PM_NUM_EVTS 9
+
+#ifndef BTA_DM_PM_PARK_IDX
+#define BTA_DM_PM_PARK_IDX 5 /* the actual index to bta_dm_pm_md[] for PARK mode */
+#endif
+
+#define BTA_DM_SW_BB_TO_MM BTM_SW_BB_TO_MM
+#define BTA_DM_SW_MM_TO_BB BTM_SW_MM_TO_BB
+#define BTA_DM_SW_BB_TO_BTC BTM_SW_BB_TO_BTC
+#define BTA_DM_SW_BTC_TO_BB BTM_SW_BTC_TO_BB
+
+typedef tBTM_SW_DIR tBTA_DM_SW_DIR;
+
+/* Switch callback events */
+#define BTA_DM_SWITCH_CMPL_EVT 0 /* Completion of the Switch API */
+
+typedef UINT8 tBTA_DM_SWITCH_EVT;
+typedef void (tBTA_DM_SWITCH_CBACK)(tBTA_DM_SWITCH_EVT event, tBTA_STATUS status);
+
+/* Audio routing out configuration */
+#define BTA_DM_ROUTE_NONE 0x00 /* No Audio output */
+#define BTA_DM_ROUTE_DAC 0x01 /* routing over analog output */
+#define BTA_DM_ROUTE_I2S 0x02 /* routing over digital (I2S) output */
+#define BTA_DM_ROUTE_BT_MONO 0x04 /* routing over SCO */
+#define BTA_DM_ROUTE_BT_STEREO 0x08 /* routing over BT Stereo */
+#define BTA_DM_ROUTE_HOST 0x10 /* routing over Host */
+#define BTA_DM_ROUTE_FMTX 0x20 /* routing over FMTX */
+#define BTA_DM_ROUTE_FMRX 0x40 /* routing over FMRX */
+#define BTA_DM_ROUTE_BTSNK 0x80 /* routing over BT SNK */
+
+typedef UINT8 tBTA_DM_ROUTE_PATH;
+
+
+/* Device Identification (DI) data structure
+*/
+/* Used to set the DI record */
+typedef tSDP_DI_RECORD tBTA_DI_RECORD;
+/* Used to get the DI record */
+typedef tSDP_DI_GET_RECORD tBTA_DI_GET_RECORD;
+/* SDP discovery database */
+typedef tSDP_DISCOVERY_DB tBTA_DISCOVERY_DB;
+
+#ifndef BTA_DI_NUM_MAX
+#define BTA_DI_NUM_MAX 3
+#endif
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function BTA_EnableBluetooth
+**
+** Description This function initializes BTA and prepares BTA and the
+** Bluetooth protocol stack for use. This function is
+** typically called at startup or when Bluetooth services
+** are required by the phone. This function must be called
+** before calling any other API function.
+**
+**
+** Returns BTA_SUCCESS if successful.
+** BTA_FAIL if internal failure.
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_DisableBluetooth
+**
+** Description This function disables BTA and the Bluetooth protocol
+** stack. It is called when BTA is no longer being used
+** by any application in the system.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_DisableBluetooth(void);
+
+/*******************************************************************************
+**
+** Function BTA_EnableTestMode
+**
+** Description Enables bluetooth device under test mode
+**
+**
+** Returns tBTA_STATUS
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_EnableTestMode(void);
+
+/*******************************************************************************
+**
+** Function BTA_DisableTestMode
+**
+** Description Disable bluetooth device under test mode
+**
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_DisableTestMode(void);
+
+/*******************************************************************************
+**
+** Function BTA_DmIsDeviceUp
+**
+** Description This function tests whether the Bluetooth module is up
+** and ready. This is a direct execution function that
+** may lock task scheduling on some platforms.
+**
+**
+** Returns TRUE if the module is ready.
+** FALSE if the module is not ready.
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN BTA_DmIsDeviceUp(void);
+
+/*******************************************************************************
+**
+** Function BTA_DmSetDeviceName
+**
+** Description This function sets the Bluetooth name of the local device.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSetDeviceName(char *p_name);
+
+/*******************************************************************************
+**
+** Function BTA_DmSetVisibility
+**
+** Description This function sets the Bluetooth connectable,discoverable,
+** pairable and conn paired only modesmodes of the local device.
+** This controls whether other Bluetooth devices can find and connect to
+** the local device.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, UINT8 pairable_mode, UINT8 conn_filter);
+
+/*******************************************************************************
+**
+** Function BTA_DmSetScanParam
+**
+** Description This function sets the parameters for page scan and
+** inquiry scan.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSetScanParam (UINT16 page_scan_interval, UINT16 page_scan_window,
+ UINT16 inquiry_scan_interval, UINT16 inquiry_scan_window);
+
+/*******************************************************************************
+**
+** Function BTA_DmSetAfhChannels
+**
+** Description This function sets the AFH first and
+** last disable channel, so channels within
+** that range are disabled.
+** In order to use this API, BTM_BYPASS_AMP_AUTO_AFH must be set
+** to be TRUE
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSetAfhChannels(UINT8 first, UINT8 last);
+
+
+/*******************************************************************************
+**
+** Function BTA_DmVendorSpecificCommand
+**
+** Description This function sends the vendor specific command
+** to the controller
+**
+**
+** Returns tBTA_STATUS
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_DmVendorSpecificCommand (UINT16 opcode, UINT8 param_len,UINT8 *p_param_buf, tBTA_VENDOR_CMPL_CBACK *p_cback);
+
+
+/*******************************************************************************
+**
+** Function BTA_DmSearch
+**
+** Description This function searches for peer Bluetooth devices. It
+** first performs an inquiry; for each device found from the
+** inquiry it gets the remote name of the device. If
+** parameter services is nonzero, service discovery will be
+** performed on each device for the services specified.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSearch(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK services,
+ tBTA_DM_SEARCH_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_DmSearchCancel
+**
+** Description This function cancels a search that has been initiated
+** by calling BTA_DmSearch().
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSearchCancel(void);
+
+/*******************************************************************************
+**
+** Function BTA_DmDiscover
+**
+** Description This function performs service discovery for the services
+** of a particular peer device.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
+ tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
+
+// btla-specific ++
+/*******************************************************************************
+**
+** Function BTA_DmDiscoverUUID
+**
+** Description This function performs service discovery for the services
+** of a particular peer device.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
+ tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
+
+/*******************************************************************************
+**
+** Function BTA_DmGetCachedRemoteName
+**
+** Description Retieve cached remote name if available
+**
+** Returns BTA_SUCCESS if cached name was retrieved
+** BTA_FAILURE if cached name is not available
+**
+*******************************************************************************/
+tBTA_STATUS BTA_DmGetCachedRemoteName(BD_ADDR remote_device, UINT8 **pp_cached_name);
+// btla-specific --
+
+/*******************************************************************************
+**
+** Function BTA_DmIsMaster
+**
+** Description This function checks if the local device is the master of
+** the link to the given device
+**
+** Returns TRUE if master.
+** FALSE if not.
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN BTA_DmIsMaster(BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTA_DmBond
+**
+** Description This function initiates a bonding procedure with a peer
+** device. The bonding procedure enables authentication
+** and optionally encryption on the Bluetooth link.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmBond(BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTA_DmBondCancel
+**
+** Description This function cancels a bonding procedure with a peer
+** device.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmBondCancel(BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTA_DmPinReply
+**
+** Description This function provides a PIN when one is requested by DM
+** during a bonding procedure. The application should call
+** this function after the security callback is called with
+** a BTA_DM_PIN_REQ_EVT.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len,
+ UINT8 *p_pin);
+
+/*******************************************************************************
+**
+** Function BTA_DmLinkPolicy
+**
+** Description This function sets/clears the link policy mask to the given
+** bd_addr.
+** If clearing the sniff or park mode mask, the link is put
+** in active mode.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmLinkPolicy(BD_ADDR bd_addr, tBTA_DM_LP_MASK policy_mask,
+ BOOLEAN set);
+
+#if (BTM_OOB_INCLUDED == TRUE)
+/*******************************************************************************
+**
+** Function BTA_DmLocalOob
+**
+** Description This function retrieves the OOB data from local controller.
+** The result is reported by bta_dm_co_loc_oob().
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmLocalOob(void);
+#endif /* BTM_OOB_INCLUDED */
+
+/*******************************************************************************
+**
+** Function BTA_DmConfirm
+**
+** Description This function accepts or rejects the numerical value of the
+** Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept);
+
+/*******************************************************************************
+**
+** Function BTA_DmPasskeyCancel
+**
+** Description This function is called to cancel the simple pairing process
+** reported by BTA_DM_SP_KEY_NOTIF_EVT
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmPasskeyCancel(BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTA_DmAddDevice
+**
+** Description This function adds a device to the security database list
+** of peer devices. This function would typically be called
+** at system startup to initialize the security database with
+** known peer devices. This is a direct execution function
+** that may lock task scheduling on some platforms.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class,
+ LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask,
+ BOOLEAN is_trusted, UINT8 key_type,
+ tBTA_IO_CAP io_cap);
+
+/*******************************************************************************
+**
+** Function BTA_DmAddDevWithName
+**
+** Description This function is newer version of BTA_DmAddDevice()
+** which added bd_name and features as input parameters.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmAddDevWithName (BD_ADDR bd_addr, DEV_CLASS dev_class,
+ BD_NAME bd_name, BD_FEATURES features,
+ LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask,
+ BOOLEAN is_trusted, UINT8 key_type, tBTA_IO_CAP io_cap);
+
+/*******************************************************************************
+**
+** Function BTA_DmRemoveDevice
+**
+** Description This function removes a device from the security database.
+** This is a direct execution function that may lock task
+** scheduling on some platforms.
+**
+**
+** Returns BTA_SUCCESS if successful.
+** BTA_FAIL if operation failed.
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTA_DmAuthorizeReply
+**
+** Description This function provides an authorization reply when
+** authorization is requested by BTA. The application calls
+** this function after the security callback is called with
+** a BTA_DM_AUTHORIZE_EVT.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmAuthorizeReply(BD_ADDR bd_addr, tBTA_SERVICE_ID service,
+ tBTA_AUTH_RESP response);
+
+/*******************************************************************************
+**
+** Function BTA_DmSignalStrength
+**
+** Description This function initiates RSSI and channnel quality
+** measurments. BTA_DM_SIG_STRENGTH_EVT is sent to
+** application with the values of RSSI and channel
+** quality
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSignalStrength(tBTA_SIG_STRENGTH_MASK mask, UINT16 period, BOOLEAN start);
+
+/*******************************************************************************
+**
+** Function BTA_DmWriteInqTxPower
+**
+** Description This command is used to write the inquiry transmit power level
+** used to transmit the inquiry (ID) data packets.
+**
+** Parameters tx_power - tx inquiry power to use, valid value is -70 ~ 20
+
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmWriteInqTxPower(INT8 tx_power);
+
+/*******************************************************************************
+**
+** Function BTA_DmEirAddUUID
+**
+** Description This function is called to add UUID into EIR.
+**
+** Parameters tBT_UUID - UUID
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmEirAddUUID (tBT_UUID *p_uuid);
+
+/*******************************************************************************
+**
+** Function BTA_DmEirRemoveUUID
+**
+** Description This function is called to remove UUID from EIR.
+**
+** Parameters tBT_UUID - UUID
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmEirRemoveUUID (tBT_UUID *p_uuid);
+
+/*******************************************************************************
+**
+** Function BTA_DmSetEIRConfig
+**
+** Description This function is called to override the BTA default EIR parameters.
+** This funciton is only valid in a system where BTU & App task
+** are in the same memory space.
+**
+** Parameters Pointer to User defined EIR config
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSetEIRConfig (tBTA_DM_EIR_CONF *p_eir_cfg);
+
+/*******************************************************************************
+**
+** Function BTA_CheckEirData
+**
+** Description This function is called to get EIR data from significant part.
+**
+** Parameters p_eir - pointer of EIR significant part
+** type - finding EIR data type
+** p_length - return the length of EIR data
+**
+** Returns pointer of EIR data
+**
+*******************************************************************************/
+BTA_API extern UINT8 *BTA_CheckEirData( UINT8 *p_eir, UINT8 tag, UINT8 *p_length );
+
+/*******************************************************************************
+**
+** Function BTA_GetEirService
+**
+** Description This function is called to get BTA service mask from EIR.
+**
+** Parameters p_eir - pointer of EIR significant part
+** p_services - return the BTA service mask
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services );
+
+/*******************************************************************************
+**
+** Function BTA_DmUseSsr
+**
+** Description This function is called to check if the connected peer device
+** supports SSR or not.
+**
+** Returns TRUE, if SSR is supported
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN BTA_DmUseSsr( BD_ADDR bd_addr );
+
+
+/*******************************************************************************
+**
+** Function BTA_DmSetLocalDiRecord
+**
+** Description This function adds a DI record to the local SDP database.
+**
+** Returns BTA_SUCCESS if record set sucessfully, otherwise error code.
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
+ UINT32 *p_handle );
+
+/*******************************************************************************
+**
+** Function BTA_DmGetLocalDiRecord
+**
+** Description Get a specified DI record to the local SDP database. If no
+** record handle is provided, the primary DI record will be
+** returned.
+**
+** Returns BTA_SUCCESS if record set sucessfully, otherwise error code.
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_DmGetLocalDiRecord( tBTA_DI_GET_RECORD *p_device_info,
+ UINT32 *p_handle );
+
+/*******************************************************************************
+**
+** Function BTA_DmDiDiscover
+**
+** Description This function queries a remote device for DI information.
+**
+** Returns None.
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmDiDiscover( BD_ADDR remote_device, tBTA_DISCOVERY_DB *p_db,
+ UINT32 len, tBTA_DM_SEARCH_CBACK *p_cback );
+
+/*******************************************************************************
+**
+** Function BTA_DmGetDiRecord
+**
+** Description This function retrieves a remote device's DI record from
+** the specified database.
+**
+** Returns None.
+**
+*******************************************************************************/
+BTA_API extern tBTA_STATUS BTA_DmGetDiRecord( UINT8 get_record_index, tBTA_DI_GET_RECORD *p_device_info,
+ tBTA_DISCOVERY_DB *p_db );
+
+/*******************************************************************************
+**
+** Function BTA_SysFeatures
+**
+** Description This function is called to set system features.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_SysFeatures (UINT16 sys_features);
+
+/*******************************************************************************
+**
+** Function bta_dmexecutecallback
+**
+** Description This function will request BTA to execute a call back in the context of BTU task
+** This API was named in lower case because it is only intended
+** for the internal customers(like BSA).
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK* p_callback, void * p_param);
+
+#if (BTM_SCO_HCI_INCLUDED == TRUE)
+/*******************************************************************************
+**
+** Function BTA_DmPcmInitSamples
+**
+** Description initialize the down sample converter.
+**
+** src_sps: original samples per second (source audio data)
+** (ex. 44100, 48000)
+** bits: number of bits per pcm sample (16)
+** n_channels: number of channels (i.e. mono(1), stereo(2)...)
+**
+** Returns none
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmPcmInitSamples (UINT32 src_sps, UINT32 bits, UINT32 n_channels);
+
+/**************************************************************************************
+** Function BTA_DmPcmResample
+**
+** Description Down sampling utility to convert higher sampling rate into 8K/16bits
+** PCM samples.
+**
+** Parameters p_src: pointer to the buffer where the original sampling PCM
+** are stored.
+** in_bytes: Length of the input PCM sample buffer in byte.
+** p_dst: pointer to the buffer which is to be used to store
+** the converted PCM samples.
+**
+**
+** Returns INT32: number of samples converted.
+**
+**************************************************************************************/
+BTA_API extern INT32 BTA_DmPcmResample (void *p_src, UINT32 in_bytes, void *p_dst);
+#endif
+
+#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
+/* BLE related API functions */
+/*******************************************************************************
+**
+** Function BTA_DmBleSecurityGrant
+**
+** Description Grant security request access.
+**
+** Parameters: bd_addr - BD address of the peer
+** res - security grant status.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res);
+
+
+
+/*******************************************************************************
+**
+** Function BTA_DmBleSetBgConnType
+**
+** Description This function is called to set BLE connectable mode for a
+** peripheral device.
+**
+** Parameters bg_conn_type: it can be auto connection, or selective connection.
+** p_select_cback: callback function when selective connection procedure
+** is being used.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_CBACK *p_select_cback);
+
+/*******************************************************************************
+**
+** Function BTA_DmBlePasskeyReply
+**
+** Description Send BLE SMP passkey reply.
+**
+** Parameters: bd_addr - BD address of the peer
+** accept - passkey entry sucessful or declined.
+** passkey - passkey value, must be a 6 digit number,
+** can be lead by 0.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey);
+
+/*******************************************************************************
+**
+** Function BTA_DmAddBleDevice
+**
+** Description Add a BLE device. This function will be normally called
+** during host startup to restore all required information
+** for a LE device stored in the NVRAM.
+**
+** Parameters: bd_addr - BD address of the peer
+** dev_type - Remote device's device type.
+** addr_type - LE device address type.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type,
+ tBT_DEVICE_TYPE dev_type);
+
+
+/*******************************************************************************
+**
+** Function BTA_DmAddBleKey
+**
+** Description Add/modify LE device information. This function will be
+** normally called during host startup to restore all required
+** information stored in the NVRAM.
+**
+** Parameters: bd_addr - BD address of the peer
+** p_le_key - LE key values.
+** key_type - LE SMP key type.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key,
+ tBTA_LE_KEY_TYPE key_type);
+
+/*******************************************************************************
+**
+** Function BTA_DmSetBlePrefConnParams
+**
+** Description This function is called to set the preferred connection
+** parameters when default connection parameter is not desired.
+**
+** Parameters: bd_addr - BD address of the peripheral
+** min_conn_int - minimum preferred connection interval
+** max_conn_int - maximum preferred connection interval
+** slave_latency - preferred slave latency
+** supervision_tout - preferred supervision timeout
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
+ UINT16 min_conn_int, UINT16 max_conn_int,
+ UINT16 slave_latency, UINT16 supervision_tout );
+
+/*******************************************************************************
+**
+** Function BTA_DmSetBleConnScanParams
+**
+** Description This function is called to set scan parameters used in
+** BLE connection request
+**
+** Parameters: bd_addr - BD address of the peripheral
+** scan_interval - scan interval
+** scan_window - scan window
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSetBleConnScanParams(UINT16 scan_interval,
+ UINT16 scan_window );
+
+/*******************************************************************************
+**
+** Function BTA_DmSearchExt
+**
+** Description This function searches for peer Bluetooth devices. It performs
+** an inquiry and gets the remote name for devices. Service
+** discovery is done if services is non zero
+**
+** Parameters p_dm_inq: inquiry conditions
+** services: if service is not empty, service discovery will be done.
+** for all GATT based service condition, put num_uuid, and
+** p_uuid is the pointer to the list of UUID values.
+** p_cback: callback functino when search is completed.
+**
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSearchExt(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK_EXT *p_services,
+ tBTA_DM_SEARCH_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_DmDiscoverExt
+**
+** Description This function does service discovery for services of a
+** peer device. When services.num_uuid is 0, it indicates all
+** GATT based services are to be searched; other wise a list of
+** UUID of interested services should be provided through
+** services.p_uuid.
+**
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
+ tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
+
+
+/*******************************************************************************
+**
+** Function BTA_DmSetEncryption
+**
+** Description This function is called to ensure that connection is
+** encrypted. Should be called only on an open connection.
+** Typically only needed for connections that first want to
+** bring up unencrypted links, then later encrypt them.
+**
+** Parameters: bd_addr - Address of the peer device
+** p_callback - Pointer to callback function to indicat the
+** link encryption status
+** sec_act - This is the security action to indicate
+** what knid of BLE security level is required for
+** the BLE link if the BLE is supported
+** Note: This parameter is ignored for the BR/EDR link
+** or the BLE is not supported
+**
+** Returns void
+**
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_DM_ENCRYPT_CBACK *p_callback,
+ tBTA_DM_BLE_SEC_ACT sec_act);
+
+#endif
+
+// btla-specific ++
+/*******************************************************************************
+**
+** Function BTA_DmSetAfhChannelAssessment
+**
+** Description This function is called to set the channel assessment mode on or off
+**
+** Returns status
+**
+*******************************************************************************/
+BTA_API extern void BTA_DmSetAfhChannelAssessment (BOOLEAN enable_or_disable);
+// btla-specific --
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_API_H */
+
diff --git a/bta/include/bta_av_api.h b/bta/include/bta_av_api.h
new file mode 100644
index 0000000..f639d22
--- /dev/null
+++ b/bta/include/bta_av_api.h
@@ -0,0 +1,753 @@
+/*****************************************************************************
+**
+** Name: bta_av_api.h
+**
+** Description: This is the public interface file for the advanced
+** audio/video streaming (AV) subsystem of BTA, Widcomm's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2004-2011, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_AV_API_H
+#define BTA_AV_API_H
+
+#include "avrc_api.h"
+#include "avdt_api.h"
+#include "a2d_api.h"
+#include "bta_api.h"
+#if( defined VDP_INCLUDED) && (VDP_INCLUDED == TRUE)
+#include "vdp_api.h"
+#endif
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+/* Set to TRUE if seperate authorization prompt desired for AVCTP besides A2DP authorization */
+/* Typically FALSE when AVRCP is used in conjunction with A2DP */
+#ifndef BTA_AV_WITH_AVCTP_AUTHORIZATION
+#define BTA_AV_WITH_AVCTP_AUTHORIZATION FALSE
+#endif
+
+/* AV status values */
+#define BTA_AV_SUCCESS 0 /* successful operation */
+#define BTA_AV_FAIL 1 /* generic failure */
+#define BTA_AV_FAIL_SDP 2 /* service not found */
+#define BTA_AV_FAIL_STREAM 3 /* stream connection failed */
+#define BTA_AV_FAIL_RESOURCES 4 /* no resources */
+#define BTA_AV_FAIL_ROLE 5 /* failed due to role management related issues */
+
+typedef UINT8 tBTA_AV_STATUS;
+
+/* AV features masks */
+#define BTA_AV_FEAT_RCTG 0x0001 /* remote control target */
+#define BTA_AV_FEAT_RCCT 0x0002 /* remote control controller */
+#define BTA_AV_FEAT_PROTECT 0x0004 /* streaming media contect protection */
+#define BTA_AV_FEAT_VENDOR 0x0008 /* remote control vendor dependent commands */
+#define BTA_AV_FEAT_REPORT 0x0020 /* use reporting service for VDP */
+#define BTA_AV_FEAT_METADATA 0x0040 /* remote control Metadata Transfer command/response */
+#define BTA_AV_FEAT_MULTI_AV 0x0080 /* use multi-av, if controller supports it */
+#define BTA_AV_FEAT_BROWSE 0x0010 /* use browsing channel */
+#define BTA_AV_FEAT_MASTER 0x0100 /* stream only as master role */
+#define BTA_AV_FEAT_ADV_CTRL 0x0200 /* remote control Advanced Control command/response */
+#define BTA_AV_FEAT_DELAY_RPT 0x0400 /* allow delay reporting */
+#define BTA_AV_FEAT_ACP_START 0x0800 /* start stream when 2nd SNK was accepted */
+
+/* Internal features */
+#define BTA_AV_FEAT_NO_SCO_SSPD 0x8000 /* Do not suspend av streaming as to AG events(SCO or Call) */
+
+typedef UINT16 tBTA_AV_FEAT;
+
+/* AV channel values */
+#define BTA_AV_CHNL_MSK 0xC0
+#define BTA_AV_CHNL_AUDIO 0x40 /* audio channel */
+#define BTA_AV_CHNL_VIDEO 0x80 /* video channel */
+typedef UINT8 tBTA_AV_CHNL;
+
+
+#define BTA_AV_HNDL_MSK 0x3F
+typedef UINT8 tBTA_AV_HNDL;
+/* handle index to mask */
+#define BTA_AV_HNDL_TO_MSK(h) ((UINT8)(1 << (h)))
+
+/* tBTA_AV_HNDL to mask */
+#define BTA_AV_HNDL_TYPE_TO_MSK(h) ((UINT8)(1 << (h&BTA_AV_HNDL_MSK)))
+
+/* offset of codec type in codec info byte array */
+#define BTA_AV_CODEC_TYPE_IDX AVDT_CODEC_TYPE_INDEX /* 2 */
+
+
+
+/* maximum number of streams created: 1 for audio, 1 for video */
+#ifndef BTA_AV_NUM_STRS
+#define BTA_AV_NUM_STRS 2
+#endif
+
+#ifndef BTA_AV_MAX_SEPS
+#define BTA_AV_MAX_SEPS 2
+#endif
+
+#ifndef BTA_AV_MAX_A2DP_MTU
+ /*#define BTA_AV_MAX_A2DP_MTU 668 //224 (DM5) * 3 - 4(L2CAP header) */
+#define BTA_AV_MAX_A2DP_MTU 1008
+#endif
+
+#ifndef BTA_AV_MAX_VDP_MTU
+#define BTA_AV_MAX_VDP_MTU 1008
+#endif
+
+
+/* codec type */
+#define BTA_AV_CODEC_SBC A2D_MEDIA_CT_SBC /* SBC media codec type */
+#define BTA_AV_CODEC_M12 A2D_MEDIA_CT_M12 /* MPEG-1, 2 Audio media codec type */
+#define BTA_AV_CODEC_M24 A2D_MEDIA_CT_M24 /* MPEG-2, 4 AAC media codec type */
+#define BTA_AV_CODEC_ATRAC A2D_MEDIA_CT_ATRAC /* ATRAC family media codec type */
+#define BTA_AV_CODEC_H263_P0 VDP_MEDIA_CT_H263_P0 /* H.263 baseline (profile 0) */
+#define BTA_AV_CODEC_MPEG4 VDP_MEDIA_CT_MPEG4 /* MPEG-4 Visual Simple Profile */
+#define BTA_AV_CODEC_H263_P3 VDP_MEDIA_CT_H263_P3 /* H.263 profile 3 */
+#define BTA_AV_CODEC_H263_P8 VDP_MEDIA_CT_H263_P8 /* H.263 profile 8 */
+#define BTA_AV_CODEC_VEND VDP_MEDIA_CT_VEND /* Non-VDP */
+
+typedef UINT8 tBTA_AV_CODEC;
+
+/* Company ID in BT assigned numbers */
+#define BTA_AV_BT_VENDOR_ID VDP_BT_VENDOR_ID /* Broadcom Corporation */
+
+/* vendor specific codec ID */
+#define BTA_AV_CODEC_ID_H264 VDP_CODEC_ID_H264 /* Non-VDP codec ID - H.264 */
+#define BTA_AV_CODEC_ID_IMG VDP_CODEC_ID_IMG /* Non-VDP codec ID - images/slideshow */
+
+/* operation id list for BTA_AvRemoteCmd */
+#define BTA_AV_RC_SELECT AVRC_ID_SELECT /* select */
+#define BTA_AV_RC_UP AVRC_ID_UP /* up */
+#define BTA_AV_RC_DOWN AVRC_ID_DOWN /* down */
+#define BTA_AV_RC_LEFT AVRC_ID_LEFT /* left */
+#define BTA_AV_RC_RIGHT AVRC_ID_RIGHT /* right */
+#define BTA_AV_RC_RIGHT_UP AVRC_ID_RIGHT_UP /* right-up */
+#define BTA_AV_RC_RIGHT_DOWN AVRC_ID_RIGHT_DOWN /* right-down */
+#define BTA_AV_RC_LEFT_UP AVRC_ID_LEFT_UP /* left-up */
+#define BTA_AV_RC_LEFT_DOWN AVRC_ID_LEFT_DOWN /* left-down */
+#define BTA_AV_RC_ROOT_MENU AVRC_ID_ROOT_MENU /* root menu */
+#define BTA_AV_RC_SETUP_MENU AVRC_ID_SETUP_MENU /* setup menu */
+#define BTA_AV_RC_CONT_MENU AVRC_ID_CONT_MENU /* contents menu */
+#define BTA_AV_RC_FAV_MENU AVRC_ID_FAV_MENU /* favorite menu */
+#define BTA_AV_RC_EXIT AVRC_ID_EXIT /* exit */
+#define BTA_AV_RC_0 AVRC_ID_0 /* 0 */
+#define BTA_AV_RC_1 AVRC_ID_1 /* 1 */
+#define BTA_AV_RC_2 AVRC_ID_2 /* 2 */
+#define BTA_AV_RC_3 AVRC_ID_3 /* 3 */
+#define BTA_AV_RC_4 AVRC_ID_4 /* 4 */
+#define BTA_AV_RC_5 AVRC_ID_5 /* 5 */
+#define BTA_AV_RC_6 AVRC_ID_6 /* 6 */
+#define BTA_AV_RC_7 AVRC_ID_7 /* 7 */
+#define BTA_AV_RC_8 AVRC_ID_8 /* 8 */
+#define BTA_AV_RC_9 AVRC_ID_9 /* 9 */
+#define BTA_AV_RC_DOT AVRC_ID_DOT /* dot */
+#define BTA_AV_RC_ENTER AVRC_ID_ENTER /* enter */
+#define BTA_AV_RC_CLEAR AVRC_ID_CLEAR /* clear */
+#define BTA_AV_RC_CHAN_UP AVRC_ID_CHAN_UP /* channel up */
+#define BTA_AV_RC_CHAN_DOWN AVRC_ID_CHAN_DOWN /* channel down */
+#define BTA_AV_RC_PREV_CHAN AVRC_ID_PREV_CHAN /* previous channel */
+#define BTA_AV_RC_SOUND_SEL AVRC_ID_SOUND_SEL /* sound select */
+#define BTA_AV_RC_INPUT_SEL AVRC_ID_INPUT_SEL /* input select */
+#define BTA_AV_RC_DISP_INFO AVRC_ID_DISP_INFO /* display information */
+#define BTA_AV_RC_HELP AVRC_ID_HELP /* help */
+#define BTA_AV_RC_PAGE_UP AVRC_ID_PAGE_UP /* page up */
+#define BTA_AV_RC_PAGE_DOWN AVRC_ID_PAGE_DOWN /* page down */
+#define BTA_AV_RC_POWER AVRC_ID_POWER /* power */
+#define BTA_AV_RC_VOL_UP AVRC_ID_VOL_UP /* volume up */
+#define BTA_AV_RC_VOL_DOWN AVRC_ID_VOL_DOWN /* volume down */
+#define BTA_AV_RC_MUTE AVRC_ID_MUTE /* mute */
+#define BTA_AV_RC_PLAY AVRC_ID_PLAY /* play */
+#define BTA_AV_RC_STOP AVRC_ID_STOP /* stop */
+#define BTA_AV_RC_PAUSE AVRC_ID_PAUSE /* pause */
+#define BTA_AV_RC_RECORD AVRC_ID_RECORD /* record */
+#define BTA_AV_RC_REWIND AVRC_ID_REWIND /* rewind */
+#define BTA_AV_RC_FAST_FOR AVRC_ID_FAST_FOR /* fast forward */
+#define BTA_AV_RC_EJECT AVRC_ID_EJECT /* eject */
+#define BTA_AV_RC_FORWARD AVRC_ID_FORWARD /* forward */
+#define BTA_AV_RC_BACKWARD AVRC_ID_BACKWARD /* backward */
+#define BTA_AV_RC_ANGLE AVRC_ID_ANGLE /* angle */
+#define BTA_AV_RC_SUBPICT AVRC_ID_SUBPICT /* subpicture */
+#define BTA_AV_RC_F1 AVRC_ID_F1 /* F1 */
+#define BTA_AV_RC_F2 AVRC_ID_F2 /* F2 */
+#define BTA_AV_RC_F3 AVRC_ID_F3 /* F3 */
+#define BTA_AV_RC_F4 AVRC_ID_F4 /* F4 */
+#define BTA_AV_RC_F5 AVRC_ID_F5 /* F5 */
+#define BTA_AV_VENDOR AVRC_ID_VENDOR /* vendor unique */
+
+typedef UINT8 tBTA_AV_RC;
+
+/* state flag for pass through command */
+#define BTA_AV_STATE_PRESS AVRC_STATE_PRESS /* key pressed */
+#define BTA_AV_STATE_RELEASE AVRC_STATE_RELEASE /* key released */
+
+typedef UINT8 tBTA_AV_STATE;
+
+/* command codes for BTA_AvVendorCmd */
+#define BTA_AV_CMD_CTRL AVRC_CMD_CTRL
+#define BTA_AV_CMD_STATUS AVRC_CMD_STATUS
+#define BTA_AV_CMD_SPEC_INQ AVRC_CMD_SPEC_INQ
+#define BTA_AV_CMD_NOTIF AVRC_CMD_NOTIF
+#define BTA_AV_CMD_GEN_INQ AVRC_CMD_GEN_INQ
+
+typedef UINT8 tBTA_AV_CMD;
+
+/* response codes for BTA_AvVendorRsp */
+#define BTA_AV_RSP_NOT_IMPL AVRC_RSP_NOT_IMPL
+#define BTA_AV_RSP_ACCEPT AVRC_RSP_ACCEPT
+#define BTA_AV_RSP_REJ AVRC_RSP_REJ
+#define BTA_AV_RSP_IN_TRANS AVRC_RSP_IN_TRANS
+#define BTA_AV_RSP_IMPL_STBL AVRC_RSP_IMPL_STBL
+#define BTA_AV_RSP_CHANGED AVRC_RSP_CHANGED
+#define BTA_AV_RSP_INTERIM AVRC_RSP_INTERIM
+
+typedef UINT8 tBTA_AV_CODE;
+
+/* error codes for BTA_AvProtectRsp */
+#define BTA_AV_ERR_NONE A2D_SUCCESS /* Success, no error */
+#define BTA_AV_ERR_BAD_STATE AVDT_ERR_BAD_STATE /* Message cannot be processed in this state */
+#define BTA_AV_ERR_RESOURCE AVDT_ERR_RESOURCE /* Insufficient resources */
+#define BTA_AV_ERR_BAD_CP_TYPE A2D_BAD_CP_TYPE /* The requested Content Protection Type is not supported */
+#define BTA_AV_ERR_BAD_CP_FORMAT A2D_BAD_CP_FORMAT /* The format of Content Protection Data is not correct */
+
+typedef UINT8 tBTA_AV_ERR;
+
+
+/* AV callback events */
+#define BTA_AV_ENABLE_EVT 0 /* AV enabled */
+#define BTA_AV_REGISTER_EVT 1 /* registered to AVDT */
+#define BTA_AV_OPEN_EVT 2 /* connection opened */
+#define BTA_AV_CLOSE_EVT 3 /* connection closed */
+#define BTA_AV_START_EVT 4 /* stream data transfer started */
+#define BTA_AV_STOP_EVT 5 /* stream data transfer stopped */
+#define BTA_AV_PROTECT_REQ_EVT 6 /* content protection request */
+#define BTA_AV_PROTECT_RSP_EVT 7 /* content protection response */
+#define BTA_AV_RC_OPEN_EVT 8 /* remote control channel open */
+#define BTA_AV_RC_CLOSE_EVT 9 /* remote control channel closed */
+#define BTA_AV_REMOTE_CMD_EVT 10 /* remote control command */
+#define BTA_AV_REMOTE_RSP_EVT 11 /* remote control response */
+#define BTA_AV_VENDOR_CMD_EVT 12 /* vendor dependent remote control command */
+#define BTA_AV_VENDOR_RSP_EVT 13 /* vendor dependent remote control response */
+#define BTA_AV_RECONFIG_EVT 14 /* reconfigure response */
+#define BTA_AV_SUSPEND_EVT 15 /* suspend response */
+#define BTA_AV_PENDING_EVT 16 /* incoming connection pending:
+ * signal channel is open and stream is not open
+ * after BTA_AV_SIG_TIME_VAL ms */
+#define BTA_AV_META_MSG_EVT 17 /* metadata messages */
+#define BTA_AV_REJECT_EVT 18 /* incoming connection rejected */
+#define BTA_AV_RC_FEAT_EVT 19 /* remote control channel peer supported features update */
+
+typedef UINT8 tBTA_AV_EVT;
+
+/* Event associated with BTA_AV_ENABLE_EVT */
+typedef struct
+{
+ tBTA_AV_FEAT features;
+} tBTA_AV_ENABLE;
+
+/* Event associated with BTA_AV_REGISTER_EVT */
+typedef struct
+{
+ tBTA_AV_CHNL chnl; /* audio/video */
+ tBTA_AV_HNDL hndl; /* Handle associated with the stream. */
+ UINT8 app_id; /* ID associated with call to BTA_AvRegister() */
+ tBTA_AV_STATUS status;
+} tBTA_AV_REGISTER;
+
+/* data associated with BTA_AV_OPEN_EVT */
+#define BTA_AV_EDR_2MBPS 0x01
+#define BTA_AV_EDR_3MBPS 0x02
+typedef UINT8 tBTA_AV_EDR;
+
+typedef struct
+{
+ tBTA_AV_CHNL chnl;
+ tBTA_AV_HNDL hndl;
+ BD_ADDR bd_addr;
+ tBTA_AV_STATUS status;
+ BOOLEAN starting;
+ tBTA_AV_EDR edr; /* 0, if peer device does not support EDR */
+} tBTA_AV_OPEN;
+
+/* data associated with BTA_AV_CLOSE_EVT */
+typedef struct
+{
+ tBTA_AV_CHNL chnl;
+ tBTA_AV_HNDL hndl;
+} tBTA_AV_CLOSE;
+
+/* data associated with BTA_AV_START_EVT */
+typedef struct
+{
+ tBTA_AV_CHNL chnl;
+ tBTA_AV_HNDL hndl;
+ tBTA_AV_STATUS status;
+ BOOLEAN initiator; /* TRUE, if local device initiates the START */
+ BOOLEAN suspending;
+} tBTA_AV_START;
+
+/* data associated with BTA_AV_SUSPEND_EVT */
+typedef struct
+{
+ tBTA_AV_CHNL chnl;
+ tBTA_AV_HNDL hndl;
+ BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */
+ tBTA_AV_STATUS status;
+} tBTA_AV_SUSPEND;
+
+/* data associated with BTA_AV_RECONFIG_EVT */
+typedef struct
+{
+ tBTA_AV_CHNL chnl;
+ tBTA_AV_HNDL hndl;
+ tBTA_AV_STATUS status;
+} tBTA_AV_RECONFIG;
+
+/* data associated with BTA_AV_PROTECT_REQ_EVT */
+typedef struct
+{
+ tBTA_AV_CHNL chnl;
+ tBTA_AV_HNDL hndl;
+ UINT8 *p_data;
+ UINT16 len;
+} tBTA_AV_PROTECT_REQ;
+
+/* data associated with BTA_AV_PROTECT_RSP_EVT */
+typedef struct
+{
+ tBTA_AV_CHNL chnl;
+ tBTA_AV_HNDL hndl;
+ UINT8 *p_data;
+ UINT16 len;
+ tBTA_AV_ERR err_code;
+} tBTA_AV_PROTECT_RSP;
+
+/* data associated with BTA_AV_RC_OPEN_EVT */
+typedef struct
+{
+ UINT8 rc_handle;
+ tBTA_AV_FEAT peer_features;
+ BD_ADDR peer_addr;
+ tBTA_AV_STATUS status;
+} tBTA_AV_RC_OPEN;
+
+/* data associated with BTA_AV_RC_CLOSE_EVT */
+typedef struct
+{
+ UINT8 rc_handle;
+ BD_ADDR peer_addr;
+} tBTA_AV_RC_CLOSE;
+
+/* data associated with BTA_AV_RC_FEAT_EVT */
+typedef struct
+{
+ UINT8 rc_handle;
+ tBTA_AV_FEAT peer_features;
+} tBTA_AV_RC_FEAT;
+
+/* data associated with BTA_AV_REMOTE_CMD_EVT */
+typedef struct
+{
+ UINT8 rc_handle;
+ tBTA_AV_RC rc_id;
+ tBTA_AV_STATE key_state;
+ UINT8 len;
+ UINT8 *p_data;
+ tAVRC_HDR hdr; /* Message header. */
+ UINT8 label;
+} tBTA_AV_REMOTE_CMD;
+
+/* data associated with BTA_AV_REMOTE_RSP_EVT */
+typedef struct
+{
+ UINT8 rc_handle;
+ tBTA_AV_RC rc_id;
+ tBTA_AV_STATE key_state;
+ UINT8 len;
+ UINT8 *p_data;
+ tBTA_AV_CODE rsp_code;
+ UINT8 label;
+} tBTA_AV_REMOTE_RSP;
+
+/* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */
+typedef struct
+{
+ UINT8 rc_handle;
+ UINT16 len; /* Max vendor dependent message is 512 */
+ UINT8 label;
+ tBTA_AV_CODE code;
+ UINT32 company_id;
+ UINT8 *p_data;
+} tBTA_AV_VENDOR;
+
+/* data associated with BTA_AV_META_MSG_EVT */
+typedef struct
+{
+ UINT8 rc_handle;
+ UINT16 len;
+ UINT8 label;
+ tBTA_AV_CODE code;
+ UINT32 company_id;
+ UINT8 *p_data;
+ tAVRC_MSG *p_msg;
+} tBTA_AV_META_MSG;
+
+/* data associated with BTA_AV_PENDING_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr;
+} tBTA_AV_PEND;
+
+/* data associated with BTA_AV_REJECT_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr;
+ tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the connection. */
+} tBTA_AV_REJECT;
+
+
+/* union of data associated with AV callback */
+typedef union
+{
+ tBTA_AV_CHNL chnl;
+ tBTA_AV_ENABLE enable;
+ tBTA_AV_REGISTER registr;
+ tBTA_AV_OPEN open;
+ tBTA_AV_CLOSE close;
+ tBTA_AV_START start;
+ tBTA_AV_PROTECT_REQ protect_req;
+ tBTA_AV_PROTECT_RSP protect_rsp;
+ tBTA_AV_RC_OPEN rc_open;
+ tBTA_AV_RC_CLOSE rc_close;
+ tBTA_AV_REMOTE_CMD remote_cmd;
+ tBTA_AV_REMOTE_RSP remote_rsp;
+ tBTA_AV_VENDOR vendor_cmd;
+ tBTA_AV_VENDOR vendor_rsp;
+ tBTA_AV_RECONFIG reconfig;
+ tBTA_AV_SUSPEND suspend;
+ tBTA_AV_PEND pend;
+ tBTA_AV_META_MSG meta_msg;
+ tBTA_AV_REJECT reject;
+ tBTA_AV_RC_FEAT rc_feat;
+} tBTA_AV;
+
+
+#define BTA_AVC_PACKET_LEN AVRC_PACKET_LEN
+#define BTA_VENDOR_DATA_OFFSET 6
+#define BTA_VENDOR_HEADER_LEN 4
+#define BTA_MAX_VENDOR_DEPENDENT_DATA_LEN (BTA_AVC_PACKET_LEN-BTA_VENDOR_DATA_OFFSET-BTA_VENDOR_HEADER_LEN)
+#define BTA_GROUP_NAVI_MSG_OP_DATA_LEN 5
+
+#define BTA_ERROR_INVALID_CMD AVRC_STS_BAD_CMD
+#define BTA_ERROR_INVALID_PARAM AVRC_STS_BAD_PARAM
+#define BTA_ERROR_BAD_CONTENTS AVRC_STS_NOT_FOUND
+#define BTA_ERROR_INTERNAL AVRC_STS_INTERNAL_ERR
+
+#define BTA_AV_META_SINGLE_PACKET AVRC_PKT_SINGLE
+
+#define BTA_AV_CO_METADATA AVRC_CO_METADATA
+
+/* AV callback */
+typedef void (tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV *p_data);
+
+/* type for stream state machine action functions */
+typedef void (*tBTA_AV_ACT)(void *p_cb, void *p_data);
+
+/* type for registering VDP */
+typedef void (tBTA_AV_REG) (tAVDT_CS *p_cs, char *p_service_name, void *p_data);
+
+/* AV configuration structure */
+typedef struct
+{
+ UINT32 company_id; /* AVRCP Company ID */
+ UINT16 avrc_mtu; /* AVRCP MTU at L2CAP for control channel */
+ UINT16 avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */
+ UINT16 avrc_ct_cat; /* AVRCP controller categories */
+ UINT16 avrc_tg_cat; /* AVRCP target categories */
+ UINT16 sig_mtu; /* AVDTP signaling channel MTU at L2CAP */
+ UINT16 audio_mtu; /* AVDTP audio transport channel MTU at L2CAP */
+ const UINT16 *p_audio_flush_to;/* AVDTP audio transport channel flush timeout */
+ UINT16 audio_mqs; /* AVDTP audio channel max data queue size */
+ UINT16 video_mtu; /* AVDTP video transport channel MTU at L2CAP */
+ UINT16 video_flush_to; /* AVDTP video transport channel flush timeout */
+ BOOLEAN avrc_group; /* TRUE, to accept AVRC 1.3 group nevigation command */
+ UINT8 num_co_ids; /* company id count in p_meta_co_ids */
+ UINT8 num_evt_ids; /* event id count in p_meta_evt_ids */
+ tBTA_AV_CODE rc_pass_rsp; /* the default response code for pass through commands */
+ const UINT32 *p_meta_co_ids;/* the metadata Get Capabilities response for company id */
+ const UINT8 *p_meta_evt_ids;/* the the metadata Get Capabilities response for event id */
+ const tBTA_AV_ACT *p_act_tbl;/* the action function table for VDP stream */
+ tBTA_AV_REG *p_reg; /* action function to register VDP */
+} tBTA_AV_CFG;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function BTA_AvEnable
+**
+** Description Enable the advanced audio/video service. When the enable
+** operation is complete the callback function will be
+** called with a BTA_AV_ENABLE_EVT. This function must
+** be called before other function in the AV API are
+** called.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features,
+ tBTA_AV_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_AvDisable
+**
+** Description Disable the advanced audio/video service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_AvRegister
+**
+** Description Register the audio or video service to stack. When the
+** operation is complete the callback function will be
+** called with a BTA_AV_REGISTER_EVT. This function must
+** be called before AVDT stream is open.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name,
+ UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_AvDeregister
+**
+** Description Deregister the audio or video service
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvDeregister(tBTA_AV_HNDL hndl);
+
+/*******************************************************************************
+**
+** Function BTA_AvOpen
+**
+** Description Opens an advanced audio/video connection to a peer device.
+** When connection is open callback function is called
+** with a BTA_AV_OPEN_EVT.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle,
+ BOOLEAN use_rc, tBTA_SEC sec_mask);
+
+/*******************************************************************************
+**
+** Function BTA_AvClose
+**
+** Description Close the current streams.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvClose(tBTA_AV_HNDL handle);
+
+/*******************************************************************************
+**
+** Function BTA_AvDisconnect
+**
+** Description Close the connection to the address.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvDisconnect(BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTA_AvStart
+**
+** Description Start audio/video stream data transfer.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvStart(void);
+
+/*******************************************************************************
+**
+** Function BTA_AvStop
+**
+** Description Stop audio/video stream data transfer.
+** If suspend is TRUE, this function sends AVDT suspend signal
+** to the connected peer(s).
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvStop(BOOLEAN suspend);
+
+/*******************************************************************************
+**
+** Function BTA_AvReconfig
+**
+** Description Reconfigure the audio/video stream.
+** If suspend is TRUE, this function tries the suspend/reconfigure
+** procedure first.
+** If suspend is FALSE or when suspend/reconfigure fails,
+** this function closes and re-opens the AVDT connection.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx,
+ UINT8 *p_codec_info, UINT8 num_protect, UINT8 *p_protect_info);
+
+/*******************************************************************************
+**
+** Function BTA_AvProtectReq
+**
+** Description Send a content protection request. This function can only
+** be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len);
+
+/*******************************************************************************
+**
+** Function BTA_AvProtectRsp
+**
+** Description Send a content protection response. This function must
+** be called if a BTA_AV_PROTECT_REQ_EVT is received.
+** This function can only be used if AV is enabled with
+** feature BTA_AV_FEAT_PROTECT.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data,
+ UINT16 len);
+
+/*******************************************************************************
+**
+** Function BTA_AvRemoteCmd
+**
+** Description Send a remote control command. This function can only
+** be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id,
+ tBTA_AV_STATE key_state);
+
+/*******************************************************************************
+**
+** Function BTA_AvVendorCmd
+**
+** Description Send a vendor dependent remote control command. This
+** function can only be used if AV is enabled with feature
+** BTA_AV_FEAT_VENDOR.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code,
+ UINT8 *p_data, UINT16 len);
+
+/*******************************************************************************
+**
+** Function BTA_AvVendorRsp
+**
+** Description Send a vendor dependent remote control response.
+** This function must be called if a BTA_AV_VENDOR_CMD_EVT
+** is received. This function can only be used if AV is
+** enabled with feature BTA_AV_FEAT_VENDOR.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
+ UINT8 *p_data, UINT16 len, UINT32 company_id);
+
+
+/*******************************************************************************
+**
+** Function BTA_AvOpenRc
+**
+** Description Open an AVRCP connection toward the device with the
+** specified handle
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvOpenRc(tBTA_AV_HNDL handle);
+
+/*******************************************************************************
+**
+** Function BTA_AvCloseRc
+**
+** Description Close an AVRCP connection
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvCloseRc(UINT8 rc_handle);
+
+/*******************************************************************************
+**
+** Function BTA_AvMetaRsp
+**
+** Description Send a Metadata command/response. The message contained
+** in p_pkt can be composed with AVRC utility functions.
+** This function can only be used if AV is enabled with feature
+** BTA_AV_FEAT_METADATA.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
+ BT_HDR *p_pkt);
+
+/*******************************************************************************
+**
+** Function BTA_AvMetaCmd
+**
+** Description Send a Metadata/Advanced Control command. The message contained
+** in p_pkt can be composed with AVRC utility functions.
+** This function can only be used if AV is enabled with feature
+** BTA_AV_FEAT_METADATA.
+** This message is sent only when the peer supports the TG role.
+*8 The only command makes sense right now is the absolute volume command.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p_pkt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_AV_API_H */
diff --git a/bta/include/bta_av_ci.h b/bta/include/bta_av_ci.h
new file mode 100644
index 0000000..c09e5e9
--- /dev/null
+++ b/bta/include/bta_av_ci.h
@@ -0,0 +1,62 @@
+/*****************************************************************************
+**
+** Name: bta_av_ci.h
+**
+** Description: This is the interface file for advanced audio/video call-in
+** functions.
+**
+** Copyright (c) 2005, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_AV_CI_H
+#define BTA_AV_CI_H
+
+#include "bta_av_api.h"
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_av_ci_src_data_ready
+**
+** Description This function sends an event to the AV indicating that
+** the phone has audio stream data ready to send and AV
+** should call bta_av_co_audio_src_data_path() or
+** bta_av_co_video_src_data_path().
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl);
+
+/*******************************************************************************
+**
+** Function bta_av_ci_setconfig
+**
+** Description This function must be called in response to function
+** bta_av_co_audio_setconfig() or bta_av_co_video_setconfig.
+** Parameter err_code is set to an AVDTP status value;
+** AVDT_SUCCESS if the codec configuration is ok,
+** otherwise error.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code,
+ UINT8 category, UINT8 num_seid, UINT8 *p_seid,
+ BOOLEAN recfg_needed);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_AV_CI_H */
+
diff --git a/bta/include/bta_av_co.h b/bta/include/bta_av_co.h
new file mode 100644
index 0000000..2f41180
--- /dev/null
+++ b/bta/include/bta_av_co.h
@@ -0,0 +1,400 @@
+/*****************************************************************************
+**
+** Name: bta_av_co.h
+**
+** Description: This is the interface file for advanced audio/video call-out
+** functions.
+**
+** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_AV_CO_H
+#define BTA_AV_CO_H
+
+#include "l2c_api.h"
+#include "bta_av_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* TRUE to use SCMS-T content protection */
+#ifndef BTA_AV_CO_CP_SCMS_T
+#define BTA_AV_CO_CP_SCMS_T FALSE
+#endif
+
+/* the content protection IDs assigned by BT SIG */
+#define BTA_AV_CP_SCMS_T_ID 0x0002
+#define BTA_AV_CP_DTCP_ID 0x0001
+
+#define BTA_AV_CP_LOSC 2
+#define BTA_AV_CP_INFO_LEN 3
+
+#define BTA_AV_CP_SCMS_COPY_MASK 3
+#define BTA_AV_CP_SCMS_COPY_FREE 2
+#define BTA_AV_CP_SCMS_COPY_ONCE 1
+#define BTA_AV_CP_SCMS_COPY_NEVER 0
+
+#define BTA_AV_CO_DEFAULT_AUDIO_OFFSET AVDT_MEDIA_OFFSET
+
+enum
+{
+ BTA_AV_CO_ST_INIT,
+ BTA_AV_CO_ST_IN,
+ BTA_AV_CO_ST_OUT,
+ BTA_AV_CO_ST_OPEN,
+ BTA_AV_CO_ST_STREAM
+};
+
+/* data type for the Video Codec Information Element*/
+typedef struct
+{
+ UINT8 codec_type; /* Codec type */
+ UINT8 levels; /* level mask */
+} tBTA_AV_VIDEO_CFG;
+
+/* data type for the Audio Codec Information*/
+typedef struct
+{
+ UINT16 bit_rate; /* SBC encoder bit rate in kbps */
+ UINT16 bit_rate_busy; /* SBC encoder bit rate in kbps */
+ UINT16 bit_rate_swampd;/* SBC encoder bit rate in kbps */
+ UINT8 busy_level; /* Busy level indicating the bit-rate to be used */
+ UINT8 codec_info[AVDT_CODEC_SIZE];
+ UINT8 codec_type; /* Codec type */
+} tBTA_AV_AUDIO_CODEC_INFO;
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_init
+**
+** Description This callout function is executed by AV when it is
+** started by calling BTA_AvEnable(). This function can be
+** used by the phone to initialize audio paths or for other
+** initialization purposes.
+**
+**
+** Returns Stream codec and content protection capabilities info.
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info,
+ UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_init
+**
+** Description This callout function is executed by AV when it is
+** started by calling BTA_AvEnable(). This function can be
+** used by the phone to initialize video paths or for other
+** initialization purposes.
+**
+**
+** Returns Stream codec and content protection capabilities info.
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN bta_av_co_video_init(UINT8 *p_codec_type, UINT8 *p_codec_info,
+ UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_disc_res
+**
+** Description This callout function is executed by AV to report the
+** number of stream end points (SEP) were found during the
+** AVDT stream discovery process.
+**
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_audio_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps,
+ UINT8 num_snk, BD_ADDR addr);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_disc_res
+**
+** Description This callout function is executed by AV to report the
+** number of stream end points (SEP) were found during the
+** AVDT stream discovery process.
+**
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_video_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps,
+ UINT8 num_snk, BD_ADDR addr);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_getconfig
+**
+** Description This callout function is executed by AV to retrieve the
+** desired codec and content protection configuration for the
+** audio stream.
+**
+**
+** Returns Stream codec and content protection configuration info.
+**
+*******************************************************************************/
+BTA_API extern UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
+ UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
+ UINT8 *p_num_protect, UINT8 *p_protect_info);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_getconfig
+**
+** Description This callout function is executed by AV to retrieve the
+** desired codec and content protection configuration for the
+** video stream.
+**
+**
+** Returns Stream codec and content protection configuration info.
+**
+*******************************************************************************/
+BTA_API extern UINT8 bta_av_co_video_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
+ UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
+ UINT8 *p_num_protect, UINT8 *p_protect_info);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_setconfig
+**
+** Description This callout function is executed by AV to set the
+** codec and content protection configuration of the audio stream.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
+ UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
+ UINT8 num_protect, UINT8 *p_protect_info);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_setconfig
+**
+** Description This callout function is executed by AV to set the
+** codec and content protection configuration of the video stream.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_video_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
+ UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
+ UINT8 num_protect, UINT8 *p_protect_info);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_open
+**
+** Description This function is called by AV when the audio stream connection
+** is opened.
+** BTA-AV maintains the MTU of A2DP streams.
+** If this is the 2nd audio stream, mtu is the smaller of the 2
+** streams.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_audio_open(tBTA_AV_HNDL hndl,
+ tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
+ UINT16 mtu);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_open
+**
+** Description This function is called by AV when the video stream connection
+** is opened.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_video_open(tBTA_AV_HNDL hndl,
+ tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
+ UINT16 mtu);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_close
+**
+** Description This function is called by AV when the audio stream connection
+** is closed.
+** BTA-AV maintains the MTU of A2DP streams.
+** When one stream is closed and no other audio stream is open,
+** mtu is reported as 0.
+** Otherwise, the MTU remains open is reported.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_audio_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
+ UINT16 mtu);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_close
+**
+** Description This function is called by AV when the video stream connection
+** is closed.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_video_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
+ UINT16 mtu);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_start
+**
+** Description This function is called by AV when the audio streaming data
+** transfer is started.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_audio_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_start
+**
+** Description This function is called by AV when the video streaming data
+** transfer is started.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_video_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_stop
+**
+** Description This function is called by AV when the audio streaming data
+** transfer is stopped.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_audio_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_stop
+**
+** Description This function is called by AV when the video streaming data
+** transfer is stopped.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_video_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_src_data_path
+**
+** Description This function is called to get the next data buffer from
+** the audio codec
+**
+** Returns NULL if data is not ready.
+** Otherwise, a GKI buffer (BT_HDR*) containing the audio data.
+**
+*******************************************************************************/
+BTA_API extern void * bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type,
+ UINT32 *p_len, UINT32 *p_timestamp);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_src_data_path
+**
+** Description This function is called to get the next data buffer from
+** the video codec.
+**
+** Returns NULL if data is not ready.
+** Otherwise, a video data buffer (UINT8*).
+**
+*******************************************************************************/
+BTA_API extern void * bta_av_co_video_src_data_path(tBTA_AV_CODEC codec_type,
+ UINT32 *p_len, UINT32 *p_timestamp);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_drop
+**
+** Description An Audio packet is dropped. .
+** It's very likely that the connected headset with this handle
+** is moved far away. The implementation may want to reduce
+** the encoder bit rate setting to reduce the packet size.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_audio_drop(tBTA_AV_HNDL hndl);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_report_conn
+**
+** Description This function is called by AV when the reporting channel is
+** opened (open=TRUE) or closed (open=FALSE).
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_video_report_conn (BOOLEAN open, UINT8 avdt_handle);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_report_rr
+**
+** Description This function is called by AV when a Receiver Report is
+** received
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_video_report_rr (UINT32 packet_lost);
+
+/*******************************************************************************
+**
+** Function bta_av_co_audio_delay
+**
+** Description This function is called by AV when the audio stream connection
+** needs to send the initial delay report to the connected SRC.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_audio_delay(tBTA_AV_HNDL hndl, UINT16 delay);
+
+/*******************************************************************************
+**
+** Function bta_av_co_video_delay
+**
+** Description This function is called by AV when the video stream connection
+** needs to send the initial delay report to the connected SRC.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_av_co_video_delay(tBTA_AV_HNDL hndl, UINT16 delay);
+
+#endif /* BTA_AV_CO_H */
+
diff --git a/bta/include/bta_dg_api.h b/bta/include/bta_dg_api.h
new file mode 100644
index 0000000..3e8b2db
--- /dev/null
+++ b/bta/include/bta_dg_api.h
@@ -0,0 +1,198 @@
+/*****************************************************************************
+**
+** Name: bta_dg_api.h
+**
+** Description: This is the public interface file for the data gateway
+** (DG) subsystem of BTA, Widcomm's Bluetooth application
+** layer for mobile phones.
+**
+** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_DG_API_H
+#define BTA_DG_API_H
+
+#include "bta_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* DG Callback events */
+#define BTA_DG_ENABLE_EVT 0 /* DG service is enabled. */
+#define BTA_DG_LISTEN_EVT 1 /* Server listen is started. */
+#define BTA_DG_OPENING_EVT 2 /* Client connection opening. */
+#define BTA_DG_OPEN_EVT 3 /* Connection has been opened. */
+#define BTA_DG_CLOSE_EVT 4 /* Connection has been closed. */
+
+typedef UINT8 tBTA_DG_EVT;
+
+/* Event associated with BTA_DG_LISTEN_EVT */
+typedef struct
+{
+ UINT16 handle; /* Handle associated with this server. */
+ UINT8 app_id; /* ID associated with call to BTA_DgListen(). */
+} tBTA_DG_LISTEN;
+
+/* Event associated with BTA_DG_OPENING_EVT */
+typedef struct
+{
+ UINT16 handle; /* Handle associated with this server. */
+ UINT8 app_id; /* ID associated with call to BTA_DgListen(). */
+} tBTA_DG_OPENING;
+
+
+/* Event associated with BTA_DG_OPEN_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address of peer device. */
+ UINT16 handle; /* Handle associated with this server. */
+ tBTA_SERVICE_ID service; /* Service ID of opened service. */
+ UINT8 app_id; /* ID associated with call to BTA_DgListen(). */
+} tBTA_DG_OPEN;
+
+/* Event associated with BTA_DG_CLOSE_EVT */
+typedef struct
+{
+ UINT16 handle; /* Handle associated with this server. */
+ UINT8 app_id; /* ID associated with call to BTA_DgListen(). */
+} tBTA_DG_CLOSE;
+
+/* Union of all DG callback structures */
+typedef union
+{
+ tBTA_DG_LISTEN listen; /* Server listen is started. */
+ tBTA_DG_OPENING opening; /* Client connection opening. */
+ tBTA_DG_OPEN open; /* Connection has been opened. */
+ tBTA_DG_CLOSE close; /* Connection has been closed. */
+} tBTA_DG;
+
+/* DG callback */
+typedef void (tBTA_DG_CBACK)(tBTA_DG_EVT event, tBTA_DG *p_data);
+
+/* configuration structure */
+typedef struct
+{
+ UINT16 mtu[4]; /* MTU for SPP, DUN, FAX, LAP */
+
+} tBTA_DG_CFG;
+
+/* Number of DG servers */
+#ifndef BTA_DG_NUM_CONN
+#define BTA_DG_NUM_CONN 5
+#endif
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function BTA_DgEnable
+**
+** Description Enable the data gateway service. This function must be
+** called before any other functions in the DG API are called.
+** When the enable operation is complete the callback function
+** will be called with a BTA_DG_ENABLE_EVT. After the DG
+** service is enabled a server can be started by calling
+** BTA_DgListen().
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DgEnable(tBTA_DG_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_DgDisable
+**
+** Description Disable the data gateway service. Before calling this
+** function all DG servers must be shut down by calling
+** BTA_DgShutdown().
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DgDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_DgListen
+**
+** Description Create a DG server for DUN, FAX or SPP. After creating a
+** server peer devices can open an RFCOMM connection to the
+** server. When the listen operation has started the callback
+** function will be called with a BTA_DG_LISTEN_EVT providing
+** the handle associated with this server. The handle
+** identifies server when calling other DG functions such as
+** BTA_DgClose() or BTA_DgShutdown().
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DgListen(tBTA_SERVICE_ID service, tBTA_SEC sec_mask,
+ char *p_service_name, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_DgOpen
+**
+** Description Open a DG client connection to a peer device. BTA first
+** searches for the requested service on the peer device. If
+** the service name is specified it will also match the
+** service name. Then BTA initiates an RFCOMM connection to
+** the peer device. The handle associated with the connection
+** is returned with the BTA_DG_OPEN_EVT. If the connection
+** fails or closes at any time the callback function will be
+** called with a BTA_DG_CLOSE_EVT.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DgOpen(BD_ADDR bd_addr, tBTA_SERVICE_ID service,
+ tBTA_SEC sec_mask, char *p_service_name, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_DgClose
+**
+** Description Close a DG connection to a peer device. BTA will
+** close the RFCOMM connection to the peer device. Servers
+** will still be listening for subsequent connections.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DgClose(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function BTA_DgShutdown
+**
+** Description Shutdown a DG server previously started by calling
+** BTA_DgListen(). The server will no longer be available
+** to peer devices. If there is currently a connection open
+** to the server it will be closed.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_DgShutdown(UINT16 handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_DG_API_H */
+
diff --git a/bta/include/bta_dg_ci.h b/bta/include/bta_dg_ci.h
new file mode 100644
index 0000000..1f52ab2
--- /dev/null
+++ b/bta/include/bta_dg_ci.h
@@ -0,0 +1,107 @@
+/*****************************************************************************
+**
+** Name: bta_dg_ci.h
+**
+** Description: This is the interface file for data gateway call-in
+** functions.
+**
+** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_DG_CI_H
+#define BTA_DG_CI_H
+
+#include "bta_dg_api.h"
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_dg_ci_tx_ready
+**
+** Description This function sends an event to DG indicating the phone is
+** ready for more data and DG should call bta_dg_co_tx_path().
+** This function is used when the TX data path is configured
+** to use a pull interface.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_ci_tx_ready(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function bta_dg_ci_rx_ready
+**
+** Description This function sends an event to DG indicating the phone
+** has data available to send to DG and DG should call
+** bta_dg_co_rx_path(). This function is used when the RX
+** data path is configured to use a pull interface.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_ci_rx_ready(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function bta_dg_ci_tx_flow
+**
+** Description This function is called to enable or disable data flow on
+** the TX path. The phone should call this function to
+** disable data flow when it is congested and cannot handle
+** any more data sent by bta_dg_co_tx_write() or
+** bta_dg_co_tx_writebuf(). This function is used when the
+** TX data path is configured to use a push interface.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_ci_tx_flow(UINT16 handle, BOOLEAN enable);
+
+/*******************************************************************************
+**
+** Function bta_dg_ci_rx_writebuf
+**
+** Description This function is called to send data to the phone when
+** the RX path is configured to use a push interface with
+** zero copy. The function sends an event to DG containing
+** the data buffer. The buffer must be allocated using
+** functions GKI_getbuf() or GKI_getpoolbuf(). The buffer
+** will be freed by BTA; the phone must not free the buffer.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_ci_rx_writebuf(UINT16 handle, BT_HDR *p_buf);
+
+/*******************************************************************************
+**
+** Function bta_dg_ci_control
+**
+** Description This function is called to send RS-232 signal information
+** to DG to be propagated over RFCOMM.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_ci_control(UINT16 handle, UINT8 signals, UINT8 values);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_DG_CI_H */
+
diff --git a/bta/include/bta_dg_co.h b/bta/include/bta_dg_co.h
new file mode 100644
index 0000000..667a01c
--- /dev/null
+++ b/bta/include/bta_dg_co.h
@@ -0,0 +1,198 @@
+/*****************************************************************************
+**
+** Name: bta_dg_co.h
+**
+** Description: This is the interface file for data gateway call-out
+** functions.
+**
+** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_DG_CO_H
+#define BTA_DG_CO_H
+
+#include "bta_dg_api.h"
+#include "l2c_api.h"
+#include "rfcdefs.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+/* RS-232 Signal Mask */
+#define BTA_DG_DTRDSR 0x01 /* DTR/DSR signal. */
+#define BTA_DG_RTSCTS 0x02 /* RTS/CTS signal. */
+#define BTA_DG_RI 0x04 /* Ring indicator signal. */
+#define BTA_DG_CD 0x08 /* Carrier detect signal. */
+
+/* RS-232 Signal Values */
+#define BTA_DG_DTRDSR_ON 0x01 /* DTR/DSR signal on. */
+#define BTA_DG_DTRDSR_OFF 0x00 /* DTR/DSR signal off. */
+#define BTA_DG_RTSCTS_ON 0x02 /* RTS/CTS signal on. */
+#define BTA_DG_RTSCTS_OFF 0x00 /* RTS/CTS signal off. */
+#define BTA_DG_RI_ON 0x04 /* Ring indicator signal on. */
+#define BTA_DG_RI_OFF 0x00 /* Ring indicator signal off. */
+#define BTA_DG_CD_ON 0x08 /* Carrier detect signal on. */
+#define BTA_DG_CD_OFF 0x00 /* Carrier detect signal off. */
+
+/* Data Flow Mask */
+#define BTA_DG_RX_PUSH_BUF 0x01 /* RX push with zero copy. */
+#define BTA_DG_RX_PULL 0x02 /* RX pull. */
+#define BTA_DG_TX_PUSH 0x00 /* TX push. */
+#define BTA_DG_TX_PUSH_BUF 0x10 /* TX push with zero copy. */
+#define BTA_DG_TX_PULL 0x20 /* TX pull. */
+
+/* BT_HDR buffer offset */
+#define BTA_DG_MIN_OFFSET (L2CAP_MIN_OFFSET + RFCOMM_MIN_OFFSET)
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function bta_dg_co_init
+**
+** Description This callout function is executed by DG when a server is
+** started by calling BTA_DgListen(). This function can be
+** used by the phone to initialize data paths or for other
+** initialization purposes. The function must return the
+** data flow mask as described below.
+**
+**
+** Returns Data flow mask.
+**
+*******************************************************************************/
+BTA_API extern UINT8 bta_dg_co_init(UINT16 handle, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_dg_co_open
+**
+** Description This function is executed by DG when a connection to a
+** server is opened. The phone can use this function to set
+** up data paths or perform any required initialization or
+** set up particular to the connected service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_co_open(UINT16 handle, UINT8 app_id, tBTA_SERVICE_ID service, UINT16 mtu);
+
+/*******************************************************************************
+**
+** Function bta_dg_co_close
+**
+** Description This function is called by DG when a connection to a
+** server is closed.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_co_close(UINT16 handle, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_dg_co_tx_path
+**
+** Description This function is called by DG to transfer data on the
+** TX path; that is, data being sent from BTA to the phone.
+** This function is used when the TX data path is configured
+** to use the pull interface. The implementation of this
+** function will typically call Bluetooth stack functions
+** PORT_Read() or PORT_ReadData() to read data from RFCOMM
+** and then a platform-specific function to send data that
+** data to the phone.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_co_tx_path(UINT16 handle, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_dg_co_rx_path
+**
+** Description This function is called by DG to transfer data on the
+** RX path; that is, data being sent from the phone to BTA.
+** This function is used when the RX data path is configured
+** to use the pull interface. The implementation of this
+** function will typically call a platform-specific function
+** to read data from the phone and then call Bluetooth stack
+** functions PORT_Write() or PORT_WriteData() to send data
+** to RFCOMM.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_co_rx_path(UINT16 handle, UINT8 app_id, UINT16 mtu);
+
+/*******************************************************************************
+**
+** Function bta_dg_co_tx_write
+**
+** Description This function is called by DG to send data to the phone
+** when the TX path is configured to use a push interface.
+** The implementation of this function must copy the data to
+** the phone's memory.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_co_tx_write(UINT16 handle, UINT8 app_id, UINT8 *p_data, UINT16 len);
+
+/*******************************************************************************
+**
+** Function bta_dg_co_tx_writebuf
+**
+** Description This function is called by DG to send data to the phone
+** when the TX path is configured to use a push interface with
+** zero copy. The phone must free the buffer using function
+** GKI_freebuf() when it is through processing the buffer.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_co_tx_writebuf(UINT16 handle, UINT8 app_id, BT_HDR *p_buf);
+
+/*******************************************************************************
+**
+** Function bta_dg_co_rx_flow
+**
+** Description This function is called by DG to enable or disable
+** data flow on the RX path when it is configured to use
+** a push interface. If data flow is disabled the phone must
+** not call bta_dg_ci_rx_write() or bta_dg_ci_rx_writebuf()
+** until data flow is enabled again.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_co_rx_flow(UINT16 handle, UINT8 app_id, BOOLEAN enable);
+
+/*******************************************************************************
+**
+** Function bta_dg_co_control
+**
+** Description This function is called by DG to send RS-232 signal
+** information to the phone. This function allows these
+** signals to be propagated from the RFCOMM channel to the
+** phone. If the phone does not use these signals the
+** implementation of this function can do nothing.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dg_co_control(UINT16 handle, UINT8 app_id, UINT8 signals, UINT8 values);
+
+#endif /* BTA_DG_CO_H */
+
diff --git a/bta/include/bta_dm_ci.h b/bta/include/bta_dm_ci.h
new file mode 100644
index 0000000..f662f17
--- /dev/null
+++ b/bta/include/bta_dm_ci.h
@@ -0,0 +1,69 @@
+/*****************************************************************************
+**
+** Name: bta_dm_ci.h
+**
+** Description: This is the interface file for device mananger call-in
+** functions.
+**
+** Copyright (c) 2006, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_DM_CI_H
+#define BTA_DM_CI_H
+
+#include "bta_api.h"
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_dm_ci_io_req
+**
+** Description This function must be called in response to function
+** bta_dm_co_io_req(), if *p_oob_data is set to BTA_OOB_UNKNOWN
+** by bta_dm_co_io_req().
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_ci_io_req(BD_ADDR bd_addr, tBTA_IO_CAP io_cap,
+ tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req);
+
+/*******************************************************************************
+**
+** Function bta_dm_ci_rmt_oob
+**
+** Description This function must be called in response to function
+** bta_dm_co_rmt_oob() to provide the OOB data associated
+** with the remote device.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr,
+ BT_OCTET16 c, BT_OCTET16 r);
+/*******************************************************************************
+**
+** Function bta_dm_sco_ci_data_ready
+**
+** Description This function sends an event to indicating that the phone
+** has SCO data ready..
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_sco_ci_data_ready(UINT16 event, UINT16 sco_handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/bta/include/bta_dm_co.h b/bta/include/bta_dm_co.h
new file mode 100644
index 0000000..cadf6bf
--- /dev/null
+++ b/bta/include/bta_dm_co.h
@@ -0,0 +1,262 @@
+/*****************************************************************************
+**
+** Name: bta_dm_co.h
+**
+** Description: This is the interface file for device mananger callout
+** functions.
+**
+** Copyright (c) 2006-2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_DM_CO_H
+#define BTA_DM_CO_H
+
+#include "bta_sys.h"
+
+
+#ifndef BTA_SCO_OUT_PKT_SIZE
+ #define BTA_SCO_OUT_PKT_SIZE BTM_SCO_DATA_SIZE_MAX
+#endif
+
+#define BTA_SCO_CODEC_PCM 0 /* used for regular SCO */
+#define BTA_SCO_CODEC_SBC 1 /* used for WBS */
+typedef UINT8 tBTA_SCO_CODEC_TYPE;
+
+#define BTA_DM_SCO_SAMP_RATE_8K 8000
+#define BTA_DM_SCO_SAMP_RATE_16K 16000
+
+/* SCO codec information */
+typedef struct
+{
+ tBTA_SCO_CODEC_TYPE codec_type;
+}tBTA_CODEC_INFO;
+
+#define BTA_DM_SCO_ROUTE_PCM BTM_SCO_ROUTE_PCM
+#define BTA_DM_SCO_ROUTE_HCI BTM_SCO_ROUTE_HCI
+
+typedef tBTM_SCO_ROUTE_TYPE tBTA_DM_SCO_ROUTE_TYPE;
+
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function bta_dm_co_io_req
+**
+** Description This callout function is executed by DM to get IO capabilities
+** of the local device for the Simple Pairing process
+**
+** Parameters bd_addr - The peer device
+** *p_io_cap - The local Input/Output capabilities
+** *p_oob_data - TRUE, if OOB data is available for the peer device.
+** *p_auth_req - TRUE, if MITM protection is required.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_co_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
+ tBTA_OOB_DATA *p_oob_data, tBTA_AUTH_REQ *p_auth_req,
+ BOOLEAN is_orig);
+
+/*******************************************************************************
+**
+** Function bta_dm_co_io_rsp
+**
+** Description This callout function is executed by DM to report IO capabilities
+** of the peer device for the Simple Pairing process
+**
+** Parameters bd_addr - The peer device
+** io_cap - The remote Input/Output capabilities
+** oob_data - TRUE, if OOB data is available for the peer device.
+** auth_req - TRUE, if MITM protection is required.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_co_io_rsp(BD_ADDR bd_addr, tBTA_IO_CAP io_cap,
+ tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req);
+
+/*******************************************************************************
+**
+** Function bta_dm_co_lk_upgrade
+**
+** Description This callout function is executed by DM to check if the
+** platform wants allow link key upgrade
+**
+** Parameters bd_addr - The peer device
+** *p_upgrade - TRUE, if link key upgrade is desired.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_co_lk_upgrade(BD_ADDR bd_addr, BOOLEAN *p_upgrade );
+
+/*******************************************************************************
+**
+** Function bta_dm_co_loc_oob
+**
+** Description This callout function is executed by DM to report the OOB
+** data of the local device for the Simple Pairing process
+**
+** Parameters valid - TRUE, if the local OOB data is retrieved from LM
+** c - Simple Pairing Hash C
+** r - Simple Pairing Randomnizer R
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_co_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r);
+
+/*******************************************************************************
+**
+** Function bta_dm_co_rmt_oob
+**
+** Description This callout function is executed by DM to request the OOB
+** data for the remote device for the Simple Pairing process
+**
+** Parameters bd_addr - The peer device
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_co_rmt_oob(BD_ADDR bd_addr);
+
+/*****************************************************************************
+** SCO over HCI Function Declarations
+*****************************************************************************/
+/*******************************************************************************
+**
+** Function bta_dm_sco_co_init
+**
+** Description This function can be used by the phone to initialize audio
+** codec or for other initialization purposes before SCO connection
+** is opened.
+**
+**
+** Returns Void.
+**
+*******************************************************************************/
+BTA_API extern tBTA_DM_SCO_ROUTE_TYPE bta_dm_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
+ tBTA_CODEC_INFO *p_codec_info, UINT8 app_id);
+
+
+/*******************************************************************************
+**
+** Function bta_dm_sco_co_open
+**
+** Description This function is executed when a SCO connection is open.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_sco_co_open(UINT16 handle, UINT8 pkt_size, UINT16 event);
+
+/*******************************************************************************
+**
+** Function bta_dm_sco_co_close
+**
+** Description This function is called when a SCO connection is closed
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_sco_co_close(void);
+
+/*******************************************************************************
+**
+** Function bta_dm_sco_co_out_data
+**
+** Description This function is called to send SCO data over HCI.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_sco_co_out_data(BT_HDR **p_buf);
+
+/*******************************************************************************
+**
+** Function bta_dm_sco_co_in_data
+**
+** Description This function is called to send incoming SCO data to application.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_sco_co_in_data(BT_HDR *p_buf, tBTM_SCO_DATA_FLAG status);
+
+
+
+/*******************************************************************************
+**
+** Function bta_dm_co_ble_io_req
+**
+** Description This callout function is executed by DM to get BLE IO capabilities
+** before SMP pairing gets going.
+**
+** Parameters bd_addr - The peer device
+** *p_io_cap - The local Input/Output capabilities
+** *p_oob_data - TRUE, if OOB data is available for the peer device.
+** *p_auth_req - Auth request setting (Bonding and MITM required or not)
+** *p_max_key_size - max key size local device supported.
+** *p_init_key - initiator keys.
+** *p_resp_key - responder keys.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
+ tBTA_OOB_DATA *p_oob_data,
+ tBTA_LE_AUTH_REQ *p_auth_req,
+ UINT8 *p_max_key_size,
+ tBTA_LE_KEY_TYPE *p_init_key,
+ tBTA_LE_KEY_TYPE *p_resp_key );
+
+
+/*******************************************************************************
+**
+** Function bta_dm_co_ble_local_key_reload
+**
+** Description This callout function is to load the local BLE keys if available
+** on the device.
+**
+** Parameters none
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_co_ble_load_local_keys (tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er,
+ tBTA_BLE_LOCAL_ID_KEYS *p_id_keys);
+
+// btla-specific ++
+/*******************************************************************************
+**
+** Function bta_dm_co_ble_io_req
+**
+** Description This callout function is executed by DM to get BLE IO capabilities
+** before SMP pairing gets going.
+**
+** Parameters bd_addr - The peer device
+** *p_io_cap - The local Input/Output capabilities
+** *p_oob_data - TRUE, if OOB data is available for the peer device.
+** *p_auth_req - Auth request setting (Bonding and MITM required or not)
+** *p_max_key_size - max key size local device supported.
+** *p_init_key - initiator keys.
+** *p_resp_key - responder keys.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
+ tBTA_OOB_DATA *p_oob_data,
+ tBTA_LE_AUTH_REQ *p_auth_req,
+ UINT8 *p_max_key_size,
+ tBTA_LE_KEY_TYPE *p_init_key,
+ tBTA_LE_KEY_TYPE *p_resp_key );
+// btla-specific --
+
+#endif
diff --git a/bta/include/bta_fs_api.h b/bta/include/bta_fs_api.h
new file mode 100644
index 0000000..c0cb4f5
--- /dev/null
+++ b/bta/include/bta_fs_api.h
@@ -0,0 +1,32 @@
+/*****************************************************************************
+**
+** Name: bta_fs_api.h
+**
+** Description: This is the public interface file for the
+** file system of BTA, Widcomm's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2003 - 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_FS_API_H
+#define BTA_FS_API_H
+
+#include "bta_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* Configuration structure */
+typedef struct
+{
+ UINT16 max_file_len; /* Maximum size file name */
+ UINT16 max_path_len; /* Maximum path length (includes appended file name) */
+ char path_separator; /* 0x2f ('/'), or 0x5c ('\') */
+} tBTA_FS_CFG;
+
+extern tBTA_FS_CFG * p_bta_fs_cfg;
+
+#endif /* BTA_FS_API_H */
diff --git a/bta/include/bta_fs_ci.h b/bta/include/bta_fs_ci.h
new file mode 100644
index 0000000..c60b3ba
--- /dev/null
+++ b/bta/include/bta_fs_ci.h
@@ -0,0 +1,244 @@
+/*****************************************************************************
+**
+** Name: bta_fs_ci.h
+**
+** Description: This is the interface file for file system
+** call-in functions.
+**
+** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_FS_CI_H
+#define BTA_FS_CI_H
+
+#include "bta_fs_co.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* Open Complete Event */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_FS_CO_STATUS status;
+ UINT32 file_size;
+ int fd;
+ const char *p_file;
+} tBTA_FS_CI_OPEN_EVT;
+
+/* Read Ready Event */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_FS_CO_STATUS status;
+ int fd;
+ UINT16 num_read;
+} tBTA_FS_CI_READ_EVT;
+
+/* Write Ready Event */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_FS_CO_STATUS status;
+ int fd;
+} tBTA_FS_CI_WRITE_EVT;
+
+/* Get Directory Entry Event */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_FS_CO_STATUS status;
+} tBTA_FS_CI_GETDIR_EVT;
+
+/* Resume Information Event */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_FS_CO_STATUS status;
+ BD_ADDR_PTR p_addr;
+ UINT8 *p_sess_info;
+ UINT32 timeout;
+ UINT32 offset;
+ UINT8 ssn;
+ UINT8 info;
+} tBTA_FS_CI_RESUME_EVT;
+
+/* Action Complete Event */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_FS_CO_STATUS status;
+} tBTA_FS_CI_ACTION_EVT;
+
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_fs_ci_write
+**
+** Description This function sends an event to BTA indicating the phone
+** has written the number of bytes specified in the call-out
+** function, bta_fs_co_write(), and is ready for more data.
+** This function is used to control the TX data flow.
+** Note: The data buffer is released by the stack aioer
+** calling this function.
+**
+** Parameters fd - file descriptor passed to the stack in the
+** bta_fs_ci_open call-in function.
+** status - BTA_FS_CO_OK, BTA_FS_CO_NOSPACE, or BTA_FS_CO_FAIL
+** evt - Used Internally by BTA -> MUST be same value passed
+** in call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_ci_write(int fd, tBTA_FS_CO_STATUS status, UINT16 evt);
+
+/*******************************************************************************
+**
+** Function bta_fs_ci_read
+**
+** Description This function sends an event to BTA indicating the phone has
+** read in the requested amount of data specified in the
+** bta_fs_co_read() call-out function. It should only be called
+** when the requested number of bytes has been read in, or aioer
+** the end of the file has been detected.
+**
+** Parameters fd - file descriptor passed to the stack in the
+** bta_fs_ci_open call-in function.
+** num_bytes_read - number of bytes read into the buffer
+** specified in the read callout-function.
+** status - BTA_FS_CO_OK if full buffer of data,
+** BTA_FS_CO_EOF if the end of file has been reached,
+** BTA_FS_CO_FAIL if an error has occurred.
+** evt - Used Internally by BTA -> MUST be same value passed
+** in call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_ci_read(int fd, UINT16 num_bytes_read,
+ tBTA_FS_CO_STATUS status, UINT16 evt);
+
+/*******************************************************************************
+**
+** Function bta_fs_ci_open
+**
+** Description This function sends an event to BTA indicating the phone has
+** finished opening a file for reading or writing.
+**
+** Parameters fd - file descriptor passed to the stack in the
+** bta_fs_ci_open call-in function.
+** status - BTA_FS_CO_OK if file was opened in mode specified
+** in the call-out function.
+** BTA_FS_CO_EACCES if the file exists, but contains
+** the wrong access permissions.
+** BTA_FS_CO_FAIL if any other error has occurred.
+** file_size - The total size of the file
+** evt - Used Internally by BTA -> MUST be same value passed
+** in call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_ci_open(int fd, tBTA_FS_CO_STATUS status,
+ UINT32 file_size, UINT16 evt);
+
+/*******************************************************************************
+**
+** Function bta_fs_ci_direntry
+**
+** Description This function is called in response to the
+** bta_fs_co_getdirentry call-out function.
+**
+** Parameters status - BTA_FS_CO_OK if p_entry points to a valid entry.
+** BTA_FS_CO_EODIR if no more entries (p_entry is ignored).
+** BTA_FS_CO_FAIL if any errors have occurred.
+** evt - Used Internally by BTA -> MUST be same value passed
+** in call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_ci_direntry(tBTA_FS_CO_STATUS status, UINT16 evt);
+
+/*******************************************************************************
+**
+** Function bta_fs_ci_resume
+**
+** Description This function is called in response to the
+** bta_fs_co_resume call-out function.
+**
+** Parameters p_sess_info - the stored session ID and related information.
+** ssn - the stored session sequence number.
+** info - the stored BTA specific information (like last active operation).
+** status - BTA_FS_CO_OK if p_entry points to a valid entry.
+** BTA_FS_CO_FAIL if any errors have occurred.
+** evt - Used Internally by BTA -> MUST be same value passed
+** in call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_ci_resume (BD_ADDR_PTR p_addr, UINT8 *p_sess_info,
+ UINT32 timeout, UINT32 offset, UINT8 ssn, UINT8 info,
+ tBTA_FS_CO_STATUS status, UINT16 evt);
+
+/*******************************************************************************
+**
+** Function bta_fs_ci_action
+**
+** Description This function is called in response to one of the action
+** call-out functions: bta_fs_co_copy, bta_fs_co_rename or
+** bta_fs_co_set_perms.
+**
+** Parameters status - BTA_FS_CO_OK if the action is succession.
+** BTA_FS_CO_FAIL if any errors have occurred.
+** evt - Used Internally by BTA -> MUST be same value passed
+** in call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_ci_action(tBTA_FS_CO_STATUS status, UINT16 evt);
+
+/*******************************************************************************
+**
+** Function bta_fs_ci_resume_op
+**
+** Description This function sends an event to BTA indicating the phone has
+** finished opening a file for reading or writing on resume.
+**
+** Parameters fd - file descriptor passed to the stack in the
+** bta_fs_ci_open call-in function.
+** status - BTA_FS_CO_OK if file was opened in mode specified
+** in the call-out function.
+** BTA_FS_CO_EACCES if the file exists, but contains
+** the wrong access permissions.
+** BTA_FS_CO_FAIL if any other error has occurred.
+** p_file - The file name associated with fd
+** file_size - The total size of the file
+** evt - Used Internally by BTA -> MUST be same value passed
+** in call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_ci_resume_op(int fd, tBTA_FS_CO_STATUS status, const char *p_file,
+ UINT32 file_size, UINT16 evt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_FS_CI_H */
+
diff --git a/bta/include/bta_fs_co.h b/bta/include/bta_fs_co.h
new file mode 100644
index 0000000..6b068df
--- /dev/null
+++ b/bta/include/bta_fs_co.h
@@ -0,0 +1,690 @@
+/*****************************************************************************
+**
+** Name: bta_fs_co.h
+**
+** Description: This is the interface file for the synchronization
+** server call-out functions.
+**
+** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_FS_CO_H
+#define BTA_FS_CO_H
+
+#include <time.h>
+
+#include "bta_api.h"
+#include "goep_fs.h"
+#include "obx_api.h"
+
+/*****************************************************************************
+** Constants and Data Types
+*****************************************************************************/
+
+#ifndef BTA_FS_CO_MAX_SSN_ENTRIES
+#define BTA_FS_CO_MAX_SSN_ENTRIES 10
+#endif
+
+/* Maximum path length supported by FS_CO */
+#ifndef BTA_FS_CO_PATH_LEN
+#define BTA_FS_CO_PATH_LEN 294
+#endif
+
+#ifndef BTA_FS_CO_TEST_ROOT
+#define BTA_FS_CO_TEST_ROOT "test_files"
+#endif
+
+#define BTA_FS_CO_TEST_TYPE_NONE 0
+#define BTA_FS_CO_TEST_TYPE_REJECT 1
+#define BTA_FS_CO_TEST_TYPE_SUSPEND 2
+
+#ifndef BTA_FS_CO_TEST_AB_END
+#define BTA_FS_CO_TEST_AB_END BTA_FS_CO_TEST_TYPE_NONE
+#endif
+
+/**************************
+** Common Definitions
+***************************/
+
+/* Status codes returned by call-out functions, or in call-in functions as status */
+#define BTA_FS_CO_OK GOEP_OK
+#define BTA_FS_CO_FAIL GOEP_FAIL /* Used to pass all other errors */
+#define BTA_FS_CO_EACCES GOEP_EACCES
+#define BTA_FS_CO_ENOTEMPTY GOEP_ENOTEMPTY
+#define BTA_FS_CO_EOF GOEP_EOF
+#define BTA_FS_CO_EODIR GOEP_EODIR
+#define BTA_FS_CO_ENOSPACE GOEP_ENOSPACE/* Returned in bta_fs_ci_open if no room */
+#define BTA_FS_CO_EIS_DIR GOEP_EIS_DIR
+#define BTA_FS_CO_RESUME GOEP_RESUME /* used in ci_open, on resume */
+#define BTA_FS_CO_NONE GOEP_NONE /* used in ci_open, on resume (no file to resume) */
+
+typedef UINT16 tBTA_FS_CO_STATUS;
+
+/* the index to the permission flags */
+#define BTA_FS_PERM_USER 0
+#define BTA_FS_PERM_GROUP 1
+#define BTA_FS_PERM_OTHER 2
+/* max number of the permission flags */
+#define BTA_FS_PERM_SIZE 3
+
+/* Flags passed to the open function (bta_fs_co_open)
+** Values are OR'd together. (First 3 are
+** mutually exclusive.
+*/
+#define BTA_FS_O_RDONLY GOEP_O_RDONLY
+#define BTA_FS_O_WRONLY GOEP_O_WRONLY
+#define BTA_FS_O_RDWR GOEP_O_RDWR
+
+#define BTA_FS_O_CREAT GOEP_O_CREAT
+#define BTA_FS_O_EXCL GOEP_O_EXCL
+#define BTA_FS_O_TRUNC GOEP_O_TRUNC
+
+#define BTA_FS_O_MODE_MASK(x) (((UINT16)(x)) & 0x0003)
+
+/* Origin for the bta_fs_co_seek function */
+#define BTA_FS_SEEK_SET GOEP_SEEK_SET
+#define BTA_FS_SEEK_CUR GOEP_SEEK_CUR
+#define BTA_FS_SEEK_END GOEP_SEEK_END
+
+/* mode field in bta_fs_co_access callout */
+#define BTA_FS_ACC_EXIST GOEP_ACC_EXIST
+#define BTA_FS_ACC_READ GOEP_ACC_READ
+#define BTA_FS_ACC_RDWR GOEP_ACC_RDWR
+
+#define BTA_FS_LEN_UNKNOWN GOEP_LEN_UNKNOWN
+#define BTA_FS_INVALID_FD GOEP_INVALID_FD
+#define BTA_FS_INVALID_APP_ID (0xFF) /* this app_id is reserved */
+
+/* mode field in tBTA_FS_DIRENTRY (OR'd together) */
+#define BTA_FS_A_RDONLY GOEP_A_RDONLY
+#define BTA_FS_A_DIR GOEP_A_DIR /* Entry is a sub directory */
+
+#define BTA_FS_CTIME_LEN GOEP_CTIME_LEN /* Creation time "yyyymmddTHHMMSSZ" */
+
+/* Return structure type for a directory entry */
+typedef struct
+{
+ UINT32 refdata; /* holder for OS specific data used to get next entry */
+ UINT32 filesize;
+ char crtime[BTA_FS_CTIME_LEN]; /* "yyyymmddTHHMMSSZ", or "" if none */
+ char *p_name; /* Contains the addr of memory to copy name into */
+ UINT8 mode; /* BTA_FS_A_RDONLY and/or BTA_FS_A_DIR */
+} tBTA_FS_DIRENTRY;
+
+/* session state */
+enum
+{
+ BTA_FS_CO_SESS_ST_NONE,
+ BTA_FS_CO_SESS_ST_ACTIVE,
+ BTA_FS_CO_SESS_ST_SUSPEND,
+ BTA_FS_CO_SESS_ST_RESUMING
+};
+typedef UINT8 tBTA_FS_CO_SESS_ST;
+
+
+
+/* a data type to keep an array of ssn/file offset - the info can be saved to NV */
+typedef struct
+{
+ char path[BTA_FS_CO_PATH_LEN + 1]; /* the "current path". path[0]==0-> root */
+ char file[BTA_FS_CO_PATH_LEN + 1]; /* file[0] !=0 on resume -> the previous suspended session had opened files */
+ int oflags; /* the flag to open the file */
+ BD_ADDR bd_addr;
+ UINT8 sess_info[OBX_SESSION_INFO_SIZE];
+ UINT32 offset; /* last file offset */
+ UINT32 timeout; /* the timeout value on suspend */
+ time_t suspend_time; /* the time of suspend */
+ UINT16 nbytes; /* number of bytes for last read/write */
+ UINT8 ssn;
+ UINT8 info; /* info for BTA on the client side */
+ UINT8 app_id;
+ tBTA_FS_CO_SESS_ST sess_st;
+} tBTA_FS_CO_SESSION;
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+/**************************
+** Common Functions
+***************************/
+/*******************************************************************************
+**
+** Function bta_fs_co_init
+**
+** Description This function is executed as a part of the start up sequence
+** to make sure the control block is initialized.
+**
+** Parameters void.
+**
+** Returns void
+**
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_init(void);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_open
+**
+** Description This function is executed by BTA when a file is opened.
+** The phone uses this function to open
+** a file for reading or writing.
+**
+** Parameters p_path - Fully qualified path and file name.
+** oflags - permissions and mode (see constants above)
+** size - size of file to put (0 if unavailable or not applicable)
+** evt - event that must be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, a file descriptor (int),
+** if successful, and an error code (tBTA_FS_CO_STATUS)
+** are returned in the call-in function, bta_fs_ci_open().
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_open(const char *p_path, int oflags, UINT32 size,
+ UINT16 evt, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_session_info
+**
+** Description This function is executed by BTA when a reliable session is
+** established (p_sess_info != NULL) or ended (p_sess_info == NULL).
+**
+** Parameters bd_addr - the peer address
+** p_sess_info - the session ID and related information.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_session_info(BD_ADDR bd_addr, UINT8 *p_sess_info, UINT8 ssn,
+ tBTA_FS_CO_SESS_ST new_st, char *p_path, UINT8 *p_info, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_resume_op
+**
+** Description This function is executed by BTA when a reliable session is
+** resumed and there was an interrupted operation.
+**
+** Parameters offset - the session ID and related information.
+** evt - event that must be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_resume_op(UINT32 offset, UINT16 evt, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_suspend
+**
+** Description This function is executed by BTA when a reliable session is
+** suspended.
+**
+** Parameters bd_addr - the peer address
+** ssn - the session sequence number.
+** info - the BTA specific information (like last active operation).
+** p_offset- the location to receive object offset of the suspended session
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_suspend(BD_ADDR bd_addr, UINT8 *p_sess_info, UINT8 ssn,
+ UINT32 *p_timeout, UINT32 *p_offset, UINT8 info, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_resume
+**
+** Description This function is executed by BTA when resuming a session.
+** This is used to retrieve the session ID and related information
+**
+** Parameters evt - event that must be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, the related session information,
+** if successful, and an error code (tBTA_FS_CO_STATUS)
+** are returned in the call-in function, bta_fs_ci_resume().
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_resume(UINT16 evt, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_sess_ssn
+**
+** Description This function is executed by BTA when resuming a session.
+** This is used to inform call-out module if the ssn/file offset
+** needs to be adjusted.
+**
+** Parameters ssn - the session sequence number of the first request
+** after resume.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_sess_ssn(int fd, UINT8 ssn, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_setdir
+**
+** Description This function is executed by BTA when the server changes the
+** local path
+**
+** Parameters p_path - the new path.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_setdir(const char *p_path, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_close
+**
+** Description This function is called by BTA when a connection to a
+** client is closed.
+**
+** Parameters fd - file descriptor of file to close.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns (tBTA_FS_CO_STATUS) status of the call.
+** [BTA_FS_CO_OK if successful],
+** [BTA_FS_CO_FAIL if failed ]
+**
+*******************************************************************************/
+BTA_API extern tBTA_FS_CO_STATUS bta_fs_co_close(int fd, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_read
+**
+** Description This function is called by BTA to read in data from the
+** previously opened file on the phone.
+**
+** Parameters fd - file descriptor of file to read from.
+** p_buf - buffer to read the data into.
+** nbytes - number of bytes to read into the buffer.
+** evt - event that must be passed into the call-in function.
+** ssn - session sequence number. Ignored, if bta_fs_co_open
+** was not called with BTA_FS_CO_RELIABLE.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, bta_fs_ci_read() is
+** called with the buffer of data, along with the number
+** of bytes read into the buffer, and a status. The
+** call-in function should only be called when ALL requested
+** bytes have been read, the end of file has been detected,
+** or an error has occurred.
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_read(int fd, UINT8 *p_buf, UINT16 nbytes, UINT16 evt,
+ UINT8 ssn, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_write
+**
+** Description This function is called by io to send file data to the
+** phone.
+**
+** Parameters fd - file descriptor of file to write to.
+** p_buf - buffer to read the data from.
+** nbytes - number of bytes to write out to the file.
+** evt - event that must be passed into the call-in function.
+** ssn - session sequence number. Ignored, if bta_fs_co_open
+** was not called with BTA_FS_CO_RELIABLE.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, bta_fs_ci_write() is
+** called with the file descriptor and the status. The
+** call-in function should only be called when ALL requested
+** bytes have been written, or an error has been detected,
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_write(int fd, const UINT8 *p_buf, UINT16 nbytes, UINT16 evt,
+ UINT8 ssn, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_seek
+**
+** Description This function is called by io to move the file pointer
+** of a previously opened file to the specified location for
+** the next read or write operation.
+**
+** Parameters fd - file descriptor of file.
+** offset - Number of bytes from origin.
+** origin - Initial position: BTA_FS_SEEK_SET, BTA_FS_SEEK_CUR,
+** or BTA_FS_SEEK_END.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_seek (int fd, INT32 offset, INT16 origin, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_access
+**
+** Description This function is called to check the existence of a file or
+** directory.
+**
+** Parameters p_path - (input) file or directory to access (fully qualified path).
+** mode - (input) [BTA_FS_ACC_EXIST, BTA_FS_ACC_READ, or BTA_FS_ACC_RDWR]
+** p_is_dir - (output) returns TRUE if p_path specifies a directory.
+** app_id - (input) application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns (tBTA_FS_CO_STATUS) status of the call.
+** [BTA_FS_CO_OK if it exists]
+** [BTA_FS_CO_EACCES if permissions are wrong]
+** [BTA_FS_CO_FAIL if it does not exist]
+**
+*******************************************************************************/
+BTA_API extern tBTA_FS_CO_STATUS bta_fs_co_access(const char *p_path, int mode,
+ BOOLEAN *p_is_dir, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_mkdir
+**
+** Description This function is called to create a directory with
+** the pathname given by path. The pathname is a null terminated
+** string. All components of the path must already exist.
+**
+** Parameters p_path - (input) name of directory to create (fully qualified path).
+** app_id - (input) application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns (tBTA_FS_CO_STATUS) status of the call.
+** [BTA_FS_CO_OK if successful]
+** [BTA_FS_CO_FAIL if unsuccessful]
+**
+*******************************************************************************/
+BTA_API extern tBTA_FS_CO_STATUS bta_fs_co_mkdir(const char *p_path, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_rmdir
+**
+** Description This function is called to remove a directory whose
+** name is given by path. The directory must be empty.
+**
+** Parameters p_path - (input) name of directory to remove (fully qualified path).
+** app_id - (input) application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns (tBTA_FS_CO_STATUS) status of the call.
+** [BTA_FS_CO_OK if successful]
+** [BTA_FS_CO_EACCES if read-only]
+** [BTA_FS_CO_ENOTEMPTY if directory is not empty]
+** [BTA_FS_CO_FAIL otherwise]
+**
+*******************************************************************************/
+BTA_API extern tBTA_FS_CO_STATUS bta_fs_co_rmdir(const char *p_path, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_unlink
+**
+** Description This function is called by to remove a file whose name
+** is given by p_path.
+**
+** Parameters p_path - (input) name of file to remove (fully qualified path).
+** app_id - (input) application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns (tBTA_FS_CO_STATUS) status of the call.
+** [BTA_FS_CO_OK if successful]
+** [BTA_FS_CO_EACCES if read-only]
+** [BTA_FS_CO_FAIL otherwise]
+**
+*******************************************************************************/
+BTA_API extern tBTA_FS_CO_STATUS bta_fs_co_unlink(const char *p_path, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_getdirentry
+**
+** Description This function is called to retrieve a directory entry for the
+** specified path. The first/next directory should be filled
+** into the location specified by p_entry.
+**
+** Parameters p_path - directory to search (Fully qualified path)
+** first_item - TRUE if first search, FALSE if next search
+** (p_cur contains previous)
+** p_entry (input/output) - Points to last entry data (valid when
+** first_item is FALSE)
+** evt - event that must be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, the status is passed
+** in the bta_fs_ci_direntry() call-in function.
+** BTA_FS_CO_OK is returned when p_entry is valid,
+** BTA_FS_CO_EODIR is returned when no more entries [finished]
+** BTA_FS_CO_FAIL is returned if an error occurred
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_getdirentry(const char *p_path, BOOLEAN first_item,
+ tBTA_FS_DIRENTRY *p_entry, UINT16 evt,
+ UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_copy
+**
+** Description This function is called to copy a file/directory whose
+** name is given by p_src_path to p_dest_path.
+**
+** Parameters p_src_path - (input) name of file/directory to be copied (fully qualified path).
+** p_dest_path - (input) new name of file/directory(fully qualified path).
+** p_perms - the permission of the new object.
+** evt - event that must be passed into the call-in function.
+** app_id - (input) application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns (tBTA_FS_CO_STATUS) status of the call.
+** [BTA_FS_CO_OK if successful]
+** [BTA_FS_CO_EIS_DIR if p_src_path is a folder]
+** [BTA_FS_CO_EACCES if p_dest_path already exists or could not be created (invalid path);
+** or p_src_path is a directory and p_dest_path specifies a different path. ]
+** [BTA_FS_CO_FAIL otherwise]
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_copy(const char *p_src_path, const char *p_dest_path, UINT8 *p_perms, UINT16 evt, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_rename
+**
+** Description This function is called to move a file/directory whose
+** name is given by p_src_path to p_dest_path.
+**
+** Parameters p_src_path - (input) name of file/directory to be moved (fully qualified path).
+** p_dest_path - (input) new name of file/directory(fully qualified path).
+** p_perms - the permission of the new object.
+** app_id - (input) application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns (tBTA_FS_CO_STATUS) status of the call.
+** [BTA_FS_CO_OK if successful]
+** [BTA_FS_CO_EACCES if p_dest_path already exists or could not be created (invalid path);
+** or p_src_path is a directory and p_dest_path specifies a different path. ]
+** [BTA_FS_CO_FAIL otherwise]
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_rename(const char *p_src_path, const char *p_dest_path, UINT8 *p_perms, UINT16 evt, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_set_perms
+**
+** Description This function is called to set the permission a file/directory
+** with name as p_src_path.
+**
+** Parameters p_src_path - (input) name of file/directory to set permission (fully qualified path).
+** p_perms - the permission .
+** app_id - (input) application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns (tBTA_FS_CO_STATUS) status of the call.
+** [BTA_FS_CO_OK if successful]
+** [BTA_FS_CO_EACCES if p_dest_path already exists or could not be created (invalid path);
+** or p_src_path is a directory and p_dest_path specifies a different path. ]
+** [BTA_FS_CO_FAIL otherwise]
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_set_perms(const char *p_src_path, UINT8 *p_perms, UINT16 evt, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_sess_fopen
+**
+** Description This function is called by bta_fs_co_open to keep track of
+** the opened file (for reliable session suspend/resume.)
+**
+** Parameters p_path - Fully qualified path and file name.
+** oflags - permissions and mode (see constants above)
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_sess_fopen(const char *p_path, int oflags, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_sess_fclose
+**
+** Description This function is called by bta_fs_co_close
+**
+** Parameters app_id - application ID specified in the enable functions.
+** It can be used to identify which profile is the caller
+** of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_sess_fclose(UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_sess_offset
+**
+** Description This function is called by bta_fs_co_write to keep track of
+** the last file offset (Only the receiving side needs to keep
+** track of the file offset)
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_sess_offset(UINT8 ssn, INT32 pos, UINT16 nbytes, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_suspended_addr
+**
+** Description find the peer address of the suspended session control block
+** for the given an app_id.
+**
+** Returns the control block found.
+**
+*******************************************************************************/
+BTA_API extern UINT8 *bta_fs_co_suspended_addr(UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_num_suspended_session
+**
+** Description find the number of suspended session control blocks for the
+** given an app_id.
+**
+** Returns the number of control blocks found.
+**
+*******************************************************************************/
+BTA_API extern UINT8 bta_fs_co_num_suspended_session(UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_get_active_session
+**
+** Description find the active session control block for the given an app_id.
+**
+** Returns the control block found.
+**
+*******************************************************************************/
+BTA_API extern tBTA_FS_CO_SESSION *bta_fs_co_get_active_session(UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_fs_co_init_db
+**
+** Description Initialize the session control blocks for platform.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_fs_co_init_db (tBTA_FS_CO_SESSION *p_first);
+
+/*******************************************************************************
+**
+** Function bta_fs_convert_oflags
+**
+** Description This function converts the open flags from BTA into MFS.
+**
+** Returns BTA FS status value.
+**
+*******************************************************************************/
+BTA_API extern int bta_fs_convert_bta_oflags(int bta_oflags);
+
+#endif /* BTA_FS_CO_H */
diff --git a/bta/include/bta_ft_api.h b/bta/include/bta_ft_api.h
new file mode 100644
index 0000000..96ed66f
--- /dev/null
+++ b/bta/include/bta_ft_api.h
@@ -0,0 +1,724 @@
+/*****************************************************************************
+**
+** Name: bta_ft_api.h
+**
+** Description: This is the public interface file for the file transfer
+** (FT) server subsystem of BTA, Widcomm's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_FT_API_H
+#define BTA_FT_API_H
+
+#include "bta_api.h"
+#include "btm_api.h"
+#if( defined BIP_INCLUDED) && (BIP_INCLUDED == TRUE)
+#include "bip_api.h"
+#endif
+#include "bta_sys.h"
+#include "bta_fs_co.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+#define BTA_FT_ENHANCED_VERSION 0x0102
+
+/**************************
+** Common Definitions
+***************************/
+/* Access response types */
+#define BTA_FT_ACCESS_ALLOW 0 /* Allow the requested operation */
+#define BTA_FT_ACCESS_FORBID 1 /* Disallow the requested operation */
+
+typedef UINT8 tBTA_FT_ACCESS;
+
+/* Access event operation types */
+#define BTA_FT_OPER_DEFAULT 0 /* Default mode */
+#define BTA_FT_OPER_PUT 1 /* Request is a PUT file */
+#define BTA_FT_OPER_GET 2 /* Request is a GET file */
+#define BTA_FT_OPER_DEL_FILE 3 /* Request is a DELETE file */
+#define BTA_FT_OPER_DEL_DIR 4 /* Request is a DELETE folder */
+#define BTA_FT_OPER_CHG_DIR 5 /* Request is a Change Folder */
+#define BTA_FT_OPER_MK_DIR 6 /* Request is a Make Folder */
+#define BTA_FT_OPER_COPY_ACT 7 /* Request is a Copy Action command */
+#define BTA_FT_OPER_MOVE_ACT 8 /* Request is a Move Action command */
+#define BTA_FT_OPER_SET_PERM 9 /* Request is a SetPermission Action command */
+
+typedef UINT8 tBTA_FT_OPER;
+
+#define BTA_FT_ACT_COPY OBX_ACT_COPY /* 0x00 Copy object */
+#define BTA_FT_ACT_MOVE OBX_ACT_MOVE /* 0x01 Move/rename object */
+#define BTA_FT_ACT_PERMISSION OBX_ACT_PERMISSION /* 0x02 Set object permission */
+typedef tOBX_ACTION tBTA_FTC_ACT;
+
+#define BTA_FTC_RESUME_NONCE 0xFFFFFFFF
+
+/* permission flags */
+#define BTA_FT_PERMISSION_READ OBX_PERMISSION_READ /* 0x01 */
+#define BTA_FT_PERMISSION_WRITE OBX_PERMISSION_WRITE /* 0x02 */
+#define BTA_FT_PERMISSION_DELETE OBX_PERMISSION_DELETE /* 0x04 */
+#define BTA_FT_PERMISSION_MODIFY OBX_PERMISSION_MODIFY /* 0x80 */
+
+/**************************
+** Server Definitions
+***************************/
+/* Extra Debug Code */
+#ifndef BTA_FTS_DEBUG
+#define BTA_FTS_DEBUG FALSE
+#endif
+
+#define BTA_FTS_OK 0
+#define BTA_FTS_FAIL 1
+typedef UINT8 tBTA_FTS_STATUS;
+
+/* Server callback function events */
+#define BTA_FTS_ENABLE_EVT 0 /* File transfer server is enabled. */
+#define BTA_FTS_OPEN_EVT 1 /* Connection to peer is open. */
+#define BTA_FTS_CLOSE_EVT 2 /* Connection to peer closed. */
+#define BTA_FTS_AUTH_EVT 3 /* Request for Authentication key and realm */
+#define BTA_FTS_ACCESS_EVT 4 /* Request for access to put a file */
+#define BTA_FTS_PROGRESS_EVT 5 /* Number of bytes read or written so far */
+#define BTA_FTS_PUT_CMPL_EVT 6 /* File Put complete */
+#define BTA_FTS_GET_CMPL_EVT 7 /* File Get complete */
+#define BTA_FTS_DEL_CMPL_EVT 8 /* Remove File or Folder complete */
+#define BTA_FTS_DISABLE_EVT 9 /* Reply to a disable api request */
+
+typedef UINT8 tBTA_FTS_EVT;
+
+/* Structure associated with BTA_FTS_xxx_CMPL_EVT */
+typedef struct
+{
+ char *p_name; /* file or folder name. */
+ tBTA_FTS_STATUS status;
+} tBTA_FTS_OBJECT;
+
+typedef struct
+{
+ UINT32 file_size; /* Total size of file (BTA_FS_LEN_UNKNOWN if unknown) */
+ UINT16 bytes; /* Number of bytes read or written since last progress event */
+} tBTA_FTS_PROGRESS;
+
+typedef struct
+{
+
+ UINT8 *p_userid;
+ UINT8 userid_len;
+ BOOLEAN userid_required; /* TRUE if user ID is required in response (rechallanged) */
+} tBTA_FTS_AUTH;
+
+typedef struct
+{
+ char *p_name; /* file name with fully qualified path */
+ UINT32 size; /* file size */
+ tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
+ tBTA_FT_OPER oper; /* operation (put) */
+ BD_ADDR bd_addr; /* Address of device */
+ char *p_dest_name; /* destination file name with fully qualified path (BTA_FT_OPER_COPY_ACT & BTA_FT_OPER_MOVE_ACT) */
+ UINT8 perms[BTA_FS_PERM_SIZE]; /* user/group/other permission (BTA_FT_OPER_SET_PERM) */
+} tBTA_FTS_ACCESS;
+
+typedef union
+{
+ tBTA_FTS_STATUS status;
+ tBTA_FTS_PROGRESS prog;
+ tBTA_FTS_AUTH auth;
+ tBTA_FTS_ACCESS access;
+ tBTA_FTS_OBJECT obj;
+ BD_ADDR bd_addr;
+} tBTA_FTS;
+
+/* Server callback function */
+typedef void tBTA_FTS_CBACK(tBTA_FTS_EVT event, tBTA_FTS *p_data);
+
+
+/**************************
+** Client Definitions
+***************************/
+/* Extra Debug Code */
+#ifndef BTA_FTC_DEBUG
+#define BTA_FTC_DEBUG FALSE
+#endif
+
+/* Additional paramters for BTA_FtcPutFile using BIP service */
+typedef union
+{
+#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
+ tBIP_IMAGE_DESC desc; /* when connectied with BIP service */
+#else
+ void* desc;
+#endif
+} tBTA_FTC_PARAM;
+
+/* Client callback function events */
+#define BTA_FTC_ENABLE_EVT 0 /* File transfer client is enabled. */
+#define BTA_FTC_OPEN_EVT 1 /* Connection to peer is open. */
+#define BTA_FTC_CLOSE_EVT 2 /* Connection to peer closed. */
+#define BTA_FTC_AUTH_EVT 3 /* Request for Authentication key and user id */
+#define BTA_FTC_LIST_EVT 4 /* Event contains a directory entry (tBTA_FTC_LIST) */
+#define BTA_FTC_PROGRESS_EVT 5 /* Number of bytes read or written so far */
+#define BTA_FTC_PUTFILE_EVT 6 /* File Put complete */
+#define BTA_FTC_GETFILE_EVT 7 /* File Get complete */
+#define BTA_FTC_BI_CAPS_EVT 8 /* BIP imaging capabilities */
+#define BTA_FTC_THUMBNAIL_EVT 9 /* BIP responder requests for the thumbnail version */
+#define BTA_FTC_CHDIR_EVT 10 /* Change Directory complete */
+#define BTA_FTC_MKDIR_EVT 11 /* Make Directory complete */
+#define BTA_FTC_REMOVE_EVT 12 /* Remove File/Directory complete */
+#define BTA_FTC_PHONEBOOK_EVT 13 /* Report the Application Parameters for BTA_FtcGetPhoneBook response */
+#define BTA_FTC_COPY_EVT 14 /* Copy File complete */
+#define BTA_FTC_MOVE_EVT 15 /* Move File complete */
+#define BTA_FTC_PERMISSION_EVT 16 /* Set File permission complete */
+
+
+typedef UINT8 tBTA_FTC_EVT;
+
+
+#define BTA_FTC_OK 0
+#define BTA_FTC_FAIL 1
+#define BTA_FTC_NO_PERMISSION 2
+#define BTA_FTC_NOT_FOUND 3
+#define BTA_FTC_FULL 4
+#define BTA_FTC_BUSY 5
+#define BTA_FTC_ABORTED 6
+#define BTA_FTC_SERVICE_UNAVL 7
+#define BTA_FTC_SDP_ERR 8
+#define BTA_FTC_OBX_ERR 9
+#define BTA_FTC_OBX_TOUT 10
+
+typedef UINT8 tBTA_FTC_STATUS;
+
+#define BTA_FTC_FLAG_NONE 0
+#define BTA_FTC_FLAG_BACKUP 1
+
+typedef UINT8 tBTA_FTC_FLAG;
+
+typedef struct
+{
+ tBTA_SERVICE_ID service; /* Connection is open with OPP, BIP, PBAP or FTP service */
+ UINT16 version;
+} tBTA_FTC_OPEN;
+
+#define BTA_FTC_FILTER_VERSION (1<<0) /* Version */
+#define BTA_FTC_FILTER_FN (1<<1) /* Formatted Name */
+#define BTA_FTC_FILTER_N (1<<2) /* Structured Presentation of Name */
+#define BTA_FTC_FILTER_PHOTO (1<<3) /* Associated Image or Photo */
+#define BTA_FTC_FILTER_BDAY (1<<4) /* Birthday */
+#define BTA_FTC_FILTER_ADR (1<<5) /* Delivery Address */
+#define BTA_FTC_FILTER_LABEL (1<<6) /* Delivery */
+#define BTA_FTC_FILTER_TEL (1<<7) /* Telephone Number */
+#define BTA_FTC_FILTER_EMAIL (1<<8) /* Electronic Mail Address */
+#define BTA_FTC_FILTER_MAILER (1<<9) /* Electronic Mail */
+#define BTA_FTC_FILTER_TZ (1<<10) /* Time Zone */
+#define BTA_FTC_FILTER_GEO (1<<11) /* Geographic Position */
+#define BTA_FTC_FILTER_TITLE (1<<12) /* Job */
+#define BTA_FTC_FILTER_ROLE (1<<13) /* Role within the Organization */
+#define BTA_FTC_FILTER_LOGO (1<<14) /* Organization Logo */
+#define BTA_FTC_FILTER_AGENT (1<<15) /* vCard of Person Representing */
+#define BTA_FTC_FILTER_ORG (1<<16) /* Name of Organization */
+#define BTA_FTC_FILTER_NOTE (1<<17) /* Comments */
+#define BTA_FTC_FILTER_REV (1<<18) /* Revision */
+#define BTA_FTC_FILTER_SOUND (1<<19) /* Pronunciation of Name */
+#define BTA_FTC_FILTER_URL (1<<20) /* Uniform Resource Locator */
+#define BTA_FTC_FILTER_UID (1<<21) /* Unique ID */
+#define BTA_FTC_FILTER_KEY (1<<22) /* Public Encryption Key */
+#define BTA_FTC_FILTER_ALL (0)
+typedef UINT32 tBTA_FTC_FILTER_MASK;
+
+enum
+{
+ BTA_FTC_FORMAT_CARD_21, /* vCard format 2.1 */
+ BTA_FTC_FORMAT_CARD_30, /* vCard format 3.0 */
+ BTA_FTC_FORMAT_MAX
+};
+typedef UINT8 tBTA_FTC_FORMAT;
+
+typedef struct
+{
+ UINT16 phone_book_size;
+ BOOLEAN pbs_exist; /* phone_book_size is present in the response */
+ UINT8 new_missed_calls;
+ BOOLEAN nmc_exist; /* new_missed_calls is present in the response */
+} tBTA_FTC_PB_PARAM;
+
+typedef struct
+{
+ tBTA_FTC_PB_PARAM *p_param;
+ UINT8 *data;
+ UINT16 len;
+ BOOLEAN final; /* If TRUE, entry is last of the series */
+ tBTA_FTC_STATUS status; /* Fields are valid when status is BTA_FTC_OK */
+} tBTA_FTC_LIST;
+
+enum
+{
+ BTA_FTC_ORDER_INDEXED = 0, /* indexed */
+ BTA_FTC_ORDER_ALPHANUM, /* alphanumeric */
+ BTA_FTC_ORDER_PHONETIC, /* phonetic */
+ BTA_FTC_ORDER_MAX
+};
+typedef UINT8 tBTA_FTC_ORDER;
+enum
+{
+ BTA_FTC_ATTR_NAME = 0, /* name */
+ BTA_FTC_ATTR_NUMBER, /* number */
+ BTA_FTC_ATTR_SOUND, /* sound */
+ BTA_FTC_ATTR_MAX
+};
+typedef UINT8 tBTA_FTC_ATTR;
+
+typedef struct
+{
+ UINT32 file_size; /* Total size of file (BTA_FS_LEN_UNKNOWN if unknown) */
+ UINT16 bytes; /* Number of bytes read or written since last progress event */
+} tBTA_FTC_PROGRESS;
+
+typedef struct
+{
+ UINT8 *p_realm;
+ UINT8 realm_len;
+ UINT8 realm_charset;
+ BOOLEAN userid_required; /* If TRUE, a user ID must be sent */
+} tBTA_FTC_AUTH;
+
+#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
+typedef struct
+{
+ tBIP_IMAGING_CAPS *p_bi_caps; /* BIP imaging capabilities */
+} tBTA_FTC_CAPS;
+
+typedef struct
+{
+ UINT8 *p_name; /* the image file name */
+ tBIP_IMG_HDL_STR handle; /* The image’s handle assigned by BIP responder. */
+} tBTA_FTC_THUMB;
+#endif
+
+typedef union
+{
+ tBTA_FTC_STATUS status;
+ tBTA_FTC_OPEN open;
+ tBTA_FTC_LIST list;
+ tBTA_FTC_PROGRESS prog;
+ tBTA_FTC_AUTH auth;
+#if( defined BTA_BI_INCLUDED ) && (BTA_BI_INCLUDED == TRUE)
+ tBTA_FTC_CAPS bi_caps;
+ tBTA_FTC_THUMB thumb;
+#endif
+ tBTA_FTC_PB_PARAM pb;
+} tBTA_FTC;
+
+/* Client callback function */
+typedef void tBTA_FTC_CBACK(tBTA_FTC_EVT event, tBTA_FTC *p_data);
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**************************
+** Server Functions
+***************************/
+
+/*******************************************************************************
+**
+** Function BTA_FtsEnable
+**
+** Description Enable the file transfer server. This function must be
+** called before any other functions in the FTS API are called.
+** When the enable operation is complete the callback function
+** will be called with an BTA_FTS_ENABLE_EVT event.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtsEnable(tBTA_SEC sec_mask, const char *p_service_name,
+ const char *p_root_path, BOOLEAN enable_authen,
+ UINT8 realm_len, UINT8 *p_realm,
+ tBTA_FTS_CBACK *p_cback, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_FtsDisable
+**
+** Description Disable the file transfer server. If the server is currently
+** connected to a peer device the connection will be closed.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtsDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_FtsClose
+**
+** Description Close the current connection. This function is called if
+** the phone wishes to close the connection before the FT
+** client disconnects.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtsClose(void);
+
+/*******************************************************************************
+**
+** Function BTA_FtsUnauthRsp
+**
+** Description Sends an OBEX authentication challenge to the connected
+** OBEX client. Called in response to an BTA_FTS_AUTH_EVT event.
+** Used when "enable_authen" is set to TRUE in BTA_FtsEnable().
+**
+** Note: If the "userid_required" is TRUE in the BTA_FTS_AUTH_EVT
+** event, then p_userid is required, otherwise it is optional.
+**
+** p_password must be less than BTA_FTS_MAX_AUTH_KEY_SIZE (16 bytes)
+** p_userid must be less than OBX_MAX_REALM_LEN (defined in target.h)
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtsAuthRsp (char *p_password, char *p_userid);
+
+/*******************************************************************************
+**
+** Function BTA_FtsAccessRsp
+**
+** Description Sends a reply to an access request event (BTA_FTS_ACCESS_EVT).
+** This call MUST be made whenever the event occurs.
+**
+** Parameters oper - operation being accessed.
+** access - BTA_FT_ACCESS_ALLOW or BTA_FT_ACCESS_FORBID
+** p_name - Full path of file to pulled or pushed.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtsAccessRsp(tBTA_FT_OPER oper, tBTA_FT_ACCESS access,
+ char *p_name);
+
+
+/**************************
+** Client Functions
+***************************/
+
+/*******************************************************************************
+**
+** Function BTA_FtcEnable
+**
+** Description Enable the file transfer client. This function must be
+** called before any other functions in the FTC API are called.
+** When the enable operation is complete the callback function
+** will be called with an BTA_FTC_ENABLE_EVT event.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcEnable(tBTA_FTC_CBACK *p_cback, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_FtcDisable
+**
+** Description Disable the file transfer client. If the client is currently
+** connected to a peer device the connection will be closed.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_FtcOpen
+**
+** Description Open a connection to an FTP, PBAP, OPP or BIP server.
+** If parameter services is set to use both all services,
+** the client will attempt to connect to the device using
+** FTP first and then PBAP, OPP, BIP.
+** When the connection is open the callback function
+** will be called with a BTA_FTC_OPEN_EVT. If the connection
+** fails or otherwise is closed the callback function will be
+** called with a BTA_FTC_CLOSE_EVT.
+**
+** If the connection is opened with FTP profile and
+** bta_ft_cfg.auto_file_list is TRUE , the callback
+** function will be called with one or more BTA_FTC_LIST_EVT
+** containing directory list information formatted in XML as
+** described in the IrOBEX Spec, Version 1.2, section 9.1.2.3.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcOpen(BD_ADDR bd_addr, tBTA_SEC sec_mask,
+ tBTA_SERVICE_MASK services, BOOLEAN srm, UINT32 nonce);
+
+/*******************************************************************************
+**
+** Function BTA_FtcSuspend
+**
+** Description Suspend the current connection to the server.
+** This is allowed only for the sessions created by
+** BTA_FtcConnect with nonce!=0
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcSuspend(void);
+
+/*******************************************************************************
+**
+** Function BTA_FtcClose
+**
+** Description Close the current connection to the server. Aborts any
+** active file transfer.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcClose(void);
+
+/*******************************************************************************
+**
+** Function BTA_FtcCopyFile
+**
+** Description Invoke a Copy action on the server.
+** Create a copy of p_src and name it as p_dest
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcCopyFile(const char *p_src, const char *p_dest);
+
+/*******************************************************************************
+**
+** Function BTA_FtcMoveFile
+**
+** Description Invoke a Move action on the server.
+** Move/rename p_src to p_dest
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcMoveFile(const char *p_src, const char *p_dest);
+
+/*******************************************************************************
+**
+** Function BTA_FtcSetPermission
+**
+** Description Invoke a SetPermission action on the server.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcSetPermission(const char *p_src, UINT8 user, UINT8 group, UINT8 other);
+
+/*******************************************************************************
+**
+** Function BTA_FtcPutFile
+**
+** Description Send a file to the connected server.
+**
+** This function can only be used when the client is connected
+** in FTP, OPP and BIP mode.
+**
+** Note: File name is specified with a fully qualified path.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcPutFile(const char *p_name, tBTA_FTC_PARAM *p_param);
+
+/*******************************************************************************
+**
+** Function BTA_FtcGetPhoneBook
+**
+** Description Retrieve a PhoneBook from the peer device and copy it to the
+** local file system.
+**
+** This function can only be used when the client is connected
+** in PBAP mode.
+**
+** Note: local file name is specified with a fully qualified path.
+** Remote file name is absolute path in UTF-8 format
+** (telecom/pb.vcf or SIM1/telecom/pb.vcf).
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcGetPhoneBook(char *p_local_name, char *p_remote_name,
+ tBTA_FTC_FILTER_MASK filter, tBTA_FTC_FORMAT format,
+ UINT16 max_list_count, UINT16 list_start_offset);
+
+/*******************************************************************************
+**
+** Function BTA_FtcGetCard
+**
+** Description Retrieve a vCard from the peer device and copy it to the
+** local file system.
+**
+** This function can only be used when the client is connected
+** in PBAP mode.
+**
+** Note: local file name is specified with a fully qualified path.
+** Remote file name is relative path in UTF-8 format.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcGetCard(char *p_local_name, char *p_remote_name,
+ tBTA_FTC_FILTER_MASK filter, tBTA_FTC_FORMAT format);
+
+/*******************************************************************************
+**
+** Function BTA_FtcGetFile
+**
+** Description Retrieve a file from the peer device and copy it to the
+** local file system.
+**
+** This function can only be used when the client is connected
+** in FTP mode.
+**
+** Note: local file name is specified with a fully qualified path.
+** Remote file name is specified in UTF-8 format.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcGetFile(char *p_local_name, char *p_remote_name);
+
+/*******************************************************************************
+**
+** Function BTA_FtcChDir
+**
+** Description Change directory on the peer device.
+**
+** This function can only be used when the client is connected
+** in FTP and PBAP mode.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcChDir(char *p_dir, tBTA_FTC_FLAG flag);
+
+/*******************************************************************************
+**
+** Function BTA_FtcAuthRsp
+**
+** Description Sends a response to an OBEX authentication challenge to the
+** connected OBEX server. Called in response to an BTA_FTC_AUTH_EVT
+** event.
+**
+** Note: If the "userid_required" is TRUE in the BTA_FTC_AUTH_EVT event,
+** then p_userid is required, otherwise it is optional.
+**
+** p_password must be less than BTA_FTC_MAX_AUTH_KEY_SIZE (16 bytes)
+** p_userid must be less than OBX_MAX_REALM_LEN (defined in target.h)
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcAuthRsp (char *p_password, char *p_userid);
+
+/*******************************************************************************
+**
+** Function BTA_FtcListCards
+**
+** Description Retrieve a directory listing from the peer device.
+** When the operation is complete the callback function will
+** be called with one or more BTA_FTC_LIST_EVT events
+** containing directory list information formatted as described
+** in the PBAP Spec, Version 0.9, section 3.1.6.
+** This function can only be used when the client is connected
+** to a peer device.
+**
+** This function can only be used when the client is connected
+** in PBAP mode.
+**
+** Parameters p_dir - Name of directory to retrieve listing of.
+**
+** Returns void
+**
+*******************************************************************************/
+
+BTA_API extern void BTA_FtcListCards(char *p_dir, tBTA_FTC_ORDER order, char *p_value,
+ tBTA_FTC_ATTR attribute, UINT16 max_list_count,
+ UINT16 list_start_offset);
+
+/*******************************************************************************
+**
+** Function BTA_FtcListDir
+**
+** Description Retrieve a directory listing from the peer device.
+** When the operation is complete the callback function will
+** be called with one or more BTA_FTC_LIST_EVT events
+** containing directory list information formatted as described
+** in the IrOBEX Spec, Version 1.2, section 9.1.2.3.
+**
+** This function can only be used when the client is connected
+** in FTP mode.
+**
+** Parameters p_dir - Name of directory to retrieve listing of. If NULL,
+** the current working directory is retrieved.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcListDir(char *p_dir);
+
+/*******************************************************************************
+**
+** Function BTA_FtcAbort
+**
+** Description Aborts any active Put or Get file operation.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcAbort(void);
+
+/*******************************************************************************
+**
+** Function BTA_FtcRemove
+**
+** Description Remove a file or directory on the peer device. When the
+** operation is complete the status is returned with the
+** BTA_FTC_REMOVE_EVT event.
+**
+** This function can only be used when the client is connected
+** in FTP mode.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcRemove(char *p_name);
+
+/*******************************************************************************
+**
+** Function BTA_FtcMkDir
+**
+** Description Create a directory on the peer device. When the operation is
+** complete the status is returned with the BTA_FTC_MKDIR_EVT
+** event.
+**
+** This function can only be used when the client is connected
+** in FTP mode.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_FtcMkDir(char *p_dir);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_FT_API_H */
diff --git a/bta/include/bta_gatt_api.h b/bta/include/bta_gatt_api.h
new file mode 100644
index 0000000..02284a5
--- /dev/null
+++ b/bta/include/bta_gatt_api.h
@@ -0,0 +1,1206 @@
+/*****************************************************************************
+**
+** Name: bta_gatt_api.h
+**
+** Description: This is the public interface file for BTA GATT.
+**
+** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_GATT_API_H
+#define BTA_GATT_API_H
+
+#include "bta_api.h"
+#include "gatt_api.h"
+
+#ifndef BTA_GATT_INCLUDED
+#define BTA_GATT_INCLUDED FALSE
+#endif
+
+
+#if ((BLE_INCLUDED == FALSE) && (BTA_GATT_INCLUDED == TRUE))
+#undef BTA_GATT_INCLUDED
+#define BTA_GATT_INCLUDED FALSE
+#endif
+
+
+#ifndef BTA_GATT_DEBUG
+#define BTA_GATT_DEBUG FALSE
+#endif
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+/**************************
+** Common Definitions
+***************************/
+/* GATT ID */
+typedef struct
+{
+ tBT_UUID uuid; /* uuid of the attribute */
+ UINT8 inst_id; /* instance ID */
+} tBTA_GATT_ID;
+
+/* Success code and error codes */
+#define BTA_GATT_OK GATT_SUCCESS
+#define BTA_GATT_INVALID_HANDLE GATT_INVALID_HANDLE /* 0x0001 */
+#define BTA_GATT_READ_NOT_PERMIT GATT_READ_NOT_PERMIT /* 0x0002 */
+#define BTA_GATT_WRITE_NOT_PERMIT GATT_WRITE_NOT_PERMIT /* 0x0003 */
+#define BTA_GATT_INVALID_PDU GATT_INVALID_PDU /* 0x0004 */
+#define BTA_GATT_INSUF_AUTHENTICATION GATT_INSUF_AUTHENTICATION /* 0x0005 */
+#define BTA_GATT_REQ_NOT_SUPPORTED GATT_REQ_NOT_SUPPORTED /* 0x0006 */
+#define BTA_GATT_INVALID_OFFSET GATT_INVALID_OFFSET /* 0x0007 */
+#define BTA_GATT_INSUF_AUTHORIZATION GATT_INSUF_AUTHORIZATION /* 0x0008 */
+#define BTA_GATT_PREPARE_Q_FULL GATT_PREPARE_Q_FULL /* 0x0009 */
+#define BTA_GATT_NOT_FOUND GATT_NOT_FOUND /* 0x000a */
+#define BTA_GATT_NOT_LONG GATT_NOT_LONG /* 0x000b */
+#define BTA_GATT_INSUF_KEY_SIZE GATT_INSUF_KEY_SIZE /* 0x000c */
+#define BTA_GATT_INVALID_ATTR_LEN GATT_INVALID_ATTR_LEN /* 0x000d */
+#define BTA_GATT_ERR_UNLIKELY GATT_ERR_UNLIKELY /* 0x000e */
+#define BTA_GATT_INSUF_ENCRYPTION GATT_INSUF_ENCRYPTION /* 0x000f */
+#define BTA_GATT_UNSUPPORT_GRP_TYPE GATT_UNSUPPORT_GRP_TYPE /* 0x0010 */
+#define BTA_GATT_INSUF_RESOURCE GATT_INSUF_RESOURCE /* 0x0011 */
+
+
+#define BTA_GATT_ILLEGAL_PARAMETER GATT_ILLEGAL_PARAMETER /* 0x0087 */
+#define BTA_GATT_NO_RESOURCES GATT_NO_RESOURCES /* 0x0080 */
+#define BTA_GATT_INTERNAL_ERROR GATT_INTERNAL_ERROR /* 0x0081 */
+#define BTA_GATT_WRONG_STATE GATT_WRONG_STATE /* 0x0082 */
+#define BTA_GATT_DB_FULL GATT_DB_FULL /* 0x0083 */
+#define BTA_GATT_BUSY GATT_BUSY /* 0x0084 */
+#define BTA_GATT_ERROR GATT_ERROR /* 0x0085 */
+#define BTA_GATT_CMD_STARTED GATT_CMD_STARTED /* 0x0086 */
+#define BTA_GATT_PENDING GATT_PENDING /* 0x0088 */
+#define BTA_GATT_AUTH_FAIL GATT_AUTH_FAIL /* 0x0089 */
+#define BTA_GATT_MORE GATT_MORE /* 0x008a */
+#define BTA_GATT_INVALID_CFG GATT_INVALID_CFG /* 0x008b */
+#define BTA_GATT_DUP_REG 0x008c
+#define BTA_GATT_ALREADY_OPEN 0x008d /* 0x008d */
+typedef UINT8 tBTA_GATT_STATUS;
+
+#define BTA_GATT_INVALID_CONN_ID GATT_INVALID_CONN_ID
+
+
+/* Client callback function events */
+#define BTA_GATTC_REG_EVT 0 /* GATT client is registered. */
+#define BTA_GATTC_DEREG_EVT 1 /* GATT client deregistered event */
+#define BTA_GATTC_OPEN_EVT 2 /* GATTC open request status event */
+#define BTA_GATTC_READ_CHAR_EVT 3 /* GATT read characteristic event */
+#define BTA_GATTC_WRITE_CHAR_EVT 4 /* GATT write characteristic or char descriptor event */
+#define BTA_GATTC_CLOSE_EVT 5 /* GATTC close request status event */
+#define BTA_GATTC_SEARCH_CMPL_EVT 6 /* GATT discovery complete event */
+#define BTA_GATTC_SEARCH_RES_EVT 7 /* GATT discovery result event */
+#define BTA_GATTC_READ_DESCR_EVT 8 /* GATT read characterisitc descriptor event */
+#define BTA_GATTC_WRITE_DESCR_EVT 9 /* GATT write characteristic descriptor event */
+#define BTA_GATTC_NOTIF_EVT 10 /* GATT attribute notification event */
+#define BTA_GATTC_PREP_WRITE_EVT 11 /* GATT prepare write event */
+#define BTA_GATTC_EXEC_EVT 12 /* execute write complete event */
+#define BTA_GATTC_ACL_EVT 13 /* ACL up event */
+#define BTA_GATTC_CANCEL_OPEN_EVT 14 /* cancel open event */
+#define BTA_GATTC_SRVC_CHG_EVT 15 /* service change event */
+typedef UINT8 tBTA_GATTC_EVT;
+
+typedef tGATT_IF tBTA_GATTC_IF;
+
+typedef struct
+{
+ UINT16 unit; /* as UUIUD defined by SIG */
+ UINT16 descr; /* as UUID as defined by SIG */
+ tGATT_FORMAT format;
+ INT8 exp;
+ UINT8 name_spc; /* The name space of the description */
+}tBTA_GATT_CHAR_PRES;
+
+#define BTA_GATT_CLT_CONFIG_NONE GATT_CLT_CONFIG_NONE /* 0x0000 */
+#define BTA_GATT_CLT_CONFIG_NOTIFICATION GATT_CLT_CONFIG_NOTIFICATION /* 0x0001 */
+#define BTA_GATT_CLT_CONFIG_INDICATION GATT_CLT_CONFIG_INDICATION /* 0x0002 */
+typedef UINT16 tBTA_GATT_CLT_CHAR_CONFIG;
+
+/* characteristic descriptor: server configuration value
+*/
+#define BTA_GATT_SVR_CONFIG_NONE GATT_SVR_CONFIG_NONE /* 0x0000 */
+#define BTA_GATT_SVR_CONFIG_BROADCAST GATT_SVR_CONFIG_BROADCAST /* 0x0001 */
+typedef UINT16 tBTA_GATT_SVR_CHAR_CONFIG;
+
+/* Characteristic Aggregate Format attribute value
+*/
+#define BTA_GATT_AGGR_HANDLE_NUM_MAX 10
+typedef struct
+{
+ UINT8 num_handle;
+ UINT16 handle_list[BTA_GATT_AGGR_HANDLE_NUM_MAX];
+} tBTA_GATT_CHAR_AGGRE;
+typedef tGATT_VALID_RANGE tBTA_GATT_VALID_RANGE;
+
+typedef struct
+{
+ UINT16 len;
+ UINT8 *p_value;
+}tBTA_GATT_UNFMT;
+
+#define BTA_GATT_MAX_ATTR_LEN GATT_MAX_ATTR_LEN
+
+#define BTA_GATTC_TYPE_WRITE GATT_WRITE
+#define BTA_GATTC_TYPE_WRITE_NO_RSP GATT_WRITE_NO_RSP
+typedef UINT8 tBTA_GATTC_WRITE_TYPE;
+
+#define BTA_GATT_CONN_UNKNOWN 0
+#define BTA_GATT_CONN_NO_RESOURCES GATT_CONN_NO_RESOURCES /* connection fail for l2cap resource failure */
+#define BTA_GATT_CONN_TIMEOUT GATT_CONN_TIMEOUT /* 0x08 connection timeout */
+#define BTA_GATT_CONN_TERMINATE_PEER_USER GATT_CONN_TERMINATE_PEER_USER /* 0x13 connection terminate by peer user */
+#define BTA_GATT_CONN_TERMINATE_LOCAL_HOST GATT_CONN_TERMINATE_LOCAL_HOST/* 0x16 connectionterminated by local host */
+#define BTA_GATT_CONN_FAIL_ESTABLISH GATT_CONN_FAIL_ESTABLISH /* 0x03E connection fail to establish */
+#define BTA_GATT_CONN_LMP_TIMEOUT GATT_CONN_LMP_TIMEOUT /* 0x22 connection fail for LMP response tout */
+#define BTA_GATT_CONN_CANCEL GATT_CONN_CANCEL /* 0x0100 L2CAP connection cancelled */
+#define BTA_GATT_CONN_NONE 0x0101 /* 0x0101 no connection to cancel */
+typedef UINT16 tBTA_GATT_REASON;
+
+typedef struct
+{
+ tBTA_GATT_ID id;
+ BOOLEAN is_primary;
+}tBTA_GATT_SRVC_ID;
+
+typedef struct
+{
+ tBTA_GATT_SRVC_ID srvc_id;
+ tBTA_GATT_ID char_id;
+}tBTA_GATTC_CHAR_ID;
+
+typedef struct
+{
+ tBTA_GATTC_CHAR_ID char_id;
+ tBT_UUID descr_type;
+}tBTA_GATTC_CHAR_DESCR_ID;
+
+typedef struct
+{
+ tBTA_GATT_SRVC_ID srvc_id;
+ tBTA_GATT_SRVC_ID incl_svc_id;
+}tBTA_GATTC_INCL_SVC_ID;
+
+#define BTA_GATT_TYPE_CHAR 0
+#define BTA_GATT_TYPE_CHAR_DESCR 1
+typedef UINT8 tBTA_GATT_ID_TYPE;
+
+typedef struct
+{
+ tBTA_GATT_ID_TYPE id_type;
+ union
+ {
+ tBTA_GATTC_CHAR_ID char_id;
+ tBTA_GATTC_CHAR_DESCR_ID char_descr_id;
+
+ } id_value;
+}tBTA_GATTC_ATTR_ID;
+
+#define BTA_GATTC_MULTI_MAX GATT_MAX_READ_MULTI_HANDLES
+
+typedef struct
+{
+ UINT8 num_attr;
+ tBTA_GATTC_ATTR_ID id_list[BTA_GATTC_MULTI_MAX];
+
+}tBTA_GATTC_MULTI;
+
+#define BTA_GATT_AUTH_REQ_NONE GATT_AUTH_REQ_NONE
+#define BTA_GATT_AUTH_REQ_NO_MITM GATT_AUTH_REQ_NO_MITM /* unauthenticated encryption */
+#define BTA_GATT_AUTH_REQ_MITM GATT_AUTH_REQ_MITM /* authenticated encryption */
+#define BTA_GATT_AUTH_REQ_SIGNED_NO_MITM GATT_AUTH_REQ_SIGNED_NO_MITM
+#define BTA_GATT_AUTH_REQ_SIGNED_MITM GATT_AUTH_REQ_SIGNED_MITM
+
+typedef tGATT_AUTH_REQ tBTA_GATT_AUTH_REQ;
+
+enum
+{
+ BTA_GATTC_ATTR_TYPE_INCL_SRVC,
+ BTA_GATTC_ATTR_TYPE_CHAR,
+ BTA_GATTC_ATTR_TYPE_CHAR_DESCR,
+ BTA_GATTC_ATTR_TYPE_SRVC
+};
+typedef UINT8 tBTA_GATTC_ATTR_TYPE;
+
+
+typedef struct
+{
+ tBT_UUID uuid;
+ UINT16 s_handle;
+ UINT16 e_handle; /* used for service only */
+ UINT8 attr_type;
+ UINT8 id;
+ UINT8 prop; /* used when attribute type is characteristic */
+ BOOLEAN is_primary; /* used when attribute type is service */
+}tBTA_GATTC_NV_ATTR;
+
+/* callback data structure */
+typedef struct
+{
+ tBTA_GATT_STATUS status;
+ tBTA_GATTC_IF client_if;
+// btla-specific ++
+ tBT_UUID app_uuid;
+// btla-specific --
+}tBTA_GATTC_REG;
+
+typedef struct
+{
+ UINT8 num_pres_fmt; /* number of presentation format aggregated*/
+ tBTA_GATTC_CHAR_DESCR_ID pre_format[BTA_GATTC_MULTI_MAX];
+}tBTA_GATT_CHAR_AGGRE_VALUE;
+
+typedef union
+{
+ tBTA_GATT_CHAR_AGGRE_VALUE aggre_value;
+ tBTA_GATT_UNFMT unformat;
+
+}tBTA_GATT_READ_VAL;
+
+typedef struct
+{
+ UINT16 conn_id;
+ tBTA_GATT_STATUS status;
+ tBTA_GATT_SRVC_ID srvc_id;
+ tBTA_GATT_ID char_id;
+ tBT_UUID descr_type;
+ tBTA_GATT_READ_VAL *p_value;
+}tBTA_GATTC_READ;
+
+typedef struct
+{
+ UINT16 conn_id;
+ tBTA_GATT_STATUS status;
+ tBTA_GATT_SRVC_ID srvc_id;
+ tBTA_GATT_ID char_id;
+ tBT_UUID descr_type;
+}tBTA_GATTC_WRITE;
+
+typedef struct
+{
+ UINT16 conn_id;
+ tBTA_GATT_STATUS status;
+}tBTA_GATTC_EXEC_CMPL;
+
+typedef struct
+{
+ UINT16 conn_id;
+ tBTA_GATT_STATUS status;
+}tBTA_GATTC_SEARCH_CMPL;
+
+typedef struct
+{
+ UINT16 conn_id;
+ tBTA_GATT_SRVC_ID service_uuid;
+}tBTA_GATTC_SRVC_RES;
+
+
+typedef struct
+{
+ tBTA_GATT_STATUS status;
+ UINT16 conn_id;
+ tBTA_GATTC_IF client_if;
+ BD_ADDR remote_bda;
+}tBTA_GATTC_OPEN;
+
+typedef struct
+{
+ tBTA_GATT_STATUS status;
+ UINT16 conn_id;
+ tBTA_GATTC_IF client_if;
+ BD_ADDR remote_bda;
+ tBTA_GATT_REASON reason; /* disconnect reason code, not useful when connect event is reported */
+}tBTA_GATTC_CLOSE;
+
+typedef struct
+{
+ UINT16 conn_id;
+ BD_ADDR bda;
+ tBTA_GATTC_CHAR_ID char_id;
+ tBT_UUID descr_type;
+ UINT16 len;
+ UINT8 value[BTA_GATT_MAX_ATTR_LEN];
+ BOOLEAN is_notify;
+}tBTA_GATTC_NOTIFY;
+
+// btla-specific ++
+typedef struct
+{
+ tBTA_GATT_STATUS status;
+ tBTA_GATTC_IF client_if;
+ UINT16 conn_id;
+ BD_ADDR remote_bda;
+}tBTA_GATTC_OPEN_CLOSE;
+// btla-specific --
+
+typedef union
+{
+ tBTA_GATT_STATUS status;
+
+ tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */
+ tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */
+ tBTA_GATTC_REG reg_oper; /* registration data */
+ tBTA_GATTC_OPEN open;
+ tBTA_GATTC_CLOSE close;
+ tBTA_GATTC_READ read; /* read attribute/descriptor data */
+ tBTA_GATTC_WRITE write; /* write complete data */
+ tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */
+ tBTA_GATTC_NOTIFY notify; /* notification/indication event data */
+ BD_ADDR remote_bda; /* service change event */
+} tBTA_GATTC;
+
+/* Client callback function */
+typedef void (tBTA_GATTC_CBACK)(tBTA_GATTC_EVT event, tBTA_GATTC *p_data);
+
+
+/* GATT Server Data Structure */
+/* Server callback function events */
+#define BTA_GATTS_REG_EVT 0
+#define BTA_GATTS_READ_EVT GATTS_REQ_TYPE_READ /* 1 */
+#define BTA_GATTS_WRITE_EVT GATTS_REQ_TYPE_WRITE /* 2 */
+#define BTA_GATTS_EXEC_WRITE_EVT GATTS_REQ_TYPE_WRITE_EXEC /* 3 */
+#define BTA_GATTS_MTU_EVT GATTS_REQ_TYPE_MTU /* 4 */
+#define BTA_GATTS_CONF_EVT GATTS_REQ_TYPE_CONF /* 5 */
+#define BTA_GATTS_DEREG_EVT 6
+#define BTA_GATTS_CREATE_EVT 7
+#define BTA_GATTS_ADD_INCL_SRVC_EVT 8
+#define BTA_GATTS_ADD_CHAR_EVT 9
+#define BTA_GATTS_ADD_CHAR_DESCR_EVT 10
+#define BTA_GATTS_DELELTE_EVT 11
+#define BTA_GATTS_START_EVT 12
+#define BTA_GATTS_STOP_EVT 13
+#define BTA_GATTS_CONNECT_EVT 14
+#define BTA_GATTS_DISCONNECT_EVT 15
+#define BTA_GATTS_OPEN_EVT 16
+#define BTA_GATTS_CANCEL_OPEN_EVT 17
+#define BTA_GATTS_CLOSE_EVT 18
+
+typedef UINT8 tBTA_GATTS_EVT;
+typedef tGATT_IF tBTA_GATTS_IF;
+
+/* Attribute permissions
+*/
+#define BTA_GATT_PERM_READ GATT_PERM_READ /* bit 0 - 0x0001 */
+#define BTA_GATT_PERM_READ_ENCRYPTED GATT_PERM_READ_ENCRYPTED /* bit 1 - 0x0002 */
+#define BTA_GATT_PERM_READ_ENC_MITM GATT_PERM_READ_ENC_MITM /* bit 2 - 0x0004 */
+#define BTA_GATT_PERM_WRITE GATT_PERM_WRITE /* bit 4 - 0x0010 */
+#define BTA_GATT_PERM_WRITE_ENCRYPTED GATT_PERM_WRITE_ENCRYPTED /* bit 5 - 0x0020 */
+#define BTA_GATT_PERM_WRITE_ENC_MITM GATT_PERM_WRITE_ENC_MITM /* bit 6 - 0x0040 */
+#define BTA_GATT_PERM_WRITE_SIGNED GATT_PERM_WRITE_SIGNED /* bit 7 - 0x0080 */
+#define BTA_GATT_PERM_WRITE_SIGNED_MITM GATT_PERM_WRITE_SIGNED_MITM /* bit 8 - 0x0100 */
+typedef UINT16 tBTA_GATT_PERM;
+
+#define BTA_GATTS_INVALID_APP 0xff
+
+#define BTA_GATTS_INVALID_IF 0
+
+/* definition of characteristic properties */
+#define BTA_GATT_CHAR_PROP_BIT_BROADCAST GATT_CHAR_PROP_BIT_BROADCAST /* 0x01 */
+#define BTA_GATT_CHAR_PROP_BIT_READ GATT_CHAR_PROP_BIT_READ /* 0x02 */
+#define BTA_GATT_CHAR_PROP_BIT_WRITE_NR GATT_CHAR_PROP_BIT_WRITE_NR /* 0x04 */
+#define BTA_GATT_CHAR_PROP_BIT_WRITE GATT_CHAR_PROP_BIT_WRITE /* 0x08 */
+#define BTA_GATT_CHAR_PROP_BIT_NOTIFY GATT_CHAR_PROP_BIT_NOTIFY /* 0x10 */
+#define BTA_GATT_CHAR_PROP_BIT_INDICATE GATT_CHAR_PROP_BIT_INDICATE /* 0x20 */
+#define BTA_GATT_CHAR_PROP_BIT_AUTH GATT_CHAR_PROP_BIT_AUTH /* 0x40 */
+#define BTA_GATT_CHAR_PROP_BIT_EXT_PROP GATT_CHAR_PROP_BIT_EXT_PROP /* 0x80 */
+typedef UINT8 tBTA_GATT_CHAR_PROP;
+
+#ifndef BTA_GATTC_CHAR_DESCR_MAX
+#define BTA_GATTC_CHAR_DESCR_MAX 7
+#endif
+
+/*********************** NV callback Data Definitions **********************
+*/
+typedef struct
+{
+ tBT_UUID app_uuid128;
+ tBT_UUID svc_uuid;
+ UINT16 svc_inst;
+ UINT16 s_handle;
+ UINT16 e_handle;
+ BOOLEAN is_primary; /* primary service or secondary */
+} tBTA_GATTS_HNDL_RANGE;
+
+#define BTA_GATTS_SRV_CHG_CMD_ADD_CLIENT GATTS_SRV_CHG_CMD_ADD_CLIENT
+#define BTA_GATTS_SRV_CHG_CMD_UPDATE_CLIENT GATTS_SRV_CHG_CMD_UPDATE_CLIENT
+#define BTA_GATTS_SRV_CHG_CMD_REMOVE_CLIENT GATTS_SRV_CHG_CMD_REMOVE_CLIENT
+#define BTA_GATTS_SRV_CHG_CMD_READ_NUM_CLENTS GATTS_SRV_CHG_CMD_READ_NUM_CLENTS
+#define BTA_GATTS_SRV_CHG_CMD_READ_CLENT GATTS_SRV_CHG_CMD_READ_CLENT
+typedef tGATTS_SRV_CHG_CMD tBTA_GATTS_SRV_CHG_CMD;
+
+typedef tGATTS_SRV_CHG tBTA_GATTS_SRV_CHG;
+typedef tGATTS_SRV_CHG_REQ tBTA_GATTS_SRV_CHG_REQ;
+typedef tGATTS_SRV_CHG_RSP tBTA_GATTS_SRV_CHG_RSP;
+
+enum
+{
+ BTA_GATT_TRANSPORT_LE,
+ BTA_GATT_TRANSPORT_BR_EDR,
+ BTA_GATT_TRANSPORT_LE_BR_EDR
+};
+typedef UINT8 tBTA_GATT_TRANSPORT;
+
+/* attribute value */
+typedef tGATT_VALUE tBTA_GATT_VALUE;
+
+/* attribute response data */
+typedef tGATTS_RSP tBTA_GATTS_RSP;
+
+/* attribute request data from the client */
+#define BTA_GATT_PREP_WRITE_CANCEL 0x00
+#define BTA_GATT_PREP_WRITE_EXEC 0x01
+typedef tGATT_EXEC_FLAG tBTA_GATT_EXEC_FLAG;
+
+/* read request always based on UUID */
+typedef tGATT_READ_REQ tTA_GBATT_READ_REQ;
+
+/* write request data */
+typedef tGATT_WRITE_REQ tBTA_GATT_WRITE_REQ;
+
+/* callback data for server access request from client */
+typedef tGATTS_DATA tBTA_GATTS_REQ_DATA;
+
+typedef struct
+{
+ BD_ADDR remote_bda;
+ UINT32 trans_id;
+ UINT16 conn_id;
+ tBTA_GATTS_REQ_DATA *p_data;
+}tBTA_GATTS_REQ;
+
+typedef struct
+{
+ tBTA_GATTS_IF server_if;
+ tBTA_GATT_STATUS status;
+// btla-specific ++
+ tBT_UUID uuid;
+// btla-specific --
+}tBTA_GATTS_REG_OPER;
+
+
+typedef struct
+{
+ tBTA_GATTS_IF server_if;
+ UINT16 service_id;
+// btla-specific ++
+ UINT16 svc_instance;
+ BOOLEAN is_primary;
+ tBTA_GATT_STATUS status;
+ tBT_UUID uuid;
+// btla-specific --
+}tBTA_GATTS_CREATE;
+
+typedef struct
+{
+ tBTA_GATTS_IF server_if;
+ UINT16 service_id;
+ UINT16 attr_id;
+ tBTA_GATT_STATUS status;
+// btla-specific ++
+ tBT_UUID char_uuid;
+// btla-specific --
+}tBTA_GATTS_ADD_RESULT;
+
+typedef struct
+{
+ tBTA_GATTS_IF server_if;
+ UINT16 service_id;
+ tBTA_GATT_STATUS status;
+}tBTA_GATTS_SRVC_OPER;
+
+
+typedef struct
+{
+ tBTA_GATTS_IF server_if;
+ BD_ADDR remote_bda;
+ UINT16 conn_id;
+ tBTA_GATT_REASON reason; /* report disconnect reason */
+}tBTA_GATTS_CONN;
+
+/* GATTS callback data */
+typedef union
+{
+ tBTA_GATTS_REG_OPER reg_oper;
+ tBTA_GATTS_CREATE create;
+ tBTA_GATTS_SRVC_OPER srvc_oper;
+ tBTA_GATT_STATUS status; /* BTA_GATTS_CONF_EVT */
+ tBTA_GATTS_ADD_RESULT add_result; /* add included service: BTA_GATTS_ADD_INCL_SRVC_EVT
+ add char : BTA_GATTS_ADD_CHAR_EVT
+ add char descriptor: BTA_GATTS_ADD_CHAR_DESCR_EVT */
+ tBTA_GATTS_REQ req_data;
+ tBTA_GATTS_CONN conn; /* BTA_GATTS_CONN_EVT */
+
+}tBTA_GATTS;
+
+
+/* Server callback function */
+typedef void (tBTA_GATTS_CBACK)(tBTA_GATTS_EVT event, tBTA_GATTS *p_data);
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**************************
+** Client Functions
+***************************/
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_AppRegister
+**
+** Description This function is called to register application callbacks
+** with BTA GATTC module.
+**
+** Parameters p_app_uuid - applicaiton UUID
+** p_client_cb - pointer to the application callback function.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_AppDeregister
+**
+** Description This function is called to deregister an application
+** from BTA GATTC module.
+**
+** Parameters client_if - client interface identifier.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_Open
+**
+** Description Open a direct connection or add a background auto connection
+** bd address
+**
+** Parameters client_if: server interface.
+** remote_bda: remote device BD address.
+** is_direct: direct connection or background auto connection
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_direct);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_CancelOpen
+**
+** Description Open a direct connection or add a background auto connection
+** bd address
+**
+** Parameters client_if: server interface.
+** remote_bda: remote device BD address.
+** is_direct: direct connection or background auto connection
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_CancelOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_direct);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_Close
+**
+** Description Close a connection to a GATT server.
+**
+** Parameters conn_id: connectino ID to be closed.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_Close(UINT16 conn_id);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_ServiceSearchRequest
+**
+** Description This function is called to request a GATT service discovery
+** on a GATT server. This function report service search result
+** by a callback event, and followed by a service search complete
+** event.
+**
+** Parameters conn_id: connection ID.
+** p_srvc_uuid: a UUID of the service application is interested in.
+** If Null, discover for all services.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_ServiceSearchRequest(UINT16 conn_id, tBT_UUID *p_srvc_uuid);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_GetFirstChar
+**
+** Description This function is called to find the first charatceristic of the
+** service on the given server.
+**
+** Parameters conn_id: connection ID which identify the server.
+** p_srvc_id: the service ID of which the characteristic is belonged to.
+** p_char_uuid_cond: Characteristic UUID, if NULL find the first available
+** characteristic.
+** p_char_result: output parameter which will store the GATT
+** characteristic ID.
+** p_property: output parameter to carry the characteristic property.
+**
+** Returns returns status.
+**
+*******************************************************************************/
+BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id,
+ tBTA_GATT_SRVC_ID *p_srvc_id,
+ tBT_UUID *p_char_uuid_cond,
+ tBTA_GATTC_CHAR_ID *p_char_result,
+ tBTA_GATT_CHAR_PROP *p_property);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_GetNextChar
+**
+** Description This function is called to find the next charatceristic of the
+** service on the given server.
+**
+** Parameters conn_id: connection ID which identify the server.
+** p_start_char_id: start the characteristic search from the next record
+** after the one identified by char_id.
+** p_char_uuid_cond: Characteristic UUID, if NULL find the first available
+** characteristic.
+** p_char_result: output parameter which will store the GATT
+** characteristic ID.
+** p_property: output parameter, characteristic property.
+**
+** Returns returns status.
+**
+*******************************************************************************/
+BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
+ tBTA_GATTC_CHAR_ID *p_start_char_id,
+ tBT_UUID *p_char_uuid_cond,
+ tBTA_GATTC_CHAR_ID *p_char_result,
+ tBTA_GATT_CHAR_PROP *p_property);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_GetFirstCharDescr
+**
+** Description This function is called to find the first charatceristic descriptor of the
+** charatceristic on the given server.
+**
+** Parameters conn_id: connection ID which identify the server.
+** p_char_id: the characteristic ID of which the descriptor is belonged to.
+** p_descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available
+** characteristic.
+** p_descr_result: output parameter which will store the GATT
+** characteristic descriptor ID.
+**
+** Returns returns status.
+**
+*******************************************************************************/
+BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
+ tBT_UUID *p_descr_uuid_cond,
+ tBTA_GATTC_CHAR_DESCR_ID *p_descr_result);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_GetNextCharDescr
+**
+** Description This function is called to find the next charatceristic of the
+** service on the given server.
+**
+** Parameters conn_id: connection ID which identify the server.
+** p_start_descr_id: start the characteristic search from the next record
+** after the one identified by p_start_descr_id.
+** p_descr_uuid_cond: Characteristic descriptor UUID, if NULL find
+** the first available characteristic descriptor.
+** p_descr_result: output parameter which will store the GATT
+** characteristic descriptor ID.
+**
+** Returns returns status.
+**
+*******************************************************************************/
+BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
+ tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id,
+ tBT_UUID *p_descr_uuid_cond,
+ tBTA_GATTC_CHAR_DESCR_ID *p_descr_result);
+
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_GetFirstIncludedService
+**
+** Description This function is called to find the first included service of the
+** service on the given server.
+**
+** Parameters conn_id: connection ID which identify the server.
+** p_srvc_id: the service ID of which the included service is belonged to.
+** p_uuid_cond: include service UUID, if NULL find the first available
+** included service.
+** p_result: output parameter which will store the GATT ID
+** of the included service found.
+**
+** Returns returns status.
+**
+*******************************************************************************/
+BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id,
+ tBTA_GATT_SRVC_ID *p_srvc_id,
+ tBT_UUID *p_uuid_cond,
+ tBTA_GATTC_INCL_SVC_ID *p_result);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_GetNextIncludedService
+**
+** Description This function is called to find the next included service of the
+** service on the given server.
+**
+** Parameters conn_id: connection ID which identify the server.
+** p_start_id: start the search from the next record
+** after the one identified by p_start_id.
+** p_uuid_cond: Included service UUID, if NULL find the first available
+** included service.
+** p_result: output parameter which will store the GATT ID
+** of the included service found.
+**
+** Returns returns status.
+**
+*******************************************************************************/
+BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
+ tBTA_GATTC_INCL_SVC_ID *p_start_id,
+ tBT_UUID *p_uuid_cond,
+ tBTA_GATTC_INCL_SVC_ID *p_result);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_ReadCharacteristic
+**
+** Description This function is called to read a service's characteristics of
+** the given characteritisc ID.
+**
+** Parameters conn_id - connectino ID.
+** p_char_id - characteritic ID to read.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_ReadCharacteristic (UINT16 conn_id,
+ tBTA_GATTC_CHAR_ID *p_char_id,
+ tBTA_GATT_AUTH_REQ auth_req);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_ReadCharDescr
+**
+** Description This function is called to read a characteristics descriptor.
+**
+** Parameters conn_id - connection ID.
+** p_char_descr_id - characteritic descriptor ID to read.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
+ tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
+ tBTA_GATT_AUTH_REQ auth_req);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_WriteCharValue
+**
+** Description This function is called to write characteristic value.
+**
+** Parameters conn_id - connection ID.
+** p_char_id - characteristic ID to write.
+** write_type - type of write.
+** len: length of the data to be written.
+** p_value - the value to be written.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_WriteCharValue (UINT16 conn_id,
+ tBTA_GATTC_CHAR_ID *p_char_id,
+ tBTA_GATTC_WRITE_TYPE write_type,
+ UINT16 len,
+ UINT8 *p_value,
+ tBTA_GATT_AUTH_REQ auth_req);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_WriteCharDescr
+**
+** Description This function is called to write characteristic descriptor value.
+**
+** Parameters conn_id - connection ID
+** p_char_descr_id - characteristic descriptor ID to write.
+** write_type - type of write.
+** p_value - the value to be written.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
+ tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
+ tBTA_GATTC_WRITE_TYPE write_type,
+ tBTA_GATT_UNFMT *p_data,
+ tBTA_GATT_AUTH_REQ auth_req);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_SendIndConfirm
+**
+** Description This function is called to send handle value confirmation.
+**
+** Parameters conn_id - connection ID.
+** p_char_id - characteristic ID to confrim.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_RegisterForNotifications
+**
+** Description This function is called to register for notification of a service.
+**
+** Parameters client_if - client interface.
+** remote_bda - target GATT server.
+** p_char_id - pointer to GATT characteristic ID.
+**
+** Returns OK if registration succeed, otherwise failed.
+**
+*******************************************************************************/
+BTA_API extern tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
+ BD_ADDR remote_bda,
+ tBTA_GATTC_CHAR_ID *p_char_id);
+
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_DeregisterForNotifications
+**
+** Description This function is called to de-register for notification of a servbice.
+**
+** Parameters client_if - client interface.
+** remote_bda - target GATT server.
+** p_char_id - pointer to a GATT characteristic ID.
+**
+** Returns OK if deregistration succeed, otherwise failed.
+**
+*******************************************************************************/
+BTA_API extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
+ BD_ADDR remote_bda,
+ tBTA_GATTC_CHAR_ID *p_char_id);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_PrepareWrite
+**
+** Description This function is called to prepare write a characteristic value.
+**
+** Parameters conn_id - connection ID.
+** p_char_id - GATT characteritic ID of the service.
+** offset - offset of the write value.
+** len: length of the data to be written.
+** p_value - the value to be written.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_PrepareWrite (UINT16 conn_id,
+ tBTA_GATTC_CHAR_ID *p_char_id,
+ UINT16 offset,
+ UINT16 len,
+ UINT8 *p_value,
+ tBTA_GATT_AUTH_REQ auth_req);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_ExecuteWrite
+**
+** Description This function is called to execute write a prepare write sequence.
+**
+** Parameters conn_id - connection ID.
+** is_execute - execute or cancel.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute);
+
+/*******************************************************************************
+**
+** Function BTA_GATTC_ReadMultiple
+**
+** Description This function is called to read multiple characteristic or
+** characteristic descriptors.
+**
+** Parameters conn_id - connectino ID.
+** p_read_multi - read multiple parameters.
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
+ tBTA_GATT_AUTH_REQ auth_req);
+
+
+
+
+/*******************************************************************************
+** BTA GATT Server API
+********************************************************************************/
+/*******************************************************************************
+**
+** Function BTA_GATTS_AppRegister
+**
+** Description This function is called to register application callbacks
+** with BTA GATTS module.
+**
+** Parameters p_app_uuid - applicaiton UUID
+** p_cback - pointer to the application callback function.
+**
+** Returns None
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback);
+
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_AppDeregister
+**
+** Description De-register with BTA GATT Server.
+**
+** Parameters server_if: server interface
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_AppDeregister(tBTA_GATTS_IF server_if);
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_CreateService
+**
+** Description Create a service. When service creation is done, a callback
+** event BTA_GATTS_CREATE_SRVC_EVT is called to report status
+** and service ID to the profile. The service ID obtained in
+** the callback function needs to be used when adding included
+** service and characteristics/descriptors into the service.
+**
+** Parameters server_if: server interface.
+** p_service_uuid: service UUID.
+** inst: instance ID number of this service.
+** num_handle: numble of handle requessted for this service.
+** is_primary: is this service a primary one or not.
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid,
+ UINT8 inst, UINT16 num_handle, BOOLEAN is_primary);
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_AddIncludeService
+**
+** Description This function is called to add an included service. After included
+** service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
+** is reported the included service ID.
+**
+** Parameters service_id: service ID to which this included service is to
+** be added.
+** included_service_id: the service ID to be included.
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_AddIncludeService(UINT16 service_id, UINT16 included_service_id);
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_AddCharacteristic
+**
+** Description This function is called to add a characteristic into a service.
+**
+** Parameters service_id: service ID to which this included service is to
+** be added.
+** p_char_uuid : Characteristic UUID.
+** perm : Characteristic value declaration attribute permission.
+** property : Characteristic Properties
+**
+** Returns None
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid,
+ tBTA_GATT_PERM perm, tBTA_GATT_CHAR_PROP property);
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_AddCharDescriptor
+**
+** Description This function is called to add characteristic descriptor. When
+** it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
+** to report the status and an ID number for this descriptor.
+**
+** Parameters service_id: service ID to which this charatceristic descriptor is to
+** be added.
+** perm: descriptor access permission.
+** p_descr_uuid: descriptor UUID.
+** p_descr_params: descriptor value if it's read only descriptor.
+**
+** Returns returns status.
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
+ tBTA_GATT_PERM perm,
+ tBT_UUID * p_descr_uuid);
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_DeleteService
+**
+** Description This function is called to delete a service. When this is done,
+** a callback event BTA_GATTS_DELETE_EVT is report with the status.
+**
+** Parameters service_id: service_id to be deleted.
+**
+** Returns returns none.
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_DeleteService(UINT16 service_id);
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_StartService
+**
+** Description This function is called to start a service.
+**
+** Parameters service_id: the service ID to be started.
+** sup_transport: supported trasnport.
+**
+** Returns None.
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_StartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transport);
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_StopService
+**
+** Description This function is called to stop a service.
+**
+** Parameters service_id - service to be topped.
+**
+** Returns None
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_StopService(UINT16 service_id);
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_HandleValueIndication
+**
+** Description This function is called to read a characteristics descriptor.
+**
+** Parameters conn_id - connection identifier.
+** attr_id - attribute ID to indicate.
+** data_len - indicate data length.
+** p_data: data to indicate.
+** need_confirm - if this indication expects a confirmation or not.
+**
+** Returns None
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id,
+ UINT16 data_len,
+ UINT8 *p_data,
+ BOOLEAN need_confirm);
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_SendRsp
+**
+** Description This function is called to send a response to a request.
+**
+** Parameters conn_id - connection identifier.
+** trans_id - transaction ID.
+** status - response status
+** p_msg - response data.
+**
+** Returns None
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
+ tBTA_GATT_STATUS status, tBTA_GATTS_RSP *p_msg);
+
+
+
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_Open
+**
+** Description Open a direct open connection or add a background auto connection
+** bd address
+**
+** Parameters server_if: server interface.
+** remote_bda: remote device BD address.
+** is_direct: direct connection or background auto connection
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_Open(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_direct);
+
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_CancelOpen
+**
+** Description Cancel a direct open connection or remove a background auto connection
+** bd address
+**
+** Parameters server_if: server interface.
+** remote_bda: remote device BD address.
+** is_direct: direct connection or background auto connection
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_CancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_direct);
+
+
+/*******************************************************************************
+**
+** Function BTA_GATTS_Close
+**
+** Description Close a connection a remote device.
+**
+** Parameters conn_id: connectino ID to be closed.
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_GATTS_Close(UINT16 conn_id);
+
+
+#ifdef __cplusplus
+
+}
+#endif
+
+
+#endif /* BTA_GATT_API_H */
+
diff --git a/bta/include/bta_gattc_ci.h b/bta/include/bta_gattc_ci.h
new file mode 100644
index 0000000..65941fc
--- /dev/null
+++ b/bta/include/bta_gattc_ci.h
@@ -0,0 +1,108 @@
+/*****************************************************************************
+**
+** Name: bta_gattc_ci.h
+**
+** Description: This is the interface file for GATT
+** call-in functions.
+**
+** Copyright (c) 2003-2009, Broadcom Corp., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_GATTC_CI_H
+#define BTA_GATTC_CI_H
+
+#include "bta_gatt_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* Open Complete Event */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_GATT_STATUS status;
+} tBTA_GATTC_CI_EVT;
+
+#define BTA_GATTC_NV_LOAD_MAX 10
+
+/* Read Ready Event */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTA_GATT_STATUS status;
+ UINT16 num_attr;
+ tBTA_GATTC_NV_ATTR attr[BTA_GATTC_NV_LOAD_MAX];
+} tBTA_GATTC_CI_LOAD;
+
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_gattc_ci_cache_open
+**
+** Description This function sends an event to indicate server cache open
+** completed.
+**
+** Parameters server_bda - server BDA of this cache.
+** status - BTA_GATT_OK if full buffer of data,
+** BTA_GATT_FAIL if an error has occurred.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_gattc_ci_cache_open(BD_ADDR server_bda, UINT16 evt,
+ tBTA_GATT_STATUS status, UINT16 conn_id);
+
+/*******************************************************************************
+**
+** Function bta_gattc_ci_cache_load
+**
+** Description This function sends an event to BTA indicating the phone has
+** load the servere cache and ready to send it to the stack.
+**
+** Parameters server_bda - server BDA of this cache.
+** num_bytes_read - number of bytes read into the buffer
+** specified in the read callout-function.
+** status - BTA_GATT_OK if full buffer of data,
+** BTA_GATT_FAIL if an error has occurred.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt,
+ UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_atrr,
+ tBTA_GATT_STATUS status, UINT16 conn_id);
+
+/*******************************************************************************
+**
+** Function bta_gattc_ci_save
+**
+** Description This function sends an event to BTA indicating the phone has
+** save the server cache.
+**
+** Parameters server_bda - server BDA of this cache.
+** status - BTA_GATT_OK if full buffer of data,
+** BTA_GATT_FAIL if an error has occurred.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_gattc_ci_cache_save(BD_ADDR server_bda, UINT16 evt,
+ tBTA_GATT_STATUS status, UINT16 conn_id);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_GATTC_CI_H */
+
diff --git a/bta/include/bta_gattc_co.h b/bta/include/bta_gattc_co.h
new file mode 100644
index 0000000..0aedf9f
--- /dev/null
+++ b/bta/include/bta_gattc_co.h
@@ -0,0 +1,89 @@
+/*****************************************************************************
+**
+** Name: bta_gattc_co.h
+**
+** Description: This is the interface file for BTA GATT client call-out
+** functions.
+**
+** Copyright (c) 2010, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_GATTC_CO_H
+#define BTA_GATTC_CO_H
+
+#include "bta_gatt_api.h"
+
+/*******************************************************************************
+**
+** Function bta_gattc_co_cache_open
+**
+** Description This callout function is executed by GATTC when a GATT server
+** cache is ready to be sent.
+**
+** Parameter server_bda: server bd address of this cache belongs to
+** evt: call in event to be passed in when cache open is done.
+** conn_id: connection ID of this cache operation attach to.
+** to_save: open cache to save or to load.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_gattc_co_cache_open(BD_ADDR server_bda, UINT16 evt,
+ UINT16 conn_id, BOOLEAN to_save);
+
+/*******************************************************************************
+**
+** Function bta_gattc_co_cache_close
+**
+** Description This callout function is executed by GATTC when a GATT server
+** cache is written completely.
+**
+** Parameter server_bda: server bd address of this cache belongs to
+** conn_id: connection ID of this cache operation attach to.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_gattc_co_cache_close(BD_ADDR server_bda, UINT16 conn_id);
+
+/*******************************************************************************
+**
+** Function bta_gattc_co_cache_save
+**
+** Description This callout function is executed by GATT when a server cache
+** is available to save.
+**
+** Parameter server_bda: server bd address of this cache belongs to
+** evt: call in event to be passed in when cache save is done.
+** num_attr: number of attribute to be save.
+** p_attr: pointer to the list of attributes to save.
+** attr_index: starting attribute index of the save operation.
+** conn_id: connection ID of this cache operation attach to.
+** Returns
+**
+*******************************************************************************/
+BTA_API extern void bta_gattc_co_cache_save(BD_ADDR server_bda, UINT16 evt,
+ UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr,
+ UINT16 attr_index, UINT16 conn_id);
+
+/*******************************************************************************
+**
+** Function bta_gattc_co_cache_load
+**
+** Description This callout function is executed by GATT when server cache
+** is required to load.
+**
+** Parameter server_bda: server bd address of this cache belongs to
+** evt: call in event to be passed in when cache save is done.
+** num_attr: number of attribute to be save.
+** attr_index: starting attribute index of the save operation.
+** conn_id: connection ID of this cache operation attach to.
+** Returns
+**
+*******************************************************************************/
+BTA_API extern void bta_gattc_co_cache_load(BD_ADDR server_bda, UINT16 evt,
+ UINT16 start_index, UINT16 conn_id);
+
+#endif /* BTA_GATT_CO_H */
+
diff --git a/bta/include/bta_gatts_co.h b/bta/include/bta_gatts_co.h
new file mode 100644
index 0000000..cb1ff76
--- /dev/null
+++ b/bta/include/bta_gatts_co.h
@@ -0,0 +1,70 @@
+/*****************************************************************************
+**
+** Name: bta_gatts_co.h
+**
+** Description: This is the interface file for BTA GATT server call-out
+** functions.
+**
+** Copyright (c) 2010, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_GATTS_CO_H
+#define BTA_GATTS_CO_H
+
+#include "bta_gatt_api.h"
+
+/*******************************************************************************
+**
+** Function bta_gatts_co_update_handle_range
+**
+** Description This callout function is executed by GATTS when a GATT server
+** handle range ios to be added or removed.
+**
+** Parameter is_add: true is to add a handle range; otherwise is to delete.
+** p_hndl_range: handle range.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_gatts_co_update_handle_range(BOOLEAN is_add, tBTA_GATTS_HNDL_RANGE *p_hndl_range);
+
+/*******************************************************************************
+**
+** Function bta_gatts_co_srv_chg
+**
+** Description This call-out is to read/write/remove service change related
+** informaiton. The request consists of the cmd and p_req and the
+** response is returned in p_rsp
+**
+** Parameter cmd - request command
+** p_req - request paramters
+** p_rsp - response data for the request
+**
+** Returns TRUE - if the request is processed successfully and
+** the response is returned in p_rsp.
+** FASLE - if the request can not be processed
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN bta_gatts_co_srv_chg(tBTA_GATTS_SRV_CHG_CMD cmd,
+ tBTA_GATTS_SRV_CHG_REQ *p_req,
+ tBTA_GATTS_SRV_CHG_RSP *p_rsp);
+
+/*******************************************************************************
+**
+** Function bta_gatts_co_load_handle_range
+**
+** Description This callout function is executed by GATTS when a GATT server
+** handle range is requested to be loaded from NV.
+**
+** Parameter
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN bta_gatts_co_load_handle_range(UINT8 index,
+ tBTA_GATTS_HNDL_RANGE *p_handle);
+
+
+#endif /* BTA_GATTS_CO_H */
+
diff --git a/bta/include/bta_hd_api.h b/bta/include/bta_hd_api.h
new file mode 100644
index 0000000..5fd7443
--- /dev/null
+++ b/bta/include/bta_hd_api.h
@@ -0,0 +1,289 @@
+/******************************************************************************
+**
+** File Name: bta_hd_api.h
+**
+** Description: This is the interface header file for the HID Device service.
+**
+** Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved.
+** WIDCOMM Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#ifndef BTA_HD_API_H
+#define BTA_HD_API_H
+
+#include "bt_types.h"
+#include "bta_api.h"
+#include "hidd_api.h"
+
+/*****************************************************************************/
+/* C O N S T A N T S */
+/*****************************************************************************/
+/* status values */
+#define BTA_HD_SUCCESS 0 /* operation successful */
+#define BTA_HD_FAIL 1 /* generic failure */
+#define BTA_HD_FAIL_SDP 2 /* service not found */
+
+typedef UINT8 tBTA_HD_STATUS;
+
+/* HD callback events */
+#define BTA_HD_ENABLE_EVT 0 /* HD enabled */
+#define BTA_HD_OPEN_EVT 1 /* connection opened */
+#define BTA_HD_CLOSE_EVT 2 /* connection closed */
+#define BTA_HD_UNPLUG_EVT 3 /* unplug */
+#define BTA_HD_DATA_EVT 4 /* Data received */
+#define BTA_HD_DATC_EVT 5 /* Data continueation received */
+
+typedef UINT8 tBTA_HD_EVT;
+
+enum
+{
+ BTA_HD_REPT_ID_SPEC, /* 0 */
+ BTA_HD_REPT_ID_KBD, /* 1: regular keyboard */
+ BTA_HD_REPT_ID_MOUSE, /* 2: mouse */
+ BTA_HD_REPT_ID_CONSUMER
+};
+typedef UINT8 tBTA_HD_REPT_ID;
+#define BTA_HD_REPT_ID_MAX BTA_HD_REPT_ID_CONSUMER
+
+
+#define BTA_HD_KBD_REPT_SIZE 9
+#define BTA_HD_MOUSE_REPT_SIZE 5
+
+
+/* Modifier Keys definition */
+#define BTA_HD_MDF_LCTRL 0x01 /* Left CTRL */
+#define BTA_HD_MDF_LSHIFT 0x02 /* Left SHIFT */
+#define BTA_HD_MDF_LALT 0x04 /* Left ALT */
+#define BTA_HD_MDF_LGUI 0x08 /* Left GUI */
+#define BTA_HD_MDF_RCTRL 0x10 /* Right CTRL */
+#define BTA_HD_MDF_RSHIFT 0x20 /* Right SHIFT */
+#define BTA_HD_MDF_RALT 0x40 /* Right ALT */
+#define BTA_HD_MDF_RGUI 0x80 /* Right GUI */
+
+/* keycode definition -
+ * See USB HID Usage Tables section 10: Keyboard/Keypad Page (0x07) */
+#define BTA_HD_KEYCODE_A 0x04 /* a A */
+#define BTA_HD_KEYCODE_B 0x05 /* b B */
+#define BTA_HD_KEYCODE_C 0x06 /* c C */
+#define BTA_HD_KEYCODE_D 0x07 /* d D */
+#define BTA_HD_KEYCODE_E 0x08 /* e E */
+#define BTA_HD_KEYCODE_F 0x09 /* f F */
+#define BTA_HD_KEYCODE_G 0x0A /* g G */
+#define BTA_HD_KEYCODE_H 0x0B /* h H */
+#define BTA_HD_KEYCODE_I 0x0C /* i I */
+#define BTA_HD_KEYCODE_J 0x0D /* j J */
+#define BTA_HD_KEYCODE_K 0x0E /* k K */
+#define BTA_HD_KEYCODE_L 0x0F /* l L */
+#define BTA_HD_KEYCODE_M 0x10 /* m M */
+#define BTA_HD_KEYCODE_N 0x11 /* n N */
+#define BTA_HD_KEYCODE_O 0x12 /* o O */
+#define BTA_HD_KEYCODE_P 0x13 /* p P */
+#define BTA_HD_KEYCODE_Q 0x14 /* q Q */
+#define BTA_HD_KEYCODE_R 0x15 /* r R */
+#define BTA_HD_KEYCODE_S 0x16 /* s S */
+#define BTA_HD_KEYCODE_T 0x17 /* t T */
+#define BTA_HD_KEYCODE_U 0x18 /* u U */
+#define BTA_HD_KEYCODE_V 0x19 /* v V */
+#define BTA_HD_KEYCODE_W 0x1A /* w W */
+#define BTA_HD_KEYCODE_X 0x1B /* x X */
+#define BTA_HD_KEYCODE_Y 0x1C /* y Y */
+#define BTA_HD_KEYCODE_Z 0x1D /* z Z */
+#define BTA_HD_KEYCODE_1 0x1E /* 1 ! */
+#define BTA_HD_KEYCODE_2 0x1F /* 2 @ */
+#define BTA_HD_KEYCODE_3 0x20 /* 3 # */
+#define BTA_HD_KEYCODE_4 0x21 /* 4 $ */
+#define BTA_HD_KEYCODE_5 0x22 /* 5 % */
+#define BTA_HD_KEYCODE_6 0x23 /* 6 ^ */
+#define BTA_HD_KEYCODE_7 0x24 /* 7 & */
+#define BTA_HD_KEYCODE_8 0x25 /* 8 * */
+#define BTA_HD_KEYCODE_9 0x26 /* 9 ( */
+#define BTA_HD_KEYCODE_0 0x27 /* 0 ) */
+#define BTA_HD_KEYCODE_ENTER 0x28 /* ENTER */
+#define BTA_HD_KEYCODE_ESC 0x29 /* ESC */
+#define BTA_HD_KEYCODE_BACKSPACE 0x2A /* BACKSPACE */
+#define BTA_HD_KEYCODE_TAB 0x2B /* TAB */
+#define BTA_HD_KEYCODE_SPACE 0x2C /* SPACE */
+#define BTA_HD_KEYCODE_MINUS 0x2D /* - _ */
+#define BTA_HD_KEYCODE_EQUAL 0x2E /* = + */
+#define BTA_HD_KEYCODE_LBRACKET 0x2F /* [ { */
+#define BTA_HD_KEYCODE_RBRACKET 0x30 /* ] } */
+#define BTA_HD_KEYCODE_BACKSLASH 0x31 /* \ | */
+#define BTA_HD_KEYCODE_SEMICOLUMN 0x33 /* ; : */
+#define BTA_HD_KEYCODE_QUOTE 0x34 /* ' " */
+#define BTA_HD_KEYCODE_TILT 0x35 /* ` ~ */
+#define BTA_HD_KEYCODE_COMMA 0x36 /* , < */
+#define BTA_HD_KEYCODE_DIR 0x37 /* . > */
+#define BTA_HD_KEYCODE_SLASH 0x38 /* / ? */
+#define BTA_HD_KEYCODE_F1 0x3A /* F1 */
+#define BTA_HD_KEYCODE_F2 0x3B /* F2 */
+#define BTA_HD_KEYCODE_F3 0x3C /* F3 */
+#define BTA_HD_KEYCODE_F4 0x3D /* F4 */
+#define BTA_HD_KEYCODE_F5 0x3E /* F5 */
+#define BTA_HD_KEYCODE_F6 0x3F /* F6 */
+#define BTA_HD_KEYCODE_F7 0x40 /* F7 */
+#define BTA_HD_KEYCODE_F8 0x41 /* F8 */
+#define BTA_HD_KEYCODE_F9 0x42 /* F9 */
+#define BTA_HD_KEYCODE_F10 0x43 /* F10 */
+#define BTA_HD_KEYCODE_F11 0x44 /* F11 */
+#define BTA_HD_KEYCODE_F12 0x45 /* F12 */
+#define BTA_HD_KEYCODE_HOME 0x4A /* HOME */
+#define BTA_HD_KEYCODE_PAGEUP 0x4B /* PAGE UP */
+#define BTA_HD_KEYCODE_END 0x4D /* END */
+#define BTA_HD_KEYCODE_PAGEDOWN 0x4E /* PAGE DOWN */
+#define BTA_HD_KEYCODE_RIGHTARROW 0x4F /* RIGHT ARROW */
+#define BTA_HD_KEYCODE_LEFTARROW 0x50 /* LEFT ARROW */
+#define BTA_HD_KEYCODE_DOWNARROW 0x51 /* DOWN ARROW */
+#define BTA_HD_KEYCODE_UPARROW 0x52 /* UP ARROW */
+#define BTA_HD_KEYCODE_POPUP 0x65 /* POPUP Menu */
+
+/* data associated with BTA_HD_OPEN_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr;
+} tBTA_HD_OPEN;
+
+/* data associated with BTA_HD_ENABLE_EVT */
+typedef struct
+{
+ tBTA_HD_STATUS status;
+} tBTA_HD_ENABLE;
+
+/* data associated with BTA_HD_CLOSE_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr;
+} tBTA_HD_CLOSE;
+
+/* data associated with BTA_HD_REPORT_EVT */
+typedef struct
+{
+ UINT8 *p_data;
+ UINT16 len;
+} tBTA_HD_REPORT;
+/*****************************************************************************/
+/* F U N C T I O N P R O T O T Y P E S */
+/*****************************************************************************/
+/* union of data associated with HD callback */
+typedef union
+{
+ tBTA_HD_ENABLE enable;
+ tBTA_HD_OPEN open;
+ tBTA_HD_CLOSE close;
+ tBTA_HD_REPORT data;
+} tBTA_HD;
+
+/* HD callback */
+typedef void (tBTA_HD_CBACK)(tBTA_HD_EVT event, tBTA_HD *p_data);
+
+/* HD configuration structure */
+typedef struct
+{
+ tHID_DEV_QOS_INFO qos;
+ tHID_DEV_SDP_INFO sdp_info;
+ BOOLEAN use_qos; /* use QoS */
+} tBTA_HD_CFG;
+
+/*******************************************************************************
+**
+** Function BTA_HdEnable
+**
+** Description Enable the HID Device service. When the enable
+** operation is complete the callback function will be
+** called with a BTA_HD_ENABLE_EVT. This function must
+** be called before other function in the HD API are
+** called.
+**
+** If all bytes of the specified bd_addr are 0xff, the
+** peer address is considered as unknown. The HID device listens
+** for incoming connection request.
+** Otherwise, The HID device initiates a connection toward the
+** specified bd_addr when BTA_HdOpen() is called.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HdEnable(BD_ADDR bd_addr, tBTA_SEC sec_mask, const char *p_service_name,
+ tBTA_HD_CBACK *p_cback, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_HdDisable
+**
+** Description Disable the HID Device service.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HdDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_HdOpen
+**
+** Description Opens an HID Device connection to a peer device.
+** When connection is open, callback function is called
+** with a BTA_HD_OPEN_EVT.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HdOpen(tBTA_SEC sec_mask);
+
+/*******************************************************************************
+**
+** Function BTA_HdClose
+**
+** Description Close the current connection a peer device.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HdClose(void);
+
+/*******************************************************************************
+**
+** Function BTA_HdSendRegularKey
+**
+** Description Send a key report to the connected host.
+** If auto_release is TRUE, assume the keyboard report must be
+** a key press. An associated key release report is also sent.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HdSendRegularKey (UINT8 modifier, UINT8 key_code, BOOLEAN auto_release);
+
+/*******************************************************************************
+**
+** Function BTA_HdSendSpecialKey
+**
+** Description Send a special key report to the connected host.
+** The report is sent as a keyboard report.
+** If auto_release is TRUE, assume the keyboard report must be
+** a key press. An associated key release report is also sent.
+** If key_len is less than BTA_HD_KBD_REPT_SIZE, the key_seq
+** is padded with 0 until BTA_HD_KBD_REPT_SIZE.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HdSendSpecialKey (UINT8 key_len, UINT8 * key_seq, BOOLEAN auto_release);
+
+/*******************************************************************************
+**
+** Function BTA_HdSendMouseReport
+**
+** Description Send a mouse report to the connected host
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_HdSendMouseReport (UINT8 is_left, UINT8 is_right, UINT8 is_middle,
+ INT8 delta_x, INT8 delta_y, INT8 delta_wheel);
+
+
+#endif /* BTA_HD_API_H */
diff --git a/bta/include/bta_hh_api.h b/bta/include/bta_hh_api.h
new file mode 100644
index 0000000..11dc35e
--- /dev/null
+++ b/bta/include/bta_hh_api.h
@@ -0,0 +1,444 @@
+/****************************************************************************
+**
+** Name: bta_hh_api.h
+**
+** Function: this file contains HID HOST side API definitions
+**
+** Copyright (c) 2002-2004, WIDCOMM Inc., All Rights Reserved.
+** WIDCOMM Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_HH_API_H
+#define BTA_HH_API_H
+
+#include "bta_api.h"
+#include "hidh_api.h"
+
+/*****************************************************************************
+** Constants and Type Definitions
+*****************************************************************************/
+#ifndef BTA_HH_DEBUG
+#define BTA_HH_DEBUG FALSE
+#endif
+
+#ifndef BTA_HH_SSR_MAX_LATENCY_DEF
+#define BTA_HH_SSR_MAX_LATENCY_DEF 1600
+#endif
+
+#ifndef BTA_HH_SSR_MIN_TOUT_DEF
+#define BTA_HH_SSR_MIN_TOUT_DEF 2
+#endif
+
+/* BTA HID Host callback events */
+#define BTA_HH_ENABLE_EVT 0 /* HH enabled */
+#define BTA_HH_DISABLE_EVT 1 /* HH disabled */
+#define BTA_HH_OPEN_EVT 2 /* connection opened */
+#define BTA_HH_CLOSE_EVT 3 /* connection closed */
+#define BTA_HH_GET_RPT_EVT 4 /* BTA_HhGetReport callback */
+#define BTA_HH_SET_RPT_EVT 5 /* BTA_HhSetReport callback */
+#define BTA_HH_GET_PROTO_EVT 6 /* BTA_GetProtoMode callback */
+#define BTA_HH_SET_PROTO_EVT 7 /* BTA_HhSetProtoMode callback */
+/* leave 8, 9 gap due to deprecate of GET_IDLE and SET_IDLE */
+#define BTA_HH_GET_DSCP_EVT 10 /* Get report descripotor */
+#define BTA_HH_ADD_DEV_EVT 11 /* Add Device callback */
+#define BTA_HH_RMV_DEV_EVT 12 /* remove device finished */
+#define BTA_HH_VC_UNPLUG_EVT 13 /* virtually unplugged */
+#define BTA_HH_UPDATE_UCD_EVT 14
+#define BTA_HH_API_ERR_EVT 15 /* API error is caught */
+
+typedef UINT16 tBTA_HH_EVT;
+
+/* defined the minimum offset */
+#define BTA_HH_MIN_OFFSET L2CAP_MIN_OFFSET+1
+
+#define BTA_HH_MAX_KNOWN HID_HOST_MAX_DEVICES
+/* invalid device handle */
+#define BTA_HH_INVALID_HANDLE 0xff
+
+/* type of protocol mode */
+#define BTA_HH_PROTO_RPT_MODE (0x00)
+#define BTA_HH_PROTO_BOOT_MODE (0x01)
+#define BTA_HH_PROTO_UNKNOWN (0xff)
+typedef UINT8 tBTA_HH_PROTO_MODE;
+
+enum
+{
+ BTA_HH_KEYBD_RPT_ID = 1,
+ BTA_HH_MOUSE_RPT_ID
+};
+typedef UINT8 tBTA_HH_BOOT_RPT_ID;
+
+/* type of devices, bit mask */
+#define BTA_HH_DEVT_UNKNOWN 0x00
+#define BTA_HH_DEVT_JOS 0x01 /* joy stick */
+#define BTA_HH_DEVT_GPD 0x02 /* game pad */
+#define BTA_HH_DEVT_RMC 0x03 /* remote control */
+#define BTA_HH_DEVT_SED 0x04 /* sensing device */
+#define BTA_HH_DEVT_DGT 0x05 /* Digitizer tablet */
+#define BTA_HH_DEVT_CDR 0x06 /* card reader */
+#define BTA_HH_DEVT_KBD 0x10 /* keyboard */
+#define BTA_HH_DEVT_MIC 0x20 /* pointing device */
+#define BTA_HH_DEVT_COM 0x30 /* Combo keyboard/pointing */
+#define BTA_HH_DEVT_OTHER 0x80
+typedef UINT8 tBTA_HH_DEVT;
+
+enum
+{
+ BTA_HH_OK,
+ BTA_HH_HS_HID_NOT_READY, /* handshake error : device not ready */
+ BTA_HH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */
+ BTA_HH_HS_TRANS_NOT_SPT, /* handshake error : transaction not spt */
+ BTA_HH_HS_INVALID_PARAM, /* handshake error : invalid paremter */
+ BTA_HH_HS_ERROR, /* handshake error : unspecified HS error */
+ BTA_HH_ERR, /* general BTA HH error */
+ BTA_HH_ERR_SDP, /* SDP error */
+ BTA_HH_ERR_PROTO, /* SET_Protocol error,
+ only used in BTA_HH_OPEN_EVT callback */
+ BTA_HH_ERR_DB_FULL, /* device database full error, used in
+ BTA_HH_OPEN_EVT/BTA_HH_ADD_DEV_EVT */
+ BTA_HH_ERR_TOD_UNSPT, /* type of device not supported */
+ BTA_HH_ERR_NO_RES, /* out of system resources */
+ BTA_HH_ERR_AUTH_FAILED, /* authentication fail */
+ BTA_HH_ERR_HDL
+};
+typedef UINT8 tBTA_HH_STATUS;
+
+
+#define BTA_HH_VIRTUAL_CABLE HID_VIRTUAL_CABLE
+#define BTA_HH_NORMALLY_CONNECTABLE HID_NORMALLY_CONNECTABLE
+#define BTA_HH_RECONN_INIT HID_RECONN_INIT
+#define BTA_HH_SDP_DISABLE HID_SDP_DISABLE
+#define BTA_HH_BATTERY_POWER HID_BATTERY_POWER
+#define BTA_HH_REMOTE_WAKE HID_REMOTE_WAKE
+#define BTA_HH_SUP_TOUT_AVLBL HID_SUP_TOUT_AVLBL
+#define BTA_HH_SEC_REQUIRED HID_SEC_REQUIRED
+typedef UINT16 tBTA_HH_ATTR_MASK;
+
+
+/* supported type of device and corresponding application ID */
+typedef struct
+{
+ tBTA_HH_DEVT tod; /* type of device */
+ UINT8 app_id; /* corresponding application ID */
+}tBTA_HH_SPT_TOD;
+
+/* configuration struct */
+typedef struct
+{
+ UINT8 max_devt_spt; /* max number of types of devices spt */
+ tBTA_HH_SPT_TOD *p_devt_list; /* supported types of device list */
+ UINT16 sdp_db_size;
+}tBTA_HH_CFG;
+
+enum
+{
+ BTA_HH_RPTT_RESRV, /* reserved */
+ BTA_HH_RPTT_INPUT, /* input report */
+ BTA_HH_RPTT_OUTPUT, /* output report */
+ BTA_HH_RPTT_FEATURE /* feature report */
+};
+typedef UINT8 tBTA_HH_RPT_TYPE;
+
+/* HID_CONTROL operation code used in BTA_HhSendCtrl()
+*/
+enum
+{
+ BTA_HH_CTRL_NOP = 0 + HID_PAR_CONTROL_NOP ,/* mapping from BTE */
+ BTA_HH_CTRL_HARD_RESET, /* hard reset */
+ BTA_HH_CTRL_SOFT_RESET, /* soft reset */
+ BTA_HH_CTRL_SUSPEND, /* enter suspend */
+ BTA_HH_CTRL_EXIT_SUSPEND, /* exit suspend */
+ BTA_HH_CTRL_VIRTUAL_CABLE_UNPLUG /* virtual unplug */
+};
+typedef UINT8 tBTA_HH_TRANS_CTRL_TYPE;
+
+typedef tHID_DEV_DSCP_INFO tBTA_HH_DEV_DESCR;
+
+/* report descriptor information */
+typedef struct
+{
+ UINT16 vendor_id; /* vendor ID */
+ UINT16 product_id; /* product ID */
+ UINT16 version; /* version */
+ UINT16 ssr_max_latency; /* SSR max latency */
+ UINT16 ssr_min_tout; /* SSR min timeout */
+ UINT8 ctry_code; /*Country Code.*/
+ tBTA_HH_DEV_DESCR descriptor;
+}tBTA_HH_DEV_DSCP_INFO;
+
+/* callback event data for BTA_HH_OPEN_EVT */
+typedef struct
+{
+ BD_ADDR bda; /* HID device bd address */
+ tBTA_HH_STATUS status; /* operation status */
+ UINT8 handle; /* device handle */
+} tBTA_HH_CONN;
+
+typedef tBTA_HH_CONN tBTA_HH_DEV_INFO;
+
+/* callback event data */
+typedef struct
+{
+ tBTA_HH_STATUS status; /* operation status */
+ UINT8 handle; /* device handle */
+} tBTA_HH_CBDATA;
+
+enum
+{
+ BTA_HH_MOD_CTRL_KEY,
+ BTA_HH_MOD_SHFT_KEY,
+ BTA_HH_MOD_ALT_KEY,
+ BTA_HH_MOD_GUI_KEY,
+ BTA_HH_MOD_MAX_KEY
+};
+
+/* parsed boot mode keyboard report */
+typedef struct
+{
+ UINT8 this_char[6]; /* virtual key code */
+ BOOLEAN mod_key[BTA_HH_MOD_MAX_KEY];
+ /* ctrl, shift, Alt, GUI */
+ /* modifier key: is Shift key pressed */
+ /* modifier key: is Ctrl key pressed */
+ /* modifier key: is Alt key pressed */
+ /* modifier key: GUI up/down */
+ BOOLEAN caps_lock; /* is caps locked */
+ BOOLEAN num_lock; /* is Num key pressed */
+} tBTA_HH_KEYBD_RPT;
+
+/* parsed boot mode mouse report */
+typedef struct
+{
+ UINT8 mouse_button; /* mouse button is clicked */
+ INT8 delta_x; /* displacement x */
+ INT8 delta_y; /* displacement y */
+}tBTA_HH_MICE_RPT;
+
+/* parsed Boot report */
+typedef struct
+{
+ tBTA_HH_BOOT_RPT_ID dev_type; /* type of device report */
+ union
+ {
+ tBTA_HH_KEYBD_RPT keybd_rpt; /* keyboard report */
+ tBTA_HH_MICE_RPT mice_rpt; /* mouse report */
+ } data_rpt;
+} tBTA_HH_BOOT_RPT;
+
+/* handshake data */
+typedef struct
+{
+ tBTA_HH_STATUS status; /* handshake status */
+ UINT8 handle; /* device handle */
+ union
+ {
+ tBTA_HH_PROTO_MODE proto_mode; /* GET_PROTO_EVT :protocol mode */
+ BT_HDR *p_rpt_data; /* GET_RPT_EVT : report data */
+ UINT8 idle_rate; /* GET_IDLE_EVT : idle rate */
+ } rsp_data;
+
+}tBTA_HH_HSDATA;
+
+/* union of data associated with HD callback */
+typedef union
+{
+ tBTA_HH_DEV_INFO dev_info; /* BTA_HH_ADD_DEV_EVT, BTA_HH_RMV_DEV_EVT */
+ tBTA_HH_CONN conn; /* BTA_HH_OPEN_EVT */
+ tBTA_HH_CBDATA dev_status; /* BTA_HH_CLOSE_EVT,
+ BTA_HH_SET_PROTO_EVT
+ BTA_HH_SET_RPT_EVT
+ BTA_HH_SET_IDLE_EVT */
+
+ tBTA_HH_STATUS status; /* BTA_HH_ENABLE_EVT */
+ tBTA_HH_DEV_DSCP_INFO dscp_info; /* BTA_HH_GET_DSCP_EVT */
+ tBTA_HH_HSDATA hs_data; /* GET_ transaction callback
+ BTA_HH_GET_RPT_EVT
+ BTA_HH_GET_PROTO_EVT
+ BTA_HH_GET_IDLE_EVT */
+} tBTA_HH;
+
+/* BTA HH callback function */
+typedef void (tBTA_HH_CBACK) (tBTA_HH_EVT event, tBTA_HH *p_data);
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function BTA_HhRegister
+**
+** Description This function enable HID host and registers HID-Host with
+** lower layers.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhEnable(tBTA_SEC sec_mask, BOOLEAN ucd_enabled, tBTA_HH_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_HhDeregister
+**
+** Description This function is called when the host is about power down.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_HhOpen
+**
+** Description This function is called to start an inquiry and read SDP
+** record of responding devices; connect to a device if only
+** one active HID device is found.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhOpen (BD_ADDR dev_bda, tBTA_HH_PROTO_MODE mode,
+ tBTA_SEC sec_mask);
+
+/*******************************************************************************
+**
+** Function BTA_HhClose
+**
+** Description This function disconnects the device.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhClose(UINT8 dev_handle);
+
+/*******************************************************************************
+**
+** Function BTA_HhSetProtoMode
+**
+** Description This function set the protocol mode at specified HID handle
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhSetProtoMode(UINT8 handle, tBTA_HH_PROTO_MODE t_type);
+
+/*******************************************************************************
+**
+** Function BTA_HhGetProtoMode
+**
+** Description This function get the protocol mode of a specified HID device.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhGetProtoMode(UINT8 dev_handle);
+/*******************************************************************************
+**
+** Function BTA_HhSetReport
+**
+** Description send SET_REPORT to device.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhSetReport(UINT8 dev_handle, tBTA_HH_RPT_TYPE r_type,
+ BT_HDR *p_data);
+
+/*******************************************************************************
+**
+** Function BTA_HhGetReport
+**
+** Description Send a GET_REPORT to HID device.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhGetReport(UINT8 dev_handle, tBTA_HH_RPT_TYPE r_type,
+ UINT8 rpt_id, UINT16 buf_size);
+/*******************************************************************************
+**
+** Function BTA_HhSendCtrl
+**
+** Description Send HID_CONTROL request to a HID device.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhSendCtrl(UINT8 dev_handle,
+ tBTA_HH_TRANS_CTRL_TYPE c_type);
+
+/*******************************************************************************
+**
+** Function BTA_HhSendData
+**
+** Description Send DATA transaction to a HID device.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhSendData(UINT8 dev_handle, BD_ADDR dev_bda, BT_HDR *p_buf);
+
+/*******************************************************************************
+**
+** Function BTA_HhGetDscpInfo
+**
+** Description Get report descriptor of the device
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhGetDscpInfo(UINT8 dev_handle);
+
+/*******************************************************************************
+**
+** Function BTA_HhAddDev
+**
+** Description Add a virtually cabled device into HID-Host device list
+** to manage and assign a device handle for future API call,
+** host applciation call this API at start-up to initialize its
+** virtually cabled devices.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhAddDev(BD_ADDR bda, tBTA_HH_ATTR_MASK attr_mask,
+ UINT8 sub_class, UINT8 app_id,
+ tBTA_HH_DEV_DSCP_INFO dscp_info);
+/*******************************************************************************
+**
+** Function BTA_HhRemoveDev
+**
+** Description Remove a device from the HID host devices list.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhRemoveDev(UINT8 dev_handle );
+/*******************************************************************************
+**
+** Parsing Utility Functions
+**
+*******************************************************************************/
+/*******************************************************************************
+**
+** Function BTA_HhParseBootRpt
+**
+** Description This utility function parse a boot mode report.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_HhParseBootRpt(tBTA_HH_BOOT_RPT *p_data, UINT8 *p_report,
+ UINT16 report_len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_HH_API_H */
diff --git a/bta/include/bta_hh_co.h b/bta/include/bta_hh_co.h
new file mode 100644
index 0000000..37d27ea
--- /dev/null
+++ b/bta/include/bta_hh_co.h
@@ -0,0 +1,60 @@
+/*****************************************************************************
+**
+** Name: bta_hh_co.h
+**
+** Description: This is the interface file for hid host call-out
+** functions.
+**
+** Copyright (c) 2005, Broadcom Corp., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_HH_CO_H
+#define BTA_HH_CO_H
+
+#include "bta_hh_api.h"
+
+
+/*******************************************************************************
+**
+** Function bta_hh_co_data
+**
+** Description This callout function is executed by HH when data is received
+** in interupt channel.
+**
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_hh_co_data(UINT8 dev_handle, UINT8 *p_rpt, UINT16 len,
+ tBTA_HH_PROTO_MODE mode, UINT8 sub_class,
+ UINT8 ctry_code, BD_ADDR peer_addr, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_hh_co_open
+**
+** Description This callout function is executed by HH when connection is
+** opened, and application may do some device specific
+** initialization.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_hh_co_open(UINT8 dev_handle, UINT8 sub_class,
+ UINT16 attr_mask, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_hh_co_close
+**
+** Description This callout function is executed by HH when connection is
+** closed, and device specific finalizatio nmay be needed.
+**
+** Returns void.
+**
+*******************************************************************************/
+BTA_API extern void bta_hh_co_close(UINT8 dev_handle, UINT8 app_id);
+
+#endif /* BTA_HH_CO_H */
+
diff --git a/bta/include/bta_hl_api.h b/bta/include/bta_hl_api.h
new file mode 100644
index 0000000..a9cd312
--- /dev/null
+++ b/bta/include/bta_hl_api.h
@@ -0,0 +1,895 @@
+/*****************************************************************************
+**
+** Name: bta_hl_api.h
+**
+** Description: This is the public interface file for the HeaLth device profile
+** (HL) subsystem of BTA, Broadcom's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_HL_API_H
+#define BTA_HL_API_H
+
+#include "bta_api.h"
+#include "btm_api.h"
+#include "mca_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+/* Extra Debug Code */
+#ifndef BTA_HL_DEBUG
+#define BTA_HL_DEBUG TRUE
+#endif
+
+#ifndef BTA_HL_NUM_APPS
+#define BTA_HL_NUM_APPS 3
+#endif
+
+#ifndef BTA_HL_NUM_MDEPS
+#define BTA_HL_NUM_MDEPS 5
+#endif
+
+#ifndef BTA_HL_NUM_MCLS
+#define BTA_HL_NUM_MCLS 7
+#endif
+
+#ifndef BTA_HL_NUM_MDLS_PER_MDEP
+#define BTA_HL_NUM_MDLS_PER_MDEP 4
+#endif
+
+#ifndef BTA_HL_NUM_MDLS_PER_MCL
+#define BTA_HL_NUM_MDLS_PER_MCL 10
+#endif
+
+#ifndef BTA_HL_NUM_DATA_TYPES
+#define BTA_HL_NUM_DATA_TYPES 5 /* maximum number of data types can be supported
+ per MDEP ID */
+#endif
+
+#define BTA_HL_MCAP_RSP_TOUT 2 /* 2 seconds */
+
+#ifndef BTA_HL_CCH_NUM_FILTER_ELEMS
+#define BTA_HL_CCH_NUM_FILTER_ELEMS 3
+#endif
+
+#ifndef BTA_HL_NUM_SDP_CBACKS
+#define BTA_HL_NUM_SDP_CBACKS 7
+#endif
+
+#ifndef BTA_HL_NUM_SDP_RECS
+#define BTA_HL_NUM_SDP_RECS 3
+#endif
+
+#ifndef BTA_HL_NUM_SDP_MDEPS
+#define BTA_HL_NUM_SDP_MDEPS 10
+#endif
+
+#ifndef BTA_HL_NUM_SVC_ELEMS
+#define BTA_HL_NUM_SVC_ELEMS 2
+#endif
+
+#ifndef BTA_HL_NUM_PROTO_ELEMS
+#define BTA_HL_NUM_PROTO_ELEMS 2
+#endif
+
+#define BTA_HL_VERSION_01_00 0x0100
+#define BTA_HL_NUM_ADD_PROTO_LISTS 1
+#define BTA_HL_NUM_ADD_PROTO_ELEMS 2
+#define BTA_HL_MDEP_SEQ_SIZE 20
+#define BTA_HL_VAL_ARRY_SIZE 320
+
+#ifndef BTA_HL_NUM_MDL_CFGS
+#define BTA_HL_NUM_MDL_CFGS 16 /* numer of MDL cfg saved in the persistent memory*/
+#endif
+
+#define BTA_HL_NUM_TIMERS 7
+
+#define BTA_HL_CCH_RSP_TOUT 2000
+#define BTA_HL_LRG_POOL_ID GKI_POOL_ID_7
+#define BTA_HL_MAX_TIME 255
+#define BTA_HL_MIN_TIME 1
+#define BTA_HL_INVALID_APP_HANDLE 0xFF
+#define BTA_HL_INVALID_MCL_HANDLE 0xFF
+#define BTA_HL_INVALID_MDL_HANDLE 0xFFFF
+
+#define BTA_HL_STATUS_OK 0
+#define BTA_HL_STATUS_FAIL 1 /* Used to pass all other errors */
+#define BTA_HL_STATUS_ABORTED 2
+#define BTA_HL_STATUS_NO_RESOURCE 3
+#define BTA_HL_STATUS_LAST_ITEM 4
+#define BTA_HL_STATUS_DUPLICATE_APP_ID 5
+#define BTA_HL_STATUS_INVALID_APP_HANDLE 6
+#define BTA_HL_STATUS_INVALID_MCL_HANDLE 7
+#define BTA_HL_STATUS_MCAP_REG_FAIL 8
+#define BTA_HL_STATUS_MDEP_CO_FAIL 9
+#define BTA_HL_STATUS_ECHO_CO_FAIL 10
+#define BTA_HL_STATUS_MDL_CFG_CO_FAIL 11
+#define BTA_HL_STATUS_SDP_NO_RESOURCE 12
+#define BTA_HL_STATUS_SDP_FAIL 13
+#define BTA_HL_STATUS_NO_CCH 14
+#define BTA_HL_STATUS_NO_MCL 15
+
+#define BTA_HL_STATUS_NO_FIRST_RELIABLE 17
+#define BTA_HL_STATUS_INVALID_DCH_CFG 18
+#define BTA_HL_STATUS_INVALID_MDL_HANDLE 19
+#define BTA_HL_STATUS_INVALID_BD_ADDR 20
+#define BTA_HL_STATUS_INVALID_RECONNECT_CFG 21
+#define BTA_HL_STATUS_ECHO_TEST_BUSY 22
+#define BTA_HL_STATUS_INVALID_LOCAL_MDEP_ID 23
+#define BTA_HL_STATUS_INVALID_MDL_ID 24
+#define BTA_HL_STATUS_NO_MDL_ID_FOUND 25
+#define BTA_HL_STATUS_DCH_BUSY 26 /* DCH is congested*/
+#define BTA_HL_STATUS_INVALID_CTRL_PSM 27
+
+typedef UINT8 tBTA_HL_STATUS;
+typedef tMCA_HANDLE tBTA_HL_APP_HANDLE;
+typedef tMCA_CL tBTA_HL_MCL_HANDLE;
+typedef tMCA_DL tBTA_HL_MDL_HANDLE;
+enum
+{
+ BTA_HL_DEVICE_TYPE_SINK,
+ BTA_HL_DEVICE_TYPE_SOURCE,
+ BTA_HL_DEVICE_TYPE_DUAL
+};
+
+typedef UINT8 tBTA_HL_DEVICE_TYPE;
+
+
+
+#define BTA_HL_SDP_IEEE_11073_20601 0x01
+
+#define BTA_HL_MCAP_SUP_RECONNECT_MASK_INIT 2 /* 0x02 */
+#define BTA_HL_MCAP_SUP_RECONNECT_MASK_ACCEPT 4 /* 0x04 */
+#define BTA_HL_MCAP_SUP_CSP_MASK_SYNC_SLAVE 0 /* 0x08 */
+#define BTA_HL_MCAP_SUP_CSP_MASK_SYNC_MASTER 0 /* 0x10 */
+
+#define BTA_HL_MCAP_SUP_PROC_MASK (BTA_HL_MCAP_SUP_RECONNECT_MASK_INIT | \
+ BTA_HL_MCAP_SUP_RECONNECT_MASK_ACCEPT | \
+ BTA_HL_MCAP_SUP_CSP_MASK_SYNC_SLAVE | \
+ BTA_HL_MCAP_SUP_CSP_MASK_SYNC_MASTER)
+#define BTA_HL_MDEP_ROLE_SOURCE 0x00
+#define BTA_HL_MDEP_ROLE_SINK 0x01
+
+typedef UINT8 tBTA_HL_MDEP_ROLE;
+
+#define BTA_HL_MDEP_ROLE_MASK_SOURCE 0x01 /* bit mask */
+#define BTA_HL_MDEP_ROLE_MASK_SINK 0x02
+typedef UINT8 tBTA_HL_MDEP_ROLE_MASK;
+
+
+#define BTA_HL_ECHO_TEST_MDEP_ID 0
+#define BTA_HL_ECHO_TEST_MDEP_CFG_IDX 0
+
+#define BTA_HL_INVALID_MDEP_ID 0xFF
+typedef tMCA_DEP tBTA_HL_MDEP_ID; /* 0 is for echo test,
+ 0x01-0x7F availave for use,
+ 0x80-0xFF reserved*/
+
+
+#define BTA_HL_DELETE_ALL_MDL_IDS 0xFFFF
+#define BTA_HL_MAX_MDL_VAL 0xFEFF
+typedef UINT16 tBTA_HL_MDL_ID; /* 0x0000 reserved,
+ 0x0001-0xFEFF dynamic range,
+ 0xFF00-0xFFFE reserved,
+ 0xFFFF indicates all MDLs*/
+
+#define BTA_HL_MDEP_DESP_LEN 35
+
+#define BTA_HL_DCH_MODE_RELIABLE 0
+#define BTA_HL_DCH_MODE_STREAMING 1
+
+typedef UINT8 tBTA_HL_DCH_MODE;
+
+#define BTA_HL_DCH_CFG_NO_PREF 0
+#define BTA_HL_DCH_CFG_RELIABLE 1
+#define BTA_HL_DCH_CFG_STREAMING 2
+#define BTA_HL_DCH_CFG_UNKNOWN 0xFF
+
+typedef UINT8 tBTA_HL_DCH_CFG;
+
+/* The Default DCH CFG for the echo test when the device is a Source */
+#define BTA_HL_DEFAULT_ECHO_TEST_SRC_DCH_CFG BTA_HL_DCH_CFG_RELIABLE
+
+#define BTA_HL_DCH_CREATE_RSP_SUCCESS 0
+#define BTA_HL_DCH_CREATE_RSP_CFG_REJ 1
+
+typedef UINT8 tBTA_HL_DCH_CREATE_RSP;
+
+#define BTA_HL_MCAP_SUP_PROC_RECONNECT_INIT 0x02
+#define BTA_HL_MCAP_SUP_PROC_RECONNECT_APT 0x04
+#define BTA_HL_MCAP_SUP_PROC_CSP_SLAVE 0x08
+#define BTA_HL_MCAP_SUP_PROC_CSP_MASTER 0x10
+
+typedef UINT8 tBTA_HL_SUP_PROC_MASK;
+
+typedef struct
+{
+ UINT16 max_rx_apdu_size; /* local rcv MTU */
+ UINT16 max_tx_apdu_size; /* maximum TX APDU size*/
+} tBTA_HL_ECHO_CFG;
+
+
+typedef struct
+{
+ UINT16 data_type;
+ UINT16 max_rx_apdu_size; /* local rcv MTU */
+ UINT16 max_tx_apdu_size; /* maximum TX APDU size*/
+ char desp[BTA_HL_MDEP_DESP_LEN+1];
+} tBTA_HL_MDEP_DATA_TYPE_CFG;
+
+
+typedef struct
+{
+ tBTA_HL_MDEP_ROLE mdep_role;
+ UINT8 num_of_mdep_data_types;
+ tBTA_HL_MDEP_DATA_TYPE_CFG data_cfg[BTA_HL_NUM_DATA_TYPES];
+} tBTA_HL_MDEP_CFG;
+
+typedef struct
+{
+ tBTA_HL_MDEP_ID mdep_id; /* MDEP ID 0x01-0x7F */
+ tBTA_HL_MDEP_CFG mdep_cfg;
+} tBTA_HL_MDEP;
+
+typedef struct
+{
+ tBTA_HL_MDEP mdep[BTA_HL_NUM_MDEPS];
+ tBTA_HL_ECHO_CFG echo_cfg;
+ tBTA_HL_MDEP_ROLE_MASK app_role_mask;
+ BOOLEAN advertize_source_sdp;
+ UINT8 num_of_mdeps;
+} tBTA_HL_SUP_FEATURE;
+
+typedef struct
+{
+ BOOLEAN delete_req_pending;
+ tBTA_HL_MDL_ID mdl_id;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+} tBTA_HL_DELETE_MDL;
+
+typedef struct
+{
+ UINT8 time;
+ UINT16 mtu;
+ tBTA_HL_MDL_ID mdl_id;
+ tBTA_HL_MDEP_ID local_mdep_id;
+ tBTA_HL_MDEP_ROLE local_mdep_role;
+ BOOLEAN active; /* true if this item is in use */
+ tBTA_HL_DCH_MODE dch_mode;
+ UINT8 fcs;
+ BD_ADDR peer_bd_addr;
+} tBTA_HL_MDL_CFG;
+
+
+/* Maximum number of supported feature list items (list_elem in tSDP_SUP_FEATURE_ELEM) */
+#define BTA_HL_NUM_SUP_FEATURE_ELEMS 10
+#define BTA_HL_SUP_FEATURE_SDP_BUF_SIZE 512
+/* This structure is used to add supported feature lists and find supported feature elements */
+typedef struct
+{
+ UINT8 mdep_id;
+ UINT16 data_type;
+ tBTA_HL_MDEP_ROLE mdep_role;
+ char *p_mdep_desp;
+} tBTA_HL_SUP_FEATURE_ELEM;
+
+typedef struct
+{
+ UINT16 num_elems;
+ tBTA_HL_SUP_FEATURE_ELEM list_elem[BTA_HL_NUM_SUP_FEATURE_ELEMS];
+} tBTA_HL_SUP_FEATURE_LIST_ELEM;
+
+
+typedef struct
+{
+ tBTA_HL_DEVICE_TYPE dev_type; /* sink, source or dual roles */
+ tBTA_SEC sec_mask; /* security mask for accepting conenction*/
+ const char *p_srv_name; /* service name to be used in the SDP; null terminated*/
+ const char *p_srv_desp; /* service description to be used in the SDP; null terminated */
+ const char *p_provider_name; /* provide name to be used in the SDP; null terminated */
+} tBTA_HL_REG_PARAM;
+
+typedef struct
+{
+ UINT16 ctrl_psm;
+ BD_ADDR bd_addr; /* Address of peer device */
+ tBTA_SEC sec_mask; /* security mask for initiating connection*/
+} tBTA_HL_CCH_OPEN_PARAM;
+
+
+typedef struct
+{
+ UINT16 ctrl_psm;
+ tBTA_HL_MDEP_ID local_mdep_id; /* local MDEP ID */
+ tBTA_HL_MDEP_ID peer_mdep_id; /* peer mdep id */
+ tBTA_HL_DCH_CFG local_cfg;
+ tBTA_SEC sec_mask; /* security mask for initiating connection*/
+} tBTA_HL_DCH_OPEN_PARAM;
+
+
+typedef struct
+{
+ UINT16 ctrl_psm;
+ tBTA_HL_MDL_ID mdl_id;
+} tBTA_HL_DCH_RECONNECT_PARAM;
+
+
+typedef struct
+{
+ UINT16 ctrl_psm;
+ UINT16 pkt_size;
+ tBTA_HL_DCH_CFG local_cfg;
+} tBTA_HL_DCH_ECHO_TEST_PARAM;
+
+typedef struct
+{
+ UINT16 buf_size;
+ UINT8 p_buf; /* buffer pointer */
+} tBTA_HL_DCH_BUF_INFO;
+
+typedef struct
+{
+ tBTA_HL_MDEP_ID local_mdep_id; /* local MDEP ID */
+ tBTA_HL_MDL_ID mdl_id;
+ tBTA_HL_DCH_CREATE_RSP rsp_code;
+ tBTA_HL_DCH_CFG cfg_rsp;
+} tBTA_HL_DCH_CREATE_RSP_PARAM;
+
+typedef struct
+{
+ UINT16 data_type;
+ UINT8 mdep_id;
+ tBTA_HL_MDEP_ROLE mdep_role;
+ char mdep_desp[BTA_HL_MDEP_DESP_LEN+1];
+}tBTA_HL_SDP_MDEP_CFG;
+
+typedef struct
+{
+ UINT16 ctrl_psm;
+ UINT16 data_psm;
+ UINT8 mcap_sup_proc;
+ UINT8 num_mdeps; /* number of mdep elements from SDP*/
+ char srv_name[BTA_SERVICE_NAME_LEN+1];
+ char srv_desp[BTA_SERVICE_DESP_LEN+1];
+ char provider_name[BTA_PROVIDER_NAME_LEN+1];
+ tBTA_HL_SDP_MDEP_CFG mdep_cfg[BTA_HL_NUM_SDP_MDEPS];
+} tBTA_HL_SDP_REC;
+
+typedef struct
+{
+ UINT8 num_recs;
+ tBTA_HL_SDP_REC sdp_rec[BTA_HL_NUM_SDP_RECS];
+} tBTA_HL_SDP;
+
+/* HL control callback function events */
+enum
+{
+ BTA_HL_CTRL_ENABLE_CFM_EVT = 0,
+ BTA_HL_CTRL_DISABLE_CFM_EVT
+};
+typedef UINT8 tBTA_HL_CTRL_EVT;
+/* Structure associated with BTA_HL_ENABLE_EVT
+ BTA_HL_DISABLE_EVT */
+
+typedef struct
+{
+ tBTA_HL_STATUS status;
+} tBTA_HL_CTRL_ENABLE_DISABLE;
+
+typedef union
+{
+ tBTA_HL_CTRL_ENABLE_DISABLE enable_cfm;
+ tBTA_HL_CTRL_ENABLE_DISABLE disable_cfm;
+} tBTA_HL_CTRL;
+
+/* HL instance callback function events */
+enum
+{
+ BTA_HL_REGISTER_CFM_EVT =0,
+ BTA_HL_DEREGISTER_CFM_EVT,
+ BTA_HL_CCH_OPEN_IND_EVT,
+ BTA_HL_CCH_OPEN_CFM_EVT,
+ BTA_HL_CCH_CLOSE_IND_EVT,
+ BTA_HL_CCH_CLOSE_CFM_EVT,
+ BTA_HL_DCH_CREATE_IND_EVT,
+ BTA_HL_DCH_OPEN_IND_EVT,
+ BTA_HL_DCH_OPEN_CFM_EVT,
+ BTA_HL_DCH_CLOSE_IND_EVT,
+ BTA_HL_DCH_CLOSE_CFM_EVT,
+ BTA_HL_DCH_RECONNECT_IND_EVT,
+ BTA_HL_DCH_RECONNECT_CFM_EVT,
+
+ BTA_HL_DCH_ABORT_IND_EVT,
+ BTA_HL_DCH_ABORT_CFM_EVT,
+ BTA_HL_DELETE_MDL_IND_EVT,
+ BTA_HL_DELETE_MDL_CFM_EVT,
+ BTA_HL_DCH_SEND_DATA_CFM_EVT,
+ BTA_HL_DCH_RCV_DATA_IND_EVT,
+ BTA_HL_CONG_CHG_IND_EVT,
+ BTA_HL_DCH_ECHO_TEST_CFM_EVT,
+ BTA_HL_SDP_QUERY_CFM_EVT,
+ BTA_HL_SDP_INFO_IND_EVT
+};
+typedef UINT8 tBTA_HL_EVT;
+
+
+typedef struct
+{
+ tBTA_HL_STATUS status; /* start status */
+ UINT8 app_id;
+ tBTA_HL_APP_HANDLE app_handle;
+} tBTA_HL_REGISTER_CFM;
+
+
+typedef struct
+{
+ tBTA_HL_STATUS status; /* start status */
+ tBTA_HL_APP_HANDLE app_handle;
+} tBTA_HL_DEREGISTER_CFM;
+
+
+typedef struct
+{
+ BOOLEAN intentional;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+} tBTA_HL_CCH_CLOSE_IND;
+
+
+typedef struct
+{
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+} tBTA_HL_MCL_IND;
+
+typedef struct
+{
+ tBTA_HL_STATUS status; /* connection status */
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+} tBTA_HL_MCL_CFM;
+
+typedef struct
+{
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+ BD_ADDR bd_addr; /* address of peer device */
+} tBTA_HL_CCH_OPEN_IND;
+
+typedef struct
+{
+ tBTA_HL_STATUS status; /* connection status */
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+ BD_ADDR bd_addr; /* address of peer device */
+} tBTA_HL_CCH_OPEN_CFM;
+
+typedef struct
+{
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+ tBTA_HL_MDEP_ID local_mdep_id;
+ tBTA_HL_MDL_ID mdl_id; /* MCAP data link ID for this
+ data channel conenction */
+ tBTA_HL_DCH_CFG cfg; /* dch cfg requested by the peer device */
+} tBTA_HL_DCH_CREATE_IND;
+
+typedef struct
+{
+ tBTA_HL_MDL_HANDLE mdl_handle;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+ tBTA_HL_MDEP_ID local_mdep_id;
+ tBTA_HL_MDL_ID mdl_id; /* MCAP data link ID for this
+ data channel conenction */
+ tBTA_HL_DCH_MODE dch_mode; /* data channel mode - reliable or streaming*/
+
+ BOOLEAN first_reliable; /* whether this is the first reliable data channel */
+ UINT16 mtu;
+} tBTA_HL_DCH_OPEN_IND;
+
+typedef struct
+{
+ tBTA_HL_STATUS status; /* connection status */
+ tBTA_HL_MDL_HANDLE mdl_handle;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+ tBTA_HL_MDEP_ID local_mdep_id;
+ tBTA_HL_MDL_ID mdl_id; /* MCAP data link ID for this
+ data channel conenction */
+ tBTA_HL_DCH_MODE dch_mode; /* data channel mode - reliable or streaming*/
+ BOOLEAN first_reliable; /* whether this is the first reliable data channel */
+ UINT16 mtu;
+} tBTA_HL_DCH_OPEN_CFM;
+
+
+typedef struct
+{
+ BOOLEAN intentional;
+ tBTA_HL_MDL_HANDLE mdl_handle;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+} tBTA_HL_DCH_CLOSE_IND;
+
+
+typedef struct
+{
+ tBTA_HL_MDL_HANDLE mdl_handle;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+} tBTA_HL_MDL_IND;
+
+typedef struct
+{
+ tBTA_HL_STATUS status;
+ tBTA_HL_MDL_HANDLE mdl_handle;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+} tBTA_HL_MDL_CFM;
+
+typedef struct
+{
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+ tBTA_HL_MDL_ID mdl_id;
+} tBTA_HL_DELETE_MDL_IND;
+
+typedef struct
+{
+ tBTA_HL_STATUS status;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+ tBTA_HL_MDL_ID mdl_id;
+} tBTA_HL_DELETE_MDL_CFM;
+
+typedef struct
+{
+ tBTA_HL_MDL_HANDLE mdl_handle;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ tBTA_HL_APP_HANDLE app_handle;
+ BOOLEAN cong;
+} tBTA_HL_DCH_CONG_IND;
+
+typedef struct
+{
+ tBTA_HL_APP_HANDLE app_handle;
+ UINT16 ctrl_psm;
+ UINT16 data_psm;
+ UINT8 data_x_spec;
+ UINT8 mcap_sup_procs;
+} tBTA_HL_SDP_INFO_IND;
+
+typedef struct
+{
+ tBTA_HL_STATUS status;
+ tBTA_HL_APP_HANDLE app_handle;
+ BD_ADDR bd_addr;
+ tBTA_HL_SDP *p_sdp;
+} tBTA_HL_SDP_QUERY_CFM;
+
+typedef union
+{
+ tBTA_HL_REGISTER_CFM reg_cfm;
+ tBTA_HL_DEREGISTER_CFM dereg_cfm;
+ tBTA_HL_CCH_OPEN_IND cch_open_ind;
+ tBTA_HL_CCH_OPEN_CFM cch_open_cfm;
+ tBTA_HL_CCH_CLOSE_IND cch_close_ind;
+ tBTA_HL_MCL_CFM cch_close_cfm;
+ tBTA_HL_DCH_CREATE_IND dch_create_ind;
+ tBTA_HL_DCH_OPEN_IND dch_open_ind;
+ tBTA_HL_DCH_OPEN_CFM dch_open_cfm;
+ tBTA_HL_DCH_CLOSE_IND dch_close_ind;
+ tBTA_HL_MDL_CFM dch_close_cfm;
+ tBTA_HL_DCH_OPEN_IND dch_reconnect_ind;
+ tBTA_HL_DCH_OPEN_CFM dch_reconnect_cfm;
+ tBTA_HL_MCL_IND dch_abort_ind;
+ tBTA_HL_MCL_CFM dch_abort_cfm;
+ tBTA_HL_DELETE_MDL_IND delete_mdl_ind;
+ tBTA_HL_DELETE_MDL_CFM delete_mdl_cfm;
+ tBTA_HL_MDL_CFM dch_send_data_cfm;
+ tBTA_HL_MDL_IND dch_rcv_data_ind;
+ tBTA_HL_DCH_CONG_IND dch_cong_ind;
+ tBTA_HL_MCL_CFM echo_test_cfm;
+ tBTA_HL_SDP_QUERY_CFM sdp_query_cfm;
+ tBTA_HL_SDP_INFO_IND sdp_info_ind;
+
+} tBTA_HL;
+
+/* HL callback functions */
+typedef void tBTA_HL_CTRL_CBACK(tBTA_HL_CTRL_EVT event, tBTA_HL_CTRL *p_data);
+typedef void tBTA_HL_CBACK(tBTA_HL_EVT event, tBTA_HL *p_data);
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**************************
+** API Functions
+***************************/
+
+/*******************************************************************************
+**
+** Function BTA_HlEnable
+**
+** Description Enable the HL subsystems. This function must be
+** called before any other functions in the HL API are called.
+** When the enable operation is completed the callback function
+** will be called with an BTA_HL_CTRL_ENABLE_CFM_EVT event.
+**
+** Parameters p_cback - HL event call back function
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlEnable(tBTA_HL_CTRL_CBACK *p_ctrl_cback);
+/*******************************************************************************
+**
+** Function BTA_HlDisable
+**
+** Description Disable the HL subsystem.
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlDisable(void);
+/*******************************************************************************
+**
+** Function BTA_HlRegister
+**
+** Description Register a HDP application
+**
+**
+** Parameters app_id - hdp application ID
+** p_reg_param - non-platform related parameters for the
+** HDP application
+** p_cback - HL event callback fucntion
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlRegister(UINT8 app_id,
+ tBTA_HL_REG_PARAM *p_reg_param,
+ tBTA_HL_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_HlDeregister
+**
+** Description Deregister an HDP application
+**
+** Parameters app_handle - Application handle
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlDeregister(tBTA_HL_APP_HANDLE app_handle);
+
+/*******************************************************************************
+**
+** Function BTA_HlCchOpen
+**
+** Description Open a Control channel connection with the specified BD address
+** and the control PSM value is used to select which
+** HDP insatnce should be used in case the peer device support
+** multiple HDP instances.
+**
+**
+** Parameters app_handle - Application Handle
+** p_open_param - parameters for opening a control channel
+**
+** Returns void
+**
+** Note: If the control PSM value is zero then the first HDP
+** instance is used for the control channel setup
+*******************************************************************************/
+ BTA_API extern void BTA_HlCchOpen(tBTA_HL_APP_HANDLE app_handle,
+ tBTA_HL_CCH_OPEN_PARAM *p_open_param);
+
+/*******************************************************************************
+**
+** Function BTA_HlCchClose
+**
+** Description Close a Control channel connection with the specified MCL
+** handle
+**
+** Parameters mcl_handle - MCL handle
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlCchClose(tBTA_HL_MCL_HANDLE mcl_handle);
+
+/*******************************************************************************
+**
+** Function BTA_HlDchOpen
+**
+** Description Open a data channel connection with the specified DCH parameters
+**
+** Parameters mcl_handle - MCL handle
+** p_open_param - parameters for opening a data channel
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlDchOpen(tBTA_HL_MCL_HANDLE mcl_handle,
+ tBTA_HL_DCH_OPEN_PARAM *p_open_param);
+/*******************************************************************************
+**
+** Function BTA_HlDchReconnect
+**
+** Description Reconnect a data channel with the specified MDL_ID
+**
+** Parameters mcl_handle - MCL handle
+*8 p_recon_param - parameters for reconnecting a data channel
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlDchReconnect(tBTA_HL_MCL_HANDLE mcl_handle,
+ tBTA_HL_DCH_RECONNECT_PARAM *p_recon_param);
+/*******************************************************************************
+**
+** Function BTA_HlDchClose
+**
+** Description Close a data channel with the specified MDL handle
+**
+** Parameters mdl_handle - MDL handle
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlDchClose(tBTA_HL_MDL_HANDLE mdl_handle);
+
+/*******************************************************************************
+**
+** Function BTA_HlDchAbort
+**
+** Description Abort the current data channel setup with the specified MCL
+** handle
+**
+** Parameters mcl_handle - MCL handle
+**
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlDchAbort(tBTA_HL_MCL_HANDLE mcl_handle);
+
+/*******************************************************************************
+**
+** Function BTA_HlSendData
+**
+** Description Send an APDU to the peer device
+**
+** Parameters mdl_handle - MDL handle
+** pkt_size - size of the data packet to be sent
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlSendData(tBTA_HL_MDL_HANDLE mdl_handle,
+ UINT16 pkt_size);
+
+/*******************************************************************************
+**
+** Function BTA_HlDeleteMdl
+**
+** Description Delete the specified MDL_ID within the specified MCL handle
+**
+** Parameters mcl_handle - MCL handle
+** mdl_id - MDL ID
+**
+** Returns void
+**
+** note: If mdl_id = 0xFFFF then this means to delete all MDLs
+** and this value can only be used with DeleteMdl request only
+** not other requests
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlDeleteMdl(tBTA_HL_MCL_HANDLE mcl_handle,
+ tBTA_HL_MDL_ID mdl_id );
+
+/*******************************************************************************
+**
+** Function BTA_HlDchEchoTest
+**
+** Description Initiate an echo test with the specified MCL handle
+**
+** Parameters mcl_handle - MCL handle
+*8 p_echo_test_param - parameters for echo testing
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlDchEchoTest( tBTA_HL_MCL_HANDLE mcl_handle,
+ tBTA_HL_DCH_ECHO_TEST_PARAM *p_echo_test_param);
+
+/*******************************************************************************
+**
+** Function BTA_HlSdpQuery
+**
+** Description SDP query request for the specified BD address
+**
+** Parameters app_handle - application handle
+** bd_addr - BD address
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlSdpQuery(tBTA_HL_APP_HANDLE app_handle,
+ BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTA_HlDchCreateMdlRsp
+**
+** Description Set the Response and configuration values for the Create MDL
+** request
+**
+** Parameters mcl_handle - MCL handle
+** p_rsp_param - parameters specified whether the request should
+** be accepted or not and if it should be accepted
+** then it also specified the configuration response
+** value
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_HlDchCreateRsp(tBTA_HL_MCL_HANDLE mcl_handle,
+ tBTA_HL_DCH_CREATE_RSP_PARAM *p_rsp_param);
+
+
+
+#ifdef __cplusplus
+
+}
+#endif
+
+#endif /* BTA_HL_API_H */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bta/include/bta_hl_ci.h b/bta/include/bta_hl_ci.h
new file mode 100644
index 0000000..6cb1451
--- /dev/null
+++ b/bta/include/bta_hl_ci.h
@@ -0,0 +1,112 @@
+/*****************************************************************************
+**
+** Name: bta_hl_ci.h
+**
+** Description: This is the interface file for the HL (HeaLth device profile)
+** subsystem call-in functions.
+**
+** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_HL_CI_H
+#define BTA_HL_CI_H
+
+#include "bta_api.h"
+#include "bta_hl_api.h"
+
+
+/*****************************************************************************
+** Constants and Data Types
+*****************************************************************************/
+/**************************
+** Common Definitions
+***************************/
+/* Read Ready Event */
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+/**************************
+** Common Functions
+***************************/
+/*******************************************************************************
+**
+** Function bta_hl_ci_get_tx_data
+**
+** Description This function is called in response to the
+** bta_hl_co_get_tx_data call-out function.
+**
+** Parameters mdl_handle -MDL handle
+** status - BTA_MA_STATUS_OK if operation is successful
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** evt - evt from the call-out function
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_ci_get_tx_data( tBTA_HL_MDL_HANDLE mdl_handle,
+ tBTA_HL_STATUS status,
+ UINT16 evt );
+
+/*******************************************************************************
+**
+** Function bta_hl_ci_put_rx_data
+**
+** Description This function is called in response to the
+** bta_hl_co_put_rx_data call-out function.
+**
+** Parameters mdl_handle -MDL handle
+** status - BTA_MA_STATUS_OK if operation is successful
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** evt - evt from the call-out function
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_ci_put_rx_data( tBTA_HL_MDL_HANDLE mdl_handle,
+ tBTA_HL_STATUS status,
+ UINT16 evt );
+
+
+
+/*******************************************************************************
+**
+** Function bta_hl_ci_get_echo_data
+**
+** Description This function is called in response to the
+** bta_hl_co_get_echo_data call-out function.
+**
+** Parameters mcl_handle -MCL handle
+** status - BTA_MA_STATUS_OK if operation is successful
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** evt - evt from the call-out function
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_ci_get_echo_data( tBTA_HL_MCL_HANDLE mcl_handle,
+ tBTA_HL_STATUS status,
+ UINT16 evt );
+
+
+/*******************************************************************************
+**
+** Function bta_hl_ci_put_echo_data
+**
+** Description This function is called in response to the
+** bta_hl_co_put_echo_data call-out function.
+**
+** Parameters mcl_handle -MCL handle
+** status - BTA_MA_STATUS_OK if operation is successful
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** evt - evt from the call-out function
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_ci_put_echo_data( tBTA_HL_MCL_HANDLE mcl_handle,
+ tBTA_HL_STATUS status,
+ UINT16 evt );
+#endif /* BTA_HL_CI_H */
+
+
diff --git a/bta/include/bta_hl_co.h b/bta/include/bta_hl_co.h
new file mode 100644
index 0000000..464e99a
--- /dev/null
+++ b/bta/include/bta_hl_co.h
@@ -0,0 +1,219 @@
+/*****************************************************************************
+**
+** Name: bta_hl_co.h
+**
+** Description: This is the interface file for the HL (HeaLth device profile)
+** subsystem call-out functions.
+**
+** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_HL_CO_H
+#define BTA_HL_CO_H
+
+#include "bta_api.h"
+#include "bta_hl_api.h"
+
+/*****************************************************************************
+** Constants and Data Types
+*****************************************************************************/
+/**************************
+** Common Definitions
+***************************/
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_get_num_of_mdep
+**
+** Description This function is called to get the number of MDEPs for this
+** application ID
+**
+** Parameters app_id - application ID
+** p_num_of_mdep (output) - number of MDEP configurations supported
+** by the application
+**
+** Returns Bloolean - TRUE success
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN bta_hl_co_get_num_of_mdep(UINT8 app_id, UINT8 *p_num_of_mdep);
+/*******************************************************************************
+**
+** Function bta_hl_co_advrtise_source_sdp
+**
+** Description This function is called to find out whether the SOURCE MDEP
+** configuration information should be advertize in the SDP or nopt
+**
+** Parameters app_id - application ID
+**
+** Returns Bloolean - TRUE advertise the SOURCE MDEP configuration
+** information
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN bta_hl_co_advrtise_source_sdp(UINT8 app_id);
+/*******************************************************************************
+**
+** Function bta_hl_co_get_mdep_config
+**
+** Description This function is called to get the supported feature
+** configuration for the specified mdep index and it also assigns
+** the MDEP ID for the specified mdep index
+**
+** Parameters app_id - HDP application ID
+** mdep_idx - the mdep index
+** mdep_id - the assigned MDEP ID for the specified medp_idx
+** p_mdl_cfg (output) - pointer to the MDEP configuration
+**
+**
+** Returns Bloolean - TRUE success
+*******************************************************************************/
+BTA_API extern BOOLEAN bta_hl_co_get_mdep_config(UINT8 app_id,
+ UINT8 mdep_idx,
+ tBTA_HL_MDEP_ID mdep_id,
+ tBTA_HL_MDEP_CFG *p_mdep_cfg);
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_get_echo_config
+**
+** Description This function is called to get the echo test
+** maximum APDU size configuration
+**
+** Parameters app_id - HDP application ID
+** p_echo_cfg (output) - pointer to the Echo test maximum APDU size
+** configuration
+**
+** Returns Bloolean - TRUE success
+*******************************************************************************/
+BTA_API extern BOOLEAN bta_hl_co_get_echo_config(UINT8 app_id,
+ tBTA_HL_ECHO_CFG *p_echo_cfg);
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_save_mdl
+**
+** Description This function is called to save a MDL configuration item in persistent
+** storage
+**
+** Parameters app_id - HDP application ID
+** item_idx - the MDL configuration storage index
+** p_mdl_cfg - pointer to the MDL configuration data
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_co_save_mdl(UINT8 app_id, UINT8 item_idx, tBTA_HL_MDL_CFG *p_mdl_cfg );
+/*******************************************************************************
+**
+** Function bta_hl_co_delete_mdl
+**
+** Description This function is called to delete a MDL configuration item in persistent
+** storage
+**
+** Parameters app_id - HDP application ID
+** item_idx - the MDL configuration storage index
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_co_delete_mdl(UINT8 app_id, UINT8 item_idx);
+/*******************************************************************************
+**
+** Function bta_hl_co_get_mdl_config
+**
+** Description This function is called to get the MDL configuration
+** from teh persistent memory. This function shall only be called
+*8 once after the device is powered up
+**
+** Parameters app_id - HDP application ID
+** buffer_size - the unit of the buffer size is sizeof(tBTA_HL_MDL_CFG)
+** p_mdl_buf - Point to the starting location of the buffer
+**
+** Returns BOOLEAN
+**
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN bta_hl_co_load_mdl_config (UINT8 app_id, UINT8 buffer_size,
+ tBTA_HL_MDL_CFG *p_mdl_buf );
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_get_tx_data
+**
+** Description Get the data to be sent
+**
+** Parameters app_id - HDP application ID
+** mdl_handle - MDL handle
+** buf_size - the size of the buffer
+** p_buf - the buffer pointer
+** evt - the evt to be passed back to the HL in the
+** bta_hl_ci_get_tx_data call-in function
+**
+** Returns Void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_co_get_tx_data (UINT8 app_id, tBTA_HL_MDL_HANDLE mdl_handle,
+ UINT16 buf_size, UINT8 *p_buf, UINT16 evt);
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_put_rx_data
+**
+** Description Put the received data
+**
+** Parameters app_id - HDP application ID
+** mdl_handle - MDL handle
+** data_size - the size of the data
+** p_data - the data pointer
+** evt - the evt to be passed back to the HL in the
+** bta_hl_ci_put_rx_data call-in function
+**
+** Returns Void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_co_put_rx_data (UINT8 app_id, tBTA_HL_MDL_HANDLE mdl_handle,
+ UINT16 data_size, UINT8 *p_data, UINT16 evt);
+/*******************************************************************************
+**
+** Function bta_hl_co_get_tx_data
+**
+** Description Get the Echo data to be sent
+**
+** Parameters app_id - HDP application ID
+** mcl_handle - MCL handle
+** buf_size - the size of the buffer
+** p_buf - the buffer pointer
+** evt - the evt to be passed back to the HL in the
+** bta_hl_ci_get_tx_data call-in function
+**
+** Returns Void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_co_get_echo_data (UINT8 app_id, tBTA_HL_MCL_HANDLE mcl_handle,
+ UINT16 buf_size, UINT8 *p_buf, UINT16 evt);
+
+/*******************************************************************************
+**
+** Function bta_hl_co_put_echo_data
+**
+** Description Put the received loopback echo data
+**
+** Parameters app_id - HDP application ID
+** mcl_handle - MCL handle
+** data_size - the size of the data
+** p_data - the data pointer
+** evt - the evt to be passed back to the HL in the
+** bta_hl_ci_put_echo_data call-in function
+**
+** Returns Void
+**
+*******************************************************************************/
+BTA_API extern void bta_hl_co_put_echo_data (UINT8 app_id, tBTA_HL_MCL_HANDLE mcl_handle,
+ UINT16 data_size, UINT8 *p_data, UINT16 evt);
+
+#endif /* BTA_HL_CO_H */
diff --git a/bta/include/bta_ma_api.h b/bta/include/bta_ma_api.h
new file mode 100644
index 0000000..e0b413e
--- /dev/null
+++ b/bta/include/bta_ma_api.h
@@ -0,0 +1,691 @@
+/*****************************************************************************
+**
+** Name: bta_ma_api.h
+**
+** Description: This file contains the common API functions used
+** for the Message Access Profiles (MAP).
+**
+** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_MA_API_H
+#define BTA_MA_API_H
+
+#include "bta_mse_api.h" /* For tBTA_MA_MSG_TYPE */
+#include <stdio.h>
+
+typedef struct
+{
+ UINT16 size; /* Size of the buffer */
+ UINT8 * p_buffer; /* Pointer to buffer */
+ UINT8 * p_next; /* Pointer to next byte to use in buffer */
+
+}tBTA_MA_MEM_STREAM;
+
+typedef struct
+{
+ int fd;
+
+}tBTA_MA_FILE_STREAM;
+
+/* Structure used for streaming data */
+typedef struct
+{
+#define STRM_TYPE_MEMORY 0
+#define STRM_TYPE_FILE 1
+
+ UINT8 type;
+
+#define STRM_SUCCESS 0
+#define STRM_ERROR_OVERFLOW 1
+#define STRM_ERROR_FILE 2
+
+ UINT8 status;
+
+ union
+ {
+ tBTA_MA_MEM_STREAM mem;
+ tBTA_MA_FILE_STREAM file;
+ } u;
+
+} tBTA_MA_STREAM;
+
+/*******************************************************************************
+**
+** bMessage functions
+**
+** Description The following API functions are generic in a sense that
+** they do not imply how the data is stored (to memory or
+** to file, etc.).
+**
+** They operate on a generic set of structure types. Though
+** the internal structure of those types are implementation
+** specific.
+**
+*******************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function BTA_MaBmsgCreate
+**
+** Description Create and initialize an instance of a tBTA_MA_BMSG structure.
+**
+** Parameters None
+**
+** Returns Pointer to a bMessage object, or NULL if this fails.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG * BTA_MaBmsgCreate(void);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgFree
+**
+** Description Destroy (free) the contents of a tBTA_MA_BMSG structure.
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgFree(tBTA_MA_BMSG * p_msg);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgSetReadSts
+**
+** Description Set the bmessage-readstatus-property value for the bMessage
+** object. If the 'read_sts' is TRUE then value will be "READ",
+** otherwise it is "UNREAD".
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+** read_sts - Read status TRUE- read FALSE - unread
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgSetReadSts(tBTA_MA_BMSG * p_msg, BOOLEAN read_sts);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetReadSts
+**
+** Description Get the bmessage-readstatus-property value for the bMessage
+** object
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+**
+** Returns Read status (TRUE/FALSE) for the specified bMessage.
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN BTA_MaBmsgGetReadSts(tBTA_MA_BMSG * p_msg);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgSetMsgType
+**
+** Description Set the bmessage-type-property value for the bMessage object
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+** msg_type - Message type
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgSetMsgType(tBTA_MA_BMSG * p_msg, tBTA_MA_MSG_TYPE msg_type);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetMsgType
+**
+** Description Get the bmessage-type-property value for the specified
+** bMessage object
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+**
+** Returns Message type
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_MSG_TYPE BTA_MaBmsgGetMsgType(tBTA_MA_BMSG * p_msg);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgSetFolder
+**
+** Description Set the bmessage-folder-property value for the bMessage object
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+** p_folder - Pointer to a folder path
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgSetFolder(tBTA_MA_BMSG * p_msg, char * p_folder);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetFolder
+**
+** Description Get the bmessage-folder-property value for the specified
+** bMessage object
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+**
+** Returns Pointer to folder path string, or NULL if it has not been set.
+**
+*******************************************************************************/
+BTA_API extern char * BTA_MaBmsgGetFolder(tBTA_MA_BMSG * p_msg);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgAddOrigToBmsg
+**
+** Description Add an originator to the bMessage object
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+**
+** Returns Pointer to a new vCard structure, or NULL if this function
+** fails.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgAddOrigToBmsg(tBTA_MA_BMSG * p_msg);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetOrigFromBmsg
+**
+** Description Get the first originator vCard information from the specified
+** bMessage object
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+**
+** Returns Pointer to first 'originator vCard, or NULL not used.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgGetOrigFromBmsg(tBTA_MA_BMSG * p_msg);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgAddEnvToBmsg
+**
+** Description Add a new envelope to the bMessage object. This is the first
+** (top) level envelope. bMessage allows up to 3 levels of envelopes.
+** application should call BTA_MaBmsgAddEnvToEnv to add the 2nd
+** 3rd level enevelope.
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+**
+** Returns Pointer to a new envelope structure, or NULL if this
+** function fails.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgAddEnvToBmsg(tBTA_MA_BMSG * p_msg);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgAddEnvToEnv
+**
+** Description Add a child envelope to an existing envelope.
+**
+** Parameters p_envelope - Pointer to a parent envelope
+**
+** Returns Pointer to an envelope structure, or NULL if this
+** function fails.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgAddEnvToEnv(tBTA_MA_BMSG_ENVELOPE * p_envelope);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetEnv
+**
+** Description Get the pointer of the first level envelope.
+**
+** Parameters p_bmsg - Pointer to a bMessage object
+**
+** Returns Pointer to the first level envelope structure, or NULL if it
+** does not exist
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgGetEnv(tBTA_MA_BMSG * p_msg);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetNextEnv
+**
+** Description Get the child envelope of the specified parent envelope.
+**
+** Parameters p_env - Pointer to a parent envelope
+**
+** Returns Pointer to a child enevelope. NULL if the
+** envelope does not have a 'child' envelope.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_ENVELOPE * BTA_MaBmsgGetNextEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgAddRecipToEnv
+**
+** Description Add recipient to the specified envelope.
+**
+** Parameters p_env - Pointer to a envelope
+**
+** Returns Pointer to a vCard structure. NULL if it
+** fails to allocate a vCard structure.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgAddRecipToEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetRecipFromEnv
+**
+** Description Get the first recipient's vCard from the specified envelope.
+**
+** Parameters p_env - Pointer to a envelope
+**
+** Returns Pointer to the first recipient's vCard structure. NULL if it
+** has not be set.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgGetRecipFromEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgAddBodyToEnv
+**
+** Description Add a message body to the specified envelope.
+**
+** Parameters p_env - Pointer to a envelope
+**
+** Returns Pointer to a message body structure.
+** NULL if it fails to allocate a message body structure.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_BODY * BTA_MaBmsgAddBodyToEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetBodyFromEnv
+**
+** Description Get the message body pointer from the specified envelope.
+**
+** Parameters p_env - Pointer to a envelope
+**
+** Returns Pointer to a message body structure.
+** NULL if it has not been set.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_BODY * BTA_MaBmsgGetBodyFromEnv(tBTA_MA_BMSG_ENVELOPE * p_env);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgSetBodyEncoding
+**
+** Description Set the bmessage-body-encoding-property value for the bMessage
+** body.
+**
+** Parameters p_body - Pointer to a bMessage body
+** encoding - encoding scheme
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgSetBodyEncoding(tBTA_MA_BMSG_BODY * p_body, tBTA_MA_BMSG_ENCODING encoding);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetBodyEncoding
+**
+** Description Get the bmessage-body-encoding-property value for the specified
+** bMessage body.
+**
+** Parameters p_body - Pointer to a bMessage body
+**
+** Returns Message encoding scheme
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_ENCODING BTA_MaBmsgGetBodyEncoding(tBTA_MA_BMSG_BODY * p_body);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgSetBodyPartid
+**
+** Description Set the bmessage-body-part-ID value for the speicified
+** bMessage body.
+**
+** Parameters p_body - Pointer to a bMessage body
+** part_id - Part ID (range: from 0 to 65535)
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgSetBodyPartid(tBTA_MA_BMSG_BODY * p_body, UINT16 part_id);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetBodyPartid
+**
+** Description Get the bmessage-body-part-ID value for the specified
+** bMessage body.
+**
+** Parameters p_body - Pointer to a bMessage body
+**
+** Returns The value of the Part ID
+**
+*******************************************************************************/
+BTA_API extern UINT16 BTA_MaBmsgGetBodyPartid(tBTA_MA_BMSG_BODY * p_body);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgIsBodyMultiPart
+**
+** Description Is this a multi-part body
+**
+** Parameters p_body - Pointer to a bMessage body
+**
+** Returns TURE - if this is a multi-part body
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN BTA_MaBmsgIsBodyMultiPart(tBTA_MA_BMSG_BODY * p_body);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetBodyCharset
+**
+** Description Get the bmessage-body-charset-property value for the speicified
+** bMessage body.
+**
+** Parameters p_body - Pointer to a bMessage body
+**
+** Returns Charset
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgSetBodyCharset(tBTA_MA_BMSG_BODY * p_body, tBTA_MA_CHARSET charset);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetBodyCharset
+**
+** Description Get the bmessage-body-charset-property value for the speicified
+** bMessage body.
+**
+** Parameters p_body - Pointer to a bMessage body
+**
+** Returns Charset
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_CHARSET BTA_MaBmsgGetBodyCharset(tBTA_MA_BMSG_BODY * p_body);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgSetBodyLanguage
+**
+** Description Set the bmessage-body-language-property value for the speicified
+** bMessage body.
+**
+** Parameters p_body - Pointer to a bMessage body
+** Language - the language of the message
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgSetBodyLanguage(tBTA_MA_BMSG_BODY * p_body, tBTA_MA_BMSG_LANGUAGE language);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetBodyLanguage
+**
+** Description Get the bmessage-body-language-property value for the speicified
+** bMessage body.
+**
+** Parameters p_body - Pointer to a bMessage body
+**
+** Returns the language of the message
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_LANGUAGE BTA_MaBmsgGetBodyLanguage(tBTA_MA_BMSG_BODY * p_body);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgAddContentToBody
+**
+** Description Add a message content to the speicified bMessage body.
+**
+** Parameters p_body - Pointer to a bMessage body
+**
+** Returns Pointer to a message content.
+** NULL if it fails to allocate a message content buffer
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_CONTENT * BTA_MaBmsgAddContentToBody(tBTA_MA_BMSG_BODY * p_body);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetContentFromBody
+**
+** Description Get a message content from the speicified bMessage body.
+**
+** Parameters p_body - Pointer to a bMessage body
+**
+** Returns Pointer to a message content.
+** NULL if it has not been set.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_CONTENT * BTA_MaBmsgGetContentFromBody(tBTA_MA_BMSG_BODY * p_body);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetNextContent
+**
+** Description Get the next message content from the speicified message content.
+**
+** Parameters p_content - Pointer to a message content
+**
+** Returns Pointer to a message content.
+** NULL if it has not been set.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_CONTENT * BTA_MaBmsgGetNextContent(tBTA_MA_BMSG_CONTENT * p_content);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgAddMsgContent
+**
+** Description Add a text string to the speicified message content.
+**
+** Parameters p_content - Pointer to a message content
+** p_text - Pointer to a text string
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgAddMsgContent(tBTA_MA_BMSG_CONTENT * p_content, char * p_text);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetMsgContent
+**
+** Description Get the next text string from the speicified message content.
+**
+** Parameters p_content - Pointer to a message content
+**
+** Returns Pointer to the next text string.
+** NULL if it has not been set.
+**
+*******************************************************************************/
+BTA_API extern char * BTA_MaBmsgGetMsgContent(tBTA_MA_BMSG_CONTENT * p_content);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetNextVcard
+**
+** Description Get the next vCard from the speicified vCard.
+**
+** Parameters p_vcard - Pointer to a vCard
+**
+** Returns Pointer to the next vCard.
+** NULL if it has not been set.
+**
+*******************************************************************************/
+BTA_API extern char * BTA_MaBmsgGetNextMsgContent(tBTA_MA_BMSG_CONTENT * p_content);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetNextVcard
+**
+** Description Get the next vCard from the speicified vCard.
+**
+** Parameters p_vcard - Pointer to a vCard
+**
+** Returns Pointer to the next vCard.
+** NULL if it has not been set.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_BMSG_VCARD * BTA_MaBmsgGetNextVcard(tBTA_MA_BMSG_VCARD * p_vcard);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgSetVcardVersion
+**
+** Description Set the vCard version for the speicified vCard.
+**
+** Parameters p_vcard - Pointer to a vCard
+** version - vcard version
+**
+** Returns None
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaBmsgSetVcardVersion(tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_VCARD_VERSION version);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetVcardVersion
+**
+** Description Get the vCard version from the speicified vCard.
+**
+** Parameters p_vcard - Pointer to a vCard
+**
+** Returns vCard version number
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_VCARD_VERSION BTA_MaBmsgGetVcardVersion(tBTA_MA_BMSG_VCARD * p_vcard);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetVcardProp
+**
+** Description Get the vCard property from the speicified vCard peoperty enum.
+**
+** Parameters p_vcard - Pointer to a vCard
+** prop - Indicate which vCard peoperty
+**
+** Returns Pointer to the vCard peoperty.
+** NULL if the vCard peoperty does not exist
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_VCARD_PROPERTY * BTA_MaBmsgAddVcardProp(tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_VCARD_PROP prop, char * p_value, char * p_param);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetVcardProp
+**
+** Description Get the next vCard property from the speicified vCard peoperty.
+**
+** Parameters p_prop - Pointer to a vCard property
+**
+** Returns Pointer to the next vCard peoperty.
+** NULL if the next vCard peoperty does not exist
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_VCARD_PROPERTY * BTA_MaBmsgGetVcardProp(tBTA_MA_BMSG_VCARD * p_vcard, tBTA_MA_VCARD_PROP prop);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetNextVcardProp
+**
+** Description Get the next vCard property from the speicified vCard peoperty.
+**
+** Parameters p_prop - Pointer to a vCard property
+**
+** Returns Pointer to the next vCard peoperty.
+** NULL if the next vCard peoperty does not exist
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_VCARD_PROPERTY * BTA_MaBmsgGetNextVcardProp(tBTA_MA_VCARD_PROPERTY * p_prop);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetVcardPropValue
+**
+** Description Get the vCard property value from the speicified vCard peoperty.
+**
+** Parameters p_prop - Pointer to a vCard property
+**
+** Returns Pointer to the vCard peoperty value.
+** NULL if the vCard peoperty value has not been set.
+**
+*******************************************************************************/
+BTA_API extern char * BTA_MaBmsgGetVcardPropValue(tBTA_MA_VCARD_PROPERTY * p_prop);
+/*******************************************************************************
+**
+** Function BTA_MaBmsgGetVcardPropParam
+**
+** Description Get the vCard property parameter from the speicified vCard peoperty.
+**
+** Parameters p_prop - Pointer to a vCard property
+**
+** Returns Poiter to the vCard peoperty parameter.
+** NULL if the vCard peoperty parameter has not been set.
+**
+*******************************************************************************/
+BTA_API extern char * BTA_MaBmsgGetVcardPropParam(tBTA_MA_VCARD_PROPERTY * p_prop);
+/*******************************************************************************
+**
+** Function BTA_MaBuildMapBmsgObj
+**
+** Description Builds a specification compliant bMessage object given a
+** generic bMessage internal structure.
+**
+** Parameters p_msg - pointer to bMessage object structure (input).
+** p_stream - Output stream.
+**
+** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_STATUS BTA_MaBuildMapBmsgObj(tBTA_MA_BMSG * p_msg, tBTA_MA_STREAM * p_stream);
+/*******************************************************************************
+**
+** Function bta_ma_parse_map_bmsg_obj
+**
+** Description Parses a bMessage object from a stream into a generic
+** bMessage internal structure.
+**
+** Parameters p_msg - pointer to bMessage object structure (output).
+** p_stream - Input stream.
+**
+** Returns BTA_MA_STATUS_OK if successful. BTA_MA_STATUS_FAIL if not.
+**
+*******************************************************************************/
+BTA_API extern tBTA_MA_STATUS BTA_MaParseMapBmsgObj(tBTA_MA_BMSG * p_msg, tBTA_MA_STREAM * p_stream);
+
+/*******************************************************************************
+**
+** Function BTA_MaInitMemStream
+**
+** Description Initializes a memory based stream
+**
+** Parameters p_stream - pointer to stream information.
+** p_buffer - pointer to buffer to be manipulated.
+** size - size of buffer pointed to by 'p_buffer'.
+**
+** Returns TRUE if stream is successfully initialized
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN BTA_MaInitMemStream(tBTA_MA_STREAM * p_stream,
+ UINT8 * p_buffer,
+ UINT16 size);
+/*******************************************************************************
+**
+** Function BTA_MaInitFileStream
+**
+** Description Initializes a file stream
+**
+** Parameters p_stream - pointer to stream information.
+** p_filename - Full pathname to file to use.
+** oflags - permissions and mode (see constants above)
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern BOOLEAN BTA_MaInitFileStream(tBTA_MA_STREAM * p_stream,
+ const char *p_path,
+ int oflags);
+/*******************************************************************************
+**
+** Function BTA_MaCloseStream
+**
+** Description Close a stream (do any necessary clean-up.
+**
+** Parameters p_stream - pointer to stream information.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_MaCloseStream(tBTA_MA_STREAM * p_stream);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_BMSG_API_H */
diff --git a/bta/include/bta_ma_co.h b/bta/include/bta_ma_co.h
new file mode 100644
index 0000000..442d106
--- /dev/null
+++ b/bta/include/bta_ma_co.h
@@ -0,0 +1,91 @@
+/*****************************************************************************
+**
+** Name: bta_ma_co.h
+**
+** Description: This is the interface file for the Message Access Profile
+** common call-out functions.
+**
+** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_MA_CO_H
+#define BTA_MA_CO_H
+
+#include <stdio.h>
+
+/*****************************************************************************
+**
+** Utility functions for converting types to strings.
+**
+*****************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_ma_co_open
+**
+** Description Open a file.
+**
+** Parameters p_path - Full path of file to open.
+** oflags - file open flags.
+**
+** Returns file descriptor. BTA_FS_INVALID_FD if open fails.
+**
+*******************************************************************************/
+ BTA_API extern int bta_ma_co_open(const char *p_path, int oflags);
+
+/*******************************************************************************
+**
+** Function bta_ma_co_write
+**
+** Description Write data to file.
+**
+** Parameters fd - file descriptor.
+** buffer - data to write.
+** size - size of data to write (in bytes).
+**
+** Returns Number of bytes written.
+**
+*******************************************************************************/
+ BTA_API extern int bta_ma_co_write(int fd, const void *buffer, int size);
+
+/*******************************************************************************
+**
+** Function bta_ma_co_read
+**
+** Description Read data from file.
+**
+** Parameters fd - file descriptor.
+** buffer - to receive data.
+** size - amount of data to read (in bytes).
+**
+** Returns Number of bytes read.
+**
+*******************************************************************************/
+ BTA_API extern int bta_ma_co_read(int fd, void *buffer, int size);
+
+/*******************************************************************************
+**
+** Function bta_ma_co_close
+**
+** Description Close the file.
+**
+** Parameters fd - file descriptor.
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void bta_ma_co_close(int fd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_MA_FILE_H */
+
+
diff --git a/bta/include/bta_ma_def.h b/bta/include/bta_ma_def.h
new file mode 100644
index 0000000..7202385
--- /dev/null
+++ b/bta/include/bta_ma_def.h
@@ -0,0 +1,479 @@
+/*****************************************************************************
+**
+** Name: bta_ma_def.h
+**
+** Description: This file contains the common definitions for the Message Access
+** profile (MA) related SW modules
+**
+** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_MA_DEF_H
+#define BTA_MA_DEF_H
+
+#include "obx_api.h"
+#include "bta_api.h"
+#include "btm_api.h"
+#include "bta_sys.h"
+#include "bta_fs_co.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+
+#define BTA_MA_HANDLE_SIZE 8
+
+typedef UINT8 tBTA_MA_MSG_HANDLE[BTA_MA_HANDLE_SIZE];
+
+typedef tOBX_HANDLE tBTA_MA_SESS_HANDLE;
+
+typedef UINT8 tBTA_MA_INST_ID;
+
+#define BTA_MA_STATUS_OK 0
+#define BTA_MA_STATUS_FAIL 1 /* Used to pass all other errors */
+#define BTA_MA_STATUS_ABORTED 2
+#define BTA_MA_STATUS_NO_RESOURCE 3
+#define BTA_MA_STATUS_EACCES 4
+#define BTA_MA_STATUS_ENOTEMPTY 5
+#define BTA_MA_STATUS_EOF 6
+#define BTA_MA_STATUS_EODIR 7
+#define BTA_MA_STATUS_ENOSPACE 8 /* Returned in bta_fs_ci_open if no room */
+#define BTA_MA_STATUS_DUPLICATE_ID 9
+#define BTA_MA_STATUS_ID_NOT_FOUND 10
+#define BTA_MA_STATUS_FULL 11 /* reach the max packet size */
+
+typedef UINT8 tBTA_MA_STATUS;
+
+#define BTA_MA_OPER_NONE 0
+#define BTA_MA_OPER_GET_MSG 1
+#define BTA_MA_OPER_PUSH_MSG 2
+
+typedef UINT8 tBTA_MA_OPER;
+
+/* mode field in tBTA_MSE_CO_FOLDER_ENTRY (OR'd together) */
+#define BTA_MA_A_RDONLY 1
+#define BTA_MA_A_DIR 2 /* Entry is a sub directory */
+
+
+/* message status inficator */
+#define BTA_MA_STS_INDTR_READ 0
+#define BTA_MA_STS_INDTR_DELETE 1
+typedef UINT8 tBTA_MA_STS_INDCTR;
+
+/* message status value */
+#define BTA_MA_STS_VALUE_NO 0
+#define BTA_MA_STS_VALUE_YES 1
+typedef UINT8 tBTA_MA_STS_VALUE;
+
+/* notification status */
+enum
+{
+ BTA_MA_NOTIF_OFF = 0,
+ BTA_MA_NOTIF_ON,
+ BTA_MA_NOTIF_MAX
+
+};
+typedef UINT8 tBTA_MA_NOTIF_STATUS;
+
+
+/* Access response types */
+enum
+{
+ BTA_MA_ACCESS_TYPE_ALLOW = 0, /* Allow the requested operation */
+ BTA_MA_ACCESS_TYPE_FORBID /* Disallow the requested operation */
+};
+
+typedef UINT8 tBTA_MA_ACCESS_TYPE;
+
+/* Structure for in progress related event*/
+typedef struct
+{
+ UINT32 obj_size; /* Total size of object 0 if unknow*/
+ tBTA_MA_SESS_HANDLE mas_session_id;
+ UINT16 bytes; /* Number of bytes read or written since last progress event */
+} tBTA_MA_IN_PROG;
+
+
+/* Message type see SDP supported message type */
+#define BTA_MA_MSG_TYPE_EMAIL (1<<0)
+#define BTA_MA_MSG_TYPE_SMS_GSM (1<<1)
+#define BTA_MA_MSG_TYPE_SMS_CDMA (1<<2)
+#define BTA_MA_MSG_TYPE_MMS (1<<3)
+typedef UINT8 tBTA_MA_MSG_TYPE;
+
+#define BTA_MA_MAX_FILTER_TEXT_SIZE 255
+
+/* Message type mask for FilterMessageType in Application parameter */
+#define BTA_MA_MSG_TYPE_MASK_SMS_GSM (1<<0)
+#define BTA_MA_MSG_TYPE_MASK_SMS_CDMA (1<<1)
+#define BTA_MA_MSG_TYPE_MASK_EMAIL (1<<2)
+#define BTA_MA_MSG_TYPE_MASK_MMS (1<<3)
+
+
+typedef UINT8 tBTA_MA_MSG_TYPE_MASK;
+
+
+
+/* Parameter Mask for Messages-Listing */
+#define BTA_MA_ML_MASK_SUBJECT (1<<0)
+#define BTA_MA_ML_MASK_DATETIME (1<<1)
+#define BTA_MA_ML_MASK_SENDER_NAME (1<<2)
+#define BTA_MA_ML_MASK_SENDER_ADDRESSING (1<<3)
+#define BTA_MA_ML_MASK_RECIPIENT_NAME (1<<4)
+#define BTA_MA_ML_MASK_RECIPIENT_ADDRESSING (1<<5)
+#define BTA_MA_ML_MASK_TYPE (1<<6)
+#define BTA_MA_ML_MASK_SIZE (1<<7)
+#define BTA_MA_ML_MASK_RECEPTION_STATUS (1<<8)
+#define BTA_MA_ML_MASK_TEXT (1<<9)
+#define BTA_MA_ML_MASK_ATTACHMENT_SIZE (1<<10)
+#define BTA_MA_ML_MASK_PRIORITY (1<<11)
+#define BTA_MA_ML_MASK_READ (1<<12)
+#define BTA_MA_ML_MASK_SENT (1<<13)
+#define BTA_MA_ML_MASK_PROTECTED (1<<14)
+#define BTA_MA_ML_MASK_REPLYTO_ADDRESSING (1<<15)
+
+typedef UINT32 tBTA_MA_ML_MASK;
+
+/* Read status used for message list */
+enum
+{
+ BTA_MA_READ_STATUS_NO_FILTERING = 0,
+ BTA_MA_READ_STATUS_UNREAD = 1,
+ BTA_MA_READ_STATUS_READ = 2
+};
+typedef UINT8 tBTA_MA_READ_STATUS;
+
+/* Priority status used for filtering message list */
+enum
+{
+ BTA_MA_PRI_STATUS_NO_FILTERING = 0,
+ BTA_MA_PRI_STATUS_HIGH = 1,
+ BTA_MA_PRI_STATUS_NON_HIGH = 2
+};
+typedef UINT8 tBTA_MA_PRI_STATUS;
+
+#define BTA_MA_LTIME_LEN 15
+typedef struct
+{
+ tBTA_MA_ML_MASK parameter_mask;
+ UINT16 max_list_cnt;
+ UINT16 list_start_offset;
+ UINT8 subject_length; /* valid range 1...255 */
+ tBTA_MA_MSG_TYPE_MASK msg_mask;
+ char period_begin[BTA_MA_LTIME_LEN+1]; /* "yyyymmddTHHMMSS", or "" if none */
+ char period_end[BTA_MA_LTIME_LEN+1]; /* "yyyymmddTHHMMSS", or "" if none */
+ tBTA_MA_READ_STATUS read_status;
+ char recipient[BTA_MA_MAX_FILTER_TEXT_SIZE+1]; /* "" if none */
+ char originator[BTA_MA_MAX_FILTER_TEXT_SIZE+1];/* "" if none */
+ tBTA_MA_PRI_STATUS pri_status;
+} tBTA_MA_MSG_LIST_FILTER_PARAM;
+
+/* enum for charset used in GetMEssage */
+enum
+{
+ BTA_MA_CHARSET_NATIVE = 0,
+ BTA_MA_CHARSET_UTF_8 = 1,
+ BTA_MA_CHARSET_UNKNOWN,
+ BTA_MA_CHARSET_MAX
+};
+typedef UINT8 tBTA_MA_CHARSET;
+
+/* enum for fraction request used in GetMEssage */
+enum
+{
+ BTA_MA_FRAC_REQ_FIRST = 0,
+ BTA_MA_FRAC_REQ_NEXT = 1,
+ BTA_MA_FRAC_REQ_NO, /* this is not a fraction request */
+ BTA_MA_FRAC_REQ_MAX
+};
+typedef UINT8 tBTA_MA_FRAC_REQ;
+
+/* enum for fraction delivery used in GetMEssage */
+enum
+{
+ BTA_MA_FRAC_DELIVER_MORE = 0,
+ BTA_MA_FRAC_DELIVER_LAST = 1,
+ BTA_MA_FRAC_DELIVER_NO, /* this is not a fraction deliver*/
+ BTA_MA_FRAC_DELIVER_MAX
+};
+typedef UINT8 tBTA_MA_FRAC_DELIVER;
+
+
+typedef struct
+{
+ BOOLEAN attachment;
+ tBTA_MA_MSG_HANDLE handle;
+ tBTA_MA_CHARSET charset;
+ tBTA_MA_FRAC_REQ fraction_request;
+} tBTA_MA_GET_MSG_PARAM;
+
+#define BTA_MA_RETRY_OFF 0
+#define BTA_MA_RETRY_ON 1
+#define BTA_MA_RETRY_UNKNOWN 0xff
+typedef UINT8 tBTA_MA_RETRY_TYPE;
+
+
+#define BTA_MA_TRANSP_OFF 0
+#define BTA_MA_TRANSP_ON 1
+#define BTA_MA_TRANSP_UNKNOWN 0xff
+typedef UINT8 tBTA_MA_TRANSP_TYPE;
+
+typedef struct
+{
+ char *p_folder; /* current or child folder
+ for current folder set
+ *p_folder = ""
+ */
+ char *p_msg_name; /* for MCE use only*/
+ tBTA_MA_TRANSP_TYPE transparent;
+ tBTA_MA_RETRY_TYPE retry;
+ tBTA_MA_CHARSET charset;
+
+} tBTA_MA_PUSH_MSG_PARAM;
+
+/* get or push message multi-packet status */
+enum
+{
+ BTA_MA_MPKT_STATUS_MORE = 0,
+ BTA_MA_MPKT_STATUS_LAST,
+ BTA_MA_MPKT_MAX
+};
+
+typedef UINT8 tBTA_MA_MPKT_STATUS;
+
+/* definitions for directory navigation */
+#define BTA_MA_DIR_NAV_ROOT_OR_DOWN_ONE_LVL 2
+#define BTA_MA_DIR_NAV_UP_ONE_LVL 3
+
+typedef UINT8 tBTA_MA_DIR_NAV;
+
+enum
+{
+ BTA_MA_ATTACH_OFF = 0,
+ BTA_MA_ATTACH_ON
+};
+typedef UINT8 tBTA_MA_ATTACH_TYPE;
+
+/* MAS tag ID in application parameters header definition */
+#define BTA_MA_APH_MAX_LIST_COUNT 0x01 /* MaxListCount 2 bytes 0x0000 to 0xFFFF */
+#define BTA_MA_APH_START_STOFF 0x02 /* StartOffset 2 bytes 0x0000 to 0xFFFF */
+#define BTA_MA_APH_FILTER_MSG_TYPE 0x03 /* SearchAttribute 1 byte 1,2,4 */
+#define BTA_MA_APH_FILTER_PRD_BEGIN 0x04 /* Filter Period Begin variable */
+#define BTA_MA_APH_FILTER_PRD_END 0x05 /* Filter Period End variable */
+#define BTA_MA_APH_FILTER_READ_STS 0x06 /* Filter read status 1 byte 0, 1, 2 */
+#define BTA_MA_APH_FILTER_RECEIP 0x07 /* FilterRecipient variable */
+#define BTA_MA_APH_FILTER_ORIGIN 0x08 /* FilterOriginator variable */
+#define BTA_MA_APH_FILTER_PRIORITY 0x09 /* FilterPriority 1 byte */
+#define BTA_MA_APH_ATTACH 0x0a /* Attachment 1 byte */
+#define BTA_MA_APH_TRANSPARENT 0x0b /* transparent 1 byte */
+#define BTA_MA_APH_RETRY 0x0c /* retry 1 byte */
+#define BTA_MA_APH_NEW_MSG 0x0d /* NewMessage 1 byte */
+#define BTA_MA_APH_NOTIF_STATUS 0x0e /* Notification Status 1 byte */
+#define BTA_MA_APH_MAS_INST_ID 0x0f /* MAS instance ID 1 byte 0 ... 255 */
+#define BTA_MA_APH_PARAM_MASK 0x10 /* Parameter mask 2 bytes */
+#define BTA_MA_APH_FOLDER_LST_SIZE 0x11 /* Folder Listing Size 2 bytes */
+#define BTA_MA_APH_MSG_LST_SIZE 0x12 /* Message Listing Size 2 bytes */
+#define BTA_MA_APH_SUBJ_LEN 0x13 /* Subject Length 1 byte */
+#define BTA_MA_APH_CHARSET 0x14 /* Character Set 1 byte :0, 1 */
+#define BTA_MA_APH_FRAC_REQ 0x15 /* Fraction request 1 byte :0, 1 */
+#define BTA_MA_APH_FRAC_DELVR 0x16 /* Fraction delivery 1 byte :0, 1 */
+#define BTA_MA_APH_STS_INDCTR 0x17 /* Status Indicator 1 byte */
+#define BTA_MA_APH_STS_VALUE 0x18 /* Status Value 1 byte: 0, 1 */
+#define BTA_MA_APH_MSE_TIME 0x19 /* MSETime variable */
+
+#define BTA_MA_BODY_FILLER_BYTE 0x30
+
+/* MAS type header */
+#define BTA_MA_HDR_TYPE_NOTIF_REG "x-bt/MAP-NotificationRegistration"
+#define BTA_MA_HDR_TYPE_MSG_UPDATE "x-bt/MAP-messageUpdate"
+#define BTA_MA_HDR_TYPE_EVENT_RPT "x-bt/MAP-event-report"
+#define BTA_MA_HDR_TYPE_MSG_LIST "x-bt/MAP-msg-listing"
+#define BTA_MA_HDR_TYPE_MSG "x-bt/message"
+#define BTA_MA_HDR_TYPE_MSG_STATUS "x-bt/messageStatus"
+#define BTA_MA_HDR_TYPE_FOLDER_LIST "x-obex/folder-listing"
+
+#define BTA_MAS_MESSAGE_ACCESS_TARGET_UUID "\xBB\x58\x2B\x40\x42\x0C\x11\xDB\xB0\xDE\x08\x00\x20\x0C\x9A\x66"
+#define BTA_MAS_MESSAGE_NOTIFICATION_TARGET_UUID "\xBB\x58\x2B\x41\x42\x0C\x11\xDB\xB0\xDE\x08\x00\x20\x0C\x9A\x66"
+#define BTA_MAS_UUID_LENGTH 16
+#define BTA_MAS_DEFAULT_VERSION 0x0100
+
+#define BTA_MA_NOTIF_STS_TAG_ID 0x0E
+#define BTA_MA_NOTIF_STS_LEN 0x01
+#define BTA_MA_NOTIF_STS_ON 0x01
+#define BTA_MA_NOTIF_STS_OFF 0x00
+
+#define BTA_MA_NAS_INST_ID_TAG_ID 0x0F
+#define BTA_MA_NAS_INST_ID_LEN 0x01
+
+#define BTA_MA_DEFAULT_MAX_LIST_CNT 1024
+
+
+#define BTA_MA_64BIT_HEX_STR_SIZE (16+1)
+#define BTA_MA_32BIT_HEX_STR_SIZE (8+1)
+
+
+
+/*******************************************************************************
+**
+** bMessage types
+**
+** Description The following types are designed to hold data in memory.
+** The internal structure of these types are implementation
+** specific.
+**
+*******************************************************************************/
+
+enum
+{
+ BTA_MA_BMSG_ENC_8BIT = 0, /* Used for Email/MMS */
+
+ BTA_MA_BMSG_ENC_G7BIT, /* Used for GSM-SMS */
+ BTA_MA_BMSG_ENC_G7BITEXT,
+ BTA_MA_BMSG_ENC_GUCS2,
+ BTA_MA_BMSG_ENC_G8BIT,
+
+ BTA_MA_BMSG_ENC_C8BIT, /* Used for CDMA-SMS */
+ BTA_MA_BMSG_ENC_CEPM,
+ BTA_MA_BMSG_ENC_C7ASCII,
+ BTA_MA_BMSG_ENC_CIA5,
+ BTA_MA_BMSG_ENC_CUNICODE,
+ BTA_MA_BMSG_ENC_CSJIS,
+ BTA_MA_BMSG_ENC_CKOREAN,
+ BTA_MA_BMSG_ENC_CLATINHEB,
+ BTA_MA_BMSG_ENC_CLATIN,
+
+ BTA_MA_BMSG_ENC_UNKNOWN
+};
+typedef UINT8 tBTA_MA_BMSG_ENCODING;
+
+enum
+{
+ BTA_MA_BMSG_LANG_UNSPECIFIED = 0,
+
+ BTA_MA_BMSG_LANG_UNKNOWN,
+ BTA_MA_BMSG_LANG_SPANISH, /* GSM-SMS or CDMA-SMS */
+
+ BTA_MA_BMSG_LANG_TURKISH, /* GSM-SMS only */
+ BTA_MA_BMSG_LANG_PORTUGUESE,
+
+ BTA_MA_BMSG_LANG_ENGLISH, /* CDMA-SMS only */
+ BTA_MA_BMSG_LANG_FRENCH,
+ BTA_MA_BMSG_LANG_JAPANESE,
+ BTA_MA_BMSG_LANG_KOREAN,
+ BTA_MA_BMSG_LANG_CHINESE,
+ BTA_MA_BMSG_LANG_HEBREW
+};
+typedef UINT8 tBTA_MA_BMSG_LANGUAGE;
+
+
+enum
+{
+ BTA_MA_VCARD_VERSION_21=0,
+ BTA_MA_VCARD_VERSION_30
+};
+typedef UINT8 tBTA_MA_VCARD_VERSION;
+
+enum
+{
+ BTA_MA_VCARD_PROP_N,
+ BTA_MA_VCARD_PROP_FN,
+ BTA_MA_VCARD_PROP_TEL,
+ BTA_MA_VCARD_PROP_EMAIL,
+
+ BTA_MA_VCARD_PROP_MAX
+};
+typedef UINT8 tBTA_MA_VCARD_PROP;
+
+typedef struct
+{
+ char * p_param;
+ char * p_value;
+
+ /* link to the next property (if any) */
+ void * p_next;
+
+} tBTA_MA_VCARD_PROPERTY;
+
+typedef struct
+{
+ tBTA_MA_VCARD_VERSION version;
+
+ tBTA_MA_VCARD_PROPERTY * p_prop[BTA_MA_VCARD_PROP_MAX];
+
+ /* link to the next vCard (if any) */
+ void * p_next;
+
+} tBTA_MA_BMSG_VCARD;
+
+typedef struct BMSG_MESSAGE_struct
+{
+ char * p_text;
+
+ /* link to the next chunk of message text (if any) */
+ void * p_next;
+
+} tBTA_MA_BMSG_MESSAGE;
+
+typedef struct BMSG_CONTENT_struct
+{
+ /* this is the first bit of message text */
+ tBTA_MA_BMSG_MESSAGE * p_message;
+
+ /* this points to the last entered text -or-
+ ** it is the last that we returned back to
+ **
+ */
+ tBTA_MA_BMSG_MESSAGE * p_last;
+
+ /* link to the next chunk of content (if any) */
+ void * p_next;
+
+} tBTA_MA_BMSG_CONTENT;
+
+
+typedef struct
+{
+ /* Part ID */
+ UINT16 part_id;
+ BOOLEAN is_multipart;
+
+ /* Properties */
+ tBTA_MA_BMSG_ENCODING encoding;
+ tBTA_MA_BMSG_LANGUAGE language; /* optional */
+ tBTA_MA_CHARSET charset;
+ /* One or more body content */
+ tBTA_MA_BMSG_CONTENT * p_content;
+
+} tBTA_MA_BMSG_BODY;
+
+typedef struct BMSG_ENVELOPE_struct
+{
+ /* One or more Recipient (vCards) */
+ tBTA_MA_BMSG_VCARD * p_recip;
+
+ /* There will be either another envelope or the body */
+ void * p_next;
+ tBTA_MA_BMSG_BODY * p_body;
+
+} tBTA_MA_BMSG_ENVELOPE;
+
+typedef struct
+{
+ /* Property values */
+ BOOLEAN read_sts;
+ tBTA_MA_MSG_TYPE msg_type;
+ char * p_folder;
+
+ /* One or more Originator (vCards) */
+ tBTA_MA_BMSG_VCARD * p_orig;
+
+ /* Envelope */
+ tBTA_MA_BMSG_ENVELOPE * p_envelope;
+
+} tBTA_MA_BMSG;
+
+
+#endif
+
diff --git a/bta/include/bta_mse_api.h b/bta/include/bta_mse_api.h
new file mode 100644
index 0000000..742ea7a
--- /dev/null
+++ b/bta/include/bta_mse_api.h
@@ -0,0 +1,470 @@
+/*****************************************************************************
+**
+** Name: bta_mse_api.h
+**
+** Description: This is the public interface file for the Message Server Equipment
+** (MSE) subsystem of BTA, Broadcom's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_MSE_API_H
+#define BTA_MSE_API_H
+
+#include "bta_api.h"
+#include "bta_ma_def.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+/* Extra Debug Code */
+#ifndef BTA_MSE_DEBUG
+ #define BTA_MSE_DEBUG TRUE
+#endif
+
+/**************************
+** Common Definitions
+***************************/
+
+/* MSE callback function events */
+enum
+{
+ BTA_MSE_ENABLE_EVT = 0, /* MAS server is enabled. */
+ BTA_MSE_DISABLE_EVT,
+ BTA_MSE_ACCESS_EVT,
+ BTA_MSE_OPER_CMPL_EVT, /* MSE operation complete */
+ BTA_MSE_MA_OPEN_EVT,
+ BTA_MSE_MA_CLOSE_EVT,
+ BTA_MSE_SET_NOTIF_REG_EVT,
+ BTA_MSE_NOTIF_REG_EVT,
+ BTA_MSE_UPDATE_INBOX_EVT,
+ BTA_MSE_GET_MSG_IN_PROG_EVT,
+ BTA_MSE_PUSH_MSG_IN_PROG_EVT,
+ BTA_MSE_SEND_NOTIF_EVT,
+ BTA_MSE_MN_OPEN_EVT,
+ BTA_MSE_MN_CLOSE_EVT,
+ BTA_MSE_START_EVT,
+ BTA_MSE_STOP_EVT
+};
+typedef UINT8 tBTA_MSE_EVT;
+
+
+/* Structure associated with BTA_MSE_ENABLE_EVT
+ BTA_MSE_DISABLE_EVT
+*/
+typedef struct
+{
+ tBTA_MA_STATUS status;
+ UINT8 app_id;
+} tBTA_MSE_ENABLE_DISABLE;
+
+
+/*******************************************
+** Message Access Server Definitions
+********************************************/
+/* Access event operation types */
+#define BTA_MSE_OPER_NONE 0
+#define BTA_MSE_OPER_SETPATH 1
+#define BTA_MSE_OPER_GET_FOLDER_LIST 2
+#define BTA_MSE_OPER_GET_MSG_LIST 3
+#define BTA_MSE_OPER_GET_MSG 4
+#define BTA_MSE_OPER_SET_MSG_STATUS 5
+#define BTA_MSE_OPER_DEL_MSG 6
+#define BTA_MSE_OPER_PUSH_MSG 7
+#define BTA_MSE_OPER_NOTIF_REG 8
+#define BTA_MSE_OPER_UPDATE_INBOX 9
+
+typedef UINT8 tBTA_MSE_OPER;
+
+/* Structure associated with BTA_MSE_ACCESS_EVT */
+typedef struct
+{
+ tBTA_MA_SESS_HANDLE mas_session_id; /* MAS Session ID */
+ tBTA_MSE_OPER oper; /* operation */
+ char *p_path; /* full path name */
+ tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
+ BD_ADDR bd_addr; /* Address of device */
+ tBTA_MA_MSG_HANDLE handle;
+ BOOLEAN delete_sts;
+} tBTA_MSE_ACCESS;
+
+/* Structure associated with BTA_MSE_OPER_CMPL_EVT */
+typedef struct
+{
+ UINT32 obj_size; /* Total size of object 0 if unknow*/
+ tBTA_MA_SESS_HANDLE mas_session_id; /* MAS Session ID */
+ tBTA_MSE_OPER operation;
+ tBTA_MA_STATUS status;
+} tBTA_MSE_OPER_CMPL;
+
+
+/* Structure associated with BTA_MSE_MA_OPEN_EVT */
+typedef struct
+{
+ tBTA_MA_INST_ID mas_instance_id; /* MAS instance ID: one MAS
+ instance can support multiple
+ sessions */
+ tBTA_MA_SESS_HANDLE mas_session_id; /* MAS Session ID, all session based
+ operation will need to use this ID */
+ tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
+ BD_ADDR bd_addr; /* Address of device */
+
+} tBTA_MSE_MA_OPEN;
+
+/* Structure associated with BTA_MSE_MA_CLOSE_EVT */
+typedef struct
+{
+ tBTA_MA_STATUS status;
+ tBTA_MA_SESS_HANDLE mas_session_id;
+ tBTA_MA_INST_ID mas_instance_id;
+} tBTA_MSE_MA_CLOSE;
+
+/* Structure associated with BTA_MSE_MN_OPEN_EVT or
+ BTA_MSE_MN_CLOSE_EVT
+*/
+typedef struct
+{
+ tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
+ BD_ADDR bd_addr; /* Address of device */
+ tBTA_MA_INST_ID first_mas_instance_id; /* MN connection can be used for more
+ than one MasInstanceIDs.
+ first_mas_instance_id is the MasInstanceId of a
+ MAS service MCE first registers to receive the
+ message notification */
+} tBTA_MSE_MN_OPEN;
+
+typedef struct
+{
+ tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
+ BD_ADDR bd_addr; /* Address of device */
+} tBTA_MSE_MN_CLOSE;
+
+/* Update Inbox response types */
+enum
+{
+ BTA_MSE_UPDATE_INBOX_ALLOW = 0, /* Allow the update inbox */
+ BTA_MSE_UPDATE_INBOX_FORBID /* Disallow the update inbox */
+};
+typedef UINT8 tBTA_MSE_UPDATE_INBOX_TYPE;
+
+
+/* Set Notification Registration response types */
+enum
+{
+ BTA_MSE_SET_NOTIF_REG_ALLOW = 0, /* Allow the notification registration request*/
+ BTA_MSE_SET_NOTIF_REG_FORBID /* Disallow the notification registration request */
+};
+typedef UINT8 tBTA_MSE_SET_NOTIF_REG_TYPE;
+
+/* Structure associated with BTA_MSE_SEND_NOTIF_EVT */
+typedef struct
+{
+ tBTA_MA_STATUS status;
+ tBTA_MA_INST_ID mas_instance_id;
+ BD_ADDR bd_addr; /* remote MCE's BD address*/
+} tBTA_MSE_SEND_NOTIF;
+
+
+/* Structure associated with BTA_MSE_START_EVT or
+ BTA_MSE_STOP_EVT */
+typedef struct
+{
+ tBTA_MA_STATUS status;
+ UINT8 mas_instance_id;
+} tBTA_MSE_START_STOP;
+
+typedef struct
+{
+ tBTA_MA_SESS_HANDLE mas_session_id;
+ tBTA_MA_INST_ID mas_instance_id;
+ tBTA_MA_NOTIF_STATUS notif_status;
+ BD_ADDR bd_addr; /* remote MCE's BD address*/
+}tBTA_MSE_SET_NOTIF_REG;
+
+typedef struct
+{
+ tBTA_MA_STATUS status;
+ tBTA_MA_SESS_HANDLE mas_session_id;
+ tBTA_MA_INST_ID mas_instance_id;
+ tBTA_MA_NOTIF_STATUS notif_status;
+ BD_ADDR bd_addr; /* remote MCE's BD address*/
+}tBTA_MSE_NOTIF_REG;
+
+
+/* Data associated with call back events */
+typedef union
+{
+ tBTA_MA_SESS_HANDLE mas_session_id; /* BTA_MSE_UPDATE_INBOX_EVT*/
+ tBTA_MSE_ENABLE_DISABLE enable;
+ tBTA_MSE_ENABLE_DISABLE disable;
+ tBTA_MSE_ACCESS access;
+ tBTA_MSE_SET_NOTIF_REG set_notif_reg;
+ tBTA_MSE_NOTIF_REG notif_reg;
+ tBTA_MSE_MN_OPEN mn_open;
+ tBTA_MSE_MN_CLOSE mn_close;
+ tBTA_MSE_MA_OPEN ma_open;
+ tBTA_MSE_MA_CLOSE ma_close;
+ tBTA_MSE_SEND_NOTIF send_notif;
+ tBTA_MA_IN_PROG get_msg_in_prog;
+ tBTA_MA_IN_PROG push_msg_in_prog;
+ tBTA_MSE_OPER_CMPL oper_cmpl;
+ tBTA_MSE_START_STOP start;
+ tBTA_MSE_START_STOP stop;
+} tBTA_MSE;
+
+/* MSE callback function */
+typedef void tBTA_MSE_CBACK(tBTA_MSE_EVT event, tBTA_MSE *p_data);
+
+
+/********************************************
+** Message Notification Client Definitions
+*********************************************/
+
+/* Send Notification function arguments definition */
+enum
+{
+ BTA_MSE_NOTIF_TYPE_NEW_MSG = 0,
+ BTA_MSE_NOTIF_TYPE_DELIVERY_SUCCESS,
+ BTA_MSE_NOTIF_TYPE_SENDING_SUCCESS,
+ BTA_MSE_NOTIF_TYPE_DELIVERY_FAILURE,
+ BTA_MSE_NOTIF_TYPE_SENDING_FAILURE,
+ BTA_MSE_NOTIF_TYPE_MEMORY_FULL,
+ BTA_MSE_NOTIF_TYPE_MEMORY_AVAILABLE,
+ BTA_MSE_NOTIF_TYPE_MESSAGE_DELETED,
+ BTA_MSE_NOTIF_TYPE_MESSAGE_SHIFT,
+ BTA_MSE_NOTIF_TYPE_MAX
+};
+
+typedef UINT8 tBTA_MSE_NOTIF_TYPE;
+
+/* configuration related constant */
+
+
+
+/* MSE configuration data */
+#define BTA_MSE_NUM_INST 4
+#define BTA_MSE_NUM_SESS 4
+#define BTA_MSE_NUM_MN 7 /* i.e. up to 7 MCEs can be connected to the MSE */
+
+typedef struct
+{
+ INT32 obx_rsp_tout; /* maximum amount of time to wait for obx rsp */
+ UINT16 max_name_len; /* maximum folder name length */
+
+} tBTA_MSE_CFG;
+
+extern tBTA_MSE_CFG * p_bta_mse_cfg;
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**************************
+** API Functions
+***************************/
+
+/*******************************************************************************
+**
+** Function BTA_MseEnable
+**
+** Description Enable the MSE subsystems. This function must be
+** called before any other functions in the MSE API are called.
+** When the enable operation is completed the callback function
+** will be called with an BTA_MSE_ENABLE_EVT event.
+**
+** Parameters p_cback - MSE event call back function
+** app_id - Application ID
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseEnable(tBTA_MSE_CBACK *p_cback, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_MseDisable
+**
+** Description Disable the MSE subsystem.
+**
+** Parameters
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseDisable(void);
+/*******************************************************************************
+**
+** Function BTA_MseStart
+**
+** Description Start a MA server on the MSE
+**
+**
+** Parameters mas_inst_id - MAS instance ID
+** sec_mask - Security Setting Mask
+** MSE always enables
+** (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)
+** p_service_name - Pointer to service name
+** p_root_path - Pointer to root path
+** (one level above telecom)
+** sup_msg_type - supported message type(s)
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseStart( tBTA_MA_INST_ID mas_inst_id,
+ tBTA_SEC sec_mask, const char *p_service_name,
+ const char *p_root_path,
+ tBTA_MA_MSG_TYPE sup_msg_type);
+/*******************************************************************************
+**
+** Function BTA_MseStop
+**
+** Description Stop a MAS service on the MSE
+**
+** Parameters mas_instance_id - MAS Instance ID
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseStop (tBTA_MA_INST_ID mas_instance_id);
+
+/*******************************************************************************
+**
+** Function BTA_MseClose
+**
+** Description Close all MAS sessions on the specified MAS Instance ID
+**
+** Parameters mas_instance_id - MAS Inatance ID
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseClose(tBTA_MA_INST_ID mas_instance_id);
+
+/*******************************************************************************
+**
+** Function BTA_MseMaClose
+**
+** Description Close a MAS sessions on the specified BD address
+**
+** Parameters bd_addr - remote BD's address
+** mas_instance_id - MAS Inatance ID
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseMaClose(BD_ADDR bd_addr, tBTA_MA_INST_ID mas_instance_id);
+
+/*******************************************************************************
+**
+** Function BTA_MseMnClose
+**
+** Description Close a MN session
+**
+** Parameters bd_addr - remote BT's address
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseMnClose(BD_ADDR bd_addr);
+
+/*******************************************************************************
+**
+** Function BTA_MseAccessRsp
+**
+** Description Send a response for the access request
+**
+** Parameters mas_session_id - MAS session ID
+** oper - MAS operation type
+** access - Access is allowed or not
+** p_path - pointer to a path if if the operation
+** involves accessing a folder
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseAccessRsp(tBTA_MA_SESS_HANDLE mas_session_id, tBTA_MSE_OPER oper,
+ tBTA_MA_ACCESS_TYPE access, char *p_name);
+
+/*******************************************************************************
+**
+** Function BTA_MseUpdateInboxRsp
+**
+** Description Send a response for the update inbox request
+**
+**
+** Parameters mas_session_id - MAS session ID
+** update_rsp - update inbox is allowed or not
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseUpdateInboxRsp(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MSE_UPDATE_INBOX_TYPE update_rsp);
+
+/*******************************************************************************
+**
+** Function BTA_MseSetNotifRegRsp
+**
+** Description Send a response for the set notification registration
+**
+**
+** Parameters mas_session_id - MAS session ID
+** set_notif_reg_rsp - indicate whether the set notification
+** registration is allowed or not
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseSetNotifRegRsp(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MSE_SET_NOTIF_REG_TYPE set_notif_reg_rsp);
+
+/*******************************************************************************
+**
+** Function BTA_MseSendNotif
+**
+** Description Send a Message notification report to all MCEs registered with
+** the specified MAS instance ID
+**
+** Parameters mas_instance_id - MAS Instance ID
+** notif_type - message notification type
+** handle - message handle
+** p_folder - pointer to current folder
+** p_old_folder - pointer to older folder
+** msg_type - message type (E_MAIL, SMS_GSM, SMS_CDMA, MMS)
+** except_bd_addr - except to the MCE on this BD Address.
+** (Note: notification will be not sent to
+** this BD Addreess)
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseSendNotif(tBTA_MA_INST_ID mas_instance_id,
+ tBTA_MSE_NOTIF_TYPE notif_type,
+ tBTA_MA_MSG_HANDLE handle,
+ char * p_folder, char *p_old_folder,
+ tBTA_MA_MSG_TYPE msg_type,
+ BD_ADDR except_bd_addr);
+
+/*******************************************************************************
+**
+** Function BTA_MseMnAbort
+**
+** Description Abort the current OBEX multi-packt operation
+**
+** Parameters mas_instance_id - MAS Instance ID
+**
+** Returns void
+**
+*******************************************************************************/
+ BTA_API extern void BTA_MseMnAbort(tBTA_MA_INST_ID mas_instance_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_MSE_API_H */
diff --git a/bta/include/bta_mse_ci.h b/bta/include/bta_mse_ci.h
new file mode 100644
index 0000000..f366f16
--- /dev/null
+++ b/bta/include/bta_mse_ci.h
@@ -0,0 +1,146 @@
+/*****************************************************************************
+**
+** Name: bta_mse_ci.h
+**
+** Description: This is the interface file for the Message Server Equipment
+** (MSE) subsystem call-out functions.
+**
+** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_MSE_CI_H
+#define BTA_MSE_CI_H
+
+#include "bta_api.h"
+#include "bta_ma_def.h"
+#include "bta_mse_api.h"
+#include "bta_mse_co.h"
+
+/*******************************************************************************
+**
+** Function bta_mse_ci_get_folder_entry
+**
+** Description This function is called in response to the
+** bta_mse_co_get_folder_entry call-out function.
+**
+** Parameters mas_session_id - MAS session ID
+** status - BTA_MA_STATUS_OK if p_entry points to a valid entry.
+** BTA_MA_STATUS_EODIR if no more entries (p_entry is ignored).
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** evt - evt from the call-out function
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_ci_get_folder_entry(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_STATUS status,
+ UINT16 evt);
+/*******************************************************************************
+**
+** Function bta_mse_ci_get_msg_list_info
+**
+** Description This function is called in response to the
+** bta_mse_co_get_msg_list_info call-out function.
+**
+** Parameters mas_session_id - MAS session ID
+** status - BTA_MA_STATUS_OK operation is successful.
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** evt - evt from the call-out function
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_ci_get_msg_list_info(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_STATUS status,
+ UINT16 evt);
+/*******************************************************************************
+**
+** Function bta_mse_ci_get_msg_list_entry
+**
+** Description This function is called in response to the
+** bta_mse_co_get_msg_list_entry call-out function.
+**
+** Parameters mas_session_id - MAS session ID
+** status - BTA_MA_STATUS_OK if p_entry points to a valid entry.
+** BTA_MA_STATUS_EODIR if no more entries (p_entry is ignored).
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** evt - evt from the call-out function
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_ci_get_msg_list_entry(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_STATUS status,
+ UINT16 evt);
+/*******************************************************************************
+**
+** Function bta_mse_ci_get_msg
+**
+** Description This function is called in response to the
+** bta_mse_co_get_msg call-out function.
+**
+** Parameters mas_session_id - MAS session ID
+** status - BTA_MA_STATUS_OK if p_msg points to a valid bmessage.
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** filled_buff_size - size of the filled buffer
+** multi_pkt_status - BTA_MA_MPKT_STATUS_MORE - need to get more packets
+** BTA_MA_MPKT_STATUS_LAST - last packet of the bMessage
+** frac_deliver_status - BTA_MA_FRAC_DELIVER_MORE - other fractions following
+** this bMessage
+** BTA_MA_FRAC_DELIVER_LAST - Last fraction
+** evt - evt from the call-out function
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_ci_get_msg(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_STATUS status,
+ UINT16 filled_buff_size,
+ tBTA_MA_MPKT_STATUS multi_pkt_status,
+ tBTA_MA_FRAC_DELIVER frac_deliver_status,
+ UINT16 evt);
+/*******************************************************************************
+**
+** Function bta_mse_ci_set_msg_delete_status
+**
+** Description This function is called in response to the
+** bta_mse_co_set_msg_delete_status call-out function.
+**
+** Parameters mas_session_id - MAS session ID
+** status - BTA_MA_STATUS_OK if operation is successful.
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** evt - evt from the call-out function
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_ci_set_msg_delete_status(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_STATUS status,
+ UINT16 evt);
+/*******************************************************************************
+**
+** Function bta_mse_ci_push_msg
+**
+** Description This function is called in response to the
+** bta_mse_co_push_msg call-out function.
+**
+** Parameters mas_session_id - MAS session ID
+** status - BTA_MA_STATUS_OK if the message upload is successful.
+** BTA_MA_STATUS_FAIL if any errors have occurred.
+** last_packet - last packet of a multi-packet message
+** handle - message handle for the uploaded message if
+** status is BTA_MA_OK and last_packet is TRUE
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_ci_push_msg(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_STATUS status,
+ BOOLEAN last_packet,
+ tBTA_MA_MSG_HANDLE handle,
+ UINT16 evt);
+#endif /* BTA_MSE_CI_H */
+
+
+
+
diff --git a/bta/include/bta_mse_co.h b/bta/include/bta_mse_co.h
new file mode 100644
index 0000000..adc551f
--- /dev/null
+++ b/bta/include/bta_mse_co.h
@@ -0,0 +1,330 @@
+/*****************************************************************************
+**
+** Name: bta_mse_co.h
+**
+** Description: This is the interface file for the Message Server Equipment
+** (MSE) subsystem call-out functions.
+**
+** Copyright (c) 2009-2011, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_MSE_CO_H
+#define BTA_MSE_CO_H
+
+#include "bta_api.h"
+#include "bta_ma_def.h"
+#include "bta_mse_api.h"
+
+/*****************************************************************************
+** Constants and Data Types
+*****************************************************************************/
+/**************************
+** Common Definitions
+***************************/
+
+
+/* Return structure type for a folder entry i.e. only folder level
+ information under the specified path and no file name */
+typedef struct
+{
+ UINT32 refdata; /* holder for OS specific data used to get next entry */
+ UINT32 filesize;
+ char *p_name; /* Contains the addr of memory to copy name into */
+ char crtime[BTA_FS_CTIME_LEN]; /* "yyyymmddTHHMMSSZ", or "" if none */
+ UINT8 mode; /* BTA_MSE_A_RDONLY and/or BTA_MSE_A_DIR */
+} tBTA_MSE_CO_FOLDER_ENTRY;
+
+
+#define BTA_MSE_CO_MAX_ADDR_LEN 256 /* See MAP spec 3.1.6 */
+#define BTA_MSE_CO_MAX_DATE_TIME 21 /* "YYYYMMDDTHHMMSS+hhmm" or "YYYYMMDDTHHMMSS" */
+
+enum
+{
+ BTA_MSE_CO_RCV_STATUS_COMPLETE = 0,
+ BTA_MSE_CO_RCV_STATUS_FRACTIONED,
+ BTA_MSE_CO_RCV_STATUS_NOTIFICATION,
+ BTA_MSE_CO_RCV_STATUS_MAX
+};
+
+typedef UINT8 tBTA_MSE_CO_RCV_STATUS;
+
+typedef struct
+{
+ UINT16 msg_list_size;
+ UINT8 mse_time_len;
+ char mse_time[BTA_FS_CTIME_LEN];
+ BOOLEAN new_msg;
+} tBTA_MSE_CO_MSG_LIST_INFO;
+
+typedef struct
+{
+ UINT32 refdata; /* holder for OS specific data used to get next msg entry */
+ tBTA_MA_ML_MASK parameter_mask;
+ UINT32 org_msg_size;
+ UINT32 attachment_size;
+ BOOLEAN text;
+ BOOLEAN high_priority;
+ BOOLEAN read;
+ BOOLEAN sent;
+ BOOLEAN is_protected;
+ tBTA_MA_MSG_HANDLE msg_handle;
+ tBTA_MA_MSG_TYPE type;
+ tBTA_MSE_CO_RCV_STATUS reception_status;
+ char subject[BTA_MSE_CO_MAX_ADDR_LEN];
+ char date_time[BTA_MSE_CO_MAX_DATE_TIME]; /* "YYYYMMDDTHHMMSS+hhmm", "YYYYMMDDTHHMMSS", or "" if none */
+ char sender_name[BTA_MSE_CO_MAX_ADDR_LEN];
+ char sender_addressing[BTA_MSE_CO_MAX_ADDR_LEN];
+ char recipient_name[BTA_MSE_CO_MAX_ADDR_LEN];
+ char recipient_addressing[BTA_MSE_CO_MAX_ADDR_LEN];
+ char replyto_addressing[BTA_MSE_CO_MAX_ADDR_LEN];
+} tBTA_MSE_CO_MSG_LIST_ENTRY;
+
+/*******************************************************************************
+**
+** Function bta_mse_co_update_inbox
+**
+** Description Update the inbox
+**
+** Parameters mas_session_id - MAS session ID
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which application
+** is the caller of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_co_update_inbox(tBTA_MA_SESS_HANDLE mas_session_id, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_mse_co_set_folder
+**
+** Description Set the current foldeer to the specified path
+**
+** Parameters mas_session_id - MAS session ID
+** p_path - points to the current folder path
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which application
+** is the caller of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_co_set_folder(tBTA_MA_SESS_HANDLE mas_session_id,
+ const char *p_path,
+ UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_mse_co_get_folder_entry
+**
+** Description This function is called to get a folder entry for the
+** specified path. The folder name should be filled
+** into the location specified by p_entry.
+**
+** Parameters mas_session_id - MAS session ID
+** p_path - points to the folder path to get the subfolder entry
+** (fully qualified path)
+** first_item - TRUE if first search, FALSE if next search
+** p_entry (input/output) - Points to the current entry data
+** evt - event that must be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which application
+** is the caller of the call-out function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, the status is passed
+** in the bta_mse_ci_get_folder_entry() call-in function.
+** BTA_MA_STATUS_OK is returned when p_entry is valid,
+** BTA_MA_STATUS_EODIR is returned when no more entries [finished]
+** BTA_MA_STATUS_FAIL is returned if an error occurred
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_co_get_folder_entry(tBTA_MA_SESS_HANDLE mas_session_id, const char *p_path,
+ BOOLEAN first_item, tBTA_MSE_CO_FOLDER_ENTRY *p_entry,
+ UINT16 evt, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_mse_co_get_msg_list_info
+**
+** Description This function is called to get a message list information for
+** the specified folder
+**
+** Parameters mas_session_id - MAS session ID
+** p_name - points to the current or child folder for getting the
+** message list information
+** (if *p_name == "" it means current folder)
+** filter_para - filter parameters for getting the message
+** list information
+** p_info(input/output) - Points to the message listing information
+** evt - event that be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which application
+** is the caller of the call-out function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, the status is passed
+** in the bta_mse_ci_get_msg_list_info() call-in function.
+** BTA_MA_STATUS_OK is returned when p_entry is valid
+** BTA_MA_STATUS_FAIL is returned if an error occurred
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_co_get_msg_list_info(tBTA_MA_SESS_HANDLE mas_session_id, const char *p_name,
+ tBTA_MA_MSG_LIST_FILTER_PARAM * p_filter_param,
+ tBTA_MSE_CO_MSG_LIST_INFO * p_info,
+ UINT16 evt, UINT8 app_id);
+/*******************************************************************************
+**
+** Function bta_mse_co_get_msg_list_entry
+**
+** Description This function is called to retrieve a message list entry for
+** the specified folder. The msg information should be filled by
+** application into the location specified by p_entry.
+**
+** Parameters mas_session_id - MAS session ID
+** p_name - points to the current or child folder for getting the
+** message list entry
+** (if *p_name == "" it means current folder)
+** filter_para - filter parameters for getting message list
+** first_item - TRUE if first get, FALSE if next msg
+** p_entry(input/output) - Points to current entry data
+** evt - event that must be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which application
+** is the caller of the call-out function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, the status is passed
+** in the bta_mse_ci_get_msg_list_entry() call-in function.
+** BTA_MA_STATUS_OK is returned when p_entry is valid,
+** BTA_MA_STATUS_EODIR is returned when no more entries [finished]
+** BTA_MA_STATUS_FAIL is returned if an error occurred
+*******************************************************************************/
+BTA_API extern void bta_mse_co_get_msg_list_entry(tBTA_MA_SESS_HANDLE mas_session_id, const char *p_name,
+ tBTA_MA_MSG_LIST_FILTER_PARAM *p_filter_param,
+ BOOLEAN first_item, tBTA_MSE_CO_MSG_LIST_ENTRY *p_entry,
+ UINT16 evt, UINT8 app_id);
+/*******************************************************************************
+**
+** Function bta_mse_co_get_msg
+**
+** Description This function is called to retrieve a msessage for the
+** specified message handle. The message will be filled by
+** application in bMessage format into the location
+** specified by p_buffer. The status and size of the filled
+** buffer are returned by bta_mse_ci_get_msg() call-in function
+**
+**
+** Parameters mas_session_id - MAS session ID
+** p_param - points to the parameters for the get message operation
+** first_get - TRUE first get FALSE subsequent get
+** buffer_size - size of the buffer pointed by p_buffer
+** p_buffer - points to the bMessage object storage location
+** evt - event that be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which application
+** is the caller of the call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_co_get_msg(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_GET_MSG_PARAM *p_param,
+ BOOLEAN first_get,
+ UINT16 buffer_size,
+ UINT8 *p_buffer,
+ UINT16 evt,
+ UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_mse_co_set_msg_delete_status
+**
+** Description This function is called to set a message delete status
+**
+** Parameters mas_session_id - MAS session ID
+** handle - message handle
+** status value - 1- yes, 0 = No
+** evt_id - event that be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which application
+** is the caller of the call-out function.
+**
+** Returns void
+**
+** Note: Upon completion of the request, the status is passed
+** in the bta_mse_ci_set_msg_delete_status() call-in function.
+** BTA_MA_STATUS_OK is returned when the delete operation is successful
+** BTA_MA_STATUS_FAIL is returned if an error occurred
+*******************************************************************************/
+BTA_API extern void bta_mse_co_set_msg_delete_status(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_MSG_HANDLE handle,
+ UINT8 status_value,
+ UINT16 evt_id,
+ UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_mse_co_set_msg_read_status
+**
+** Description This function is called to set a message read status
+**
+** Parameters mas_session_id - MAS session ID
+** handle - message handle
+** status value - 1- yes, 0 = No
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which application
+** is the caller of the call-out function.
+**
+** Returns BTA_MA_STATUS_OK - read status change is successful
+** BTA_MA_STATUS_FAIL
+*******************************************************************************/
+BTA_API extern tBTA_MA_STATUS bta_mse_co_set_msg_read_status(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_MSG_HANDLE handle,
+ UINT8 status_value,
+ UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_mse_co_push_msg
+**
+** Description This function is called to upload a message to the
+** specified folder
+**
+** Parameters mas_session_id - MAS session ID
+** p_param - points to parameters for message upload
+** msg_len - length of the message to be uploaded
+** p_msg - points to the message to be uploaded
+** first_pkt - TRUE first push message packet
+** multi_pkt_status -
+** BTA_MA_MPKT_STATUS_MORE - need to get more packets
+** BTA_MA_MPKT_STATUS_LAST - last packet of
+** the bMessage to be uploaded
+** evt - event that be passed into the call-in function.
+** app_id - application ID specified in the enable functions.
+** It can be used to identify which application
+** is the caller of the call-out function.
+**
+** Returns void
+**
+** Note1: Upon completion of the request, the status is passed
+** in the bta_mse_ci_push_msg() call-in function.
+** BTA_MA_STATUS_OK is returned if the request is successful,
+** BTA_MA_STATUS_FAIL is returned if an error occurred
+**
+*******************************************************************************/
+BTA_API extern void bta_mse_co_push_msg(tBTA_MA_SESS_HANDLE mas_session_id,
+ tBTA_MA_PUSH_MSG_PARAM *p_param,
+ UINT16 msg_len,
+ UINT8 *p_msg,
+ BOOLEAN first_pkt,
+ tBTA_MA_MPKT_STATUS mpkt_status,
+ UINT16 evt,
+ UINT8 app_id);
+
+#endif /* BTA_MSE_CO_H */
diff --git a/bta/include/bta_op_api.h b/bta/include/bta_op_api.h
new file mode 100644
index 0000000..b2a624c
--- /dev/null
+++ b/bta/include/bta_op_api.h
@@ -0,0 +1,621 @@
+/*****************************************************************************
+**
+** Name: bta_op_api.h
+**
+** Description: This is the public interface file for the object push
+** (OP) client and server subsystem of BTA, Widcomm's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2003-2006, Broadcom Corp., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_OP_API_H
+#define BTA_OP_API_H
+
+#include "bta_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+/* Extra Debug Code */
+#ifndef BTA_OPS_DEBUG
+#define BTA_OPS_DEBUG FALSE
+#endif
+
+#ifndef BTA_OPC_DEBUG
+#define BTA_OPC_DEBUG FALSE
+#endif
+
+
+/* Object format */
+#define BTA_OP_VCARD21_FMT 1 /* vCard 2.1 */
+#define BTA_OP_VCARD30_FMT 2 /* vCard 3.0 */
+#define BTA_OP_VCAL_FMT 3 /* vCal 1.0 */
+#define BTA_OP_ICAL_FMT 4 /* iCal 2.0 */
+#define BTA_OP_VNOTE_FMT 5 /* vNote */
+#define BTA_OP_VMSG_FMT 6 /* vMessage */
+#define BTA_OP_OTHER_FMT 0xFF /* other format */
+
+typedef UINT8 tBTA_OP_FMT;
+
+/* Object format mask */
+#define BTA_OP_VCARD21_MASK 0x01 /* vCard 2.1 */
+#define BTA_OP_VCARD30_MASK 0x02 /* vCard 3.0 */
+#define BTA_OP_VCAL_MASK 0x04 /* vCal 1.0 */
+#define BTA_OP_ICAL_MASK 0x08 /* iCal 2.0 */
+#define BTA_OP_VNOTE_MASK 0x10 /* vNote */
+#define BTA_OP_VMSG_MASK 0x20 /* vMessage */
+#define BTA_OP_ANY_MASK 0x40 /* Any type of object. */
+
+typedef UINT8 tBTA_OP_FMT_MASK;
+
+/* Status */
+#define BTA_OP_OK 0 /* Operation successful. */
+#define BTA_OP_FAIL 1 /* Operation failed. */
+#define BTA_OP_MEM 2 /* Not enough memory to complete operation. */
+
+typedef UINT8 tBTA_OP_STATUS;
+
+/* vCal Object Type */
+#define BTA_OP_VCAL_EVENT 0 /* Object is an "Event" object. */
+#define BTA_OP_VCAL_TODO 1 /* Object is a "ToDo" object. */
+
+typedef UINT8 tBTA_OP_VCAL;
+
+/* vCard Property Names */
+#define BTA_OP_VCARD_ADR 1 /* Address. */
+#define BTA_OP_VCARD_EMAIL 2 /* Email address. */
+#define BTA_OP_VCARD_FN 3 /* Formatted name. */
+#define BTA_OP_VCARD_NOTE 4 /* Note. */
+#define BTA_OP_VCARD_NICKNAME 5 /* Nickname. */
+#define BTA_OP_VCARD_N 6 /* Name. */
+#define BTA_OP_VCARD_ORG 7 /* Organization. */
+#define BTA_OP_VCARD_TEL 8 /* Telephone number. */
+#define BTA_OP_VCARD_TITLE 9 /* Title. */
+#define BTA_OP_VCARD_URL 10 /* URL. */
+#define BTA_OP_VCARD_LUID 11 /* Locally Unique Identifier. */
+#define BTA_OP_VCARD_BDAY 12 /* Birthday. */
+#define BTA_OP_VCARD_PHOTO 13 /* Photo. */
+#define BTA_OP_VCARD_SOUND 14 /* Sound. */
+#define BTA_OP_VCARD_CALL 15 /* Call date-time */
+
+/* vCal Property Names */
+#define BTA_OP_VCAL_CATEGORIES 1 /* Categories of event. */
+#define BTA_OP_VCAL_COMPLETED 2 /* Time event is completed. */
+#define BTA_OP_VCAL_DESCRIPTION 3 /* Description of event. */
+#define BTA_OP_VCAL_DTEND 4 /* End date and time of event. */
+#define BTA_OP_VCAL_DTSTART 5 /* Start date and time of event. */
+#define BTA_OP_VCAL_DUE 6 /* Due date and time of event. */
+#define BTA_OP_VCAL_LOCATION 7 /* Location of event. */
+#define BTA_OP_VCAL_PRIORITY 8 /* Priority of event. */
+#define BTA_OP_VCAL_STATUS 9 /* Status of event. */
+#define BTA_OP_VCAL_SUMMARY 10 /* Summary of event. */
+#define BTA_OP_VCAL_LUID 11 /* Locally Unique Identifier. */
+
+/* vNote Property Names */
+#define BTA_OP_VNOTE_BODY 1 /* Message body text. */
+#define BTA_OP_VNOTE_LUID 2 /* Locally Unique Identifier. */
+
+/* Structure of the 32-bit parameters mask:
+**
+** + property-specific
+** +reserved | + character set
+** | | | + encoding
+** | | | |
+** 0000000000000000 00000000 00000 000
+*/
+
+/* Encoding Parameter */
+#define BTA_OP_ENC_QUOTED_PRINTABLE (1<<0) /* Quoted-Printable encoding. */
+#define BTA_OP_ENC_8BIT (2<<0) /* 8-bit encoding */
+#define BTA_OP_ENC_BINARY (3<<0) /* Binary encoding */
+// btla-specific ++
+#define BTA_OP_ENC_BASE64 (4<<0) /* base64 encoding */
+// btla-specific --
+
+/* Character Set Parameter */
+#define BTA_OP_CHAR_BIG5 (1<<3) /* Big5 character set. */
+#define BTA_OP_CHAR_EUC_JP (2<<3) /* EUC-JP character set. */
+#define BTA_OP_CHAR_EUC_KR (3<<3) /* EUC-KR character set. */
+#define BTA_OP_CHAR_GB2312 (4<<3) /* GB2312 character set. */
+#define BTA_OP_CHAR_ISO_2022_JP (5<<3) /* ISO-2022-JP character set. */
+#define BTA_OP_CHAR_ISO_8859_1 (6<<3) /* ISO-8859-1 character set. */
+#define BTA_OP_CHAR_ISO_8859_2 (7<<3) /* ISO-8859-2 character set. */
+#define BTA_OP_CHAR_ISO_8859_3 (8<<3) /* ISO-8859-3 character set. */
+#define BTA_OP_CHAR_ISO_8859_4 (9<<3) /* ISO-8859-4 character set. */
+#define BTA_OP_CHAR_ISO_8859_5 (10<<3) /* ISO-8859-5 character set. */
+#define BTA_OP_CHAR_ISO_8859_6 (11<<3) /* ISO-8859-6 character set. */
+#define BTA_OP_CHAR_ISO_8859_7 (12<<3) /* ISO-8859-7 character set. */
+#define BTA_OP_CHAR_ISO_8859_8 (13<<3) /* ISO-8859-8 character set. */
+#define BTA_OP_CHAR_KOI8_R (14<<3) /* KOI8-R character set. */
+#define BTA_OP_CHAR_SHIFT_JIS (15<<3) /* Shift_JIS character set. */
+#define BTA_OP_CHAR_UTF_8 (16<<3) /* UTF-8 character set. */
+
+/* Address Type Parameter */
+#define BTA_OP_ADR_DOM (1<<8) /* Domestic address. */
+#define BTA_OP_ADR_INTL (1<<9) /* International address. */
+#define BTA_OP_ADR_POSTAL (1<<10) /* Postal address. */
+#define BTA_OP_ADR_PARCEL (1<<11) /* Parcel post address. */
+#define BTA_OP_ADR_HOME (1<<12) /* Home address. */
+#define BTA_OP_ADR_WORK (1<<13) /* Work address. */
+
+/* EMAIL Type Parameter */
+#define BTA_OP_EMAIL_PREF (1<<8) /* Preferred email. */
+#define BTA_OP_EMAIL_INTERNET (1<<9) /* Internet email. */
+#define BTA_OP_EMAIL_X400 (1<<10) /* x400 emaill */
+
+/* Telephone Number Type Parameter */
+#define BTA_OP_TEL_PREF (1<<8) /* Preferred number. */
+#define BTA_OP_TEL_WORK (1<<9) /* Work number. */
+#define BTA_OP_TEL_HOME (1<<10) /* Home number. */
+#define BTA_OP_TEL_VOICE (1<<11) /* Voice number. */
+#define BTA_OP_TEL_FAX (1<<12) /* Fax number. */
+#define BTA_OP_TEL_MSG (1<<13) /* Message number. */
+#define BTA_OP_TEL_CELL (1<<14) /* Cell phone number. */
+#define BTA_OP_TEL_PAGER (1<<15) /* Pager number. */
+
+/* Photo Parameter */
+#define BTA_OP_PHOTO_VALUE_URI (1<<8) /* URI value */
+#define BTA_OP_PHOTO_VALUE_URL (1<<9) /* URL value */
+#define BTA_OP_PHOTO_TYPE_JPEG (1<<10) /* JPEG photo */
+#define BTA_OP_PHOTO_TYPE_GIF (1<<11) /* GIF photo */
+
+/* Sound Parameter */
+#define BTA_OP_SOUND_VALUE_URI (1<<8) /* URI value */
+#define BTA_OP_SOUND_VALUE_URL (1<<9) /* URL value */
+#define BTA_OP_SOUND_TYPE_BASIC (1<<10) /* BASIC sound */
+#define BTA_OP_SOUND_TYPE_WAVE (1<<11) /* WAVE sound */
+
+/* vCard filter mask */
+#define BTA_OP_FILTER_VERSION (1<<0) /* vCard Version */
+#define BTA_OP_FILTER_FN (1<<1) /* Formatted Name */
+#define BTA_OP_FILTER_N (1<<2) /* Structured Presentation of Name */
+#define BTA_OP_FILTER_PHOTO (1<<3) /* Associated Image or Photo */
+#define BTA_OP_FILTER_BDAY (1<<4) /* Birthday */
+#define BTA_OP_FILTER_ADR (1<<5) /* Delivery Address */
+#define BTA_OP_FILTER_LABEL (1<<6) /* Delivery */
+#define BTA_OP_FILTER_TEL (1<<7) /* Telephone Number */
+#define BTA_OP_FILTER_EMAIL (1<<8) /* Electronic Mail Address */
+#define BTA_OP_FILTER_MAILER (1<<9) /* Electronic Mail */
+#define BTA_OP_FILTER_TZ (1<<10) /* Time Zone */
+#define BTA_OP_FILTER_GEO (1<<11) /* Geographic Position */
+#define BTA_OP_FILTER_TITLE (1<<12) /* Job */
+#define BTA_OP_FILTER_ROLE (1<<13) /* Role within the Organization */
+#define BTA_OP_FILTER_LOGO (1<<14) /* Organization Logo */
+#define BTA_OP_FILTER_AGENT (1<<15) /* vCard of Person Representing */
+#define BTA_OP_FILTER_ORG (1<<16) /* Name of Organization */
+#define BTA_OP_FILTER_NOTE (1<<17) /* Comments */
+#define BTA_OP_FILTER_REV (1<<18) /* Revision */
+#define BTA_OP_FILTER_SOUND (1<<19) /* Pronunciation of Name */
+#define BTA_OP_FILTER_URL (1<<20) /* Uniform Resource Locator */
+#define BTA_OP_FILTER_UID (1<<21) /* Unique ID */
+#define BTA_OP_FILTER_KEY (1<<22) /* Public Encryption Key */
+#define BTA_OP_FILTER_NICKNAME (1<<23) /* Nickname */
+#define BTA_OP_FILTER_CATEGORIES (1<<24) /* Categories */
+#define BTA_OP_FILTER_PROID (1<<25) /* Product ID */
+#define BTA_OP_FILTER_CLASS (1<<26) /* Class Information */
+#define BTA_OP_FILTER_SORT_STRING (1<<27) /* String used for sorting operations */
+#define BTA_OP_FILTER_TIME_STAMP (1<<28) /* Time Stamp */
+#define BTA_OP_FILTER_ALL (0)
+
+/* This structure describes an object property, or individual item, inside an object. */
+typedef struct
+{
+ UINT8 *p_data; /* Pointer to property data. */
+ UINT32 parameters; /* Property parameters. */
+ UINT16 name; /* Property name. */
+ UINT16 len; /* Length of data. */
+ UINT8 *p_param; /* Pointer to the Parameters */
+ UINT16 param_len; /* Param Len */
+} tBTA_OP_PROP;
+
+
+/* Access response types */
+#define BTA_OP_ACCESS_ALLOW 0 /* Allow the requested operation */
+#define BTA_OP_ACCESS_FORBID 1 /* Disallow the requested operation */
+#define BTA_OP_ACCESS_NONSUP 2 /* Requested operation is not supported */
+
+typedef UINT8 tBTA_OP_ACCESS;
+
+/* Access event operation types */
+#define BTA_OP_OPER_PUSH 1
+#define BTA_OP_OPER_PULL 2
+
+typedef UINT8 tBTA_OP_OPER;
+
+
+/* Client callback function event */
+#define BTA_OPC_ENABLE_EVT 0 /* Object push client is enabled. */
+#define BTA_OPC_OPEN_EVT 1 /* Connection to peer is open. */
+#define BTA_OPC_PROGRESS_EVT 2 /* push/pull in progres */
+#define BTA_OPC_OBJECT_EVT 3 /* Object Pulled */
+#define BTA_OPC_OBJECT_PSHD_EVT 4 /* Object pushed */
+#define BTA_OPC_CLOSE_EVT 5 /* Connection to peer closed. */
+
+typedef UINT8 tBTA_OPC_EVT;
+
+/* Client callback function result */
+#define BTA_OPC_OK 0 /* Object push succeeded. */
+#define BTA_OPC_FAIL 1 /* Object push failed. */
+#define BTA_OPC_NOT_FOUND 2 /* Object not found. */
+#define BTA_OPC_NO_PERMISSION 3 /* Operation not authorized. */
+#define BTA_OPC_SRV_UNAVAIL 4 /* Service unavaliable */
+#define BTA_OPC_ON_BT 5 /* only used for BTA_OPC_MOVE_CH_EVT */
+#define BTA_OPC_RSP_FORBIDDEN 6 /* Operation forbidden */
+#define BTA_OPC_RSP_NOT_ACCEPTABLE 7 /* Operation not acceptable */
+
+typedef UINT8 tBTA_OPC_STATUS;
+
+/* Structure associated with BTA_OPC_OBJECT_EVT */
+typedef struct
+{
+ char *p_name; /* Object name. */
+ tBTA_OPC_STATUS status;
+} tBTA_OPC_OBJECT;
+
+typedef struct
+{
+ UINT32 obj_size; /* Total size of object (BTA_FS_LEN_UNKNOWN if unknown) */
+ UINT16 bytes; /* Number of bytes read or written since last progress event */
+ tBTA_OP_OPER operation; /* Is progress for Push or Pull */
+} tBTA_OPC_PROGRESS;
+
+/* Union of all client callback structures */
+typedef union
+{
+ tBTA_OPC_OBJECT object;
+ tBTA_OPC_PROGRESS prog;
+ tBTA_OPC_STATUS status;
+} tBTA_OPC;
+
+/* Client callback function */
+typedef void (tBTA_OPC_CBACK)(tBTA_OPC_EVT event, tBTA_OPC *p_data);
+
+/* Server callback function event */
+#define BTA_OPS_ENABLE_EVT 0 /* Object push server is enabled. */
+#define BTA_OPS_OPEN_EVT 1 /* Connection to peer is open. */
+#define BTA_OPS_PROGRESS_EVT 2 /* Object being sent or received. */
+#define BTA_OPS_OBJECT_EVT 3 /* Object has been received. */
+#define BTA_OPS_CLOSE_EVT 4 /* Connection to peer closed. */
+#define BTA_OPS_ACCESS_EVT 5 /* Request for access to push or pull object */
+
+typedef UINT8 tBTA_OPS_EVT;
+
+typedef UINT8 tBTA_OPS_STATUS;
+
+/* Structure associated with BTA_OPS_OBJECT_EVT */
+typedef struct
+{
+ char *p_name; /* Object name. */
+ tBTA_OP_FMT format; /* Object format. */
+} tBTA_OPS_OBJECT;
+
+typedef struct
+{
+ UINT32 obj_size; /* Total size of object (BTA_FS_LEN_UNKNOWN if unknown) */
+ UINT16 bytes; /* Number of bytes read or written since last progress event */
+ tBTA_OP_OPER operation; /* Is progress for Push or Pull */
+} tBTA_OPS_PROGRESS;
+
+typedef struct
+{
+ char *p_name; /* Object name */
+ char *p_type; /* Object type (NULL if not specified) */
+ UINT32 size; /* Object size */
+ tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
+ BD_ADDR bd_addr; /* Address of device */
+ tBTA_OP_OPER oper; /* Operation (push or pull) */
+ tBTA_OP_FMT format; /* Object format */
+} tBTA_OPS_ACCESS;
+
+/* Union of all server callback structures */
+typedef union
+{
+ tBTA_OPS_STATUS status;
+ tBTA_OPS_OBJECT object;
+ tBTA_OPS_PROGRESS prog;
+ tBTA_OPS_ACCESS access;
+ BD_ADDR bd_addr;
+} tBTA_OPS;
+
+/* Server callback function */
+typedef void (tBTA_OPS_CBACK)(tBTA_OPS_EVT event, tBTA_OPS *p_data);
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function BTA_OpcEnable
+**
+** Description Enable the object push client. This function must be
+** called before any other functions in the OP API are called.
+** When the enable operation is complete the callback function
+** will be called with a BTA_OPC_ENABLE_EVT.
+**
+** If single_op is FALSE, the connection stays open after
+** the operation finishes (until BTA_OpcClose is called).
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpcEnable(tBTA_SEC sec_mask, tBTA_OPC_CBACK *p_cback,
+ BOOLEAN single_op, BOOLEAN srm, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_OpcDisable
+**
+** Description Disable the object push client. If the client is currently
+** connected to a peer device the connection will be closed.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpcDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_OpcPush
+**
+** Description Push an object to a peer device. p_name must point to
+** a fully qualified path and file name.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpcPush(BD_ADDR bd_addr, tBTA_OP_FMT format, char *p_name);
+
+/*******************************************************************************
+**
+** Function BTA_OpcPullCard
+**
+** Description Pull default card from peer. p_path must point to a fully
+** qualified path specifying where to store the pulled card.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpcPullCard(BD_ADDR bd_addr, char *p_path);
+
+
+/*******************************************************************************
+**
+** Function BTA_OpcExchCard
+**
+** Description Exchange business cards with a peer device. p_send points to
+** a fully qualified path and file name of vcard to push.
+** p_recv_path points to a fully qualified path specifying
+** where to store the pulled card.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpcExchCard(BD_ADDR bd_addr, char *p_send,
+ char *p_recv_path);
+
+
+/*******************************************************************************
+**
+** Function BTA_OpcClose
+**
+** Description Close the current connection. This function is called if
+** the phone wishes to close the connection before the object
+** push is completed. In a typical connection this function
+** does not need to be called; the connection will be closed
+** automatically when the object push is complete.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpcClose(void);
+
+/*******************************************************************************
+**
+** Function BTA_OpsEnable
+**
+** Description Enable the object push server. This function must be
+** called before any other functions in the OPS API are called.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpsEnable(tBTA_SEC sec_mask, tBTA_OP_FMT_MASK formats,
+ char *p_service_name, tBTA_OPS_CBACK *p_cback,
+ BOOLEAN srm, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_OpsDisable
+**
+** Description Disable the object push server. If the server is currently
+** connected to a peer device the connection will be closed.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpsDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_OpsClose
+**
+** Description Close the current connection. This function is called if
+** the phone wishes to close the connection before the object
+** push is completed.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpsClose(void);
+
+/*******************************************************************************
+**
+** Function BTA_OpsAccessRsp
+**
+** Description Sends a reply to an access request event (BTA_OPS_ACCESS_EVT).
+** This call MUST be made whenever the event occurs.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpsAccessRsp(tBTA_OP_OPER oper, tBTA_OP_ACCESS access,
+ char *p_name);
+
+/*******************************************************************************
+**
+** Function BTA_OpBuildCard
+**
+** Description Build a vCard object. The input to this function is
+** requested format(2.1/3.0), an array of vCard properties
+** and a pointer to memory to store the card.
+** The output is a formatted vCard.
+**
+**
+** Returns BTA_OP_OK if operation successful.
+** BTA_OP_FAIL if invalid property data.
+** BTA_OP_MEM if not enough memory to complete build.
+**
+*******************************************************************************/
+BTA_API extern tBTA_OP_STATUS BTA_OpBuildCard(UINT8 *p_card, UINT16 *p_len,
+ tBTA_OP_FMT fmt,
+ tBTA_OP_PROP *p_prop,
+ UINT8 num_prop);
+
+/*******************************************************************************
+**
+** Function BTA_OpBuildNote
+**
+** Description Build a vNote object. The input to this function is an
+** array of vNote properties and a pointer to memory to store
+** the card. The output is a formatted vNote.
+**
+**
+** Returns BTA_OP_OK if operation successful.
+** BTA_OP_FAIL if invalid property data.
+** BTA_OP_MEM if not enough memory to complete build.
+**
+*******************************************************************************/
+BTA_API extern tBTA_OP_STATUS BTA_OpBuildNote(UINT8 *p_note, UINT16 *p_len,
+ tBTA_OP_PROP *p_prop,
+ UINT8 num_prop);
+
+/*******************************************************************************
+**
+** Function BTA_OpBuildCal
+**
+** Description Build a vCal 1.0 object. The input to this function is an
+** array of vCaalproperties and a pointer to memory to store
+** the card. The output is a formatted vCal.
+**
+**
+** Returns BTA_OP_OK if operation successful.
+** BTA_OP_FAIL if invalid property data.
+** BTA_OP_MEM if not enough memory to complete build.
+**
+*******************************************************************************/
+BTA_API extern tBTA_OP_STATUS BTA_OpBuildCal(UINT8 *p_cal, UINT16 *p_len,
+ tBTA_OP_PROP *p_prop,
+ UINT8 num_prop,
+ tBTA_OP_VCAL vcal_type);
+
+/*******************************************************************************
+**
+** Function BTA_OpParseCard
+**
+** Description Parse a vCard 2.1 object. The input to this function is
+** a pointer to vCard data. The output is an array of parsed
+** vCard properties.
+**
+**
+** Returns BTA_OP_OK if operation successful.
+** BTA_OP_FAIL if invalid property data.
+** BTA_OP_MEM if not enough memory to complete parsing.
+**
+*******************************************************************************/
+BTA_API extern tBTA_OP_STATUS BTA_OpParseCard(tBTA_OP_PROP *p_prop,
+ UINT8 *p_num_prop, UINT8 *p_card,
+ UINT16 len);
+
+/*******************************************************************************
+**
+** Function BTA_OpGetCardProperty
+**
+** Description Get Card property value by name. The input to this function is
+** property name. The output is property value and len
+**
+**
+** Returns BTA_OP_OK if operation successful.
+** BTA_OP_FAIL if invalid property data.
+**
+*******************************************************************************/
+BTA_API extern tBTA_OP_STATUS BTA_OpGetCardProperty(UINT8 *p_value, UINT16 *p_len, tBTA_OP_PROP *p_prop,
+ UINT8 num_prop, UINT8 *p_name);
+
+/*******************************************************************************
+**
+** Function BTA_OpParseNote
+**
+** Description Parse a vNote object. The input to this function is a
+** pointer to vNote data. The output is an array of parsed
+** vNote properties.
+**
+**
+** Returns BTA_OP_OK if operation successful.
+** BTA_OP_FAIL if invalid property data.
+** BTA_OP_MEM if not enough memory to complete parsing.
+**
+*******************************************************************************/
+BTA_API extern tBTA_OP_STATUS BTA_OpParseNote(tBTA_OP_PROP *p_prop,
+ UINT8 *p_num_prop,
+ UINT8 *p_note, UINT16 len);
+
+/*******************************************************************************
+**
+** Function BTA_OpParseCal
+**
+** Description Parse a vCal object. The input to this function is a
+** pointer to vCal data. The output is an array of parsed
+** vCal properties.
+**
+**
+** Returns BTA_OP_OK if operation successful.
+** BTA_OP_FAIL if invalid property data.
+** BTA_OP_MEM if not enough memory to complete parsing.
+**
+*******************************************************************************/
+BTA_API extern tBTA_OP_STATUS BTA_OpParseCal(tBTA_OP_PROP *p_prop,
+ UINT8 *p_num_prop, UINT8 *p_cal,
+ UINT16 len, tBTA_OP_VCAL *p_vcal_type);
+
+/*******************************************************************************
+**
+** Function BTA_OpSetCardPropFilterMask
+**
+** Description Set Property Filter Mask
+**
+**
+** Returns
+**
+*******************************************************************************/
+BTA_API extern void BTA_OpSetCardPropFilterMask(UINT32 mask);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_OP_API_H */
+
diff --git a/bta/include/bta_pan_api.h b/bta/include/bta_pan_api.h
new file mode 100644
index 0000000..83fa40d
--- /dev/null
+++ b/bta/include/bta_pan_api.h
@@ -0,0 +1,187 @@
+/*****************************************************************************
+**
+** Name: bta_pan_api.h
+**
+** Description: This is the public interface file for the Personal
+** Area Networking (PAN) subsystem of BTA, Widcomm's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2004, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_PAN_API_H
+#define BTA_PAN_API_H
+
+#include "bta_api.h"
+#include "pan_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+#define BTA_PAN_SUCCESS 0
+#define BTA_PAN_FAIL 1
+
+typedef UINT8 tBTA_PAN_STATUS;
+
+
+/* PAN Callback events */
+#define BTA_PAN_ENABLE_EVT 0 /* PAN service is enabled. */
+#define BTA_PAN_SET_ROLE_EVT 1 /* PAN roles registered */
+#define BTA_PAN_OPENING_EVT 2 /* Connection is being opened. */
+#define BTA_PAN_OPEN_EVT 3 /* Connection has been opened. */
+#define BTA_PAN_CLOSE_EVT 4 /* Connection has been closed. */
+
+typedef UINT8 tBTA_PAN_EVT;
+
+
+/* pan roles */
+#define BTA_PAN_ROLE_PANU PAN_ROLE_CLIENT
+#define BTA_PAN_ROLE_GN PAN_ROLE_GN_SERVER
+#define BTA_PAN_ROLE_NAP PAN_ROLE_NAP_SERVER
+
+
+typedef UINT8 tBTA_PAN_ROLE;
+
+/* information regarding PAN roles */
+typedef struct
+{
+ char *p_srv_name; /* service name for the PAN role */
+ UINT8 app_id; /* application id */
+ tBTA_SEC sec_mask; /* security setting for the role */
+
+} tBTA_PAN_ROLE_INFO;
+
+
+/* Event associated with BTA_PAN_SET_ROLE_EVT */
+typedef struct
+{
+ tBTA_PAN_ROLE role; /* PAN roles successfully registered */
+} tBTA_PAN_SET_ROLE;
+
+/* Event associated with BTA_PAN_OPENING_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address of peer device. */
+ UINT16 handle; /* Handle associated with this connection. */
+
+} tBTA_PAN_OPENING;
+
+
+/* Event associated with BTA_PAN_OPEN_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* BD address of peer device. */
+ UINT16 handle; /* Handle associated with this connection. */
+ tBTA_PAN_STATUS status; /* status of open event */
+ tBTA_PAN_ROLE local_role; /* Local device PAN role for the connection */
+ tBTA_PAN_ROLE peer_role; /* Peer device PAN role for the connection */
+
+} tBTA_PAN_OPEN;
+
+/* Event associated with BTA_PAN_CLOSE_EVT */
+typedef struct
+{
+ UINT16 handle; /* Handle associated with the connection. */
+} tBTA_PAN_CLOSE;
+
+/* Union of all PAN callback structures */
+typedef union
+{
+ tBTA_PAN_SET_ROLE set_role; /* set_role event */
+ tBTA_PAN_OPEN open; /* Connection has been opened. */
+ tBTA_PAN_OPENING opening; /* Connection being opened */
+ tBTA_PAN_CLOSE close; /* Connection has been closed. */
+} tBTA_PAN;
+
+/* Number of PAN connections */
+#ifndef BTA_PAN_NUM_CONN
+#define BTA_PAN_NUM_CONN 4
+#endif
+
+/* PAN callback */
+typedef void (tBTA_PAN_CBACK)(tBTA_PAN_EVT event, tBTA_PAN *p_data);
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function BTA_PanEnable
+**
+** Description Enable PAN service. This function must be
+** called before any other functions in the PAN API are called.
+** When the enable operation is complete the callback function
+** will be called with a BTA_PAN_ENABLE_EVT.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_PanEnable(tBTA_PAN_CBACK p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_PanDisable
+**
+** Description Disable PAN service.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_PanDisable(void);
+
+
+/*******************************************************************************
+**
+** Function BTA_PanSetRole
+**
+** Description Sets PAN roles. When the enable operation is complete
+** the callback function will be called with a BTA_PAN_SET_ROLE_EVT.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_PanSetRole(tBTA_PAN_ROLE role, tBTA_PAN_ROLE_INFO *p_user_info, tBTA_PAN_ROLE_INFO *p_gn_info,
+ tBTA_PAN_ROLE_INFO *p_nap_info);
+
+
+/*******************************************************************************
+**
+** Function BTA_PanOpen
+**
+** Description Opens a connection to a peer device.
+** When connection is open callback function is called
+** with a BTA_PAN_OPEN_EVT.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void BTA_PanOpen(BD_ADDR bd_addr, tBTA_PAN_ROLE local_role, tBTA_PAN_ROLE peer_role);
+
+
+
+/*******************************************************************************
+**
+** Function BTA_PanClose
+**
+** Description Close a PAN connection to a peer device.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_PanClose(UINT16 handle);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_PAN_API_H */
+
diff --git a/bta/include/bta_pan_ci.h b/bta/include/bta_pan_ci.h
new file mode 100644
index 0000000..cd759d9
--- /dev/null
+++ b/bta/include/bta_pan_ci.h
@@ -0,0 +1,139 @@
+/*****************************************************************************
+**
+** Name: bta_pan_ci.h
+**
+** Description: This is the interface file for pan call-in
+** functions.
+**
+** Copyright (c) 2004, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_PAN_CI_H
+#define BTA_PAN_CI_H
+
+#include "bta_pan_api.h"
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_pan_ci_tx_ready
+**
+** Description This function sends an event to PAN indicating the phone is
+** ready for more data and PAN should call bta_pan_co_tx_path().
+** This function is used when the TX data path is configured
+** to use a pull interface.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_ci_tx_ready(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function bta_pan_ci_rx_ready
+**
+** Description This function sends an event to PAN indicating the phone
+** has data available to send to PAN and PAN should call
+** bta_pan_co_rx_path(). This function is used when the RX
+** data path is configured to use a pull interface.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_ci_rx_ready(UINT16 handle);
+
+/*******************************************************************************
+**
+** Function bta_pan_ci_tx_flow
+**
+** Description This function is called to enable or disable data flow on
+** the TX path. The phone should call this function to
+** disable data flow when it is congested and cannot handle
+** any more data sent by bta_pan_co_tx_write() or
+** bta_pan_co_tx_writebuf(). This function is used when the
+** TX data path is configured to use a push interface.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_ci_tx_flow(UINT16 handle, BOOLEAN enable);
+
+/*******************************************************************************
+**
+** Function bta_pan_ci_rx_writebuf
+**
+** Description This function is called to send data to the phone when
+** the RX path is configured to use a push interface with
+** zero copy. The function sends an event to PAN containing
+** the data buffer. The buffer must be allocated using
+** functions GKI_getbuf() or GKI_getpoolbuf(). The buffer
+** will be freed by BTA; the phone must not free the buffer.
+**
+**
+** Returns TRUE if flow enabled
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_ci_rx_writebuf(UINT16 handle, BD_ADDR src, BD_ADDR dst, UINT16 protocol, BT_HDR *p_buf, BOOLEAN ext);
+
+/*******************************************************************************
+**
+** Function bta_pan_ci_readbuf
+**
+** Description This function is called by the phone to read data from PAN
+** when the TX path is configured to use a pull interface.
+** The phone must free the buffer using function GKI_freebuf() when
+** it is through processing the buffer.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern BT_HDR * bta_pan_ci_readbuf(UINT16 handle, BD_ADDR src, BD_ADDR dst, UINT16 *p_protocol,
+ BOOLEAN* p_ext, BOOLEAN* p_forward);
+
+/*******************************************************************************
+**
+** Function bta_pan_ci_set_pfilters
+**
+** Description This function is called to set protocol filters
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_ci_set_pfilters(UINT16 handle, UINT16 num_filters, UINT16 *p_start_array, UINT16 *p_end_array);
+
+
+/*******************************************************************************
+**
+** Function bta_pan_ci_set_mfilters
+**
+** Description This function is called to set multicast filters
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_ci_set_mfilters(UINT16 handle, UINT16 num_mcast_filters, UINT8 *p_start_array,
+ UINT8 *p_end_array);
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_PAN_CI_H */
+
diff --git a/bta/include/bta_pan_co.h b/bta/include/bta_pan_co.h
new file mode 100644
index 0000000..c8769f4
--- /dev/null
+++ b/bta/include/bta_pan_co.h
@@ -0,0 +1,189 @@
+/*****************************************************************************
+**
+** Name: bta_pan_co.h
+**
+** Description: This is the interface file for data gateway call-out
+** functions.
+**
+** Copyright (c) 2004, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_PAN_CO_H
+#define BTA_PAN_CO_H
+
+#include "bta_pan_api.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+
+
+
+/* BT_HDR buffer offset */
+#define BTA_PAN_MIN_OFFSET PAN_MINIMUM_OFFSET
+
+
+/* Data Flow Mask */
+#define BTA_PAN_RX_PUSH 0x00 /* RX push. */
+#define BTA_PAN_RX_PUSH_BUF 0x01 /* RX push with zero copy. */
+#define BTA_PAN_RX_PULL 0x02 /* RX pull. */
+#define BTA_PAN_TX_PUSH 0x00 /* TX push. */
+#define BTA_PAN_TX_PUSH_BUF 0x10 /* TX push with zero copy. */
+#define BTA_PAN_TX_PULL 0x20 /* TX pull. */
+
+
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function bta_pan_co_init
+**
+** Description This callout function is executed by PAN when a server is
+** started by calling BTA_PanEnable(). This function can be
+** used by the phone to initialize data paths or for other
+** initialization purposes. The function must return the
+** data flow mask as described below.
+**
+**
+** Returns Data flow mask.
+**
+*******************************************************************************/
+BTA_API extern UINT8 bta_pan_co_init(UINT8 *q_level);
+
+/*******************************************************************************
+**
+** Function bta_pan_co_open
+**
+** Description This function is executed by PAN when a connection
+** is opened. The phone can use this function to set
+** up data paths or perform any required initialization.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_co_open(UINT16 handle, UINT8 app_id, tBTA_PAN_ROLE local_role, tBTA_PAN_ROLE peer_role, BD_ADDR peer_addr);
+
+/*******************************************************************************
+**
+** Function bta_pan_co_close
+**
+** Description This function is called by PAN when a connection to a
+** server is closed.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_co_close(UINT16 handle, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_pan_co_tx_path
+**
+** Description This function is called by PAN to transfer data on the
+** TX path; that is, data being sent from BTA to the phone.
+** This function is used when the TX data path is configured
+** to use the pull interface.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_co_tx_path(UINT16 handle, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_pan_co_rx_path
+**
+** Description This function is called by PAN to transfer data on the
+** RX path; that is, data being sent from the phone to BTA.
+** This function is used when the RX data path is configured
+** to use the pull interface.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_co_rx_path(UINT16 handle, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function bta_pan_co_tx_write
+**
+** Description This function is called by PAN to send data to the phone
+** when the TX path is configured to use a push interface.
+** The implementation of this function must copy the data to
+** the phone's memory.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_co_tx_write(UINT16 handle, UINT8 app_id, BD_ADDR src, BD_ADDR dst, UINT16 protocol, UINT8 *p_data,
+ UINT16 len, BOOLEAN ext, BOOLEAN forward);
+
+/*******************************************************************************
+**
+** Function bta_pan_co_tx_writebuf
+**
+** Description This function is called by PAN to send data to the phone
+** when the TX path is configured to use a push interface with
+** zero copy. The phone must free the buffer using function
+** GKI_freebuf() when it is through processing the buffer.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_co_tx_writebuf(UINT16 handle, UINT8 app_id, BD_ADDR src, BD_ADDR dst, UINT16 protocol, BT_HDR *p_buf,
+ BOOLEAN ext, BOOLEAN forward);
+
+
+/*******************************************************************************
+**
+** Function bta_pan_co_rx_flow
+**
+** Description This function is called by PAN to enable or disable
+** data flow on the RX path when it is configured to use
+** a push interface. If data flow is disabled the phone must
+** not call bta_pan_ci_rx_write() or bta_pan_ci_rx_writebuf()
+** until data flow is enabled again.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_co_rx_flow(UINT16 handle, UINT8 app_id, BOOLEAN enable);
+
+
+/*******************************************************************************
+**
+** Function bta_pan_co_filt_ind
+**
+** Description protocol filter indication from peer device
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_co_pfilt_ind(UINT16 handle, BOOLEAN indication, tBTA_PAN_STATUS result,
+ UINT16 len, UINT8 *p_filters);
+
+/*******************************************************************************
+**
+** Function bta_pan_co_mfilt_ind
+**
+** Description multicast filter indication from peer device
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pan_co_mfilt_ind(UINT16 handle, BOOLEAN indication, tBTA_PAN_STATUS result,
+ UINT16 len, UINT8 *p_filters);
+
+#endif /* BTA_PAN_CO_H */
+
diff --git a/bta/include/bta_pbs_api.h b/bta/include/bta_pbs_api.h
new file mode 100644
index 0000000..41198ff
--- /dev/null
+++ b/bta/include/bta_pbs_api.h
@@ -0,0 +1,298 @@
+/*****************************************************************************
+**
+** Name: bta_pbs_api.h
+**
+** Description: This is the public interface file for the phone book access
+** (PB) server subsystem of BTA, Widcomm's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2003-2011, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_PB_API_H
+#define BTA_PB_API_H
+
+#include "bta_api.h"
+#include "btm_api.h"
+#include "bta_sys.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/**************************
+** Common Definitions
+***************************/
+
+/* Profile supported features */
+#define BTA_PBS_SUPF_DOWNLOAD 0x0001
+#define BTA_PBS_SURF_BROWSE 0x0002
+
+/* Profile supported repositories */
+#define BTA_PBS_REPOSIT_LOCAL 0x01 /* Local PhoneBook */
+#define BTA_PBS_REPOSIT_SIM 0x02 /* SIM card PhoneBook */
+
+enum
+{
+ BTA_PBS_VCF_FMT_21 = 0, /* vcard format 2.1 */
+ BTA_PBS_VCF_FMT_30 /* vcard format 3.0 */
+};
+typedef UINT8 tBTA_PBS_VCF_FMT;
+
+enum
+{
+ BTA_PBS_ORDER_INDEX = 0, /* Default. vCard handle */
+ BTA_PBS_ORDER_ALPHA_NUM, /* UTF8 name attribute, LastName then FirstName then MiddleName */
+ BTA_PBS_ORDER_PHONETIC /* UTF8 representation of the sound attribute */
+};
+typedef UINT8 tBTA_PBS_ORDER;
+
+enum
+{
+ BTA_PBS_ATTR_NAME = 0, /* name */
+ BTA_PBS_ATTR_NUMBER, /* number */
+ BTA_PBS_ATTR_SOUND, /* sound */
+ BTA_PBS_ATTR_MAX
+};
+typedef UINT8 tBTA_PBS_ATTR;
+
+#define BTA_PBS_FILTER_VERSION (1<<0) /* vCard Version */
+#define BTA_PBS_FILTER_FN (1<<1) /* Formatted Name */
+#define BTA_PBS_FILTER_N (1<<2) /* Structured Presentation of Name */
+#define BTA_PBS_FILTER_PHOTO (1<<3) /* Associated Image or Photo */
+#define BTA_PBS_FILTER_BDAY (1<<4) /* Birthday */
+#define BTA_PBS_FILTER_ADR (1<<5) /* Delivery Address */
+#define BTA_PBS_FILTER_LABEL (1<<6) /* Delivery */
+#define BTA_PBS_FILTER_TEL (1<<7) /* Telephone Number */
+#define BTA_PBS_FILTER_EMAIL (1<<8) /* Electronic Mail Address */
+#define BTA_PBS_FILTER_MAILER (1<<9) /* Electronic Mail */
+#define BTA_PBS_FILTER_TZ (1<<10) /* Time Zone */
+#define BTA_PBS_FILTER_GEO (1<<11) /* Geographic Position */
+#define BTA_PBS_FILTER_TITLE (1<<12) /* Job */
+#define BTA_PBS_FILTER_ROLE (1<<13) /* Role within the Organization */
+#define BTA_PBS_FILTER_LOGO (1<<14) /* Organization Logo */
+#define BTA_PBS_FILTER_AGENT (1<<15) /* vCard of Person Representing */
+#define BTA_PBS_FILTER_ORG (1<<16) /* Name of Organization */
+#define BTA_PBS_FILTER_NOTE (1<<17) /* Comments */
+#define BTA_PBS_FILTER_REV (1<<18) /* Revision */
+#define BTA_PBS_FILTER_SOUND (1<<19) /* Pronunciation of Name */
+#define BTA_PBS_FILTER_URL (1<<20) /* Uniform Resource Locator */
+#define BTA_PBS_FILTER_UID (1<<21) /* Unique ID */
+#define BTA_PBS_FILTER_KEY (1<<22) /* Public Encryption Key */
+#define BTA_PBS_FILTER_NICKNAME (1<<23) /* Nickname */
+#define BTA_PBS_FILTER_CATEGORIES (1<<24) /* Categories */
+#define BTA_PBS_FILTER_PROID (1<<25) /* Product ID */
+#define BTA_PBS_FILTER_CLASS (1<<26) /* Class Information */
+#define BTA_PBS_FILTER_SORT_STRING (1<<27) /* String used for sorting operations */
+#define BTA_PBS_FILTER_TIME_STAMP (1<<28) /* Time Stamp */
+#define BTA_PBS_FILTER_PROPRIETARY (1<<39) /* Indicates the usage of a proprietary filter */
+#define BTA_PBS_FILTER_ALL (0)
+
+typedef UINT32 tBTA_PBS_FILTER_MASK;
+
+/* Access response types */
+enum
+{
+ BTA_PBS_ACCESS_TYPE_ALLOW = 0, /* Allow the requested operation */
+ BTA_PBS_ACCESS_TYPE_FORBID, /* Disallow the requested operation */
+ BTA_PBS_ACCESS_TYPE_PRECONDITION /* Get vCard Entry operation only (object handle invalid) */
+};
+
+typedef UINT8 tBTA_PBS_ACCESS_TYPE;
+
+#define BTA_PBS_MAX_FILE_LEN 64
+#define BTA_PBS_MAX_CONTACT_NAME_LEN 128
+
+/* Obex application params passed to open callout */
+typedef struct
+{
+ tBTA_PBS_FILTER_MASK filter;
+ tBTA_PBS_VCF_FMT format;
+ UINT16 max_count;
+ UINT16 start_offset;
+} tBTA_PBS_PULLPB_APP_PARAMS;
+
+/* Obex application params passed to getvlist callout */
+typedef struct
+{
+ tBTA_PBS_ORDER order;
+ tBTA_PBS_ATTR attribute;
+ UINT8 p_value[64];
+ UINT16 value_len;
+ UINT16 max_count;
+ UINT16 start_offset;
+} tBTA_PBS_VCARDLIST_APP_PARAMS;
+
+/* VCard Listing structuture Returned by application*/
+typedef struct
+{
+ char handle[BTA_PBS_MAX_FILE_LEN]; /* Contains the vcf name */
+ char name[BTA_PBS_MAX_CONTACT_NAME_LEN]; /* Contains the contacted name of the vlist */
+} tBTA_PBS_VCARDLIST;
+
+/* Access event operation types */
+#define BTA_PBS_OPER_NONE 0
+#define BTA_PBS_OPER_PULL_PB 1
+#define BTA_PBS_OPER_SET_PB 2
+#define BTA_PBS_OPER_PULL_VCARD_LIST 3
+#define BTA_PBS_OPER_PULL_VCARD_ENTRY 4
+
+typedef UINT8 tBTA_PBS_OPER;
+
+/* Object type */
+#define BTA_PBS_NONE_OBJ 0
+#define BTA_PBS_PB_OBJ 1
+#define BTA_PBS_ICH_OBJ 2
+#define BTA_PBS_OCH_OBJ 3
+#define BTA_PBS_MCH_OBJ 4
+#define BTA_PBS_CCH_OBJ 5
+
+typedef UINT8 tBTA_PBS_OBJ_TYPE;
+
+
+/**************************
+** Server Definitions
+***************************/
+/* Extra Debug Code */
+#ifndef BTA_PBS_DEBUG
+#define BTA_PBS_DEBUG FALSE
+#endif
+
+#define BTA_PBS_OK 0
+#define BTA_PBS_FAIL 1
+typedef UINT8 tBTA_PBS_STATUS;
+
+/* Server callback function events */
+#define BTA_PBS_ENABLE_EVT 0 /* PB transfer server is enabled. */
+#define BTA_PBS_OPEN_EVT 1 /* Connection to peer is open. */
+#define BTA_PBS_CLOSE_EVT 2 /* Connection to peer closed. */
+#define BTA_PBS_AUTH_EVT 3 /* Request for Authentication key and realm */
+#define BTA_PBS_ACCESS_EVT 4 /* Request for access to put a file */
+#define BTA_PBS_OPER_CMPL_EVT 5 /* PB operation complete */
+
+typedef UINT8 tBTA_PBS_EVT;
+
+/* Structure associated with BTA_PBS_OPER_CMPL_EVT */
+typedef struct
+{
+ char *p_name; /* file or folder name. */
+ tBTA_PBS_OPER operation;
+ tBTA_PBS_STATUS status;
+} tBTA_PBS_OBJECT;
+
+typedef struct
+{
+ UINT8 *p_userid;
+ UINT8 userid_len;
+ BOOLEAN userid_required; /* TRUE if user ID is required in response (rechallanged) */
+} tBTA_PBS_AUTH;
+
+typedef struct
+{
+ char *p_name; /* file or directory name with fully qualified path */
+ tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
+ tBTA_PBS_OPER oper; /* operation */
+ BD_ADDR bd_addr; /* Address of device */
+} tBTA_PBS_ACCESS;
+
+typedef struct
+{
+ tBTM_BD_NAME dev_name; /* Name of device, "" if unknown */
+ BD_ADDR bd_addr; /* Address of device */
+} tBTA_PBS_OPEN;
+
+typedef union
+{
+ tBTA_PBS_AUTH auth;
+ tBTA_PBS_ACCESS access;
+ tBTA_PBS_OBJECT obj;
+ tBTA_PBS_OPEN open;
+} tBTA_PBS;
+
+/* Server callback function */
+typedef void tBTA_PBS_CBACK(tBTA_PBS_EVT event, tBTA_PBS *p_data);
+
+/**************************
+** Server Functions
+***************************/
+
+/*******************************************************************************
+**
+** Function BTA_PbsEnable
+**
+** Description Enable the phone book access server. This function must be
+** called before any other functions in the PB Server API are called.
+** When the enable operation is complete the callback function
+** will be called with an BTA_PBS_ENABLE_EVT event.
+** Note: Pbs always enable (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_PbsEnable(tBTA_SEC sec_mask, const char *p_service_name,
+ const char *p_root_path, BOOLEAN enable_authen,
+ UINT8 realm_len, UINT8 *p_realm,
+ tBTA_PBS_CBACK *p_cback, UINT8 app_id);
+
+/*******************************************************************************
+**
+** Function BTA_PbsDisable
+**
+** Description Disable the Phone book access server. If the server is currently
+** connected to a peer device the connection will be closed.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_PbsDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_PbsAuthRsp
+**
+** Description Respond to obex client authenticate repond by sending back password to
+** BTA. Called in response to an BTA_PBS_AUTH_EVT event.
+** Used when "enable_authen" is set to TRUE in BTA_PbapsEnable().
+**
+** Note: If the "userid_required" is TRUE in the BTA_PBS_AUTH_EVT
+** event, then p_userid is required, otherwise it is optional.
+**
+** p_password must be less than BTA_PBS_MAX_AUTH_KEY_SIZE (16 bytes)
+** p_userid must be less than OBX_MAX_REALM_LEN (defined in target.h)
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_PbsAuthRsp (char *p_password, char *p_userid);
+
+/*******************************************************************************
+**
+** Function BTA_PbsAccessRsp
+**
+** Description Sends a reply to an access request event (BTA_PBS_ACCESS_EVT).
+** This call MUST be made whenever the event occurs.
+**
+** Parameters oper - operation being accessed.
+** access - BTA_PBS_ACCESS_ALLOW or BTA_PBS_ACCESS_FORBID
+** p_name - path of file or directory to be accessed.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_PbsAccessRsp(tBTA_PBS_OPER oper, tBTA_PBS_ACCESS_TYPE access,
+ char *p_name);
+
+/*******************************************************************************
+**
+** Function BTA_PbsClose
+**
+** Description Close the current connection.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_PbsClose(void);
+#endif
diff --git a/bta/include/bta_pbs_ci.h b/bta/include/bta_pbs_ci.h
new file mode 100644
index 0000000..e44f960
--- /dev/null
+++ b/bta/include/bta_pbs_ci.h
@@ -0,0 +1,93 @@
+/*****************************************************************************
+**
+** Name: bta_pbs_ci.h
+**
+** Description: This is the interface file for phone book access server
+** call-in functions.
+**
+** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_PBS_CI_H
+#define BTA_PBS_CI_H
+
+#include "bta_pbs_co.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+
+
+/*******************************************************************************
+**
+** Function bta_pbs_ci_read
+**
+** Description This function sends an event to BTA indicating the phone has
+** read in the requested amount of data specified in the
+** bta_pbs_co_read() call-out function.
+**
+** Parameters fd - file descriptor passed to the stack in the
+** bta_pbs_ci_open call-in function.
+** num_bytes_read - number of bytes read into the buffer
+** specified in the read callout-function.
+** status - BTA_PBS_CO_OK if get buffer of data,
+** BTA_PBS_CO_FAIL if an error has occurred.
+** final - indicate whether it is the final data
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pbs_ci_read(int fd, UINT16 num_bytes_read,
+ tBTA_PBS_CO_STATUS status, BOOLEAN final);
+
+/*******************************************************************************
+**
+** Function bta_pbs_ci_open
+**
+** Description This function sends an event to BTA indicating the phone has
+** finished opening a pb for reading.
+**
+** Parameters fd - file descriptor passed to the stack in the
+** bta_pbs_ci_open call-in function.
+** status - BTA_PBS_CO_OK if file was opened in mode specified
+** in the call-out function.
+** BTA_PBS_CO_EACCES if the file exists, but contains
+** the wrong access permissions.
+** BTA_PBS_CO_FAIL if any other error has occurred.
+** file_size - The total size of the file
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pbs_ci_open(int fd, tBTA_PBS_CO_STATUS status,
+ UINT32 file_size);
+
+/*******************************************************************************
+**
+** Function bta_pbs_ci_getvlist
+**
+** Description This function sends an event to BTA indicating the phone has
+** finished reading a VCard list entry.
+**
+** Parameters
+** status - BTA_PBS_CO_OK if reading Vcard list entry
+** BTA_PBS_CO_FAIL if any other error has occurred.
+** final - whether it is the last entry
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_pbs_ci_getvlist(tBTA_PBS_CO_STATUS status, BOOLEAN final);
+
+
+#endif
+
diff --git a/bta/include/bta_pbs_co.h b/bta/include/bta_pbs_co.h
new file mode 100644
index 0000000..76ec75a
--- /dev/null
+++ b/bta/include/bta_pbs_co.h
@@ -0,0 +1,160 @@
+/*****************************************************************************
+**
+** Name: bta_pbs_co.h
+**
+** Description: This is the interface file for the phone book access server
+** call-out functions.
+**
+** Copyright (c) 2003-2004, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_PBS_CO_H
+#define BTA_PBS_CO_H
+
+#include "bta_api.h"
+#include "goep_fs.h"
+#include "bta_pbs_api.h"
+
+
+/*****************************************************************************
+** Constants and Data Types
+*****************************************************************************/
+/**************************
+** Common Definitions
+***************************/
+
+/* Status codes returned by call-out functions, or in call-in functions as status */
+#define BTA_PBS_CO_OK GOEP_OK
+#define BTA_PBS_CO_FAIL GOEP_FAIL /* Used to pass all other errors */
+#define BTA_PBS_CO_EACCES GOEP_EACCES
+#define BTA_PBS_CO_EOF GOEP_EOF
+#define BTA_PBS_CO_EODIR GOEP_EODIR
+
+typedef UINT16 tBTA_PBS_CO_STATUS;
+
+#define BTA_PBS_LEN_UNKNOWN GOEP_LEN_UNKNOWN
+#define BTA_PBS_INVALID_FD GOEP_INVALID_FD
+#define BTA_PBS_INVALID_APP_ID (0xFF) /* this app_id is reserved */
+
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+/**************************
+** Common Functions
+***************************/
+/*******************************************************************************
+**
+** Function bta_pbs_co_open
+**
+** Description This function is executed by BTA when a pb file is requested to be opened.
+** The phone book access profile server uses this function to open
+** a file for reading on two phone book access operations
+** (pull pb or pull pb entry)
+**
+** Parameters p_path - path and file name.
+** operation - BTA_PB_OPER_PULL_PB or BTA_PB_OPER_PULL_VCARD_ENTRY
+** p_app_params - obex application params
+**
+**
+** Returns void
+**
+** Note: Upon completion of the request
+** if successful, and an error code (tBTA_PBS_CO_STATUS)
+** are returned in the call-in function, bta_pbs_ci_open().
+**
+*******************************************************************************/
+BTA_API extern void bta_pbs_co_open(const char *p_path, tBTA_PBS_OPER operation, tBTA_PBS_PULLPB_APP_PARAMS *p_app_params);
+
+/*******************************************************************************
+**
+** Function bta_pbs_co_close
+**
+** Description This function is called by BTA when a connection to a
+** client is closed.
+**
+** Parameters fd - file descriptor of file to close.
+**
+**
+** Returns (tBTA_PBS_CO_STATUS) status of the call.
+** [BTA_PBS_CO_OK if successful],
+** [BTA_PBS_CO_FAIL if failed ]
+**
+*******************************************************************************/
+BTA_API extern tBTA_PBS_CO_STATUS bta_pbs_co_close(int fd);
+
+/*******************************************************************************
+**
+** Function bta_pbs_co_get_pbinfo
+**
+** Description This function is called by BTA to inquire about pb size and new missed calls.
+**
+** Parameters p_name: which type of phone book object Eg. telecom/pb.vcf, telecom/ich.vcf
+** operation: phone book operation type Eg. BTA_PBS_OPER_PULL_PB
+** obj_type: phone book repository type Eg. BTA_PBS_MCH_OBJ
+**
+** Returns pb_size - phone book size
+** new_missed_call - new missed calls
+* (tBTA_PBS_CO_STATUS) status of the call.
+** [BTA_PBS_CO_OK if successful],
+** [BTA_PBS_CO_FAIL if failed ]
+**
+*******************************************************************************/
+BTA_API extern tBTA_PBS_CO_STATUS bta_pbs_co_getpbinfo(tBTA_PBS_OPER operation, tBTA_PBS_OBJ_TYPE obj_type, UINT16 *pb_size, UINT16 *new_missed_call);
+
+/*******************************************************************************
+**
+** Function bta_pbs_co_read
+**
+** Description This function is called by BTA to read in data from the
+** previously opened pb file on the phone.
+** the application callin should fill in the PB object needed to be
+** send to the client
+**
+** Parameters fd - file descriptor of file to read from.
+** operation - BTA_PBS_OPER_PULL_PB or BTA_PBS_OPER_PULL_VCARD_ENTRY
+** p_buf - buffer to read the data into.
+** nbytes - number of bytes to read into the buffer.
+**
+**
+** Returns void
+**
+** Note: Upon completion of the request, bta_pbs_ci_read() is
+** called with the buffer of data, along with the number
+** of bytes read into the buffer, and a status.
+**
+*******************************************************************************/
+BTA_API extern void bta_pbs_co_read(int fd, tBTA_PBS_OPER operation, UINT8 *p_buf, UINT16 nbytes);
+
+
+/*******************************************************************************
+**
+** Function bta_pbs_co_getvlist
+**
+** Description This function is called to retrieve a vcard list entry for the
+** specified path.
+** The first/next directory should be filled by application
+** into the location specified by p_entry.
+**
+** Parameters p_path - directory to search
+** p_app_params - Obex application params, NULL if first_item is FALSE
+** first_item - TRUE if first get, FALSE if next getvlist
+** (p_entry contains previous)
+** p_entry(input/output) - Points to prev entry data, the callout application need
+** to fill in with the next entry
+**
+**
+** Returns void
+**
+** Note: Upon completion of the request, bta_pbs_ci_getvlist() is
+** called with the a status and final flag.
+**
+**
+**
+*******************************************************************************/
+BTA_API extern void bta_pbs_co_getvlist(const char *p_path, tBTA_PBS_VCARDLIST_APP_PARAMS *p_app_params,
+ BOOLEAN first_item, tBTA_PBS_VCARDLIST *p_entry);
+
+
+#endif /* BTA_PBS_CO_H */
diff --git a/bta/include/bta_prm_api.h b/bta/include/bta_prm_api.h
new file mode 100644
index 0000000..434888f
--- /dev/null
+++ b/bta/include/bta_prm_api.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+**
+** Name: bta_prm_api.h
+**
+** Description: This is the public interface file for the patch ram
+** subsystem of BTA, Widcomm's
+** Bluetooth application layer for mobile phones.
+**
+** Copyright (c) 2003-2005, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_PRM_API_H
+#define BTA_PRM_API_H
+
+#include "bta_api.h"
+#include "bta_sys.h"
+
+/* callback function */
+typedef void (tBTA_PRM_CBACK) (tBTA_STATUS status);
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function BTA_PatchRam
+**
+** Description Patch Ram function
+**
+** Parameters p_cback - callback to indicate status of download operation.
+** p_name - path and file name of the patch file.
+** - if p_name is NULL, try to use patch data built into code.
+** fs_app_id - app_id used by bta file system callout functions
+** - to distinguish between applications which uses FS.
+** address - address of patch ram
+**
+**
+** Returns void
+**
+**
+*******************************************************************************/
+BTA_API extern void BTA_PatchRam(tBTA_PRM_CBACK *p_cback, const char *p_name,
+ UINT8 fs_app_id, UINT32 address);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/bta/include/bta_sc_api.h b/bta/include/bta_sc_api.h
new file mode 100644
index 0000000..90e673f
--- /dev/null
+++ b/bta/include/bta_sc_api.h
@@ -0,0 +1,193 @@
+/*****************************************************************************
+**
+** Name: bta_sc_api.c
+**
+** Description: This is the implementation of the API for the SIM
+** Card (SC) server subsystem of BTA, Widcomm's Bluetooth
+** application layer for mobile phones.
+**
+** Copyright (c) 2004, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_SC_API_H
+#define BTA_SC_API_H
+
+#include "bta_api.h"
+#include "sap_api.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+/* Status of SIM card (for BTA_ScCardStatus) */
+#define BTA_SC_CARD_UNKNOWN_ERROR SAP_CARD_UNKNOWN_ERROR /* Unknown problem with SIM card. */
+#define BTA_SC_CARD_RESET SAP_CARD_RESET /* SIM inserted and powered on prior to SIM Access Profile connection. */
+#define BTA_SC_CARD_NOT_ACCESSIBLE SAP_CARD_NOT_ACCESSIBLE /* SIM inserted, but not accessible. */
+#define BTA_SC_CARD_REMOVED SAP_CARD_REMOVED /* SIM not inserted, or has been removed. */
+#define BTA_SC_CARD_INSERTED SAP_CARD_INSERTED /* SIM inserted, but not powered on. Client needs to power on the SIM before using it. */
+#define BTA_SC_CARD_RECOVERED SAP_CARD_RECOVERED /* Previously not accessible card has been made accessible again, and is powered on by server. */
+typedef UINT8 tBTA_SC_CARD_STATUS;
+
+/* Flags describing Card Reader options (for reader_flags parameter of BTA_ScEnable) */
+#define BTA_SC_READER_FL_REMOVABLE 0x0001
+typedef UINT16 tBTA_SC_READER_FLAGS;
+
+/* Status of card reader (for BTA_ScReaderStatus) */
+#define BTA_SC_READER_STATUS_ATTACHED 0
+#define BTA_SC_READER_STATUS_REMOVED 1
+typedef UINT8 tBTA_SC_READER_STATUS;
+
+
+/* Disconnection type (for BTA_Disconnect) */
+#define BTA_SC_DISC_GRACEFUL SAP_DISCONNECT_GRACEFUL
+#define BTA_SC_DISC_IMMEDIATE SAP_DISCONNECT_IMMEDIATE
+typedef UINT8 tBTA_SC_DISCONNECT_TYPE;
+
+/* Server callback function events */
+#define BTA_SC_ENABLE_EVT 0 /* SIM Access server is enabled. */
+#define BTA_SC_OPEN_EVT 1 /* Connection to peer is open. */
+#define BTA_SC_CLOSE_EVT 2 /* Connection to peer closed. */
+// btla-specific ++
+#define BTA_SC_DISABLE_EVT 3 /* SIM Access server is disabled. */
+// btla-specific --
+typedef UINT8 tBTA_SC_EVT;
+
+
+/* Results codes for use with call-in functions */
+#define BTA_SC_RESULT_OK SAP_RESULT_OK /* Request processed correctly. */
+#define BTA_SC_RESULT_ERROR SAP_RESULT_ERROR /* Error - no reason specified. */
+#define BTA_SC_RESULT_CARD_NOT_ACCESSIBLE SAP_RESULT_CARD_NOT_ACCESSIBLE /* Error - card inserted but not accessible. */
+#define BTA_SC_RESULT_CARD_POWERED_OFF SAP_RESULT_CARD_POWERED_OFF /* Error - card is powered off. */
+#define BTA_SC_RESULT_CARD_REMOVED SAP_RESULT_CARD_REMOVED /* Error - card is not inserted. */
+#define BTA_SC_RESULT_CARD_ALREADY_ON SAP_RESULT_CARD_ALREADY_ON /* Error - card already turned on. */
+#define BTA_SC_RESULT_DATA_NOT_AVAILABLE SAP_RESULT_DATA_NOT_AVAILABLE /* Error - data not available. */
+/* Request codes for use with call-in functions */
+#define BTA_SC_REQUEST_APDU (BTA_SC_RESULT_OK + 10)
+typedef UINT8 tBTA_SC_RESULT;
+
+
+/* Results codes for sim reset */
+#define BTA_SC_RESET_RESULT_OK 0 /* Reset successful */
+#define BTA_SC_RESET_RESULT_ERROR 1 /* Reset failed */
+#define BTA_SC_RESET_RESULT_OK_ONGOING_CALL 2 /* Ongoing call (will reset after call is released) */
+typedef UINT8 tBTA_SC_RESET_RESULT;
+
+/**************************
+** Structure definitions
+***************************/
+/* Event data for BTA_SC_OPEN_EVT */
+typedef struct
+{
+ BD_ADDR bd_addr; /* Client bd address */
+} tBTA_SC_OPEN;
+
+
+/* Union of data types for BTA_SC callback function */
+typedef union
+{
+ tBTA_SC_OPEN open;
+} tBTA_SC;
+
+/* Server callback function */
+typedef void tBTA_SC_CBACK (tBTA_SC_EVT event, tBTA_SC *p_data);
+
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/*******************************************************************************
+**
+** Function BTA_ScEnable
+**
+** Description Enable the SIM Card server. This function must be
+** called before any other functions in the SC API are called.
+** When the enable operation is complete the callback function
+** will be called with a BTA_SC_ENABLE_EVT.
+**
+** Parameters
+** sec_mask Security options
+** p_service_name Service name for SDP record
+** reader_id SIM Card Reader ID (for TRANSFER_CARD_READER_STATUS requests)
+** reader_flags Flags describing card reader
+** msg_size_min Min message size for SIM APDU commands
+** msg_size_max Max message size for SIM APDU commands
+** p_cback Callback for BTA_SC event notification
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_ScEnable(tBTA_SEC sec_mask, const char *p_service_name,
+ UINT8 reader_id, tBTA_SC_READER_FLAGS reader_flags,
+ UINT16 msg_size_min, UINT16 msg_size_max,
+ tBTA_SC_CBACK *p_cback);
+
+/*******************************************************************************
+**
+** Function BTA_ScDisable
+**
+** Description Disable the SIM Card server.
+**
+** Parameters none
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_ScDisable(void);
+
+/*******************************************************************************
+**
+** Function BTA_ScClose
+**
+** Description Close client connection.
+**
+** Parameters
+** type Type of disconnection desired (BTA_SC_DISC_GRACEFUL or
+** BTA_SC_DISC_IMMEDIATE)
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_ScClose(tBTA_SC_DISCONNECT_TYPE type);
+
+
+/*******************************************************************************
+**
+** Function BTA_ScCardStatus
+**
+** Description Notify client of change in SIM card status
+**
+** Parameters
+** status New status
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_ScCardStatus(tBTA_SC_CARD_STATUS status);
+
+
+/*******************************************************************************
+**
+** Function BTA_ScReaderStatus
+**
+** Description Notify client of change in SIM card reader status
+**
+** Parameters
+** status New status
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void BTA_ScReaderStatus(tBTA_SC_READER_STATUS status);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_SC_API_H */
diff --git a/bta/include/bta_sc_ci.h b/bta/include/bta_sc_ci.h
new file mode 100644
index 0000000..10b11e6
--- /dev/null
+++ b/bta/include/bta_sc_ci.h
@@ -0,0 +1,111 @@
+/*****************************************************************************
+**
+** Name: bta_sc_ci.h
+**
+** Description: This is the interface file for SIM Access server
+** call-in functions.
+**
+** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_SC_CI_H
+#define BTA_SC_CI_H
+
+#include "bta_sc_api.h"
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_sc_ci_apdu
+**
+** Description This function sends an event to SC to indicate the APDU request
+** has been completed or requested
+**
+** Parameters
+** result result of operation or request of operation
+** p_apdu response buffer for APDU command (if result=BTA_SC_RESULT_OK)
+** or request buffer for APDU command (if result=BTA_SC_REQUEST_APDU)
+** apdulen length of response or request buffer
+** is_apdu_7816 TRUE if format of apdu data is APDU7816
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_ci_apdu(tBTA_SC_RESULT result, UINT8 *p_apdu, UINT16 apdulen, BOOLEAN is_apdu_7816);
+
+/*******************************************************************************
+**
+** Function bta_sc_ci_atr
+**
+** Description This function sends an event to SC to indicate the ATR request
+** has been completed
+**
+** Parameters
+** result result of operation
+** p_atr response buffer for ATR request (if result=BTA_SC_RESULT_OK)
+** atrlen length of response buffer
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_ci_atr(tBTA_SC_RESULT result, UINT8 *p_atr, UINT16 atrlen);
+
+/*******************************************************************************
+**
+** Function bta_sc_ci_sim_on
+**
+** Description This function sends an event to SC to indicate the SIM_ON request
+** has been completed
+**
+** Parameters
+** result result of operation
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_ci_sim_on(tBTA_SC_RESULT result);
+
+/*******************************************************************************
+**
+** Function bta_sc_ci_sim_off
+**
+** Description This function sends an event to SC to indicate the SIM_OFF request
+** has been completed
+**
+** Parameters
+** result result of operation
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_ci_sim_off(tBTA_SC_RESULT result);
+
+/*******************************************************************************
+**
+** Function bta_sc_ci_sim_reset
+**
+** Description This function sends an event to SC to indicate the SIM_RESET request
+** has been completed
+**
+** Parameters
+** result result of operation
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_ci_sim_reset(tBTA_SC_RESET_RESULT result);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_SC_CI_H */
+
diff --git a/bta/include/bta_sc_co.h b/bta/include/bta_sc_co.h
new file mode 100644
index 0000000..a088823
--- /dev/null
+++ b/bta/include/bta_sc_co.h
@@ -0,0 +1,153 @@
+/*****************************************************************************
+**
+** Name: bta_sc_co.h
+**
+** Description: This is the interface file for the SIM access
+** server call-out functions.
+**
+** Copyright (c) 2003, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_SC_CO_H
+#define BTA_SC_CO_H
+
+#include "bta_sc_api.h"
+
+/*****************************************************************************
+** Constants and Data Types
+*****************************************************************************/
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_sc_co_sim_opem
+**
+** Description Called when client connection is opened, in case any special
+** handling or intialization of the SIM is required.
+**
+** Parameters
+** None.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_co_sim_open(void);
+
+/*******************************************************************************
+**
+** Function bta_sc_co_sim_close
+**
+** Description Called when client connection is closed.
+**
+** Parameters
+** None.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_co_sim_close(void);
+
+/*******************************************************************************
+**
+** Function bta_sc_co_sim_reset
+**
+** Description This function is called by BTA to reset the SIM card
+**
+** Once SIM has been turned reset, call bta_sc_ci_sim_reset().
+**
+** Parameters
+** None.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_co_sim_reset(void);
+
+/*******************************************************************************
+**
+** Function bta_sc_co_sim_off
+**
+** Description This function is called by BTA to turn the SIM card off
+**
+** Once SIM has been turned on, call bta_sc_ci_sim_on().
+**
+** Parameters
+** None.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_co_sim_off(void);
+
+/*******************************************************************************
+**
+** Function bta_sc_co_sim_on
+**
+** Description This function is called by BTA to turn the SIM card on
+**
+** Once SIM has been turned on, call bta_sc_ci_sim_on().
+**
+** Parameters
+** None.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_co_sim_on(void);
+
+/*******************************************************************************
+**
+** Function bta_sc_co_atr
+**
+** Description This function is called by BTA to retrieve ATR information
+** (operational requirements of the SIM, as described in
+** section 5.8 of GSM 11.11)
+**
+** Once the ATR information is retrieved, call bta_sc_ci_atr().
+**
+** Parameters
+** None.
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_co_atr(void);
+
+/*******************************************************************************
+**
+** Function bta_sc_co_apdu
+**
+** Description This function is called by BTA to to transfer APDU command
+** messages to the SIM. Generally used for selecting, storing
+** and retrieving data from the SIM.
+**
+** Once the command has been completed, call bta_sc_ci_apdu()
+** with the result.
+**
+** Parameters
+** p_apdu_req Pointer to the APDU message from the client. Format
+** is described in section 9 of GSM 11.11
+**
+** req_len Length of APDU message.
+**
+** rsp_maxlen Maximum length of response message allowed by client
+** (negotiated during CONNECT_REQ)
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API extern void bta_sc_co_apdu(UINT8 *p_apdu_req, UINT16 req_len, UINT16 rsp_maxlen, BOOLEAN is_apdu_7816);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_SC_CO_H */
diff --git a/bta/include/bta_sys_ci.h b/bta/include/bta_sys_ci.h
new file mode 100644
index 0000000..48cfab1
--- /dev/null
+++ b/bta/include/bta_sys_ci.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+**
+** Name: bta_sys_ci.h
+**
+** Description: This is the interface file for system call-in
+** functions.
+**
+** Copyright (c) 2010, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_SYS_CI_H
+#define BTA_SYS_CI_H
+
+#include "bta_api.h"
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*******************************************************************************
+**
+** Function bta_sys_hw_ci_enabled
+**
+** Description This function must be called in response to function
+** bta_sys_hw_co_enable(), when HW is indeed enabled
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void bta_sys_hw_ci_enabled(tBTA_SYS_HW_MODULE module );
+
+
+/*******************************************************************************
+**
+** Function bta_sys_hw_ci_disabled
+**
+** Description This function must be called in response to function
+** bta_sys_hw_co_disable() when HW is really OFF
+**
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void bta_sys_hw_ci_disabled( tBTA_SYS_HW_MODULE module );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/bta/include/bta_sys_co.h b/bta/include/bta_sys_co.h
new file mode 100644
index 0000000..2b82153
--- /dev/null
+++ b/bta/include/bta_sys_co.h
@@ -0,0 +1,47 @@
+/*****************************************************************************
+**
+** Name: bta_sys_co.h
+**
+** Description: This is the interface file for system callout
+** functions.
+**
+** Copyright (c) 2010, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef BTA_SYS_CO_H
+#define BTA_SYS_CO_H
+
+#include "bta_sys.h"
+
+
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+
+
+/*******************************************************************************
+**
+** Function bta_sys_hw_co_enable
+**
+** Description This function is called by the stack to power up the HW
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void bta_sys_hw_co_enable( tBTA_SYS_HW_MODULE module );
+
+/*******************************************************************************
+**
+** Function bta_sys_hw_co_disable
+**
+** Description This function is called by the stack to power down the HW
+**
+** Returns void
+**
+*******************************************************************************/
+BTA_API void bta_sys_hw_co_disable( tBTA_SYS_HW_MODULE module );
+
+
+#endif
diff --git a/bta/include/ptim.h b/bta/include/ptim.h
new file mode 100644
index 0000000..35082a0
--- /dev/null
+++ b/bta/include/ptim.h
@@ -0,0 +1,86 @@
+/*****************************************************************************
+**
+** Name: ptim.h
+**
+** Description: Protocol timer services.
+**
+** Copyright (c) 2003-2006, Broadcom Corp., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef PTIM_H
+#define PTIM_H
+
+#include "gki.h"
+
+/*****************************************************************************
+** Constants and data types
+*****************************************************************************/
+
+typedef struct
+{
+ TIMER_LIST_Q timer_queue; /* GKI timer queue */
+ INT32 period; /* Timer period in milliseconds */
+ UINT32 last_gki_ticks; /* GKI ticks since last time update called */
+ UINT8 timer_id; /* GKI timer id */
+} tPTIM_CB;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function ptim_init
+**
+** Description Initialize a protocol timer service control block.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void ptim_init(tPTIM_CB *p_cb, UINT16 period, UINT8 timer_id);
+
+/*******************************************************************************
+**
+** Function ptim_timer_update
+**
+** Description Update the protocol timer list and handle expired timers.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void ptim_timer_update(tPTIM_CB *p_cb);
+
+/*******************************************************************************
+**
+** Function ptim_start_timer
+**
+** Description Start a protocol timer for the specified amount
+** of time in milliseconds.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void ptim_start_timer(tPTIM_CB *p_cb, TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout);
+
+/*******************************************************************************
+**
+** Function ptim_stop_timer
+**
+** Description Stop a protocol timer.
+**
+** Returns void
+**
+*******************************************************************************/
+extern void ptim_stop_timer(tPTIM_CB *p_cb, TIMER_LIST_ENT *p_tle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PTIM_H */
diff --git a/bta/include/utl.h b/bta/include/utl.h
new file mode 100644
index 0000000..392d239
--- /dev/null
+++ b/bta/include/utl.h
@@ -0,0 +1,156 @@
+/*****************************************************************************
+**
+** Name: utl.h
+**
+** Description: Basic utility functions.
+**
+** Copyright (c) 2003-2004, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+#ifndef UTL_H
+#define UTL_H
+
+#include "data_types.h"
+
+/*****************************************************************************
+** Constants
+*****************************************************************************/
+/*** class of device settings ***/
+#define BTA_UTL_SET_COD_MAJOR_MINOR 0x01
+#define BTA_UTL_SET_COD_SERVICE_CLASS 0x02 /* only set the bits in the input */
+#define BTA_UTL_CLR_COD_SERVICE_CLASS 0x04
+#define BTA_UTL_SET_COD_ALL 0x08 /* take service class as the input (may clear some set bits!!) */
+#define BTA_UTL_INIT_COD 0x0a
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+
+/** for utl_set_device_class() **/
+typedef struct
+{
+ UINT8 minor;
+ UINT8 major;
+ UINT16 service;
+} tBTA_UTL_COD;
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function utl_str2int
+**
+** Description This utility function converts a character string to an
+** integer. Acceptable values in string are 0-9. If invalid
+** string or string value too large, -1 is returned.
+**
+**
+** Returns Integer value or -1 on error.
+**
+*******************************************************************************/
+extern INT16 utl_str2int(const char *p_s);
+
+/*******************************************************************************
+**
+** Function utl_strucmp
+**
+** Description This utility function compares two strings in uppercase.
+** String p_s must be uppercase. String p_t is converted to
+** uppercase if lowercase. If p_s ends first, the substring
+** match is counted as a match.
+**
+**
+** Returns 0 if strings match, nonzero otherwise.
+**
+*******************************************************************************/
+extern int utl_strucmp(const char *p_s, const char *p_t);
+
+/*******************************************************************************
+**
+** Function utl_itoa
+**
+** Description This utility function converts a UINT16 to a string. The
+** string is NULL-terminated. The length of the string is
+** returned.
+**
+**
+** Returns Length of string.
+**
+*******************************************************************************/
+extern UINT8 utl_itoa(UINT16 i, char *p_s);
+
+/*******************************************************************************
+**
+** Function utl_freebuf
+**
+** Description This function calls GKI_freebuf to free the buffer passed
+** in, if buffer pointer is not NULL, and also initializes
+** buffer pointer to NULL.
+**
+**
+** Returns Nothing.
+**
+*******************************************************************************/
+extern void utl_freebuf(void **p);
+
+/*******************************************************************************
+**
+** Function utl_set_device_class
+**
+** Description This function updates the local Device Class.
+**
+** Parameters:
+** p_cod - Pointer to the device class to set to
+**
+** cmd - the fields of the device class to update.
+** BTA_UTL_SET_COD_MAJOR_MINOR, - overwrite major, minor class
+** BTA_UTL_SET_COD_SERVICE_CLASS - set the bits in the input
+** BTA_UTL_CLR_COD_SERVICE_CLASS - clear the bits in the input
+** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class
+** BTA_UTL_INIT_COD - overwrite major, minor, and service class
+**
+** Returns TRUE if successful, Otherwise FALSE
+**
+*******************************************************************************/
+extern BOOLEAN utl_set_device_class(tBTA_UTL_COD *p_cod, UINT8 cmd);
+
+/*******************************************************************************
+**
+** Function utl_isintstr
+**
+** Description This utility function checks if the given string is an
+** integer string or not
+**
+**
+** Returns TRUE if successful, Otherwise FALSE
+**
+*******************************************************************************/
+extern BOOLEAN utl_isintstr(const char *p_s);
+
+/*******************************************************************************
+**
+** Function utl_isdialstr
+**
+** Description This utility function checks if the given string contains
+** only dial digits or not
+**
+**
+** Returns TRUE if successful, Otherwise FALSE
+**
+*******************************************************************************/
+extern BOOLEAN utl_isdialstr(const char *p_s);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* UTL_H */