mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
fix ag example outgoing callback not triggered
Closes https://github.com/espressif/esp-idf/issues/4967
This commit is contained in:
@ -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)
|
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||||
void esp_hf_outgoing_data_ready(void)
|
void esp_hf_outgoing_data_ready(void)
|
||||||
{
|
{
|
||||||
BTA_AgCiData();
|
btc_hf_ci_sco_data();
|
||||||
}
|
}
|
||||||
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||||
|
|
||||||
|
@ -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
|
* 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;
|
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->event = BTA_AG_CI_SCO_DATA_EVT;
|
||||||
|
p_buf->layer_specific = handle;
|
||||||
bta_sys_sendmsg(p_buf);
|
bta_sys_sendmsg(p_buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
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)
|
if (status == BTM_CMD_STARTED)
|
||||||
{
|
{
|
||||||
@ -760,21 +761,18 @@ static void bta_ag_sco_event(tBTA_AG_SCB *p_scb, UINT8 event)
|
|||||||
p_buf->offset = pkt_offset;
|
p_buf->offset = pkt_offset;
|
||||||
len_to_send = bta_ag_sco_co_out_data(p_buf->data + pkt_offset);
|
len_to_send = bta_ag_sco_co_out_data(p_buf->data + pkt_offset);
|
||||||
p_buf->len = len_to_send;
|
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) {
|
if (p_sco->state == BTA_AG_SCO_OPEN_ST) {
|
||||||
tBTM_STATUS write_stat = BTM_WriteScoData(p_sco->p_curr_scb->sco_idx, p_buf);
|
tBTM_STATUS write_stat = BTM_WriteScoData(p_sco->p_curr_scb->sco_idx, p_buf);
|
||||||
if (write_stat != BTM_SUCCESS) {
|
if (write_stat != BTM_SUCCESS) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
osi_free(p_buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
osi_free(p_buf);
|
osi_free(p_buf);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
osi_free(p_buf);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -582,7 +582,7 @@ void BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec);
|
|||||||
** Returns void
|
** Returns void
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void BTA_AgCiData(void);
|
void BTA_AgCiData(UINT16 handle);
|
||||||
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -873,6 +873,22 @@ update_call_states:
|
|||||||
return status;
|
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
|
** Memory malloc and release
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
@ -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);
|
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_INCLUDED == TRUE
|
||||||
|
|
||||||
#endif /* __BTC_HF_AG_H__ */
|
#endif /* __BTC_HF_AG_H__ */
|
||||||
|
@ -441,6 +441,9 @@ tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf)
|
|||||||
p_buf->len += HCI_SCO_PREAMBLE_SIZE;
|
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_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);
|
fixed_queue_enqueue(p_ccb->xmit_data_q, p_buf, FIXED_QUEUE_MAX_TIMEOUT);
|
||||||
btm_sco_check_send_pkts (sco_inx);
|
btm_sco_check_send_pkts (sco_inx);
|
||||||
} else {
|
} else {
|
||||||
@ -454,7 +457,7 @@ tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf)
|
|||||||
status = BTM_UNKNOWN_ADDR;
|
status = BTM_UNKNOWN_ADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != BTM_SUCCESS) {
|
if (status != BTM_SUCCESS && status!= BTM_NO_RESOURCES) {
|
||||||
BTM_TRACE_WARNING ("stat %d", status);
|
BTM_TRACE_WARNING ("stat %d", status);
|
||||||
osi_free(p_buf);
|
osi_free(p_buf);
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,8 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
tBTM_ESCO_INFO esco; /* Current settings */
|
tBTM_ESCO_INFO esco; /* Current settings */
|
||||||
#if BTM_SCO_HCI_INCLUDED == TRUE
|
#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 */
|
fixed_queue_t *xmit_data_q; /* SCO data transmitting queue */
|
||||||
INT16 sent_not_acked;
|
INT16 sent_not_acked;
|
||||||
#endif
|
#endif
|
||||||
|
@ -119,9 +119,9 @@ static const int16_t sine_int16[] = {
|
|||||||
#define TABLE_SIZE_CVSD 100
|
#define TABLE_SIZE_CVSD 100
|
||||||
static uint32_t bt_app_hf_outgoing_cb(uint8_t *p_buf, uint32_t sz)
|
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] = sine_int16[sine_phase];
|
||||||
p_buf[i * 2 + 1] = sine_int16[sine_phase];
|
p_buf[i * 2 + 1] = sine_int16[sine_phase];
|
||||||
++sine_phase;
|
++sine_phase;
|
||||||
@ -131,7 +131,7 @@ static uint32_t bt_app_hf_outgoing_cb(uint8_t *p_buf, uint32_t sz)
|
|||||||
}
|
}
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bt_app_hf_incoming_cb(const uint8_t *buf, uint32_t sz)
|
static void bt_app_hf_incoming_cb(const uint8_t *buf, uint32_t sz)
|
||||||
{
|
{
|
||||||
// direct to i2s
|
// direct to i2s
|
||||||
|
Reference in New Issue
Block a user