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

📄 main.c

📁 实现蓝牙立体声耳机功能。。可以接收并播放来自有蓝牙功能的手机
💻 C
📖 第 1 页 / 共 4 页
字号:
                case avHeadsetA2dpSignallingActive:
                default:
                    unhandledA2dpState(current_a2dp_state, id);
                    break;      
            }
            break;
            
        case A2DP_SUSPEND_IND:
            MAIN_DEBUG(("A2DP_SUSPEND_IND\n"));
                    
            switch(current_a2dp_state)
            {
                case avHeadsetA2dpStreaming:
                    avHeadsetHandleA2dpSuspendInd(&app);
                    break;
                    
                case avHeadsetA2dpReady:
                case avHeadsetA2dpInitialising:
                case avHeadsetA2dpConnected:
                case avHeadsetA2dpInitiating:
                case avHeadsetA2dpSignallingActive:
                default:
                    unhandledA2dpState(current_a2dp_state, id);
                    break;      
            }
            break;
            
        case A2DP_SUSPEND_CFM:
            MAIN_DEBUG(("A2DP_SUSPEND_CFM\n"));
                    
            switch(current_a2dp_state)
            {
                case avHeadsetA2dpStreaming:
				case avHeadsetA2dpConnected:
                    avHeadsetHandleA2dpSuspendCfm(&app, (A2DP_SUSPEND_CFM_T*) message);
                    break;
                    
                case avHeadsetA2dpReady:
                case avHeadsetA2dpInitialising:
                case avHeadsetA2dpInitiating:
                case avHeadsetA2dpSignallingActive:
                default:
                    unhandledA2dpState(current_a2dp_state, id);
                    break;      
            }
            break;
            
        case A2DP_CLOSE_IND:
            MAIN_DEBUG(("A2DP_CLOSE_IND\n"));
                    
            switch(current_a2dp_state)
            {
                case avHeadsetA2dpStreaming:
                case avHeadsetA2dpConnected:
				case avHeadsetA2dpReady:
                    avHeadsetHandleA2dpCloseInd(&app, (A2DP_CLOSE_IND_T *) message);
                    break;

                case avHeadsetA2dpInitialising:
                case avHeadsetA2dpInitiating:
                case avHeadsetA2dpSignallingActive:
                default:
                    unhandledA2dpState(current_a2dp_state, id);
                    break;      
            }
            break;
            
        case A2DP_CLOSE_CFM:
            MAIN_DEBUG(("A2DP_CLOSE_CFM\n"));
                    
            switch(current_a2dp_state)
            {
                case avHeadsetA2dpStreaming:
                case avHeadsetA2dpConnected:
                    avHeadsetHandleA2dpCloseCfm(&app);
                    break;
                    
                case avHeadsetA2dpReady:
                case avHeadsetA2dpSignallingActive:
                case avHeadsetA2dpInitialising:
                case avHeadsetA2dpInitiating:
                default:
                    unhandledA2dpState(current_a2dp_state, id);
                    break;      
            }
            break;
            
            case A2DP_CODEC_SETTINGS_IND:
                MAIN_DEBUG(("A2DP_CODEC_SETTINGS_IND\n"));
                
                switch(current_a2dp_state)
                {
                case avHeadsetA2dpReady:
                case avHeadsetA2dpConnected:
                case avHeadsetA2dpInitiating:
                case avHeadsetA2dpSignallingActive:
                    avHeadsetHandleA2dpCodecSettingsInd(&app, (A2DP_CODEC_SETTINGS_IND_T *) message);
                    break;
                    
                case avHeadsetA2dpStreaming:
                case avHeadsetA2dpInitialising:
                default:
                    unhandledA2dpState(current_a2dp_state, id);
                    break;      
                }
                break;
                
        case A2DP_SIGNALLING_OPEN_IND:
			MAIN_DEBUG(("A2DP_SIGNALLING_OPEN_IND\n"));
			avHeadsetHandleA2dpSignallingOpenInd(&app, (A2DP_SIGNALLING_OPEN_IND_T *) message);
			break;
				
		case A2DP_SIGNALLING_CLOSE_IND:
			MAIN_DEBUG(("A2DP_SIGNALLING_CLOSE_IND %d\n",((A2DP_SIGNALLING_CLOSE_IND_T *)message)->result));
			avHeadsetHandleA2dpSignallingCloseInd(&app, (A2DP_SIGNALLING_CLOSE_IND_T *) message);
			break;

        default:
            MAIN_DEBUG(("AV Headset - Unhandled a2dp msg 0x%x\n",id));
            break;
    }
}


/**************************************************************************/
static void hfp_msg_handler(MessageId id, Message message)
{
    headsetHfpState current_hfp_state = app.hfp_state;

    switch (id)
    {
        case HFP_INIT_CFM:
            MAIN_DEBUG(("HFP_INIT_CFM\n"));
            switch(current_hfp_state)
            {
            case headsetInitialising:
                {
                    HFP_INIT_CFM_T *msg = (HFP_INIT_CFM_T *) message;
                    if (msg->status == hfp_init_success)
                        hfpHeadsetInitComplete(&app, msg);
                    else
                        Panic();
                }
                break;

            case headsetReady:
            case headsetConnecting:
            case headsetConnected:
            case headsetOutgoingCallEstablish:
            case headsetIncomingCallEstablish:
            case headsetActiveCall:
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;

        case HFP_SLC_CONNECT_IND:
            MAIN_DEBUG(("HFP_SLC_CONNECT_IND\n"));

            switch(current_hfp_state)
            {
            case headsetReady:
            case headsetConnecting:
            case headsetConnected:
            case headsetOutgoingCallEstablish:
            case headsetIncomingCallEstablish:
            case headsetActiveCall:
                hfpHeadsetHandleSlcConnectInd(&app, (HFP_SLC_CONNECT_IND_T *) message);
                break;

            case headsetInitialising:           
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;

        case HFP_SLC_CONNECT_CFM:
            MAIN_DEBUG(("HFP_SLC_CONNECT_CFM %d\n",((HFP_SLC_CONNECT_CFM_T *) message)->status));
            
            switch(current_hfp_state)
            {
            case headsetConnecting:
            case headsetConnected:
            case headsetOutgoingCallEstablish:
            case headsetIncomingCallEstablish:
            case headsetActiveCall:
                hfpHeadsetHandleSlcConnectCfm(&app, (HFP_SLC_CONNECT_CFM_T *) message);
                break;

            case headsetReady:
            case headsetInitialising:           
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;

        case HFP_SLC_DISCONNECT_IND:
            MAIN_DEBUG(("HFP_SLC_DISCONNECT_IND %d\n",((HFP_SLC_DISCONNECT_IND_T *) message)->status));
            
            switch(current_hfp_state)
            {
            case headsetConnecting:         
            case headsetConnected:
            case headsetOutgoingCallEstablish:
            case headsetIncomingCallEstablish:
            case headsetActiveCall:
                hfpHeadsetHandleSlcDisconnectInd(&app, (HFP_SLC_DISCONNECT_IND_T *) message);
                break;

            case headsetReady:
            case headsetInitialising:           
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;

        case HFP_IN_BAND_RING_IND:
            MAIN_DEBUG(("HFP_IN_BAND_RING_IND\n"));
            switch(current_hfp_state)
            {
            case headsetConnecting:
            case headsetConnected:
            case headsetOutgoingCallEstablish:
            case headsetIncomingCallEstablish:
            case headsetActiveCall:
                hfpHeadsetHandleInBandRingInd(&app, (HFP_IN_BAND_RING_IND_T *) message);
                break;

            case headsetInitialising:
            case headsetReady:
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;        

        case HFP_CALL_IND:
            MAIN_DEBUG(("HFP_CALL_IND %d\n",((HFP_CALL_IND_T *) message)->call));
            
            switch(current_hfp_state)
            {
            case headsetConnecting:
            case headsetConnected:
            case headsetIncomingCallEstablish:
            case headsetOutgoingCallEstablish:
            case headsetActiveCall:
                hfpHeadsetHandleCallIndicator(&app, (HFP_CALL_IND_T *) message);
                break; 

            case headsetInitialising:
            case headsetReady:
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;

        case HFP_CALL_SETUP_IND:
            MAIN_DEBUG(("HFP_CALL_SETUP_IND %d\n",((HFP_CALL_SETUP_IND_T *) message)->call_setup));
            
            switch(current_hfp_state)
            {
            case headsetConnecting:
            case headsetConnected:
            case headsetIncomingCallEstablish:
            case headsetOutgoingCallEstablish:
            case headsetActiveCall:
                hfpHeadsetHandleCallSetupIndicator(&app, (HFP_CALL_SETUP_IND_T *) message);
                break; 

            case headsetInitialising:
            case headsetReady:
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;

        case HFP_RING_IND:
            MAIN_DEBUG(("HFP_RING_IND\n"));
            
            switch(current_hfp_state)
            {
            case headsetConnected:
            case headsetIncomingCallEstablish:
            case headsetActiveCall:
                hfpHeadsetHandleRingInd(&app, (HFP_RING_IND_T *) message);
                break;

            case headsetConnecting:
            case headsetOutgoingCallEstablish:
                unhandledHfpState(current_hfp_state, id);
                break;

            case headsetInitialising:
            case headsetReady:
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;
            
        case HFP_VOICE_RECOGNITION_IND:
            MAIN_DEBUG(("HFP_VOICE_RECOGNITION_IND %d\n",((HFP_VOICE_RECOGNITION_IND_T *) message)->enable));
            switch(current_hfp_state)
            {
            case headsetConnected:
            case headsetOutgoingCallEstablish:
                hfpHeadsetHandleVoiceRecognitionInd(&app, (HFP_VOICE_RECOGNITION_IND_T *) message);
                break;

            case headsetActiveCall:
            case headsetIncomingCallEstablish:
            case headsetConnecting:
            case headsetInitialising:
            case headsetReady:
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;

        case HFP_VOICE_RECOGNITION_ENABLE_CFM:
            MAIN_DEBUG(("HFP_VOICE_RECOGNITION_ENABLE_CFM %d\n",((HFP_VOICE_RECOGNITION_ENABLE_CFM_T *) message)->status));
            switch(current_hfp_state)
            {
            case headsetConnected:
                hfpHeadsetHandleVoiceRecognitionCfm(&app, (HFP_VOICE_RECOGNITION_ENABLE_CFM_T *) message);
                break;

            case headsetActiveCall:
            case headsetOutgoingCallEstablish:
            case headsetIncomingCallEstablish:
            case headsetConnecting:
            case headsetInitialising:
            case headsetReady:
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;        
            
        case HFP_ENCRYPTION_CHANGE_IND:
            MAIN_DEBUG(("HFP_ENCRYPTION_CHANGE_IND %d\n",((HFP_ENCRYPTION_CHANGE_IND_T *)message)->encrypted));
            
            switch(current_hfp_state)
            {
            case headsetConnecting:
            case headsetConnected:
            case headsetIncomingCallEstablish:
            case headsetOutgoingCallEstablish:
            case headsetActiveCall:
                if (((HFP_ENCRYPTION_CHANGE_IND_T *)message)->encrypted == FALSE)
                    MessageSendLater(getAppTask(), APP_DISCONNECT_HFP_SLC_IND, 0, (uint32) 5000);
                else
                    (void) MessageCancelAll(getAppTask(), APP_DISCONNECT_HFP_SLC_IND);
                break;

            case headsetReady:
            case headsetInitialising:
            default:
                unhandledHfpState(current_hfp_state, id);
            }
                
            break;

        case HFP_SPEAKER_VOLUME_IND:
            MAIN_DEBUG(("HFP_SPEAKER_VOLUME_IND\n"));
            /* Update the local valume and the actual gain setting */
            app.speaker_volume.hfp_volume = (uint8)((HFP_SPEAKER_VOLUME_IND_T *) message)->volume_gain;           
            
            /* Update the local volume */
            if (app.sco_sink)
            {
    		    AudioSetVolume(	app.speaker_volume.hfp_volume , app.codec_task ) ;
			        /* Check to see if we should we play a tone here */
	            headsetCheckHfVolLimits(&app);
            }
            
            
            break;

		case HFP_UNRECOGNISED_AT_CMD_IND:
            {
                uint16 i;
                HFP_UNRECOGNISED_AT_CMD_IND_T *ind = (HFP_UNRECOGNISED_AT_CMD_IND_T *) message;
    
				MAIN_DEBUG(("HFP_UNRECOGNISED_AT_CMD_IND len %d\n", ind->size_data));
                for (i=0; i<ind->size_data; i++)
                {
                    MAIN_DEBUG(("%c", ind->data[i]));
                }
                MAIN_DEBUG(("\n"));

            }
            break;        

        case HFP_AUDIO_CONNECT_IND:
            MAIN_DEBUG(("HFP_AUDIO_CONNECT_IND\n"));
            hfpHeadsetHandleAudioConnectInd(&app, (HFP_AUDIO_CONNECT_IND_T *)message);
            break;

        case HFP_AUDIO_CONNECT_CFM:
            MAIN_DEBUG(("HFP_AUDIO_CONNECT_CFM\n"));
            switch(current_hfp_state)
            {
            case headsetConnecting:
				/* 
					If we have received a SCO indication before the SLC is up assume 
					phone has performed call transfer early and cancel the queued 
					button press event. 
				*/
                (void) MessageCancelAll(&app.task, BUTTON_MFB_SHORT);
				(void) MessageCancelAll(&app.task, BUTTON_MFB_LONG_RELEASE);

				/* Still handle the SCO indication as normal */
				hfpHeadsetHandleAudioConnectCfm(&app, (HFP_AUDIO_CONNECT_CFM_T *) message);
				break;

            case headsetConnected:
            case headsetIncomingCallEstablish:
            case headsetOutgoingCallEstablish:
            case headsetActiveCall:
                hfpHeadsetHandleAudioConnectCfm(&app, (HFP_AUDIO_CONNECT_CFM_T *) message);
                break;

            case headsetInitialising:
            case headsetReady:
            default:
                unhandledHfpState(current_hfp_state, id);
            }
            break;

        case HFP_AUDIO_DISCONNECT_IND:
            MAIN_DEBUG(("HFP_AUDIO_DISCONNECT_IND\n"));
            switch(current_hfp_state)

⌨️ 快捷键说明

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