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

📄 main.c

📁 蓝牙耳机的源代码,结合csr的开发套件使用
💻 C
📖 第 1 页 / 共 4 页
字号:
            if (stateManagerGetState () != headsetPoweringOn)            {                stateManagerEnterConnDiscoverableState ( &theHeadset ) ;            }                break ;           case (EventPairingFail):            /*we have failed to pair in the alloted time - return to the connectable state*/            MAIN_DEBUG(("HS: Pairing Fail\n")) ;            stateManagerEnterConnectableState( &theHeadset, TRUE) ;                      break ;                                case ( EventPairingSuccessful):            MAIN_DEBUG(("HS: Pairing Successful\n")) ;            if (stateManagerGetState() == headsetConnDiscoverable)            {                stateManagerEnterConnectableState( &theHeadset , FALSE) ;            }            break ;        case ( EventEstablishSLC ) :                     MAIN_DEBUG(("EventEstablishSLC\n")) ;            slcEstablishSLCRequest(&theHeadset , hfp_handsfree_profile) ;               break ;            /*can probably lose this now as the limbo state has its own built in timeout*/        case ( EventLEDEventComplete ) :            /*the message is a ptr to the event we have completed*/            MAIN_DEBUG(("HS : LEDEvCmp[%x]\n" ,  (( LMEndMessage_t *)message)->Event  )) ;                        if ( (( LMEndMessage_t *)message)->Event  == EventResetPairedDeviceList )            {                    /*then the reset has been completed*/                MessageSend(&theHeadset.task , EventResetComplete , 0 ) ;                        /*Reboot if required*/                if (theHeadset.features.RebootAfterReset )                {                    MAIN_DEBUG(("HS: Reboot After Reset\n")) ;                            MessageSend ( &theHeadset.task , EventPowerOff , 0 ) ;                }            }                        if (theHeadset.features.QueueLEDEvents )            {                    /*if there is a queueud event*/                if (theHeadset.theLEDTask.Queue.Event1)                {                    MAIN_DEBUG(("HS : Play Q'd Ev [%x]\n", (EVENTS_EVENT_BASE + theHeadset.theLEDTask.Queue.Event1)  ));                    MAIN_DEBUG(("HS : Queue [%x][%x][%x][%x]\n", theHeadset.theLEDTask.Queue.Event1,                                                              theHeadset.theLEDTask.Queue.Event2,                                                              theHeadset.theLEDTask.Queue.Event3,                                                              theHeadset.theLEDTask.Queue.Event4                                                                                                                                    ));                                    LEDManagerIndicateEvent (&theHeadset.theLEDTask , (EVENTS_EVENT_BASE + theHeadset.theLEDTask.Queue.Event1) ) ;                            /*shuffle the queue*/                    theHeadset.theLEDTask.Queue.Event1 = theHeadset.theLEDTask.Queue.Event2 ;                    theHeadset.theLEDTask.Queue.Event2 = theHeadset.theLEDTask.Queue.Event3 ;                    theHeadset.theLEDTask.Queue.Event3 = theHeadset.theLEDTask.Queue.Event4 ;                    theHeadset.theLEDTask.Queue.Event4 = 0x00 ;                }            }                         break ;           case (EventAutoSwitchOff):         MAIN_DEBUG(("HS: Auto S Off[%d] sec elapsed\n" , theHeadset.AutoSwitchOffTimeSecs )) ;            switch ( lState )            {                case headsetPoweringOn:                case headsetConnectable:                case headsetConnDiscoverable:                 MessageSend ( task , EventPowerOff , 0) ;                    break;                case headsetConnected:                case headsetOutgoingCallEstablish:                   case headsetIncomingCallEstablish:                   case headsetActiveCall:                         case headsetTestMode:                    break ;                default:                    MAIN_DEBUG(("HS : UE ?s [%d]\n", lState));                    break ;            }            break;           case (EventChargerConnected):        {            MAIN_DEBUG(("HS: Charger Connected\n"));            powerManagerChargerConnected(theHeadset.power);            if ( stateManagerGetState() == headsetPoweringOn )            {                 stateManagerUpdateLimboState ( &theHeadset ) ;            }        }        break;           case (EventChargerDisconnected):        {            MAIN_DEBUG(("HS: Charger Disconnected\n"));            powerManagerChargerDisconnected(theHeadset.power);             if (stateManagerGetState() == headsetPoweringOn )            {                stateManagerUpdateLimboState ( &theHeadset ) ;            }        }        break;           case (EventResetPairedDeviceList):            {                MAIN_DEBUG(("HS: --Reset PDL--")) ;                                if ( stateManagerIsConnected () )                {                        /*then we have an SLC active*/                   headsetDisconnectSlc( &theHeadset );                }                                configManagerReset ( &theHeadset ) ;            }        break ;                case ( EventLimboTimeout ):            {                /*we have received a power on timeout - shutdown*/                MAIN_DEBUG(("HS: EvLimbo TIMEOUT\n")) ;                if (stateManagerGetState() != headsetTestMode)                {                    stateManagerUpdateLimboState ( &theHeadset ) ;                }            }            break ;                    case EventSLCDisconnected:                 MAIN_DEBUG(("HS: EvSLCDisconnect\n")) ;            {                theHeadset.VoiceRecognitionIsActive = FALSE ;                MessageCancelAll ( &theHeadset.task , EventNetworkOrServiceNotPresent ) ;            }        break ;            case (EventLinkLoss):            MAIN_DEBUG(("HS: Link Loss\n")) ;            {                /*A Link Loss has occured -attempt reconnect*/                slcConnectAfterLinkLoss ( &theHeadset ) ;            }        break ;                case (EventMuteReminder) :                    MAIN_DEBUG(("HS: Mute Remind\n")) ;                /*arrange the next mute reminder tone*/            soundManagerMuteRemind ( &theHeadset ) ;                    break;                case EventLowBattery:            MAIN_DEBUG(("HS: EvLowBatt\n")) ;        break;         case EventTrickleCharge:           MAIN_DEBUG(("HS: EvTrickleChg\n")) ;        break;        case EventFastCharge:         MAIN_DEBUG(("HS: EvFastChg\n")) ;        break;        case EventOkBattery:         MAIN_DEBUG(("HS: EvBatOK\n")) ;        break;/*************************************************************/                case EventEnterDUTState :        {            MAIN_DEBUG(("EnterDUTState \n")) ;            stateManagerEnterTestModeState (&theHeadset) ;                        }        break;                case EventEnterDutMode :        {            MAIN_DEBUG(("Enter DUT Mode \n")) ;                        if (stateManagerGetState() !=headsetTestMode)            {                MessageSend( task , EventEnterDUTState, 0 ) ;            }            enterDutMode () ;                       }        break;                case EventEnterTXContTestMode :        {            MAIN_DEBUG(("Enter TX Cont \n")) ;                    if (stateManagerGetState() !=headsetTestMode)            {                MessageSend( task , EventEnterDUTState , 0 ) ;            }                        enterTxContinuousTestMode() ;        }        break ;/*************************************************************/        case EventVolumeOrientationNormal:                theHeadset.theSoundTask.gVolButtonsInverted = FALSE ;                               MAIN_DEBUG(("HS: VOL ORIENT NORMAL [%d]\n", theHeadset.theSoundTask.gVolButtonsInverted)) ;                    /*write this to the PSKEY*/                                configManagerWriteVolumeOrientation ( &theHeadset , FALSE ) ;        break;        case EventVolumeOrientationInvert:                      theHeadset.theSoundTask.gVolButtonsInverted = TRUE ;               MAIN_DEBUG(("HS: VOL ORIENT INVERT[%d]\n", theHeadset.theSoundTask.gVolButtonsInverted)) ;                                  /*write this to the PSKEY*/                               configManagerWriteVolumeOrientation ( &theHeadset , TRUE ) ;                   break;                case EventToggleVolume:                                theHeadset.theSoundTask.gVolButtonsInverted ^=1 ;                    MAIN_DEBUG(("HS: Toggle Volume Orientation[%d]\n", theHeadset.theSoundTask.gVolButtonsInverted)) ;                        break ;                    /*network service indicators*/        case EventNetworkOrServiceNotPresent:            {                    /*only bother to repeat this indication if it is not 0*/                if ( theHeadset.NetworkServiceIndicatorRepeatTimeSecs )                {                                        /*make sure only ever one in the system*/                    MessageCancelAll( task , EventNetworkOrServiceNotPresent) ;                    MessageSendLater  ( task ,                                         EventNetworkOrServiceNotPresent ,                                        0 ,                                         D_SEC(theHeadset.NetworkServiceIndicatorRepeatTimeSecs) ) ;                }                                                    MAIN_DEBUG(("HS: NO NETWORK [%d]\n", theHeadset.NetworkServiceIndicatorRepeatTimeSecs )) ;            }                                        break ;        case EventNetworkOrServicePresent:            {                MessageCancelAll ( task , EventNetworkOrServiceNotPresent ) ;                                MAIN_DEBUG(("HS: YES NETWORK\n")) ;            }           break ;                case EventEnableDisableLeds  :               MAIN_DEBUG(("HS: Toggle EN_DIS LEDS ")) ;            MAIN_DEBUG(("HS: Tog Was[%c]\n" , theHeadset.theLEDTask.gLEDSEnabled ? 'T' : 'F')) ;                        LedManagerToggleLEDS ( &theHeadset.theLEDTask ) ;                        MAIN_DEBUG(("HS: Tog Now[%c]\n" , theHeadset.theLEDTask.gLEDSEnabled ? 'T' : 'F')) ;                    break ;                case EventEnableLEDS:            MAIN_DEBUG(("HS: Enable LEDS\n")) ;            LedManagerEnableLEDS ( &theHeadset.theLEDTask ) ;                break ;        case EventDisableLEDS:            MAIN_DEBUG(("HS: Disable LEDS\n")) ;                        LedManagerDisableLEDS ( &theHeadset.theLEDTask ) ;                    break ;		case EventCancelLedIndication:			MAIN_DEBUG(("HS: Disable LED indication\n")) ;                    LedManagerResetLEDIndications ( &theHeadset.theLEDTask ) ;            		break ;                case EventSLCConnected:            MAIN_DEBUG(("HS: EventSLCConnected\n")) ;                /*if there is a queued event - we might want to know*/                            headsetRecallQueuedEvent ( &theHeadset ) ;        break;                    case EventHSPEnterActiveCallState:			MAIN_DEBUG(("HS: HSP Enter Active Call State\n")) ;            {                if ( theHeadset.profile_connected == hfp_headset_profile)                {                    if ( &theHeadset.sco_sink)                    {                        stateManagerEnterActiveCallState (&theHeadset) ;                    }                }            }        break ;                case EventVLongTimer:        case EventLongTimer:           if (stateManagerGetState() == headsetPoweringOn)           {               lIndicateEvent = FALSE ;           }        break ;        case EventChargeError:            MAIN_DEBUG(("HS: EventChargerError \n")) ;            {       /*use the standard event if we are connected otherwise:*/                if (stateManagerGetState() != headsetActiveCall )                {                    /*we are not connected so use the idle charger error event*/                    lIndicateEvent = FALSE ;                    MessageSend( task , EventChargeErrorInIdleState , 0 ) ;                }                                 }        break ;                /*these events have no required action directly associated with them  */             /*they are received here so that LED patterns and Tones can be assigned*/        case EventSCOLinkOpen :                    MAIN_DEBUG(("EventScoLinkOpen\n")) ;            break ;        case EventSCOLinkClose:                    MAIN_DEBUG(("EventScoLinkClose\n")) ;            break ;        case EventEndOfCall :                    MAIN_DEBUG(("EventEndOfCall\n")) ;            break;            case EventResetComplete:                    MAIN_DEBUG(("EventResetComplete\n")) ;            break ;        case EventError:                    MAIN_DEBUG(("EventError\n")) ;            break;		case EventChargeErrorInIdleState:                    MAIN_DEBUG(("EventChargeErrorInIdle\n")) ;        break;             /****************************************************/               /*3 way calling here for now*/ /*only processed if supported features says that we can*/        case EventThreeWayReleaseAllHeld:                   MAIN_DEBUG(("HS3 : RELEASE ALL [%c]\n", TRUE_OR_FALSE(theHeadset.supp_features_local & HFP_THREE_WAY_CALLING))) ;                      if (theHeadset.supp_features_local & HFP_THREE_WAY_CALLING)            {				HfpMultipleCallsReleaseHeldOrRejectWaiting (theHeadset.hfp) ;                        }                break;        case EventThreeWayAcceptWaitingReleaseActive:                MAIN_DEBUG(("HS3 : ACCEPT & RELEASE [%c]\n", TRUE_OR_FALSE(theHeadset.supp_features_local & HFP_THREE_WAY_CALLING))) ;            if (theHeadset.supp_features_local & HFP_THREE_WAY_CALLING)            {            	HfpMultipleCallsReleaseActiveAcceptOther ( theHeadset.hfp )  ;            }            break ;        case EventThreeWayAcceptWaitingHoldActive  :            MAIN_DEBUG(("HS3 : ACCEPT & HOLD[%c]\n", TRUE_OR_FALSE(theHeadset.supp_features_local & HFP_THREE_WAY_CALLING))) ;            if (theHeadset.supp_features_local & HFP_THREE_WAY_CALLING)            {            	HfpMultipleCallsHoldActiveAcceptOther ( theHeadset.hfp ) ;            }            break ;        case EventThreeWayAddHeldTo3Way  :            MAIN_DEBUG(("HS3 : ADD HELD to 3WAY[%c]\n", TRUE_OR_FALSE(theHeadset.supp_features_local & HFP_THREE_WAY_CALLING))) ;            if (theHeadset.supp_features_local & HFP_THREE_WAY_CALLING)            {            	HfpMultipleCallsAddHeldCall( theHeadset.hfp ) ;            }                break ;        case EventThreeWayConnect2Disconnect:              MAIN_DEBUG(("HS3 : EXPLICIT TRANSFER[%c]\n", TRUE_OR_FALSE(theHeadset.supp_features_local & HFP_THREE_WAY_CALLING))) ;            if (theHeadset.supp_features_local & HFP_THREE_WAY_CALLING)            {            	HfpMultipleCallsExplicitCallTransfer(theHeadset.hfp) ;            }            break ;    /****************************************************/        case (EventEnablePowerOff):        {            MAIN_DEBUG(("HS: EventEnablePowerOff \n")) ;            theHeadset.PowerOffIsEnabled = TRUE ;        }        break;                case EventPlaceIncomingCallOnHold:            if (stateManagerGetState() == headsetIncomingCallEstablish)            {                MAIN_DEBUG(("HS: HoldIncomingCall [%d]\n" , stateManagerGetState() )) ;                HfpHoldIncomingCall(theHeadset.hfp);                        }        break ;

⌨️ 快捷键说明

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