有关Cordless Mode的参考 文档和sample code文档
0赞[DESCRIPTION]
BT Cordless mode的参考文档和一些sample code文档。
[SOLUTION]来自半导体社区
关于cordless mode的实现可以参考文档
Bluetooth Speech Interface_V1.01_2008-04-07.pdf
根据0852的code整理的最新版本的sample code:
This text introduce how to add cordless mode feature in project(08.52.MP project.)
1. Aud_bt_hfp.c
(1)开头处加入如下声明:
extern kal_bool g_cordless_mode; //Yunhai008
extern kal_bool g_mmi_profiles_bt_app_in_use; //Yunhai008
(2)
void aud_bt_hfp_set_speech_path_on(void)
{
……
/* Set Speech Path*/
if(aud_bt_hfp_ctx.speech_mode == BT_HFP_CARKIT_MODE)
{
speech_mode = SPH_MODE_BT_CARKIT;
speech_param_index = SPH_MODE_BT_CARKIT;
}
else
{
speech_mode = SPH_MODE_BT_EARPHONE;
speech_param_index = SPH_MODE_BT_EARPHONE;
}
if(g_cordless_mode) //Yunhai008
{
speech_mode = SPH_MODE_BT_CORDLESS;
speech_param_index = SPH_MODE_BT_CORDLESS;
}
……
/* Mute microphone for a short time to avoid noise goes to uplink */
if(!L1SP_IsMicrophoneMuted())
{
L1SP_MuteMicrophone(KAL_TRUE);
med_stop_timer(AUD_BT_SET_PATH_TIMER);
med_start_timer(AUD_BT_SET_PATH_TIMER, 1000, aud_bt_hfp_set_path_delay_timer_hdlr, 0);
aud_bt_hfp_ctx.mic_mute_flag = 1;
}
if(g_cordless_mode) //Yunhai008
{
//aud_speech_set_output_device(L1SP_LOUD_SPEAKER);
Media_SetOutputDevice(L1SP_SPEAKER1); //set output path of cordless mode
L1SP_SetInputSource( L1SP_LNA_0 ); //set input path of cordless mode
}
……
}
2. BTMMIHfp.c中
(1) 开头处加入
extern kal_bool g_mmi_profiles_bt_app_in_use; //Yunhai008
kal_bool g_cordless_mode = KAL_FALSE; //Yunhai008
(2) 文件末尾处加入
void mmi_bth_hfg_cordless_mode_init(void) //Yunhai008
{
g_cordless_mode = KAL_TRUE;
g_mmi_profiles_bt_app_in_use = KAL_TRUE;
if(!mmi_bt_is_hfp_audio_link_connected())
{
mmi_profiles_bt_connect_req(MMI_PROFILES_BT_HFP_SCO);
}
}
void mmi_bth_hfg_cordless_mode_exit(void) //Yunhai008
{
if(mmi_bt_is_hfp_audio_link_connected())
{
mmi_profiles_bt_disconnect_req(MMI_PROFILES_BT_HFP_SCO);
}
g_cordless_mode = KAL_FALSE;
g_mmi_profiles_bt_app_in_use = KAL_FALSE;
}
3. L1sp.c中
(1) 文件开头处加入:
extern void mmi_bth_hfg_cordless_mode_init(void); //Yunhai008
extern void mmi_bth_hfg_cordless_mode_exit(void);//Yunhai008
uint16 cordless_para[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; //Yunhai008
(2)文件末尾处加入:
void TurnOnBtCordlessTest(void) //Yunhai008 此功能的入口函数
{
L1SP_Speech_Off();
mmi_bth_hfg_cordless_mode_init();
//L1SP_SetOutputDevice(L1SP_LOUD_SPEAKER);
Media_SetOutputDevice(L1SP_SPEAKER1);
L1SP_SetInputSource( L1SP_LNA_0 );
L1SP_SetSpeechMode(SPH_MODE_BT_CORDLESS, cordless_para);
}
void TurnOffBtCordlessTest(void) //Yunhai008 此功能的退出函数
{
mmi_bth_hfg_cordless_mode_exit();
L1SP_Speech_Off();
}
4.SettingProf.c中
void mmi_profiles_bt_sco_timeout(void)
{
MMI_TRACE(MMI_MEDIA_TRC_G2_APP,MMI_USER_PROF_BT_SCO_TIMEOUT,mmi_profiles_bt_is_connected(MMI_PROFILES
_BT_HFP_SCO), g_mmi_profiles_bt_in_call);
if(mmi_profiles_bt_is_connected(MMI_PROFILES_BT_HFP_SCO))
{
/* If audio/video is not playing or not in call */
if(!g_mmi_profiles_bt_in_call &&
mmi_profiles_bt_is_sco_app_idle()&&!g_mmi_profiles_bt_app_in_use) //Yunhai008
{
mmi_profiles_bt_disconnect_sco();
}
/* still using audio resource, disconnect later */
else if(g_mmi_profiles_bt_sco_timeout && !g_mmi_profiles_bt_in_call)
{
StartTimer(BT_SCO_CONNECT_TIMER, BT_SCO_CONNECT_TIMEOUT_DURATION,
mmi_profiles_bt_sco_timeout);
}
}
}
5.为了避免sp_enhance.c中的ASSERT而做的修改
第一步的修改会引起sp_enhance.c 中的若干ASSERT,这个原因是我们在Cordless Mode时,DSP的一些功能不能使用
,需要做如下修改:
a)
L1SP_Speech_On 函数
{
.......
if ( !AM_IsBTCordlessMode() )
SPE_SetSBSD( true );
......
if ( !AM_IsBTCordlessMode() )
SetSpeechEnhancement( true );
}
b)
void L1SP_SetMicrophoneVolume( uint8 mic_volume )
{
..........
if ( !AM_IsBTCordlessMode() )
SetSpeechEnhancement( true );
............
}
c)
void L1SP_SetSpeechVolumeLevel( kal_uint8 level )
{
..........
if ( !AM_IsBTCordlessMode() )
SetSpeechEnhancement( true );
..........
}
d)
void L1SP_SetSpeechMode( uint8 mode, uint16 m_para[NUM_MODE_PARAS] )
{
......
if ( !AM_IsBTCordlessMode() )
SetSpeechEnhancement( true );
......
}
e)
void L1SP_LoadCommonSpeechPara( uint16 c_para[NUM_COMMON_PARAS] )
{
......
if ( !AM_IsBTCordlessMode() )
SetSpeechEnhancement( true );
......
}
f)
void SetSpeechEnhancement( bool ec )
{
......
if ((on_state != 0)&&(!AM_IsBTCordlessMode()))
SPE_TurnOnProcess(on_state);
......
}
6. 进入cordless mode调用TurnOnBtCordlessTest 函数
退出cordless mode调用TurnOffBtCordlessTest 函数
(如果要test这个功能,需先连接蓝牙耳机的hfp profile.才能进入cordless mode)
