📄 headset_hfp_call.c
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2007
FILE NAME
headset_hfp_call.h
DESCRIPTION
Handles HFP call functionality.
*/
#include "headset_a2dp_stream_control.h"
#include "headset_debug.h"
#include "headset_hfp_call.h"
#include "headset_statemanager.h"
#include "headset_tones.h"
#include <hfp.h>
#include <panic.h>
#include <ps.h>
#ifdef DEBUG_HFP_CALL
#define HFP_CALL_DEBUG(x) DEBUG(x)
#else
#define HFP_CALL_DEBUG(x)
#endif
static void headsetQueueEvent ( hsTaskData * pApp , headsetEvents_t pEvent) ;
static headsetEvents_t gMessageQueued = EventInvalid ;
/****************************************************************************
FUNCTIONS
*/
/****************************************************************************/
void hfpCallInitiateVoiceDial ( hsTaskData* pApp )
{
HFP_CALL_DEBUG(("CM: VD\n")) ;
if (!stateManagerIsHfpConnected() )
{
MessageSend ( &pApp->task , EventEstablishSLC , 0 ) ;
headsetQueueEvent( pApp , EventInitateVoiceDial ) ;
pApp->voice_recognition_enabled = FALSE ;
}
else
{
HFP_CALL_DEBUG(("CM: VD Connected\n")) ;
/* Pause A2DP streaming */
streamControlCeaseA2dpStreaming(pApp, TRUE);
if ( pApp->profile_connected == hfp_handsfree_profile )
{
HfpVoiceRecognitionEnable(pApp->hfp, TRUE);
pApp->voice_recognition_enabled = TRUE ;
}
else
{
HfpSendHsButtonPress ( pApp->hsp ) ;
}
}
}
/****************************************************************************/
void hfpCallCancelVoiceDial ( hsTaskData * pApp )
{
if ( pApp->profile_connected == hfp_handsfree_profile )
{
/*if we believe voice dial is currently active*/
if ( pApp->voice_recognition_enabled)
{
HfpVoiceRecognitionEnable(pApp->hfp, FALSE);
pApp->voice_recognition_enabled = FALSE ;
}
}
}
/****************************************************************************/
void hfpCallInitiateLNR ( hsTaskData * pApp )
{
HFP_CALL_DEBUG(("CM: LNR\n")) ;
if (!stateManagerIsHfpConnected() )
{
MessageSend ( &pApp->task , EventEstablishSLC , 0 ) ;
headsetQueueEvent(pApp , EventLastNumberRedial) ;
}
else
{
HFP_CALL_DEBUG(("CM: LNR Connected\n")) ;
if ( pApp->profile_connected == hfp_handsfree_profile )
{
HfpLastNumberRedial( pApp->hfp );
}
else
{
HfpSendHsButtonPress ( pApp->hsp ) ;
}
}
}
/****************************************************************************/
void hfpCallAnswer ( hsTaskData *pApp )
{
/*
Call the HFP lib function, this will determine the AT cmd to send
depending on whether the profile instance is HSP or HFP compliant.
*/
if ( pApp->profile_connected == hfp_handsfree_profile )
{
HfpAnswerCall ( pApp->hfp );
/* Terminate the ring tone */
ToneTerminate ( pApp ) ;
}
else
{
HfpSendHsButtonPress ( pApp->hsp ) ;
}
}
/****************************************************************************/
void hfpCallReject ( hsTaskData *pApp )
{
/*
Reject incoming call - only valid for instances of HFP in HSP mode
send a button press.
*/
if ( pApp->profile_connected == hfp_handsfree_profile )
{
HfpRejectCall ( pApp->hfp );
/* Terminate the ring tone */
ToneTerminate ( pApp ) ;
}
else
{
HfpSendHsButtonPress ( pApp->hsp ) ;
}
}
/****************************************************************************/
void hfpCallHangUp ( const hsTaskData *pApp )
{
/* Terminate the current ongoing call process */
if ( pApp->profile_connected == hfp_handsfree_profile )
{
HfpTerminateCall ( pApp->hfp );
}
else
{
HfpSendHsButtonPress ( pApp->hsp ) ;
}
}
/****************************************************************************/
void hfpCallTransferToggle ( hsTaskData *pApp )
{
hfp_audio_transfer_direction lTransferDirection = hfp_audio_to_ag ;
if ( !pApp->sco_sink )
{
lTransferDirection = hfp_audio_to_hfp ;
}
/* Call the transfer function - a hsp transfer call will generate the HSP button press */
if ( pApp->profile_connected == hfp_handsfree_profile )
{
HfpAudioTransferConnection(pApp->hfp, lTransferDirection, sync_all_pkt_types, 0 );
}
else
{
HfpAudioTransferConnection(pApp->hsp, lTransferDirection, (sync_all_sco), 0 );
}
}
/*****************************************************************************/
void hfpCallRecallQueuedEvent ( hsTaskData * pApp )
{
/*this is currently only applicable to LNR and voice Dial but does not care */
if (gMessageQueued != EventInvalid)
{
switch (stateManagerGetHfpState() )
{
case headsetIncomingCallEstablish:
case headsetOutgoingCallEstablish:
case headsetActiveCall:
/* Do Nothing Message Gets ignored*/
break ;
default:
if ( pApp->profile_connected == hfp_handsfree_profile )
{
MessageSend ( &pApp->task , gMessageQueued , 0 ) ;
HFP_CALL_DEBUG(("CM: Queued Message ? [%x] Sent\n" , gMessageQueued))
}
else
{
HfpSendHsButtonPress ( pApp->hsp ) ;
HFP_CALL_DEBUG(("CM: Queued Msg - HSP Butt Sent\n"))
}
break;
}
}
/*reset the queued event*/
gMessageQueued = EventInvalid ;
}
/*****************************************************************************/
void hfpCallClearQueuedEvent ( hsTaskData * pApp )
{
/* this resets the queue - on a conenction fail / power off etc */
gMessageQueued = EventInvalid ;
}
/****************************************************************************
NAME
headsetQueueEvent
DESCRIPTION
Queues an event to be sent once the headset is connected.
*/
static void headsetQueueEvent ( hsTaskData * pApp , headsetEvents_t pEvent)
{
HFP_CALL_DEBUG(("CM: QQ Ev[%x]\n", pEvent)) ;
gMessageQueued = pEvent ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -