?? hfp_handler.c
字號:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.6.2-release
FILE NAME
hfp_handler.c
DESCRIPTION
HFP handler.
*/
/****************************************************************************
Header files
*/
#include "headset_private.h"
#include "headset_common.h"
#include "headset_tones.h"
#include "hfp_handler.h"
#include "hfp_audio.h"
#include "headset_volume.h"
#include <hfp.h>
#include <panic.h>
#include <stdlib.h>
#include <audio.h>
#ifdef DEBUG_HFP
#define HFP_DEBUG(x) DEBUG(x)
#else
#define HFP_DEBUG(x)
#endif
/*****************************************************************************/
void hfpHeadsetAnswerCall(const headsetTaskData *app)
{
/*
Call the HFP lib function, this will determine the AT cmd to send
depending on whether the profile instance is HSP or HFP compliant.
*/
HfpAnswerCall(app->hfp);
}
/*****************************************************************************/
void hfpHeadsetRejectCall(const headsetTaskData *app)
{
/* Reject incoming call - only valid for instances of HFP */
HfpRejectCall(app->hfp);
}
/*****************************************************************************/
void hfpHeadsetHangUpCall(const headsetTaskData *app)
{
/* Terminate the current ongoing call process */
HfpTerminateCall(app->hfp);
}
/*****************************************************************************/
void hfpHeadsetLastNumberRedial(const headsetTaskData *app)
{
/* Issue a redial request to the HFP lib */
HfpLastNumberRedial(app->hfp);
}
/*****************************************************************************/
void hfpHeadsetHandleVoiceRecognitionInd(headsetTaskData *app, const HFP_VOICE_RECOGNITION_IND_T *ind)
{
/* Update the local flag */
app->voice_recognition_enabled = ind->enable;
if (app->voice_recognition_enabled)
{
AudioSetMode (AUDIO_MODE_MUTE_SPEAKER , NULL) ;
}
else
{
AudioSetMode (AUDIO_MODE_CONNECTED, NULL) ;
}
}
/*****************************************************************************/
void hfpHeadsetVoiceRecognitionEnable(headsetTaskData *app, uint16 enable)
{
if (app->profile_connected == hfp_handsfree_profile)
{
HfpVoiceRecognitionEnable(app->hfp, enable);
}
else
{
/* Send an HSP button press */
HfpSendHsButtonPress(app->hsp);
}
HFP_DEBUG(("HFP: Sent voice enable %d to AG\n",enable));
if (app->voice_recognition_enabled)
{
AudioSetMode (AUDIO_MODE_MUTE_SPEAKER, NULL) ;
}
else
{
AudioSetMode (AUDIO_MODE_CONNECTED, NULL) ;
}
}
/*****************************************************************************/
void hfpHeadsetHandleVoiceRecognitionCfm(headsetTaskData *app, const HFP_VOICE_RECOGNITION_ENABLE_CFM_T *cfm)
{
/* If the cmd succeeds we've got the flag set to the right state anyway */
if (cfm->status == hfp_fail)
{
/* Voice recognition cmd not accepted - change the state to what it was */
app->voice_recognition_enabled = FALSE ;
headsetPlayTone(app, tone_type_error);
headsetRestartAV(app);
AudioSetMode( AUDIO_MODE_CONNECTED, NULL);
}
}
/*****************************************************************************/
void hfpHeadsetHandleCallIndicator(headsetTaskData *app, const HFP_CALL_IND_T *ind)
{
HFP_DEBUG(("HFP: Call Ind = %d\n",ind->call));
if (ind->call)
{
/* Active call */
setHfpState(app, headsetActiveCall);
}
else
{
/* If an active call has been released update state accordingly */
if (app->hfp_state == headsetActiveCall)
{
setHfpState(app, headsetConnected);
HFP_DEBUG(("HFP: state connected\n"));
headsetPlayTone(app, tone_type_call_end);
}
}
}
/*****************************************************************************/
void hfpHeadsetHandleCallSetupIndicator(headsetTaskData *app, const HFP_CALL_SETUP_IND_T *ind)
{
headsetHfpState old_hfp_state = app->hfp_state;
headsetHfpState new_hfp_state;
/* Update the local state according to the value in this indicator */
HFP_DEBUG(("HFP: Call Setup Ind = %d\n",ind->call_setup));
HFP_DEBUG(("HFP: old hfp_state = %d\n",app->hfp_state));
switch (ind->call_setup)
{
case hfp_no_call_setup:
if (app->hfp_state != headsetActiveCall && app->hfp_state != headsetConnecting)
setHfpState(app, headsetConnected);
break;
case hfp_incoming_call_setup:
if (app->hfp_state != headsetActiveCall)
{
setHfpState(app, headsetIncomingCallEstablish);
app->active_profile = hfp_active;
}
break;
case hfp_outgoing_call_setup:
case hfp_outgoing_call_alerting_setup:
setHfpState(app, headsetOutgoingCallEstablish);
break;
default:
/* Invalid call setup indicator value received. */
HFP_DEBUG(("HFP: PANIC!\n"));
Panic();
}
HFP_DEBUG(("HFP: new hfp_state = %d\n",app->hfp_state));
new_hfp_state = app->hfp_state;
if ((old_hfp_state == headsetIncomingCallEstablish) && (new_hfp_state == headsetConnected))
{
headsetPlayTone(app, tone_type_call_end);
/* Noone answered a locally generated ring tone so restart AV if necessary */
headsetRestartAV(app);
}
if ((old_hfp_state == headsetOutgoingCallEstablish) && (new_hfp_state == headsetConnected))
{
headsetRestartAV(app);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -