📄 aud_bt_hfp.c
字号:
if (aud_bt_hfp_ctx.next_cmd == AUD_BT_HFP_CMD_NONE)
{
if (aud_bt_hfp_ctx.state == AUD_BT_HFP_STATE_IDLE)
{
bt_hfg_send_sco_connect_req(MOD_MED, aud_bt_hfp_ctx.connect_id);
}
else
{
processed = KAL_FALSE;
}
}
if (processed)
{
aud_bt_hfp_ctx.next_cmd = AUD_BT_HFP_CMD_CONNECT_SCO;
}
return processed;
}
/*****************************************************************************
* FUNCTION
* aud_bt_hfp_sco_connect_cnf_hdlr
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_bt_hfp_sco_connect_cnf_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
bt_hfg_sco_connect_cnf_struct *msg_p = (bt_hfg_sco_connect_cnf_struct*) ilm_ptr->local_para_ptr;
kal_bool next_disc = (aud_bt_hfp_ctx.next_cmd == AUD_BT_HFP_CMD_DISCONNECT_SCO);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_HFP_FUNC_ENTRY3( AUD_BT_HFP_SCO_CONNECT_CNF_HDLR, aud_bt_hfp_ctx.state, aud_bt_hfp_ctx.audio_path_on, msg_p->result)
aud_bt_hfp_ctx.next_cmd = AUD_BT_HFP_CMD_NONE;
if (msg_p->result == BT_HFG_RESULT_OK)
{
AUD_BT_HFP_ENTER_STATE(AUD_BT_HFP_STATE_OPEN);
aud_send_bt_audio_open_ind(aud_bt_hfp_ctx.src_mod_id, BT_HFP);
if (next_disc)
{
aud_bt_hfp_sco_disconnect_req();
}
else
{
/* check if it's disabled */
if (aud_bt_hfp_ctx.disabled)
{
return;
}
aud_bt_hfp_set_audio_path(KAL_TRUE);
}
}
else
{
aud_send_bt_audio_open_cnf(aud_bt_hfp_ctx.src_mod_id, BT_HFP, MED_RES_FAIL);
if (next_disc)
{
aud_send_bt_audio_close_ind(aud_bt_hfp_ctx.src_mod_id, BT_HFP, MED_RES_OK);
}
}
}
/*****************************************************************************
* FUNCTION
* aud_bt_hfp_sco_connect_ind_hdlr
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_bt_hfp_sco_connect_ind_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/* bt_hfg_sco_connect_ind_struct *msg_p = (bt_hfg_sco_connect_ind_struct*)ilm_ptr->local_para_ptr; */
kal_bool next_disc = (aud_bt_hfp_ctx.next_cmd == AUD_BT_HFP_CMD_DISCONNECT_SCO);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_HFP_FUNC_ENTRY2(AUD_BT_HFP_SCO_CONNECT_IND_HDLR, aud_bt_hfp_ctx.state, aud_bt_hfp_ctx.audio_path_on)
ASSERT(aud_bt_hfp_ctx.state == AUD_BT_HFP_STATE_IDLE);
aud_bt_hfp_ctx.next_cmd = AUD_BT_HFP_CMD_NONE;
AUD_BT_HFP_ENTER_STATE(AUD_BT_HFP_STATE_OPEN);
aud_send_bt_audio_open_ind(aud_bt_hfp_ctx.src_mod_id, BT_HFP);
if (next_disc)
{
aud_bt_hfp_sco_disconnect_req();
}
else
{
/* check if it's disabled */
if (aud_bt_hfp_ctx.disabled)
{
return;
}
aud_bt_hfp_set_audio_path(KAL_TRUE);
}
}
/*****************************************************************************
* FUNCTION
* aud_bt_hfp_sco_disconnect_req
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
*
*****************************************************************************/
kal_bool aud_bt_hfp_sco_disconnect_req(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_bool processed = KAL_TRUE;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (aud_bt_hfp_ctx.next_cmd == AUD_BT_HFP_CMD_NONE)
{
if (aud_bt_hfp_ctx.state == AUD_BT_HFP_STATE_OPEN)
{
bt_hfg_send_sco_disconnect_req(MOD_MED, aud_bt_hfp_ctx.connect_id);
}
else
{
processed = KAL_FALSE;
}
}
if (processed)
{
aud_bt_hfp_ctx.next_cmd = AUD_BT_HFP_CMD_DISCONNECT_SCO;
}
return processed;
}
/*****************************************************************************
* FUNCTION
* aud_bt_hfp_sco_disconnect_cnf_hdlr
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_bt_hfp_sco_disconnect_cnf_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
bt_hfg_sco_disconnect_cnf_struct *msg_p = (bt_hfg_sco_disconnect_cnf_struct*) ilm_ptr->local_para_ptr;
kal_uint16 result;
kal_bool next_conn = (aud_bt_hfp_ctx.next_cmd == AUD_BT_HFP_CMD_CONNECT_SCO);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_HFP_FUNC_ENTRY3(
AUD_BT_HFP_SCO_DISCONNECT_CNF_HDLR,
aud_bt_hfp_ctx.state,
aud_bt_hfp_ctx.audio_path_on,
msg_p->result)
if (aud_bt_hfp_ctx.state == AUD_BT_HFP_STATE_IDLE)
return;
aud_bt_hfp_ctx.next_cmd = AUD_BT_HFP_CMD_NONE;
AUD_BT_HFP_ENTER_STATE(AUD_BT_HFP_STATE_IDLE);
if (msg_p->result == BT_HFG_RESULT_OK)
{
result = MED_RES_OK;
}
else
{
result = MED_RES_FAIL;
}
aud_bt_hfp_set_audio_path(KAL_FALSE);
aud_send_bt_audio_close_ind(aud_bt_hfp_ctx.src_mod_id, BT_HFP, result);
/* check if it's disabled */
if (aud_bt_hfp_ctx.disabled)
{
return;
}
if (next_conn)
{
aud_bt_hfp_sco_connect_req();
}
}
/*****************************************************************************
* FUNCTION
* aud_bt_hfp_sco_disconnect_ind_hdlr
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_bt_hfp_sco_disconnect_ind_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/* bt_hfg_sco_disconnect_ind_struct *msg_p = (bt_hfg_sco_disconnect_ind_struct*)ilm_ptr->local_para_ptr; */
kal_bool next_conn = (aud_bt_hfp_ctx.next_cmd == AUD_BT_HFP_CMD_CONNECT_SCO);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_HFP_FUNC_ENTRY2(AUD_BT_HFP_SCO_DISCONNECT_IND_HDLR, aud_bt_hfp_ctx.state, aud_bt_hfp_ctx.audio_path_on)
if (aud_bt_hfp_ctx.state == AUD_BT_HFP_STATE_IDLE)
return;
aud_bt_hfp_ctx.next_cmd = AUD_BT_HFP_CMD_NONE;
AUD_BT_HFP_ENTER_STATE(AUD_BT_HFP_STATE_IDLE);
aud_bt_hfp_set_audio_path(KAL_FALSE);
aud_send_bt_audio_close_ind(aud_bt_hfp_ctx.src_mod_id, BT_HFP, MED_RES_HFP_CLOSE);
/* check if it's disabled */
if (aud_bt_hfp_ctx.disabled)
{
return;
}
if (next_conn)
{
aud_bt_hfp_sco_connect_req();
}
}
/*****************************************************************************
* FUNCTION
* aud_bt_hfp_is_audio_path_on
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
*
*****************************************************************************/
kal_bool aud_bt_hfp_is_audio_path_on(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_HFP_FUNC_ENTRY2(AUD_BT_HFP_IS_AUDIO_PATH_ON, aud_bt_hfp_ctx.state, aud_bt_hfp_ctx.audio_path_on)
return aud_bt_hfp_ctx.audio_path_on;
}
/*****************************************************************************
* FUNCTION
* aud_bt_hfp_set_audio_path
* DESCRIPTION
*
* PARAMETERS
* on [IN]
* RETURNS
* void
*****************************************************************************/
void aud_bt_hfp_set_audio_path(kal_bool on)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_HFP_FUNC_ENTRY3(AUD_BT_HFP_SET_AUDIO_PATH, aud_bt_hfp_ctx.state, aud_bt_hfp_ctx.audio_path_on, on)
if ((aud_bt_hfp_ctx.audio_path_on && !on) || (!aud_bt_hfp_ctx.audio_path_on && on))
{
if (aud_context_p->speech_on)
{
L1SP_Speech_Off();
}
if (on)
{
L1SP_SetSpeechMode(SPH_MODE_BT_EARPHONE, aud_context_p->audio_param.speech_mode_para[SPH_MODE_BT_EARPHONE]);
}
else
{
L1SP_SetSpeechMode(
aud_context_p->audio_mode,
aud_context_p->audio_param.speech_mode_para[aud_context_p->audio_mode]);
}
if (aud_context_p->speech_on)
{
L1SP_Speech_On();
}
aud_bt_hfp_ctx.audio_path_on = on;
}
}
#endif /* __MED_BT_HFP_MOD__ */
#endif /* MED_NOT_PRESENT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -