Merge branch 'bugfix/hf_ag_report_event_with_null_bdaddr_v5.1' into 'release/v5.1'

Bugfix/fixed bugs of HFP in BlueDroid (v5.1)

See merge request espressif/esp-idf!25827
This commit is contained in:
Jiang Jiang Jian 2023-09-11 10:54:09 +08:00
commit 680a254b18
26 changed files with 725 additions and 155 deletions

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -512,10 +512,30 @@ esp_err_t esp_hf_ag_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_h
} }
#if (BTM_SCO_HCI_INCLUDED == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE)
esp_err_t esp_hf_ag_pkt_stat_nums_get(uint16_t sync_conn_handle)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HF;
msg.act = BTC_HF_REQUEST_PKT_STAT_EVT;
btc_hf_args_t arg;
memset(&arg, 0, sizeof(btc_hf_args_t));
arg.pkt_sync_hd.sync_conn_handle = sync_conn_handle;
/* Switch to BTC context */
bt_status_t status = btc_transfer_context(&msg, &arg, sizeof(btc_hf_args_t), NULL, NULL);
return (status == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
void esp_hf_ag_outgoing_data_ready(void) void esp_hf_ag_outgoing_data_ready(void)
{ {
btc_hf_ci_sco_data(); btc_hf_ci_sco_data();
} }
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */
#endif // BTC_HF_INCLUDED #endif // BTC_HF_INCLUDED

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -515,8 +515,27 @@ esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL; return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
} }
#if (BTM_SCO_HCI_INCLUDED == TRUE)
esp_err_t esp_hf_client_pkt_stat_nums_get(uint16_t sync_conn_handle)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HF_CLIENT;
msg.act = BTC_HF_CLIENT_REQUEST_PKT_STAT_EVT;
btc_hf_client_args_t arg;
memset(&arg, 0, sizeof(btc_hf_client_args_t));
arg.pkt_sync_hd.sync_conn_handle = sync_conn_handle;
/* Switch to BTC context */
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL, NULL);
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
#if (BTM_SCO_HCI_INCLUDED == TRUE )
void esp_hf_client_outgoing_data_ready(void) void esp_hf_client_outgoing_data_ready(void)
{ {
BTA_HfClientCiData(); BTA_HfClientCiData();
@ -537,6 +556,6 @@ int32_t esp_hf_client_pcm_resample(void *src, uint32_t in_bytes, void *dst)
return BTA_DmPcmResample(src, in_bytes, dst); return BTA_DmPcmResample(src, in_bytes, dst);
} }
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */
#endif /* BTC_HF_CLIENT_INCLUDED */ #endif /* BTC_HF_CLIENT_INCLUDED */

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -62,13 +62,22 @@ typedef enum
ESP_HF_DIAL_EVT, /*!< Origin an outgoing call with specific number or the dial the last number */ ESP_HF_DIAL_EVT, /*!< Origin an outgoing call with specific number or the dial the last number */
ESP_HF_WBS_RESPONSE_EVT, /*!< Codec Status */ ESP_HF_WBS_RESPONSE_EVT, /*!< Codec Status */
ESP_HF_BCS_RESPONSE_EVT, /*!< Final Codec Choice */ ESP_HF_BCS_RESPONSE_EVT, /*!< Final Codec Choice */
ESP_HF_PKT_STAT_NUMS_GET_EVT, /*!< Request number of packet different status */
} esp_hf_cb_event_t; } esp_hf_cb_event_t;
/// Dial type of ESP_HF_DIAL_EVT
typedef enum
{
ESP_HF_DIAL_MEM = 0, /*!< Dial with a memory position */
ESP_HF_DIAL_VOIP, /*!< Dial with VoIP */
ESP_HF_DIAL_NUM, /*!< Dial with a phone number */
} esp_hf_dial_type_t;
/// HFP AG callback parameters /// HFP AG callback parameters
typedef union typedef union
{ {
/** /**
* @brief ESP_HS_CONNECTION_STATE_EVT * @brief ESP_HF_CONNECTION_STATE_EVT
*/ */
struct hf_conn_stat_param { struct hf_conn_stat_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
@ -83,6 +92,7 @@ typedef union
struct hf_audio_stat_param { struct hf_audio_stat_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */ esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_audio_state_t state; /*!< Audio connection state */ esp_hf_audio_state_t state; /*!< Audio connection state */
uint16_t sync_conn_handle; /*!< (e)SCO connection handle */
} audio_stat; /*!< AG callback param of ESP_HF_AUDIO_STATE_EVT */ } audio_stat; /*!< AG callback param of ESP_HF_AUDIO_STATE_EVT */
/** /**
@ -97,6 +107,7 @@ typedef union
* @brief ESP_HF_VOLUME_CONTROL_EVT * @brief ESP_HF_VOLUME_CONTROL_EVT
*/ */
struct hf_volume_control_param { struct hf_volume_control_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_volume_type_t type; /*!< Volume control target, speaker or microphone */ esp_hf_volume_type_t type; /*!< Volume control target, speaker or microphone */
int volume; /*!< Gain, ranges from 0 to 15 */ int volume; /*!< Gain, ranges from 0 to 15 */
} volume_control; /*!< AG callback param of ESP_HF_VOLUME_CONTROL_EVT */ } volume_control; /*!< AG callback param of ESP_HF_VOLUME_CONTROL_EVT */
@ -105,48 +116,89 @@ typedef union
* @brief ESP_HF_UNAT_RESPONSE_EVT * @brief ESP_HF_UNAT_RESPONSE_EVT
*/ */
struct hf_unat_rep_param { struct hf_unat_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
char *unat; /*!< Unknown AT command string */ char *unat; /*!< Unknown AT command string */
}unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */ } unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */
/**
* @brief ESP_HF_CIND_RESPONSE_EVT
*/
struct hf_cind_param {
esp_hf_call_status_t call_status; /*!< call status indicator */
esp_hf_call_setup_status_t call_setup_status; /*!< call setup status indicator */
esp_hf_network_state_t svc; /*!< bluetooth proprietary call hold status indicator */
int signal_strength; /*!< bluetooth proprietary call hold status indicator */
esp_hf_roaming_status_t roam; /*!< bluetooth proprietary call hold status indicator */
int battery_level; /*!< battery charge value, ranges from 0 to 5 */
esp_hf_call_held_status_t call_held_status; /*!< bluetooth proprietary call hold status indicator */
} cind; /*!< AG callback param of ESP_HF_CIND_RESPONSE_EVT */
/** /**
* @brief ESP_HF_DIAL_EVT * @brief ESP_HF_DIAL_EVT
*/ */
struct hf_out_call_param { struct hf_out_call_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */ esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
esp_hf_dial_type_t type; /*!< dial type */
char *num_or_loc; /*!< location in phone memory */ char *num_or_loc; /*!< location in phone memory */
} out_call; /*!< AG callback param of ESP_HF_DIAL_EVT */ } out_call; /*!< AG callback param of ESP_HF_DIAL_EVT */
/**
* @brief ESP_HF_IND_UPDATE_EVT
*/
struct hf_ind_upd_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} ind_upd; /*!< AG callback param of ESP_HF_IND_UPDATE_EVT */
/**
* @brief ESP_HF_CIND_RESPONSE_EVT
*/
struct hf_cind_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} cind_rep; /*!< AG callback param of ESP_HF_CIND_RESPONSE_EVT */
/**
* @brief ESP_HF_COPS_RESPONSE_EVT
*/
struct hf_cops_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} cops_rep; /*!< AG callback param of ESP_HF_COPS_RESPONSE_EVT */
/**
* @brief ESP_HF_CLCC_RESPONSE_EVT
*/
struct hf_clcc_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} clcc_rep; /*!< AG callback param of ESP_HF_CLCC_RESPONSE_EVT */
/**
* @brief ESP_HF_CNUM_RESPONSE_EVT
*/
struct hf_cnum_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} cnum_rep; /*!< AG callback param of ESP_HF_CNUM_RESPONSE_EVT */
/** /**
* @brief ESP_HF_VTS_RESPONSE_EVT * @brief ESP_HF_VTS_RESPONSE_EVT
*/ */
struct hf_vts_rep_param { struct hf_vts_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
char *code; /*!< MTF code from HF Client */ char *code; /*!< MTF code from HF Client */
}vts_rep; /*!< AG callback param of ESP_HF_VTS_RESPONSE_EVT */ } vts_rep; /*!< AG callback param of ESP_HF_VTS_RESPONSE_EVT */
/** /**
* @brief ESP_HF_NREC_RESPONSE_EVT * @brief ESP_HF_NREC_RESPONSE_EVT
*/ */
struct hf_nrec_param { struct hf_nrec_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_nrec_t state; /*!< NREC enabled or disabled */ esp_hf_nrec_t state; /*!< NREC enabled or disabled */
} nrec; /*!< AG callback param of ESP_HF_NREC_RESPONSE_EVT */ } nrec; /*!< AG callback param of ESP_HF_NREC_RESPONSE_EVT */
/**
* @brief ESP_HF_ATA_RESPONSE_EVT
*/
struct hf_ata_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} ata_rep; /*!< AG callback param of ESP_HF_ATA_RESPONSE_EVT */
/**
* @brief ESP_HF_CHUP_RESPONSE_EVT
*/
struct hf_chup_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
} chup_rep; /*!< AG callback param of ESP_HF_CHUP_RESPONSE_EVT */
/** /**
* @brief ESP_HF_WBS_RESPONSE_EVT * @brief ESP_HF_WBS_RESPONSE_EVT
*/ */
struct hf_wbs_rep_param { struct hf_wbs_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_wbs_config_t codec; /*!< codec mode CVSD or mSBC */ esp_hf_wbs_config_t codec; /*!< codec mode CVSD or mSBC */
} wbs_rep; /*!< AG callback param of ESP_HF_WBS_RESPONSE_EVT */ } wbs_rep; /*!< AG callback param of ESP_HF_WBS_RESPONSE_EVT */
@ -154,9 +206,23 @@ typedef union
* @brief ESP_HF_BCS_RESPONSE_EVT * @brief ESP_HF_BCS_RESPONSE_EVT
*/ */
struct hf_bcs_rep_param { struct hf_bcs_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_wbs_config_t mode; /*!< codec mode CVSD or mSBC */ esp_hf_wbs_config_t mode; /*!< codec mode CVSD or mSBC */
} bcs_rep; /*!< AG callback param of ESP_HF_BCS_RESPONSE_EVT */ } bcs_rep; /*!< AG callback param of ESP_HF_BCS_RESPONSE_EVT */
/**
* @brief ESP_HF_PKT_STAT_NUMS_GET_EVT
*/
struct ag_pkt_status_nums {
uint32_t rx_total; /*!< the total number of packets received */
uint32_t rx_correct; /*!< the total number of packets data correctly received */
uint32_t rx_err; /*!< the total number of packets data with possible invalid */
uint32_t rx_none; /*!< the total number of packets data no received */
uint32_t rx_lost; /*!< the total number of packets data partially lost */
uint32_t tx_total; /*!< the total number of packets send */
uint32_t tx_discarded; /*!< the total number of packets send lost */
} pkt_nums; /*!< AG callback param of ESP_HF_PKT_STAT_NUMS_GET_EVT */
} esp_hf_cb_param_t; /*!< HFP AG callback param compound*/ } esp_hf_cb_param_t; /*!< HFP AG callback param compound*/
/** /**
@ -586,6 +652,22 @@ esp_err_t esp_hf_ag_end_call(esp_bd_addr_t remote_addr, int num_active, int num_
*/ */
esp_err_t esp_hf_ag_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_hf_outgoing_data_cb_t send); esp_err_t esp_hf_ag_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_hf_outgoing_data_cb_t send);
/**
*
* @brief Get the number of packets received and sent
*
* This function is only used in the case that Voice Over HCI is enabled and the audio state is connected.
* When the operation is completed, the callback function will be called with ESP_HF_PKT_STAT_NUMS_GET_EVT.
*
* @param[in] sync_conn_handle: the (e)SCO connection handle
*
* @return
* - ESP_OK: if the request is sent successfully
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_hf_ag_pkt_stat_nums_get(uint16_t sync_conn_handle);
/** /**
* @brief Trigger the lower-layer to fetch and send audio data. * @brief Trigger the lower-layer to fetch and send audio data.

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -96,6 +96,7 @@ typedef enum {
ESP_HF_CLIENT_BSIR_EVT, /*!< setting of in-band ring tone */ ESP_HF_CLIENT_BSIR_EVT, /*!< setting of in-band ring tone */
ESP_HF_CLIENT_BINP_EVT, /*!< requested number of last voice tag from AG */ ESP_HF_CLIENT_BINP_EVT, /*!< requested number of last voice tag from AG */
ESP_HF_CLIENT_RING_IND_EVT, /*!< ring indication event */ ESP_HF_CLIENT_RING_IND_EVT, /*!< ring indication event */
ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT, /*!< requested number of packet different status */
} esp_hf_client_cb_event_t; } esp_hf_client_cb_event_t;
/// HFP client callback parameters /// HFP client callback parameters
@ -116,6 +117,7 @@ typedef union {
struct hf_client_audio_stat_param { struct hf_client_audio_stat_param {
esp_hf_client_audio_state_t state; /*!< audio connection state */ esp_hf_client_audio_state_t state; /*!< audio connection state */
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */ esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
uint16_t sync_conn_handle; /*!< (e)SCO connection handle */
} audio_stat; /*!< HF callback param of ESP_HF_CLIENT_AUDIO_STATE_EVT */ } audio_stat; /*!< HF callback param of ESP_HF_CLIENT_AUDIO_STATE_EVT */
/** /**
@ -251,6 +253,19 @@ typedef union {
const char *number; /*!< phone number corresponding to the last voice tag in the HF */ const char *number; /*!< phone number corresponding to the last voice tag in the HF */
} binp; /*!< HF callback param of ESP_HF_CLIENT_BINP_EVT */ } binp; /*!< HF callback param of ESP_HF_CLIENT_BINP_EVT */
/**
* @brief ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT
*/
struct hf_client_pkt_status_nums {
uint32_t rx_total; /*!< the total number of packets received */
uint32_t rx_correct; /*!< the total number of packets data correctly received */
uint32_t rx_err; /*!< the total number of packets data with possible invalid */
uint32_t rx_none; /*!< the total number of packets data no received */
uint32_t rx_lost; /*!< the total number of packets data partially lost */
uint32_t tx_total; /*!< the total number of packets send */
uint32_t tx_discarded; /*!< the total number of packets send lost */
} pkt_nums; /*!< HF callback param of ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT */
} esp_hf_client_cb_param_t; /*!< HFP client callback parameters */ } esp_hf_client_cb_param_t; /*!< HFP client callback parameters */
/** /**
@ -508,7 +523,7 @@ esp_err_t esp_hf_client_answer_call(void);
/** /**
* *
* @brief Reject an incoming call(send AT+CHUP command). * @brief Reject an incoming call or terminate an ongoing call(send AT+CHUP command).
* As a precondition to use this API, Service Level Connection shall exist with AG. * As a precondition to use this API, Service Level Connection shall exist with AG.
* *
* @return * @return
@ -655,6 +670,22 @@ esp_err_t esp_hf_client_send_nrec(void);
esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t recv, esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t recv,
esp_hf_client_outgoing_data_cb_t send); esp_hf_client_outgoing_data_cb_t send);
/**
*
* @brief Get the number of packets received and sent
* This function is only used in the case that Voice Over HCI is enabled and the audio state is connected.
* When the operation is completed, the callback function will be called with ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT.
*
* @param[in] sync_conn_handle: the (e)SCO connection handle
*
* @return
* - ESP_OK: if the request is sent successfully
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*
*/
esp_err_t esp_hf_client_pkt_stat_nums_get(uint16_t sync_conn_handle);
/** /**
* @brief Trigger the lower-layer to fetch and send audio data. * @brief Trigger the lower-layer to fetch and send audio data.
* This function is only only used in the case that Voice Over HCI is enabled. After this * This function is only only used in the case that Voice Over HCI is enabled. After this

View File

@ -245,7 +245,6 @@ void BTA_AgAudioClose(UINT16 handle)
} }
} }
/******************************************************************************* /*******************************************************************************
** **
** Function BTA_AgResult ** Function BTA_AgResult
@ -297,7 +296,30 @@ void BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec)
} }
} }
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #if (BTM_SCO_HCI_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTA_AgPktStatsNumsGet
**
** Description Specify the sync_conn_handle to be used for the packet numbers
** received or send.
**
**
** Returns void
**
*******************************************************************************/
void BTA_AgPktStatsNumsGet(UINT16 handle, UINT16 sync_conn_handle)
{
tBTA_AG_PKT_STAT_GET *p_buf;
if ((p_buf = (tBTA_AG_PKT_STAT_GET *) osi_malloc(sizeof(tBTA_AG_PKT_STAT_GET))) != NULL) {
p_buf->hdr.event = BTA_AG_PKT_STAT_NUMS_GET_EVT;
p_buf->hdr.layer_specific = handle;
p_buf->sync_conn_handle = sync_conn_handle;
bta_sys_sendmsg(p_buf);
}
}
/************************************************************************************************ /************************************************************************************************
* Function BTA_AgCiData * Function BTA_AgCiData
* *
@ -317,6 +339,6 @@ void BTA_AgCiData(UINT16 handle)
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
} }
} }
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */
#endif /* #if (BTA_AG_INCLUDED == TRUE)*/ #endif /* #if (BTA_AG_INCLUDED == TRUE)*/

View File

@ -146,6 +146,14 @@ enum
BTA_AG_HF_CMD_BAC BTA_AG_HF_CMD_BAC
}; };
/* dialing type of BTA_AG_HF_CMD_D */
enum
{
BTA_AG_HF_DIAL_NUM = 0,
BTA_AG_HF_DIAL_VOIP,
BTA_AG_HF_DIAL_MEM,
};
/* HFP AT command interpreter table */ /* HFP AT command interpreter table */
const tBTA_AG_AT_CMD bta_ag_hfp_cmd[] = const tBTA_AG_AT_CMD bta_ag_hfp_cmd[] =
{ {
@ -856,6 +864,8 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
case BTA_AG_HF_CMD_D: case BTA_AG_HF_CMD_D:
{ {
UINT16 src = 0;
UINT16 dst = 0;
/* Do not send OK for Dial cmds Let application decide whether to send OK or ERROR*/ /* Do not send OK for Dial cmds Let application decide whether to send OK or ERROR*/
/* if mem dial cmd, make sure string contains only digits */ /* if mem dial cmd, make sure string contains only digits */
if(p_arg[0] == '>') { if(p_arg[0] == '>') {
@ -863,6 +873,8 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
event = 0; event = 0;
bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR); bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR);
} }
val.value = BTA_AG_HF_DIAL_MEM;
src = 1;
} else if (p_arg[0] == 'V') { } else if (p_arg[0] == 'V') {
/* ATDV : Dial VoIP Call */ /* ATDV : Dial VoIP Call */
/* We do not check string. Code will be added later if needed. */ /* We do not check string. Code will be added later if needed. */
@ -870,6 +882,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
event = 0; event = 0;
bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED); bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED);
} }
val.value = BTA_AG_HF_DIAL_VOIP;
} else { } else {
/* If dial cmd, make sure string contains only dial digits /* If dial cmd, make sure string contains only dial digits
** Dial digits are 0-9, A-C, *, #, + */ ** Dial digits are 0-9, A-C, *, #, + */
@ -877,6 +890,17 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
event = 0; event = 0;
bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR); bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR);
} }
val.value = BTA_AG_HF_DIAL_NUM;
}
if (event != 0) {
while ((val.str[dst] = p_arg[src]) != '\0') {
if (val.str[dst] == ';') {
val.str[dst] = '\0';
break;
}
src++;
dst++;
}
} }
break; break;
} }

View File

@ -91,6 +91,7 @@ enum
BTA_AG_CI_SCO_DATA, BTA_AG_CI_SCO_DATA,
BTA_AG_CI_RX_DATA, BTA_AG_CI_RX_DATA,
BTA_AG_RCVD_SLC_READY, BTA_AG_RCVD_SLC_READY,
BTA_AG_PKT_STAT_NUMS,
BTA_AG_NUM_ACTIONS BTA_AG_NUM_ACTIONS
}; };
@ -133,7 +134,8 @@ const tBTA_AG_ACTION bta_ag_action[] =
bta_ag_send_ring, bta_ag_send_ring,
bta_ag_ci_sco_data, bta_ag_ci_sco_data,
bta_ag_ci_rx_data, bta_ag_ci_rx_data,
bta_ag_rcvd_slc_ready bta_ag_rcvd_slc_ready,
bta_ag_pkt_stat_nums
}; };
/* state table information */ /* state table information */
@ -167,7 +169,8 @@ const UINT8 bta_ag_st_init[][BTA_AG_NUM_COLS] =
/* RING_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_INIT_ST}, /* RING_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_INIT_ST},
/* SVC_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_INIT_ST}, /* SVC_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_INIT_ST},
/* CI_SCO_DATA_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_INIT_ST}, /* CI_SCO_DATA_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_INIT_ST},
/* CI_SLC_READY_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_INIT_ST} /* CI_SLC_READY_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_INIT_ST},
/* PKT_STAT_NUMS_GET_EVT */ {BTA_AG_PKT_STAT_NUMS, BTA_AG_IGNORE, BTA_AG_INIT_ST}
}; };
/* state table for opening state */ /* state table for opening state */
@ -196,7 +199,8 @@ const UINT8 bta_ag_st_opening[][BTA_AG_NUM_COLS] =
/* RING_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_OPENING_ST}, /* RING_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_OPENING_ST},
/* SVC_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_OPENING_ST}, /* SVC_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_OPENING_ST},
/* CI_SCO_DATA_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_OPENING_ST}, /* CI_SCO_DATA_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_OPENING_ST},
/* CI_SLC_READY_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_OPENING_ST} /* CI_SLC_READY_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_OPENING_ST},
/* PKT_STAT_NUMS_GET_EVT */ {BTA_AG_PKT_STAT_NUMS, BTA_AG_IGNORE, BTA_AG_OPENING_ST}
}; };
/* state table for open state */ /* state table for open state */
@ -225,7 +229,8 @@ const UINT8 bta_ag_st_open[][BTA_AG_NUM_COLS] =
/* RING_TOUT_EVT */ {BTA_AG_SEND_RING, BTA_AG_IGNORE, BTA_AG_OPEN_ST}, /* RING_TOUT_EVT */ {BTA_AG_SEND_RING, BTA_AG_IGNORE, BTA_AG_OPEN_ST},
/* SVC_TOUT_EVT */ {BTA_AG_START_CLOSE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST}, /* SVC_TOUT_EVT */ {BTA_AG_START_CLOSE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST},
/* CI_SCO_DATA_EVT */ {BTA_AG_CI_SCO_DATA, BTA_AG_IGNORE, BTA_AG_OPEN_ST}, /* CI_SCO_DATA_EVT */ {BTA_AG_CI_SCO_DATA, BTA_AG_IGNORE, BTA_AG_OPEN_ST},
/* CI_SLC_READY_EVT */ {BTA_AG_RCVD_SLC_READY, BTA_AG_IGNORE, BTA_AG_OPEN_ST} /* CI_SLC_READY_EVT */ {BTA_AG_RCVD_SLC_READY, BTA_AG_IGNORE, BTA_AG_OPEN_ST},
/* PKT_STAT_NUMS_GET_EVT */ {BTA_AG_PKT_STAT_NUMS, BTA_AG_IGNORE, BTA_AG_OPEN_ST}
}; };
/* state table for closing state */ /* state table for closing state */
@ -254,7 +259,8 @@ const UINT8 bta_ag_st_closing[][BTA_AG_NUM_COLS] =
/* RING_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST}, /* RING_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST},
/* SVC_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST}, /* SVC_TOUT_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST},
/* CI_SCO_DATA_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST}, /* CI_SCO_DATA_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST},
/* CI_SLC_READY_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST} /* CI_SLC_READY_EVT */ {BTA_AG_IGNORE, BTA_AG_IGNORE, BTA_AG_CLOSING_ST},
/* PKT_STAT_NUMS_GET_EVT */ {BTA_AG_PKT_STAT_NUMS, BTA_AG_IGNORE, BTA_AG_CLOSING_ST}
}; };
/* type for state table */ /* type for state table */
@ -357,6 +363,8 @@ static char *bta_ag_evt_str(UINT16 event, tBTA_AG_RES result)
return "SCO data Callin"; return "SCO data Callin";
case BTA_AG_CI_SLC_READY_EVT: case BTA_AG_CI_SLC_READY_EVT:
return "SLC Ready Callin"; return "SLC Ready Callin";
case BTA_AG_PKT_STAT_NUMS_GET_EVT:
return "Get Packet Nums";
default: default:
return "Unknown AG Event"; return "Unknown AG Event";
} }

View File

@ -342,7 +342,7 @@ static void bta_ag_sco_read_cback(UINT16 sco_inx, BT_HDR *p_data, tBTM_SCO_DATA_
{ {
if (status != BTM_SCO_DATA_CORRECT) if (status != BTM_SCO_DATA_CORRECT)
{ {
APPL_TRACE_WARNING("bta_ag_sco_read_cback: status(%d)", status); APPL_TRACE_DEBUG("bta_ag_sco_read_cback: status(%d)", status);
} }
/* Callout function must free the data. */ /* Callout function must free the data. */
@ -475,6 +475,7 @@ static void bta_ag_cback_sco(tBTA_AG_SCB *p_scb, UINT8 event)
sco.handle = bta_ag_scb_to_idx(p_scb); sco.handle = bta_ag_scb_to_idx(p_scb);
sco.app_id = p_scb->app_id; sco.app_id = p_scb->app_id;
sco.sync_conn_handle = BTM_ReadScoHandle(p_scb->sco_idx);
/* call close cback */ /* call close cback */
(*bta_ag_cb.p_cback)(event, (tBTA_AG *) &sco); (*bta_ag_cb.p_cback)(event, (tBTA_AG *) &sco);
@ -1477,6 +1478,32 @@ void bta_ag_sco_codec_nego(tBTA_AG_SCB *p_scb, BOOLEAN result)
} }
#endif #endif
/*******************************************************************************
**
** Function bta_ag_pkt_stat_nums
**
** Description Get the number of packet states
**
**
** Returns void
**
*******************************************************************************/
void bta_ag_pkt_stat_nums(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
{
UNUSED(p_scb);
#if (BTM_SCO_HCI_INCLUDED == TRUE)
tBTA_AG_PKT_STAT_NUMS pkt_stat_nums;
uint16_t sync_conn_handle = p_data->pkt_stat.sync_conn_handle;
BTM_PktStatNumsGet(sync_conn_handle, (tBTM_SCO_PKT_STAT_NUMS *) &pkt_stat_nums);
/* call app cback */
if (bta_ag_cb.p_cback) {
(*bta_ag_cb.p_cback)(BTA_AG_PKT_NUMS_GET_EVT, (tBTA_AG*) &pkt_stat_nums);
}
#endif
}
/******************************************************************************* /*******************************************************************************
** **
** Function bta_ag_sco_shutdown ** Function bta_ag_sco_shutdown

View File

@ -114,6 +114,7 @@ enum
BTA_AG_SVC_TOUT_EVT, BTA_AG_SVC_TOUT_EVT,
BTA_AG_CI_SCO_DATA_EVT, BTA_AG_CI_SCO_DATA_EVT,
BTA_AG_CI_SLC_READY_EVT, BTA_AG_CI_SLC_READY_EVT,
BTA_AG_PKT_STAT_NUMS_GET_EVT,
BTA_AG_MAX_EVT, BTA_AG_MAX_EVT,
/* these events are handled outside of the state machine */ /* these events are handled outside of the state machine */
@ -219,6 +220,13 @@ typedef struct
char p_data[BTA_AG_MTU+1]; char p_data[BTA_AG_MTU+1];
} tBTA_AG_CI_RX_WRITE; } tBTA_AG_CI_RX_WRITE;
/* data type for BTA_AG_PKT_STAT_NUMS_GET_EVT */
typedef struct
{
BT_HDR hdr;
UINT16 sync_conn_handle;
} tBTA_AG_PKT_STAT_GET;
/* union of all event datatypes */ /* union of all event datatypes */
typedef union typedef union
{ {
@ -233,6 +241,7 @@ typedef union
tBTA_AG_DISC_RESULT disc_result; tBTA_AG_DISC_RESULT disc_result;
tBTA_AG_RFC rfc; tBTA_AG_RFC rfc;
tBTA_AG_CI_RX_WRITE ci_rx_write; tBTA_AG_CI_RX_WRITE ci_rx_write;
tBTA_AG_PKT_STAT_GET pkt_stat;
} tBTA_AG_DATA; } tBTA_AG_DATA;
/* type for each profile */ /* type for each profile */
@ -277,7 +286,7 @@ typedef struct
tBTA_AG_SCO_MSBC_SETTINGS codec_msbc_settings; /* settings to be used for the impending eSCO */ tBTA_AG_SCO_MSBC_SETTINGS codec_msbc_settings; /* settings to be used for the impending eSCO */
TIMER_LIST_ENT cn_timer; /* codec negotiation timer */ TIMER_LIST_ENT cn_timer; /* codec negotiation timer */
#endif #endif
UINT16 sco_idx; /* SCO handle */ UINT16 sco_idx; /* SCO connection index */
BOOLEAN in_use; /* scb in use */ BOOLEAN in_use; /* scb in use */
BOOLEAN dealloc; /* TRUE if service shutting down */ BOOLEAN dealloc; /* TRUE if service shutting down */
BOOLEAN clip_enabled; /* set to TRUE if HF enables CLIP reporting */ BOOLEAN clip_enabled; /* set to TRUE if HF enables CLIP reporting */
@ -438,6 +447,7 @@ extern void bta_ag_ci_sco_data(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data);
extern void bta_ag_set_esco_param(BOOLEAN set_reset, tBTM_ESCO_PARAMS *param); extern void bta_ag_set_esco_param(BOOLEAN set_reset, tBTM_ESCO_PARAMS *param);
extern void bta_ag_ci_rx_data(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data); extern void bta_ag_ci_rx_data(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data);
extern void bta_ag_rcvd_slc_ready(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data); extern void bta_ag_rcvd_slc_ready(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data);
extern void bta_ag_pkt_stat_nums(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data);
#endif /* #if (BTA_AG_INCLUDED == TRUE) */ #endif /* #if (BTA_AG_INCLUDED == TRUE) */

View File

@ -299,7 +299,28 @@ void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
} }
} }
#if (BTM_SCO_HCI_INCLUDED == TRUE )
#if (BTM_SCO_HCI_INCLUDED == TRUE)
/*******************************************************************************
**
** Function BTA_HfClientPktStatsNumsGet
**
** Description Get the packet ststus numbers received and send for a specific (e)SCO connection handle.
**
**
** Returns void
**
*******************************************************************************/
void BTA_HfClientPktStatsNumsGet(UINT16 sync_conn_handle)
{
tBTA_HF_CLIENT_PKT_STAT_GET *p_buf;
if ((p_buf = (tBTA_HF_CLIENT_PKT_STAT_GET *) osi_malloc(sizeof(tBTA_HF_CLIENT_PKT_STAT_GET))) != NULL) {
p_buf->hdr.event = BTA_HF_CLIENT_PKT_NUMS_GET_EVT;
p_buf->sync_conn_handle = sync_conn_handle;
bta_sys_sendmsg(p_buf);
}
}
void BTA_HfClientCiData(void) void BTA_HfClientCiData(void)
{ {
BT_HDR *p_buf; BT_HDR *p_buf;

View File

@ -75,6 +75,7 @@ enum {
BTA_HF_CLIENT_SEND_AT_CMD, BTA_HF_CLIENT_SEND_AT_CMD,
#if (BTM_SCO_HCI_INCLUDED == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE)
BTA_HF_CLIENT_CI_SCO_DATA, BTA_HF_CLIENT_CI_SCO_DATA,
BTA_HF_CLIENT_PKT_STAT_NUMS,
#endif #endif
BTA_HF_CLIENT_NUM_ACTIONS, BTA_HF_CLIENT_NUM_ACTIONS,
}; };
@ -111,8 +112,9 @@ const tBTA_HF_CLIENT_ACTION bta_hf_client_action[] = {
/* BTA_HF_CLIENT_DISC_ACP_RES */ bta_hf_client_disc_acp_res, /* BTA_HF_CLIENT_DISC_ACP_RES */ bta_hf_client_disc_acp_res,
/* BTA_HF_CLIENT_SVC_CONN_OPEN */ bta_hf_client_svc_conn_open, /* BTA_HF_CLIENT_SVC_CONN_OPEN */ bta_hf_client_svc_conn_open,
/* BTA_HF_CLIENT_SEND_AT_CMD */ bta_hf_client_send_at_cmd, /* BTA_HF_CLIENT_SEND_AT_CMD */ bta_hf_client_send_at_cmd,
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #if (BTM_SCO_HCI_INCLUDED == TRUE)
/* BTA_HF_CLIENT_CI_SCO_DATA */ bta_hf_client_ci_sco_data, /* BTA_HF_CLIENT_CI_SCO_DATA */ bta_hf_client_ci_sco_data,
/* BTA_HF_CLIENT_PKT_STAT_NUMS */ bta_hf_client_pkt_stat_nums,
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
}; };
@ -143,6 +145,7 @@ const UINT8 bta_hf_client_st_init[][BTA_HF_CLIENT_NUM_COLS] = {
/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST}, /* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #if (BTM_SCO_HCI_INCLUDED == TRUE )
/* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST}, /* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
/* PKT_STAT_NUMS_GET_EVT */ {BTA_HF_CLIENT_PKT_STAT_NUMS, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
}; };
@ -166,8 +169,9 @@ const UINT8 bta_hf_client_st_opening[][BTA_HF_CLIENT_NUM_COLS] = {
/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST}, /* SCO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST}, /* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST}, /* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #if (BTM_SCO_HCI_INCLUDED == TRUE)
/* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST}, /* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
/* PKT_STAT_NUMS_GET_EVT */ {BTA_HF_CLIENT_PKT_STAT_NUMS, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
}; };
@ -193,6 +197,7 @@ const UINT8 bta_hf_client_st_open[][BTA_HF_CLIENT_NUM_COLS] = {
/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_SEND_AT_CMD, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST}, /* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_SEND_AT_CMD, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #if (BTM_SCO_HCI_INCLUDED == TRUE )
/* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_CI_SCO_DATA, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST}, /* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_CI_SCO_DATA, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
/* PKT_STAT_NUMS_GET_EVT */ {BTA_HF_CLIENT_PKT_STAT_NUMS, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
}; };
@ -218,6 +223,7 @@ const UINT8 bta_hf_client_st_closing[][BTA_HF_CLIENT_NUM_COLS] = {
/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST}, /* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #if (BTM_SCO_HCI_INCLUDED == TRUE )
/* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST}, /* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
/* PKT_STAT_NUMS_GET_EVT */ {BTA_HF_CLIENT_PKT_STAT_NUMS, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
}; };
@ -640,6 +646,7 @@ static char *bta_hf_client_evt_str(UINT16 event)
CASE_RETURN_STR(BTA_HF_CLIENT_SCO_OPEN_EVT) CASE_RETURN_STR(BTA_HF_CLIENT_SCO_OPEN_EVT)
CASE_RETURN_STR(BTA_HF_CLIENT_SCO_CLOSE_EVT) CASE_RETURN_STR(BTA_HF_CLIENT_SCO_CLOSE_EVT)
CASE_RETURN_STR(BTA_HF_CLIENT_SEND_AT_CMD_EVT) CASE_RETURN_STR(BTA_HF_CLIENT_SEND_AT_CMD_EVT)
CASE_RETURN_STR(BTA_HF_CLIENT_PKT_NUMS_GET_EVT)
default: default:
return "Unknown HF Client Event"; return "Unknown HF Client Event";
} }

View File

@ -155,6 +155,7 @@ void bta_hf_client_cback_sco(UINT8 event)
tBTA_HF_CLIENT_HDR evt; tBTA_HF_CLIENT_HDR evt;
memset(&evt, 0, sizeof(evt)); memset(&evt, 0, sizeof(evt));
evt.sync_conn_handle = BTM_ReadScoHandle(bta_hf_client_cb.scb.sco_idx);
/* call app cback */ /* call app cback */
(*bta_hf_client_cb.p_cback)(event, (tBTA_HF_CLIENT_HDR *) &evt); (*bta_hf_client_cb.p_cback)(event, (tBTA_HF_CLIENT_HDR *) &evt);
@ -237,7 +238,29 @@ static void bta_hf_client_sco_conn_rsp(tBTM_ESCO_CONN_REQ_EVT_DATA *p_data)
BTM_EScoConnRsp(p_data->sco_inx, hci_status, &resp); BTM_EScoConnRsp(p_data->sco_inx, hci_status, &resp);
} }
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #if (BTM_SCO_HCI_INCLUDED == TRUE)
/*******************************************************************************
**
** Function bta_hf_client_pkt_stat_nums
**
** Description Get the packet status number
**
**
** Returns void
**
*******************************************************************************/
void bta_hf_client_pkt_stat_nums(tBTA_HF_CLIENT_DATA *p_data)
{
tBTA_SCO_PKT_STAT_NUMS pkt_stat_nums;
uint16_t sync_conn_handle = p_data->pkt_stat.sync_conn_handle;
BTM_PktStatNumsGet(sync_conn_handle, (tBTM_SCO_PKT_STAT_NUMS *) &pkt_stat_nums);
/* call app cback */
if (bta_hf_client_cb.p_cback) {
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT, (void*) &pkt_stat_nums);
}
}
/******************************************************************************* /*******************************************************************************
** **
** Function bta_hf_client_ci_sco_data ** Function bta_hf_client_ci_sco_data
@ -254,6 +277,7 @@ void bta_hf_client_ci_sco_data(tBTA_HF_CLIENT_DATA *p_data)
bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_CI_DATA_E); bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_CI_DATA_E);
} }
#endif #endif
/******************************************************************************* /*******************************************************************************
** **
** Function bta_hf_client_sco_connreq_cback ** Function bta_hf_client_sco_connreq_cback

View File

@ -65,6 +65,7 @@ enum {
BTA_HF_CLIENT_SEND_AT_CMD_EVT, BTA_HF_CLIENT_SEND_AT_CMD_EVT,
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #if (BTM_SCO_HCI_INCLUDED == TRUE )
BTA_HF_CLIENT_CI_SCO_DATA_EVT, BTA_HF_CLIENT_CI_SCO_DATA_EVT,
BTA_HF_CLIENT_PKT_NUMS_GET_EVT,
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
BTA_HF_CLIENT_MAX_EVT, BTA_HF_CLIENT_MAX_EVT,
@ -121,6 +122,12 @@ typedef struct {
char str[BTA_HF_CLIENT_MAX_LEN + 1]; char str[BTA_HF_CLIENT_MAX_LEN + 1];
} tBTA_HF_CLIENT_DATA_VAL; } tBTA_HF_CLIENT_DATA_VAL;
/* data type for BTA_HF_CLIENT_PKT_NUMS_GET_EVT */
typedef struct {
BT_HDR hdr;
UINT16 sync_conn_handle;
} tBTA_HF_CLIENT_PKT_STAT_GET;
/* union of all event datatypes */ /* union of all event datatypes */
typedef union { typedef union {
BT_HDR hdr; BT_HDR hdr;
@ -130,6 +137,7 @@ typedef union {
tBTA_HF_CLIENT_DISC_RESULT disc_result; tBTA_HF_CLIENT_DISC_RESULT disc_result;
tBTA_HF_CLIENT_RFC rfc; tBTA_HF_CLIENT_RFC rfc;
tBTA_HF_CLIENT_DATA_VAL val; tBTA_HF_CLIENT_DATA_VAL val;
tBTA_HF_CLIENT_PKT_STAT_GET pkt_stat;
} tBTA_HF_CLIENT_DATA; } tBTA_HF_CLIENT_DATA;
@ -302,6 +310,7 @@ extern void bta_hf_client_binp(char *number);
extern void bta_hf_client_dial(tBTA_HF_CLIENT_DATA *p_data); extern void bta_hf_client_dial(tBTA_HF_CLIENT_DATA *p_data);
extern void bta_hf_client_send_at_cmd(tBTA_HF_CLIENT_DATA *p_data); extern void bta_hf_client_send_at_cmd(tBTA_HF_CLIENT_DATA *p_data);
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #if (BTM_SCO_HCI_INCLUDED == TRUE )
extern void bta_hf_client_pkt_stat_nums(tBTA_HF_CLIENT_DATA *p_data);
extern void bta_hf_client_ci_sco_data(tBTA_HF_CLIENT_DATA *p_data); extern void bta_hf_client_ci_sco_data(tBTA_HF_CLIENT_DATA *p_data);
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
#endif /* #if (BTA_HF_INCLUDED == TRUE) */ #endif /* #if (BTA_HF_INCLUDED == TRUE) */

View File

@ -158,6 +158,8 @@ typedef UINT8 tBTA_AG_RES;
#endif #endif
#define BTA_AG_AUDIO_MSBC_OPEN_EVT 32 /* Audio connection with mSBC codec open */ #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 */ /* Values below are for HFP only */
#define BTA_AG_AT_A_EVT 10 /* Answer a incoming call */ #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_D_EVT 11 /* Place a call using number or memory dial */
@ -261,15 +263,15 @@ typedef UINT8 tBTA_AG_BTRH_TYPE;
#endif #endif
/* indicator constants HFP 1.1 and later */ /* indicator constants HFP 1.1 and later */
#define BTA_AG_IND_CALL 0 /* position of call indicator */ #define BTA_AG_IND_CALL 1 /* position of call indicator */
#define BTA_AG_IND_CALLSETUP 1 /* position of callsetup indicator */ #define BTA_AG_IND_CALLSETUP 2 /* position of callsetup indicator */
#define BTA_AG_IND_SERVICE 2 /* position of service indicator */ #define BTA_AG_IND_SERVICE 3 /* position of service indicator */
/* indicator constants HFP 1.5 and later */ /* indicator constants HFP 1.5 and later */
#define BTA_AG_IND_SIGNAL 3 /* position of signal strength indicator */ #define BTA_AG_IND_SIGNAL 4 /* position of signal strength indicator */
#define BTA_AG_IND_ROAM 4 /* position of roaming indicator */ #define BTA_AG_IND_ROAM 5 /* position of roaming indicator */
#define BTA_AG_IND_BATTCHG 5 /* position of battery charge indicator */ #define BTA_AG_IND_BATTCHG 6 /* position of battery charge indicator */
#define BTA_AG_IND_CALLHELD 6 /* position of callheld indicator */ #define BTA_AG_IND_CALLHELD 7 /* position of callheld indicator */
#define BTA_AG_IND_BEARER 7 /* position of bearer indicator */ #define BTA_AG_IND_BEARER 8 /* position of bearer indicator */
typedef UINT16 tBTA_AG_IND_TYPE; typedef UINT16 tBTA_AG_IND_TYPE;
/* call indicator values */ /* call indicator values */
@ -327,6 +329,7 @@ typedef struct
UINT16 handle; UINT16 handle;
UINT8 app_id; UINT8 app_id;
tBTA_AG_STATUS status; tBTA_AG_STATUS status;
UINT16 sync_conn_handle;
} tBTA_AG_HDR; } tBTA_AG_HDR;
/* data associated with BTA_AG_REGISTER_EVT */ /* data associated with BTA_AG_REGISTER_EVT */
@ -405,6 +408,17 @@ typedef struct {
char number[BTA_AG_NUMBER_LEN + 1]; char number[BTA_AG_NUMBER_LEN + 1];
} tBTA_AG_CNUM; } 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 */ /* union of data associated with AG callback */
typedef union typedef union
{ {
@ -421,6 +435,7 @@ typedef union
tBTA_AG_AT_RESULT result; tBTA_AG_AT_RESULT result;
tBTA_AG_CLCC clcc; tBTA_AG_CLCC clcc;
tBTA_AG_CNUM cnum; tBTA_AG_CNUM cnum;
tBTA_AG_PKT_STAT_NUMS pkt_num;
} tBTA_AG; } tBTA_AG;
/* AG callback */ /* AG callback */
@ -581,6 +596,18 @@ void BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec);
#if (BTM_SCO_HCI_INCLUDED == TRUE ) #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 ** Function BTA_AgCiData

View File

@ -113,6 +113,7 @@ typedef UINT8 tBTA_HF_CLIENT_AT_RESULT_TYPE;
#define BTA_HF_CLIENT_BINP_EVT 20 /* binp number 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_RING_INDICATION 21 /* HF Client ring indication */
#define BTA_HF_CLIENT_DISABLE_EVT 30 /* HF Client disabled */ #define BTA_HF_CLIENT_DISABLE_EVT 30 /* HF Client disabled */
#define BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT 31 /* HF Client packet status nums */
typedef UINT8 tBTA_HF_CLIENT_EVT; typedef UINT8 tBTA_HF_CLIENT_EVT;
@ -163,6 +164,7 @@ typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE;
/* data associated with most non-AT events */ /* data associated with most non-AT events */
/* placeholder, if not needed should be removed*/ /* placeholder, if not needed should be removed*/
typedef struct { typedef struct {
UINT16 sync_conn_handle;
} tBTA_HF_CLIENT_HDR; } tBTA_HF_CLIENT_HDR;
/* data associated with BTA_HF_CLIENT_REGISTER_EVT */ /* data associated with BTA_HF_CLIENT_REGISTER_EVT */
@ -232,6 +234,17 @@ typedef struct {
UINT16 value; UINT16 value;
} tBTA_HF_CLIENT_VAL; } 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 */ /* union of data associated with AG callback */
typedef union { typedef union {
tBTA_HF_CLIENT_HDR hdr; tBTA_HF_CLIENT_HDR hdr;
@ -245,6 +258,7 @@ typedef union {
tBTA_HF_CLIENT_AT_RESULT result; tBTA_HF_CLIENT_AT_RESULT result;
tBTA_HF_CLIENT_CLCC clcc; tBTA_HF_CLIENT_CLCC clcc;
tBTA_HF_CLIENT_CNUM cnum; tBTA_HF_CLIENT_CNUM cnum;
tBTA_SCO_PKT_STAT_NUMS pkt_num;
} tBTA_HF_CLIENT; } tBTA_HF_CLIENT;
typedef UINT32 tBTA_HF_CLIENT_FEAT; typedef UINT32 tBTA_HF_CLIENT_FEAT;
@ -380,6 +394,18 @@ void BTA_HfClientAudioClose(UINT16 handle);
void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val1, UINT32 val2, const char *str); 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 ) #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); void BTA_HfClientCiData(void);
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */ #endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -214,37 +214,6 @@ static void send_indicator_update(UINT16 indicator, UINT16 value)
BTA_AgResult(BTA_AG_HANDLE_ALL, BTA_AG_IND_RES, &ag_res); BTA_AgResult(BTA_AG_HANDLE_ALL, BTA_AG_IND_RES, &ag_res);
} }
static void btc_hf_cind_evt(tBTA_AG_IND *ind)
{
esp_hf_cb_param_t param;
memset(&param, 0, sizeof(esp_hf_cb_param_t));
switch (ind->type) {
case BTA_AG_IND_CALL:
param.cind.call_status = ind->value;
break;
case BTA_AG_IND_CALLSETUP:
param.cind.call_setup_status = ind->value;
break;
case BTA_AG_IND_SERVICE:
param.cind.svc = ind->value;
break;
case BTA_AG_IND_SIGNAL:
param.cind.signal_strength = ind->value;
break;
case BTA_AG_IND_ROAM:
param.cind.roam = ind->value;
break;
case BTA_AG_IND_BATTCHG:
param.cind.battery_level = ind->value;
break;
case BTA_AG_IND_CALLHELD:
param.cind.call_held_status = ind->value;
break;
}
btc_hf_cb_to_app(ESP_HF_CIND_RESPONSE_EVT, &param);
}
static void bte_hf_evt(tBTA_AG_EVT event, tBTA_AG *param) static void bte_hf_evt(tBTA_AG_EVT event, tBTA_AG *param)
{ {
int param_len = 0; int param_len = 0;
@ -441,6 +410,21 @@ bt_status_t btc_hf_disconnect_audio(bt_bdaddr_t *bd_addr)
return BT_STATUS_FAIL; return BT_STATUS_FAIL;
} }
static bt_status_t btc_hf_pkt_stat_nums_get(UINT16 sync_conn_handle)
{
bt_status_t status = BT_STATUS_FAIL;
#if (BTM_SCO_HCI_INCLUDED == TRUE)
int idx = btc_hf_latest_connected_idx();
CHECK_HF_SLC_CONNECTED(idx);
if (idx != BTC_HF_INVALID_IDX) {
BTA_AgPktStatsNumsGet(hf_local_param[idx].btc_hf_cb.handle, sync_conn_handle);
status = BT_STATUS_SUCCESS;
}
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE) */
return status;
}
/************************************************************************************ /************************************************************************************
** AT cmd Handle ** AT cmd Handle
************************************************************************************/ ************************************************************************************/
@ -1206,8 +1190,13 @@ void btc_hf_call_handler(btc_msg_t *msg)
case BTC_HF_REGISTER_DATA_CALLBACK_EVT: case BTC_HF_REGISTER_DATA_CALLBACK_EVT:
{ {
btc_hf_reg_data_cb(arg->reg_data_cb.recv, arg->reg_data_cb.send); btc_hf_reg_data_cb(arg->reg_data_cb.recv, arg->reg_data_cb.send);
}
break; break;
}
case BTC_HF_REQUEST_PKT_STAT_EVT:
{
btc_hf_pkt_stat_nums_get(arg->pkt_sync_hd.sync_conn_handle);
break;
}
default: default:
BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act); BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act);
@ -1225,6 +1214,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
BTC_TRACE_DEBUG("%s: event = %s", __FUNCTION__, dump_hf_event(event)); BTC_TRACE_DEBUG("%s: event = %s", __FUNCTION__, dump_hf_event(event));
memset(&param, 0, sizeof(esp_hf_cb_param_t));
switch (event) { switch (event) {
case BTA_AG_ENABLE_EVT: case BTA_AG_ENABLE_EVT:
case BTA_AG_DISABLE_EVT: case BTA_AG_DISABLE_EVT:
@ -1261,7 +1252,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
} }
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
memcpy(param.conn_stat.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t)); memcpy(param.conn_stat.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t));
param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state; param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state;
param.conn_stat.peer_feat = 0; param.conn_stat.peer_feat = 0;
@ -1288,7 +1278,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
hf_local_param[idx].btc_hf_cb.connection_state = ESP_HF_CONNECTION_STATE_SLC_CONNECTED; hf_local_param[idx].btc_hf_cb.connection_state = ESP_HF_CONNECTION_STATE_SLC_CONNECTED;
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state; param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state;
param.conn_stat.peer_feat = hf_local_param[idx].btc_hf_cb.peer_feat; param.conn_stat.peer_feat = hf_local_param[idx].btc_hf_cb.peer_feat;
param.conn_stat.chld_feat = hf_local_param[idx].btc_hf_cb.chld_feat; param.conn_stat.chld_feat = hf_local_param[idx].btc_hf_cb.chld_feat;
@ -1309,7 +1298,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
BTC_TRACE_DEBUG("%s: BTA_AG_CLOSE_EVT," "hf_local_param[%d].btc_hf_cb.handle = %d", __FUNCTION__, BTC_TRACE_DEBUG("%s: BTA_AG_CLOSE_EVT," "hf_local_param[%d].btc_hf_cb.handle = %d", __FUNCTION__,
idx, hf_local_param[idx].btc_hf_cb.handle); idx, hf_local_param[idx].btc_hf_cb.handle);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.conn_stat.state = ESP_HF_CONNECTION_STATE_DISCONNECTED; param.conn_stat.state = ESP_HF_CONNECTION_STATE_DISCONNECTED;
param.conn_stat.peer_feat = 0; param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0; param.conn_stat.chld_feat = 0;
@ -1328,9 +1316,9 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1; idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx); CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED; param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t)); memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param); btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
} while(0); } while(0);
break; break;
@ -1341,9 +1329,9 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1; idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx); CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED_MSBC; param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED_MSBC;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t)); memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param); btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
} while (0); } while (0);
break; break;
@ -1353,9 +1341,9 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1; idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx); CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.audio_stat.state = ESP_HF_AUDIO_STATE_DISCONNECTED; param.audio_stat.state = ESP_HF_AUDIO_STATE_DISCONNECTED;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t)); memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param); btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
} while(0); } while(0);
break; break;
@ -1366,8 +1354,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1; idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx); CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.vra_rep.value = p_data->val.num; param.vra_rep.value = p_data->val.num;
memcpy(param.vra_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_BVRA_RESPONSE_EVT, &param); btc_hf_cb_to_app(ESP_HF_BVRA_RESPONSE_EVT, &param);
if (p_data->val.num) { if (p_data->val.num) {
btc_hf_connect_audio(&hf_local_param[idx].btc_hf_cb.connected_bda); btc_hf_connect_audio(&hf_local_param[idx].btc_hf_cb.connected_bda);
@ -1381,8 +1369,10 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_SPK_EVT: case BTA_AG_SPK_EVT:
case BTA_AG_MIC_EVT: case BTA_AG_MIC_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.volume_control.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.volume_control.type = (event == BTA_AG_SPK_EVT) ? ESP_HF_VOLUME_CONTROL_TARGET_SPK : ESP_HF_VOLUME_CONTROL_TARGET_MIC; param.volume_control.type = (event == BTA_AG_SPK_EVT) ? ESP_HF_VOLUME_CONTROL_TARGET_SPK : ESP_HF_VOLUME_CONTROL_TARGET_MIC;
param.volume_control.volume = p_data->val.num; param.volume_control.volume = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_VOLUME_CONTROL_EVT, &param); btc_hf_cb_to_app(ESP_HF_VOLUME_CONTROL_EVT, &param);
@ -1392,46 +1382,67 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_UNAT_EVT: case BTA_AG_AT_UNAT_EVT:
{ {
memset(&param, 0, sizeof(esp_hf_cb_param_t)); idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memcpy(param.unat_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.unat_rep.unat = p_data->val.str; param.unat_rep.unat = p_data->val.str;
btc_hf_cb_to_app(ESP_HF_UNAT_RESPONSE_EVT, &param); btc_hf_cb_to_app(ESP_HF_UNAT_RESPONSE_EVT, &param);
} while (0);
break; break;
} }
case BTA_AG_AT_CBC_EVT: case BTA_AG_AT_CBC_EVT:
{ {
btc_hf_cb_to_app(ESP_HF_IND_UPDATE_EVT, NULL); idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.ind_upd.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_IND_UPDATE_EVT, &param);
break; break;
} }
case BTA_AG_AT_CIND_EVT: case BTA_AG_AT_CIND_EVT:
{ {
btc_hf_cind_evt(&p_data->ind); idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.cind_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CIND_RESPONSE_EVT, &param);
break; break;
} }
case BTA_AG_AT_COPS_EVT: case BTA_AG_AT_COPS_EVT:
{ {
btc_hf_cb_to_app(ESP_HF_COPS_RESPONSE_EVT, NULL); idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.cops_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_COPS_RESPONSE_EVT, &param);
break; break;
} }
case BTA_AG_AT_CLCC_EVT: case BTA_AG_AT_CLCC_EVT:
{ {
btc_hf_cb_to_app(ESP_HF_CLCC_RESPONSE_EVT, NULL); idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.clcc_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CLCC_RESPONSE_EVT, &param);
break; break;
} }
case BTA_AG_AT_CNUM_EVT: case BTA_AG_AT_CNUM_EVT:
{ {
btc_hf_cb_to_app(ESP_HF_CNUM_RESPONSE_EVT, NULL); idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.cnum_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CNUM_RESPONSE_EVT, &param);
break; break;
} }
case BTA_AG_AT_VTS_EVT: case BTA_AG_AT_VTS_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.vts_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.vts_rep.code = p_data->val.str; param.vts_rep.code = p_data->val.str;
btc_hf_cb_to_app(ESP_HF_VTS_RESPONSE_EVT, &param); btc_hf_cb_to_app(ESP_HF_VTS_RESPONSE_EVT, &param);
} while(0); } while(0);
@ -1440,8 +1451,10 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_NREC_EVT: case BTA_AG_AT_NREC_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do { do {
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.nrec.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.nrec.state = p_data->val.num; param.nrec.state = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_NREC_RESPONSE_EVT, &param); btc_hf_cb_to_app(ESP_HF_NREC_RESPONSE_EVT, &param);
} while(0); } while(0);
@ -1450,29 +1463,39 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_A_EVT: case BTA_AG_AT_A_EVT:
{ {
btc_hf_cb_to_app(ESP_HF_ATA_RESPONSE_EVT, NULL); idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.ata_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_ATA_RESPONSE_EVT, &param);
break; break;
} }
case BTA_AG_AT_CHUP_EVT: case BTA_AG_AT_CHUP_EVT:
{ {
btc_hf_cb_to_app(ESP_HF_CHUP_RESPONSE_EVT, NULL); idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.chup_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CHUP_RESPONSE_EVT, &param);
break; break;
} }
case BTA_AG_AT_BLDN_EVT: case BTA_AG_AT_BLDN_EVT:
case BTA_AG_AT_D_EVT: case BTA_AG_AT_D_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do { do {
if (event == BTA_AG_AT_D_EVT) { // dial_number_or_memory if (event == BTA_AG_AT_D_EVT) { // dial_number_or_memory
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.out_call.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.out_call.type = p_data->val.value;
param.out_call.num_or_loc = osi_malloc((strlen(p_data->val.str) + 1) * sizeof(char)); param.out_call.num_or_loc = osi_malloc((strlen(p_data->val.str) + 1) * sizeof(char));
sprintf(param.out_call.num_or_loc, "%s", p_data->val.str); sprintf(param.out_call.num_or_loc, "%s", p_data->val.str);
btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param); btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param);
send_indicator_update(BTA_AG_IND_CALLSETUP,BTA_AG_CALLSETUP_OUTGOING); send_indicator_update(BTA_AG_IND_CALLSETUP,BTA_AG_CALLSETUP_OUTGOING);
osi_free(param.out_call.num_or_loc); osi_free(param.out_call.num_or_loc);
} else if (event == BTA_AG_AT_BLDN_EVT) { //dial_last } else if (event == BTA_AG_AT_BLDN_EVT) { //dial_last
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.out_call.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.out_call.num_or_loc = NULL;
btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param); btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param);
} }
} while(0); } while(0);
@ -1515,23 +1538,37 @@ void btc_hf_cb_handler(btc_msg_t *msg)
#if (BTM_WBS_INCLUDED == TRUE) #if (BTM_WBS_INCLUDED == TRUE)
case BTA_AG_WBS_EVT: case BTA_AG_WBS_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
BTC_TRACE_DEBUG("Set codec status %d codec %d 1=CVSD 2=MSBC", p_data->val.hdr.status, p_data->val.num); BTC_TRACE_DEBUG("Set codec status %d codec %d 1=CVSD 2=MSBC", p_data->val.hdr.status, p_data->val.num);
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.wbs_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.wbs_rep.codec = p_data->val.num; param.wbs_rep.codec = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_WBS_RESPONSE_EVT, &param); btc_hf_cb_to_app(ESP_HF_WBS_RESPONSE_EVT, &param);
} while (0);
break; break;
} }
case BTA_AG_AT_BCS_EVT: case BTA_AG_AT_BCS_EVT:
{ {
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
BTC_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", p_data->val.num); BTC_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", p_data->val.num);
memset(&param, 0, sizeof(esp_hf_cb_param_t)); memcpy(param.bcs_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
param.bcs_rep.mode = p_data->val.num; param.bcs_rep.mode = p_data->val.num;
/* No ESP_HF_WBS_NONE case, becuase HFP 1.6 supported device can send BCS */ /* No ESP_HF_WBS_NONE case, becuase HFP 1.6 supported device can send BCS */
btc_hf_cb_to_app(ESP_HF_BCS_RESPONSE_EVT, &param); btc_hf_cb_to_app(ESP_HF_BCS_RESPONSE_EVT, &param);
} while (0);
break; break;
} }
#endif #endif
case BTA_AG_PKT_NUMS_GET_EVT:
{
memcpy(&param.pkt_nums, &p_data->pkt_num, sizeof(struct ag_pkt_status_nums));
btc_hf_cb_to_app(ESP_HF_PKT_STAT_NUMS_GET_EVT, &param);
break;
}
default: default:
BTC_TRACE_WARNING("%s: Unhandled event: %d", __FUNCTION__, event); BTC_TRACE_WARNING("%s: Unhandled event: %d", __FUNCTION__, event);
break; break;

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -677,6 +677,24 @@ static bt_status_t btc_hf_client_send_nrec(void)
return BT_STATUS_UNSUPPORTED; return BT_STATUS_UNSUPPORTED;
} }
/*******************************************************************************
**
** Function btc_hf_client_pkt_stat_nums_get;
**
** Description Request packet status numbers for a specific (e)SCO connection handle
**
** Returns bt_status_t
**
*******************************************************************************/
static bt_status_t btc_hf_client_pkt_stat_nums_get(UINT16 sync_conn_handle)
{
CHECK_HF_CLIENT_SLC_CONNECTED();
#if (BTM_SCO_HCI_INCLUDED == TRUE)
BTA_HfClientPktStatsNumsGet(sync_conn_handle);
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE) */
return BT_STATUS_SUCCESS;
}
/******************************************************************************* /*******************************************************************************
** **
** Function bte_hf_client_evt ** Function bte_hf_client_evt
@ -802,6 +820,8 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
esp_hf_client_cb_param_t param; esp_hf_client_cb_param_t param;
bdstr_t bdstr; bdstr_t bdstr;
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
switch (event) switch (event)
{ {
case BTA_HF_CLIENT_ENABLE_EVT: case BTA_HF_CLIENT_ENABLE_EVT:
@ -832,7 +852,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
} }
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.conn_stat.state = hf_client_local_param.btc_hf_client_cb.state; param.conn_stat.state = hf_client_local_param.btc_hf_client_cb.state;
param.conn_stat.peer_feat = 0; param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0; param.conn_stat.chld_feat = 0;
@ -858,7 +877,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
hf_client_local_param.btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_SLC_CONNECTED; hf_client_local_param.btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_SLC_CONNECTED;
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.conn_stat.state = hf_client_local_param.btc_hf_client_cb.state; param.conn_stat.state = hf_client_local_param.btc_hf_client_cb.state;
param.conn_stat.peer_feat = hf_client_local_param.btc_hf_client_cb.peer_feat; param.conn_stat.peer_feat = hf_client_local_param.btc_hf_client_cb.peer_feat;
param.conn_stat.chld_feat = hf_client_local_param.btc_hf_client_cb.chld_feat; param.conn_stat.chld_feat = hf_client_local_param.btc_hf_client_cb.chld_feat;
@ -873,7 +891,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
if (hf_client_local_param.btc_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_INBAND) if (hf_client_local_param.btc_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_INBAND)
{ {
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.bsir.state = ESP_HF_CLIENT_IN_BAND_RINGTONE_PROVIDED; param.bsir.state = ESP_HF_CLIENT_IN_BAND_RINGTONE_PROVIDED;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_BSIR_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_BSIR_EVT, &param);
} while (0); } while (0);
@ -885,7 +902,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
case BTA_HF_CLIENT_CLOSE_EVT: case BTA_HF_CLIENT_CLOSE_EVT:
hf_client_local_param.btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED; hf_client_local_param.btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.conn_stat.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED; param.conn_stat.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
param.conn_stat.peer_feat = 0; param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0; param.conn_stat.chld_feat = 0;
@ -906,7 +922,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break; break;
case BTA_HF_CLIENT_MIC_EVT: case BTA_HF_CLIENT_MIC_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.volume_control.type = ESP_HF_VOLUME_CONTROL_TARGET_MIC; param.volume_control.type = ESP_HF_VOLUME_CONTROL_TARGET_MIC;
param.volume_control.volume = p_data->val.value; param.volume_control.volume = p_data->val.value;
@ -915,7 +930,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break; break;
case BTA_HF_CLIENT_SPK_EVT: case BTA_HF_CLIENT_SPK_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.volume_control.type = ESP_HF_VOLUME_CONTROL_TARGET_SPK; param.volume_control.type = ESP_HF_VOLUME_CONTROL_TARGET_SPK;
param.volume_control.volume = p_data->val.value; param.volume_control.volume = p_data->val.value;
@ -924,7 +938,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break; break;
case BTA_HF_CLIENT_VOICE_REC_EVT: case BTA_HF_CLIENT_VOICE_REC_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.bvra.value = p_data->val.value; param.bvra.value = p_data->val.value;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_BVRA_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_BVRA_EVT, &param);
@ -932,35 +945,30 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break; break;
case BTA_HF_CLIENT_OPERATOR_NAME_EVT: case BTA_HF_CLIENT_OPERATOR_NAME_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.cops.name = p_data->operator.name; param.cops.name = p_data->operator.name;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT, &param);
} while (0); } while (0);
break; break;
case BTA_HF_CLIENT_CLIP_EVT: case BTA_HF_CLIENT_CLIP_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.clip.number = p_data->number.number; param.clip.number = p_data->number.number;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CLIP_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_CLIP_EVT, &param);
} while (0); } while (0);
break; break;
case BTA_HF_CLIENT_BINP_EVT: case BTA_HF_CLIENT_BINP_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.binp.number = p_data->number.number; param.binp.number = p_data->number.number;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_BINP_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_BINP_EVT, &param);
} while (0); } while (0);
break; break;
case BTA_HF_CLIENT_CCWA_EVT: case BTA_HF_CLIENT_CCWA_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.ccwa.number = p_data->number.number; param.ccwa.number = p_data->number.number;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CCWA_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_CCWA_EVT, &param);
} while (0); } while (0);
break; break;
case BTA_HF_CLIENT_AT_RESULT_EVT: case BTA_HF_CLIENT_AT_RESULT_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.at_response.code = p_data->result.type; param.at_response.code = p_data->result.type;
param.at_response.cme = p_data->result.cme; param.at_response.cme = p_data->result.cme;
@ -969,7 +977,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break; break;
case BTA_HF_CLIENT_CLCC_EVT: case BTA_HF_CLIENT_CLCC_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.clcc.idx = p_data->clcc.idx; param.clcc.idx = p_data->clcc.idx;
param.clcc.dir = p_data->clcc.inc ? ESP_HF_CURRENT_CALL_DIRECTION_INCOMING : param.clcc.dir = p_data->clcc.inc ? ESP_HF_CURRENT_CALL_DIRECTION_INCOMING :
ESP_HF_CURRENT_CALL_DIRECTION_OUTGOING; ESP_HF_CURRENT_CALL_DIRECTION_OUTGOING;
@ -982,7 +989,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break; break;
case BTA_HF_CLIENT_CNUM_EVT: case BTA_HF_CLIENT_CNUM_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.cnum.number = p_data->cnum.number; param.cnum.number = p_data->cnum.number;
if (p_data->cnum.service == 4) { if (p_data->cnum.service == 4) {
param.cnum.type = ESP_HF_SUBSCRIBER_SERVICE_TYPE_VOICE; param.cnum.type = ESP_HF_SUBSCRIBER_SERVICE_TYPE_VOICE;
@ -998,7 +1004,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
case BTA_HF_CLIENT_BTRH_EVT: case BTA_HF_CLIENT_BTRH_EVT:
if (p_data->val.value <= ESP_HF_BTRH_STATUS_REJECTED) { if (p_data->val.value <= ESP_HF_BTRH_STATUS_REJECTED) {
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.btrh.status = p_data->val.value; param.btrh.status = p_data->val.value;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_BTRH_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_BTRH_EVT, &param);
@ -1006,7 +1011,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
} }
break; break;
case BTA_HF_CLIENT_BSIR_EVT: case BTA_HF_CLIENT_BSIR_EVT:
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
if (p_data->val.value != 0) if (p_data->val.value != 0)
{ {
param.bsir.state = ESP_HF_CLIENT_IN_BAND_RINGTONE_PROVIDED; param.bsir.state = ESP_HF_CLIENT_IN_BAND_RINGTONE_PROVIDED;
@ -1019,28 +1023,28 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break; break;
case BTA_HF_CLIENT_AUDIO_OPEN_EVT: case BTA_HF_CLIENT_AUDIO_OPEN_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED; param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED;
memcpy(param.audio_stat.remote_bda, &hf_client_local_param.btc_hf_client_cb.connected_bda, memcpy(param.audio_stat.remote_bda, &hf_client_local_param.btc_hf_client_cb.connected_bda,
sizeof(esp_bd_addr_t)); sizeof(esp_bd_addr_t));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, &param);
} while (0); } while (0);
break; break;
case BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT: case BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC; param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC;
memcpy(param.audio_stat.remote_bda, &hf_client_local_param.btc_hf_client_cb.connected_bda, memcpy(param.audio_stat.remote_bda, &hf_client_local_param.btc_hf_client_cb.connected_bda,
sizeof(esp_bd_addr_t)); sizeof(esp_bd_addr_t));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, &param);
} while (0); } while (0);
break; break;
case BTA_HF_CLIENT_AUDIO_CLOSE_EVT: case BTA_HF_CLIENT_AUDIO_CLOSE_EVT:
do { do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_DISCONNECTED; param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_DISCONNECTED;
memcpy(param.audio_stat.remote_bda, &hf_client_local_param.btc_hf_client_cb.connected_bda, memcpy(param.audio_stat.remote_bda, &hf_client_local_param.btc_hf_client_cb.connected_bda,
sizeof(esp_bd_addr_t)); sizeof(esp_bd_addr_t));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, &param);
} while (0); } while (0);
break; break;
@ -1049,6 +1053,12 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
btc_hf_client_cb_to_app(ESP_HF_CLIENT_RING_IND_EVT, NULL); btc_hf_client_cb_to_app(ESP_HF_CLIENT_RING_IND_EVT, NULL);
} while (0); } while (0);
break; break;
case BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT:
{
memcpy(&param.pkt_nums, &p_data->pkt_num, sizeof(struct hf_client_pkt_status_nums));
btc_hf_client_cb_to_app(ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT, &param);
break;
}
default: default:
BTC_TRACE_WARNING("%s: Unhandled event: %d", __FUNCTION__, event); BTC_TRACE_WARNING("%s: Unhandled event: %d", __FUNCTION__, event);
break; break;
@ -1132,6 +1142,9 @@ void btc_hf_client_call_handler(btc_msg_t *msg)
case BTC_HF_CLIENT_SEND_IPHONEACCEV_EVT: case BTC_HF_CLIENT_SEND_IPHONEACCEV_EVT:
btc_hf_client_send_iphoneaccev(arg->send_iphoneaccev.bat_level, arg->send_iphoneaccev.docked); btc_hf_client_send_iphoneaccev(arg->send_iphoneaccev.bat_level, arg->send_iphoneaccev.docked);
break; break;
case BTC_HF_CLIENT_REQUEST_PKT_STAT_EVT:
btc_hf_client_pkt_stat_nums_get(arg->pkt_sync_hd.sync_conn_handle);
break;
default: default:
BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act); BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act);
} }

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -55,7 +55,8 @@ typedef enum
BTC_HF_OUT_CALL_EVT, BTC_HF_OUT_CALL_EVT,
BTC_HF_END_CALL_EVT, BTC_HF_END_CALL_EVT,
//REG //REG
BTC_HF_REGISTER_DATA_CALLBACK_EVT BTC_HF_REGISTER_DATA_CALLBACK_EVT,
BTC_HF_REQUEST_PKT_STAT_EVT
} btc_hf_act_t; } btc_hf_act_t;
/* btc_hf_args_t */ /* btc_hf_args_t */
@ -180,6 +181,11 @@ typedef union
esp_hf_outgoing_data_cb_t send; esp_hf_outgoing_data_cb_t send;
} reg_data_cb; } reg_data_cb;
// BTC_HF_REQUEST_PKT_STAT_EVT
struct req_pkt_stat_sync_handle {
UINT16 sync_conn_handle;
} pkt_sync_hd;
} btc_hf_args_t; } btc_hf_args_t;
/************************************************************************************ /************************************************************************************

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -52,6 +52,7 @@ typedef enum {
BTC_HF_CLIENT_SEND_NREC_EVT, BTC_HF_CLIENT_SEND_NREC_EVT,
BTC_HF_CLIENT_SEND_XAPL_EVT, BTC_HF_CLIENT_SEND_XAPL_EVT,
BTC_HF_CLIENT_SEND_IPHONEACCEV_EVT, BTC_HF_CLIENT_SEND_IPHONEACCEV_EVT,
BTC_HF_CLIENT_REQUEST_PKT_STAT_EVT,
} btc_hf_client_act_t; } btc_hf_client_act_t;
/* btc_hf_client_args_t */ /* btc_hf_client_args_t */
@ -117,6 +118,12 @@ typedef union {
uint32_t bat_level; uint32_t bat_level;
bool docked; bool docked;
} send_iphoneaccev; } send_iphoneaccev;
// BTC_HF_CLIENT_REQUEST_PKT_STAT_EVT
struct req_pkt_stat_sync_handle {
UINT16 sync_conn_handle;
} pkt_sync_hd;
} btc_hf_client_args_t; } btc_hf_client_args_t;
/************************************************************************************ /************************************************************************************

View File

@ -341,6 +341,82 @@ void btm_sco_process_num_completed_pkts (UINT8 *p)
return; return;
} }
/*******************************************************************************
**
** Function btm_pkt_stat_nums_update
**
** Description Update the number of received SCO data packet status.
**
** Returns void
**
*******************************************************************************/
static void btm_pkt_stat_nums_update(uint16_t sco_inx, uint8_t pkt_status)
{
tSCO_CONN *p_ccb = &btm_cb.sco_cb.sco_db[sco_inx];
p_ccb->pkt_stat_nums.rx_total++;
if (pkt_status == BTM_SCO_DATA_CORRECT) {
p_ccb->pkt_stat_nums.rx_correct++;
} else if (pkt_status == BTM_SCO_DATA_PAR_ERR) {
p_ccb->pkt_stat_nums.rx_err++;
} else if (pkt_status == BTM_SCO_DATA_NONE) {
p_ccb->pkt_stat_nums.rx_none++;
} else {
p_ccb->pkt_stat_nums.rx_lost++;
}
}
/*******************************************************************************
**
** Function btm_pkt_stat_send_nums_update
**
** Description Update the number of send packet status.
**
** Returns void
**
*******************************************************************************/
static void btm_pkt_stat_send_nums_update(uint16_t sco_inx, uint8_t pkt_status)
{
tSCO_CONN *p_ccb = &btm_cb.sco_cb.sco_db[sco_inx];
p_ccb->pkt_stat_nums.tx_total++;
if (pkt_status != BTM_SUCCESS) {
p_ccb->pkt_stat_nums.tx_discarded++;
}
}
/*******************************************************************************
**
** Function btm_pkt_stat_nums_reset
**
** Description This function is called to reset the number of packet status struct
**
** Returns void
**
*******************************************************************************/
static void btm_pkt_stat_nums_reset(uint16_t sco_inx)
{
memset(&btm_cb.sco_cb.sco_db[sco_inx].pkt_stat_nums, 0, sizeof(tBTM_SCO_PKT_STAT_NUMS));
}
/*******************************************************************************
**
** Function BTM_PktStatNumsGet
**
** Description This function is called to get the number of packet status struct
**
** Returns void
**
*******************************************************************************/
void BTM_PktStatNumsGet(uint16_t sync_conn_handle, tBTM_SCO_PKT_STAT_NUMS *p_pkt_nums)
{
uint16_t sco_inx = btm_find_scb_by_handle(sync_conn_handle);
if (sco_inx < BTM_MAX_SCO_LINKS) {
memcpy(p_pkt_nums, &btm_cb.sco_cb.sco_db[sco_inx].pkt_stat_nums, sizeof(tBTM_SCO_PKT_STAT_NUMS));
} else {
memset(p_pkt_nums, 0, sizeof(tBTM_SCO_PKT_STAT_NUMS));
}
}
#endif /* BTM_SCO_HCI_INCLUDED == TRUE */ #endif /* BTM_SCO_HCI_INCLUDED == TRUE */
/******************************************************************************* /*******************************************************************************
@ -374,6 +450,7 @@ void btm_route_sco_data(BT_HDR *p_msg)
{ {
osi_free (p_msg); osi_free (p_msg);
} else { } else {
btm_pkt_stat_nums_update(sco_inx, pkt_status);
(*btm_cb.sco_cb.p_data_cb)(sco_inx, p_msg, (tBTM_SCO_DATA_FLAG) pkt_status); (*btm_cb.sco_cb.p_data_cb)(sco_inx, p_msg, (tBTM_SCO_DATA_FLAG) pkt_status);
} }
} else { /* no mapping handle SCO connection is active, free the buffer */ } else { /* no mapping handle SCO connection is active, free the buffer */
@ -461,6 +538,7 @@ tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf)
BTM_TRACE_WARNING ("stat %d", status); BTM_TRACE_WARNING ("stat %d", status);
osi_free(p_buf); osi_free(p_buf);
} }
btm_pkt_stat_send_nums_update(sco_inx, status);
return (status); return (status);
#else #else
@ -994,6 +1072,7 @@ void btm_sco_connected (UINT8 hci_status, BD_ADDR bda, UINT16 hci_handle,
} }
#if BTM_SCO_HCI_INCLUDED == TRUE #if BTM_SCO_HCI_INCLUDED == TRUE
p->sent_not_acked = 0; p->sent_not_acked = 0;
btm_pkt_stat_nums_reset(xx);
#endif #endif
p->state = SCO_ST_CONNECTED; p->state = SCO_ST_CONNECTED;
p->hci_handle = hci_handle; p->hci_handle = hci_handle;

View File

@ -431,6 +431,7 @@ typedef struct {
#define BTM_SCO_XMIT_QUEUE_HIGH_WM 20 #define BTM_SCO_XMIT_QUEUE_HIGH_WM 20
fixed_queue_t *xmit_data_q; /* SCO data transmitting queue */ fixed_queue_t *xmit_data_q; /* SCO data transmitting queue */
INT16 sent_not_acked; INT16 sent_not_acked;
tBTM_SCO_PKT_STAT_NUMS pkt_stat_nums;
#endif #endif
tBTM_SCO_CB *p_conn_cb; /* Callback for when connected */ tBTM_SCO_CB *p_conn_cb; /* Callback for when connected */
tBTM_SCO_CB *p_disc_cb; /* Callback for when disconnect */ tBTM_SCO_CB *p_disc_cb; /* Callback for when disconnect */

View File

@ -1062,6 +1062,17 @@ enum {
}; };
typedef UINT8 tBTM_SCO_DATA_FLAG; typedef UINT8 tBTM_SCO_DATA_FLAG;
/* Count the number of SCO Data Packet Status */
typedef struct {
UINT32 rx_total;
UINT32 rx_correct;
UINT32 rx_err;
UINT32 rx_none;
UINT32 rx_lost;
UINT32 tx_total;
UINT32 tx_discarded;
} tBTM_SCO_PKT_STAT_NUMS;
/*************************** /***************************
** SCO Callback Functions ** SCO Callback Functions
****************************/ ****************************/
@ -4190,6 +4201,17 @@ tBTM_STATUS BTM_SetAfhChannels (AFH_CHANNELS channels, tBTM_CMPL_CB *p_afh_chann
*******************************************************************************/ *******************************************************************************/
tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels, tBTM_CMPL_CB *p_ble_channels_cmpl_cback); tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels, tBTM_CMPL_CB *p_ble_channels_cmpl_cback);
/*******************************************************************************
**
** Function BTM_PktStatNumsGet
**
** Description This function is called to get the number of packet status struct
**
** Returns void
**
*******************************************************************************/
void BTM_PktStatNumsGet(UINT16 sync_conn_handle, tBTM_SCO_PKT_STAT_NUMS *pkt_nums);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@ -45,6 +45,7 @@ const char *c_hf_evt_str[] = {
"DIAL_EVT", /*!< DIAL INCOMING EVT */ "DIAL_EVT", /*!< DIAL INCOMING EVT */
"WBS_EVT", /*!< CURRENT CODEC EVT */ "WBS_EVT", /*!< CURRENT CODEC EVT */
"BCS_EVT", /*!< CODEC NEGO EVT */ "BCS_EVT", /*!< CODEC NEGO EVT */
"PKT_STAT_EVT", /*!< REQUEST PACKET STATUS EVT */
}; };
//esp_hf_connection_state_t //esp_hf_connection_state_t
@ -212,7 +213,7 @@ static void bt_app_send_data_timer_cb(void *arg)
static void bt_app_send_data_task(void *arg) static void bt_app_send_data_task(void *arg)
{ {
uint64_t frame_data_num; uint64_t frame_data_num;
uint32_t item_size = 0; size_t item_size = 0;
uint8_t *buf = NULL; uint8_t *buf = NULL;
for (;;) { for (;;) {
if (xSemaphoreTake(s_send_data_Semaphore, (TickType_t)portMAX_DELAY)) { if (xSemaphoreTake(s_send_data_Semaphore, (TickType_t)portMAX_DELAY)) {
@ -275,14 +276,14 @@ void bt_app_send_data_shut_down(void)
vTaskDelete(s_bt_app_send_data_task_handler); vTaskDelete(s_bt_app_send_data_task_handler);
s_bt_app_send_data_task_handler = NULL; s_bt_app_send_data_task_handler = NULL;
} }
if (s_send_data_Semaphore) {
vSemaphoreDelete(s_send_data_Semaphore);
s_send_data_Semaphore = NULL;
}
if(s_periodic_timer) { if(s_periodic_timer) {
ESP_ERROR_CHECK(esp_timer_stop(s_periodic_timer)); ESP_ERROR_CHECK(esp_timer_stop(s_periodic_timer));
ESP_ERROR_CHECK(esp_timer_delete(s_periodic_timer)); ESP_ERROR_CHECK(esp_timer_delete(s_periodic_timer));
} }
if (s_send_data_Semaphore) {
vSemaphoreDelete(s_send_data_Semaphore);
s_send_data_Semaphore = NULL;
}
if (s_m_rb) { if (s_m_rb) {
vRingbufferDelete(s_m_rb); vRingbufferDelete(s_m_rb);
} }
@ -292,7 +293,7 @@ void bt_app_send_data_shut_down(void)
void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param) void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
{ {
if (event <= ESP_HF_BCS_RESPONSE_EVT) { if (event <= ESP_HF_PKT_STAT_NUMS_GET_EVT) {
ESP_LOGI(BT_HF_TAG, "APP HFP event: %s", c_hf_evt_str[event]); ESP_LOGI(BT_HF_TAG, "APP HFP event: %s", c_hf_evt_str[event]);
} else { } else {
ESP_LOGE(BT_HF_TAG, "APP HFP invalid event %d", event); ESP_LOGE(BT_HF_TAG, "APP HFP invalid event %d", event);
@ -348,7 +349,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
case ESP_HF_UNAT_RESPONSE_EVT: case ESP_HF_UNAT_RESPONSE_EVT:
{ {
ESP_LOGI(BT_HF_TAG, "--UNKOW AT CMD: %s", param->unat_rep.unat); ESP_LOGI(BT_HF_TAG, "--UNKOW AT CMD: %s", param->unat_rep.unat);
esp_hf_ag_unknown_at_send(hf_peer_addr, NULL); esp_hf_ag_unknown_at_send(param->unat_rep.remote_addr, NULL);
break; break;
} }
@ -359,7 +360,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
esp_hf_call_setup_status_t call_setup_state = 2; esp_hf_call_setup_status_t call_setup_state = 2;
esp_hf_network_state_t ntk_state = 1; esp_hf_network_state_t ntk_state = 1;
int signal = 2; int signal = 2;
esp_hf_ag_devices_status_indchange(hf_peer_addr,call_state,call_setup_state,ntk_state,signal); esp_hf_ag_devices_status_indchange(param->ind_upd.remote_addr,call_state,call_setup_state,ntk_state,signal);
break; break;
} }
@ -373,14 +374,14 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
esp_hf_roaming_status_t roam = 0; esp_hf_roaming_status_t roam = 0;
int batt_lev = 3; int batt_lev = 3;
esp_hf_call_held_status_t call_held_status = 0; esp_hf_call_held_status_t call_held_status = 0;
esp_hf_ag_cind_response(hf_peer_addr,call_status,call_setup_status,ntk_state,signal,roam,batt_lev,call_held_status); esp_hf_ag_cind_response(param->cind_rep.remote_addr,call_status,call_setup_status,ntk_state,signal,roam,batt_lev,call_held_status);
break; break;
} }
case ESP_HF_COPS_RESPONSE_EVT: case ESP_HF_COPS_RESPONSE_EVT:
{ {
const int svc_type = 1; const int svc_type = 1;
esp_hf_ag_cops_response(hf_peer_addr, c_operator_name_str[svc_type]); esp_hf_ag_cops_response(param->cops_rep.remote_addr, c_operator_name_str[svc_type]);
break; break;
} }
@ -397,7 +398,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
esp_hf_call_addr_type_t type = ESP_HF_CALL_ADDR_TYPE_UNKNOWN; esp_hf_call_addr_type_t type = ESP_HF_CALL_ADDR_TYPE_UNKNOWN;
ESP_LOGI(BT_HF_TAG, "--Calling Line Identification."); ESP_LOGI(BT_HF_TAG, "--Calling Line Identification.");
esp_hf_ag_clcc_response(hf_peer_addr, index, dir, current_call_status, mode, mpty, number, type); esp_hf_ag_clcc_response(param->clcc_rep.remote_addr, index, dir, current_call_status, mode, mpty, number, type);
break; break;
} }
@ -406,7 +407,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
char *number = {"123456"}; char *number = {"123456"};
esp_hf_subscriber_service_type_t type = 1; esp_hf_subscriber_service_type_t type = 1;
ESP_LOGI(BT_HF_TAG, "--Current Number is %s ,Type is %s.", number, c_subscriber_service_type_str[type]); ESP_LOGI(BT_HF_TAG, "--Current Number is %s ,Type is %s.", number, c_subscriber_service_type_str[type]);
esp_hf_ag_cnum_response(hf_peer_addr, number,type); esp_hf_ag_cnum_response(param->cnum_rep.remote_addr, number,type);
break; break;
} }
@ -426,7 +427,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
{ {
ESP_LOGI(BT_HF_TAG, "--Asnwer Incoming Call."); ESP_LOGI(BT_HF_TAG, "--Asnwer Incoming Call.");
char *number = {"123456"}; char *number = {"123456"};
esp_hf_ag_answer_call(hf_peer_addr,1,0,1,0,number,0); esp_hf_ag_answer_call(param->ata_rep.remote_addr,1,0,1,0,number,0);
break; break;
} }
@ -434,18 +435,33 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
{ {
ESP_LOGI(BT_HF_TAG, "--Reject Incoming Call."); ESP_LOGI(BT_HF_TAG, "--Reject Incoming Call.");
char *number = {"123456"}; char *number = {"123456"};
esp_hf_ag_reject_call(hf_peer_addr,0,0,0,0,number,0); esp_hf_ag_reject_call(param->chup_rep.remote_addr,0,0,0,0,number,0);
break; break;
} }
case ESP_HF_DIAL_EVT: case ESP_HF_DIAL_EVT:
{ {
if (param->out_call.num_or_loc) { if (param->out_call.num_or_loc) {
//dia_num_or_mem if (param->out_call.type == ESP_HF_DIAL_NUM) {
ESP_LOGI(BT_HF_TAG, "--Dial \"%s\".", param->out_call.num_or_loc); // dia_num
esp_hf_ag_out_call(hf_peer_addr,1,0,1,0,param->out_call.num_or_loc,0); ESP_LOGI(BT_HF_TAG, "--Dial number \"%s\".", param->out_call.num_or_loc);
esp_hf_ag_out_call(param->out_call.remote_addr,1,0,1,0,param->out_call.num_or_loc,0);
} else if (param->out_call.type == ESP_HF_DIAL_MEM) {
// dia_mem
ESP_LOGI(BT_HF_TAG, "--Dial memory \"%s\".", param->out_call.num_or_loc);
// AG found phone number by memory position
bool num_found = true;
if (num_found) {
char *number = "123456";
esp_hf_ag_cmee_send(param->out_call.remote_addr, ESP_HF_AT_RESPONSE_CODE_OK, ESP_HF_CME_AG_FAILURE);
esp_hf_ag_out_call(param->out_call.remote_addr,1,0,1,0,number,0);
} else {
esp_hf_ag_cmee_send(param->out_call.remote_addr, ESP_HF_AT_RESPONSE_CODE_CME, ESP_HF_CME_MEMORY_FAILURE);
}
}
} else { } else {
//dia_last //dia_last
//refer to dia_mem
ESP_LOGI(BT_HF_TAG, "--Dial last number."); ESP_LOGI(BT_HF_TAG, "--Dial last number.");
} }
break; break;
@ -462,6 +478,11 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
ESP_LOGI(BT_HF_TAG, "--Consequence of codec negotiation: %s",c_codec_mode_str[param->bcs_rep.mode]); ESP_LOGI(BT_HF_TAG, "--Consequence of codec negotiation: %s",c_codec_mode_str[param->bcs_rep.mode]);
break; break;
} }
case ESP_HF_PKT_STAT_NUMS_GET_EVT:
{
ESP_LOGI(BT_HF_TAG, "ESP_HF_PKT_STAT_NUMS_GET_EVT: %d.", event);
break;
}
default: default:
ESP_LOGI(BT_HF_TAG, "Unsupported HF_AG EVT: %d.", event); ESP_LOGI(BT_HF_TAG, "Unsupported HF_AG EVT: %d.", event);

View File

@ -0,0 +1,11 @@
# Override some defaults so BT stack is enabled and
# Classic BT is enabled and BT_DRAM_RELEASE is disabled
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_ENABLED=n
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN=1
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_HFP_ENABLE=y
CONFIG_BT_HFP_AG_ENABLE=y
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@ -48,6 +48,7 @@ const char *c_hf_evt_str[] = {
"INBAND_RING_TONE_EVT", /*!< in-band ring tone settings */ "INBAND_RING_TONE_EVT", /*!< in-band ring tone settings */
"LAST_VOICE_TAG_NUMBER_EVT", /*!< requested number from AG event */ "LAST_VOICE_TAG_NUMBER_EVT", /*!< requested number from AG event */
"RING_IND_EVT", /*!< ring indication event */ "RING_IND_EVT", /*!< ring indication event */
"PKT_STAT_EVT", /*!< requested number of packet status event */
}; };
// esp_hf_client_connection_state_t // esp_hf_client_connection_state_t
@ -228,7 +229,7 @@ static void bt_app_hf_client_incoming_cb(const uint8_t *buf, uint32_t sz)
/* callback for HF_CLIENT */ /* callback for HF_CLIENT */
void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param) void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param)
{ {
if (event <= ESP_HF_CLIENT_RING_IND_EVT) { if (event <= ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT) {
ESP_LOGI(BT_HF_TAG, "APP HFP event: %s", c_hf_evt_str[event]); ESP_LOGI(BT_HF_TAG, "APP HFP event: %s", c_hf_evt_str[event]);
} else { } else {
ESP_LOGE(BT_HF_TAG, "APP HFP invalid event %d", event); ESP_LOGE(BT_HF_TAG, "APP HFP invalid event %d", event);
@ -393,7 +394,11 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
(param->binp.number == NULL) ? "NULL" : param->binp.number); (param->binp.number == NULL) ? "NULL" : param->binp.number);
break; break;
} }
case ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT:
{
ESP_LOGE(BT_HF_TAG, "ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT: %d", event);
break;
}
default: default:
ESP_LOGE(BT_HF_TAG, "HF_CLIENT EVT: %d", event); ESP_LOGE(BT_HF_TAG, "HF_CLIENT EVT: %d", event);
break; break;

View File

@ -0,0 +1,11 @@
# Override some defaults so BT stack is enabled and
# Classic BT is enabled and BT_DRAM_RELEASE is disabled
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_ENABLED=n
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN=1
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_HFP_ENABLE=y
CONFIG_BT_HFP_CLIENT_ENABLE=y
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y