Merge branch 'bugfix/hf_ag_report_event_with_null_bdaddr_v4.4' into 'release/v4.4'

Bugfix/fixed bugs of HFP in BlueDroid (v4.4)

See merge request espressif/esp-idf!25829
This commit is contained in:
Wang Meng Yang 2023-10-11 19:14:59 +08:00
commit c1d9e6197c
26 changed files with 761 additions and 251 deletions

View File

@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <stdlib.h>
@ -528,10 +520,30 @@ esp_err_t esp_bt_hf_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_h
}
#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_outgoing_data_ready(void)
{
btc_hf_ci_sco_data();
}
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */
#endif // BTC_HF_INCLUDED

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "common/bt_target.h"
#include <string.h>
@ -470,8 +462,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;
}
#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)
{
BTA_HfClientCiData();
@ -492,6 +503,6 @@ int32_t esp_hf_client_pcm_resample(void *src, uint32_t in_bytes, void *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 */

View File

@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_HF_AG_API_H__
#define __ESP_HF_AG_API_H__
@ -70,13 +62,22 @@ typedef enum
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_BCS_RESPONSE_EVT, /*!< Final Codec Choice */
ESP_HF_PKT_STAT_NUMS_GET_EVT, /*!< Request number of packet different status */
} 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
typedef union
{
/**
* @brief ESP_HS_CONNECTION_STATE_EVT
* @brief ESP_HF_CONNECTION_STATE_EVT
*/
struct hf_conn_stat_param {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
@ -91,6 +92,7 @@ typedef union
struct hf_audio_stat_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
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 */
/**
@ -105,6 +107,7 @@ typedef union
* @brief ESP_HF_VOLUME_CONTROL_EVT
*/
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 */
int volume; /*!< Gain, ranges from 0 to 15 */
} volume_control; /*!< AG callback param of ESP_HF_VOLUME_CONTROL_EVT */
@ -113,48 +116,89 @@ typedef union
* @brief ESP_HF_UNAT_RESPOSNE_EVT
*/
struct hf_unat_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
char *unat; /*!< Unknown AT command string */
}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 */
} unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */
/**
* @brief ESP_HF_DIAL_EVT
*/
struct hf_out_call_param {
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 */
} out_call; /*!< AG callback param of ESP_HF_DIAL_EVT */
/**
* @brief ESP_HF_VTS_RESPOSNE_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
*/
struct hf_vts_rep_param {
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
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_RESPOSNE_EVT
*/
struct hf_nrec_param {
esp_hf_nrec_t state; /*!< NREC enabled or disabled */
esp_bd_addr_t remote_addr; /*!< Remote bluetooth device address */
esp_hf_nrec_t state; /*!< NREC enabled or disabled */
} 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
*/
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 */
} wbs_rep; /*!< AG callback param of ESP_HF_WBS_RESPONSE_EVT */
@ -162,9 +206,23 @@ typedef union
* @brief ESP_HF_BCS_RESPONSE_EVT
*/
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 */
} 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*/
/**
@ -598,6 +656,22 @@ esp_err_t esp_bt_hf_end_call(esp_bd_addr_t remote_addr, int num_active, int num_
*/
esp_err_t esp_bt_hf_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.

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_HF_CLIENT_API_H__
#define __ESP_HF_CLIENT_API_H__
@ -96,6 +88,7 @@ typedef enum {
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_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;
/// HFP client callback parameters
@ -116,6 +109,7 @@ typedef union {
struct hf_client_audio_stat_param {
esp_hf_client_audio_state_t state; /*!< audio connection state */
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 */
/**
@ -251,6 +245,19 @@ typedef union {
const char *number; /*!< phone number corresponding to the last voice tag in the HF */
} 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 */
/**
@ -508,7 +515,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.
*
* @return
@ -617,6 +624,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_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.
* 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
@ -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
*
@ -317,6 +339,6 @@ void BTA_AgCiData(UINT16 handle)
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)*/

View File

@ -146,6 +146,14 @@ enum
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 */
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:
{
UINT16 src = 0;
UINT16 dst = 0;
/* 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(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;
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') {
/* ATDV : Dial VoIP Call */
/* 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;
bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED);
}
val.value = BTA_AG_HF_DIAL_VOIP;
} else {
/* If dial cmd, make sure string contains only dial digits
** 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;
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;
}

View File

@ -91,6 +91,7 @@ enum
BTA_AG_CI_SCO_DATA,
BTA_AG_CI_RX_DATA,
BTA_AG_RCVD_SLC_READY,
BTA_AG_PKT_STAT_NUMS,
BTA_AG_NUM_ACTIONS
};
@ -133,7 +134,8 @@ const tBTA_AG_ACTION bta_ag_action[] =
bta_ag_send_ring,
bta_ag_ci_sco_data,
bta_ag_ci_rx_data,
bta_ag_rcvd_slc_ready
bta_ag_rcvd_slc_ready,
bta_ag_pkt_stat_nums
};
/* 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},
/* 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_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 */
@ -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},
/* 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_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 */
@ -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},
/* 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_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 */
@ -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},
/* 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_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 */
@ -357,6 +363,8 @@ static char *bta_ag_evt_str(UINT16 event, tBTA_AG_RES result)
return "SCO data Callin";
case BTA_AG_CI_SLC_READY_EVT:
return "SLC Ready Callin";
case BTA_AG_PKT_STAT_NUMS_GET_EVT:
return "Get Packet Nums";
default:
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)
{
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. */
@ -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.app_id = p_scb->app_id;
sco.sync_conn_handle = BTM_ReadScoHandle(p_scb->sco_idx);
/* call close cback */
(*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
/*******************************************************************************
**
** 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

View File

@ -113,6 +113,7 @@ enum
BTA_AG_SVC_TOUT_EVT,
BTA_AG_CI_SCO_DATA_EVT,
BTA_AG_CI_SLC_READY_EVT,
BTA_AG_PKT_STAT_NUMS_GET_EVT,
BTA_AG_MAX_EVT,
/* these events are handled outside of the state machine */
@ -218,6 +219,13 @@ typedef struct
char p_data[BTA_AG_MTU+1];
} 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 */
typedef union
{
@ -232,6 +240,7 @@ typedef union
tBTA_AG_DISC_RESULT disc_result;
tBTA_AG_RFC rfc;
tBTA_AG_CI_RX_WRITE ci_rx_write;
tBTA_AG_PKT_STAT_GET pkt_stat;
} tBTA_AG_DATA;
/* type for each profile */
@ -276,7 +285,7 @@ typedef struct
tBTA_AG_SCO_MSBC_SETTINGS codec_msbc_settings; /* settings to be used for the impending eSCO */
TIMER_LIST_ENT cn_timer; /* codec negotiation timer */
#endif
UINT16 sco_idx; /* SCO handle */
UINT16 sco_idx; /* SCO connection index */
BOOLEAN in_use; /* scb in use */
BOOLEAN dealloc; /* TRUE if service shutting down */
BOOLEAN clip_enabled; /* set to TRUE if HF enables CLIP reporting */
@ -437,6 +446,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_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_pkt_stat_nums(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data);
#endif /* #if (BTA_AG_INCLUDED == TRUE) */

View File

@ -294,7 +294,28 @@ void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val
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)
{
BT_HDR *p_buf;

View File

@ -75,6 +75,7 @@ enum {
BTA_HF_CLIENT_SEND_AT_CMD,
#if (BTM_SCO_HCI_INCLUDED == TRUE)
BTA_HF_CLIENT_CI_SCO_DATA,
BTA_HF_CLIENT_PKT_STAT_NUMS,
#endif
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_SVC_CONN_OPEN */ bta_hf_client_svc_conn_open,
/* 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 */ bta_hf_client_pkt_stat_nums,
#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},
#if (BTM_SCO_HCI_INCLUDED == TRUE )
/* 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 ) */
};
@ -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_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},
#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},
/* 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 ) */
};
@ -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},
#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},
/* 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 ) */
};
@ -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},
#if (BTM_SCO_HCI_INCLUDED == TRUE )
/* 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 ) */
};
@ -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_CLOSE_EVT)
CASE_RETURN_STR(BTA_HF_CLIENT_SEND_AT_CMD_EVT)
CASE_RETURN_STR(BTA_HF_CLIENT_PKT_NUMS_GET_EVT)
default:
return "Unknown HF Client Event";
}

View File

@ -155,6 +155,7 @@ void bta_hf_client_cback_sco(UINT8 event)
tBTA_HF_CLIENT_HDR evt;
memset(&evt, 0, sizeof(evt));
evt.sync_conn_handle = BTM_ReadScoHandle(bta_hf_client_cb.scb.sco_idx);
/* call app cback */
(*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);
}
#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
@ -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);
}
#endif
/*******************************************************************************
**
** Function bta_hf_client_sco_connreq_cback

View File

@ -64,6 +64,7 @@ enum {
BTA_HF_CLIENT_SEND_AT_CMD_EVT,
#if (BTM_SCO_HCI_INCLUDED == TRUE )
BTA_HF_CLIENT_CI_SCO_DATA_EVT,
BTA_HF_CLIENT_PKT_NUMS_GET_EVT,
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
BTA_HF_CLIENT_MAX_EVT,
@ -120,6 +121,12 @@ typedef struct {
char str[BTA_HF_CLIENT_NUMBER_LEN + 1];
} 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 */
typedef union {
BT_HDR hdr;
@ -129,6 +136,7 @@ typedef union {
tBTA_HF_CLIENT_DISC_RESULT disc_result;
tBTA_HF_CLIENT_RFC rfc;
tBTA_HF_CLIENT_DATA_VAL val;
tBTA_HF_CLIENT_PKT_STAT_GET pkt_stat;
} tBTA_HF_CLIENT_DATA;
@ -299,6 +307,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_send_at_cmd(tBTA_HF_CLIENT_DATA *p_data);
#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);
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
#endif /* #if (BTA_HF_INCLUDED == TRUE) */

View File

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

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_RING_INDICATION 21 /* HF Client ring indication */
#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;
@ -159,6 +160,7 @@ typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE;
/* data associated with most non-AT events */
/* placeholder, if not needed should be removed*/
typedef struct {
UINT16 sync_conn_handle;
} tBTA_HF_CLIENT_HDR;
/* data associated with BTA_HF_CLIENT_REGISTER_EVT */
@ -228,6 +230,17 @@ typedef struct {
UINT16 value;
} tBTA_HF_CLIENT_VAL;
/* data associated with BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT */
typedef struct {
UINT32 rx_total;
UINT32 rx_correct;
UINT32 rx_err;
UINT32 rx_none;
UINT32 rx_lost;
UINT32 tx_total;
UINT32 tx_discarded;
} tBTA_SCO_PKT_STAT_NUMS;
/* union of data associated with AG callback */
typedef union {
tBTA_HF_CLIENT_HDR hdr;
@ -241,6 +254,7 @@ typedef union {
tBTA_HF_CLIENT_AT_RESULT result;
tBTA_HF_CLIENT_CLCC clcc;
tBTA_HF_CLIENT_CNUM cnum;
tBTA_SCO_PKT_STAT_NUMS pkt_num;
} tBTA_HF_CLIENT;
typedef UINT32 tBTA_HF_CLIENT_FEAT;
@ -376,6 +390,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);
#if (BTM_SCO_HCI_INCLUDED == TRUE )
/*******************************************************************************
**
** Function BTA_HfClientPktStatsNumsGet
**
** Description Get the Number of packets status received and send
**
**
** Returns void
**
*******************************************************************************/
void BTA_HfClientPktStatsNumsGet(UINT16 sync_conn_handle);
void BTA_HfClientCiData(void);
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */

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
*/
@ -193,37 +193,6 @@ static void send_indicator_update(UINT16 indicator, UINT16 value)
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)
{
int param_len = 0;
@ -429,6 +398,21 @@ bt_status_t btc_hf_disconnect_audio(bt_bdaddr_t *bd_addr)
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
************************************************************************************/
@ -1194,8 +1178,13 @@ void btc_hf_call_handler(btc_msg_t *msg)
case BTC_HF_REGISTER_DATA_CALLBACK_EVT:
{
btc_hf_reg_data_cb(arg->reg_data_cb.recv, arg->reg_data_cb.send);
}
break;
}
case BTC_HF_REQUEST_PKT_STAT_EVT:
{
btc_hf_pkt_stat_nums_get(arg->pkt_sync_hd.sync_conn_handle);
break;
}
default:
BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act);
@ -1213,6 +1202,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
BTC_TRACE_DEBUG("%s: event = %s", __FUNCTION__, dump_hf_event(event));
memset(&param, 0, sizeof(esp_hf_cb_param_t));
switch (event) {
case BTA_AG_ENABLE_EVT:
case BTA_AG_DISABLE_EVT:
@ -1249,7 +1240,6 @@ void btc_hf_cb_handler(btc_msg_t *msg)
}
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));
param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state;
param.conn_stat.peer_feat = 0;
@ -1276,7 +1266,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;
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.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;
@ -1297,7 +1286,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__,
idx, hf_local_param[idx].btc_hf_cb.handle);
do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.conn_stat.state = ESP_HF_CONNECTION_STATE_DISCONNECTED;
param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0;
@ -1316,9 +1304,9 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
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));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
} while(0);
break;
@ -1329,9 +1317,9 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
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));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
} while (0);
break;
@ -1341,9 +1329,9 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
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));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
} while(0);
break;
@ -1354,8 +1342,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memset(&param, 0, sizeof(esp_hf_cb_param_t));
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);
if (p_data->val.num) {
btc_hf_connect_audio(&hf_local_param[idx].btc_hf_cb.connected_bda);
@ -1369,8 +1357,10 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_SPK_EVT:
case BTA_AG_MIC_EVT:
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
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.volume = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_VOLUME_CONTROL_EVT, &param);
@ -1380,46 +1370,67 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_UNAT_EVT:
{
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.unat_rep.unat = p_data->val.str;
btc_hf_cb_to_app(ESP_HF_UNAT_RESPONSE_EVT, &param);
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;
btc_hf_cb_to_app(ESP_HF_UNAT_RESPONSE_EVT, &param);
} while (0);
break;
}
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;
}
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;
}
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;
}
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;
}
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;
}
case BTA_AG_AT_VTS_EVT:
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
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;
btc_hf_cb_to_app(ESP_HF_VTS_RESPONSE_EVT, &param);
} while(0);
@ -1428,8 +1439,10 @@ void btc_hf_cb_handler(btc_msg_t *msg)
case BTA_AG_AT_NREC_EVT:
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
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;
btc_hf_cb_to_app(ESP_HF_NREC_RESPONSE_EVT, &param);
} while(0);
@ -1438,29 +1451,39 @@ void btc_hf_cb_handler(btc_msg_t *msg)
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;
}
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;
}
case BTA_AG_AT_BLDN_EVT:
case BTA_AG_AT_D_EVT:
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
if (event == BTA_AG_AT_D_EVT && p_data->val.str) { // 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));
sprintf(param.out_call.num_or_loc, p_data->val.str);
btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param);
send_indicator_update(BTA_AG_IND_CALLSETUP,BTA_AG_CALLSETUP_OUTGOING);
osi_free(param.out_call.num_or_loc);
} 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);
}
} while(0);
@ -1503,23 +1526,37 @@ void btc_hf_cb_handler(btc_msg_t *msg)
#if (BTM_WBS_INCLUDED == TRUE)
case BTA_AG_WBS_EVT:
{
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));
param.wbs_rep.codec = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_WBS_RESPONSE_EVT, &param);
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);
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;
btc_hf_cb_to_app(ESP_HF_WBS_RESPONSE_EVT, &param);
} while (0);
break;
}
case BTA_AG_AT_BCS_EVT:
{
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));
param.bcs_rep.mode = p_data->val.num;
/* 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);
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);
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;
/* 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);
} while (0);
break;
}
#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:
BTC_TRACE_WARNING("%s: Unhandled event: %d", __FUNCTION__, event);
break;

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/******************************************************************************
**
@ -650,6 +642,24 @@ static bt_status_t btc_hf_client_send_nrec(void)
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
@ -775,6 +785,8 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
esp_hf_client_cb_param_t param;
bdstr_t bdstr;
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
switch (event)
{
case BTA_HF_CLIENT_ENABLE_EVT:
@ -805,7 +817,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
}
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.peer_feat = 0;
param.conn_stat.chld_feat = 0;
@ -831,7 +842,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;
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.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;
@ -846,7 +856,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)
{
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.bsir.state = ESP_HF_CLIENT_IN_BAND_RINGTONE_PROVIDED;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_BSIR_EVT, &param);
} while (0);
@ -858,7 +867,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
case BTA_HF_CLIENT_CLOSE_EVT:
hf_client_local_param.btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.conn_stat.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0;
@ -879,7 +887,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break;
case BTA_HF_CLIENT_MIC_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.volume_control.type = ESP_HF_VOLUME_CONTROL_TARGET_MIC;
param.volume_control.volume = p_data->val.value;
@ -888,7 +895,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break;
case BTA_HF_CLIENT_SPK_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.volume_control.type = ESP_HF_VOLUME_CONTROL_TARGET_SPK;
param.volume_control.volume = p_data->val.value;
@ -897,7 +903,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break;
case BTA_HF_CLIENT_VOICE_REC_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.bvra.value = p_data->val.value;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_BVRA_EVT, &param);
@ -905,35 +910,30 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break;
case BTA_HF_CLIENT_OPERATOR_NAME_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.cops.name = p_data->operator.name;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT, &param);
} while (0);
break;
case BTA_HF_CLIENT_CLIP_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.clip.number = p_data->number.number;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CLIP_EVT, &param);
} while (0);
break;
case BTA_HF_CLIENT_BINP_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.binp.number = p_data->number.number;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_BINP_EVT, &param);
} while (0);
break;
case BTA_HF_CLIENT_CCWA_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.ccwa.number = p_data->number.number;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CCWA_EVT, &param);
} while (0);
break;
case BTA_HF_CLIENT_AT_RESULT_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.at_response.code = p_data->result.type;
param.at_response.cme = p_data->result.cme;
@ -942,7 +942,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break;
case BTA_HF_CLIENT_CLCC_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.clcc.idx = p_data->clcc.idx;
param.clcc.dir = p_data->clcc.inc ? ESP_HF_CURRENT_CALL_DIRECTION_INCOMING :
ESP_HF_CURRENT_CALL_DIRECTION_OUTGOING;
@ -955,7 +954,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break;
case BTA_HF_CLIENT_CNUM_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.cnum.number = p_data->cnum.number;
if (p_data->cnum.service == 4) {
param.cnum.type = ESP_HF_SUBSCRIBER_SERVICE_TYPE_VOICE;
@ -971,7 +969,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
case BTA_HF_CLIENT_BTRH_EVT:
if (p_data->val.value <= ESP_HF_BTRH_STATUS_REJECTED) {
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.btrh.status = p_data->val.value;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_BTRH_EVT, &param);
@ -979,7 +976,6 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
}
break;
case BTA_HF_CLIENT_BSIR_EVT:
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
if (p_data->val.value != 0)
{
param.bsir.state = ESP_HF_CLIENT_IN_BAND_RINGTONE_PROVIDED;
@ -992,28 +988,28 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
break;
case BTA_HF_CLIENT_AUDIO_OPEN_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
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,
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);
} while (0);
break;
case BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
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,
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);
} while (0);
break;
case BTA_HF_CLIENT_AUDIO_CLOSE_EVT:
do {
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
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,
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);
} while (0);
break;
@ -1022,6 +1018,12 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
btc_hf_client_cb_to_app(ESP_HF_CLIENT_RING_IND_EVT, NULL);
} while (0);
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:
BTC_TRACE_WARNING("%s: Unhandled event: %d", __FUNCTION__, event);
break;
@ -1099,6 +1101,9 @@ void btc_hf_client_call_handler(btc_msg_t *msg)
case BTC_HF_CLIENT_SEND_NREC_EVT:
btc_hf_client_send_nrec();
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:
BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act);
}

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*******************************************************************************
*
@ -63,7 +55,8 @@ typedef enum
BTC_HF_OUT_CALL_EVT,
BTC_HF_END_CALL_EVT,
//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_args_t */
@ -194,6 +187,11 @@ typedef union
esp_hf_outgoing_data_cb_t send;
} 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;
/************************************************************************************

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*******************************************************************************
@ -58,6 +50,7 @@ typedef enum {
BTC_HF_CLIENT_REQUEST_LAST_VOICE_TAG_NUMBER_EVT,
BTC_HF_CLIENT_REGISTER_DATA_CALLBACK_EVT,
BTC_HF_CLIENT_SEND_NREC_EVT,
BTC_HF_CLIENT_REQUEST_PKT_STAT_EVT,
} btc_hf_client_act_t;
/* btc_hf_client_args_t */
@ -111,6 +104,12 @@ typedef union {
esp_hf_client_incoming_data_cb_t recv;
esp_hf_client_outgoing_data_cb_t send;
} reg_data_cb;
// 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;
/************************************************************************************

View File

@ -341,6 +341,82 @@ void btm_sco_process_num_completed_pkts (UINT8 *p)
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 && pkt_status != BTM_NO_RESOURCES && pkt_status != BTM_SCO_BAD_LENGTH) {
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 */
/*******************************************************************************
@ -374,6 +450,7 @@ void btm_route_sco_data(BT_HDR *p_msg)
{
osi_free (p_msg);
} 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);
}
} else { /* no mapping handle SCO connection is active, free the buffer */
@ -457,10 +534,11 @@ tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf)
status = BTM_UNKNOWN_ADDR;
}
if (status != BTM_SUCCESS && status!= BTM_NO_RESOURCES) {
if (status != BTM_SUCCESS && status!= BTM_NO_RESOURCES && status != BTM_SCO_BAD_LENGTH) {
BTM_TRACE_WARNING ("stat %d", status);
osi_free(p_buf);
}
btm_pkt_stat_send_nums_update(sco_inx, status);
return (status);
#else
@ -994,6 +1072,7 @@ void btm_sco_connected (UINT8 hci_status, BD_ADDR bda, UINT16 hci_handle,
}
#if BTM_SCO_HCI_INCLUDED == TRUE
p->sent_not_acked = 0;
btm_pkt_stat_nums_reset(xx);
#endif
p->state = SCO_ST_CONNECTED;
p->hci_handle = hci_handle;

View File

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

View File

@ -1062,6 +1062,17 @@ enum {
};
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
****************************/
@ -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);
/*******************************************************************************
**
** 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
}
#endif

View File

@ -1,10 +1,8 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <stdint.h>
#include <stdbool.h>
@ -46,6 +44,7 @@ const char *c_hf_evt_str[] = {
"DIAL_EVT", /*!< DIAL INCOMING EVT */
"WBS_EVT", /*!< CURRENT CODEC EVT */
"BCS_EVT", /*!< CODEC NEGO EVT */
"PKT_STAT_EVT", /*!< REQUEST PACKET STATUS EVT */
};
//esp_hf_connection_state_t
@ -213,7 +212,7 @@ static void bt_app_send_data_timer_cb(void *arg)
static void bt_app_send_data_task(void *arg)
{
uint64_t frame_data_num;
uint32_t item_size = 0;
size_t item_size = 0;
uint8_t *buf = NULL;
for (;;) {
if (xSemaphoreTake(s_send_data_Semaphore, (portTickType)portMAX_DELAY)) {
@ -276,14 +275,14 @@ void bt_app_send_data_shut_down(void)
vTaskDelete(s_bt_app_send_data_task_handler);
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) {
ESP_ERROR_CHECK(esp_timer_stop(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) {
vRingbufferDelete(s_m_rb);
}
@ -293,7 +292,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)
{
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]);
} else {
ESP_LOGE(BT_HF_TAG, "APP HFP invalid event %d", event);
@ -349,7 +348,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
case ESP_HF_UNAT_RESPONSE_EVT:
{
ESP_LOGI(BT_HF_TAG, "--UNKOW AT CMD: %s", param->unat_rep.unat);
esp_hf_unat_response(hf_peer_addr, NULL);
esp_hf_unat_response(param->unat_rep.remote_addr, NULL);
break;
}
@ -360,7 +359,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_network_state_t ntk_state = 1;
int signal = 2;
esp_bt_hf_indchange_notification(hf_peer_addr,call_state,call_setup_state,ntk_state,signal);
esp_bt_hf_indchange_notification(param->ind_upd.remote_addr,call_state,call_setup_state,ntk_state,signal);
break;
}
@ -374,14 +373,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;
int batt_lev = 3;
esp_hf_call_held_status_t call_held_status = 0;
esp_bt_hf_cind_response(hf_peer_addr,call_status,call_setup_status,ntk_state,signal,roam,batt_lev,call_held_status);
esp_bt_hf_cind_response(param->cind_rep.remote_addr,call_status,call_setup_status,ntk_state,signal,roam,batt_lev,call_held_status);
break;
}
case ESP_HF_COPS_RESPONSE_EVT:
{
const int svc_type = 1;
esp_bt_hf_cops_response(hf_peer_addr, c_operator_name_str[svc_type]);
esp_bt_hf_cops_response(param->cops_rep.remote_addr, c_operator_name_str[svc_type]);
break;
}
@ -398,7 +397,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_LOGI(BT_HF_TAG, "--Calling Line Identification.");
esp_bt_hf_clcc_response(hf_peer_addr, index, dir, current_call_status, mode, mpty, number, type);
esp_bt_hf_clcc_response(param->clcc_rep.remote_addr, index, dir, current_call_status, mode, mpty, number, type);
break;
}
@ -407,7 +406,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
char *number = {"123456"};
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_bt_hf_cnum_response(hf_peer_addr, number,type);
esp_bt_hf_cnum_response(param->cnum_rep.remote_addr, number,type);
break;
}
@ -427,7 +426,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.");
char *number = {"123456"};
esp_bt_hf_answer_call(hf_peer_addr,1,0,1,0,number,0);
esp_bt_hf_answer_call(param->ata_rep.remote_addr,1,0,1,0,number,0);
break;
}
@ -435,18 +434,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.");
char *number = {"123456"};
esp_bt_hf_reject_call(hf_peer_addr,0,0,0,0,number,0);
esp_bt_hf_reject_call(param->chup_rep.remote_addr,0,0,0,0,number,0);
break;
}
case ESP_HF_DIAL_EVT:
{
if (param->out_call.num_or_loc) {
//dia_num_or_mem
ESP_LOGI(BT_HF_TAG, "--Dial \"%s\".", param->out_call.num_or_loc);
esp_bt_hf_out_call(hf_peer_addr,1,0,1,0,param->out_call.num_or_loc,0);
if (param->out_call.type == ESP_HF_DIAL_NUM) {
// dia_num
ESP_LOGI(BT_HF_TAG, "--Dial number \"%s\".", param->out_call.num_or_loc);
esp_bt_hf_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_bt_hf_cmee_response(param->out_call.remote_addr, ESP_HF_AT_RESPONSE_CODE_OK, ESP_HF_CME_AG_FAILURE);
esp_bt_hf_out_call(param->out_call.remote_addr,1,0,1,0,number,0);
} else {
esp_bt_hf_cmee_response(param->out_call.remote_addr, ESP_HF_AT_RESPONSE_CODE_CME, ESP_HF_CME_MEMEORY_FAILURE);
}
}
} else {
//dia_last
//refer to dia_mem
ESP_LOGI(BT_HF_TAG, "--Dial last number.");
}
break;
@ -463,6 +477,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]);
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:
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,10 +1,8 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express esp_hf_ag_apiied.
*/
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <stdint.h>
#include <stdbool.h>
@ -49,6 +47,7 @@ const char *c_hf_evt_str[] = {
"INBAND_RING_TONE_EVT", /*!< in-band ring tone settings */
"LAST_VOICE_TAG_NUMBER_EVT", /*!< requested number from AG event */
"RING_IND_EVT", /*!< ring indication event */
"PKT_STAT_EVT", /*!< requested number of packet status event */
};
// esp_hf_client_connection_state_t
@ -229,7 +228,7 @@ static void bt_app_hf_client_incoming_cb(const uint8_t *buf, uint32_t sz)
/* callback for HF_CLIENT */
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]);
} else {
ESP_LOGE(BT_HF_TAG, "APP HFP invalid event %d", event);
@ -394,7 +393,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);
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:
ESP_LOGE(BT_HF_TAG, "HF_CLIENT EVT: %d", event);
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