⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 headset_threewaycall.c

📁 bluelab的一个很好的例程
💻 C
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004

FILE NAME
    headset_threewaycall.c
    
DESCRIPTION
        three way call handling functions
                
*/


#include "headset_private.h"
#include "headset_threewaycall.h"


#ifdef DEBUG_THREEWAY
#define TWC_DEBUG(x) DEBUG(x)
#else
#define TWC_DEBUG(x) 
#endif   



void headsetHandleThreeCallWaitingCfm (hsTaskData * pApp , HFP_CALL_WAITING_ENABLE_CFM_T * pCfm )
{
    TWC_DEBUG(("TWC: Call waiting cfm \n")) ;
}
    
void headsetHandleThreeCallWaitingInd (hsTaskData * pApp , HFP_CALL_WAITING_IND_T * pInd )
{
    TWC_DEBUG(("TWC: call waiting ind\n")) ;
    
        /*change state accordingly*/
    stateManagerEnterThreeWayCallWaitingState ( pApp ) ;

}


void headsetHandleThreeReleaseHeldRejectWaitingCfm (hsTaskData * pApp ,  HFP_RELEASE_HELD_REJECT_WAITING_CALL_CFM_T * pCfm)
{
    TWC_DEBUG(("TWC: release held reject waiting cfm \n ")) ;
    
    if (pCfm->status == hfp_success)
    {
        stateManagerEnterActiveCallState ( pApp ) ;
    }
}

void headsetHandleThreeReleaseActiveAcceptOtherCfm ( hsTaskData * pApp , HFP_RELEASE_ACTIVE_ACCEPT_OTHER_CALL_CFM_T * pCfm)
{
    TWC_DEBUG(("TWC: Release active accept other cfm \n")) ;
    
    if (pCfm->status == hfp_success)
    {
        stateManagerEnterActiveCallState ( pApp ) ;
    }
    
}

void headsetHandleThreeHoldActiveAcceptOtherCfm (hsTaskData * pApp , HFP_HOLD_ACTIVE_ACCEPT_OTHER_CALL_CFM_T* pCfm)
{
    TWC_DEBUG(("TWC: hold active accpet other cfm \n")) ;
        if (pCfm->status == hfp_success)
    {
        stateManagerEnterThreeWayCallOnHoldState ( pApp ) ;
    }

}

void headsetHandleThreeAddCall (hsTaskData * pApp , HFP_ADD_HELD_CALL_CFM_T* pCfm)
{
    TWC_DEBUG(("TWC: add call cfm \n")) ;
    
    if (pCfm->status == hfp_success)
    {
        stateManagerEnterThreeWayMulticallState ( pApp ) ;
    }

}

void headsetHandleThreeExplicitTransfer ( hsTaskData * pApp , HFP_EXPLICIT_CALL_TRANSFER_CFM_T * pCfm)
{
    TWC_DEBUG(("TWC: 7")) ;
    
    if (pCfm->status == hfp_success)
    {
        if ( stateManagerGetState() != headsetConnected )
        {
            stateManagerEnterConnectedState ( pApp ) ;
        }    
    }

}


void headsetHandleThreeCallSetupInd ( hsTaskData * pApp , HFP_CALL_SETUP_IND_T * pInd ) 
{
    TWC_DEBUG(("TWC: Call SetupInd [%d] [%d]\n", pInd->call_setup , stateManagerGetState() )) ;

    switch (pInd->call_setup)
    {
    case hfp_no_call_setup:		
        switch (stateManagerGetState () )
        {
            case headsetThreeWayCallWaiting:   
            stateManagerEnterActiveCallState (pApp) ;
            break;

            case headsetThreeWayCallOnHold:
            case headsetThreeWayMulticall:
            default:
            break ;
        }
    break;
    
	case hfp_incoming_call_setup:
    case hfp_outgoing_call_setup :			
    case hfp_outgoing_call_alerting_setup:
    default:
        TWC_DEBUG(("unhandled state [%d]", pInd->call_setup)) ;
    break ;
    }
}


void headsetHandleThreeCallInd ( hsTaskData * pApp , HFP_CALL_IND_T * pInd ) 
{
    TWC_DEBUG(("TWC: Call Ind [%d] [%d]\n", pInd->call , stateManagerGetState() )) ;
    
    switch( pInd->call  )
    {
        case (0):
        {
            stateManagerEnterConnectedState ( pApp) ;
        }
        break;
        case (1):
            TWC_DEBUG(("TWC: Call Ind call active\n")) ;
                /*end of call detected*/
            switch ( stateManagerGetState() )
            {
                case headsetThreeWayCallWaiting:
                    stateManagerEnterActiveCallState (pApp) ;           
                break ;
                case headsetThreeWayCallOnHold:
                
                    MessageSend ( &pApp->task , EventEndOfCall , 0 ) ;
                    stateManagerEnterActiveCallState (pApp) ;
                break ;
                case headsetThreeWayMulticall:
                
                    MessageSend ( &pApp->task , EventEndOfCall , 0 ) ;
                    stateManagerEnterActiveCallState (pApp) ;
                break ;
                default:
                break ;
            }
        break;
        default: 
        break ;
    }
}


void headsetHandleCurrentCallsInd (  hsTaskData * pApp , HFP_CURRENT_CALLS_IND_T * pInd ) 
{
    headsetState pState = stateManagerGetState()  ;
    
    TWC_DEBUG(("TWC: HFP_CURRENT_CALLS_IND id[%d] mult[%d] status[%d] STATE[%d]\n" ,
                                            pInd->call_idx , 
                                            pInd->multiparty  , 
                                            pInd->status , 
                                            pState)) ;
                                            
    switch (pState ) 
    {
          
        case headsetConnected:
            switch (pInd->status)
            {
                case hfp_call_active:      /*! Call is currently active.*/
                    stateManagerEnterActiveCallState (pApp);
                break;
                case hfp_call_held:        /*! Call is currently held.*/
                    stateManagerEnterIncomingCallOnHoldState (pApp);
                break;
                case hfp_call_dialling:    /*! Call is being dialled - mobile originated only.*/
                case hfp_call_alerting:    /*! Call is alerting - mobile originated only.*/
                    stateManagerEnterOutgoingCallEstablishState(pApp);
                break;
                case hfp_call_incoming:    /*! Call is incoming - mobile terminated only.*/
                case hfp_call_waiting:    /*! Call is waiting - mobile terminated only.*/
                    stateManagerEnterIncomingCallEstablishState( pApp) ;
                break ;
                default:
                break ;
            }
        break ;    
        case headsetIncomingCallEstablish:
            switch (pInd->status)
            {
                case hfp_call_active:      /*! Call is currently active.*/
                    stateManagerEnterThreeWayCallWaitingState (pApp);
                break;
                case hfp_call_held:        /*! Call is currently held.*/
                    stateManagerEnterThreeWayCallOnHoldState (pApp);
                break;
                default:
                break ;
            }
        break;
        case headsetActiveCall:    
            switch (pInd->status)
            {
                case hfp_call_incoming:      /*! Call is currently incoming.*/
                case hfp_call_waiting:    /*! Call is waiting - mobile terminated only.*/
                    stateManagerEnterThreeWayCallWaitingState (pApp);
                break;
                case hfp_call_held:        /*! Call is currently held.*/
                    stateManagerEnterThreeWayCallOnHoldState (pApp);
                break;
                default:
                break ;
            }
        break;
        case headsetOutgoingCallEstablish:
             switch (pInd->status)
            {
                case hfp_call_active:      /*! Call is currently active.*/
                    stateManagerEnterThreeWayCallWaitingState (pApp);
                break;
                case hfp_call_held:        /*! Call is currently held.*/
                    stateManagerEnterThreeWayCallOnHoldState (pApp);
                break;
                default:
                break ;
            }
        break;
        case headsetIncomingCallOnHold:
            switch (pInd->status)
            {
                case hfp_call_active:      /*! Call is currently active.*/
                    stateManagerEnterThreeWayCallOnHoldState (pApp);
                break;
                case hfp_call_held:        /*! Call is currently held.*/
                    stateManagerEnterThreeWayCallOnHoldState (pApp);
                break;
                default:
                break ;
            }
        break;
            /*we are now in one of the TWC states - make no more changes*/
        case headsetThreeWayCallWaiting:
        case headsetThreeWayCallOnHold:
        case headsetThreeWayMulticall:                
        default:
        break ;
    }
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -