Merge branch 'bugfix/fix_ag_outging_callback_not_triggered' into 'master'

Bugfix/Fix Ag Example Outgoing Callback Not Triggered

Closes BTCI-50

See merge request espressif/esp-idf!10828
This commit is contained in:
Jiang Jiang Jian 2020-10-28 19:57:02 +08:00
commit 6bed9ec70c
9 changed files with 40 additions and 18 deletions

View File

@ -522,7 +522,7 @@ esp_err_t esp_bt_hf_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_h
#if (BTM_SCO_HCI_INCLUDED == TRUE)
void esp_hf_outgoing_data_ready(void)
{
BTA_AgCiData();
btc_hf_ci_sco_data();
}
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */

View File

@ -307,11 +307,13 @@ void BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec)
* layer will invoke esp_hf_client_outgoing_data_cb_t to fetch data
*
***********************************************************************************************/
void BTA_AgCiData(void)
void BTA_AgCiData(UINT16 handle)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
tBTA_AG_SCB *p_scb;
if ((p_scb = bta_ag_scb_by_idx(handle)) != NULL && (p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_AG_CI_SCO_DATA_EVT;
p_buf->layer_specific = handle;
bta_sys_sendmsg(p_buf);
}
}

View File

@ -618,7 +618,8 @@ static void bta_ag_create_sco(tBTA_AG_SCB *p_scb, BOOLEAN is_orig)
p_bd_addr = p_scb->peer_addr;
status = BTM_CreateSco(p_bd_addr, is_orig, params.packet_types, &p_scb->sco_idx, bta_ag_sco_conn_cback, bta_ag_sco_disc_cback);
status = BTM_CreateSco(p_bd_addr, is_orig, params.packet_types, &p_scb->sco_idx, bta_ag_sco_conn_cback,
bta_ag_sco_disc_cback);
if (status == BTM_CMD_STARTED)
{
@ -760,23 +761,20 @@ static void bta_ag_sco_event(tBTA_AG_SCB *p_scb, UINT8 event)
p_buf->offset = pkt_offset;
len_to_send = bta_ag_sco_co_out_data(p_buf->data + pkt_offset);
p_buf->len = len_to_send;
if (len_to_send == p_scb->out_pkt_len)
{
if (len_to_send == p_scb->out_pkt_len) {
if (p_sco->state == BTA_AG_SCO_OPEN_ST) {
tBTM_STATUS write_stat = BTM_WriteScoData(p_sco->p_curr_scb->sco_idx, p_buf);
if (write_stat != BTM_SUCCESS) {
break;
}
else {
} else {
osi_free(p_buf);
}
}
else {
} else {
osi_free(p_buf);
break;
}
}
}
return;
}
#endif

View File

@ -582,7 +582,7 @@ void BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec);
** Returns void
**
*******************************************************************************/
void BTA_AgCiData(void);
void BTA_AgCiData(UINT16 handle);
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */
#ifdef __cplusplus

View File

@ -873,6 +873,22 @@ update_call_states:
return status;
}
bt_status_t btc_hf_ci_sco_data(void)
{
bt_status_t status = BT_STATUS_SUCCESS;
#if (BTM_SCO_HCI_INCLUDED == TRUE)
int idx = btc_hf_latest_connected_idx();
CHECK_HF_SLC_CONNECTED();
if (idx != BTC_HF_INVALID_IDX) {
BTA_AgCiData(hf_local_param[idx].btc_hf_cb.handle);
return status;
}
status = BT_STATUS_FAIL;
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */
return status;
}
/************************************************************************************
** Memory malloc and release
************************************************************************************/

View File

@ -253,6 +253,8 @@ void btc_hf_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_hf_arg_deep_free(btc_msg_t *msg);
bt_status_t btc_hf_ci_sco_data(void);
#endif // BTC_HF_INCLUDED == TRUE
#endif /* __BTC_HF_AG_H__ */

View File

@ -441,6 +441,9 @@ tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf)
p_buf->len += HCI_SCO_PREAMBLE_SIZE;
if (fixed_queue_length(p_ccb->xmit_data_q) < BTM_SCO_XMIT_QUEUE_THRS) {
if (fixed_queue_length(p_ccb->xmit_data_q) >= BTM_SCO_XMIT_QUEUE_HIGH_WM) {
status = BTM_NO_RESOURCES;
}
fixed_queue_enqueue(p_ccb->xmit_data_q, p_buf, FIXED_QUEUE_MAX_TIMEOUT);
btm_sco_check_send_pkts (sco_inx);
} else {
@ -454,7 +457,7 @@ tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf)
status = BTM_UNKNOWN_ADDR;
}
if (status != BTM_SUCCESS) {
if (status != BTM_SUCCESS && status!= BTM_NO_RESOURCES) {
BTM_TRACE_WARNING ("stat %d", status);
osi_free(p_buf);
}

View File

@ -422,7 +422,8 @@ typedef struct {
typedef struct {
tBTM_ESCO_INFO esco; /* Current settings */
#if BTM_SCO_HCI_INCLUDED == TRUE
#define BTM_SCO_XMIT_QUEUE_THRS 20
#define BTM_SCO_XMIT_QUEUE_THRS 30
#define BTM_SCO_XMIT_QUEUE_HIGH_WM 20
fixed_queue_t *xmit_data_q; /* SCO data transmitting queue */
INT16 sent_not_acked;
#endif

View File

@ -119,9 +119,9 @@ static const int16_t sine_int16[] = {
#define TABLE_SIZE_CVSD 100
static uint32_t bt_app_hf_outgoing_cb(uint8_t *p_buf, uint32_t sz)
{
int sine_phase = esp_random();
static int sine_phase = 0;
for (int i = 0; i < TABLE_SIZE_CVSD; i++) {
for (int i = 0; i * 2 + 1 < sz; i++) {
p_buf[i * 2] = sine_int16[sine_phase];
p_buf[i * 2 + 1] = sine_int16[sine_phase];
++sine_phase;