From ee29c25b29eaa4fac4e897442634b69ecc8d8125 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 28 Mar 2024 14:32:49 +1100 Subject: Fork ESP-IDF's bluetooth component i want better sbc encoding, and no cla will stop me --- lib/bt/host/bluedroid/bta/include/bta/bta_ag_api.h | 630 ++++ lib/bt/host/bluedroid/bta/include/bta/bta_ag_co.h | 163 + lib/bt/host/bluedroid/bta/include/bta/bta_api.h | 3155 ++++++++++++++++++++ lib/bt/host/bluedroid/bta/include/bta/bta_ar_api.h | 144 + lib/bt/host/bluedroid/bta/include/bta/bta_av_api.h | 874 ++++++ lib/bt/host/bluedroid/bta/include/bta/bta_av_ci.h | 77 + lib/bt/host/bluedroid/bta/include/bta/bta_av_co.h | 393 +++ lib/bt/host/bluedroid/bta/include/bta/bta_av_sbc.h | 222 ++ lib/bt/host/bluedroid/bta/include/bta/bta_dm_ci.h | 68 + lib/bt/host/bluedroid/bta/include/bta/bta_dm_co.h | 218 ++ .../host/bluedroid/bta/include/bta/bta_gap_bt_co.h | 21 + .../host/bluedroid/bta/include/bta/bta_gatt_api.h | 1580 ++++++++++ .../bluedroid/bta/include/bta/bta_gatt_common.h | 28 + .../host/bluedroid/bta/include/bta/bta_gattc_ci.h | 117 + .../host/bluedroid/bta/include/bta/bta_gattc_co.h | 140 + .../host/bluedroid/bta/include/bta/bta_gatts_co.h | 88 + lib/bt/host/bluedroid/bta/include/bta/bta_hd_api.h | 295 ++ .../bluedroid/bta/include/bta/bta_hf_client_api.h | 418 +++ .../bluedroid/bta/include/bta/bta_hf_client_co.h | 107 + .../host/bluedroid/bta/include/bta/bta_hfp_defs.h | 39 + lib/bt/host/bluedroid/bta/include/bta/bta_hh_api.h | 565 ++++ lib/bt/host/bluedroid/bta/include/bta/bta_hh_co.h | 132 + lib/bt/host/bluedroid/bta/include/bta/bta_jv_api.h | 972 ++++++ lib/bt/host/bluedroid/bta/include/bta/bta_jv_co.h | 55 + .../host/bluedroid/bta/include/bta/bta_sdp_api.h | 168 ++ lib/bt/host/bluedroid/bta/include/bta/bta_sys.h | 292 ++ lib/bt/host/bluedroid/bta/include/bta/utl.h | 184 ++ 27 files changed, 11145 insertions(+) create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_ag_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_ag_co.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_ar_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_av_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_av_ci.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_av_co.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_av_sbc.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_dm_ci.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_dm_co.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_gap_bt_co.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_gatt_common.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_gattc_ci.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_gattc_co.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_gatts_co.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_hd_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_hf_client_co.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_hfp_defs.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_hh_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_hh_co.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_jv_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_jv_co.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_sdp_api.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/bta_sys.h create mode 100644 lib/bt/host/bluedroid/bta/include/bta/utl.h (limited to 'lib/bt/host/bluedroid/bta/include') diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_ag_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_ag_api.h new file mode 100644 index 00000000..35bb6ab5 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_ag_api.h @@ -0,0 +1,630 @@ +/****************************************************************************** + * + * Copyright (C) 2003-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the public interface file for the audio gateway (AG) subsystem + * of BTA, Broadcom's Bluetooth application layer for mobile phones. + * + ******************************************************************************/ +#ifndef BTA_AG_API_H +#define BTA_AG_API_H + +#include "bta_api.h" +#include "bta_hfp_defs.h" +#include "esp_hf_defs.h" + +#if (BTA_AG_INCLUDED == TRUE) +/***************************************************************************** +** 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 */ +/* HFP 1.7+ */ +#define BTA_AG_FEAT_HF_IND 0x00000400 /* HF Indicators */ +#define BTA_AG_FEAT_ESCO_S4 0x00000800 /* eSCO S4 Setting Supported */ + +/* 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 */ +#define BTA_AG_FEAT_VOIP 0x00100000 /* VoIP call */ +typedef UINT32 tBTA_AG_FEAT; + +/* 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 */ +/* HFP 1.7+ */ +#define BTA_AG_PEER_FEAT_HF_IND 0x0100 /* HF Indicators */ +#define BTA_AG_PEER_FEAT_ESCO_S4 0x0200 /* eSCO S4 Setting Supported */ +typedef UINT16 tBTA_AG_PEER_FEAT; + +/* Proprietary features: using bits after 12 */ +/* Pass unknown AT command responses to application */ +#define BTA_AG_PEER_FEAT_UNAT 0x1000 +#define BTA_AG_PEER_FEAT_VOIP 0x2000 /* VoIP call */ + +/* AG extended call handling - masks not related to any spec */ +#define BTA_AG_CLIENT_CHLD_REL 0x00000001 /* 0 Release waiting call or held calls */ +#define BTA_AG_CLIENT_CHLD_REL_ACC 0x00000002 /* 1 Release active calls and accept other (waiting or held) cal */ +#define BTA_AG_CLIENT_CHLD_REL_X 0x00000004 /* 1x Release x call*/ +#define BTA_AG_CLIENT_CHLD_HOLD_ACC 0x00000008 /* 2 Active calls on hold and accept other call */ +#define BTA_AG_CLIENT_CHLD_PRIV_X 0x00000010 /* 2x Active multiparty call on hold except call x */ +#define BTA_AG_CLIENT_CHLD_MERGE 0x00000020 /* 3 Add held call to multiparty */ +#define BTA_AG_CLIENT_CHLD_MERGE_DETACH 0x00000040 /* 4 Add held call to multiparty */ +typedef UINT16 tBTA_AG_CHLD_FEAT; + +/* HFP peer supported codec masks */ +// TODO(google) This should use common definitions +// in hci/include/hci_audio.h +#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; + +/* AG parse mode */ +#define BTA_AG_PARSE 0 /* Perform AT command parsing in AG */ +#define BTA_AG_PASS_THROUGH 1 /* Pass data directly to phones 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 +/* It is safe to use the same value as BTA_AG_HANDLE_ALL + * HANDLE_ALL is used for delivering indication + * SCO_NO_CHANGE is used for changing sco behavior + * They donot interfere with each other + */ +#define BTA_AG_HANDLE_SCO_NO_CHANGE 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 AT+BSIR */ +#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 +CIEV<...> */ +#define BTA_AG_BVRA_RES 6 /* Update voice recognition state for AT+BVRA */ +#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 AT+CLCC */ +#define BTA_AG_COPS_RES 10 /* Read network operator for AT+COPS */ +#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 for AT+CCWA */ +#define BTA_AG_OUT_CALL_ORIG_RES 14 /* Outgoing phone call origination AT+ATD*/ +#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 AT+CHUP */ +#define BTA_AG_IN_CALL_HELD_RES 19 /* Incoming call held AT+CHLD */ +#define BTA_AG_UNAT_RES 20 /* Response to unknown AT command event AT+UNAT */ +#define BTA_AG_MULTI_CALL_RES 21 /* SLC at three way call */ +typedef UINT8 tBTA_AG_RES; + +/* 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 */ +#if (BTM_WBS_INCLUDED == TRUE ) +#define BTA_AG_WBS_EVT 31 /* SCO codec nego */ +#endif +#define BTA_AG_AUDIO_MSBC_OPEN_EVT 32 /* Audio connection with mSBC codec open */ + +#define BTA_AG_PKT_NUMS_GET_EVT 33 /* AG packet status nums */ + +/* Values below are for HFP only */ +#define BTA_AG_AT_A_EVT 10 /* Answer a incoming 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 Current Operator Name on AG */ +#define BTA_AG_AT_UNAT_EVT 24 /* Unknown AT command */ +#define BTA_AG_AT_CBC_EVT 25 /* Indicator Update */ +#define BTA_AG_AT_BAC_EVT 26 /* avablable codec */ +#define BTA_AG_AT_BCS_EVT 27 /* Codec select */ +typedef UINT8 tBTA_AG_EVT; + +/* 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 */ +typedef UINT8 tBTA_AG_ERR_TYPE; + +#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 */ +typedef UINT8 tBTA_AG_AT_RESULT_TYPE; + +/* 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) */ +typedef UINT8 tBTA_AG_BTRH_TYPE; + +/* 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 + +/* 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 */ +typedef UINT16 tBTA_AG_IND_TYPE; + +/* 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 */ + +/* data associated with BTA_AG_IND_RES */ +typedef struct +{ + tBTA_AG_IND_TYPE type; + UINT16 value; +} tBTA_AG_IND; + +/* data type for BTA_AgResult() */ +typedef struct +{ + char str[BTA_AG_AT_MAX_LEN+1]; /* used for cops,clcc,cnum... */ + tBTA_AG_IND ind; /* used for indicator type */ + UINT16 num; /* used for codec state */ + UINT16 audio_handle; /* used for audio path */ + 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; + +/* data associated with most non-AT events */ +typedef struct +{ + UINT16 handle; + UINT8 app_id; + tBTA_AG_STATUS status; + UINT16 sync_conn_handle; +} tBTA_AG_HDR; + +/* data associated with BTA_AG_REGISTER_EVT */ +typedef struct +{ + tBTA_AG_HDR hdr; +} 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_OPEN; + +/* data associated with BTA_AG_CLOSE_EVT */ +typedef struct +{ + tBTA_AG_HDR hdr; + BD_ADDR bd_addr; +} tBTA_AG_CLOSE; + +/* data associated with BTA_AG_CONN_EVT */ +typedef struct +{ + tBTA_AG_HDR hdr; + tBTA_AG_PEER_FEAT peer_feat; + BD_ADDR bd_addr; + tBTA_AG_PEER_CODEC peer_codec; + tBTA_AG_CHLD_FEAT chld_feat; +} tBTA_AG_CONN; + +/* data associated with AT command event */ +typedef struct +{ + tBTA_AG_HDR hdr; + BD_ADDR bd_addr; + char str[BTA_AG_AT_MAX_LEN+1]; + UINT16 num; /* voice recognition state*/ + UINT8 idx; /* call number used by CLCC and CHLD */ + UINT16 value; +} tBTA_AG_VAL; + +/* data associated with BTA_AG_CLIP_EVT and BTA_AG_CCWA_EVT*/ +#define BTA_AG_NUMBER_LEN 32 +typedef struct { + char number[BTA_AG_NUMBER_LEN + 1]; +} tBTA_AG_NUMBER; + +/* data associated with BTA_HF_CLIENT_OPERATOR_NAME_EVT */ +#define BTA_AG_COPS_LEN 16 +typedef struct { + char name[BTA_AG_COPS_LEN + 1]; +} tBTA_AG_COPS; + +/* data associated with BTA_AG_AT_RESULT_EVT event */ +typedef struct { + tBTA_AG_AT_RESULT_TYPE type; + UINT16 cme; +} tBTA_AG_AT_RESULT; + +/* data associated with BTA_AG_CLCC_EVT event */ +typedef struct { + UINT32 idx; + BOOLEAN inc; + UINT8 status; + BOOLEAN mpty; + BOOLEAN number_present; + char number[BTA_AG_NUMBER_LEN + 1]; +} tBTA_AG_CLCC; + +/* data associated with BTA_AG_CNUM_EVT event */ +typedef struct { + UINT16 service; + char number[BTA_AG_NUMBER_LEN + 1]; +} tBTA_AG_CNUM; + +/* data associated with BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT */ +typedef struct { + UINT32 rx_total; + UINT32 rx_correct; + UINT32 rx_err; + UINT32 rx_none; + UINT32 rx_lost; + UINT32 tx_total; + UINT32 tx_discarded; +} tBTA_AG_PKT_STAT_NUMS; + +/* union of data associated with AG callback */ +typedef union +{ + tBTA_AG_HDR hdr; + tBTA_AG_REGISTER reg; + tBTA_AG_OPEN open; + tBTA_AG_CLOSE close; + tBTA_AG_CONN conn; + tBTA_AG_IND ind; + tBTA_AG_VAL val; + //add + tBTA_AG_COPS operator; + tBTA_AG_NUMBER number; + tBTA_AG_AT_RESULT result; + tBTA_AG_CLCC clcc; + tBTA_AG_CNUM cnum; + tBTA_AG_PKT_STAT_NUMS pkt_num; +} tBTA_AG; + +/* AG callback */ +typedef void (tBTA_AG_CBACK)(tBTA_AG_EVT event, tBTA_AG *p_data); + +/* 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. +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +void BTA_AgDisable(void); + +/******************************************************************************* +** +** Function BTA_AgRegister +** +** Description Register an Audio Gateway service. +** +** +** Returns void +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +void BTA_AgClose(UINT16 handle); + +/******************************************************************************* +** +** Function BTA_AgAudioOpen +** +** Description Opens an audio connection to the currently connected +** headset or hnadsfree +** +** +** Returns void +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +void BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec); + + +#if (BTM_SCO_HCI_INCLUDED == TRUE ) +/******************************************************************************* +** +** Function BTA_AgPktStatsNumsGet +** +** Description Get the Number of packets status received +** +** +** Returns void +** +*******************************************************************************/ +void BTA_AgPktStatsNumsGet(UINT16 handle, UINT16 sync_conn_handle); + +/******************************************************************************* +** +** Function BTA_AgCiData +** +** Description Give an EVT to BTA that tell outgoing data is ready. +** +** +** Returns void +** +*******************************************************************************/ +void BTA_AgCiData(UINT16 handle); +#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */ + +#ifdef __cplusplus +} +#endif + +#endif /* #if (BTA_AG_INCLUDED == TRUE) */ + +#endif /* BTA_HF_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_ag_co.h b/lib/bt/host/bluedroid/bta/include/bta/bta_ag_co.h new file mode 100644 index 00000000..932ecddd --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_ag_co.h @@ -0,0 +1,163 @@ +/****************************************************************************** + * + * Copyright (C) 2003-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for audio gateway call-out and call-in functions. + * + ******************************************************************************/ +#ifndef BTA_AG_CO_H +#define BTA_AG_CO_H + +#include "bta/bta_ag_api.h" +#include "hci/hci_audio.h" + +#if (BTA_AG_INCLUDED == TRUE) +#if (BTM_SCO_HCI_INCLUDED == TRUE) +/******************************************************************************* +** +** Function bta_ag_sco_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 +** codec - if WBS support is compiled in, codec to going to be used is provided +** and when in SCO_STATE_SETUP, BTM_I2SPCMConfig() must be called with +** the correct platform parameters. +** in the other states codec type should not be ignored +** +** Returns void +** +*******************************************************************************/ +#if (BTM_WBS_INCLUDED == TRUE) +void bta_ag_sco_audio_state(UINT16 handle, UINT8 app_id, UINT8 state, tBTA_AG_PEER_CODEC codec); +#else +void bta_ag_sco_audio_state(UINT16 handle, UINT8 app_id, UINT8 state); +#endif + +/******************************************************************************* +** +** Function bta_ag_sco_co_init +** +** Description Set default data path for SCO/eSCO. +** 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. +** +*******************************************************************************/ +tBTA_HFP_SCO_ROUTE_TYPE bta_ag_sco_co_init(UINT32 rx_bw, UINT32 tx_bw, tBTA_HFP_CODEC_INFO *p_codec_info, UINT8 app_id); + +/******************************************************************************* +** +** Function bta_ag_sco_co_open +** +** Description This function is executed by AG when a service level connection +** is opened. +** +** +** Returns void +** +*******************************************************************************/ +void bta_ag_sco_co_open(UINT16 handle, tBTM_SCO_AIR_MODE_TYPE air_mode, UINT8 inout_pkt_size, UINT16 event); + +/******************************************************************************* +** +** Function bta_ag_sco_co_close +** +** Description This function is called by AG when a service level +** connection is closed. +** +** +** Returns void +** +*******************************************************************************/ +void bta_ag_sco_co_close(void); + +/******************************************************************************* +** +** Function bta_ag_sco_co_out_data +** +** Description This function is called to send SCO data over HCI. +** +** Returns number of bytes got from application +** +*******************************************************************************/ +uint32_t bta_ag_sco_co_out_data(UINT8 *p_buf); + +/******************************************************************************* +** +** Function bta_hf_client_sco_co_in_data +** +** Description This function is called to send incoming SCO data to application. +** +** Returns void +** +*******************************************************************************/ +void bta_ag_sco_co_in_data(BT_HDR *p_buf, tBTM_SCO_DATA_FLAG status); + +/******************************************************************************* +** +** 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 phones memory. +** +** Returns void +** +*******************************************************************************/ +void bta_ag_co_tx_write(UINT16 handle, UINT8 *p_data, UINT16 len); + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +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 +** +******************************************************************************/ +extern void bta_ag_ci_slc_ready(UINT16 handle); + +#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */ + +#endif /* #if (BTA_AG_INCLUDED == TRUE) */ + +#endif /* BTA_AG_CO_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_api.h new file mode 100644 index 00000000..8ba75884 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -0,0 +1,3155 @@ +/****************************************************************************** + * + * Copyright (C) 2003-2014 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the public interface file for BTA, Broadcom's Bluetooth + * application layer for mobile phones. + * + ******************************************************************************/ +#ifndef BTA_API_H +#define BTA_API_H + +#include "common/bt_target.h" +#include "stack/bt_types.h" +#include "stack/btm_api.h" +// #include "uipc_msg.h" +#include "stack/sdp_api.h" + +// #if BLE_INCLUDED == TRUE +#include "stack/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 +#define BTA_EIR_TOO_LARGE 6 + +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 (stack/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_A2DP_SOURCE_SERVICE_ID 3 /* A2DP Source 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_SINK_SERVICE_ID 18 /* A2DP Sink */ +#define BTA_AVRCP_SERVICE_ID 19 /* A/V remote control */ +#define BTA_HID_SERVICE_ID 20 /* HID Host*/ +#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*/ +#define BTA_SDP_SERVICE_ID 29 /* SDP Search*/ +#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE +/* BLE profile service ID */ +#define BTA_BLE_SERVICE_ID 30 /* GATT profile */ + +// btla-specific ++ +#define BTA_USER_SERVICE_ID 31 /* User requested UUID */ + +#define BTA_MAX_SERVICE_ID 32 +// btla-specific -- +#else +#define BTA_USER_SERVICE_ID 30 /* User requested UUID */ +#define BTA_MAX_SERVICE_ID 31 +#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. */ +#define BTA_SEC_MODE4_LEVEL4 (BTM_SEC_MODE4_LEVEL4) /* Mode 4 level 4 service, i.e. incoming/outgoing MITM and P-256 encryption */ +#define BTA_SEC_MITM (BTM_SEC_IN_MITM | BTM_SEC_OUT_MITM) /* Man-In-The_Middle protection */ +#define BTA_SEC_IN_16_DIGITS (BTM_SEC_IN_MIN_16_DIGIT_PIN) /* Min 16 digit for pin code */ + +typedef UINT16 tBTA_SEC; + +typedef tBTM_GET_DEV_NAME_CBACK tBTA_GET_DEV_NAME_CBACK; + +/* Ignore for Discoverable, Connectable, Pairable and Connectable Paired only device modes */ +#define BTA_DM_IGNORE 0x00FF + +/* Ignore for Discoverable, Connectable only for LE modes */ +#define BTA_DM_LE_IGNORE 0xFF00 + +#define BTA_APP_ID_1 1 /* PM example profile 1 */ +#define BTA_APP_ID_PAN_MULTI 0xFE /* app id for pan multiple connection */ +#define BTA_ALL_APP_ID 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. */ +#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) +#define BTA_DM_BLE_NON_DISCOVERABLE BTM_BLE_NON_DISCOVERABLE /* Device is not LE discoverable */ +#define BTA_DM_BLE_GENERAL_DISCOVERABLE BTM_BLE_GENERAL_DISCOVERABLE /* Device is LE General discoverable */ +#define BTA_DM_BLE_LIMITED_DISCOVERABLE BTM_BLE_LIMITED_DISCOVERABLE /* Device is LE Limited discoverable */ +#endif +typedef UINT16 tBTA_DM_DISC; /* this discoverability mode is a bit mask among BR mode and LE mode */ + +/* Connectable Modes */ +#define BTA_DM_NON_CONN BTM_NON_CONNECTABLE /* Device is not connectable. */ +#define BTA_DM_CONN BTM_CONNECTABLE /* Device is connectable. */ +#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) +#define BTA_DM_BLE_NON_CONNECTABLE BTM_BLE_NON_CONNECTABLE /* Device is LE non-connectable. */ +#define BTA_DM_BLE_CONNECTABLE BTM_BLE_CONNECTABLE /* Device is LE connectable. */ +#endif + +// btla-specific ++ +typedef UINT16 tBTA_DM_CONN; + +#define BTA_TRANSPORT_UNKNOWN 0 +#define BTA_TRANSPORT_BR_EDR BT_TRANSPORT_BR_EDR +#define BTA_TRANSPORT_LE BT_TRANSPORT_LE +typedef tBT_TRANSPORT tBTA_TRANSPORT; + +/* 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_INQUIRY_NONE BTM_INQUIRY_NONE /*No BR inquiry. */ +#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 +#define BTA_SLAVE_ROLE_ONLY 0x03 /* Used for PANU only, skip role switch to master */ + +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. */ +#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE) + UINT8 intl_duration[4];/*duration array storing the interleave scan's time portions*/ +#endif +} tBTA_DM_INQ; + +/* Config EIR callback */ +typedef void (tBTA_DM_CONFIG_EIR_CBACK) (tBTA_STATUS status, UINT8 eir_type_num, UINT8 *eir_type); + +typedef struct { + BOOLEAN bta_dm_eir_fec_required; /* FEC required */ + BOOLEAN bta_dm_eir_included_name; /* Included device name or not */ + UINT8 bta_dm_eir_min_name_len; /* minimum length of local name when it is shortened */ + + BOOLEAN bta_dm_eir_included_uuid; /* Included UUIDs or not */ +#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 + + BOOLEAN bta_dm_eir_included_tx_power; /* Included inquiry TX power or not */ + INT8 bta_dm_eir_inq_tx_power; /* Inquiry TX power */ + + 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 */ + UINT8 bta_dm_eir_url_len; /* length of URL in bytes */ + UINT8 *bta_dm_eir_url; /* URL data */ + + tBTA_DM_CONFIG_EIR_CBACK *config_eir_callback; /* callback */ +} 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_DMT_CONTROLLER_SPT BTM_BLE_DMT_CONTROLLER_SPT +#define BTA_BLE_DMT_HOST_SPT BTM_BLE_DMT_HOST_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 + +/* ADV data bit 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_INT_RANGE BTM_BLE_AD_BIT_INT_RANGE +#define BTA_BLE_AD_BIT_SERVICE BTM_BLE_AD_BIT_SERVICE +#define BTA_BLE_AD_BIT_APPEARANCE BTM_BLE_AD_BIT_APPEARANCE +#define BTA_BLE_AD_BIT_PROPRIETARY BTM_BLE_AD_BIT_PROPRIETARY +#define BTA_DM_BLE_AD_BIT_SERVICE_SOL BTM_BLE_AD_BIT_SERVICE_SOL +#define BTA_DM_BLE_AD_BIT_SERVICE_DATA BTM_BLE_AD_BIT_SERVICE_DATA +#define BTA_DM_BLE_AD_BIT_SIGN_DATA BTM_BLE_AD_BIT_SIGN_DATA +#define BTA_DM_BLE_AD_BIT_SERVICE_128SOL BTM_BLE_AD_BIT_SERVICE_128SOL +#define BTA_DM_BLE_AD_BIT_PUBLIC_ADDR BTM_BLE_AD_BIT_PUBLIC_ADDR +#define BTA_DM_BLE_AD_BIT_RANDOM_ADDR BTM_BLE_AD_BIT_RANDOM_ADDR +#define BTA_DM_BLE_AD_BIT_SERVICE_128 BTM_BLE_AD_BIT_SERVICE_128 /*128-bit Service UUIDs*/ + +typedef tBTM_BLE_AD_MASK 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; + + +typedef struct { + UINT8 len; + UINT8 *p_val; +} tBTA_BLE_MANU; + +typedef struct { + UINT8 adv_type; + UINT8 len; + UINT8 *p_val; /* number of len byte */ +} tBTA_BLE_PROP_ELEM; + +/* vendor proprietary adv type */ +typedef struct { + UINT8 num_elem; + tBTA_BLE_PROP_ELEM *p_elem; +} tBTA_BLE_PROPRIETARY; + +typedef struct { + tBT_UUID service_uuid; + UINT8 len; + UINT8 *p_val; +} tBTA_BLE_SERVICE_DATA; + +typedef tBTM_BLE_128SERVICE tBTA_BLE_128SERVICE; +typedef tBTM_BLE_32SERVICE tBTA_BLE_32SERVICE; + +typedef struct { + tBTA_BLE_INT_RANGE int_range; /* slave prefered conn interval range */ + tBTA_BLE_MANU *p_manu; /* manufacturer data */ + tBTA_BLE_SERVICE *p_services; /* 16 bits services */ + tBTA_BLE_128SERVICE *p_services_128b; /* 128 bits service */ + tBTA_BLE_32SERVICE *p_service_32b; /* 32 bits Service UUID */ + tBTA_BLE_SERVICE *p_sol_services; /* 16 bits services Solicitation UUIDs */ + tBTA_BLE_32SERVICE *p_sol_service_32b; /* List of 32 bit Service Solicitation UUIDs */ + tBTA_BLE_128SERVICE *p_sol_service_128b;/* List of 128 bit Service Solicitation UUIDs */ + tBTA_BLE_PROPRIETARY *p_proprietary; /* proprietary data */ + tBTA_BLE_SERVICE_DATA *p_service_data; /* service data */ + UINT16 appearance; /* appearance data */ + UINT8 flag; + UINT8 tx_power; +} tBTA_BLE_ADV_DATA; + +typedef void (tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTA_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info); + +typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status); + +typedef tBTM_START_ADV_CMPL_CBACK tBTA_START_ADV_CMPL_CBACK; + +typedef tBTM_START_STOP_ADV_CMPL_CBACK tBTA_START_STOP_ADV_CMPL_CBACK; + +typedef tBTM_UPDATE_WHITELIST_CBACK tBTA_UPDATE_WHITELIST_CBACK; + +typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK; + +typedef tBTM_DTM_CMD_CMPL_CBACK tBTA_DTM_CMD_CMPL_CBACK; + +typedef tBTM_SET_RAND_ADDR_CBACK tBTA_SET_RAND_ADDR_CBACK; + +typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK; + +typedef tBTM_CMPL_CB tBTA_CMPL_CB; + +typedef tBTM_TX_POWER_RESULTS tBTA_TX_POWER_RESULTS; + +typedef tBTM_RSSI_RESULTS tBTA_RSSI_RESULTS; + +typedef tBTM_SET_AFH_CHANNELS_RESULTS tBTA_SET_AFH_CHANNELS_RESULTS; +typedef tBTM_BLE_SET_CHANNELS_RESULTS tBTA_BLE_SET_CHANNELS_RESULTS; + +typedef tBTM_SET_PAGE_TIMEOUT_RESULTS tBTA_SET_PAGE_TIMEOUT_RESULTS; +typedef tBTM_GET_PAGE_TIMEOUT_RESULTS tBTA_GET_PAGE_TIMEOUT_RESULTS; + +typedef tBTM_SET_ACL_PKT_TYPES_RESULTS tBTA_SET_ACL_PKT_TYPES_RESULTS; + +typedef tBTM_REMOTE_DEV_NAME tBTA_REMOTE_DEV_NAME; + +/* advertising channel map */ +#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37 +#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38 +#define BTA_BLE_ADV_CHNL_39 BTM_BLE_ADV_CHNL_39 +typedef tBTM_BLE_ADV_CHNL_MAP tBTA_BLE_ADV_CHNL_MAP; /* use as a bit mask */ + +/* advertising filter policy */ +typedef tBTM_BLE_AFP tBTA_BLE_AFP; + +/* adv event type */ +#define BTA_BLE_CONNECT_EVT BTM_BLE_CONNECT_EVT /* Connectable undirected advertising */ +#define BTA_BLE_CONNECT_DIR_EVT BTM_BLE_CONNECT_DIR_EVT /* Connectable directed advertising */ +#define BTA_BLE_DISCOVER_EVT BTM_BLE_DISCOVER_EVT /* Scannable undirected advertising */ +#define BTA_BLE_NON_CONNECT_EVT BTM_BLE_NON_CONNECT_EVT /* Non connectable undirected advertising */ +typedef UINT8 tBTA_BLE_ADV_EVT; + +/* adv tx power level */ +#define BTA_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */ +#define BTA_BLE_ADV_TX_POWER_LOW 1 /* low tx power */ +#define BTA_BLE_ADV_TX_POWER_MID 2 /* middle tx power */ +#define BTA_BLE_ADV_TX_POWER_UPPER 3 /* upper tx power */ +#define BTA_BLE_ADV_TX_POWER_MAX 4 /* maximum tx power */ +typedef UINT8 tBTA_BLE_ADV_TX_POWER; + +/* advertising instance parameters */ +typedef struct { + UINT16 adv_int_min; /* minimum adv interval */ + UINT16 adv_int_max; /* maximum adv interval */ + tBTA_BLE_ADV_EVT adv_type; /* adv event type */ + tBTA_BLE_ADV_CHNL_MAP channel_map; /* adv channel map */ + tBTA_BLE_AFP adv_filter_policy; /* advertising filter policy */ + tBTA_BLE_ADV_TX_POWER tx_power; /* adv tx power */ +} tBTA_BLE_ADV_PARAMS; + +/* 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_SERVICE service; +} tBTA_BLE_INQ_DATA; + +enum { + BTA_BLE_BATCH_SCAN_MODE_PASS = 1, + BTA_BLE_BATCH_SCAN_MODE_ACTI = 2, + BTA_BLE_BATCH_SCAN_MODE_PASS_ACTI = 3 +}; +typedef UINT8 tBTA_BLE_BATCH_SCAN_MODE; + +enum { + BTA_BLE_DISCARD_OLD_ITEMS = 0, + BTA_BLE_DISCARD_LOWER_RSSI_ITEMS = 1 +}; +typedef UINT8 tBTA_BLE_DISCARD_RULE; + +enum { + BTA_BLE_ADV_SEEN_FIRST_TIME = 0, + BTA_BLE_ADV_TRACKING_TIMEOUT = 1 +}; +typedef UINT8 tBTA_BLE_ADV_CHANGE_REASON; + +enum { + BTA_BLE_BATCH_SCAN_ENB_EVT = 1, + BTA_BLE_BATCH_SCAN_CFG_STRG_EVT = 2, + BTA_BLE_BATCH_SCAN_DATA_EVT = 3, + BTA_BLE_BATCH_SCAN_THRES_EVT = 4, + BTA_BLE_BATCH_SCAN_PARAM_EVT = 5, + BTA_BLE_BATCH_SCAN_DIS_EVT = 6 +}; +typedef tBTM_BLE_BATCH_SCAN_EVT tBTA_BLE_BATCH_SCAN_EVT; + +typedef tBTM_BLE_TRACK_ADV_ACTION tBTA_BLE_TRACK_ADV_ACTION; +// #endif + +/* BLE customer specific feature function type definitions */ +/* data type used on customer specific feature for RSSI monitoring */ +#define BTA_BLE_RSSI_ALERT_HI 0 +#define BTA_BLE_RSSI_ALERT_RANGE 1 +#define BTA_BLE_RSSI_ALERT_LO 2 +typedef UINT8 tBTA_DM_BLE_RSSI_ALERT_TYPE; + +#define BTA_BLE_RSSI_ALERT_NONE BTM_BLE_RSSI_ALERT_NONE /* (0) */ +#define BTA_BLE_RSSI_ALERT_HI_BIT BTM_BLE_RSSI_ALERT_HI_BIT /* (1) */ +#define BTA_BLE_RSSI_ALERT_RANGE_BIT BTM_BLE_RSSI_ALERT_RANGE_BIT /* (1 << 1) */ +#define BTA_BLE_RSSI_ALERT_LO_BIT BTM_BLE_RSSI_ALERT_LO_BIT /* (1 << 2) */ +typedef UINT8 tBTA_DM_BLE_RSSI_ALERT_MASK; + + +typedef void (tBTA_DM_BLE_RSSI_CBACK) (BD_ADDR bd_addr, tBTA_DM_BLE_RSSI_ALERT_TYPE alert_type, INT8 rssi); + +/* max number of filter spot for different filter type */ +#define BTA_DM_BLE_MAX_UUID_FILTER BTM_BLE_MAX_UUID_FILTER /* 8 */ +#define BTA_DM_BLE_MAX_ADDR_FILTER BTM_BLE_MAX_ADDR_FILTER /* 8 */ +#define BTA_DM_BLE_PF_STR_COND_MAX BTM_BLE_PF_STR_COND_MAX /* 4 apply to manu data , or local name */ +#define BTA_DM_BLE_PF_STR_LEN_MAX BTM_BLE_PF_STR_LEN_MAX /* match for first 20 bytes */ + +#define BTA_DM_BLE_PF_LOGIC_OR 0 +#define BTA_DM_BLE_PF_LOGIC_AND 1 +typedef UINT8 tBTA_DM_BLE_PF_LOGIC_TYPE; + +enum { + BTA_DM_BLE_SCAN_COND_ADD, + BTA_DM_BLE_SCAN_COND_DELETE, + BTA_DM_BLE_SCAN_COND_CLEAR = 2 +}; +typedef UINT8 tBTA_DM_BLE_SCAN_COND_OP; + +/* ADV payload filtering vendor specific call event */ +enum { + BTA_BLE_SCAN_PF_ENABLE_EVT = 7, + BTA_BLE_SCAN_PF_COND_EVT +}; + +/* filter selection bit index */ +#define BTA_DM_BLE_PF_ADDR_FILTER BTM_BLE_PF_ADDR_FILTER +#define BTA_DM_BLE_PF_SRVC_DATA BTM_BLE_PF_SRVC_DATA +#define BTA_DM_BLE_PF_SRVC_UUID BTM_BLE_PF_SRVC_UUID +#define BTA_DM_BLE_PF_SRVC_SOL_UUID BTM_BLE_PF_SRVC_SOL_UUID +#define BTA_DM_BLE_PF_LOCAL_NAME BTM_BLE_PF_LOCAL_NAME +#define BTA_DM_BLE_PF_MANU_DATA BTM_BLE_PF_MANU_DATA +#define BTA_DM_BLE_PF_SRVC_DATA_PATTERN BTM_BLE_PF_SRVC_DATA_PATTERN +#define BTA_DM_BLE_PF_TYPE_ALL BTM_BLE_PF_TYPE_ALL +#define BTA_DM_BLE_PF_TYPE_MAX BTM_BLE_PF_TYPE_MAX +typedef UINT8 tBTA_DM_BLE_PF_COND_TYPE; + +typedef union { + UINT16 uuid16_mask; + UINT32 uuid32_mask; + UINT8 uuid128_mask[LEN_UUID_128]; +} tBTA_DM_BLE_PF_COND_MASK; + +typedef struct { + tBLE_BD_ADDR *p_target_addr; /* target address, if NULL, generic UUID filter */ + tBT_UUID uuid; /* UUID condition */ + tBTA_DM_BLE_PF_LOGIC_TYPE cond_logic; /* AND/OR */ + tBTA_DM_BLE_PF_COND_MASK *p_uuid_mask; /* UUID condition mask, if NULL, match exact as UUID condition */ +} tBTA_DM_BLE_PF_UUID_COND; + +typedef struct { + UINT8 data_len; /* <= 20 bytes */ + UINT8 *p_data; +} tBTA_DM_BLE_PF_LOCAL_NAME_COND; + +typedef struct { + UINT16 company_id; /* company ID */ + UINT8 data_len; /* <= 20 bytes */ + UINT8 *p_pattern; + UINT16 company_id_mask; /* UUID value mask */ + UINT8 *p_pattern_mask; /* Manufacturer data matching mask, same length + as data pattern, set to all 0xff, match exact data */ +} tBTA_DM_BLE_PF_MANU_COND; + +typedef struct { + UINT16 uuid; /* service ID */ + UINT8 data_len; /* <= 20 bytes */ + UINT8 *p_pattern; + UINT8 *p_pattern_mask; /* Service data matching mask, same length + as data pattern, set to all 0xff, match exact data */ +} tBTA_DM_BLE_PF_SRVC_PATTERN_COND; + +typedef union { + tBLE_BD_ADDR target_addr; + tBTA_DM_BLE_PF_LOCAL_NAME_COND local_name; /* local name filtering */ + tBTA_DM_BLE_PF_MANU_COND manu_data; /* manufacturer data filtering */ + tBTA_DM_BLE_PF_UUID_COND srvc_uuid; /* service UUID filtering */ + tBTA_DM_BLE_PF_UUID_COND solicitate_uuid; /* solicited service UUID filtering */ + tBTA_DM_BLE_PF_SRVC_PATTERN_COND srvc_data; /* service data pattern */ +} tBTA_DM_BLE_PF_COND_PARAM; + +typedef UINT8 tBTA_DM_BLE_PF_FILT_INDEX; +typedef UINT8 tBTA_DM_BLE_PF_AVBL_SPACE; + +typedef INT8 tBTA_DM_RSSI_VALUE; +typedef UINT8 tBTA_DM_LINK_QUALITY_VALUE; + + +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 */ +#define BTA_DM_BLE_NC_REQ_EVT 22 /* SMP Numeric Comparison request event */ +// btla-specific ++ +#define BTA_DM_SP_RMT_OOB_EXT_EVT 23 /* Simple Pairing Remote OOB Extended Data request. */ +#define BTA_DM_BLE_AUTH_CMPL_EVT 24 /* BLE Auth complete */ +// btla-specific -- +#define BTA_DM_DEV_UNPAIRED_EVT 25 /* BT unpair event */ +#define BTA_DM_HW_ERROR_EVT 26 /* BT Chip H/W error */ +#define BTA_DM_LE_FEATURES_READ 27 /* Cotroller specific LE features are read */ +#define BTA_DM_ENER_INFO_READ 28 /* Energy info read */ +#define BTA_DM_BLE_DEV_UNPAIRED_EVT 29 /* BLE unpair event */ +#define BTA_DM_SP_KEY_REQ_EVT 30 /* Simple Pairing Passkey request */ +#define BTA_DM_PM_MODE_CHG_EVT 31 /* Mode changed event */ +#define BTA_DM_ACL_LINK_STAT_EVT 32 /* ACL connection status report event */ +#define BTA_DM_BLE_SC_OOB_REQ_EVT 33 /* BLE SMP SC OOB request event */ +#define BTA_DM_BLE_SC_CR_LOC_OOB_EVT 34 /* BLE SMP SC Create Local OOB request event */ +#define BTA_DM_ENC_CHG_EVT 35 /* Encryption change event */ + +typedef UINT8 tBTA_DM_SEC_EVT; + +/* Structure associated with BTA_DM_ENABLE_EVT */ +typedef struct { + tBTA_STATUS status; +} tBTA_DM_ENABLE; + +/* Structure associated with BTA_DM_PIN_REQ_EVT */ +typedef struct { + /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */ + BD_ADDR bd_addr; /* BD address peer device. */ + DEV_CLASS dev_class; /* Class of Device */ + BD_NAME bd_name; /* Name of peer device. */ + BOOLEAN min_16_digit; /* TRUE if the pin returned must be at least 16 digits */ +} tBTA_DM_PIN_REQ; + +/* BLE related definition */ +#if (SMP_INCLUDED == TRUE) +#define BTA_DM_AUTH_FAIL_BASE (HCI_ERR_MAX_ERR + 10) +#define BTA_DM_AUTH_CONVERT_SMP_CODE(x) (BTA_DM_AUTH_FAIL_BASE + (x)) +#define BTA_DM_AUTH_SMP_PASSKEY_FAIL BTA_DM_AUTH_CONVERT_SMP_CODE (SMP_PASSKEY_ENTRY_FAIL) +#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_INVALID_PARAMETERS (BTA_DM_AUTH_FAIL_BASE + SMP_INVALID_PARAMETERS) +#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) +#endif ///SMP_INCLUDED == TRUE +/* connection parameter boundary value and dummy value */ +#define BTA_DM_BLE_SCAN_INT_MIN BTM_BLE_SCAN_INT_MIN +#define BTA_DM_BLE_SCAN_INT_MAX BTM_BLE_SCAN_INT_MAX +#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 */ + +#if (SMP_INCLUDED == TRUE) +#define BTA_LE_KEY_PENC BTM_LE_KEY_PENC /* encryption information of peer device */ +#define BTA_LE_KEY_PID BTM_LE_KEY_PID /* identity key of the peer device */ +#define BTA_LE_KEY_PCSRK BTM_LE_KEY_PCSRK /* peer SRK */ +#define BTA_LE_KEY_LENC BTM_LE_KEY_LENC /* master role security information:div */ +#define BTA_LE_KEY_LID BTM_LE_KEY_LID /* master device ID key */ +#define BTA_LE_KEY_LCSRK BTM_LE_KEY_LCSRK /* local CSRK has been deliver to peer */ +#endif ///SMP_INCLUDED == TRUE +typedef UINT8 tBTA_LE_KEY_TYPE; /* can be used as a bit mask */ + + +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 tBTM_LE_PID_KEYS tBTA_LE_PID_KEYS ; + +typedef union { + tBTA_LE_PENC_KEYS penc_key; /* received peer encryption key */ + tBTA_LE_PCSRK_KEYS psrk_key; /* received peer device SRK */ + tBTA_LE_PID_KEYS 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_PID_KEYS lid_key; /* local device ID key for the particular remote */ +} 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; +#if (SMP_INCLUDED == TRUE) +#define BTA_DM_SEC_GRANTED BTA_SUCCESS +#define BTA_DM_SEC_PAIR_NOT_SPT BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT +#define BTA_DM_SEC_REP_ATTEMPTS BTA_DM_AUTH_SMP_REPEATED_ATTEMPT +#endif ///SMP_INCLUDED == TRUE +typedef UINT8 tBTA_DM_BLE_SEC_GRANT; + + +#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); + +typedef tBTM_LE_UPDATE_CONN_PRAMS tBTA_LE_UPDATE_CONN_PRAMS; +typedef tBTM_UPDATE_CONN_PARAM_CBACK tBTA_UPDATE_CONN_PARAM_CBACK; + + +/* 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 *p_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 */ + tBLE_ADDR_TYPE addr_type; /* Peer device address type */ + tBT_DEVICE_TYPE dev_type; + UINT8 auth_mode; + BOOLEAN sc_support; /* Denotes if peer device supported secure connection while bonding. */ +} 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 { + BOOLEAN sc_downgrade; /* Security downgrade state. */ + BD_ADDR bd_addr; /* BD address peer device. */ +#if BLE_INCLUDED == TRUE + tBTA_TRANSPORT link_type; +#endif +} 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 */ + UINT8 reason; /* link down reason */ + BOOLEAN is_removed; /* TRUE if device is removed when link is down */ +#if BLE_INCLUDED == TRUE + tBTA_TRANSPORT link_type; +#endif +} tBTA_DM_LINK_DOWN; + +enum { + BTA_ACL_LINK_STAT_CONN_CMPL, + BTA_ACL_LINK_STAT_DISCONN_CMPL +}; +typedef UINT8 tBTA_ACL_LINK_STAT_EVT; + +typedef struct { + UINT8 status; /* ACL link connection status */ + UINT16 handle; /* ACL connection handle */ + BD_ADDR bd_addr; /* peer bluetooth address */ +} tBTA_DM_ACL_CONN_CMPL_STAT; + +typedef struct { + UINT8 reason; /* ACL link disconnection reason */ + UINT16 handle; /* ACL connection handle */ + BD_ADDR bd_addr; /* peer bluetooth address */ +} tBTA_DM_ACL_DISCONN_CMPL_STAT; + +/* Structure associated with BTA_DM_ACL_LINK_STAT_EVT */ +typedef struct { + tBTA_ACL_LINK_STAT_EVT event; /* ACL link event */ + union { + tBTA_DM_ACL_CONN_CMPL_STAT conn_cmpl; + tBTA_DM_ACL_DISCONN_CMPL_STAT disconn_cmpl; + } link_act; +} tBTA_DM_ACL_LINK_STAT; + +/* 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_BUSY_LEVEL_EVT */ +typedef struct { + UINT8 level; /* when paging or inquiring, level is 10. + Otherwise, the number of ACL links */ + UINT8 level_flags; /* indicates individual flags */ +} tBTA_DM_BUSY_LEVEL; + +#define BTA_IO_CAP_OUT BTM_IO_CAP_OUT /* 0 DisplayOnly */ +#define BTA_IO_CAP_IO BTM_IO_CAP_IO /* 1 DisplayYesNo */ +#define BTA_IO_CAP_IN BTM_IO_CAP_IN /* 2 KeyboardOnly */ +#define BTA_IO_CAP_NONE BTM_IO_CAP_NONE /* 3 NoInputNoOutput */ +#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE +#define BTA_IO_CAP_KBDISP BTM_IO_CAP_KBDISP /* 4 Keyboard display */ +#endif +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 */ + +#if (SMP_INCLUDED == TRUE) +#define BTA_LE_AUTH_NO_BOND BTM_LE_AUTH_REQ_NO_BOND /* 0*/ +#define BTA_LE_AUTH_BOND BTM_LE_AUTH_REQ_BOND /* 1 << 0 */ +#define BTA_LE_AUTH_REQ_MITM BTM_LE_AUTH_REQ_MITM /* 1 << 2 */ + +#define BTA_LE_AUTH_REQ_SC_ONLY BTM_LE_AUTH_REQ_SC_ONLY /* 1 << 3 */ +#define BTA_LE_AUTH_REQ_SC_BOND BTM_LE_AUTH_REQ_SC_BOND /* 1001 */ +#define BTA_LE_AUTH_REQ_SC_MITM BTM_LE_AUTH_REQ_SC_MITM /* 1100 */ +#define BTA_LE_AUTH_REQ_SC_MITM_BOND BTM_LE_AUTH_REQ_SC_MITM_BOND /* 1101 */ +#endif ///SMP_INCLUDED == TRUE +typedef tBTM_LE_AUTH_REQ tBTA_LE_AUTH_REQ; /* combination of the above bit pattern */ + +#define BTA_OOB_NONE BTM_OOB_NONE +#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; + +#define BTA_PM_MD_ACTIVE BTM_PM_MD_ACTIVE /* 0 Active mode */ +#define BTA_PM_MD_HOLD BTM_PM_MD_HOLD /* 1 Hold mode */ +#define BTA_PM_MD_SNIFF BTM_PM_MD_SNIFF /* 2 Sniff mode */ +#define BTA_PM_MD_PARK BTM_PM_MD_PARK /* 3 Park state */ +typedef tBTM_PM_MODE tBTA_PM_MODE; + +/* Structure associated with BTA_DM_SP_CFM_REQ_EVT */ +typedef struct { + /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */ + 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_IO_CAP loc_io_caps; /* IO Capabilities of local device */ + tBTA_AUTH_REQ rmt_io_caps; /* IO Capabilities of remote device */ +} tBTA_DM_SP_CFM_REQ; + +/* Structure associated with tBTA_DM_SP_KEY_REQ */ +typedef struct { + BD_ADDR bd_addr; /* peer address */ + DEV_CLASS dev_class; /* peer CoD */ + BD_NAME bd_name; /* peer device name */ +} tBTA_DM_SP_KEY_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 { + /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */ + 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 { + /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */ + 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; + +/* Structure associated with BTA_DM_PM_MODE_CHG_EVT */ +typedef struct { + BD_ADDR bd_addr; /* BD address peer device. */ + tBTA_PM_MODE mode; /* the new connection role */ +} tBTA_DM_MODE_CHG; + +typedef struct { + BT_OCTET16 local_oob_c; /* Local OOB Data Confirmation/Commitment */ + BT_OCTET16 local_oob_r; /* Local OOB Data Randomizer */ +} tBTA_DM_LOC_OOB_DATA; + +typedef struct { + BD_ADDR bd_addr; /* BD address peer device */ + UINT8 enc_mode; /* Encryption mode */ +} tBTA_DM_ENC_CHG; + +/* 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 up event */ + tBTA_DM_LINK_DOWN link_down; /* ACL connection down event */ + tBTA_DM_ACL_LINK_STAT acl_link_stat; /* ACL link status event */ + tBTA_DM_BUSY_LEVEL busy_level; /* System busy level */ + tBTA_DM_SP_CFM_REQ cfm_req; /* user confirm request */ + tBTA_DM_SP_KEY_REQ key_req; /* user passkey 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 */ +#if BTA_DM_PM_INCLUDED + tBTA_DM_MODE_CHG mode_chg; /* mode change event */ +#endif ///BTA_DM_PM_INCLUDED + tBTA_DM_LOC_OOB_DATA local_oob_data; /* Local OOB data generated by us */ + tBTA_DM_ENC_CHG enc_chg; /* Encryption change event */ +} tBTA_DM_SEC; + +/* Security callback */ +typedef void (tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data); + +#define BTA_BLE_MULTI_ADV_ILLEGAL 0 + +/* multi adv callback event */ +#define BTA_BLE_MULTI_ADV_ENB_EVT 1 +#define BTA_BLE_MULTI_ADV_DISABLE_EVT 2 +#define BTA_BLE_MULTI_ADV_PARAM_EVT 3 +#define BTA_BLE_MULTI_ADV_DATA_EVT 4 + +typedef UINT8 tBTA_BLE_MULTI_ADV_EVT; + +/* multi adv callback */ +typedef void (tBTA_BLE_MULTI_ADV_CBACK)(tBTA_BLE_MULTI_ADV_EVT event, + UINT8 inst_id, void *p_ref, tBTA_STATUS status); +typedef UINT32 tBTA_DM_BLE_REF_VALUE; + +#define BTA_DM_BLE_PF_ENABLE_EVT BTM_BLE_PF_ENABLE +#define BTA_DM_BLE_PF_CONFIG_EVT BTM_BLE_PF_CONFIG +typedef UINT8 tBTA_DM_BLE_PF_EVT; + +#define BTA_DM_BLE_PF_ENABLE 1 +#define BTA_DM_BLE_PF_CONFIG 2 +typedef UINT8 tBTA_DM_BLE_PF_ACTION; + +/* Config callback */ +typedef void (tBTA_DM_BLE_PF_CFG_CBACK) (tBTA_DM_BLE_PF_ACTION action, + tBTA_DM_BLE_PF_COND_TYPE cfg_cond, + tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, tBTA_STATUS status, + tBTA_DM_BLE_REF_VALUE ref_value); +/* Param callback */ +typedef void (tBTA_DM_BLE_PF_PARAM_CBACK) (UINT8 action_type, tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, + tBTA_DM_BLE_REF_VALUE ref_value, tBTA_STATUS status); + +/* Status callback */ +typedef void (tBTA_DM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTA_STATUS status, + tBTA_DM_BLE_REF_VALUE ref_value); + + +#define BTA_DM_BLE_PF_BRDCAST_ADDR_FILT 1 +#define BTA_DM_BLE_PF_SERV_DATA_CHG_FILT 2 +#define BTA_DM_BLE_PF_SERV_UUID 4 +#define BTA_DM_BLE_PF_SERV_SOLC_UUID 8 +#define BTA_DM_BLE_PF_LOC_NAME_CHECK 16 +#define BTA_DM_BLE_PF_MANUF_NAME_CHECK 32 +#define BTA_DM_BLE_PF_SERV_DATA_CHECK 64 +typedef UINT16 tBTA_DM_BLE_PF_FEAT_SEL; + +#define BTA_DM_BLE_PF_LIST_LOGIC_OR 1 +#define BTA_DM_BLE_PF_LIST_LOGIC_AND 2 +typedef UINT16 tBTA_DM_BLE_PF_LIST_LOGIC_TYPE; + +#define BTA_DM_BLE_PF_FILT_LOGIC_OR 0 +#define BTA_DM_BLE_PF_FILT_LOGIC_AND 1 +typedef UINT16 tBTA_DM_BLE_PF_FILT_LOGIC_TYPE; + +typedef UINT8 tBTA_DM_BLE_PF_RSSI_THRESHOLD; +typedef UINT8 tBTA_DM_BLE_PF_DELIVERY_MODE; +typedef UINT16 tBTA_DM_BLE_PF_TIMEOUT; +typedef UINT8 tBTA_DM_BLE_PF_TIMEOUT_CNT; +typedef UINT16 tBTA_DM_BLE_PF_ADV_TRACK_ENTRIES; + +typedef struct { + tBTA_DM_BLE_PF_FEAT_SEL feat_seln; + tBTA_DM_BLE_PF_LIST_LOGIC_TYPE list_logic_type; + tBTA_DM_BLE_PF_FILT_LOGIC_TYPE filt_logic_type; + tBTA_DM_BLE_PF_RSSI_THRESHOLD rssi_high_thres; + tBTA_DM_BLE_PF_RSSI_THRESHOLD rssi_low_thres; + tBTA_DM_BLE_PF_DELIVERY_MODE dely_mode; + tBTA_DM_BLE_PF_TIMEOUT found_timeout; + tBTA_DM_BLE_PF_TIMEOUT lost_timeout; + tBTA_DM_BLE_PF_TIMEOUT_CNT found_timeout_cnt; + tBTA_DM_BLE_PF_ADV_TRACK_ENTRIES num_of_tracking_entries; +} tBTA_DM_BLE_PF_FILT_PARAMS; + +/* 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 */ +#define BTA_DM_INQ_DISCARD_NUM_EVT 7 /* The number of inquiry discarded packets */ + +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; + UINT8 flag; + UINT8 adv_data_len; + UINT8 scan_rsp_len; +#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_INQ_DISCARD_NUM_EVT */ +typedef struct { + UINT32 num_dis; /* The number of inquiry discarded packets. */ +} tBTA_DM_INQ_DISCARD; + +/* 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 */ + UINT32 num_uuids; + UINT8 *p_uuid_list; +// 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; + +/* Structure associated with tBTA_DM_RMTNAME_CMPL */ +typedef struct { + BD_ADDR bd_addr; + BD_NAME bd_name; + tBTA_CMPL_CB *read_rmtname_cb; +} tBTA_DM_RMTNAME_CMPL; + +/* 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_INQ_DISCARD inq_dis; /* the discarded packets information of inquiry */ + tBTA_DM_RMTNAME_CMPL rmt_name; /* the remote name information */ +} tBTA_DM_SEARCH; + +/* Structure of search callback event and structures */ +typedef struct { + tBTA_DM_SEARCH_EVT event; /* Search callback events */ + UINT16 len; /* Length of p_data */ + tBTA_DM_SEARCH *p_data; /* Union of all search callback structures */ +} tBTA_DM_SEARCH_PARAM; + +/* 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_TRANSPORT transport, tBTA_STATUS result); + +/* Relate to ESP_BLE_SEC_xxx in esp_gatt_defs.h */ +#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; + +typedef tBTM_BLE_TX_TIME_MS tBTA_DM_BLE_TX_TIME_MS; +typedef tBTM_BLE_RX_TIME_MS tBTA_DM_BLE_RX_TIME_MS; +typedef tBTM_BLE_IDLE_TIME_MS tBTA_DM_BLE_IDLE_TIME_MS; +typedef tBTM_BLE_ENERGY_USED tBTA_DM_BLE_ENERGY_USED; + +#define BTA_DM_CONTRL_UNKNOWN 0 /* Unknown state */ +#define BTA_DM_CONTRL_ACTIVE 1 /* ACL link on, SCO link ongoing, sniff mode */ +#define BTA_DM_CONTRL_SCAN 2 /* Scan state - paging/inquiry/trying to connect*/ +#define BTA_DM_CONTRL_IDLE 3 /* Idle state - page scan, LE advt, inquiry scan */ + +typedef UINT8 tBTA_DM_CONTRL_STATE; + +typedef UINT8 tBTA_DM_BLE_ADV_STATE; +typedef UINT8 tBTA_DM_BLE_ADV_INFO_PRESENT; +typedef UINT8 tBTA_DM_BLE_RSSI_VALUE; +typedef UINT16 tBTA_DM_BLE_ADV_INFO_TIMESTAMP; + +typedef tBTM_BLE_TRACK_ADV_DATA tBTA_DM_BLE_TRACK_ADV_DATA; + +typedef void (tBTA_BLE_SCAN_THRESHOLD_CBACK)(tBTA_DM_BLE_REF_VALUE ref_value); + +typedef void (tBTA_BLE_SCAN_REP_CBACK) (tBTA_DM_BLE_REF_VALUE ref_value, UINT8 report_format, + UINT8 num_records, UINT16 data_len, + UINT8 *p_rep_data, tBTA_STATUS status); + +typedef void (tBTA_BLE_SCAN_SETUP_CBACK) (tBTA_BLE_BATCH_SCAN_EVT evt, + tBTA_DM_BLE_REF_VALUE ref_value, + tBTA_STATUS status); + +typedef void (tBTA_START_STOP_SCAN_CMPL_CBACK) (tBTA_STATUS status); + +typedef void (tBTA_START_STOP_ADV_CMPL_CBACK) (tBTA_STATUS status); + +typedef void (tBTA_CLEAR_ADV_CMPL_CBACK) (tBTA_STATUS status); + +typedef void (tBTA_BLE_TRACK_ADV_CMPL_CBACK)(int action, tBTA_STATUS status, + tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, + tBTA_DM_BLE_REF_VALUE ref_value); + +typedef void (tBTA_BLE_TRACK_ADV_CBACK)(tBTA_DM_BLE_TRACK_ADV_DATA *p_adv_data); + +typedef void (tBTA_BLE_ENERGY_INFO_CBACK)(tBTA_DM_BLE_TX_TIME_MS tx_time, + tBTA_DM_BLE_RX_TIME_MS rx_time, + tBTA_DM_BLE_IDLE_TIME_MS idle_time, + tBTA_DM_BLE_ENERGY_USED energy_used, + tBTA_DM_CONTRL_STATE ctrl_state, + tBTA_STATUS status); + +#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_SUSPEND 0x04 /* prefers suspend mode */ +#define BTA_DM_PM_NO_PREF 0x01 /* service has no preference on power mode setting. eg. connection to service got closed */ + +typedef UINT8 tBTA_DM_PM_ACTION; + +/* index to bta_dm_ssr_spec */ +#define BTA_DM_PM_SSR0 0 +#define BTA_DM_PM_SSR1 1 /* BTA_DM_PM_SSR1 will be dedicated for + HH SSR setting entry, no other profile can use it */ +#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 + +#ifndef BTA_DM_PM_SNIFF_A2DP_IDX +#define BTA_DM_PM_SNIFF_A2DP_IDX BTA_DM_PM_SNIFF +#endif + +#ifndef BTA_DM_PM_SNIFF_AVK_IDLE_IDX +#define BTA_DM_PM_SNIFF_AVK_IDLE_IDX BTA_DM_PM_SNIFF4 +#endif + +#ifndef BTA_DM_PM_SNIFF_JV_IDX +#define BTA_DM_PM_SNIFF_JV_IDX BTA_DM_PM_SNIFF +#endif + +#ifndef BTA_DM_PM_SNIFF_HD_IDLE_IDX +#define BTA_DM_PM_SNIFF_HD_IDLE_IDX BTA_DM_PM_SNIFF4 +#endif + +#ifndef BTA_DM_PM_SNIFF_SCO_OPEN_IDX +#define BTA_DM_PM_SNIFF_SCO_OPEN_IDX BTA_DM_PM_SNIFF3 +#endif + +#ifndef BTA_DM_PM_SNIFF_HD_ACTIVE_IDX +#define BTA_DM_PM_SNIFF_HD_ACTIVE_IDX BTA_DM_PM_SNIFF5 +#endif + +#ifndef BTA_DM_PM_SNIFF_HH_OPEN_IDX +#define BTA_DM_PM_SNIFF_HH_OPEN_IDX BTA_DM_PM_SNIFF4 +#endif + +#ifndef BTA_DM_PM_SNIFF_HH_ACTIVE_IDX +#define BTA_DM_PM_SNIFF_HH_ACTIVE_IDX BTA_DM_PM_SNIFF4 +#endif + +#ifndef BTA_DM_PM_SNIFF_HH_IDLE_IDX +#define BTA_DM_PM_SNIFF_HH_IDLE_IDX BTA_DM_PM_SNIFF4 +#endif + +#ifndef BTA_DM_PM_HH_OPEN_DELAY +#define BTA_DM_PM_HH_OPEN_DELAY 30000 +#endif + +#ifndef BTA_DM_PM_HH_ACTIVE_DELAY +#define BTA_DM_PM_HH_ACTIVE_DELAY 30000 +#endif + +#ifndef BTA_DM_PM_HH_IDLE_DELAY +#define BTA_DM_PM_HH_IDLE_DELAY 30000 +#endif + +/* The Sniff Parameters defined below must be ordered from highest + * latency (biggest interval) to lowest latency. If there is a conflict + * among the connected services the setting with the lowest latency will + * be selected. If a device should override a sniff parameter then it + * must insure that order is maintained. + */ +#ifndef BTA_DM_PM_SNIFF_MAX +#define BTA_DM_PM_SNIFF_MAX 800 +#define BTA_DM_PM_SNIFF_MIN 400 +#define BTA_DM_PM_SNIFF_ATTEMPT 4 +#define BTA_DM_PM_SNIFF_TIMEOUT 1 +#endif + +#ifndef BTA_DM_PM_SNIFF1_MAX +#define BTA_DM_PM_SNIFF1_MAX 400 +#define BTA_DM_PM_SNIFF1_MIN 200 +#define BTA_DM_PM_SNIFF1_ATTEMPT 4 +#define BTA_DM_PM_SNIFF1_TIMEOUT 1 +#endif + +#ifndef BTA_DM_PM_SNIFF2_MAX +#define BTA_DM_PM_SNIFF2_MAX 180 //54 +#define BTA_DM_PM_SNIFF2_MIN 150 //30 +#define BTA_DM_PM_SNIFF2_ATTEMPT 4 +#define BTA_DM_PM_SNIFF2_TIMEOUT 1 +#endif + +#ifndef BTA_DM_PM_SNIFF3_MAX +#define BTA_DM_PM_SNIFF3_MAX 150 +#define BTA_DM_PM_SNIFF3_MIN 50 +#define BTA_DM_PM_SNIFF3_ATTEMPT 4 +#define BTA_DM_PM_SNIFF3_TIMEOUT 1 +#endif + +#ifndef BTA_DM_PM_SNIFF4_MAX +#define BTA_DM_PM_SNIFF4_MAX 54 //18 +#define BTA_DM_PM_SNIFF4_MIN 30 //10 +#define BTA_DM_PM_SNIFF4_ATTEMPT 4 +#define BTA_DM_PM_SNIFF4_TIMEOUT 1 +#endif + +#ifndef BTA_DM_PM_SNIFF5_MAX +#define BTA_DM_PM_SNIFF5_MAX 18 +#define BTA_DM_PM_SNIFF5_MIN 10 +#define BTA_DM_PM_SNIFF5_ATTEMPT 4 +#define BTA_DM_PM_SNIFF5_TIMEOUT 1 +#endif + +#ifndef BTA_DM_PM_PARK_MAX +#define BTA_DM_PM_PARK_MAX 800 +#define BTA_DM_PM_PARK_MIN 400 +#define BTA_DM_PM_PARK_ATTEMPT 0 +#define BTA_DM_PM_PARK_TIMEOUT 0 +#endif + + +/* 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; + +#if (SDP_INCLUDED == TRUE) +/* 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; +#endif ///SDP_INCLUDED == TRUE + +#ifndef BTA_DI_NUM_MAX +#define BTA_DI_NUM_MAX 3 +#endif + +/* Device features mask definitions */ +#define BTA_FEATURE_BYTES_PER_PAGE BTM_FEATURE_BYTES_PER_PAGE +#define BTA_EXT_FEATURES_PAGE_MAX BTM_EXT_FEATURES_PAGE_MAX +/* ACL type +*/ +#define BTA_DM_LINK_TYPE_BR_EDR 0x01 +#define BTA_DM_LINK_TYPE_LE 0x02 +#define BTA_DM_LINK_TYPE_ALL 0xFF +typedef UINT8 tBTA_DM_LINK_TYPE; + +#define IMMEDIATE_DELY_MODE 0x00 +#define ONFOUND_DELY_MODE 0x01 +#define BATCH_DELY_MODE 0x02 +#define ALLOW_ALL_FILTER 0x00 +#define LOWEST_RSSI_VALUE 129 +#if (BLE_50_FEATURE_SUPPORT == TRUE) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE (1 << 0) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE (1 << 1) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED (1 << 2) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED (1 << 3) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY (1 << 4) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_ANON_ADV (1 << 5) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_INCLUDE_TX_PWR (1 << 6) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_MASK (0x7F) + +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ + ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\ + ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_LD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ + ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\ + ESP_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_HD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ + ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\ + ESP_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_SCAN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ + ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE) +#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_NONCONN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY) +typedef UINT16 tBTA_DM_BLE_EXT_ADV_TYPE_MASK; + + +#define BTA_DM_BLE_GAP_PHY_1M 1 +#define BTA_DM_BLE_GAP_PHY_2M 2 +#define BTA_DM_BLE_GAP_PHY_CODED 3 +typedef UINT8 tBTA_DM_BLE_GAP_PHY; + +#define BTA_DM_BLE_GAP_PHY_NO_TX_PREF_MASK (0x01) +#define BTA_DM_BLE_GAP_PHY_NO_RX_PREF_MASK (0x02) +#define BTA_DM_BLE_GAP_PHY_1M_PREF_MASK (0x03) +#define BTA_DM_BLE_GAP_PHY_2M_PREF_MASK (0x04) +#define BTA_DM_BLE_GAP_PHY_CODED_PREF_MASK (0x05) +typedef UINT8 tBTA_DM_BLE_GAP_PHY_MASK; + +#define BTA_DM_BLE_GAP_EXT_SCAN_UNCODE_MASK 0x01 +#define BTA_DM_BLE_GAP_EXT_SCAN_CODE_MASK 0x02 +typedef UINT8 tBTA_DM_BLE_EXT_SCAN_CFG_MASK; + + +typedef struct { + tBTA_DM_BLE_EXT_ADV_TYPE_MASK type; + UINT32 interval_min; + UINT32 interval_max; + tBTA_BLE_ADV_CHNL_MAP channel_map; + tBLE_ADDR_TYPE own_addr_type; + tBLE_ADDR_TYPE peer_addr_type; + BD_ADDR peer_addr; + tBTA_BLE_AFP filter_policy; + INT8 tx_power; + tBTA_DM_BLE_GAP_PHY primary_phy; + UINT8 max_skip; + tBTA_DM_BLE_GAP_PHY secondary_phy; + UINT8 sid; + BOOLEAN scan_req_notif; +} tBTA_DM_BLE_GAP_EXT_ADV_PARAMS; + +typedef struct { + UINT8 instance; + int duration; + int max_events; +} tBTA_DM_BLE_EXT_ADV; + +typedef struct { + UINT16 interval_min; + UINT16 interval_max; + UINT8 properties; +} tBTA_DM_BLE_Periodic_Adv_Params; + +typedef struct { + UINT8 filter_policy; + #if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) + UINT8 reports_disabled; + UINT8 filter_duplicates; + #endif + UINT8 sid; + tBLE_ADDR_TYPE addr_type; + BD_ADDR addr; + UINT16 skip; + UINT16 sync_timeout; +} tBTA_DM_BLE_Periodic_Sync_Params; + +typedef struct { + tBLE_SCAN_MODE scan_type; + UINT16 scan_interval; + UINT16 scan_window; +} tBTA_DM_BLE_EXT_SCAN_CFG; + +typedef struct { + tBLE_ADDR_TYPE own_addr_type; + UINT8 filter_policy; + UINT8 scan_duplicate; + tBTA_DM_BLE_EXT_SCAN_CFG_MASK cfg_mask; + tBTA_DM_BLE_EXT_SCAN_CFG uncoded_cfg; + tBTA_DM_BLE_EXT_SCAN_CFG coded_cfg; +} tBTA_DM_BLE_EXT_SCAN_PARAMS; + +typedef struct { + UINT16 scan_interval; + UINT16 scan_window; + UINT16 interval_min; + UINT16 interval_max; + UINT16 latency; + UINT16 supervision_timeout; + UINT16 min_ce_len; + UINT16 max_ce_len; +} tBTA_DM_BLE_CONN_PARAMS; + +#define BTA_DM_BLE_5_GAP_READ_PHY_COMPLETE_EVT BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT BTM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT BTM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT BTM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT BTM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT BTM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_EXT_ADV_REPORT_EVT BTM_BLE_5_GAP_EXT_ADV_REPORT_EVT +#define BTA_DM_BLE_5_GAP_SCAN_TIMEOUT_EVT BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT +#define BTA_DM_BLE_5_GAP_ADV_TERMINATED_EVT BTM_BLE_5_GAP_ADV_TERMINATED_EVT +#define BTA_DM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT BTM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT +#define BTA_DM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT BTM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT +#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT +#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) +#define BTA_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT BTM_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT +#define BTA_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT +#define BTA_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT BTM_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT +#define BTA_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT BTM_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT +#define BTA_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT +#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) +#define BTA_DM_BLE_5_GAP_UNKNOWN_EVT BTM_BLE_5_GAP_UNKNOWN_EVT +typedef tBTM_BLE_5_GAP_EVENT tBTA_DM_BLE_5_GAP_EVENT; + +typedef tBTM_BLE_5_GAP_CB_PARAMS tBTA_DM_BLE_5_GAP_CB_PARAMS; +typedef tBTM_BLE_5_HCI_CBACK tBTA_DM_BLE_5_HCI_CBCAK; + +extern tBTM_BLE_5_HCI_CBACK ble_5_hci_cb; + +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) + +#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) +typedef struct { + UINT8 mode; + UINT16 skip; + UINT16 sync_timeout; + UINT8 cte_type; +} tBTA_DM_BLE_PAST_PARAMS; +#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) + +/***************************************************************************** +** 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. +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern tBTA_STATUS BTA_DisableBluetooth(void); + +/******************************************************************************* +** +** Function BTA_EnableTestMode +** +** Description Enables bluetooth device under test mode +** +** +** Returns tBTA_STATUS +** +*******************************************************************************/ +extern tBTA_STATUS BTA_EnableTestMode(void); + +/******************************************************************************* +** +** Function BTA_DisableTestMode +** +** Description Disable bluetooth device under test mode +** +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DisableTestMode(void); + +/******************************************************************************* +** +** Function BTA_DmSetDeviceName +** +** Description This function sets the Bluetooth name of the local device. +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmSetDeviceName(const char *p_name); + +/******************************************************************************* +** +** Function BTA_DmGetDeviceName +** +** Description This function gets the Bluetooth name of the local device. +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback); + +/******************************************************************************* +** +** Function BTA_DmCfgCoexStatus +** +** Description This function configures coexist status. +** +** +** Returns void +** +*******************************************************************************/ +#if (ESP_COEX_VSC_INCLUDED == TRUE) +extern void BTA_DmCfgCoexStatus(UINT8 op, UINT8 type, UINT8 status); +#endif + +/******************************************************************************* +** +** Function BTA_DmGetRemoteName +** +** Description This function gets the peer device's Bluetooth name. +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmGetRemoteName(BD_ADDR remote_addr, tBTA_CMPL_CB *read_remote_name_cb); + +/******************************************************************************* +** +** Function BTA_DmConfigEir +** +** Description This function config EIR data of the local device. +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config); + +/******************************************************************************* +** +** Function BTA_DmSetAfhChannels +** +** Description This function sets the AFH channels +** +** +** Returns void +** +*******************************************************************************/ +void BTA_DmSetAfhChannels(const uint8_t *channels, tBTA_CMPL_CB *set_afh_cb); + +#if (BTA_DM_QOS_INCLUDED == TRUE) +/******************************************************************************* +** +** Function BTA_DmSetQos +** +** Description This function sets the QOS +** +** +** Returns void +** +*******************************************************************************/ +void BTA_DmSetQos(BD_ADDR bd_addr, UINT32 t_poll, tBTM_CMPL_CB *p_cb); +#endif /// (BTA_DM_QOS_INCLUDED == TRUE) + +/******************************************************************************* +** +** Function BTA_DmSetPageTimeout +** +** Description This function sets the Bluetooth page timeout. +** +** +** Returns void +** +*******************************************************************************/ +void BTA_DmSetPageTimeout(UINT16 page_to, tBTM_CMPL_CB *p_cb); +/******************************************************************************* +** +** Function BTA_DmGetPageTimeout +** +** Description This function gets the Bluetooth page timeout. +** +** +** Returns void +** +*******************************************************************************/ +void BTA_DmGetPageTimeout(tBTM_CMPL_CB *p_cb); + +/******************************************************************************* +** +** Function BTA_DmSetAclPktTypes +** +** Description This function sets the packet types used for ACL traffic. +** +** +** Returns void +** +*******************************************************************************/ +void BTA_DmSetAclPktTypes(BD_ADDR remote_addr, UINT16 pkt_types, tBTM_CMPL_CB *p_cb); + +#if (BLE_INCLUDED == TRUE) +/******************************************************************************* +** +** Function BTA_DmBleSetChannels +** +** Description This function sets BLE channels +** +** +** Returns void +** +*******************************************************************************/ +void BTA_DmBleSetChannels(const uint8_t *channels, tBTA_CMPL_CB *set_channels_cb); + +extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_TYPE addr_type, tBTA_UPDATE_WHITELIST_CBACK *update_wl_cb); + +extern void BTA_DmClearWhiteList(tBTA_UPDATE_WHITELIST_CBACK *update_wl_cb); + +extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb); +#endif ///BLE_INCLUDED == TRUE + +extern void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb); + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +extern void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, UINT8 pairable_mode, UINT8 conn_filter); + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_DmSearchCancel(void); + +/******************************************************************************* +** +** Function BTA_DmDiscover +** +** Description This function performs service discovery for the services +** of a particular peer device. +** +** +** Returns void +** +*******************************************************************************/ +#if (SDP_INCLUDED == TRUE) +extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services, + tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search); +// btla-specific ++ +/******************************************************************************* +** +** Function BTA_DmDiscoverUUID +** +** Description This function performs service discovery for the services +** of a particular peer device. +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid, + tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search); +#endif ///SDP_INCLUDED == TRUE +/******************************************************************************* +** +** Function BTA_DmGetCachedRemoteName +** +** 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_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 +** +*******************************************************************************/ +extern void BTA_DmBond(BD_ADDR bd_addr); + +/******************************************************************************* +** +** Function BTA_DmBondByTransport +** +** Description This function initiates a bonding procedure with a peer +** device by designated transport. The bonding procedure enables +** authentication and optionally encryption on the Bluetooth link. +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBondByTransport(BD_ADDR bd_addr, tBTA_TRANSPORT transport); + + +/******************************************************************************* +** +** Function BTA_DmBondCancel +** +** Description This function cancels a bonding procedure with a peer +** device. +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBondCancel(BD_ADDR bd_addr); + +/******************************************************************************* +** +** Function BTA_DMSetPinType +** +** Description This function sets pin type as BTM_PIN_TYPE_FIXED or BTM_PIN_TYPE_VARIABLE +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DMSetPinType (UINT8 pin_type, UINT8 *pin_code, UINT8 pin_code_len); + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +extern void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, + UINT8 *p_pin); + +#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 +** +*******************************************************************************/ +extern void BTA_DmLocalOob(void); + +/******************************************************************************* +** +** Function BTA_DmOobReply +** +** This function is called to provide the OOB data for +** SMP in response to BTA_LE_OOB_REQ_EVT +** +** Parameters: bd_addr - Address of the peer device +** len - length of simple pairing Randomizer C +** p_value - simple pairing Randomizer C. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmOobReply(BD_ADDR bd_addr, UINT8 len, UINT8 *p_value); + +/******************************************************************************* +** +** Function BTA_DmSecureConnectionOobReply +** +** This function is called to provide the OOB data for +** SMP in response to BTA_LE_OOB_REQ_EVT when secure connection +** +** Parameters: bd_addr - Address of the peer device +** p_c - Pointer to Confirmation +** p_r - Pointer to Randomizer +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmSecureConnectionOobReply(BD_ADDR bd_addr, UINT8 *p_c, UINT8 *p_r); +/******************************************************************************* +** +** Function BTA_DmSecureConnectionCreateOobData +** +** This function is called to create the OOB data for +** SMP when secure connection +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmSecureConnectionCreateOobData(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 +** +*******************************************************************************/ +extern void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept); + +/******************************************************************************* +** +** Function BTA_DmPasskeyReqReply +** +** Description This function is called to provide the passkey for +** Simple Pairing in response to BTA_DM_SP_KEY_REQ_EVT +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmPasskeyReqReply(BOOLEAN accept, BD_ADDR bd_addr, UINT32 passkey); + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +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, UINT8 pin_length, + UINT8 sc_support); + +/******************************************************************************* +** +** 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. +** +*******************************************************************************/ +extern tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr, tBT_TRANSPORT transport); + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +extern void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services ); + +/******************************************************************************* +** +** Function BTA_DmGetConnectionState +** +** Description Returns whether the remote device is currently connected. +** +** Returns 0 if the device is NOT connected. +** +*******************************************************************************/ +extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr ); + +#if (SDP_INCLUDED == TRUE) +/******************************************************************************* +** +** Function BTA_DmSetLocalDiRecord +** +** Description This function adds a DI record to the local SDP database. +** +** Returns BTA_SUCCESS if record set successfully, otherwise error code. +** +*******************************************************************************/ +extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info, + UINT32 *p_handle ); +#endif ///SDP_INCLUDED == TRUE +/******************************************************************************* +** +** +** Function BTA_DmCloseACL +** +** Description This function force to close an ACL connection and remove the +** device from the security database list of known devices. +** +** Parameters: bd_addr - Address of the peer device +** remove_dev - remove device or not after link down +** transport - which transport to close + +** +** Returns void. +** +*******************************************************************************/ +extern void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transport); + +/******************************************************************************* +** +** 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 BTIF). +** +** Returns void +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_DmPcmInitSamples (UINT32 src_sps, UINT32 bits, UINT32 n_channels); + +/******************************************************************************* +** +** Function BTA_DmPcmDeinitSamples +** +** Description Deinitialize the down sample converter. +** +** Returns none +** +*******************************************************************************/ +extern void BTA_DmPcmDeinitSamples(void); + +/************************************************************************************** +** 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. +** +**************************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey); + +/******************************************************************************* +** +** Function BTA_DmBleSetStaticPasskey +** +** Description Set BLE SMP static passkey. +** +** Parameters: add - add static passkey when add is true +** clear static passkey when add is false +** passkey - static passkey value +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleSetStaticPasskey(bool add, uint32_t passkey); + +/******************************************************************************* +** +** Function BTA_DmBleConfirmReply +** +** Description Send BLE SMP SC user confirmation reply. +** +** Parameters: bd_addr - BD address of the peer +** accept - numbers to compare are the same or different. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept); + +/******************************************************************************* +** +** 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. +** auth_mode - auth mode +** addr_type - LE device address type. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, int auth_mode, + 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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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: scan_interval - scan interval +** scan_window - scan window +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmSetBleConnScanParams(UINT32 scan_interval, + UINT32 scan_window); + +/******************************************************************************* +** +** Function BTA_DmSetBleScanParams +** +** Description This function is called to set scan parameters +** +** Parameters: client_if - Client IF +** scan_interval - scan interval +** scan_window - scan window +** scan_mode - scan mode +** scan_param_setup_status_cback - Set scan param status callback +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval, + UINT32 scan_window, tBLE_SCAN_MODE scan_mode, + tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_status_cback); + + +/******************************************************************************* +** +** Function BTA_DmSetBleScanFilterParams +** +** Description This function is called to set scan parameters +** +** Parameters: client_if - Client IF +** scan_interval - scan interval +** scan_window - scan window +** scan_mode - scan mode +** scan_duplicate_filter - scan duplicate filter +** scan_param_setup_status_cback - Set scan param status callback +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, + UINT32 scan_window, tBLE_SCAN_MODE scan_mode, UINT8 scan_fil_poilcy, + UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback); + + +/******************************************************************************* +** +** Function BTA_DmSetBleAdvParams +** +** Description This function sets the advertising parameters BLE functionality. +** It is to be called when device act in peripheral or broadcaster +** role. +** +** Parameters: adv_int_min - adv interval minimum +** adv_int_max - adv interval max +** p_dir_bda - directed adv initator address +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max, + tBLE_BD_ADDR *p_dir_bda); + +extern void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max, + UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own, + tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol, + tBLE_BD_ADDR *p_dir_bda, tBTA_START_ADV_CMPL_CBACK p_start_adv_cb); + + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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_DmDiscoverByTransport +** +** Description This function does service discovery on particular transport +** 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 +** p_services->p_uuid. +** +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services, + tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search, + tBTA_TRANSPORT transport); + +/******************************************************************************* +** +** 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 +** transport - transport of the link to be encruypted +** 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 +** +** +*******************************************************************************/ +extern void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, + tBTA_DM_ENCRYPT_CBACK *p_callback, + tBTA_DM_BLE_SEC_ACT sec_act); + + +/******************************************************************************* +** +** Function BTA_DmBleObserve +** +** Description This procedure keep the device listening for advertising +** events from a broadcast device. +** +** Parameters start: start or stop observe. +** duration : Duration of the scan. Continuous scan if 0 is passed +** p_results_cb: Callback to be called with scan results +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleObserve(BOOLEAN start, UINT32 duration, + tBTA_DM_SEARCH_CBACK *p_results_cb, + tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_stop_scan_cb); + +/******************************************************************************* +** +** Function BTA_DmBleScan +** +** Description This procedure keep the device listening for advertising +** events from a broadcast device. +** +** Parameters start: start or stop observe. +** duration : Duration of the scan. Continuous scan if 0 is passed +** p_results_cb: Callback to be called with scan results +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleScan(BOOLEAN start, UINT32 duration, + tBTA_DM_SEARCH_CBACK *p_results_cb, + tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_stop_scan_cb); + +extern void BTA_DmBleStopAdvertising(void); + +extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback); +extern void BTA_DmClearRandAddress(void); + +#endif + +#if BLE_INCLUDED == TRUE +// btla-specific -- +/******************************************************************************* +** +** Function BTA_DmBleConfigLocalPrivacy +** +** Description Enable/disable privacy on the local device +** +** Parameters: privacy_enable - enable/disabe privacy on remote device. +** set_local_privacy_cback -callback to be called with result +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback); + +/******************************************************************************* +** +** Function BTA_DmBleConfigLocalIcon +** +** Description set gap local icon +** +** Parameters: icon - appearance value. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleConfigLocalIcon(uint16_t icon); + +/******************************************************************************* +** +** Function BTA_DmBleEnableRemotePrivacy +** +** Description Enable/disable privacy on a remote device +** +** Parameters: bd_addr - BD address of the peer +** privacy_enable - enable/disabe privacy on remote device. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleEnableRemotePrivacy(BD_ADDR bd_addr, BOOLEAN privacy_enable); + + +/******************************************************************************* +** +** Function BTA_DmBleSetAdvConfig +** +** Description This function is called to override the BTA default ADV parameters. +** +** Parameters Pointer to User defined ADV data structure +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, + tBTA_BLE_ADV_DATA *p_adv_cfg, + tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); + +/******************************************************************************* +** +** Function BTA_DmBleSetAdvConfigRaw +** +** Description This function is called to set raw Advertising data +** +** Parameters p_raw_adv : raw advertising data. +** raw_adv_len : raw advertising data length. +** p_adv_data_cback : set adv data complete callback. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleSetAdvConfigRaw (UINT8 *p_raw_adv, UINT32 raw_adv_len, + tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); + +/******************************************************************************* +** +** Function BTA_DmBleSetLongAdv +** +** Description This function is called to set long Advertising data +** +** Parameters adv_data : long advertising data. +** adv_data_len : long advertising data length. +** p_adv_data_cback : set long adv data complete callback. +** +** Returns None +** +*******************************************************************************/ +void BTA_DmBleSetLongAdv (UINT8 *adv_data, UINT32 adv_data_len, + tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); + +/******************************************************************************* +** +** Function BTA_DmBleClearAdv +** +** Description This function is called to clear Advertising +** +** Parameters p_adv_data_cback : clear adv complete callback. +** +** Returns None +** +*******************************************************************************/ +void BTA_DmBleClearAdv (tBTA_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback); + +/******************************************************************************* +** +** Function BTA_DmBleSetScanRsp +** +** Description This function is called to override the BTA scan response. +** +** Parameters Pointer to User defined ADV data structure +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, + tBTA_BLE_ADV_DATA *p_adv_cfg, + tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); + +/******************************************************************************* +** +** Function BTA_DmBleSetScanRspRaw +** +** Description This function is called to set raw scan response data +** +** Parameters p_raw_scan_rsp : raw scan_rspertising data. +** raw_scan_rsp_len : raw scan_rspertising data length. +** p_scan_rsp_data_cback : set scan_rsp data complete callback. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len, + tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback); + +/******************************************************************************* +** +** Function BTA_DmUpdateDuplicateExceptionalList +** +** Description This function is called to update duplicate scan exceptional list +** +** Parameters subcode : add, remove or clean duplicate scan exceptional list. +** type : device info type. +** device_info: device info +** p_update_duplicate_ignore_list_cback : update complete callback. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type, + BD_ADDR device_info, + tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_exceptional_list_cback); + +/******************************************************************************* +** +** Function BTA_DmBleBroadcast +** +** Description This function starts or stops LE broadcasting. +** +** Parameters start: start or stop broadcast. +** p_start_stop_adv_cb: stop broadcast completed event +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p_start_stop_adv_cb); + + +/******************************************************************************* +** +** Function BTA_BleEnableAdvInstance +** +** Description This function enables the Multi ADV instance feature +** +** Parameters p_params Pointer to ADV param user defined structure +** p_cback Pointer to Multi ADV callback structure +** p_ref - Reference pointer +** +** Returns None +** +*******************************************************************************/ +extern void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params, + tBTA_BLE_MULTI_ADV_CBACK *p_cback, void *p_ref); + +/******************************************************************************* +** +** Function BTA_BleUpdateAdvInstParam +** +** Description This function updates the Multi ADV instance params +** +** Parameters inst_id Instance ID +** p_params Pointer to ADV param user defined structure +** +** Returns None +** +*******************************************************************************/ +extern void BTA_BleUpdateAdvInstParam (UINT8 inst_id, + tBTA_BLE_ADV_PARAMS *p_params); + +/******************************************************************************* +** +** Function BTA_BleCfgAdvInstData +** +** Description This function is called to configure the ADV instance data +** +** Parameters inst_id - Instance ID +** is_scan_rsp - Boolean value Scan response +** Pointer to User defined ADV data structure +** Returns None +** +*******************************************************************************/ +extern void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp, + tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_data); + +/******************************************************************************* +** +** Function BTA_BleDisableAdvInstance +** +** Description This function is called to disable the ADV instance +** +** Parameters inst_id - Instance ID to be disabled +** +** Returns None +** +*******************************************************************************/ +extern void BTA_BleDisableAdvInstance(UINT8 inst_id); + +/******************************************************************************* +** +** Function BTA_DmBleUpdateConnectionParams +** +** Description Update connection parameters, can only be used when connection is up. +** +** Parameters: bd_addr - BD address of the peer +** min_int - minimum connection interval, [0x0004~ 0x4000] +** max_int - maximum connection interval, [0x0004~ 0x4000] +** latency - slave latency [0 ~ 500] +** timeout - supervision timeout [0x000a ~ 0xc80] +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, + UINT16 max_int, UINT16 latency, UINT16 timeout); + +/******************************************************************************* +** +** Function BTA_DmBleDisconnect +** +** Description This function is to disconnect the ble connection +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleDisconnect(BD_ADDR bd_addr); + +/******************************************************************************* +** +** Function BTA_DmBleSetDataLength +** +** Description This function is to set maximum LE data packet size +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length, tBTA_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback); + +extern void BTA_DmBleDtmTxStart(uint8_t tx_channel, uint8_t len_of_data, uint8_t pkt_payload, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); +extern void BTA_DmBleDtmRxStart(uint8_t rx_channel, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); +extern void BTA_DmBleDtmStop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); + +/******************************************************************************* +** +** Function BTA_DmBleSetStorageParams +** +** Description This function is called to set the storage parameters +** +** Parameters batch_scan_full_max -Max storage space (in %) allocated to full scanning +** batch_scan_trunc_max -Max storage space (in %) allocated to truncated scanning +** batch_scan_notify_threshold - Setup notification level based on total space +** consumed by both pools. Setting it to 0 will disable threshold notification +** p_setup_cback - Setup callback +** p_thres_cback - Threshold callback +** p_rep_cback - Reports callback +** ref_value - Reference value +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max, + UINT8 batch_scan_trunc_max, + UINT8 batch_scan_notify_threshold, + tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback, + tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback, + tBTA_BLE_SCAN_REP_CBACK *p_rep_cback, + tBTA_DM_BLE_REF_VALUE ref_value); + +/******************************************************************************* +** +** Function BTA_DmBleEnableBatchScan +** +** Description This function is called to enable the batch scan +** +** Parameters scan_mode -Batch scan mode +** scan_interval - Scan interval +** scan_window - Scan window +** discard_rule -Discard rules +** addr_type - Address type +** ref_value - Reference value +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode, + UINT32 scan_interval, UINT32 scan_window, + tBTA_BLE_DISCARD_RULE discard_rule, + tBLE_ADDR_TYPE addr_type, + tBTA_DM_BLE_REF_VALUE ref_value); + +/******************************************************************************* +** +** Function BTA_DmBleReadScanReports +** +** Description This function is called to read the batch scan reports +** +** Parameters scan_mode -Batch scan mode +** ref_value - Reference value +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type, + tBTA_DM_BLE_REF_VALUE ref_value); + +/******************************************************************************* +** +** Function BTA_DmBleDisableBatchScan +** +** Description This function is called to disable the batch scanning +** +** Parameters ref_value - Reference value +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value); + +/******************************************************************************* +** +** Function BTA_DmEnableScanFilter +** +** Description This function is called to enable the adv data payload filter +** +** Parameters action - enable or disable the APCF feature +** p_cmpl_cback - Command completed callback +** ref_value - Reference value +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmEnableScanFilter(UINT8 action, + tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cback, + tBTA_DM_BLE_REF_VALUE ref_value); + +/******************************************************************************* +** +** Function BTA_DmBleScanFilterSetup +** +** Description This function is called to setup the filter params +** +** Parameters p_target: enable the filter condition on a target device; if NULL +** filt_index - Filter index +** p_filt_params -Filter parameters +** ref_value - Reference value +** action - Add, delete or clear +** p_cmpl_back - Command completed callback +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleScanFilterSetup(UINT8 action, + tBTA_DM_BLE_PF_FILT_INDEX filt_index, + tBTA_DM_BLE_PF_FILT_PARAMS *p_filt_params, + tBLE_BD_ADDR *p_target, + tBTA_DM_BLE_PF_PARAM_CBACK *p_cmpl_cback, + tBTA_DM_BLE_REF_VALUE ref_value); + +/******************************************************************************* +** +** Function BTA_DmBleCfgFilterCondition +** +** Description This function is called to configure the adv data payload filter +** condition. +** +** Parameters action: to read/write/clear +** cond_type: filter condition type +** filt_index - Filter index +** p_cond: filter condition parameter +** p_cmpl_back - Command completed callback +** ref_value - Reference value +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action, + tBTA_DM_BLE_PF_COND_TYPE cond_type, + tBTA_DM_BLE_PF_FILT_INDEX filt_index, + tBTA_DM_BLE_PF_COND_PARAM *p_cond, + tBTA_DM_BLE_PF_CFG_CBACK *p_cmpl_cback, + tBTA_DM_BLE_REF_VALUE ref_value); + + +/******************************************************************************* +** +** Function BTA_DmBleTrackAdvertiser +** +** Description This function is called to track the advertiser +** +** Parameters ref_value - Reference value +** p_track_adv_cback - ADV callback +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value, + tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback); + +/******************************************************************************* +** +** Function BTA_DmBleGetEnergyInfo +** +** Description This function is called to obtain the energy info +** +** Parameters p_cmpl_cback - Command complete callback +** +** Returns void +** +*******************************************************************************/ +extern void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK *p_cmpl_cback); + +/******************************************************************************* +** +** Function BTA_BrcmInit +** +** Description This function initializes Broadcom specific VS handler in BTA +** +** Returns void +** +*******************************************************************************/ +extern void BTA_VendorInit (void); + +/******************************************************************************* +** +** Function BTA_BrcmCleanup +** +** Description This function frees up Broadcom specific VS specific dynamic memory +** +** Returns void +** +*******************************************************************************/ +extern void BTA_VendorCleanup (void); + +#if (BLE_50_FEATURE_SUPPORT == TRUE) +extern void BTA_DmBleGapReadPHY(BD_ADDR addr); + +extern void BTA_DmBleGapSetPreferedDefaultPHY(tBTA_DM_BLE_GAP_PHY_MASK tx_phy_mask, + tBTA_DM_BLE_GAP_PHY_MASK rx_phy_mask); + +extern void BTA_DmBleGapSetPreferedPHY(BD_ADDR addr, + UINT8 all_phys, + tBTA_DM_BLE_GAP_PHY_MASK tx_phy_mask, + tBTA_DM_BLE_GAP_PHY_MASK rx_phy_mask, + UINT16 phy_options); + +extern void BTA_DmBleGapExtAdvSetRandaddr(UINT16 instance, BD_ADDR addr); + +extern void BTA_DmBleGapExtAdvSetParams(UINT16 instance, + const tBTA_DM_BLE_GAP_EXT_ADV_PARAMS *params); + +extern void BTA_DmBleGapConfigExtAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 length, + const UINT8 *data); + +extern void BTA_DmBleGapStartExtAdv(UINT8 num, tBTA_DM_BLE_EXT_ADV *ext_adv); + +extern void BTA_DmBleGapExtAdvEnable(BOOLEAN enable, UINT8 num, tBTA_DM_BLE_EXT_ADV *ext_adv); + +extern void BTA_DmBleGapExtAdvSetRemove(UINT8 instance); + +extern void BTA_DmBleGapExtAdvSetClear(void); + +extern void BTA_DmBleGapPeriodicAdvSetParams(UINT8 instance, + tBTA_DM_BLE_Periodic_Adv_Params *params); + +extern void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length, + const UINT8 *data,BOOLEAN only_update_did); + +extern void BTA_DmBleGapPeriodicAdvEnable(UINT8 enable, UINT8 instance); + +extern void BTA_DmBleGapPeriodicAdvCreateSync(tBTA_DM_BLE_Periodic_Sync_Params *params); + +extern void BTA_DmBleGapPeriodicAdvSyncCancel(void); + +extern void BTA_DmBleGapPeriodicAdvSyncTerm(UINT16 sync_handle); + +extern void BTA_DmBleGapPeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type, + BD_ADDR addr, + UINT16 sid); + +extern void BTA_DmBleGapPeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type, + BD_ADDR addr, + UINT16 sid); + +extern void BTA_DmBleGapPeriodicAdvClearDev(void); + +extern void BTA_DmBleGapSetExtScanParams(tBTA_DM_BLE_EXT_SCAN_PARAMS *params); + +extern void BTA_DmBleGapExtScan(BOOLEAN start, UINT32 duration, UINT16 period); + +extern void BTA_DmBleGapPreferExtConnectParamsSet(BD_ADDR bd_addr, + UINT8 phy_mask, + const tBTA_DM_BLE_CONN_PARAMS *phy_1m_conn_params, + const tBTA_DM_BLE_CONN_PARAMS *phy_2m_conn_params, + const tBTA_DM_BLE_CONN_PARAMS *phy_coded_conn_params); + +extern void BTA_DmBleGapExtConnect(tBLE_ADDR_TYPE own_addr_type, const BD_ADDR peer_addr); + +extern void BTA_DmBleDtmEnhTxStart(uint8_t tx_channel, uint8_t len_of_data, uint8_t pkt_payload, uint8_t phy, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); + +extern void BTA_DmBleDtmEnhRxStart(uint8_t rx_channel, uint8_t phy, uint8_t modulation_index, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) + +#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) +extern void BTA_DmBleGapPeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable); + +extern void BTA_DmBleGapPeriodicAdvSyncTrans(BD_ADDR peer_addr, UINT16 service_data, UINT16 sync_handle); + +extern void BTA_DmBleGapPeriodicAdvSetInfoTrans(BD_ADDR peer_addr, UINT16 service_data, UINT8 adv_handle); + +extern void BTA_DmBleGapSetPeriodicAdvSyncTransParams(BD_ADDR peer_addr, tBTA_DM_BLE_PAST_PARAMS *params); +#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) + +#endif + +enum { + BTA_COEX_EVT_SCAN_STARTED = 1, + BTA_COEX_EVT_SCAN_STOPPED, + BTA_COEX_EVT_ACL_CONNECTED, + BTA_COEX_EVT_ACL_DISCONNECTED, + BTA_COEX_EVT_STREAMING_STARTED, + BTA_COEX_EVT_STREAMING_STOPPED, + BTA_COEX_EVT_SNIFF_ENTER, + BTA_COEX_EVT_SNIFF_EXIT, + BTA_COEX_EVT_A2DP_PAUSED_ENTER, + BTA_COEX_EVT_A2DP_PAUSED_EXIT, +}; + +extern void BTA_DmCoexEventTrigger(uint32_t event); + +#ifdef __cplusplus +} +#endif + +#endif /* BTA_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_ar_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_ar_api.h new file mode 100644 index 00000000..2823d674 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_ar_api.h @@ -0,0 +1,144 @@ +/****************************************************************************** + * + * Copyright (C) 2004-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the public interface file for the simulatenous advanced + * audio/video streaming (AV) source and sink of BTA, Broadcom's Bluetooth + * application layer for mobile phones. + * + ******************************************************************************/ +#ifndef BTA_AR_API_H +#define BTA_AR_API_H + +#include "stack/avdt_api.h" +#include "stack/avct_api.h" +#include "stack/avrc_api.h" +#include "stack/sdp_api.h" +#include "bta/bta_av_api.h" +#include "bta/bta_sys.h" + +#if (BTA_AR_INCLUDED == TRUE) + +/***************************************************************************** +** Constants and data types +*****************************************************************************/ +/* This event signal to AR user that other profile is connected */ +#define BTA_AR_AVDT_CONN_EVT (AVDT_MAX_EVT + 1) + +/******************************************************************************* +** +** Function bta_ar_init +** +** Description This function is called from bta_sys_init(). +** to initialize the control block +** +** Returns void +** +*******************************************************************************/ +extern void bta_ar_init(void); + +/******************************************************************************* +** +** Function bta_ar_reg_avdt +** +** Description This function is called to register to AVDTP. +** +** Returns void +** +*******************************************************************************/ +extern void bta_ar_reg_avdt(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback, tBTA_SYS_ID sys_id); + +/******************************************************************************* +** +** Function bta_ar_dereg_avdt +** +** Description This function is called to de-register from AVDTP. +** +** Returns void +** +*******************************************************************************/ +extern void bta_ar_dereg_avdt(tBTA_SYS_ID sys_id); + +/******************************************************************************* +** +** Function bta_ar_avdt_conn +** +** Description This function is called to let ar know that some AVDTP profile +** is connected for this sys_id. +** If the other sys modules started a timer for PENDING_EVT, +** the timer can be stopped now. +** +** Returns void +** +*******************************************************************************/ +extern void bta_ar_avdt_conn(tBTA_SYS_ID sys_id, BD_ADDR bd_addr); + +/******************************************************************************* +** +** Function bta_ar_reg_avct +** +** Description This function is called to register to AVCTP. +** +** Returns void +** +*******************************************************************************/ +extern void bta_ar_reg_avct(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask, tBTA_SYS_ID sys_id); + +/******************************************************************************* +** +** Function bta_ar_dereg_avct +** +** Description This function is called to deregister from AVCTP. +** +** Returns void +** +*******************************************************************************/ +extern void bta_ar_dereg_avct(tBTA_SYS_ID sys_id); + +/****************************************************************************** +** +** Function bta_ar_reg_avrc +** +** Description This function is called to register an SDP record for AVRCP. +** +** Returns void +** +******************************************************************************/ +extern void bta_ar_reg_avrc(UINT16 service_uuid, char *p_service_name, char *p_provider_name, + UINT16 categories, tBTA_SYS_ID sys_id, BOOLEAN browsing_en); + +/****************************************************************************** +** +** Function bta_ar_dereg_avrc +** +** Description This function is called to de-register/delete an SDP record for AVRCP. +** +** Returns void +** +******************************************************************************/ +extern void bta_ar_dereg_avrc(UINT16 service_uuid, tBTA_SYS_ID sys_id); + + +#ifdef __cplusplus +} +#endif + +#endif ///BTA_AR_INCLUDED == TRUE + +#endif /* BTA_AR_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_av_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_av_api.h new file mode 100644 index 00000000..ddf72b96 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_av_api.h @@ -0,0 +1,874 @@ +/****************************************************************************** + * + * Copyright (C) 2004-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the public interface file for the advanced audio/video streaming + * (AV) subsystem of BTA, Broadcom's Bluetooth application layer for mobile + * phones. + * + ******************************************************************************/ +#ifndef BTA_AV_API_H +#define BTA_AV_API_H + +#include "stack/avrc_api.h" +#include "stack/avdt_api.h" +#include "stack/a2d_api.h" +#include "bta/bta_api.h" + +#if (BTA_AV_INCLUDED == TRUE) + +/***************************************************************************** +** Constants and data types +*****************************************************************************/ +/* AV status values */ +#define BTA_AV_SUCCESS 0 /* successful operation */ +#define BTA_AV_FAIL 1 /* generic failure */ +#define BTA_AV_FAIL_SDP 2 /* service not found */ +#define BTA_AV_FAIL_STREAM 3 /* stream connection failed */ +#define BTA_AV_FAIL_RESOURCES 4 /* no resources */ +#define BTA_AV_FAIL_ROLE 5 /* failed due to role management related issues */ +#define BTA_AV_FAIL_GET_CAP 6 /* get capability failed due to no SEP availale on the peer */ + +typedef UINT8 tBTA_AV_STATUS; + +/* AV features masks */ +#define BTA_AV_FEAT_RCTG 0x0001 /* remote control target */ +#define BTA_AV_FEAT_RCCT 0x0002 /* remote control controller */ +#define BTA_AV_FEAT_PROTECT 0x0004 /* streaming media contect protection */ +#define BTA_AV_FEAT_VENDOR 0x0008 /* remote control vendor dependent commands */ +#define BTA_AV_FEAT_REPORT 0x0020 /* use reporting service for VDP */ +#define BTA_AV_FEAT_METADATA 0x0040 /* remote control Metadata Transfer command/response */ +#define BTA_AV_FEAT_MULTI_AV 0x0080 /* use multi-av, if controller supports it */ +#define BTA_AV_FEAT_BROWSE 0x0010 /* use browsing channel */ +#define BTA_AV_FEAT_MASTER 0x0100 /* stream only as master role */ +#define BTA_AV_FEAT_ADV_CTRL 0x0200 /* remote control Advanced Control command/response */ +#define BTA_AV_FEAT_DELAY_RPT 0x0400 /* allow delay reporting */ +#define BTA_AV_FEAT_ACP_START 0x0800 /* start stream when 2nd SNK was accepted */ + +/* Internal features */ +#define BTA_AV_FEAT_NO_SCO_SSPD 0x8000 /* Do not suspend av streaming as to AG events(SCO or Call) */ + +/* Protocol service capabilities mask*/ +#define BTA_AV_PSC_DEALY_RPT (1<<0) /* Delay Report */ + +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 1 +#endif + +#ifndef BTA_AV_MAX_A2DP_MTU +/*#define BTA_AV_MAX_A2DP_MTU 668 //224 (DM5) * 3 - 4(L2CAP header) */ +#define BTA_AV_MAX_A2DP_MTU 1008 +#endif + +#ifndef BTA_AV_MAX_VDP_MTU +#define BTA_AV_MAX_VDP_MTU 1008 +#endif + + +/* codec type */ +#define BTA_AV_CODEC_SBC A2D_MEDIA_CT_SBC /* SBC media codec type */ +#define BTA_AV_CODEC_M12 A2D_MEDIA_CT_M12 /* MPEG-1, 2 Audio media codec type */ +#define BTA_AV_CODEC_M24 A2D_MEDIA_CT_M24 /* MPEG-2, 4 AAC media codec type */ +#define BTA_AV_CODEC_ATRAC A2D_MEDIA_CT_ATRAC /* ATRAC family media codec type */ +#define BTA_AV_CODEC_H263_P0 VDP_MEDIA_CT_H263_P0 /* H.263 baseline (profile 0) */ +#define BTA_AV_CODEC_MPEG4 VDP_MEDIA_CT_MPEG4 /* MPEG-4 Visual Simple Profile */ +#define BTA_AV_CODEC_H263_P3 VDP_MEDIA_CT_H263_P3 /* H.263 profile 3 */ +#define BTA_AV_CODEC_H263_P8 VDP_MEDIA_CT_H263_P8 /* H.263 profile 8 */ +#define BTA_AV_CODEC_VEND VDP_MEDIA_CT_VEND /* Non-VDP */ + +typedef UINT8 tBTA_AV_CODEC; + +/* Company ID in BT assigned numbers */ +#define BTA_AV_BT_VENDOR_ID VDP_BT_VENDOR_ID /* Broadcom Corporation */ + +/* vendor specific codec ID */ +#define BTA_AV_CODEC_ID_H264 VDP_CODEC_ID_H264 /* Non-VDP codec ID - H.264 */ +#define BTA_AV_CODEC_ID_IMG VDP_CODEC_ID_IMG /* Non-VDP codec ID - images/slideshow */ + +/* operation id list for BTA_AvRemoteCmd */ +#define BTA_AV_RC_SELECT AVRC_ID_SELECT /* select */ +#define BTA_AV_RC_UP AVRC_ID_UP /* up */ +#define BTA_AV_RC_DOWN AVRC_ID_DOWN /* down */ +#define BTA_AV_RC_LEFT AVRC_ID_LEFT /* left */ +#define BTA_AV_RC_RIGHT AVRC_ID_RIGHT /* right */ +#define BTA_AV_RC_RIGHT_UP AVRC_ID_RIGHT_UP /* right-up */ +#define BTA_AV_RC_RIGHT_DOWN AVRC_ID_RIGHT_DOWN /* right-down */ +#define BTA_AV_RC_LEFT_UP AVRC_ID_LEFT_UP /* left-up */ +#define BTA_AV_RC_LEFT_DOWN AVRC_ID_LEFT_DOWN /* left-down */ +#define BTA_AV_RC_ROOT_MENU AVRC_ID_ROOT_MENU /* root menu */ +#define BTA_AV_RC_SETUP_MENU AVRC_ID_SETUP_MENU /* setup menu */ +#define BTA_AV_RC_CONT_MENU AVRC_ID_CONT_MENU /* contents menu */ +#define BTA_AV_RC_FAV_MENU AVRC_ID_FAV_MENU /* favorite menu */ +#define BTA_AV_RC_EXIT AVRC_ID_EXIT /* exit */ +#define BTA_AV_RC_0 AVRC_ID_0 /* 0 */ +#define BTA_AV_RC_1 AVRC_ID_1 /* 1 */ +#define BTA_AV_RC_2 AVRC_ID_2 /* 2 */ +#define BTA_AV_RC_3 AVRC_ID_3 /* 3 */ +#define BTA_AV_RC_4 AVRC_ID_4 /* 4 */ +#define BTA_AV_RC_5 AVRC_ID_5 /* 5 */ +#define BTA_AV_RC_6 AVRC_ID_6 /* 6 */ +#define BTA_AV_RC_7 AVRC_ID_7 /* 7 */ +#define BTA_AV_RC_8 AVRC_ID_8 /* 8 */ +#define BTA_AV_RC_9 AVRC_ID_9 /* 9 */ +#define BTA_AV_RC_DOT AVRC_ID_DOT /* dot */ +#define BTA_AV_RC_ENTER AVRC_ID_ENTER /* enter */ +#define BTA_AV_RC_CLEAR AVRC_ID_CLEAR /* clear */ +#define BTA_AV_RC_CHAN_UP AVRC_ID_CHAN_UP /* channel up */ +#define BTA_AV_RC_CHAN_DOWN AVRC_ID_CHAN_DOWN /* channel down */ +#define BTA_AV_RC_PREV_CHAN AVRC_ID_PREV_CHAN /* previous channel */ +#define BTA_AV_RC_SOUND_SEL AVRC_ID_SOUND_SEL /* sound select */ +#define BTA_AV_RC_INPUT_SEL AVRC_ID_INPUT_SEL /* input select */ +#define BTA_AV_RC_DISP_INFO AVRC_ID_DISP_INFO /* display information */ +#define BTA_AV_RC_HELP AVRC_ID_HELP /* help */ +#define BTA_AV_RC_PAGE_UP AVRC_ID_PAGE_UP /* page up */ +#define BTA_AV_RC_PAGE_DOWN AVRC_ID_PAGE_DOWN /* page down */ +#define BTA_AV_RC_POWER AVRC_ID_POWER /* power */ +#define BTA_AV_RC_VOL_UP AVRC_ID_VOL_UP /* volume up */ +#define BTA_AV_RC_VOL_DOWN AVRC_ID_VOL_DOWN /* volume down */ +#define BTA_AV_RC_MUTE AVRC_ID_MUTE /* mute */ +#define BTA_AV_RC_PLAY AVRC_ID_PLAY /* play */ +#define BTA_AV_RC_STOP AVRC_ID_STOP /* stop */ +#define BTA_AV_RC_PAUSE AVRC_ID_PAUSE /* pause */ +#define BTA_AV_RC_RECORD AVRC_ID_RECORD /* record */ +#define BTA_AV_RC_REWIND AVRC_ID_REWIND /* rewind */ +#define BTA_AV_RC_FAST_FOR AVRC_ID_FAST_FOR /* fast forward */ +#define BTA_AV_RC_EJECT AVRC_ID_EJECT /* eject */ +#define BTA_AV_RC_FORWARD AVRC_ID_FORWARD /* forward */ +#define BTA_AV_RC_BACKWARD AVRC_ID_BACKWARD /* backward */ +#define BTA_AV_RC_ANGLE AVRC_ID_ANGLE /* angle */ +#define BTA_AV_RC_SUBPICT AVRC_ID_SUBPICT /* subpicture */ +#define BTA_AV_RC_F1 AVRC_ID_F1 /* F1 */ +#define BTA_AV_RC_F2 AVRC_ID_F2 /* F2 */ +#define BTA_AV_RC_F3 AVRC_ID_F3 /* F3 */ +#define BTA_AV_RC_F4 AVRC_ID_F4 /* F4 */ +#define BTA_AV_RC_F5 AVRC_ID_F5 /* F5 */ +#define BTA_AV_VENDOR AVRC_ID_VENDOR /* vendor unique */ + +typedef UINT8 tBTA_AV_RC; + +/* state flag for pass through command */ +#define BTA_AV_STATE_PRESS AVRC_STATE_PRESS /* key pressed */ +#define BTA_AV_STATE_RELEASE AVRC_STATE_RELEASE /* key released */ + +typedef UINT8 tBTA_AV_STATE; + +/* command codes for BTA_AvVendorCmd */ +#define BTA_AV_CMD_CTRL AVRC_CMD_CTRL +#define BTA_AV_CMD_STATUS AVRC_CMD_STATUS +#define BTA_AV_CMD_SPEC_INQ AVRC_CMD_SPEC_INQ +#define BTA_AV_CMD_NOTIF AVRC_CMD_NOTIF +#define BTA_AV_CMD_GEN_INQ AVRC_CMD_GEN_INQ + +typedef UINT8 tBTA_AV_CMD; + +/* response codes for BTA_AvVendorRsp */ +#define BTA_AV_RSP_NOT_IMPL AVRC_RSP_NOT_IMPL +#define BTA_AV_RSP_ACCEPT AVRC_RSP_ACCEPT +#define BTA_AV_RSP_REJ AVRC_RSP_REJ +#define BTA_AV_RSP_IN_TRANS AVRC_RSP_IN_TRANS +#define BTA_AV_RSP_IMPL_STBL AVRC_RSP_IMPL_STBL +#define BTA_AV_RSP_CHANGED AVRC_RSP_CHANGED +#define BTA_AV_RSP_INTERIM AVRC_RSP_INTERIM + +typedef UINT8 tBTA_AV_CODE; + +/* error codes for BTA_AvProtectRsp */ +#define BTA_AV_ERR_NONE A2D_SUCCESS /* Success, no error */ +#define BTA_AV_ERR_BAD_STATE AVDT_ERR_BAD_STATE /* Message cannot be processed in this state */ +#define BTA_AV_ERR_RESOURCE AVDT_ERR_RESOURCE /* Insufficient resources */ +#define BTA_AV_ERR_BAD_CP_TYPE A2D_BAD_CP_TYPE /* The requested Content Protection Type is not supported */ +#define BTA_AV_ERR_BAD_CP_FORMAT A2D_BAD_CP_FORMAT /* The format of Content Protection Data is not correct */ + +typedef UINT8 tBTA_AV_ERR; + + +/* AV callback events */ +#define BTA_AV_ENABLE_EVT 0 /* AV enabled */ +#define BTA_AV_REGISTER_EVT 1 /* registered to AVDT */ +#define BTA_AV_OPEN_EVT 2 /* connection opened */ +#define BTA_AV_CLOSE_EVT 3 /* connection closed */ +#define BTA_AV_START_EVT 4 /* stream data transfer started */ +#define BTA_AV_STOP_EVT 5 /* stream data transfer stopped */ +#define BTA_AV_PROTECT_REQ_EVT 6 /* content protection request */ +#define BTA_AV_PROTECT_RSP_EVT 7 /* content protection response */ +#define BTA_AV_RC_OPEN_EVT 8 /* remote control channel open */ +#define BTA_AV_RC_CLOSE_EVT 9 /* remote control channel closed */ +#define BTA_AV_REMOTE_CMD_EVT 10 /* remote control command */ +#define BTA_AV_REMOTE_RSP_EVT 11 /* remote control response */ +#define BTA_AV_VENDOR_CMD_EVT 12 /* vendor dependent remote control command */ +#define BTA_AV_VENDOR_RSP_EVT 13 /* vendor dependent remote control response */ +#define BTA_AV_RECONFIG_EVT 14 /* reconfigure response */ +#define BTA_AV_SUSPEND_EVT 15 /* suspend response */ +#define BTA_AV_PENDING_EVT 16 /* incoming connection pending: + * signal channel is open and stream is not open + * after BTA_AV_SIG_TIME_VAL ms */ +#define BTA_AV_META_MSG_EVT 17 /* metadata messages */ +#define BTA_AV_REJECT_EVT 18 /* incoming connection rejected */ +#define BTA_AV_RC_FEAT_EVT 19 /* remote control channel peer supported features update */ +#define BTA_AV_MEDIA_SINK_CFG_EVT 20 /* command to configure codec */ +#define BTA_AV_MEDIA_DATA_EVT 21 /* sending data to Media Task */ +#define BTA_AV_SET_DELAY_VALUE_EVT 22 /* set delay reporting value */ +#define BTA_AV_GET_DELAY_VALUE_EVT 23 /* get delay reporting value */ +#define BTA_AV_SNK_PSC_CFG_EVT 24 /* Protocol service capabilities. */ +/* Max BTA event */ +#define BTA_AV_MAX_EVT 25 + + +/* function types for call-out functions */ +typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info, + UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 tsep); +typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps, + UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local); +typedef void (*tBTA_AV_CO_CFG_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps, + UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local); +typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, + UINT8 *p_num_protect, UINT8 *p_protect_info); +typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, + UINT8 num_protect, UINT8 *p_protect_info, + UINT8 t_local_sep, UINT8 avdt_handle); +typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl, + tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, + UINT16 mtu); +typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu); +typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr); +typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); +typedef void *(*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type, + UINT32 *p_len, UINT32 *p_timestamp); +typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay); + +/// AVRCP call-out function +// check whether PASSTHROUGH command is supported +typedef BOOLEAN (*tBTA_AVRC_CO_CMD_ALLOWED) (tBTA_AV_RC rc_id); +// get the event notification capabilities +typedef UINT8 (*tBTA_AVRC_CO_RN_EVT_CAP) (UINT8 *event_ids); +// check whether the event_id is supported +typedef BOOLEAN (*tBTA_AVRC_CO_RN_EVT_SUPPORTED) (UINT8 event_id); + +/* the call-out functions for one stream */ +typedef struct { + tBTA_AV_CO_INIT init; + tBTA_AV_CO_DISC_RES disc_res; + tBTA_AV_CO_CFG_RES cfg_res; + tBTA_AV_CO_GETCFG getcfg; + tBTA_AV_CO_SETCFG setcfg; + tBTA_AV_CO_OPEN open; + tBTA_AV_CO_CLOSE close; + tBTA_AV_CO_START start; + tBTA_AV_CO_STOP stop; + tBTA_AV_CO_DATAPATH data; + tBTA_AV_CO_DELAY delay; +} tBTA_AV_CO_FUNCTS; + +/* the call-out functions for AVRCP */ +typedef struct { + tBTA_AVRC_CO_CMD_ALLOWED rc_cmd; + tBTA_AVRC_CO_RN_EVT_CAP rn_evt_cap; + tBTA_AVRC_CO_RN_EVT_SUPPORTED rn_evt_supported; +} tBTA_AVRC_CO_FUNCTS; + +typedef UINT8 tBTA_AV_EVT; + +/* Event associated with BTA_AV_ENABLE_EVT */ +typedef struct { + tBTA_AV_FEAT features; +} tBTA_AV_ENABLE; + +/* Event associated with BTA_AV_REGISTER_EVT */ +typedef struct { + tBTA_AV_CHNL chnl; /* audio/video */ + tBTA_AV_HNDL hndl; /* Handle associated with the stream. */ + UINT8 app_id; /* ID associated with call to BTA_AvRegister() */ + tBTA_AV_STATUS status; + tBTA_AV_CO_FUNCTS *p_bta_av_cos; + tBTA_AVRC_CO_FUNCTS *p_bta_avrc_cos; +} tBTA_AV_REGISTER; + +/* data associated with BTA_AV_OPEN_EVT */ +#define BTA_AV_EDR_2MBPS 0x01 +#define BTA_AV_EDR_3MBPS 0x02 +typedef UINT8 tBTA_AV_EDR; + +typedef struct { + tBTA_AV_CHNL chnl; + tBTA_AV_HNDL hndl; + BD_ADDR bd_addr; + tBTA_AV_STATUS status; + BOOLEAN starting; + tBTA_AV_EDR edr; /* 0, if peer device does not support EDR */ + UINT8 sep; /* sep type of peer device */ +} tBTA_AV_OPEN; + +/* data associated with BTA_AV_CLOSE_EVT */ +typedef struct { + tBTA_AV_CHNL chnl; + tBTA_AV_HNDL hndl; + UINT8 disc_rsn; /* disconnection reason */ +} tBTA_AV_CLOSE; + +/* data associated with BTA_AV_START_EVT */ +typedef struct { + tBTA_AV_CHNL chnl; + tBTA_AV_HNDL hndl; + tBTA_AV_STATUS status; + BOOLEAN initiator; /* TRUE, if local device initiates the START */ + BOOLEAN suspending; +} tBTA_AV_START; + +/* data associated with BTA_AV_SUSPEND_EVT */ +typedef struct { + tBTA_AV_CHNL chnl; + tBTA_AV_HNDL hndl; + BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */ + tBTA_AV_STATUS status; +} tBTA_AV_SUSPEND; + +/* data associated with BTA_AV_RECONFIG_EVT */ +typedef struct { + tBTA_AV_CHNL chnl; + tBTA_AV_HNDL hndl; + tBTA_AV_STATUS status; +} tBTA_AV_RECONFIG; + +/* data associated with BTA_AV_PROTECT_REQ_EVT */ +typedef struct { + tBTA_AV_CHNL chnl; + tBTA_AV_HNDL hndl; + UINT8 *p_data; + UINT16 len; +} tBTA_AV_PROTECT_REQ; + +/* data associated with BTA_AV_PROTECT_RSP_EVT */ +typedef struct { + tBTA_AV_CHNL chnl; + tBTA_AV_HNDL hndl; + UINT8 *p_data; + UINT16 len; + tBTA_AV_ERR err_code; +} tBTA_AV_PROTECT_RSP; + +/* data associated with BTA_AV_RC_OPEN_EVT */ +typedef struct { + UINT8 rc_handle; + BOOLEAN sdp_disc_done; + tBTA_AV_FEAT peer_features; + UINT16 peer_ct_features; + UINT16 peer_tg_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; + UINT16 peer_ct_features; + UINT16 peer_tg_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; + +/* data associated with BTA_AV_SET_DELAY_VALUE_EVT/BTA_AV_GET_DELAY_VALUE_EVT */ +typedef struct { + tBTA_AV_STATUS status; + UINT16 delay_value; +} tBTA_AV_DELAY; + +/* data associated with BTA_AV_SNK_PSC_CFG_EVT */ +typedef struct { + UINT16 psc_mask; +} tBTA_AV_SNK_PSC_CFG; + + +/* 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_DELAY delay; + tBTA_AV_SNK_PSC_CFG psc; +} tBTA_AV; + +/* union of data associated with AV Media callback */ +typedef union { + BT_HDR *p_data; + UINT8 *codec_info; +} tBTA_AV_MEDIA; + + +#define BTA_AVC_PACKET_LEN AVRC_PACKET_LEN +#define BTA_VENDOR_DATA_OFFSET 6 +#define BTA_VENDOR_HEADER_LEN 4 +#define BTA_MAX_VENDOR_DEPENDENT_DATA_LEN (BTA_AVC_PACKET_LEN-BTA_VENDOR_DATA_OFFSET-BTA_VENDOR_HEADER_LEN) +#define BTA_GROUP_NAVI_MSG_OP_DATA_LEN 5 + +#define BTA_ERROR_INVALID_CMD AVRC_STS_BAD_CMD +#define BTA_ERROR_INVALID_PARAM AVRC_STS_BAD_PARAM +#define BTA_ERROR_BAD_CONTENTS AVRC_STS_NOT_FOUND +#define BTA_ERROR_INTERNAL AVRC_STS_INTERNAL_ERR + +#define BTA_AV_META_SINGLE_PACKET AVRC_PKT_SINGLE + +#define BTA_AV_CO_METADATA AVRC_CO_METADATA + +/* AV callback */ +typedef void (tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV *p_data); +typedef void (tBTA_AV_DATA_CBACK)(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data); + +/* type for stream state machine action functions */ +typedef void (*tBTA_AV_ACT)(void *p_cb, void *p_data); + +/* type for registering VDP */ +typedef void (tBTA_AV_REG) (tAVDT_CS *p_cs, char *p_service_name, void *p_data); + +/* AV configuration structure */ +typedef struct { + UINT32 company_id; /* AVRCP Company ID */ + UINT16 avrc_mtu; /* AVRCP MTU at L2CAP for control channel */ + UINT16 avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */ + UINT16 avrc_snk_ct_cat; /* AVRCP controller categories as SNK */ + UINT16 avrc_snk_tg_cat; /* AVRCP target categories SNK */ + UINT16 avrc_src_ct_cat; /* AVRCP controller categories as SRC */ + UINT16 avrc_src_tg_cat; /* AVRCP target categories as SRC */ + 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 */ + BOOLEAN avrc_br; /* FALSE, does not support browsing channel */ + UINT8 num_co_ids; /* company id count in p_meta_co_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 tBTA_AV_ACT *p_act_tbl;/* the action function table for VDP stream */ + tBTA_AV_REG *p_reg; /* action function to register VDP */ + char avrc_controller_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP controller name */ + char avrc_target_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP target name*/ +} tBTA_AV_CFG; + +#ifdef __cplusplus +extern "C" +{ +#endif + +/***************************************************************************** +** External Function Declarations +*****************************************************************************/ + +/******************************************************************************* +** +** Function BTA_AvEnable +** +** Description Enable the advanced audio/video service. When the enable +** operation is complete the callback function will be +** called with a BTA_AV_ENABLE_EVT. This function must +** be called before other function in the AV API are +** called. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features, + tBTA_AV_CBACK *p_cback); + +/******************************************************************************* +** +** Function BTA_AvDisable +** +** Description Disable the advanced audio/video service. +** +** +** Returns void +** +*******************************************************************************/ +void BTA_AvDisable(void); + +/******************************************************************************* +** +** Function BTA_AvRegister +** +** Description Register the audio or video service to stack. When the +** operation is complete the callback function will be +** called with a BTA_AV_REGISTER_EVT. This function must +** be called before AVDT stream is open. +** +** +** Returns void +** +*******************************************************************************/ +void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, + UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, + tBTA_AV_CO_FUNCTS *bta_av_cos, tBTA_AVRC_CO_FUNCTS *bta_avrc_cos, + UINT8 tsep); + +/******************************************************************************* +** +** Function BTA_AvDeregister +** +** Description Deregister the audio or video service +** +** Returns void +** +*******************************************************************************/ +void BTA_AvDeregister(tBTA_AV_HNDL hndl); + +/******************************************************************************* +** +** Function BTA_AvOpen +** +** Description Opens an advanced audio/video connection to a peer device. +** When connection is open callback function is called +** with a BTA_AV_OPEN_EVT. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, + BOOLEAN use_rc, tBTA_SEC sec_mask, UINT16 uuid); + +/******************************************************************************* +** +** Function BTA_AvClose +** +** Description Close the current streams. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvClose(tBTA_AV_HNDL handle); + +/******************************************************************************* +** +** Function BTA_AvDisconnect +** +** Description Close the connection to the address. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvDisconnect(BD_ADDR bd_addr); + +/******************************************************************************* +** +** Function BTA_AvEnable_Sink +** +** Description Enable/Disable A2DP Sink. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvEnable_Sink(int enable); + +/******************************************************************************* +** +** Function BTA_AvStart +** +** Description Start audio/video stream data transfer. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvStart(void); + +/******************************************************************************* +** +** Function BTA_AvStop +** +** Description Stop audio/video stream data transfer. +** If suspend is TRUE, this function sends AVDT suspend signal +** to the connected peer(s). +** +** Returns void +** +*******************************************************************************/ +void BTA_AvStop(BOOLEAN suspend); + +/******************************************************************************* +** +** Function BTA_AvReconfig +** +** Description Reconfigure the audio/video stream. +** If suspend is TRUE, this function tries the suspend/reconfigure +** procedure first. +** If suspend is FALSE or when suspend/reconfigure fails, +** this function closes and re-opens the AVDT connection. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx, + UINT8 *p_codec_info, UINT8 num_protect, UINT8 *p_protect_info); + +/******************************************************************************* +** +** Function BTA_AvProtectReq +** +** Description Send a content protection request. This function can only +** be used if AV is enabled with feature BTA_AV_FEAT_PROTECT. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len); + +/******************************************************************************* +** +** Function BTA_AvProtectRsp +** +** Description Send a content protection response. This function must +** be called if a BTA_AV_PROTECT_REQ_EVT is received. +** This function can only be used if AV is enabled with +** feature BTA_AV_FEAT_PROTECT. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data, + UINT16 len); + +/******************************************************************************* +** +** Function BTA_SetDelayValue +** +** Description Set delay report value +** +** Returns void +** +*******************************************************************************/ +void BTA_SetDelayValue(UINT16 delay_value); + +/******************************************************************************* +** +** Function BTA_GetDelayValue +** +** Description Get delay report value +** +** Returns void +** +*******************************************************************************/ +void BTA_GetDelayValue(void); + +/******************************************************************************* +** +** Function BTA_AvRemoteCmd +** +** Description Send a remote control command. This function can only +** be used if AV is enabled with feature BTA_AV_FEAT_RCCT. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id, + tBTA_AV_STATE key_state); + +/******************************************************************************* +** +** Function BTA_AvVendorCmd +** +** Description Send a vendor dependent remote control command. This +** function can only be used if AV is enabled with feature +** BTA_AV_FEAT_VENDOR. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code, + UINT8 *p_data, UINT16 len); + +/******************************************************************************* +** +** Function BTA_AvVendorRsp +** +** Description Send a vendor dependent remote control response. +** This function must be called if a BTA_AV_VENDOR_CMD_EVT +** is received. This function can only be used if AV is +** enabled with feature BTA_AV_FEAT_VENDOR. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code, + UINT8 *p_data, UINT16 len, UINT32 company_id); + + +/******************************************************************************* +** +** Function BTA_AvOpenRc +** +** Description Open an AVRCP connection toward the device with the +** specified handle +** +** Returns void +** +*******************************************************************************/ +void BTA_AvOpenRc(tBTA_AV_HNDL handle); + +/******************************************************************************* +** +** Function BTA_AvCloseRc +** +** Description Close an AVRCP connection +** +** Returns void +** +*******************************************************************************/ +void BTA_AvCloseRc(UINT8 rc_handle); + +/******************************************************************************* +** +** Function BTA_AvMetaRsp +** +** Description Send a Metadata command/response. The message contained +** in p_pkt can be composed with AVRC utility functions. +** This function can only be used if AV is enabled with feature +** BTA_AV_FEAT_METADATA. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code, + BT_HDR *p_pkt); + +/******************************************************************************* +** +** Function BTA_AvMetaCmd +** +** Description Send a Metadata/Advanced Control command. The message contained +** in p_pkt can be composed with AVRC utility functions. +** This function can only be used if AV is enabled with feature +** BTA_AV_FEAT_METADATA. +** This message is sent only when the peer supports the TG role. +*8 The only command makes sense right now is the absolute volume command. +** +** Returns void +** +*******************************************************************************/ +void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p_pkt); + +#ifdef __cplusplus +} +#endif + +#endif ///BTA_AV_INCLUDED == TRUE + +#endif /* BTA_AV_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_av_ci.h b/lib/bt/host/bluedroid/bta/include/bta/bta_av_ci.h new file mode 100644 index 00000000..b39acace --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_av_ci.h @@ -0,0 +1,77 @@ +/****************************************************************************** + * + * Copyright (C) 2005-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for advanced audio/video call-in functions. + * + ******************************************************************************/ +#ifndef BTA_AV_CI_H +#define BTA_AV_CI_H + +#include "bta/bta_av_api.h" + +#if (BTA_AV_INCLUDED == TRUE) + +/***************************************************************************** +** Function Declarations +*****************************************************************************/ +#ifdef __cplusplus +extern "C" +{ +#endif + +/******************************************************************************* +** +** Function bta_av_ci_src_data_ready +** +** Description This function sends an event to the AV indicating that +** the phone has audio stream data ready to send and AV +** should call bta_av_co_audio_src_data_path() or +** bta_av_co_video_src_data_path(). +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl); + +/******************************************************************************* +** +** Function bta_av_ci_setconfig +** +** Description This function must be called in response to function +** bta_av_co_audio_setconfig() or bta_av_co_video_setconfig. +** Parameter err_code is set to an AVDTP status value; +** AVDT_SUCCESS if the codec configuration is ok, +** otherwise error. +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, + UINT8 category, UINT8 num_seid, UINT8 *p_seid, + BOOLEAN recfg_needed, UINT8 avdt_handle); + + +#ifdef __cplusplus +} +#endif + +#endif ///BTA_AV_INCLUDED == TRUE + +#endif /* BTA_AV_CI_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_av_co.h b/lib/bt/host/bluedroid/bta/include/bta/bta_av_co.h new file mode 100644 index 00000000..03c07c33 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_av_co.h @@ -0,0 +1,393 @@ +/****************************************************************************** + * + * Copyright (C) 2003-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for advanced audio/video call-out functions. + * + ******************************************************************************/ +#ifndef BTA_AV_CO_H +#define BTA_AV_CO_H + +#include "stack/l2c_api.h" +#include "bta/bta_av_api.h" + +#if (BTA_AV_INCLUDED == TRUE) + +/***************************************************************************** +** Constants and data types +*****************************************************************************/ + +/* TRUE to use SCMS-T content protection */ +#ifndef BTA_AV_CO_CP_SCMS_T +#define BTA_AV_CO_CP_SCMS_T FALSE +#endif + +/* the content protection IDs assigned by BT SIG */ +#define BTA_AV_CP_SCMS_T_ID 0x0002 +#define BTA_AV_CP_DTCP_ID 0x0001 + +#define BTA_AV_CP_LOSC 2 +#define BTA_AV_CP_INFO_LEN 3 + +#define BTA_AV_CP_SCMS_COPY_MASK 3 +#define BTA_AV_CP_SCMS_COPY_FREE 2 +#define BTA_AV_CP_SCMS_COPY_ONCE 1 +#define BTA_AV_CP_SCMS_COPY_NEVER 0 + +#define BTA_AV_CO_DEFAULT_AUDIO_OFFSET AVDT_MEDIA_OFFSET + +enum { + BTA_AV_CO_ST_INIT, + BTA_AV_CO_ST_IN, + BTA_AV_CO_ST_OUT, + BTA_AV_CO_ST_OPEN, + BTA_AV_CO_ST_STREAM +}; + + +/* data type for the Audio Codec Information*/ +typedef struct { + UINT16 bit_rate; /* SBC encoder bit rate in kbps */ + UINT16 bit_rate_busy; /* SBC encoder bit rate in kbps */ + UINT16 bit_rate_swampd;/* SBC encoder bit rate in kbps */ + UINT8 busy_level; /* Busy level indicating the bit-rate to be used */ + UINT8 codec_info[AVDT_CODEC_SIZE]; + UINT8 codec_type; /* Codec type */ +} tBTA_AV_AUDIO_CODEC_INFO; + +/******************************************************************************* +** +** Function bta_av_co_audio_init +** +** Description This callout function is executed by AV when it is +** started by calling BTA_AvEnable(). This function can be +** used by the phone to initialize audio paths or for other +** initialization purposes. +** +** +** Returns Stream codec and content protection capabilities info. +** +*******************************************************************************/ +extern BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, + UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 tsep); + +/******************************************************************************* +** +** Function bta_av_co_audio_disc_res +** +** Description This callout function is executed by AV to report the +** number of stream end points (SEP) were found during the +** AVDT stream discovery process. +** +** +** Returns void. +** +*******************************************************************************/ +extern void bta_av_co_audio_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps, + UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local); + +/******************************************************************************* +** +** Function bta_av_co_video_disc_res +** +** Description This callout function is executed by AV to report the +** number of stream end points (SEP) were found during the +** AVDT stream discovery process. +** +** +** Returns void. +** +*******************************************************************************/ +extern void bta_av_co_video_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps, + UINT8 num_snk, BD_ADDR addr); + +/******************************************************************************* +** +** Function bta_av_co_audio_getconfig +** +** Description This callout function is executed by AV to retrieve the +** desired codec and content protection configuration for the +** audio stream. +** +** +** Returns Stream codec and content protection configuration info. +** +*******************************************************************************/ +extern UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, + UINT8 *p_num_protect, UINT8 *p_protect_info); + +/******************************************************************************* +** +** Function bta_av_co_video_getconfig +** +** Description This callout function is executed by AV to retrieve the +** desired codec and content protection configuration for the +** video stream. +** +** +** Returns Stream codec and content protection configuration info. +** +*******************************************************************************/ +extern UINT8 bta_av_co_video_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, + UINT8 *p_num_protect, UINT8 *p_protect_info); + +/******************************************************************************* +** +** Function bta_av_co_audio_setconfig +** +** Description This callout function is executed by AV to set the +** codec and content protection configuration of the audio stream. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, + UINT8 num_protect, UINT8 *p_protect_info, UINT8 t_local_sep, UINT8 avdt_handle); + +/******************************************************************************* +** +** Function bta_av_co_video_setconfig +** +** Description This callout function is executed by AV to set the +** codec and content protection configuration of the video stream. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_video_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, + UINT8 num_protect, UINT8 *p_protect_info); + +/******************************************************************************* +** +** Function bta_av_co_audio_open +** +** Description This function is called by AV when the audio stream connection +** is opened. +** BTA-AV maintains the MTU of A2DP streams. +** If this is the 2nd audio stream, mtu is the smaller of the 2 +** streams. +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_audio_open(tBTA_AV_HNDL hndl, + tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, + UINT16 mtu); + +/******************************************************************************* +** +** Function bta_av_co_video_open +** +** Description This function is called by AV when the video stream connection +** is opened. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_video_open(tBTA_AV_HNDL hndl, + tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, + UINT16 mtu); + +/******************************************************************************* +** +** Function bta_av_co_audio_close +** +** Description This function is called by AV when the audio stream connection +** is closed. +** BTA-AV maintains the MTU of A2DP streams. +** When one stream is closed and no other audio stream is open, +** mtu is reported as 0. +** Otherwise, the MTU remains open is reported. +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_audio_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT16 mtu); + +/******************************************************************************* +** +** Function bta_av_co_video_close +** +** Description This function is called by AV when the video stream connection +** is closed. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_video_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT16 mtu); + +/******************************************************************************* +** +** Function bta_av_co_audio_start +** +** Description This function is called by AV when the audio streaming data +** transfer is started. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_audio_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr); + +/******************************************************************************* +** +** Function bta_av_co_video_start +** +** Description This function is called by AV when the video streaming data +** transfer is started. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_video_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr); + +/******************************************************************************* +** +** Function bta_av_co_audio_stop +** +** Description This function is called by AV when the audio streaming data +** transfer is stopped. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_audio_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); + +/******************************************************************************* +** +** Function bta_av_co_video_stop +** +** Description This function is called by AV when the video streaming data +** transfer is stopped. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_video_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); + +/******************************************************************************* +** +** Function bta_av_co_audio_src_data_path +** +** Description This function is called to get the next data buffer from +** the audio codec +** +** Returns NULL if data is not ready. +** Otherwise, a buffer (BT_HDR*) containing the audio data. +** +*******************************************************************************/ +extern void *bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type, + UINT32 *p_len, UINT32 *p_timestamp); + +/******************************************************************************* +** +** Function bta_av_co_video_src_data_path +** +** Description This function is called to get the next data buffer from +** the video codec. +** +** Returns NULL if data is not ready. +** Otherwise, a video data buffer (UINT8*). +** +*******************************************************************************/ +extern void *bta_av_co_video_src_data_path(tBTA_AV_CODEC codec_type, + UINT32 *p_len, UINT32 *p_timestamp); + +/******************************************************************************* +** +** Function bta_av_co_audio_drop +** +** Description An Audio packet is dropped. . +** It's very likely that the connected headset with this handle +** is moved far away. The implementation may want to reduce +** the encoder bit rate setting to reduce the packet size. +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_audio_drop(tBTA_AV_HNDL hndl); + +/******************************************************************************* +** +** Function bta_av_co_video_report_conn +** +** Description This function is called by AV when the reporting channel is +** opened (open=TRUE) or closed (open=FALSE). +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_video_report_conn (BOOLEAN open, UINT8 avdt_handle); + +/******************************************************************************* +** +** Function bta_av_co_video_report_rr +** +** Description This function is called by AV when a Receiver Report is +** received +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_video_report_rr (UINT32 packet_lost); + +/******************************************************************************* +** +** Function bta_av_co_audio_delay +** +** Description This function is called by AV when the audio stream connection +** needs to send the initial delay report to the connected SRC. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_audio_delay(tBTA_AV_HNDL hndl, UINT16 delay); + +/******************************************************************************* +** +** Function bta_av_co_video_delay +** +** Description This function is called by AV when the video stream connection +** needs to send the initial delay report to the connected SRC. +** +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_co_video_delay(tBTA_AV_HNDL hndl, UINT16 delay); + +#endif ///BTA_AV_INCLUDED == TRUE + +#endif /* BTA_AV_CO_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_av_sbc.h b/lib/bt/host/bluedroid/bta/include/bta/bta_av_sbc.h new file mode 100644 index 00000000..fccc02fa --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_av_sbc.h @@ -0,0 +1,222 @@ +/****************************************************************************** + * + * Copyright (C) 2004-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface to utility functions for dealing with SBC data + * frames and codec capabilities. + * + ******************************************************************************/ +#ifndef BTA_AV_SBC_H +#define BTA_AV_SBC_H + +#if (BTA_AV_INCLUDED == TRUE) + +/***************************************************************************** +** constants +*****************************************************************************/ + +/* SBC packet header size */ +#define BTA_AV_SBC_HDR_SIZE A2D_SBC_MPL_HDR_LEN + +/******************************************************************************* +** +** Function bta_av_sbc_init_up_sample +** +** Description initialize the up sample +** +** src_sps: samples per second (source audio data) +** dst_sps: samples per second (converted audio data) +** bits: number of bits per pcm sample +** n_channels: number of channels (i.e. mono(1), stereo(2)...) +** +** Returns none +** +*******************************************************************************/ +extern void bta_av_sbc_init_up_sample (UINT32 src_sps, UINT32 dst_sps, + UINT16 bits, UINT16 n_channels); + +/******************************************************************************* +** +** Function bta_av_sbc_up_sample +** +** Description Given the source (p_src) audio data and +** source speed (src_sps, samples per second), +** This function converts it to audio data in the desired format +** +** p_src: the data buffer that holds the source audio data +** p_dst: the data buffer to hold the converted audio data +** src_samples: The number of source samples (number of bytes) +** dst_samples: The size of p_dst (number of bytes) +** +** Note: An AE reported an issue with this function. +** When called with bta_av_sbc_up_sample(src, uint8_array_dst..) +** the byte before uint8_array_dst may get overwritten. +** Using uint16_array_dst avoids the problem. +** This issue is related to endian-ness and is hard to resolve +** in a generic manner. +** **************** Please use uint16 array as dst. +** +** Returns The number of bytes used in p_dst +** The number of bytes used in p_src (in *p_ret) +** +*******************************************************************************/ +extern int bta_av_sbc_up_sample (void *p_src, void *p_dst, + UINT32 src_samples, UINT32 dst_samples, + UINT32 *p_ret); + +/******************************************************************************* +** +** Function bta_av_sbc_up_sample_16s (16bits-stereo) +** +** Description Given the source (p_src) audio data and +** source speed (src_sps, samples per second), +** This function converts it to audio data in the desired format +** +** p_src: the data buffer that holds the source audio data +** p_dst: the data buffer to hold the converted audio data +** src_samples: The number of source samples (in uint of 4 bytes) +** dst_samples: The size of p_dst (in uint of 4 bytes) +** +** Returns The number of bytes used in p_dst +** The number of bytes used in p_src (in *p_ret) +** +*******************************************************************************/ +extern int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst, + UINT32 src_samples, UINT32 dst_samples, + UINT32 *p_ret); + +/******************************************************************************* +** +** Function bta_av_sbc_up_sample_16m (16bits-mono) +** +** Description Given the source (p_src) audio data and +** source speed (src_sps, samples per second), +** This function converts it to audio data in the desired format +** +** p_src: the data buffer that holds the source audio data +** p_dst: the data buffer to hold the converted audio data +** src_samples: The number of source samples (in uint of 2 bytes) +** dst_samples: The size of p_dst (in uint of 2 bytes) +** +** Returns The number of bytes used in p_dst +** The number of bytes used in p_src (in *p_ret) +** +*******************************************************************************/ +extern int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst, + UINT32 src_samples, UINT32 dst_samples, + UINT32 *p_ret); + +/******************************************************************************* +** +** Function bta_av_sbc_up_sample_8s (8bits-stereo) +** +** Description Given the source (p_src) audio data and +** source speed (src_sps, samples per second), +** This function converts it to audio data in the desired format +** +** p_src: the data buffer that holds the source audio data +** p_dst: the data buffer to hold the converted audio data +** src_samples: The number of source samples (in uint of 2 bytes) +** dst_samples: The size of p_dst (in uint of 2 bytes) +** +** Returns The number of bytes used in p_dst +** The number of bytes used in p_src (in *p_ret) +** +*******************************************************************************/ +extern int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst, + UINT32 src_samples, UINT32 dst_samples, + UINT32 *p_ret); + +/******************************************************************************* +** +** Function bta_av_sbc_up_sample_8m (8bits-mono) +** +** Description Given the source (p_src) audio data and +** source speed (src_sps, samples per second), +** This function converts it to audio data in the desired format +** +** p_src: the data buffer that holds the source audio data +** p_dst: the data buffer to hold the converted audio data +** src_samples: The number of source samples (number of bytes) +** dst_samples: The size of p_dst (number of bytes) +** +** Returns The number of bytes used in p_dst +** The number of bytes used in p_src (in *p_ret) +** +*******************************************************************************/ +extern int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst, + UINT32 src_samples, UINT32 dst_samples, + UINT32 *p_ret); + +/******************************************************************************* +** +** Function bta_av_sbc_cfg_for_cap +** +** Description Determine the preferred SBC codec configuration for the +** given codec capabilities. The function is passed the +** preferred codec configuration and the peer codec +** capabilities for the stream. The function attempts to +** match the preferred capabilities with the configuration +** as best it can. The resulting codec configuration is +** returned in the same memory used for the capabilities. +** +** Returns 0 if ok, nonzero if error. +** Codec configuration in p_cap. +** +*******************************************************************************/ +extern UINT8 bta_av_sbc_cfg_for_cap(UINT8 *p_peer, tA2D_SBC_CIE *p_cap, tA2D_SBC_CIE *p_pref); + +/******************************************************************************* +** +** Function bta_av_sbc_cfg_in_cap +** +** Description This function checks whether an SBC codec configuration +** is allowable for the given codec capabilities. +** +** Returns 0 if ok, nonzero if error. +** +*******************************************************************************/ +extern UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap); + +/******************************************************************************* +** +** Function bta_av_sbc_cfg_matches_cap +** +** Description This function checks whether an SBC codec configuration +** matched with capabilities. Here we check subset. +** +** Returns 0 if ok, nonzero if error. +** +*******************************************************************************/ +extern UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap); + +/******************************************************************************* +** +** Function bta_av_sbc_bld_hdr +** +** Description This function builds the packet header for MPF1. +** +** Returns void +** +*******************************************************************************/ +extern void bta_av_sbc_bld_hdr(BT_HDR *p_buf, UINT16 fr_per_pkt); + +#endif ///BTA_AV_INCLUDED == TRUE + +#endif /* BTA_AV_SBC_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_dm_ci.h b/lib/bt/host/bluedroid/bta/include/bta/bta_dm_ci.h new file mode 100644 index 00000000..cd15c86c --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_dm_ci.h @@ -0,0 +1,68 @@ +/****************************************************************************** + * + * Copyright (C) 2006-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for device mananger call-in functions. + * + ******************************************************************************/ +#ifndef BTA_DM_CI_H +#define BTA_DM_CI_H + +#include "bta/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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr, + BT_OCTET16 c, BT_OCTET16 r); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_dm_co.h b/lib/bt/host/bluedroid/bta/include/bta/bta_dm_co.h new file mode 100644 index 00000000..124711eb --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_dm_co.h @@ -0,0 +1,218 @@ +/****************************************************************************** + * + * Copyright (C) 2006-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for device mananger callout functions. + * + ******************************************************************************/ +#ifndef BTA_DM_CO_H +#define BTA_DM_CO_H + +#include "bta/bta_sys.h" +#include "esp_err.h" + +/***************************************************************************** +** Function Declarations +*****************************************************************************/ + +/******************************************************************************* +** +** Function bta_dm_co_bt_set_io_cap +** +** Description This function is used to set IO capabilities +** +** Parameters bt_io_cap - IO capabilities +** +** @return - ESP_BT_STATUS_SUCCESS : success +** - other : failed +** +*******************************************************************************/ +extern esp_err_t bta_dm_co_bt_set_io_cap(UINT8 bt_io_cap); + +/******************************************************************************* +** +** 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. +** +*******************************************************************************/ +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. +** +*******************************************************************************/ +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. +** +*******************************************************************************/ +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. +** +*******************************************************************************/ +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. +** +*******************************************************************************/ +extern void bta_dm_co_rmt_oob(BD_ADDR bd_addr); + + +/******************************************************************************* +** +** 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. +** +*******************************************************************************/ +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. +** +*******************************************************************************/ +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. +** +*******************************************************************************/ +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 -- + +extern void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap); + +extern void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req); + +extern void bta_dm_co_ble_set_init_key_req(UINT8 init_key); + +extern void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key); + +extern void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size); + +extern void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size); + +extern void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable); + +extern UINT8 bta_dm_co_ble_get_accept_auth_enable(void); + +extern UINT8 bta_dm_co_ble_get_auth_req(void); + +extern void bta_dm_co_ble_oob_support(UINT8 enable); +#endif diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_gap_bt_co.h b/lib/bt/host/bluedroid/bta/include/bta/bta_gap_bt_co.h new file mode 100644 index 00000000..35aeb933 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_gap_bt_co.h @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + + +/****************************************************************************** + * + * This is the interface file for BT GAP call-out functions. + * + ******************************************************************************/ +#ifndef BTA_GAP_BT_CO_H +#define BTA_GAP_BT_CO_H + +#if (BTC_GAP_BT_INCLUDED == TRUE) + +extern void btc_gap_bt_config_eir_cmpl_callback (uint8_t status, uint8_t eir_type_num, uint8_t *eir_type); + +#endif /// (BTC_GAP_BT_INCLUDED == TRUE) +#endif /// BTA_GAP_BT_CO_H diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h new file mode 100644 index 00000000..183e3acc --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h @@ -0,0 +1,1580 @@ +/****************************************************************************** + * + * Copyright (C) 2003-2013 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the public interface file for BTA GATT. + * + ******************************************************************************/ + +#ifndef BTA_GATT_API_H +#define BTA_GATT_API_H + +#include "bta/bta_api.h" +#include "stack/gatt_api.h" +#include "osi/list.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 + +typedef enum { + BTGATT_DB_PRIMARY_SERVICE, + BTGATT_DB_SECONDARY_SERVICE, + BTGATT_DB_CHARACTERISTIC, + BTGATT_DB_DESCRIPTOR, + BTGATT_DB_INCLUDED_SERVICE, +}bt_gatt_db_attribute_type_t; + +typedef enum { + GATT_OP_GET_SVC_BY_UUID, + GATT_OP_GET_ALL_CHAR, + GATT_OP_GET_ALL_DESCRI, + GATT_OP_GET_CHAR_BY_UUID, + GATT_OP_GET_DESCRI_BY_UUID, + GATT_OP_GET_DESCRI_BY_HANDLE, + GATT_OP_GET_INCLUDE_SVC, +}bt_gatt_get_db_op_t; + +typedef struct { + bt_gatt_db_attribute_type_t type; + UINT16 attribute_handle; + UINT16 start_handle; + UINT16 end_handle; + UINT16 id; + UINT8 properties; + bt_uuid_t uuid; +}btgatt_db_element_t; + +/***************************************************************************** +** Constants and data types +*****************************************************************************/ +/************************** +** Common Definitions +***************************/ +/* GATT ID */ +typedef struct { + tBT_UUID uuid; /* uuid of the attribute */ + UINT8 inst_id; /* instance ID */ +} __attribute__((packed)) tBTA_GATT_ID; + +/* relate to ESP_GATT_xxx in esp_gatt_def.h */ +/* 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_NO_RESOURCES GATT_NO_RESOURCES /* 0x80 */ +#define BTA_GATT_INTERNAL_ERROR GATT_INTERNAL_ERROR /* 0x81 */ +#define BTA_GATT_WRONG_STATE GATT_WRONG_STATE /* 0x82 */ +#define BTA_GATT_DB_FULL GATT_DB_FULL /* 0x83 */ +#define BTA_GATT_BUSY GATT_BUSY /* 0x84 */ +#define BTA_GATT_ERROR GATT_ERROR /* 0x85 */ +#define BTA_GATT_CMD_STARTED GATT_CMD_STARTED /* 0x86 */ +#define BTA_GATT_ILLEGAL_PARAMETER GATT_ILLEGAL_PARAMETER /* 0x87 */ +#define BTA_GATT_PENDING GATT_PENDING /* 0x88 */ +#define BTA_GATT_AUTH_FAIL GATT_AUTH_FAIL /* 0x89 */ +#define BTA_GATT_MORE GATT_MORE /* 0x8a */ +#define BTA_GATT_INVALID_CFG GATT_INVALID_CFG /* 0x8b */ +#define BTA_GATT_SERVICE_STARTED GATT_SERVICE_STARTED /* 0x8c */ +#define BTA_GATT_ENCRYPED_MITM GATT_ENCRYPED_MITM /* GATT_SUCCESS */ +#define BTA_GATT_ENCRYPED_NO_MITM GATT_ENCRYPED_NO_MITM /* 0x8d */ +#define BTA_GATT_NOT_ENCRYPTED GATT_NOT_ENCRYPTED /* 0x8e */ +#define BTA_GATT_CONGESTED GATT_CONGESTED /* 0x8f */ + +#define BTA_GATT_DUP_REG GATT_DUP_REG /* 0x90 */ +#define BTA_GATT_ALREADY_OPEN GATT_ALREADY_OPEN /* 0x91 */ +#define BTA_GATT_CANCEL GATT_CANCEL /* 0x92 */ + +/* 0xE0 ~ 0xFC reserved for future use */ +#define BTA_GATT_STACK_RSP GATT_STACK_RSP /* 0xE0 */ +#define BTA_GATT_APP_RSP GATT_APP_RSP /* 0xE1 */ +//Error caused by customer application or stack bug +#define BTA_GATT_UNKNOWN_ERROR GATT_UNKNOWN_ERROR /* 0XEF */ + /* 0xE0 ~ 0xFC reserved for future use */ +#define BTA_GATT_CCC_CFG_ERR GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */ +#define BTA_GATT_PRC_IN_PROGRESS GATT_PRC_IN_PROGRESS /* 0xFE Procedure Already in progress */ +#define BTA_GATT_OUT_OF_RANGE GATT_OUT_OF_RANGE /* 0xFFAttribute value out of range */ + +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 characteristic 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 */ +#define BTA_GATTC_LISTEN_EVT 16 /* listen event */ +#define BTA_GATTC_ENC_CMPL_CB_EVT 17 /* encryption complete callback event */ +#define BTA_GATTC_CFG_MTU_EVT 18 /* configure MTU complete event */ +#define BTA_GATTC_ADV_DATA_EVT 19 /* ADV data event */ +#define BTA_GATTC_MULT_ADV_ENB_EVT 20 /* Enable Multi ADV event */ +#define BTA_GATTC_MULT_ADV_UPD_EVT 21 /* Update parameter event */ +#define BTA_GATTC_MULT_ADV_DATA_EVT 22 /* Multi ADV data event */ +#define BTA_GATTC_MULT_ADV_DIS_EVT 23 /* Disable Multi ADV event */ +#define BTA_GATTC_CONGEST_EVT 24 /* Congestion event */ +#define BTA_GATTC_BTH_SCAN_ENB_EVT 25 /* Enable batch scan event */ +#define BTA_GATTC_BTH_SCAN_CFG_EVT 26 /* Config storage event */ +#define BTA_GATTC_BTH_SCAN_RD_EVT 27 /* Batch scan reports read event */ +#define BTA_GATTC_BTH_SCAN_THR_EVT 28 /* Batch scan threshold event */ +#define BTA_GATTC_BTH_SCAN_PARAM_EVT 29 /* Batch scan param event */ +#define BTA_GATTC_BTH_SCAN_DIS_EVT 30 /* Disable batch scan event */ +#define BTA_GATTC_SCAN_FLT_CFG_EVT 31 /* Scan filter config event */ +#define BTA_GATTC_SCAN_FLT_PARAM_EVT 32 /* Param filter event */ +#define BTA_GATTC_SCAN_FLT_STATUS_EVT 33 /* Filter status event */ +#define BTA_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */ +#define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */ +#define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */ +#define BTA_GATTC_READ_MULTIPLE_EVT 37 /* GATTC Read mutiple event */ +#define BTA_GATTC_QUEUE_FULL_EVT 38 /* GATTC queue full event */ +#define BTA_GATTC_ASSOC_EVT 39 /* GATTC association address event */ +#define BTA_GATTC_GET_ADDR_LIST_EVT 40 /* GATTC get address list in the cache event */ +#define BTA_GATTC_DIS_SRVC_CMPL_EVT 41 /* GATTC discover service complete */ +#define BTA_GATTC_READ_MULTI_VAR_EVT 42 /* GATTC read multiple variable event */ + +typedef UINT8 tBTA_GATTC_EVT; + +typedef tGATT_IF tBTA_GATTC_IF; + +typedef UINT8 tBTA_ADDR_TYPE; + +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; + +typedef struct { + UINT16 interval; + UINT16 latency; + UINT16 timeout; +} tBTA_GATT_CONN_PARAMS; + +#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; + +/* relate to ESP_GATT_CONN_xxx in esp_gatt_defs.h */ +#define BTA_GATT_CONN_UNKNOWN 0 +#define BTA_GATT_CONN_L2C_FAILURE GATT_CONN_L2C_FAILURE /* general 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; + + +#define BTA_GATTC_MULTI_MAX GATT_MAX_READ_MULTI_HANDLES + +typedef struct { + UINT8 num_attr; + UINT16 handles[BTA_GATTC_MULTI_MAX]; +}tBTA_GATTC_MULTI; + +/* relate to ESP_GATT_xxx in esp_gatt_def.h */ +#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 */ + UINT16 incl_srvc_s_handle; /* used when attribute type is included service */ + UINT16 incl_srvc_e_handle; /* used when attribute type is included service */ +}tBTA_GATTC_NV_ATTR; + +/* callback data structure */ +typedef struct { + tBTA_GATT_STATUS status; + tBTA_GATTC_IF client_if; + tBT_UUID app_uuid; +}tBTA_GATTC_REG; + +typedef struct { + UINT16 conn_id; + tBTA_GATT_STATUS status; + UINT16 handle; + tBTA_GATT_UNFMT *p_value; +}tBTA_GATTC_READ; + +typedef struct { + UINT16 conn_id; + tBTA_GATT_STATUS status; + UINT16 handle; + UINT16 offset; +}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; + UINT8 searched_service_source; +} tBTA_GATTC_SEARCH_CMPL; + +typedef struct { + UINT16 conn_id; + tBTA_GATT_STATUS status; +}tBTA_GATTC_DIS_CMPL; + +typedef struct { + UINT16 conn_id; + UINT16 start_handle; + UINT16 end_handle; + tBTA_GATT_ID service_uuid; + bool is_primary; +}tBTA_GATTC_SRVC_RES; + +typedef struct { + UINT16 conn_id; + tBTA_GATT_STATUS status; + UINT16 mtu; +} tBTA_GATTC_CFG_MTU; + +typedef struct { + tBTA_GATT_STATUS status; + UINT16 conn_id; + tBTA_GATTC_IF client_if; + BD_ADDR remote_bda; + tBTA_TRANSPORT transport; + UINT16 mtu; +} 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; + UINT16 handle; + UINT16 len; + UINT8 value[BTA_GATT_MAX_ATTR_LEN]; + BOOLEAN is_notify; +} tBTA_GATTC_NOTIFY; + +typedef struct { + UINT16 conn_id; + BOOLEAN congested; /* congestion indicator */ +} tBTA_GATTC_CONGEST; + +typedef struct { + tBTA_GATT_STATUS status; + UINT16 conn_id; + BOOLEAN is_full; +} tBTA_GATTC_QUEUE_FULL; + +typedef struct { + tBTA_GATT_STATUS status; + tBTA_GATTC_IF client_if; +} tBTA_GATTC_SET_ASSOC; + +typedef struct { + tBTA_GATT_STATUS status; + tBTA_GATTC_IF client_if; + UINT8 num_addr; + BD_ADDR *bda_list; +} tBTA_GATTC_GET_ADDR_LIST; + +typedef struct { + tBTA_GATT_STATUS status; + tBTA_GATTC_IF client_if; + UINT16 conn_id; + BD_ADDR remote_bda; +} tBTA_GATTC_OPEN_CLOSE; + +typedef struct { + tBTA_GATTC_IF client_if; + BD_ADDR remote_bda; +} tBTA_GATTC_ENC_CMPL_CB; + +typedef struct { + UINT16 conn_id; + UINT8 link_role; + tBTA_GATTC_IF client_if; + BD_ADDR remote_bda; + tBTA_GATT_CONN_PARAMS conn_params; + UINT8 ble_addr_type; + UINT16 conn_handle; +} tBTA_GATTC_CONNECT; + +typedef struct { + tGATT_DISCONN_REASON reason; + UINT16 conn_id; + tBTA_GATTC_IF client_if; + BD_ADDR remote_bda; +} tBTA_GATTC_DISCONNECT; + +typedef struct { + UINT16 conn_id; + BD_ADDR remote_bda; +} tBTA_GATTC_SERVICE_CHANGE; + +typedef union { + tBTA_GATT_STATUS status; + tBTA_GATTC_DIS_CMPL dis_cmpl; /* discovery complete */ + tBTA_GATTC_SEARCH_CMPL search_cmpl; /* search complete */ + tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */ + tBTA_GATTC_REG reg_oper; /* registration data */ + tBTA_GATTC_OPEN open; + tBTA_GATTC_CONNECT connect; + tBTA_GATTC_CLOSE close; + tBTA_GATTC_DISCONNECT disconnect; + 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 */ + tBTA_GATTC_ENC_CMPL_CB enc_cmpl; + tBTA_GATTC_CFG_MTU cfg_mtu; /* configure MTU operation */ + tBTA_GATTC_CONGEST congest; + tBTA_GATTC_QUEUE_FULL queue_full; + tBTA_GATTC_SERVICE_CHANGE srvc_chg; /* service change event */ + tBTA_GATTC_SET_ASSOC set_assoc; + tBTA_GATTC_GET_ADDR_LIST get_addr_list; +} tBTA_GATTC; + +/* GATTC enable callback function */ +typedef void (tBTA_GATTC_ENB_CBACK)(tBTA_GATT_STATUS status); + +/* 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 +#define BTA_GATTS_LISTEN_EVT 19 +#define BTA_GATTS_CONGEST_EVT 20 +#define BTA_GATTS_SET_ATTR_VAL_EVT 23 +#define BTA_GATTS_SEND_SERVICE_CHANGE_EVT 24 + +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 */ +#define BTA_GATT_PERM_READ_AUTHORIZATION GATT_PERM_READ_AUTHORIZATION /* bit 9 - 0x0200 */ +#define BTA_GATT_PERM_WRITE_AUTHORIZATION GATT_PERM_WRITE_AUTHORIZATION /* bit 10 - 0x0400 */ +typedef UINT16 tBTA_GATT_PERM; +typedef tGATT_ATTR_VAL tBTA_GATT_ATTR_VAL; +typedef tGATTS_ATTR_CONTROL tBTA_GATTS_ATTR_CONTROL; + +#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; + +#define BTA_GATT_TRANSPORT_LE GATT_TRANSPORT_LE +#define BTA_GATT_TRANSPORT_BR_EDR GATT_TRANSPORT_BR_EDR +#define BTA_GATT_TRANSPORT_LE_BR_EDR 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; + +/* relate to ESP_GATT_PREP_WRITE_xxx in esp_gatt_defs.h */ +/* 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 tBTA_GATT_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 { + tBTA_GATT_STATUS status; + BD_ADDR remote_bda; + UINT32 trans_id; + UINT16 conn_id; + UINT16 handle; + tBTA_GATTS_REQ_DATA *p_data; + UINT16 data_len; + UINT8 *value; +} tBTA_GATTS_REQ; + +typedef struct { + tBTA_GATTS_IF server_if; + tBTA_GATT_STATUS status; + tBT_UUID uuid; +}tBTA_GATTS_REG_OPER; + + +typedef struct { + tBTA_GATTS_IF server_if; + UINT16 service_id; + UINT16 svc_instance; + BOOLEAN is_primary; + tBTA_GATT_STATUS status; + tBT_UUID uuid; +}tBTA_GATTS_CREATE; + +typedef struct { + tBTA_GATTS_IF server_if; + UINT16 service_id; + UINT16 attr_id; + tBTA_GATT_STATUS status; + tBT_UUID char_uuid; +}tBTA_GATTS_ADD_RESULT; +typedef struct{ + tBTA_GATTS_IF server_if; + UINT16 service_id; + UINT16 attr_id; + tBTA_GATT_STATUS status; +}tBAT_GATTS_ATTR_VAL_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; + UINT8 link_role; + tBTA_GATT_REASON reason; /* report disconnect reason */ + tBTA_GATT_TRANSPORT transport; + tBTA_GATT_CONN_PARAMS conn_params; + UINT8 ble_addr_type; + UINT16 conn_handle; +} tBTA_GATTS_CONN; + +typedef struct { + UINT16 conn_id; + BOOLEAN congested; /* report channel congestion indicator */ +} tBTA_GATTS_CONGEST; + +typedef struct { + UINT16 conn_id; /* connection ID */ + tBTA_GATT_STATUS status; /* notification/indication status */ +} tBTA_GATTS_CONF; + +typedef struct { + tBTA_GATT_STATUS status; + UINT16 conn_id; /* connection ID */ +} tBTA_GATTS_CLOSE; + +typedef struct { + tBTA_GATT_STATUS status; + tBTA_GATTS_IF server_if; +} tBTA_GATTS_SERVICE_CHANGE; + +typedef struct { + tBTA_GATT_STATUS status; + tBTA_GATTS_IF server_if; +} tBTA_GATTS_OPEN; + +typedef struct { + tBTA_GATT_STATUS status; + tBTA_GATTS_IF server_if; +} tBTA_GATTS_CANCEL_OPEN; +/* 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_LISTEN_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 */ + tBAT_GATTS_ATTR_VAL_RESULT attr_val; + tBTA_GATTS_REQ req_data; + tBTA_GATTS_CONN conn; /* BTA_GATTS_CONN_EVT */ + tBTA_GATTS_CONGEST congest; /* BTA_GATTS_CONGEST_EVT callback data */ + tBTA_GATTS_CONF confirm; /* BTA_GATTS_CONF_EVT callback data */ + tBTA_GATTS_CLOSE close; /* BTA_GATTS_CLOSE_EVT callback data */ + tBTA_GATTS_OPEN open; /* BTA_GATTS_OPEN_EVT callback data */ + tBTA_GATTS_CANCEL_OPEN cancel_open; /* tBTA_GATTS_CANCEL_OPEN callback data */ + tBTA_GATTS_SERVICE_CHANGE service_change; + +} tBTA_GATTS; + +/* GATTC wait for service change ccc timer callback data */ +typedef struct { + UINT16 conn_id; + BD_ADDR remote_bda; + UINT8 count; + UINT8 last_status; +}tBTA_GATTC_WAIT_CCC_TIMER; + +/* GATTS enable callback function */ +typedef void (tBTA_GATTS_ENB_CBACK)(tBTA_GATT_STATUS status); + +/* Server callback function */ +typedef void (tBTA_GATTS_CBACK)(tBTA_GATTS_EVT event, tBTA_GATTS *p_data); +typedef struct +{ + tBT_UUID uuid; + BOOLEAN is_primary; + UINT16 handle; + UINT16 s_handle; + UINT16 e_handle; + list_t *characteristics; /* list of tBTA_GATTC_CHARACTERISTIC */ + list_t *included_svc; /* list of tBTA_GATTC_INCLUDED_SVC */ +} __attribute__((packed)) tBTA_GATTC_SERVICE; + +typedef struct +{ + tBT_UUID uuid; + UINT16 handle; + tBTA_GATT_CHAR_PROP properties; + tBTA_GATTC_SERVICE *service; /* owning service*/ + list_t *descriptors; /* list of tBTA_GATTC_DESCRIPTOR */ +} __attribute__((packed)) tBTA_GATTC_CHARACTERISTIC; + +typedef struct +{ + tBT_UUID uuid; + UINT16 handle; + tBTA_GATTC_CHARACTERISTIC *characteristic; /* owning characteristic */ +} __attribute__((packed)) tBTA_GATTC_DESCRIPTOR; + +typedef struct +{ + tBT_UUID uuid; + UINT16 handle; + UINT16 incl_srvc_s_handle; + UINT16 incl_srvc_e_handle; + tBTA_GATTC_SERVICE *owning_service; /* owning service*/ + tBTA_GATTC_SERVICE *included_service; +} __attribute__((packed)) tBTA_GATTC_INCLUDED_SVC; + +/***************************************************************************** +** External Function Declarations +*****************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************** +** Client Functions +***************************/ + +/******************************************************************************* +** +** Function BTA_GATTC_Disable +** +** Description This function is called to disable the GATTC module +** +** Parameters None. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_GATTC_Disable(void); + +/******************************************************************************* +** +** Function BTA_GATTC_AppRegister +** +** Description This function is called to register application callbacks +** with BTA GATTC module. +** +** Parameters p_app_uuid - application UUID +** p_client_cb - pointer to the application callback function. +** +** Returns None +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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. +** remote_addr_type: remote device BD address type. +** is_direct: direct connection or background auto connection +** +** Returns void +** +*******************************************************************************/ +extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, + BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux); + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +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: connection ID to be closed. +** +** Returns void +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_GATTC_ServiceSearchRequest(UINT16 conn_id, tBT_UUID *p_srvc_uuid); + +/******************************************************************************* +** +** Function BTA_GATTC_GetServices +** +** Description This function is called to find the services on the given server. +** +** Parameters conn_id: connection ID which identify the server. +** +** Returns returns list_t of tBTA_GATTC_SERVICE or NULL. +** +*******************************************************************************/ +extern const list_t* BTA_GATTC_GetServices(UINT16 conn_id); + +/******************************************************************************* +** +** Function BTA_GATTC_GetCharacteristic +** +** Description This function is called to find the characteristic on the given server. +** +** Parameters conn_id: connection ID which identify the server. +** handle: characteristic handle +** +** Returns returns pointer to tBTA_GATTC_CHARACTERISTIC or NULL. +** +*******************************************************************************/ +extern const tBTA_GATTC_CHARACTERISTIC* BTA_GATTC_GetCharacteristic(UINT16 conn_id, UINT16 handle); + +/******************************************************************************* +** +** Function BTA_GATTC_GetDescriptor +** +** Description This function is called to find the characteristic on the given server. +** +** Parameters conn_id: connection ID which identify the server. +** handle: descriptor handle +** +** Returns returns pointer to tBTA_GATTC_DESCRIPTOR or NULL. +** +*******************************************************************************/ +extern const tBTA_GATTC_DESCRIPTOR* BTA_GATTC_GetDescriptor(UINT16 conn_id, UINT16 handle); + +extern void BTA_GATTC_GetServiceWithUUID(UINT16 conn_id, tBT_UUID *svc_uuid, + btgatt_db_element_t **db, UINT16 *count); + +extern void BTA_GATTC_GetAllChar(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, + btgatt_db_element_t **db, UINT16 *count); + +extern void BTA_GATTC_GetAllDescriptor(UINT16 conn_id, UINT16 char_handle, + btgatt_db_element_t **db, UINT16 *count); + +extern void BTA_GATTC_GetCharByUUID(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, tBT_UUID char_uuid, + btgatt_db_element_t **db, UINT16 *count); + +extern void BTA_GATTC_GetDescrByUUID(UINT16 conn_id, uint16_t start_handle, uint16_t end_handle, + tBT_UUID char_uuid, tBT_UUID descr_uuid, + btgatt_db_element_t **db, UINT16 *count); + +extern void BTA_GATTC_GetDescrByCharHandle(UINT16 conn_id, UINT16 char_handle, tBT_UUID descr_uuid, + btgatt_db_element_t **db, UINT16 *count); + +extern void BTA_GATTC_GetIncludeService(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, + tBT_UUID *incl_uuid, btgatt_db_element_t **db, UINT16 *count); + +extern void BTA_GATTC_GetDBSize(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, UINT16 *count); + +extern void BTA_GATTC_GetDBSizeByType(UINT16 conn_id, bt_gatt_db_attribute_type_t type, + UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, UINT16 *count); + +/******************************************************************************* +** +** Function BTA_GATTC_GetGattDb +** +** Description This function is called to get gatt db. +** +** Parameters conn_id: connection ID which identify the server. +** db: output parameter which will contain gatt db copy. +** Caller is responsible for freeing it. +** count: number of elements in db. +** +*******************************************************************************/ +extern void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, + btgatt_db_element_t **db, UINT16 *count); + +/******************************************************************************* +** +** Function BTA_GATTC_ReadCharacteristic +** +** Description This function is called to read a characteristics value +** +** Parameters conn_id - connectino ID. +** handle - characteritic handle to read. +** +** Returns None +** +*******************************************************************************/ +void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_REQ auth_req); + +/******************************************************************************* +** +** Function BTA_GATTC_Read_by_type +** +** Description This function is called to read a attribute value by uuid +** +** Parameters conn_id - connection ID. +** s_handle - start handle. +** e_handle - end hanle +** uuid - The attribute UUID. +** +** Returns None +** +*******************************************************************************/ +void BTA_GATTC_Read_by_type(UINT16 conn_id, UINT16 s_handle,UINT16 e_handle, tBT_UUID *uuid, tBTA_GATT_AUTH_REQ auth_req); + +/******************************************************************************* +** +** Function BTA_GATTC_ReadCharDescr +** +** Description This function is called to read a descriptor value. +** +** Parameters conn_id - connection ID. +** handle - descriptor handle to read. +** +** Returns None +** +*******************************************************************************/ +void BTA_GATTC_ReadCharDescr (UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_REQ auth_req); + +/******************************************************************************* +** +** Function BTA_GATTC_WriteCharValue +** +** Description This function is called to write characteristic value. +** +** Parameters conn_id - connection ID. +** handle - characteristic handle to write. +** write_type - type of write. +** len: length of the data to be written. +** p_value - the value to be written. +** +** Returns None +** +*******************************************************************************/ +void BTA_GATTC_WriteCharValue ( UINT16 conn_id, + UINT16 handle, + 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 descriptor value. +** +** Parameters conn_id - connection ID +** handle - descriptor handle to write. +** write_type - type of write. +** p_value - the value to be written. +** +** Returns None +** +*******************************************************************************/ +void BTA_GATTC_WriteCharDescr (UINT16 conn_id, + UINT16 handle, + 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. +** handle - characteristic handle to confirm. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_GATTC_SendIndConfirm (UINT16 conn_id, UINT16 handle); + +/******************************************************************************* +** +** 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. +** handle - GATT characteristic handle. +** +** Returns OK if registration succeed, otherwise failed. +** +*******************************************************************************/ +extern tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if, + BD_ADDR remote_bda, + UINT16 handle); + +/******************************************************************************* +** +** 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. +** handle - GATT characteristic handle. +** +** Returns OK if deregistration succeed, otherwise failed. +** +*******************************************************************************/ +extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if, + BD_ADDR remote_bda, + UINT16 handle); + +/******************************************************************************* +** +** Function BTA_GATTC_PrepareWrite +** +** Description This function is called to prepare write a characteristic value. +** +** Parameters conn_id - connection ID. +** handle - GATT characteritic handle. +** offset - offset of the write value. +** len - length of the data to be written. +** p_value - the value to be written. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_GATTC_PrepareWrite (UINT16 conn_id, + UINT16 handle, + UINT16 offset, + UINT16 len, + UINT8 *p_value, + tBTA_GATT_AUTH_REQ auth_req); + +/******************************************************************************* +** +** Function BTA_GATTC_PrepareWriteCharDescr +** +** Description This function is called to prepare write a characteristic descriptor value. +** +** Parameters conn_id - connection ID. +** p_char_descr_id - GATT characteritic descriptor ID of the service. +** offset - offset of the write value. +** len: length of the data to be written. +** p_value - the value to be written. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_GATTC_PrepareWriteCharDescr (UINT16 conn_id, + UINT16 handle, + UINT16 offset, + tBTA_GATT_UNFMT *p_data, + tBTA_GATT_AUTH_REQ auth_req); +/******************************************************************************* +** +** Function BTA_GATTC_ExecuteWrite +** +** Description This function is called to execute write a prepare write sequence. +** +** Parameters conn_id - connection ID. +** is_execute - execute or cancel. +** +** Returns None +** +*******************************************************************************/ +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 - connection ID. +** p_read_multi - read multiple parameters. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi, + tBTA_GATT_AUTH_REQ auth_req); + +/******************************************************************************* +** +** Function BTA_GATTC_ReadMultiple +** +** Description This function is called to read multiple variable length characteristic or +** characteristic descriptors. +** +** Parameters conn_id - connection ID. +** p_read_multi - read multiple parameters. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_GATTC_ReadMultipleVariable(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi, + tBTA_GATT_AUTH_REQ auth_req); + +/******************************************************************************* +** +** Function BTA_GATTC_Refresh +** +** Description Refresh the server cache of the remote device +** +** Parameters remote_bda: remote device BD address. +** erase_flash: delete cache from nvs flash +** +** Returns void +** +*******************************************************************************/ +extern void BTA_GATTC_Refresh(BD_ADDR remote_bda, bool erase_flash); + +extern void BTA_GATTC_CacheAssoc(tBTA_GATTC_IF client_if, BD_ADDR src_addr, BD_ADDR assoc_addr, BOOLEAN is_assoc); + +extern void BTA_GATTC_CacheGetAddrList(tBTA_GATTC_IF client_if); + +/******************************************************************************* +** +** Function BTA_GATTC_Clean +** +** Description Clean the server cache of the remote device +** +** Parameters remote_bda: remote device BD address. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_GATTC_Clean(BD_ADDR remote_bda); + +/******************************************************************************* +** +** Function BTA_GATTC_Listen +** +** Description Start advertisement to listen for connection request. +** +** Parameters client_if: server interface. +** start: to start or stop listening for connection +** remote_bda: remote device BD address, if listen to all device +** use NULL. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target_bda); + +/******************************************************************************* +** +** Function BTA_GATTC_Broadcast +** +** Description Start broadcasting (non-connectable advertisements) +** +** Parameters client_if: client interface. +** start: to start or stop listening for connection +** +** Returns void +** +*******************************************************************************/ +extern void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start); + + +/******************************************************************************* +** +** Function BTA_GATTC_ConfigureMTU +** +** Description Configure the MTU size in the GATT channel. This can be done +** only once per connection. +** +** Parameters conn_id: connection ID. +** +** +** Returns void +** +*******************************************************************************/ +extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id); + +/******************************************************************************* +** BTA GATT Server API +********************************************************************************/ + +/******************************************************************************* +** +** Function BTA_GATTS_Init +** +** Description This function is called to initalize GATTS module +** +** Parameters None +** +** Returns None +** +*******************************************************************************/ +extern void BTA_GATTS_Init(void); + +/******************************************************************************* +** +** Function BTA_GATTS_Disable +** +** Description This function is called to disable GATTS module +** +** Parameters None. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_GATTS_Disable(void); + +/******************************************************************************* +** +** Function BTA_GATTS_AppRegister +** +** Description This function is called to register application callbacks +** with BTA GATTS module. +** +** Parameters p_app_uuid - application UUID +** p_cback - pointer to the application callback function. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_GATTS_AppRegister(const 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 +** +*******************************************************************************/ +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_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 +** +*******************************************************************************/ +extern void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, const 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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_GATTS_AddCharacteristic (UINT16 service_id, const tBT_UUID * p_char_uuid, + tBTA_GATT_PERM perm, tBTA_GATT_CHAR_PROP property, tGATT_ATTR_VAL *attr_val, + tBTA_GATTS_ATTR_CONTROL *control); + +/******************************************************************************* +** +** 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. +** +*******************************************************************************/ +extern void BTA_GATTS_AddCharDescriptor (UINT16 service_id, + tBTA_GATT_PERM perm, + const tBT_UUID * p_descr_uuid, tBTA_GATT_ATTR_VAL *attr_val, + tBTA_GATTS_ATTR_CONTROL *control); + +/******************************************************************************* +** +** 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. +** +*******************************************************************************/ +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 transport. +** +** Returns None. +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id, + tBTA_GATT_STATUS status, tBTA_GATTS_RSP *p_msg); + + + +/******************************************************************************* +** +** Function BTA_SetAttributeValue +** +** Description This function is called to set the attribute value in the gatt database +** +** Parameters attr_handle - the attribute value handle. +** length - the value length which has been set to the attribute. +** value - the pointer to the value +** +** Returns None +** +*******************************************************************************/ +extern void BTA_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *value); + + +/******************************************************************************* +** +** Function BTA_GetAttributeValue +** +** Description This function is called to get the attribute value in the gatt database +** +** Parameters attr_handle - the attribute value handle. +** length - the value length which has been set to the attribute. +** value - the pointer to the value +** +** Returns tBTA_GATT_STATUS +** +*******************************************************************************/ +extern tBTA_GATT_STATUS BTA_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value); + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +extern void BTA_GATTS_Open(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, + BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport); + + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +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: connection ID to be closed. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_GATTS_Close(UINT16 conn_id); + +/******************************************************************************* +** +** Function BTA_GATTS_SendServiceChangeIndication +** +** Description send a service change indication. +** +** Returns void +** +*******************************************************************************/ + +void BTA_GATTS_SendServiceChangeIndication(tBTA_GATTS_IF server_if, BD_ADDR remote_bda); + +/******************************************************************************* +** +** Function BTA_GATTS_Listen +** +** Description Start advertisement to listen for connection request for a +** GATT server +** +** Parameters server_if: server interface. +** start: to start or stop listening for connection +** remote_bda: remote device BD address, if listen to all device +** use NULL. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_GATTS_Listen(tBTA_GATTS_IF server_if, BOOLEAN start, + BD_ADDR_PTR target_bda); + +/******************************************************************************* +** +** Function BTA_GATTS_ShowLocalDatabase +** +** Description print local service database. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_GATTS_ShowLocalDatabase(void); + +extern void bta_gattc_clcb_dealloc_by_conn_id(UINT16 conn_id); + +#ifdef __cplusplus + +} +#endif + + +#endif /* BTA_GATT_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_gatt_common.h b/lib/bt/host/bluedroid/bta/include/bta/bta_gatt_common.h new file mode 100644 index 00000000..2d696729 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_gatt_common.h @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/****************************************************************************** + * + * This file contains the action functions for gatts and gattc. + * + * + ******************************************************************************/ + +#include "stack/bt_types.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern void BTA_GATT_SetLocalMTU(uint16_t mtu); + +extern uint16_t BTA_GATT_GetLocalMTU(void); + +#ifdef __cplusplus +} +#endif diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_gattc_ci.h b/lib/bt/host/bluedroid/bta/include/bta/bta_gattc_ci.h new file mode 100644 index 00000000..d523e87b --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_gattc_ci.h @@ -0,0 +1,117 @@ +/****************************************************************************** + * + * Copyright (C) 2003-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for GATT call-in functions. + * + ******************************************************************************/ +#ifndef BTA_GATTC_CI_H +#define BTA_GATTC_CI_H + +#include "bta/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 100 + +/* 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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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/lib/bt/host/bluedroid/bta/include/bta/bta_gattc_co.h b/lib/bt/host/bluedroid/bta/include/bta/bta_gattc_co.h new file mode 100644 index 00000000..44a0e18e --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_gattc_co.h @@ -0,0 +1,140 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2013 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for BTA GATT client call-out functions. + * + ******************************************************************************/ +#ifndef BTA_GATTC_CO_H +#define BTA_GATTC_CO_H + +#include "bta/bta_gatt_api.h" +#include "osi/hash_functions.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. +** +*******************************************************************************/ +extern tBTA_GATT_STATUS bta_gattc_co_cache_open(BD_ADDR server_bda, BOOLEAN to_save, UINT8 *index); + +/******************************************************************************* +** +** 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. +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void bta_gattc_co_cache_save (BD_ADDR server_bda, UINT16 num_attr, + tBTA_GATTC_NV_ATTR *p_attr_list); + +/******************************************************************************* +** +** 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 +** +*******************************************************************************/ +extern tBTA_GATT_STATUS bta_gattc_co_cache_load(tBTA_GATTC_NV_ATTR *attr, UINT8 index); + +/******************************************************************************* +** +** Function bta_gattc_co_cache_reset +** +** Description This callout function is executed by GATTC to reset cache in +** application +** +** Parameter server_bda: server bd address of this cache belongs to +** +** Returns void. +** +*******************************************************************************/ +extern void bta_gattc_co_cache_reset(BD_ADDR server_bda); + +extern size_t bta_gattc_get_cache_attr_length(UINT8 index); + +extern void bta_gattc_co_cache_addr_init(void); + +extern void bta_gattc_co_cache_addr_deinit(void); + +extern BOOLEAN bta_gattc_co_addr_in_cache(BD_ADDR bda); + +extern uint8_t bta_gattc_co_find_addr_in_cache(BD_ADDR bda); + +extern uint8_t bta_gattc_co_find_hash_in_cache(hash_key_t hash_key); + +extern UINT8 bta_gattc_co_get_addr_num(void); + +extern void bta_gattc_co_get_addr_list(BD_ADDR *addr_list); + +extern void bta_gattc_co_cache_addr_save(BD_ADDR bd_addr, hash_key_t hash_key); + +extern BOOLEAN bta_gattc_co_cache_new_assoc_list(BD_ADDR src_addr, uint8_t index); + +extern BOOLEAN bta_gattc_co_cache_append_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr); + +extern BOOLEAN bta_gattc_co_cache_remove_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr); + +uint8_t* bta_gattc_co_cache_find_src_addr(BD_ADDR assoc_addr, uint8_t *index); + +extern BOOLEAN bta_gattc_co_cache_clear_assoc_addr(BD_ADDR src_addr); + +#endif /* BTA_GATT_CO_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_gatts_co.h b/lib/bt/host/bluedroid/bta/include/bta/bta_gatts_co.h new file mode 100644 index 00000000..66178c76 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_gatts_co.h @@ -0,0 +1,88 @@ +/****************************************************************************** + * + * Copyright (C) 2010-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for BTA GATT server call-out functions. + * + ******************************************************************************/ +#ifndef BTA_GATTS_CO_H +#define BTA_GATTS_CO_H + +#include "bta/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. +** +*******************************************************************************/ +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. +** FALSE - if the request can not be processed +** +*******************************************************************************/ +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. +** +*******************************************************************************/ +extern BOOLEAN bta_gatts_co_load_handle_range(UINT8 index, + tBTA_GATTS_HNDL_RANGE *p_handle); + +extern void bta_gatts_co_cl_feat_save(BD_ADDR remote_addr, UINT8 *feature); + +extern void bta_gatts_co_db_hash_save(BD_ADDR remote_addr, BT_OCTET16 db_hash); + +extern void bta_gatts_co_cl_feat_load(BD_ADDR remote_addr, UINT8 *feature); + +extern void bta_gatts_co_db_hash_load(BD_ADDR remote_addr, BT_OCTET16 db_hash); + +#endif /* BTA_GATTS_CO_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_hd_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_hd_api.h new file mode 100644 index 00000000..1c7e708e --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_hd_api.h @@ -0,0 +1,295 @@ +/****************************************************************************** + * + * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2002-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +#ifndef BTA_HD_API_H +#define BTA_HD_API_H + +#include "bta_api.h" +#include "stack/hidd_api.h" + +#if BTA_HD_INCLUDED == TRUE + +/***************************************************************************** + * Constants and Type Definitions + ****************************************************************************/ + +#ifndef BTA_HD_DEBUG +#define BTA_HD_DEBUG TRUE +#endif + +/* BTA HID Device callback events */ +#define BTA_HD_ENABLE_EVT 0 /* BT-HD enabled */ +#define BTA_HD_DISABLE_EVT 1 /* BT-HD disabled */ +#define BTA_HD_REGISTER_APP_EVT 2 /* application registered */ +#define BTA_HD_UNREGISTER_APP_EVT 3 /* application unregistered */ +#define BTA_HD_OPEN_EVT 4 /* connection to host opened */ +#define BTA_HD_CLOSE_EVT 5 /* connection to host closed */ +#define BTA_HD_GET_REPORT_EVT 6 /* GET_REPORT request from host */ +#define BTA_HD_SET_REPORT_EVT 7 /* SET_REPORT request from host */ +#define BTA_HD_SET_PROTOCOL_EVT 8 /* SET_PROTOCOL request from host */ +#define BTA_HD_INTR_DATA_EVT 9 /* DATA received from host on intr */ +#define BTA_HD_VC_UNPLUG_EVT 10 /* Virtual Cable Unplug */ +// #define BTA_HD_CONN_STATE_EVT 11 /* Report connection state change */ +#define BTA_HD_SEND_REPORT_EVT 12 /* Send report finish */ +#define BTA_HD_REPORT_ERR_EVT 13 /* Report Handshake finish */ +#define BTA_HD_API_ERR_EVT 99 /* BT-HD API error */ + +typedef uint16_t tBTA_HD_EVT; + +enum { BTA_HD_OK, BTA_HD_ERROR }; + +typedef enum { + BTA_HD_CONN_STATE_CONNECTED, + BTA_HD_CONN_STATE_CONNECTING, + BTA_HD_CONN_STATE_DISCONNECTED, + BTA_HD_CONN_STATE_DISCONNECTING, + BTA_HD_CONN_STATE_UNKNOWN +} tBTA_HD_CONN_STAT; + +typedef uint8_t tBTA_HD_STATUS; +typedef tHID_DEV_DSCP_INFO tBTA_HD_DEV_DESCR; + +typedef struct { + char *p_name; + char *p_description; + char *p_provider; + uint8_t subclass; + tBTA_HD_DEV_DESCR descriptor; +} tBTA_HD_APP_INFO; + +typedef struct { + uint8_t service_type; + uint32_t token_rate; + uint32_t token_bucket_size; + uint32_t peak_bandwidth; + uint32_t access_latency; + uint32_t delay_variation; +} tBTA_HD_QOS_INFO; + +typedef struct { + bool use_intr; + uint8_t type; + uint8_t id; + uint16_t len; + uint8_t *p_data; +} tBTA_HD_REPORT; + +typedef struct { + tBTA_HD_STATUS status; + bool in_use; + BD_ADDR bda; +} tBTA_HD_REG_STATUS; + +typedef struct { + BD_ADDR bda; + tBTA_HD_STATUS status; + tBTA_HD_CONN_STAT conn_status; +} tBTA_HD_CONN; + +typedef struct { + uint8_t report_type; + uint8_t report_id; + uint16_t buffer_size; +} tBTA_HD_GET_REPORT; + +typedef struct { + uint8_t report_type; + uint8_t report_id; + uint16_t len; + uint8_t *p_data; +} tBTA_HD_SET_REPORT; + +typedef uint8_t tBTA_HD_SET_PROTOCOL; + +typedef struct { + uint8_t report_id; + uint16_t len; + uint8_t *p_data; +} tBTA_HD_INTR_DATA; + +typedef struct { + tBTA_HD_STATUS status; + uint8_t reason; + uint8_t report_type; + uint8_t report_id; +} tBTA_HD_API_SEND_REPORT; + +typedef struct { + tBTA_HD_STATUS status; + uint8_t reason; +} tBTA_HD_API_REPORT_ERR; + +/* union of data associated with HD callback */ +typedef union { + tBTA_HD_STATUS status; /* BTA_HD_ENABLE_EVT + BTA_HD_DISABLE_EVT + BTA_HD_UNREGISTER_APP_EVT */ + tBTA_HD_REG_STATUS reg_status; /* BTA_HD_REGISTER_APP_EVT */ + tBTA_HD_CONN conn; /* BTA_HD_OPEN_EVT + BTA_HD_CLOSE_EVT + BTA_HD_VC_UNPLUG_EVT + BTA_HD_OWN_VC_UNPLUG_EVT */ + tBTA_HD_GET_REPORT get_report; /* BTA_HD_GET_REPORT */ + tBTA_HD_SET_REPORT set_report; /* BTA_HD_SET_REPORT */ + tBTA_HD_SET_PROTOCOL set_protocol; /* BTA_HD_SETPROTOCOL */ + tBTA_HD_INTR_DATA intr_data; /* BTA_HD_INTR_DATA_EVT */ + tBTA_HD_API_SEND_REPORT send_report; /* BTA_HD_API_SEND_REPORT_EVT */ + tBTA_HD_API_REPORT_ERR report_err; /* BTA_HD_API_REPORT_ERR_EVT */ +} tBTA_HD; + +/* BTA HD callback function */ +typedef void (tBTA_HD_CBACK)(tBTA_HD_EVT event, tBTA_HD *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 + * + ******************************************************************************/ +extern void BTA_HdEnable(tBTA_HD_CBACK *p_cback); + +/******************************************************************************* + * + * Function BTA_HhDeregister + * + * Description This function is called when the host is about power down. + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdDisable(void); + +/******************************************************************************* + * + * Function BTA_HdRegisterApp + * + * Description This function is called when application should be + * registered + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdRegisterApp(tBTA_HD_APP_INFO *p_app_info, tBTA_HD_QOS_INFO *p_in_qos, tBTA_HD_QOS_INFO *p_out_qos); + +/******************************************************************************* + * + * Function BTA_HdUnregisterApp + * + * Description This function is called when application should be + * unregistered + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdUnregisterApp(void); + +/******************************************************************************* + * + * Function BTA_HdSendReport + * + * Description This function is called when report is to be sent + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdSendReport(tBTA_HD_REPORT *p_report); + +/******************************************************************************* + * + * Function BTA_HdVirtualCableUnplug + * + * Description This function is called when VCU shall be sent + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdVirtualCableUnplug(void); + +/******************************************************************************* + * + * Function BTA_HdConnect + * + * Description This function is called when connection to host shall be + * made. + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdConnect(BD_ADDR addr); + +/******************************************************************************* + * + * Function BTA_HdDisconnect + * + * Description This function is called when host shall be disconnected + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdDisconnect(void); + +/******************************************************************************* + * + * Function BTA_HdAddDevice + * + * Description This function is called when a device is virtually cabled + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdAddDevice(BD_ADDR addr); + +/******************************************************************************* + * + * Function BTA_HdRemoveDevice + * + * Description This function is called when a device is virtually uncabled + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdRemoveDevice(BD_ADDR addr); + +/******************************************************************************* + * + * Function BTA_HdReportError + * + * Description This function is called when reporting error for set report + * + * Returns void + * + ******************************************************************************/ +extern void BTA_HdReportError(uint8_t error); + +#ifdef __cplusplus +} +#endif + +#endif /* BTA_HD_INCLUDED */ +#endif /* BTA_HD_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h new file mode 100644 index 00000000..ac834c7b --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h @@ -0,0 +1,418 @@ +/****************************************************************************** + * + * Copyright (c) 2014 The Android Open Source Project + * Copyright (C) 2003-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the public interface file for the handsfree (HF role) subsystem + * + ******************************************************************************/ +#ifndef BTA_HF_CLIENT_API_H +#define BTA_HF_CLIENT_API_H + +#include "bta_api.h" +#include "bta_hfp_defs.h" + +#if (BTA_HF_INCLUDED == TRUE) +/***************************************************************************** +** Constants and data types +*****************************************************************************/ + +/* Hands-Free unit(HF) version */ +#define HFP_HF_VERSION_1_6 0x0106 /* v1.6 */ +#define HFP_HF_VERSION_1_7 0x0107 /* v1.7 */ + +/* HFP peer (AG) features*/ +#define BTA_HF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */ +#define BTA_HF_CLIENT_PEER_FEAT_ECNR 0x00000002 /* Echo cancellation and/or noise reduction */ +#define BTA_HF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */ +#define BTA_HF_CLIENT_PEER_INBAND 0x00000008 /* In-band ring tone */ +#define BTA_HF_CLIENT_PEER_VTAG 0x00000010 /* Attach a phone number to a voice tag */ +#define BTA_HF_CLIENT_PEER_REJECT 0x00000020 /* Ability to reject incoming call */ +#define BTA_HF_CLIENT_PEER_ECS 0x00000040 /* Enhanced Call Status */ +#define BTA_HF_CLIENT_PEER_ECC 0x00000080 /* Enhanced Call Control */ +#define BTA_HF_CLIENT_PEER_EXTERR 0x00000100 /* Extended error codes */ +#define BTA_HF_CLIENT_PEER_CODEC 0x00000200 /* Codec Negotiation */ +/* HFP 1.7+ */ +#define BTA_HF_CLIENT_PEER_HF_IND 0x00000400 /* HF Indicators */ +#define BTA_HF_CLIENT_PEER_ESCO_S4 0x00000800 /* eSCO S4 Setting Supported */ + +typedef UINT16 tBTA_HF_CLIENT_PEER_FEAT; + +/* HFP HF features */ +#define BTA_HF_CLIENT_FEAT_ECNR 0x00000001 /* Echo cancellation and/or noise reduction */ +#define BTA_HF_CLIENT_FEAT_3WAY 0x00000002 /* Call waiting and three-way calling */ +#define BTA_HF_CLIENT_FEAT_CLI 0x00000004 /* Caller ID presentation capability */ +#define BTA_HF_CLIENT_FEAT_VREC 0x00000008 /* Voice recognition activation */ +#define BTA_HF_CLIENT_FEAT_VOL 0x00000010 /* Remote volume control */ +#define BTA_HF_CLIENT_FEAT_ECS 0x00000020 /* Enhanced Call Status */ +#define BTA_HF_CLIENT_FEAT_ECC 0x00000040 /* Enhanced Call Control */ +#define BTA_HF_CLIENT_FEAT_CODEC 0x00000080 /* Codec Negotiation */ +#define BTA_HF_CLIENT_FEAT_HF_IND 0x00000100 /* HF indicators */ +#define BTA_HF_CLIENT_FEAT_ESCO_S4 0x00000200 /* eSCO S4 Setting Supported */ + +/* HFP HF extended call handling - masks not related to any spec */ +#define BTA_HF_CLIENT_CHLD_REL 0x00000001 /* 0 Release waiting call or held calls */ +#define BTA_HF_CLIENT_CHLD_REL_ACC 0x00000002 /* 1 Release active calls and accept other (waiting or held) cal */ +#define BTA_HF_CLIENT_CHLD_REL_X 0x00000004 /* 1x Release x call*/ +#define BTA_HF_CLIENT_CHLD_HOLD_ACC 0x00000008 /* 2 Active calls on hold and accept other call */ +#define BTA_HF_CLIENT_CHLD_PRIV_X 0x00000010 /* 2x Active multiparty call on hold except call x */ +#define BTA_HF_CLIENT_CHLD_MERGE 0x00000020 /* 3 Add held call to multiparty */ +#define BTA_HF_CLIENT_CHLD_MERGE_DETACH 0x00000040 /* 4 Add held call to multiparty */ + +typedef UINT16 tBTA_HF_CLIENT_CHLD_FEAT; + +/* HFP AG errors ot OK sent to HF Unit */ +#define BTA_HF_CLIENT_AT_RESULT_OK 0 +#define BTA_HF_CLIENT_AT_RESULT_ERROR 1 +#define BTA_HF_CLIENT_AT_RESULT_NO_CARRIER 2 +#define BTA_HF_CLIENT_AT_RESULT_BUSY 3 +#define BTA_HF_CLIENT_AT_RESULT_NO_ANSWER 4 +#define BTA_HF_CLIENT_AT_RESULT_DELAY 5 +#define BTA_HF_CLIENT_AT_RESULT_BLACKLISTED 6 +#define BTA_HF_CLIENT_AT_RESULT_CME 7 + +typedef UINT8 tBTA_HF_CLIENT_AT_RESULT_TYPE; + +/* HF Client callback events */ +#define BTA_HF_CLIENT_ENABLE_EVT 0 /* HF Client enabled */ +#define BTA_HF_CLIENT_REGISTER_EVT 1 /* HF Client registered */ +#define BTA_HF_CLIENT_OPEN_EVT 2 /* HF Client connection open */ +#define BTA_HF_CLIENT_CLOSE_EVT 3 /* HF Client connection closed */ +#define BTA_HF_CLIENT_CONN_EVT 4 /* Service level connection opened */ +#define BTA_HF_CLIENT_AUDIO_OPEN_EVT 5 /* Audio connection open */ +#define BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT 6 /* Audio connection with mSBC codec open */ +#define BTA_HF_CLIENT_AUDIO_CLOSE_EVT 7 /* Audio connection closed */ +#define BTA_HF_CLIENT_SPK_EVT 8 /* Speaker volume changed */ +#define BTA_HF_CLIENT_MIC_EVT 9 /* Microphone volume changed */ +#define BTA_HF_CLIENT_IND_EVT 10 /* Indicator */ +#define BTA_HF_CLIENT_VOICE_REC_EVT 11 /* AG changed voice recognition setting */ +#define BTA_HF_CLIENT_OPERATOR_NAME_EVT 12 /* Operator name acquired */ +#define BTA_HF_CLIENT_CLIP_EVT 13 /* Calling line identification event */ +#define BTA_HF_CLIENT_CCWA_EVT 14 /* Call waiting notification */ +#define BTA_HF_CLIENT_AT_RESULT_EVT 15 /* Call waiting notification */ +#define BTA_HF_CLIENT_CLCC_EVT 16 /* current call event */ +#define BTA_HF_CLIENT_CNUM_EVT 17 /* subscriber information event */ +#define BTA_HF_CLIENT_BTRH_EVT 18 /* bluetooth response and hold event */ +#define BTA_HF_CLIENT_BSIR_EVT 19 /* in-band ring tone setting changed event */ +#define BTA_HF_CLIENT_BINP_EVT 20 /* binp number event */ +#define BTA_HF_CLIENT_RING_INDICATION 21 /* HF Client ring indication */ +#define BTA_HF_CLIENT_DISABLE_EVT 22 /* HF Client disabled */ +#define BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT 23 /* HF Client packet status nums */ + +typedef UINT8 tBTA_HF_CLIENT_EVT; + +/* HF Client open status */ +#define BTA_HF_CLIENT_SUCCESS 0 /* Connection successfully opened */ +#define BTA_HF_CLIENT_FAIL_SDP 1 /* Open failed due to SDP */ +#define BTA_HF_CLIENT_FAIL_RFCOMM 2 /* Open failed due to RFCOMM */ +#define BTA_HF_CLIENT_FAIL_RESOURCES 3 /* out of resources failure */ + +typedef UINT8 tBTA_HF_CLIENT_STATUS; + +/* indicator constants HFP 1.1 and later */ +#define BTA_HF_CLIENT_IND_CALL 0 /* position of call indicator */ +#define BTA_HF_CLIENT_IND_CALLSETUP 1 /* position of callsetup indicator */ +#define BTA_HF_CLIENT_IND_SERVICE 2 /* position of service indicator */ +/* indicator constants HFP 1.5 and later */ +#define BTA_HF_CLIENT_IND_SIGNAL 3 /* position of signal strength indicator */ +#define BTA_HF_CLIENT_IND_ROAM 4 /* position of roaming indicator */ +#define BTA_HF_CLIENT_IND_BATTCH 5 /* position of battery charge indicator */ +#define BTA_HF_CLIENT_IND_CALLHELD 6 /* position of callheld indicator */ +#define BTA_HF_CLIENT_IND_BEARER 7 /* position of bearer indicator */ +typedef UINT8 tBTA_HF_CLIENT_IND_TYPE; + +/* AT commands */ +#define BTA_HF_CLIENT_AT_CMD_VTS 0 +#define BTA_HF_CLIENT_AT_CMD_BTRH 1 +#define BTA_HF_CLIENT_AT_CMD_CHUP 2 +#define BTA_HF_CLIENT_AT_CMD_CHLD 3 +#define BTA_HF_CLIENT_AT_CMD_BCC 4 +#define BTA_HF_CLIENT_AT_CMD_CNUM 5 +#define BTA_HF_CLIENT_AT_CMD_ATA 6 +#define BTA_HF_CLIENT_AT_CMD_COPS 7 +#define BTA_HF_CLIENT_AT_CMD_ATD 8 +#define BTA_HF_CLIENT_AT_CMD_VGM 9 +#define BTA_HF_CLIENT_AT_CMD_VGS 10 +#define BTA_HF_CLIENT_AT_CMD_BVRA 11 +#define BTA_HF_CLIENT_AT_CMD_CLCC 12 +#define BTA_HF_CLIENT_AT_CMD_BINP 13 +#define BTA_HF_CLIENT_AT_CMD_BLDN 14 +#define BTA_HF_CLIENT_AT_CMD_NREC 15 +#define BTA_HF_CLIENT_AT_CMD_XAPL 16 +#define BTA_HF_CLIENT_AT_CMD_IPHONEACCEV 17 + +typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE; + +#define BTA_HF_CLIENT_MAX_LEN 32 + +/* data associated with most non-AT events */ +/* placeholder, if not needed should be removed*/ +typedef struct { + UINT16 sync_conn_handle; +} tBTA_HF_CLIENT_HDR; + +/* data associated with BTA_HF_CLIENT_REGISTER_EVT */ +typedef struct { + tBTA_HF_CLIENT_HDR hdr; + UINT16 handle; + tBTA_HF_CLIENT_STATUS status; +} tBTA_HF_CLIENT_REGISTER; + +/* data associated with BTA_HF_CLIENT_OPEN_EVT */ +typedef struct { + tBTA_HF_CLIENT_HDR hdr; + BD_ADDR bd_addr; + tBTA_HF_CLIENT_STATUS status; +} tBTA_HF_CLIENT_OPEN; + +/* data associated with BTA_HF_CLIENT_CONN_EVT */ +typedef struct { + tBTA_HF_CLIENT_HDR hdr; + tBTA_HF_CLIENT_PEER_FEAT peer_feat; + tBTA_HF_CLIENT_CHLD_FEAT chld_feat; +} tBTA_HF_CLIENT_CONN; + +/* data associated with BTA_HF_CLIENT_IND_EVT event */ +typedef struct { + tBTA_HF_CLIENT_HDR hdr; + tBTA_HF_CLIENT_IND_TYPE type; + UINT16 value; +} tBTA_HF_CLIENT_IND; + +/* data associated with BTA_HF_CLIENT_OPERATOR_NAME_EVT */ +#define BTA_HF_CLIENT_OPERATOR_NAME_LEN 16 +typedef struct { + char name[BTA_HF_CLIENT_OPERATOR_NAME_LEN + 1]; +} tBTA_HF_CLIENT_OPERATOR_NAME; + +/* data associated with BTA_HF_CLIENT_CLIP_EVT and BTA_HF_CLIENT_CCWA_EVT*/ +#define BTA_HF_CLIENT_NUMBER_LEN 32 +typedef struct { + char number[BTA_HF_CLIENT_NUMBER_LEN + 1]; +} tBTA_HF_CLIENT_NUMBER; + +/* data associated with BTA_HF_CLIENT_AT_RESULT_EVT event */ +typedef struct { + tBTA_HF_CLIENT_AT_RESULT_TYPE type; + UINT16 cme; +} tBTA_HF_CLIENT_AT_RESULT; + +/* data associated with BTA_HF_CLIENT_CLCC_EVT event */ +typedef struct { + UINT32 idx; + BOOLEAN inc; + UINT8 status; + BOOLEAN mpty; + BOOLEAN number_present; + char number[BTA_HF_CLIENT_NUMBER_LEN + 1]; +} tBTA_HF_CLIENT_CLCC; + +/* data associated with BTA_HF_CLIENT_CNUM_EVT event */ +typedef struct { + UINT16 service; + char number[BTA_HF_CLIENT_NUMBER_LEN + 1]; +} tBTA_HF_CLIENT_CNUM; + +/* data associated with other events */ +typedef struct { + UINT16 value; +} tBTA_HF_CLIENT_VAL; + +/* data associated with BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT */ +typedef struct { + UINT32 rx_total; + UINT32 rx_correct; + UINT32 rx_err; + UINT32 rx_none; + UINT32 rx_lost; + UINT32 tx_total; + UINT32 tx_discarded; +} tBTA_SCO_PKT_STAT_NUMS; + +/* union of data associated with AG callback */ +typedef union { + tBTA_HF_CLIENT_HDR hdr; + tBTA_HF_CLIENT_REGISTER reg; + tBTA_HF_CLIENT_OPEN open; + tBTA_HF_CLIENT_CONN conn; + tBTA_HF_CLIENT_IND ind; + tBTA_HF_CLIENT_VAL val; + tBTA_HF_CLIENT_OPERATOR_NAME operator; + tBTA_HF_CLIENT_NUMBER number; + tBTA_HF_CLIENT_AT_RESULT result; + tBTA_HF_CLIENT_CLCC clcc; + tBTA_HF_CLIENT_CNUM cnum; + tBTA_SCO_PKT_STAT_NUMS pkt_num; +} tBTA_HF_CLIENT; + +typedef UINT32 tBTA_HF_CLIENT_FEAT; + +/* HF Client callback */ +typedef void (tBTA_HF_CLIENT_CBACK)(tBTA_HF_CLIENT_EVT event, void *p_data); + +#ifdef __cplusplus +extern "C" +{ +#endif + +/***************************************************************************** +** External Function Declarations +*****************************************************************************/ + +/******************************************************************************* +** +** Function BTA_HfClientEnable +** +** Description Enable the HF CLient service. When the enable +** operation is complete the callback function will be +** called with a BTA_HF_CLIENT_ENABLE_EVT. This function must +** be called before other function in the HF CLient API are +** called. +** +** Returns BTA_SUCCESS if OK, BTA_FAILURE otherwise. +** +*******************************************************************************/ +tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK *p_cback); + +/******************************************************************************* +** +** Function BTA_HfClientDisable +** +** Description Disable the HF Client service +** +** +** Returns void +** +*******************************************************************************/ +void BTA_HfClientDisable(void); + +/******************************************************************************* +** +** Function BTA_HfClientRegister +** +** Description Register an HF Client service. +** +** +** Returns void +** +*******************************************************************************/ +void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features, + char *p_service_name); + +/******************************************************************************* +** +** Function BTA_HfClientDeregister +** +** Description Deregister an HF Client service. +** +** +** Returns void +** +*******************************************************************************/ +void BTA_HfClientDeregister(UINT16 handle); + +/******************************************************************************* +** +** Function BTA_HfClientOpen +** +** Description Opens a connection to an audio gateway. +** When connection is open callback function is called +** with a BTA_HF_CLIENT_OPEN_EVT. Only the data connection is +** opened. The audio connection is not opened. +** +** +** Returns void +** +*******************************************************************************/ +void BTA_HfClientOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask); + +/******************************************************************************* +** +** Function BTA_HfClientClose +** +** Description Close the current connection to an audio gateway. +** Any current audio connection will also be closed +** +** +** Returns void +** +*******************************************************************************/ +void BTA_HfClientClose(UINT16 handle); + +/******************************************************************************* +** +** Function BTA_HfCllientAudioOpen +** +** Description Opens an audio connection to the currently connected +** audio gateway +** +** +** Returns void +** +*******************************************************************************/ +void BTA_HfClientAudioOpen(UINT16 handle); + +/******************************************************************************* +** +** Function BTA_HfClientAudioClose +** +** Description Close the currently active audio connection to an audio +** gateway. The data connection remains open +** +** +** Returns void +** +*******************************************************************************/ +void BTA_HfClientAudioClose(UINT16 handle); + +/******************************************************************************* +** +** Function BTA_HfClientSendAT +** +** Description send AT command +** +** +** Returns void +** +*******************************************************************************/ +void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val1, UINT32 val2, const char *str); + +#if (BTM_SCO_HCI_INCLUDED == TRUE ) +/******************************************************************************* +** +** Function BTA_HfClientPktStatsNumsGet +** +** Description Get the Number of packets status received and send +** +** +** Returns void +** +*******************************************************************************/ +void BTA_HfClientPktStatsNumsGet(UINT16 sync_conn_handle); + +void BTA_HfClientCiData(void); +#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */ + +int BTA_HfClientGetCbDataSize(tBTA_HF_CLIENT_EVT event); + +#ifdef __cplusplus +} +#endif +#endif /* #if (BTA_HF_INCLUDED == TRUE) */ +#endif /* BTA_HF_CLIENT_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_hf_client_co.h b/lib/bt/host/bluedroid/bta/include/bta/bta_hf_client_co.h new file mode 100644 index 00000000..42299723 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_hf_client_co.h @@ -0,0 +1,107 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + + +/****************************************************************************** + * + * This is the interface file for hf client call-out functions. + * + ******************************************************************************/ +#ifndef BTA_HF_CLIENT_CO_H +#define BTA_HF_CLIENT_CO_H + +#include "common/bt_target.h" +#include "bta/bta_hf_client_api.h" + +#if (BTA_HF_INCLUDED == TRUE) + +#if (BTM_SCO_HCI_INCLUDED == TRUE) +/******************************************************************************* +** +** Function bta_hf_client_co_audio_state +** +** Description This function is called by the HF CLIENT 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 +** codec - if WBS support is compiled in, codec to going to be used is provided +** and when in SCO_STATE_SETUP, BTM_I2SPCMConfig() must be called with +** the correct platform parameters. +** in the other states codec type should not be ignored +** +** Returns void +** +*******************************************************************************/ +void bta_hf_client_co_audio_state(UINT16 handle, UINT8 state, tBTA_HFP_PEER_CODEC codec); + + +/******************************************************************************* +** +** Function bta_hf_client_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. +** +*******************************************************************************/ +tBTA_HFP_SCO_ROUTE_TYPE bta_hf_client_sco_co_init(UINT32 rx_bw, UINT32 tx_bw, + tBTA_HFP_CODEC_INFO *p_codec_info, UINT8 app_id); + + +/******************************************************************************* +** +** Function bta_hf_client_sco_co_open +** +** Description This function is executed when a SCO connection is open. +** +** +** Returns void +** +*******************************************************************************/ +void bta_hf_client_sco_co_open(UINT16 handle, UINT8 air_mode, UINT8 inout_pkt_size, UINT16 event); + +/******************************************************************************* +** +** Function bta_hf_client_sco_co_close +** +** Description This function is called when a SCO connection is closed +** +** +** Returns void +** +*******************************************************************************/ +void bta_hf_client_sco_co_close(void); + +/******************************************************************************* +** +** Function bta_hf_client_sco_co_out_data +** +** Description This function is called to send SCO data over HCI. +** +** Returns number of bytes got from application +** +*******************************************************************************/ +uint32_t bta_hf_client_sco_co_out_data(UINT8 *p_buf); + +/******************************************************************************* +** +** Function bta_hf_client_sco_co_in_data +** +** Description This function is called to send incoming SCO data to application. +** +** Returns void +** +*******************************************************************************/ +extern void bta_hf_client_sco_co_in_data(BT_HDR *p_buf, tBTM_SCO_DATA_FLAG status); + +#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */ + +#endif /* #if (BTA_HF_INCLUDED == TRUE) */ +#endif /* BTA_HF_CLIENT_CO_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_hfp_defs.h b/lib/bt/host/bluedroid/bta/include/bta/bta_hfp_defs.h new file mode 100644 index 00000000..752b2be3 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_hfp_defs.h @@ -0,0 +1,39 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef __BTA_HFP_DEFS_H__ +#define __BTA_HFP_DEFS_H__ + +#include "stack/btm_api.h" + +#define BTA_HFP_CODEC_NONE BTM_SCO_CODEC_NONE +#define BTA_HFP_CODEC_CVSD BTM_SCO_CODEC_CVSD /* CVSD */ +#define BTA_HFP_CODEC_MSBC BTM_SCO_CODEC_MSBC /* mSBC */ + +typedef UINT16 tBTA_HFP_PEER_CODEC; + +#ifndef BTA_HFP_SCO_OUT_PKT_SIZE +#define BTA_HFP_SCO_OUT_PKT_SIZE BTM_SCO_DATA_SIZE_MAX +#endif + +#define BTA_HFP_SCO_CODEC_PCM 0 /* used for regular SCO */ +#define BTA_HFP_SCO_CODEC_SBC 1 /* used for WBS */ +typedef UINT8 tBTA_HFP_SCO_CODEC_TYPE; + +#define BTA_HFP_SCO_SAMP_RATE_8K 8000 +#define BTA_HFP_SCO_SAMP_RATE_16K 16000 + +/* SCO codec information */ +typedef struct { + tBTA_HFP_SCO_CODEC_TYPE codec_type; +} tBTA_HFP_CODEC_INFO; + +#define BTA_HFP_SCO_ROUTE_PCM BTM_SCO_ROUTE_PCM +#define BTA_HFP_SCO_ROUTE_HCI BTM_SCO_ROUTE_HCI + +typedef tBTM_SCO_ROUTE_TYPE tBTA_HFP_SCO_ROUTE_TYPE; + +#endif /* __BTA_HFP_DEFS_H__ */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_hh_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_hh_api.h new file mode 100644 index 00000000..88cd1926 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_hh_api.h @@ -0,0 +1,565 @@ +/****************************************************************************** + * + * Copyright (C) 2002-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +#ifndef BTA_HH_API_H +#define BTA_HH_API_H + +#include "bta/bta_api.h" +#include "stack/hidh_api.h" +#if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) + +#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) +#include "stack/gatt_api.h" +#endif + +/***************************************************************************** +** Constants and Type Definitions +*****************************************************************************/ +#ifndef BTA_HH_DEBUG +#define BTA_HH_DEBUG TRUE +#endif + +#ifndef BTA_HH_SSR_MAX_LATENCY_DEF +#define BTA_HH_SSR_MAX_LATENCY_DEF 800 /* 500 ms*/ +#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 */ +#define BTA_HH_GET_IDLE_EVT 8 /* BTA_HhGetIdle comes callback */ +#define BTA_HH_SET_IDLE_EVT 9 /* BTA_HhSetIdle finish callback */ +#define BTA_HH_GET_DSCP_EVT 10 /* Get report descriptor */ +#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_DATA_EVT 15 +#define BTA_HH_API_ERR_EVT 16 /* API error is caught */ +#define BTA_HH_UPDATE_SCPP_EVT 17 /* update scan paramter complete */ +#define BTA_HH_DATA_IND_EVT 18 /* Data on interrupt channel */ + +typedef UINT16 tBTA_HH_EVT; + +/* application ID(none-zero) for each type of device */ +#define BTA_HH_APP_ID_MI 1 +#define BTA_HH_APP_ID_KB 2 +#define BTA_HH_APP_ID_RMC 3 +#define BTA_HH_APP_ID_3DSG 4 +#define BTA_HH_APP_ID_JOY 5 +#define BTA_HH_APP_ID_GPAD 6 +#define BTA_HH_APP_ID_LE 0xff + +/* defined the minimum offset */ +#define BTA_HH_MIN_OFFSET L2CAP_MIN_OFFSET+1 + +/* HID_HOST_MAX_DEVICES can not exceed 15 for th design of BTA HH */ +#define BTA_HH_IDX_INVALID 0xff +#define BTA_HH_MAX_KNOWN HID_HOST_MAX_DEVICES + +#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) +/* GATT_MAX_PHY_CHANNEL can not exceed 14 for the design of BTA HH */ +#define BTA_HH_LE_MAX_KNOWN GATT_MAX_PHY_CHANNEL +#define BTA_HH_MAX_DEVICE (HID_HOST_MAX_DEVICES + GATT_MAX_PHY_CHANNEL) +#else +#define BTA_HH_MAX_DEVICE HID_HOST_MAX_DEVICES +#endif +/* 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, /* connection handle error */ + BTA_HH_ERR_SEC, /* encryption error */ +}; +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; + +#define BTA_HH_SSR_PARAM_INVALID HID_SSR_PARAM_INVALID + +/* id DI is not existing in remote device, vendor_id in tBTA_HH_DEV_DSCP_INFO will be set to 0xffff */ +#define BTA_HH_VENDOR_ID_INVALID 0xffff + + +/* 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, BTA_HH_SSR_PARAM_INVALID if unknown */ + UINT16 ssr_min_tout; /* SSR min timeout, BTA_HH_SSR_PARAM_INVALID if unknown */ + UINT8 ctry_code; /*Country Code.*/ +#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) +#define BTA_HH_LE_REMOTE_WAKE 0x01 +#define BTA_HH_LE_NORMAL_CONN 0x02 + + UINT8 flag; +#endif + 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 */ + BOOLEAN is_orig; /* indicate if host initiate connection */ +#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) + BOOLEAN le_hid; /* is LE devices? */ + BOOLEAN scps_supported; /* scan parameter service supported */ +#endif + +} 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; + + +/* upper layer send data */ +typedef struct { + tBTA_HH_STATUS status; /* handshake status */ + UINT8 handle; /* device handle */ + UINT8 reason; /* send data failed reason */ +} tBTA_HH_API_SENDDATA; + +/* interrupt channel data */ +typedef struct { + tBTA_HH_STATUS status; /* handshake status */ + UINT8 handle; /* device handle */ + tBTA_HH_PROTO_MODE proto_mode; /* protocol mode */ + BT_HDR *p_data; /* DATA_EVT : feature report data */ +} tBTA_HH_INTDATA; + +/* 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 + BTA_HH_UPDATE_SCPP_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_API_SENDDATA send_data; /* BTA_HH_DATA_EVT */ + tBTA_HH_INTDATA int_data; /* BTA_HH_DATA_IND_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 +** +*******************************************************************************/ +extern void BTA_HhEnable(tBTA_SEC sec_mask, tBTA_HH_CBACK *p_cback); + +/******************************************************************************* +** +** Function BTA_HhDeregister +** +** Description This function is called when the host is about power down. +** +** Returns void +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_HhClose(UINT8 dev_handle); + +/******************************************************************************* +** +** Function BTA_HhSetProtoMode +** +** Description This function set the protocol mode at specified HID handle +** +** Returns void +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_HhGetProtoMode(UINT8 dev_handle); +/******************************************************************************* +** +** Function BTA_HhSetReport +** +** Description send SET_REPORT to device. +** +** Returns void +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_HhGetReport(UINT8 dev_handle, tBTA_HH_RPT_TYPE r_type, + UINT8 rpt_id, UINT16 buf_size); +/******************************************************************************* +** +** Function BTA_HhSetIdle +** +** Description send SET_IDLE to device. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_HhSetIdle(UINT8 dev_handle, UINT16 idle_rate); + +/******************************************************************************* +** +** Function BTA_HhGetIdle +** +** Description Send a GET_IDLE to HID device. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_HhGetIdle(UINT8 dev_handle); + +/******************************************************************************* +** +** Function BTA_HhSendCtrl +** +** Description Send HID_CONTROL request to a HID device. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_HhSendCtrl(UINT8 dev_handle, + tBTA_HH_TRANS_CTRL_TYPE c_type); + +/******************************************************************************* +** +** Function BTA_HhSetIdle +** +** Description send SET_IDLE to device. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_HhSetIdle(UINT8 dev_handle, UINT16 idle_rate); + + +/******************************************************************************* +** +** Function BTA_HhGetIdle +** +** Description Send a GET_IDLE from HID device. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_HhGetIdle(UINT8 dev_handle); + +/******************************************************************************* +** +** Function BTA_HhSendData +** +** Description Send DATA transaction to a HID device. +** +** Returns void +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +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 +** +*******************************************************************************/ +extern void BTA_HhRemoveDev(UINT8 dev_handle ); + +/******************************************************************************* +** +** Parsing Utility Functions +** +*******************************************************************************/ +/******************************************************************************* +** +** Function BTA_HhParseBootRpt +** +** Description This utility function parse a boot mode report. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_HhParseBootRpt(tBTA_HH_BOOT_RPT *p_data, UINT8 *p_report, + UINT16 report_len); + +#if BTA_HH_LE_INCLUDED == TRUE +/******************************************************************************* +** +** Function BTA_HhUpdateLeScanParam +** +** Description Update the scan paramteters if connected to a LE hid device as +** report host. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_HhUpdateLeScanParam(UINT8 dev_handle, UINT16 scan_int, UINT16 scan_win); +#endif +/* test commands */ +extern void bta_hh_le_hid_read_rpt_clt_cfg(BD_ADDR bd_addr, UINT8 rpt_id); + + + +#ifdef __cplusplus +} +#endif + +#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) + + +#endif /* BTA_HH_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_hh_co.h b/lib/bt/host/bluedroid/bta/include/bta/bta_hh_co.h new file mode 100644 index 00000000..f0fef370 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_hh_co.h @@ -0,0 +1,132 @@ +/****************************************************************************** + * + * Copyright (C) 2005-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for hid host call-out functions. + * + ******************************************************************************/ +#ifndef BTA_HH_CO_H +#define BTA_HH_CO_H + +#include "bta/bta_hh_api.h" + +typedef struct { + UINT16 rpt_uuid; + UINT8 rpt_id; + tBTA_HH_RPT_TYPE rpt_type; + UINT8 inst_id; + UINT8 prop; +} tBTA_HH_RPT_CACHE_ENTRY; + +/******************************************************************************* +** +** Function bta_hh_co_data +** +** Description This callout function is executed by HH when data is received +** in interupt channel. +** +** +** Returns void. +** +*******************************************************************************/ +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. +** +*******************************************************************************/ +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. +** +*******************************************************************************/ +extern void bta_hh_co_close(UINT8 dev_handle, UINT8 app_id); + +#if (BLE_INCLUDED == TRUE && BTA_HH_LE_INCLUDED == TRUE) +/******************************************************************************* +** +** Function bta_hh_le_co_rpt_info +** +** Description This callout function is to convey the report information on +** a HOGP device to the application. Application can save this +** information in NV if device is bonded and load it back when +** stack reboot. +** +** Parameters remote_bda - remote device address +** p_entry - report entry pointer +** app_id - application id +** +** Returns void. +** +*******************************************************************************/ +extern void bta_hh_le_co_rpt_info(BD_ADDR remote_bda, + tBTA_HH_RPT_CACHE_ENTRY *p_entry, + UINT8 app_id); + +/******************************************************************************* +** +** Function bta_hh_le_co_cache_load +** +** Description This callout function is to request the application to load the +** cached HOGP report if there is any. When cache reading is completed, +** bta_hh_le_ci_cache_load() is called by the application. +** +** Parameters remote_bda - remote device address +** p_num_rpt: number of cached report +** app_id - application id +** +** Returns the acched report array +** +*******************************************************************************/ +extern tBTA_HH_RPT_CACHE_ENTRY *bta_hh_le_co_cache_load (BD_ADDR remote_bda, + UINT8 *p_num_rpt, + UINT8 app_id); + +/******************************************************************************* +** +** Function bta_hh_le_co_reset_rpt_cache +** +** Description This callout function is to reset the HOGP device cache. +** +** Parameters remote_bda - remote device address +** +** Returns none +** +*******************************************************************************/ +extern void bta_hh_le_co_reset_rpt_cache (BD_ADDR remote_bda, UINT8 app_id); + +#endif /* #if (BLE_INCLUDED == TRUE && BTA_HH_LE_INCLUDED == TRUE) */ +#endif /* BTA_HH_CO_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_jv_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_jv_api.h new file mode 100644 index 00000000..660ce5cf --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_jv_api.h @@ -0,0 +1,972 @@ +/****************************************************************************** + * + * Copyright (C) 2006-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the public interface file the BTA Java I/F + * + ******************************************************************************/ +#ifndef BTA_JV_API_H +#define BTA_JV_API_H + +#include "common/bt_target.h" +#include "stack/bt_types.h" +#include "bta/bta_api.h" +#include "stack/btm_api.h" +#include "stack/l2c_api.h" +#include "stack/rfcdefs.h" +#include "stack/sdp_api.h" + +#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE) +/***************************************************************************** +** Constants and data types +*****************************************************************************/ +/* status values */ +#define BTA_JV_SUCCESS 0 /* Successful operation. */ +#define BTA_JV_FAILURE 1 /* Generic failure. */ +#define BTA_JV_BUSY 2 /* Temporarily can not handle this request. */ +#define BTA_JV_NO_DATA 3 /* no data. */ +#define BTA_JV_NO_RESOURCE 4 /* No more set pm control block */ +#define BTA_JV_ALREADY_DONE 5 /* already done, repeat the operation */ + +typedef UINT8 tBTA_JV_STATUS; +#define BTA_JV_INTERNAL_ERR (-1) /* internal error. */ + +#define BTA_JV_MAX_UUIDS SDP_MAX_UUID_FILTERS +#define BTA_JV_MAX_ATTRS SDP_MAX_ATTR_FILTERS +#define BTA_JV_MAX_SDP_REC SDP_MAX_RECORDS +#define BTA_JV_MAX_L2C_CONN GAP_MAX_CONNECTIONS /* GAP handle is used as index, hence do not change this value */ +#define BTA_JV_MAX_SCN PORT_MAX_RFC_PORTS /* same as BTM_MAX_SCN (in btm_int.h) */ +#define BTA_JV_MAX_RFC_CONN MAX_RFC_PORTS +#define BTA_JV_MAX_CREDIT_NUM PORT_RX_BUF_HIGH_WM + +#ifndef BTA_JV_DEF_RFC_MTU +#define BTA_JV_DEF_RFC_MTU (3*330) +#endif + +#ifndef BTA_JV_MAX_RFC_SR_SESSION +#define BTA_JV_MAX_RFC_SR_SESSION MAX_BD_CONNECTIONS +#endif + +/* BTA_JV_MAX_RFC_SR_SESSION can not be bigger than MAX_BD_CONNECTIONS */ +#if (BTA_JV_MAX_RFC_SR_SESSION > MAX_BD_CONNECTIONS) +#undef BTA_JV_MAX_RFC_SR_SESSION +#define BTA_JV_MAX_RFC_SR_SESSION MAX_BD_CONNECTIONS +#endif + +#define BTA_JV_FIRST_SERVICE_ID BTA_FIRST_JV_SERVICE_ID +#define BTA_JV_LAST_SERVICE_ID BTA_LAST_JV_SERVICE_ID +#define BTA_JV_NUM_SERVICE_ID (BTA_LAST_JV_SERVICE_ID - BTA_FIRST_JV_SERVICE_ID + 1) + +/* Discoverable modes */ +enum { + BTA_JV_DISC_NONE, + BTA_JV_DISC_LIMITED, + BTA_JV_DISC_GENERAL +}; +typedef UINT16 tBTA_JV_DISC; + +#define BTA_JV_ROLE_SLAVE BTM_ROLE_SLAVE +#define BTA_JV_ROLE_MASTER BTM_ROLE_MASTER +typedef UINT32 tBTA_JV_ROLE; + +#define BTA_JV_SERVICE_LMTD_DISCOVER BTM_COD_SERVICE_LMTD_DISCOVER /* 0x0020 */ +#define BTA_JV_SERVICE_POSITIONING BTM_COD_SERVICE_POSITIONING /* 0x0100 */ +#define BTA_JV_SERVICE_NETWORKING BTM_COD_SERVICE_NETWORKING /* 0x0200 */ +#define BTA_JV_SERVICE_RENDERING BTM_COD_SERVICE_RENDERING /* 0x0400 */ +#define BTA_JV_SERVICE_CAPTURING BTM_COD_SERVICE_CAPTURING /* 0x0800 */ +#define BTA_JV_SERVICE_OBJ_TRANSFER BTM_COD_SERVICE_OBJ_TRANSFER /* 0x1000 */ +#define BTA_JV_SERVICE_AUDIO BTM_COD_SERVICE_AUDIO /* 0x2000 */ +#define BTA_JV_SERVICE_TELEPHONY BTM_COD_SERVICE_TELEPHONY /* 0x4000 */ +#define BTA_JV_SERVICE_INFORMATION BTM_COD_SERVICE_INFORMATION /* 0x8000 */ + +/* JV ID type */ +#define BTA_JV_PM_ID_1 1 /* PM example profile 1 */ +#define BTA_JV_PM_ID_2 2 /* PM example profile 2 */ +#define BTA_JV_PM_ID_CLEAR 0 /* Special JV ID used to clear PM profile */ +#define BTA_JV_PM_ALL 0xFF /* Generic match all id, see bta_dm_cfg.c */ +typedef UINT8 tBTA_JV_PM_ID; + +#define BTA_JV_PM_HANDLE_CLEAR 0xFF /* Special JV ID used to clear PM profile */ + +/* define maximum number of registered PM entities. should be in sync with bta pm! */ +#ifndef BTA_JV_PM_MAX_NUM +#define BTA_JV_PM_MAX_NUM 5 +#endif + +/* JV pm connection states */ +enum { + BTA_JV_CONN_OPEN = 0, /* Connection opened state */ + BTA_JV_CONN_CLOSE, /* Connection closed state */ + BTA_JV_APP_OPEN, /* JV Application opened state */ + BTA_JV_APP_CLOSE, /* JV Application closed state */ + BTA_JV_SCO_OPEN, /* SCO connection opened state */ + BTA_JV_SCO_CLOSE, /* SCO connection opened state */ + BTA_JV_CONN_IDLE, /* Connection idle state */ + BTA_JV_CONN_BUSY, /* Connection busy state */ + BTA_JV_MAX_CONN_STATE /* Max number of connection state */ +}; +typedef UINT8 tBTA_JV_CONN_STATE; + +/* JV Connection types */ +#define BTA_JV_CONN_TYPE_RFCOMM 0 +#define BTA_JV_CONN_TYPE_L2CAP 1 +#define BTA_JV_CONN_TYPE_L2CAP_LE 2 + +/* Java I/F callback events */ +/* events received by tBTA_JV_DM_CBACK */ +#define BTA_JV_ENABLE_EVT 0 /* JV enabled */ +#define BTA_JV_DISABLE_EVT 1 /* JV disabled */ +#define BTA_JV_GET_SCN_EVT 6 /* Reserved an SCN */ +#define BTA_JV_GET_PSM_EVT 7 /* Reserved a PSM */ +#define BTA_JV_DISCOVERY_COMP_EVT 8 /* SDP discovery complete */ +#define BTA_JV_CREATE_RECORD_EVT 11 /* the result for BTA_JvCreateRecord */ + +/* events received by tBTA_JV_L2CAP_CBACK */ +#if BTA_JV_L2CAP_INCLUDED +#define BTA_JV_L2CAP_OPEN_EVT 16 /* open status of L2CAP connection */ +#define BTA_JV_L2CAP_CLOSE_EVT 17 /* L2CAP connection closed */ +#define BTA_JV_L2CAP_START_EVT 18 /* L2CAP server started */ +#define BTA_JV_L2CAP_CL_INIT_EVT 19 /* L2CAP client initiated a connection */ +#define BTA_JV_L2CAP_DATA_IND_EVT 20 /* L2CAP connection received data */ +#define BTA_JV_L2CAP_CONG_EVT 21 /* L2CAP connection congestion status changed */ +#define BTA_JV_L2CAP_READ_EVT 22 /* the result for BTA_JvL2capRead */ +#define BTA_JV_L2CAP_RECEIVE_EVT 23 /* the result for BTA_JvL2capReceive*/ +#define BTA_JV_L2CAP_WRITE_EVT 24 /* the result for BTA_JvL2capWrite*/ +#define BTA_JV_L2CAP_WRITE_FIXED_EVT 25 /* the result for BTA_JvL2capWriteFixed */ +#endif /* BTA_JV_L2CAP_INCLUDED */ + +/* events received by tBTA_JV_RFCOMM_CBACK */ +#if BTA_JV_RFCOMM_INCLUDED +#define BTA_JV_RFCOMM_OPEN_EVT 26 /* open status of RFCOMM Client connection */ +#define BTA_JV_RFCOMM_CLOSE_EVT 27 /* RFCOMM connection closed */ +#define BTA_JV_RFCOMM_START_EVT 28 /* RFCOMM server started */ +#define BTA_JV_RFCOMM_CL_INIT_EVT 29 /* RFCOMM client initiated a connection */ +#define BTA_JV_RFCOMM_DATA_IND_EVT 30 /* RFCOMM connection received data */ +#define BTA_JV_RFCOMM_CONG_EVT 31 /* RFCOMM connection congestion status changed */ +#define BTA_JV_RFCOMM_READ_EVT 32 /* the result for BTA_JvRfcommRead */ +#define BTA_JV_RFCOMM_WRITE_EVT 33 /* the result for BTA_JvRfcommWrite*/ +#define BTA_JV_RFCOMM_SRV_OPEN_EVT 34 /* open status of Server RFCOMM connection */ +#endif /* BTA_JV_RFCOMM_INCLUDED */ +#define BTA_JV_FREE_SCN_EVT 35 /* FREE an SCN */ +#define BTA_JV_MAX_EVT 36 /* max number of JV events */ + +typedef UINT16 tBTA_JV_EVT; + +/* data associated with BTA_JV_SET_DISCOVER_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + tBTA_JV_DISC disc_mode; /* The current discoverable mode */ +} tBTA_JV_SET_DISCOVER; + +/* data associated with BTA_JV_DISCOVERY_COMP_EVT_ */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT8 scn_num; /* num of channel */ + UINT8 scn[BTA_JV_MAX_SCN]; /* channel # */ + const char *service_name[BTA_JV_MAX_SCN]; /* service_name */ +} tBTA_JV_DISCOVERY_COMP; + +/* data associated with BTA_JV_CREATE_RECORD_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The SDP handle */ +} tBTA_JV_CREATE_RECORD; + +#if BTA_JV_L2CAP_INCLUDED +/* data associated with BTA_JV_L2CAP_OPEN_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + BD_ADDR rem_bda; /* The peer address */ + INT32 tx_mtu; /* The transmit MTU */ +} tBTA_JV_L2CAP_OPEN; + +/* data associated with BTA_JV_L2CAP_CLOSE_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + BOOLEAN async; /* FALSE, if local initiates disconnect */ + void * user_data; /* piggyback caller's private data */ +} tBTA_JV_L2CAP_CLOSE; + +/* data associated with BTA_JV_L2CAP_START_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + UINT8 sec_id; /* security ID used by this server */ +} tBTA_JV_L2CAP_START; + +/* data associated with BTA_JV_L2CAP_CL_INIT_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + UINT8 sec_id; /* security ID used by this client */ +} tBTA_JV_L2CAP_CL_INIT; + +/* data associated with BTA_JV_L2CAP_CONG_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + BOOLEAN cong; /* TRUE, congested. FALSE, uncongested */ +} tBTA_JV_L2CAP_CONG; + +/* data associated with BTA_JV_L2CAP_READ_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + UINT32 req_id; /* The req_id in the associated BTA_JvL2capRead() */ + UINT8 *p_data; /* This points the same location as the p_data + * parameter in BTA_JvL2capRead () */ + UINT16 len; /* The length of the data read. */ +} tBTA_JV_L2CAP_READ; + +/* data associated with BTA_JV_L2CAP_RECEIVE_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + UINT32 req_id; /* The req_id in the associated BTA_JvL2capReceive() */ + UINT8 *p_data; /* This points the same location as the p_data + * parameter in BTA_JvL2capReceive () */ + UINT16 len; /* The length of the data read. */ +} tBTA_JV_L2CAP_RECEIVE; + +/* data associated with BTA_JV_L2CAP_WRITE_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + UINT32 req_id; /* The req_id in the associated BTA_JvL2capWrite() */ + UINT16 len; /* The length of the data written. */ + BOOLEAN cong; /* congestion status */ +} tBTA_JV_L2CAP_WRITE; + +/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + BD_ADDR rem_bda; /* The peer address */ + INT32 tx_mtu; /* The transmit MTU */ + void **p_p_cback; /* set them for new socket */ + void **p_user_data;/* set them for new socket */ + +} tBTA_JV_L2CAP_LE_OPEN; + +/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */ +typedef struct { + UINT32 handle; /* The connection handle */ + BT_HDR *p_buf; /* The incoming data */ +} tBTA_JV_LE_DATA_IND; + +/* data associated with BTA_JV_L2CAP_WRITE_FIXED_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT16 channel; /* The connection channel */ + BD_ADDR addr; /* The peer address */ + UINT32 req_id; /* The req_id in the associated BTA_JvL2capWrite() */ + UINT16 len; /* The length of the data written. */ + BOOLEAN cong; /* congestion status */ +} tBTA_JV_L2CAP_WRITE_FIXED; +#endif /* BTA_JV_L2CAP_INCLUDED */ + +#if BTA_JV_RFCOMM_INCLUDED +/* data associated with BTA_JV_RFCOMM_OPEN_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT16 peer_mtu; /* Max MTU that port can send */ + UINT32 handle; /* The connection handle */ + BD_ADDR rem_bda; /* The peer address */ +} tBTA_JV_RFCOMM_OPEN; + +/* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT16 peer_mtu; /* Max MTU that port can send */ + UINT32 handle; /* The connection handle */ + UINT32 new_listen_handle; /* The new listen handle */ + BD_ADDR rem_bda; /* The peer address */ +} tBTA_JV_RFCOMM_SRV_OPEN; + +/* data associated with BTA_JV_RFCOMM_CLOSE_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 port_status; /* PORT status */ + UINT32 handle; /* The connection handle */ + BOOLEAN async; /* FALSE, if local initiates disconnect */ + void * user_data; /* piggyback caller's private data */ +} tBTA_JV_RFCOMM_CLOSE; + +/* data associated with BTA_JV_RFCOMM_START_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + UINT8 sec_id; /* security ID used by this server */ + UINT8 scn; /* Server channe number */ + BOOLEAN use_co; /* TRUE to use co_rfc_data */ +} tBTA_JV_RFCOMM_START; + +/* data associated with BTA_JV_RFCOMM_CL_INIT_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + UINT8 sec_id; /* security ID used by this client */ + BOOLEAN use_co; /* TRUE to use co_rfc_data */ +} tBTA_JV_RFCOMM_CL_INIT; + +/* data associated with BTA_JV_RFCOMM_CONG_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + BOOLEAN cong; /* TRUE, congested. FALSE, uncongested */ +} tBTA_JV_RFCOMM_CONG; + +/* data associated with BTA_JV_RFCOMM_READ_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + UINT32 req_id; /* The req_id in the associated BTA_JvRfcommRead() */ + UINT8 *p_data; /* This points the same location as the p_data + * parameter in BTA_JvRfcommRead () */ + UINT16 len; /* The length of the data read. */ +} tBTA_JV_RFCOMM_READ; + +/* data associated with BTA_JV_RFCOMM_WRITE_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + UINT32 req_id; /* The req_id in the associated BTA_JvRfcommWrite() */ + int len; /* The length of the data written. */ + BOOLEAN cong; /* congestion status */ + BOOLEAN old_cong; /* congestion status */ +} tBTA_JV_RFCOMM_WRITE; +#endif /* BTA_JV_RFCOMM_INCLUDED */ + +/*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */ +typedef struct { + UINT32 handle; /* The connection handle */ + BT_HDR *p_buf; /* The incoming data */ +} tBTA_JV_DATA_IND; + +/* data associated with BTA_JV_API_SET_PM_PROFILE_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Status of the operation */ + UINT32 handle; /* Connection handle */ + tBTA_JV_PM_ID app_id; /* JV app ID */ +} tBTA_JV_SET_PM_PROFILE; + +/* data associated with BTA_JV_API_NOTIFY_PM_STATE_CHANGE_EVT */ +typedef struct { + UINT32 handle; /* Connection handle */ + tBTA_JV_CONN_STATE state; /* JV connection stata */ +} tBTA_JV_NOTIFY_PM_STATE_CHANGE; + +/* indicate server at which status */ +typedef enum { + BTA_JV_SERVER_START_FAILED, + BTA_JV_SERVER_RUNNING, + BTA_JV_SERVER_STATUS_MAX, +} tBTA_JV_SERVER_STATUS; + +typedef struct { + tBTA_JV_SERVER_STATUS server_status; + UINT32 slot_id; +}tBTA_JV_FREE_SCN_USER_DATA; + +/* data associated with BTA_JV_FREE_SCN_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Status of the operation */ + tBTA_JV_SERVER_STATUS server_status; /* Server status */ + UINT8 scn; /* Server channe number */ +} tBTA_JV_FREE_SCN; + + +/* union of data associated with JV callback */ +typedef union { + tBTA_JV_STATUS status; /* BTA_JV_ENABLE_EVT */ + tBTA_JV_DISCOVERY_COMP disc_comp; /* BTA_JV_DISCOVERY_COMP_EVT */ + tBTA_JV_SET_DISCOVER set_discover; /* BTA_JV_SET_DISCOVER_EVT */ + UINT8 scn; /* BTA_JV_GET_SCN_EVT */ + UINT16 psm; /* BTA_JV_GET_PSM_EVT */ + tBTA_JV_CREATE_RECORD create_rec; /* BTA_JV_CREATE_RECORD_EVT */ +#if BTA_JV_L2CAP_INCLUDED + tBTA_JV_L2CAP_OPEN l2c_open; /* BTA_JV_L2CAP_OPEN_EVT */ + tBTA_JV_L2CAP_CLOSE l2c_close; /* BTA_JV_L2CAP_CLOSE_EVT */ + tBTA_JV_L2CAP_START l2c_start; /* BTA_JV_L2CAP_START_EVT */ + tBTA_JV_L2CAP_CL_INIT l2c_cl_init; /* BTA_JV_L2CAP_CL_INIT_EVT */ + tBTA_JV_L2CAP_CONG l2c_cong; /* BTA_JV_L2CAP_CONG_EVT */ + tBTA_JV_L2CAP_READ l2c_read; /* BTA_JV_L2CAP_READ_EVT */ + tBTA_JV_L2CAP_WRITE l2c_write; /* BTA_JV_L2CAP_WRITE_EVT */ +#endif /* BTA_JV_L2CAP_INCLUDED */ +#if BTA_JV_RFCOMM_INCLUDED + tBTA_JV_RFCOMM_OPEN rfc_open; /* BTA_JV_RFCOMM_OPEN_EVT */ + tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open; /* BTA_JV_RFCOMM_SRV_OPEN_EVT */ + tBTA_JV_RFCOMM_CLOSE rfc_close; /* BTA_JV_RFCOMM_CLOSE_EVT */ + tBTA_JV_RFCOMM_START rfc_start; /* BTA_JV_RFCOMM_START_EVT */ + tBTA_JV_RFCOMM_CL_INIT rfc_cl_init; /* BTA_JV_RFCOMM_CL_INIT_EVT */ + tBTA_JV_RFCOMM_CONG rfc_cong; /* BTA_JV_RFCOMM_CONG_EVT */ + tBTA_JV_RFCOMM_READ rfc_read; /* BTA_JV_RFCOMM_READ_EVT */ + tBTA_JV_RFCOMM_WRITE rfc_write; /* BTA_JV_RFCOMM_WRITE_EVT */ +#endif /* BTA_JV_RFCOMM_INCLUDED */ + tBTA_JV_DATA_IND data_ind; /* BTA_JV_L2CAP_DATA_IND_EVT + BTA_JV_RFCOMM_DATA_IND_EVT */ + tBTA_JV_FREE_SCN free_scn; /* BTA_JV_FREE_SCN_EVT */ +#if BTA_JV_L2CAP_INCLUDED + tBTA_JV_L2CAP_LE_OPEN l2c_le_open; /* BTA_JV_L2CAP_OPEN_EVT */ + tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */ + tBTA_JV_L2CAP_WRITE_FIXED l2c_write_fixed; /* BTA_JV_L2CAP_WRITE_FIXED_EVT */ +#endif /* BTA_JV_L2CAP_INCLUDED */ +} tBTA_JV; + +/* JAVA DM Interface callback */ +typedef void (tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data); + +/* JAVA RFCOMM interface callback */ +typedef void *(tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data); + +#if BTA_JV_L2CAP_INCLUDED +/* JAVA L2CAP interface callback */ +typedef void *(tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_Data); +#endif /* BTA_JV_L2CAP_INCLUDED */ + +/* JV configuration structure */ +typedef struct { + UINT16 sdp_raw_size; /* The size of p_sdp_raw_data */ + UINT16 sdp_db_size; /* The size of p_sdp_db */ + UINT8 *p_sdp_raw_data; /* The data buffer to keep raw data */ + tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */ +} tBTA_JV_CFG; + +/******************************************************************************* +** +** Function BTA_JvEnable +** +** Description Enable the Java I/F service. When the enable +** operation is complete the callback function will be +** called with a BTA_JV_ENABLE_EVT. This function must +** be called before other functions in the JV API are +** called. +** +** Returns BTA_JV_SUCCESS if successful. +** BTA_JV_FAIL if internal failure. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback); + +/******************************************************************************* +** +** Function BTA_JvDisable +** +** Description Disable the Java I/F. When the enable +** operation is complete the callback function will be +** called with a BTA_JV_DISABLE_EVT. +** +** Returns void +** +*******************************************************************************/ +extern void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback); + +/******************************************************************************* +** +** Function BTA_JvFree +** +** Description Free JV configuration +** +** Returns void +** +*******************************************************************************/ +extern void BTA_JvFree(void); + +/******************************************************************************* +** +** Function BTA_JvIsEnable +** +** Description Get the JV registration status. +** +** Returns TRUE, if registered +** +*******************************************************************************/ +extern BOOLEAN BTA_JvIsEnable(void); + +/******************************************************************************* +** +** Function BTA_JvIsEncrypted +** +** Description This function checks if the link to peer device is encrypted +** +** Returns TRUE if encrypted. +** FALSE if not. +** +*******************************************************************************/ +extern BOOLEAN BTA_JvIsEncrypted(BD_ADDR bd_addr); + +/******************************************************************************* +** +** Function BTA_JvGetChannelId +** +** Description This function reserves a SCN/PSM for applications running +** over RFCOMM or L2CAP. It is primarily called by +** server profiles/applications to register their SCN/PSM into the +** SDP database. The SCN is reported by the tBTA_JV_DM_CBACK +** callback with a BTA_JV_GET_SCN_EVT. +** If the SCN/PSM reported is 0, that means all SCN resources are +** exhausted. +** The channel parameter can be used to request a specific +** channel. If the request on the specific channel fails, the +** SCN/PSM returned in the EVT will be 0 - no attempt to request +** a new channel will be made. set channel to <= 0 to automatically +** assign an channel ID. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data, + INT32 channel); + +/******************************************************************************* +** +** Function BTA_JvFreeChannel +** +** Description This function frees a SCN/PSM that was used +** by an application running over RFCOMM or L2CAP. +** Parameters +** channel The channel to free +** conn_type one of BTA_JV_CONN_TYPE_ +** p_cback tBTA_JV_RFCOMM_CBACK is called with BTA_JV_FREE_SCN_EVT when server frees a SCN/PSM +** user_data indicate the RFCOMM server status +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvStartDiscovery +** +** Description This function performs service discovery for the services +** provided by the given peer device. When the operation is +** complete the tBTA_JV_DM_CBACK callback function will be +** called with a BTA_JV_DISCOVERY_COMP_EVT. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, UINT16 num_uuid, + tSDP_UUID *p_uuid_list, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvCreateRecordByUser +** +** Description Create a service record in the local SDP database by user in +** tBTA_JV_DM_CBACK callback with a BTA_JV_CREATE_RECORD_EVT. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvCreateRecordByUser(const char *name, UINT32 channel, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvDeleteRecord +** +** Description Delete a service record in the local SDP database. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle); + +#if BTA_JV_L2CAP_INCLUDED +/******************************************************************************* +** +** Function BTA_JvL2capConnectLE +** +** Description Initiate a connection as an LE L2CAP client to the given BD +** Address. +** When the connection is initiated or failed to initiate, +** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT +** When the connection is established or failed, +** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role, + const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_chan, + UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, + BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvL2capConnect +** +** Description Initiate a connection as a L2CAP client to the given BD +** Address. +** When the connection is initiated or failed to initiate, +** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT +** When the connection is established or failed, +** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role, + const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_psm, + UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, + BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvL2capClose +** +** Description This function closes an L2CAP client connection +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capClose(UINT32 handle, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvL2capCloseLE +** +** Description This function closes an L2CAP client connection for Fixed Channels +** Function is idempotent and no callbacks are called! +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capCloseLE(UINT32 handle); + +/******************************************************************************* +** +** Function BTA_JvL2capStartServer +** +** Description This function starts an L2CAP server and listens for an L2CAP +** connection from a remote Bluetooth device. When the server +** is started successfully, tBTA_JV_L2CAP_CBACK is called with +** BTA_JV_L2CAP_START_EVT. When the connection is established, +** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, + const tL2CAP_ERTM_INFO *ertm_info, + UINT16 local_psm, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, + tBTA_JV_L2CAP_CBACK *p_cback, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvL2capStartServerLE +** +** Description This function starts an LE L2CAP server and listens for an L2CAP +** connection from a remote Bluetooth device on a fixed channel +** over an LE link. When the server +** is started successfully, tBTA_JV_L2CAP_CBACK is called with +** BTA_JV_L2CAP_START_EVT. When the connection is established, +** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capStartServerLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role, + const tL2CAP_ERTM_INFO *ertm_info, + UINT16 local_chan, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, + tBTA_JV_L2CAP_CBACK *p_cback, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvL2capStopServerLE +** +** Description This function stops the LE L2CAP server. If the server has an +** active connection, it would be closed. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capStopServerLE(UINT16 local_chan, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvL2capStopServerLE +** +** Description This function stops the LE L2CAP server. If the server has an +** active connection, it would be closed. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capStopServer(UINT16 local_psm, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvL2capRead +** +** Description This function reads data from an L2CAP connection +** When the operation is complete, tBTA_JV_L2CAP_CBACK is +** called with BTA_JV_L2CAP_READ_EVT. +** +** Returns Length of read data. +** +*******************************************************************************/ +extern int BTA_JvL2capRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len); + +/******************************************************************************* +** +** Function BTA_JvL2capReceive +** +** Description This function reads data from an L2CAP connection +** When the operation is complete, tBTA_JV_L2CAP_CBACK is +** called with BTA_JV_L2CAP_RECEIVE_EVT. +** If there are more data queued in L2CAP than len, the extra data will be discarded. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capReceive(UINT32 handle, UINT32 req_id, + UINT8 *p_data, UINT16 len); + +/******************************************************************************* +** +** Function BTA_JvL2capReady +** +** Description This function determined if there is data to read from +** an L2CAP connection +** +** Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size. +** BTA_JV_FAILURE, if error. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capReady(UINT32 handle, UINT32 *p_data_size); + +/******************************************************************************* +** +** Function BTA_JvL2capWrite +** +** Description This function writes data to an L2CAP connection +** When the operation is complete, tBTA_JV_L2CAP_CBACK is +** called with BTA_JV_L2CAP_WRITE_EVT. Works for +** PSM-based connections +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id, + UINT8 *p_data, UINT16 len, void *user_data); + + +/******************************************************************************* +** +** Function BTA_JvL2capWriteFixed +** +** Description This function writes data to an L2CAP connection +** When the operation is complete, tBTA_JV_L2CAP_CBACK is +** called with BTA_JV_L2CAP_WRITE_FIXED_EVT. Works for +** fixed-channel connections +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id, + tBTA_JV_L2CAP_CBACK *p_cback, + UINT8 *p_data, UINT16 len, void *user_data); +#endif /* BTA_JV_L2CAP_INCLUDED */ + +#if BTA_JV_RFCOMM_INCLUDED +/******************************************************************************* +** +** Function BTA_JvRfcommConfig +** +** Description This function is to configure RFCOMM. +** +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvRfcommConfig(BOOLEAN enable_l2cap_ertm); + +/******************************************************************************* +** +** Function BTA_JvRfcommConnect +** +** Description This function makes an RFCOMM conection to a remote BD +** Address. +** When the connection is initiated or failed to initiate, +** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CL_INIT_EVT +** When the connection is established or failed, +** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_OPEN_EVT +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, + tBTA_JV_ROLE role, UINT8 remote_scn, BD_ADDR peer_bd_addr, + tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvRfcommClose +** +** Description This function closes an RFCOMM connection +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvRfcommStartServer +** +** Description This function starts listening for an RFCOMM connection +** request from a remote Bluetooth device. When the server is +** started successfully, tBTA_JV_RFCOMM_CBACK is called +** with BTA_JV_RFCOMM_START_EVT. +** When the connection is established, tBTA_JV_RFCOMM_CBACK +** is called with BTA_JV_RFCOMM_OPEN_EVT. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, + UINT8 local_scn, UINT8 max_session, + tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvRfcommStopServer +** +** Description This function stops the RFCOMM server. If the server has an +** active connection, it would be closed. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void *user_data); + +/******************************************************************************* +** +** Function BTA_JvRfcommRead +** +** Description This function reads data from an RFCOMM connection +** When the operation is complete, tBTA_JV_RFCOMM_CBACK is +** called with BTA_JV_RFCOMM_READ_EVT. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len); + +/******************************************************************************* +** +** Function BTA_JvRfcommReady +** +** Description This function determined if there is data to read from +** an RFCOMM connection +** +** Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size. +** BTA_JV_FAILURE, if error. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvRfcommReady(UINT32 handle, UINT32 *p_data_size); + +/******************************************************************************* +** +** Function BTA_JvRfcommWrite +** +** Description This function writes data to an RFCOMM connection +** When the operation is complete, tBTA_JV_RFCOMM_CBACK is +** called with BTA_JV_RFCOMM_WRITE_EVT. +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p_data); + +/******************************************************************************* +** +** Function BTA_JvRfcommFlowControl +** +** Description This function gives the credit to the peer +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvRfcommFlowControl(UINT32 handle, UINT16 credits_given); + +/******************************************************************************* +** +** Function BTA_JvRfcommGetPortHdl +** +** Description This function fetches the rfcomm port handle +** +** Returns BTA_JV_SUCCESS, if the request is being processed. +** BTA_JV_FAILURE, otherwise. +** +*******************************************************************************/ +UINT16 BTA_JvRfcommGetPortHdl(UINT32 handle); +#endif /* BTA_JV_RFCOMM_INCLUDED */ + +/******************************************************************************* + ** + ** Function BTA_JVSetPmProfile + ** + ** Description This function set or free power mode profile for different JV application + ** + ** Parameters: handle, JV handle from RFCOMM or L2CAP + ** app_id: app specific pm ID, can be BTA_JV_PM_ALL, see bta_dm_cfg.c for details + ** BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st is ignored and + ** BTA_JV_CONN_CLOSE is called implicitely + ** init_st: state after calling this API. typically it should be BTA_JV_CONN_OPEN + ** + ** Returns BTA_JV_SUCCESS, if the request is being processed. + ** BTA_JV_FAILURE, otherwise. + ** + ** NOTE: BTA_JV_PM_ID_CLEAR: In general no need to be called as jv pm calls automatically + ** BTA_JV_CONN_CLOSE to remove in case of connection close! + ** + *******************************************************************************/ +extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_STATE init_st); + +#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE +#endif /* BTA_JV_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_jv_co.h b/lib/bt/host/bluedroid/bta/include/bta/bta_jv_co.h new file mode 100644 index 00000000..b37625cf --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_jv_co.h @@ -0,0 +1,55 @@ +/****************************************************************************** + * + * Copyright (C) 2007-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the interface file for java interface call-out functions. + * + ******************************************************************************/ +#ifndef BTA_JV_CO_H +#define BTA_JV_CO_H + +#include "bta/bta_jv_api.h" + +#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE) +/***************************************************************************** +** Function Declarations +*****************************************************************************/ + + +/******************************************************************************* +** +** Function bta_jv_co_rfc_data +** +** Description This function is called by JV to send data to the java glue +** code when the RX data path is configured to use a call-out +** +** Returns void +** +*******************************************************************************/ + +extern int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf); +extern int bta_co_rfc_data_outgoing_size(void *user_data, int *size); +extern int bta_co_rfc_data_outgoing(void *user_data, UINT8 *buf, UINT16 size); + +extern int bta_co_l2cap_data_incoming(void *user_data, BT_HDR *p_buf); +extern int bta_co_l2cap_data_outgoing_size(void *user_data, int *size); +extern int bta_co_l2cap_data_outgoing(void *user_data, UINT8 *buf, UINT16 size); + +#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE +#endif /* BTA_DG_CO_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_sdp_api.h b/lib/bt/host/bluedroid/bta/include/bta/bta_sdp_api.h new file mode 100644 index 00000000..62b5228a --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_sdp_api.h @@ -0,0 +1,168 @@ +/****************************************************************************** + * + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the public interface file for the BTA SDP I/F + * + ******************************************************************************/ +#ifndef BTA_SDP_API_H +#define BTA_SDP_API_H + +#include "bt_sdp.h" +#include "common/bt_target.h" +#include "stack/bt_types.h" +#include "bta/bta_api.h" +#include "stack/btm_api.h" + +#if (SDP_INCLUDED == TRUE) +/* status values */ +#define BTA_SDP_SUCCESS 0 /* Successful operation. */ +#define BTA_SDP_FAILURE 1 /* Generic failure. */ +#define BTA_SDP_BUSY 2 /* Temporarily can not handle this request. */ + +typedef UINT8 tBTA_SDP_STATUS; + +/* SDP I/F callback events */ +/* events received by tBTA_SDP_DM_CBACK */ +#define BTA_SDP_ENABLE_EVT 0 /* SDP service enabled */ +#define BTA_SDP_DISENABLE_EVT 1 /* SDP service disenabled */ +#define BTA_SDP_SEARCH_EVT 2 /* SDP search started */ +#define BTA_SDP_SEARCH_COMP_EVT 3 /* SDP search complete */ +#define BTA_SDP_CREATE_RECORD_USER_EVT 4 /* SDP create record complete */ +#define BTA_SDP_REMOVE_RECORD_USER_EVT 5 /* SDP remove record complete */ +#define BTA_SDP_MAX_EVT 6 /* max number of SDP events */ + +#define BTA_SDP_MAX_RECORDS 15 + +typedef UINT16 tBTA_SDP_EVT; + +/* data associated with BTA_SDP_DISCOVERY_COMP_EVT */ +typedef struct { + tBTA_SDP_STATUS status; + BD_ADDR remote_addr; + tBT_UUID uuid; + int record_count; + bluetooth_sdp_record records[BTA_SDP_MAX_RECORDS]; +} tBTA_SDP_SEARCH_COMP; + +/* data associated with BTA_SDP_CREATE_RECORD_USER_EVT */ +typedef struct { + tBTA_SDP_STATUS status; + int handle; +} tBTA_SDP_CREATE_RECORD_USER; + +typedef union { + tBTA_SDP_STATUS status; /* BTA_SDP_SEARCH_EVT */ + tBTA_SDP_SEARCH_COMP sdp_search_comp; /* BTA_SDP_SEARCH_COMP_EVT */ + tBTA_SDP_CREATE_RECORD_USER sdp_create_record; /* BTA_SDP_CREATE_RECORD_USER_EVT */ +} tBTA_SDP; + +/* SDP DM Interface callback */ +typedef void (tBTA_SDP_DM_CBACK)(tBTA_SDP_EVT event, tBTA_SDP *p_data, void *user_data); + +/* MCE configuration structure */ +typedef struct { + UINT16 sdp_db_size; /* The size of p_sdp_db */ +#if (SDP_INCLUDED == TRUE) + tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */ +#endif ///SDP_INCLUDED == TRUE +} tBTA_SDP_CFG; + +#ifdef __cplusplus +extern "C" +{ +#endif +/******************************************************************************* +** +** Function BTA_SdpEnable +** +** Description Enable the SDP I/F service. When the enable +** operation is complete the callback function will be +** called with a BTA_SDP_ENABLE_EVT. This function must +** be called before other functions in the MCE API are +** called. +** +** Returns BTA_SDP_SUCCESS if successful. +** BTA_SDP_FAIL if internal failure. +** +*******************************************************************************/ +extern tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback); + +/******************************************************************************* +** +** Function BTA_SdpDisable +** +** Description Disable the SDP search I/F service. +** Free buffer for SDP configuration structure. +** +** Returns BTA_SDP_SUCCESS if successful. +** BTA_SDP_FAIL if internal failure. +** +*******************************************************************************/ +extern tBTA_SDP_STATUS BTA_SdpDisable(void); + +/******************************************************************************* +** +** Function BTA_SdpSearch +** +** Description Start a search for sdp records for a specific BD_ADDR with a +** specific profile uuid. +** When the search operation is completed, the callback function +** will be called with a BTA_SDP_SEARCH_EVT. +** Returns BTA_SDP_SUCCESS if successful. +** BTA_SDP_FAIL if internal failure. +** +*******************************************************************************/ +extern tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid); + +/******************************************************************************* +** +** Function BTA_SdpCreateRecordByUser +** +** Description This function is used to request a callback to create a SDP +** record. The registered callback will be called with event +** BTA_SDP_CREATE_RECORD_USER_EVT. +** +** Returns BTA_SDP_SUCCESS, if the request is being processed. +** BTA_SDP_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void *user_data); + +/******************************************************************************* +** +** Function BTA_SdpRemoveRecordByUser +** +** Description This function is used to request a callback to remove a SDP +** record. The registered callback will be called with event +** BTA_SDP_REMOVE_RECORD_USER_EVT. +** +** Returns BTA_SDP_SUCCESS, if the request is being processed. +** BTA_SDP_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data); + +#ifdef __cplusplus +} +#endif + +#endif ///SDP_INCLUDED == TRUE + +#endif /* BTA_SDP_API_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/bta_sys.h b/lib/bt/host/bluedroid/bta/include/bta/bta_sys.h new file mode 100644 index 00000000..54376de6 --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/bta_sys.h @@ -0,0 +1,292 @@ +/****************************************************************************** + * + * Copyright (C) 2003-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the public interface file for the BTA system manager. + * + ******************************************************************************/ +#ifndef BTA_SYS_H +#define BTA_SYS_H + +#include "common/bt_target.h" +#include "common/bt_defs.h" + +/***************************************************************************** +** Constants and data types +*****************************************************************************/ + +/* vendor specific event handler function type */ +typedef BOOLEAN (tBTA_SYS_VS_EVT_HDLR)(UINT16 evt, void *p); + +/* event handler function type */ +typedef BOOLEAN (tBTA_SYS_EVT_HDLR)(BT_HDR *p_msg); + +/* disable function type */ +typedef void (tBTA_SYS_DISABLE)(void); + + +/* HW modules */ +enum { + BTA_SYS_HW_BLUETOOTH, + BTA_SYS_HW_RT, + + BTA_SYS_MAX_HW_MODULES +}; + +typedef UINT16 tBTA_SYS_HW_MODULE; + +#ifndef BTA_DM_NUM_JV_ID +#define BTA_DM_NUM_JV_ID 2 +#endif + +/* SW sub-systems */ +#define BTA_ID_SYS 0 /* system manager */ +/* BLUETOOTH PART - from 0 to BTA_ID_BLUETOOTH_MAX */ +#define BTA_ID_DM 1 /* device manager */ +#define BTA_ID_DM_SEARCH 2 /* device manager search */ +#define BTA_ID_DM_SEC 3 /* device manager security */ +#define BTA_ID_DG 4 /* data gateway */ +#define BTA_ID_AG 5 /* audio gateway */ +#define BTA_ID_OPC 6 /* object push client */ +#define BTA_ID_OPS 7 /* object push server */ +#define BTA_ID_FTS 8 /* file transfer server */ +#define BTA_ID_CT 9 /* cordless telephony terminal */ +#define BTA_ID_FTC 10 /* file transfer client */ +#define BTA_ID_SS 11 /* synchronization server */ +#define BTA_ID_PR 12 /* Printer client */ +#define BTA_ID_BIC 13 /* Basic Imaging Client */ +#define BTA_ID_PAN 14 /* Personal Area Networking */ +#define BTA_ID_BIS 15 /* Basic Imaging Server */ +#define BTA_ID_ACC 16 /* Advanced Camera Client */ +#define BTA_ID_SC 17 /* SIM Card Access server */ +#define BTA_ID_AV 18 /* Advanced audio/video */ +#define BTA_ID_AVK 19 /* Audio/video sink */ +#define BTA_ID_HD 20 /* HID Device */ +#define BTA_ID_CG 21 /* Cordless Gateway */ +#define BTA_ID_BP 22 /* Basic Printing Client */ +#define BTA_ID_HH 23 /* Human Interface Device Host */ +#define BTA_ID_PBS 24 /* Phone Book Access Server */ +#define BTA_ID_PBC 25 /* Phone Book Access Client */ +#define BTA_ID_JV 26 /* Java */ +#define BTA_ID_HS 27 /* Headset */ +#define BTA_ID_MSE 28 /* Message Server Equipment */ +#define BTA_ID_MCE 29 /* Message Client Equipment */ +#define BTA_ID_HL 30 /* Health Device Profile*/ +#define BTA_ID_GATTC 31 /* GATT Client */ +#define BTA_ID_GATTS 32 /* GATT Client */ +#define BTA_ID_SDP 33 /* SDP Client */ +#define BTA_ID_BLUETOOTH_MAX 34 /* last BT profile */ + +/* GENERIC */ +#define BTA_ID_PRM 38 +#define BTA_ID_SYSTEM 39 /* platform-specific */ +#define BTA_ID_SWRAP 40 /* Insight script wrapper */ +#define BTA_ID_MIP 41 /* Multicase Individual Polling */ +#define BTA_ID_RT 42 /* Audio Routing module: This module is always on. */ + + +/* JV */ +#define BTA_ID_JV1 44 /* JV1 */ +#define BTA_ID_JV2 45 /* JV2 */ + +#define BTA_ID_MAX (44 + BTA_DM_NUM_JV_ID) + +typedef UINT8 tBTA_SYS_ID; + + +#define BTA_SYS_CONN_OPEN 0x00 +#define BTA_SYS_CONN_CLOSE 0x01 +#define BTA_SYS_APP_OPEN 0x02 +#define BTA_SYS_APP_CLOSE 0x03 +#define BTA_SYS_SCO_OPEN 0x04 +#define BTA_SYS_SCO_CLOSE 0x05 +#define BTA_SYS_CONN_IDLE 0x06 +#define BTA_SYS_CONN_BUSY 0x07 + +/* for link policy */ +#define BTA_SYS_PLCY_SET 0x10 /* set the link policy to the given addr */ +#define BTA_SYS_PLCY_CLR 0x11 /* clear the link policy to the given addr */ +#define BTA_SYS_PLCY_DEF_SET 0x12 /* set the default link policy */ +#define BTA_SYS_PLCY_DEF_CLR 0x13 /* clear the default link policy */ +#define BTA_SYS_ROLE_CHANGE 0x14 /* role change */ + +typedef UINT8 tBTA_SYS_CONN_STATUS; + +/* Bitmask of sys features */ +#define BTA_SYS_FEAT_PCM2 0x0001 +#define BTA_SYS_FEAT_PCM2_MASTER 0x0002 + +/* tBTA_PREF_ROLES */ +typedef UINT8 tBTA_SYS_PREF_ROLES; + +/* conn callback for role / low power manager*/ +typedef void (tBTA_SYS_CONN_CBACK)(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr); + +/* conn callback for role / low power manager*/ +typedef void (tBTA_SYS_SSR_CFG_CBACK)(UINT8 id, UINT8 app_id, UINT16 latency, UINT16 tout); + +#if (BTA_EIR_CANNED_UUID_LIST != TRUE) +/* eir callback for adding/removeing UUID */ +typedef void (tBTA_SYS_EIR_CBACK)(tBT_UUID uuid, BOOLEAN adding); +#endif + +/* registration structure */ +typedef struct { + tBTA_SYS_EVT_HDLR *evt_hdlr; + tBTA_SYS_DISABLE *disable; +} tBTA_SYS_REG; + +/* data type to send events to BTA SYS HW manager */ +typedef struct { + BT_HDR hdr; + tBTA_SYS_HW_MODULE hw_module; +} tBTA_SYS_HW_MSG; + +/***************************************************************************** +** Global data +*****************************************************************************/ + +/* trace level */ +extern UINT8 appl_trace_level; + +/***************************************************************************** +** Macros +*****************************************************************************/ + +/* Calculate start of event enumeration; id is top 8 bits of event */ +#define BTA_SYS_EVT_START(id) ((id) << 8) + +/***************************************************************************** +** events for BTA SYS HW manager +*****************************************************************************/ + +/* events sent to SYS HW manager - must be kept synchronized with tables in bta_sys_main.c */ +enum { + /* device manager local device API events */ + BTA_SYS_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_SYS), + BTA_SYS_EVT_ENABLED_EVT, + BTA_SYS_EVT_STACK_ENABLED_EVT, + BTA_SYS_API_DISABLE_EVT, + BTA_SYS_EVT_DISABLED_EVT, + BTA_SYS_ERROR_EVT, + + BTA_SYS_MAX_EVT +}; + + + +/* SYS HW status events - returned by SYS HW manager to other modules. */ +enum { + BTA_SYS_HW_OFF_EVT, + BTA_SYS_HW_ON_EVT, + BTA_SYS_HW_STARTING_EVT, + BTA_SYS_HW_STOPPING_EVT, + BTA_SYS_HW_ERROR_EVT + +}; +typedef UINT8 tBTA_SYS_HW_EVT; + +/* HW enable callback type */ +typedef void (tBTA_SYS_HW_CBACK)(tBTA_SYS_HW_EVT status); + +/***************************************************************************** +** Function declarations +*****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +extern void bta_sys_init(void); +extern void bta_sys_free(void); +extern void bta_sys_event(void * param); +extern void bta_sys_set_trace_level(UINT8 level); +extern void bta_sys_register(UINT8 id, const tBTA_SYS_REG *p_reg); +extern void bta_sys_deregister(UINT8 id); +extern BOOLEAN bta_sys_is_register(UINT8 id); +extern UINT16 bta_sys_get_sys_features(void); +extern void bta_sys_sendmsg(void *p_msg); +extern void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms); +extern void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle); +extern void bta_sys_free_timer(TIMER_LIST_ENT *p_tle); +extern BOOLEAN bta_sys_timer_is_active(TIMER_LIST_ENT *p_tle); +extern void bta_sys_disable(tBTA_SYS_HW_MODULE module); +extern UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle); + +extern void bta_sys_hw_register( tBTA_SYS_HW_MODULE module, tBTA_SYS_HW_CBACK *cback); +extern void bta_sys_hw_unregister( tBTA_SYS_HW_MODULE module ); + + +extern void bta_sys_rm_register(tBTA_SYS_CONN_CBACK *p_cback); +extern void bta_sys_pm_register(tBTA_SYS_CONN_CBACK *p_cback); + +extern void bta_sys_policy_register(tBTA_SYS_CONN_CBACK *p_cback); +extern void bta_sys_sco_register(tBTA_SYS_CONN_CBACK *p_cback); + + +extern void bta_sys_conn_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +extern void bta_sys_conn_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +extern void bta_sys_app_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +extern void bta_sys_app_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +extern void bta_sys_sco_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +extern void bta_sys_sco_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +extern void bta_sys_sco_use(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +extern void bta_sys_sco_unuse(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +extern void bta_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); +extern void bta_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); + +#if (BTM_SSR_INCLUDED == TRUE) +extern void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK *p_cback); +extern void bta_sys_chg_ssr_config (UINT8 id, UINT8 app_id, UINT16 max_latency, UINT16 min_tout); +#endif + +extern void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK *p_cback); +extern void bta_sys_notify_role_chg(BD_ADDR_PTR p_bda, UINT8 new_role, UINT8 hci_status); +extern void bta_sys_collision_register(UINT8 bta_id, tBTA_SYS_CONN_CBACK *p_cback); +extern void bta_sys_notify_collision (BD_ADDR_PTR p_bda); + +#if (BTA_EIR_CANNED_UUID_LIST != TRUE) +extern void bta_sys_eir_register(tBTA_SYS_EIR_CBACK *p_cback); +extern void bta_sys_add_uuid(UINT16 uuid); +extern void bta_sys_add_uuid_32(UINT32 uuid32); +extern void bta_sys_add_uuid_128(UINT8 *uuid128); +extern void bta_sys_remove_uuid(UINT16 uuid16); +extern void bta_sys_remove_uuid_32(UINT32 uuid32); +extern void bta_sys_remove_uuid_128(UINT8 *uuid128); +#else +#define bta_sys_eir_register(ut) +#define bta_sys_add_uuid(ut) +#define bta_sys_add_uuid_32(ut) +#define bta_sys_add_uuid_128(ut) +#define bta_sys_remove_uuid(ut) +#define bta_sys_remove_uuid_32(ut) +#define bta_sys_remove_uuid_128(ut) +#endif + +extern void bta_sys_set_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr); +extern void bta_sys_clear_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr); +extern void bta_sys_set_default_policy (UINT8 id, UINT8 policy); +extern void bta_sys_clear_default_policy (UINT8 id, UINT8 policy); +extern BOOLEAN bta_sys_vs_hdl(UINT16 evt, void *p); + +#ifdef __cplusplus +} +#endif + +#endif /* BTA_SYS_H */ diff --git a/lib/bt/host/bluedroid/bta/include/bta/utl.h b/lib/bt/host/bluedroid/bta/include/bta/utl.h new file mode 100644 index 00000000..a140832f --- /dev/null +++ b/lib/bt/host/bluedroid/bta/include/bta/utl.h @@ -0,0 +1,184 @@ +/****************************************************************************** + * + * Copyright (C) 2003-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Basic utility functions. + * + ******************************************************************************/ +#ifndef UTL_H +#define UTL_H + +#include "stack/bt_types.h" +// #include "bt_utils.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 osi_free 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_get_device_class +** +** Description This function get the local Device Class. +** +** Parameters: +** p_cod - Pointer to the device class to get to +** +** +** Returns TRUE if successful, Otherwise FALSE +** +*******************************************************************************/ +extern BOOLEAN utl_get_device_class(tBTA_UTL_COD *p_cod); + +/******************************************************************************* +** +** 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 */ -- cgit v1.2.3