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

📄 main.c

📁 蓝牙a2dp_source_dongle的例程
💻 C
📖 第 1 页 / 共 3 页
字号:
                default:
                    unhandledState(id);
                    break;
            }
            break;

        case APP_START_STREAMING_REQ:
            /* Check the current state */
            switch (state_a2dp)
            {
                case a2dp_state_connected:
                    a2dpSdStreamRequest(&theApp);
                    break;

                case a2dp_state_accepting:
                case a2dp_state_disconnecting:
                case a2dp_state_streaming:
                case a2dp_state_initiating:
                case a2dp_state_discovering:
                case a2dp_state_initialising:
                default:
                    unhandledState(id);
                    break;
            }
            break;

		case APP_SUSPEND_STREAMING_REQ:
            /* Check the current state */
            switch (state_a2dp)
            {
				case a2dp_state_streaming:
                    a2dpSdSuspendRequest(&theApp);
                    break;

                case a2dp_state_accepting:
                case a2dp_state_disconnecting:
                case a2dp_state_connected:
                case a2dp_state_initiating:
                case a2dp_state_discovering:
                case a2dp_state_initialising:
                default:
                    unhandledState(id);
                    break;
            }
            break;

        case APP_KICK_PROFILE_REQ:
            /* Check the current state */
            switch (state_a2dp)
            {
                case a2dp_state_accepting:
                    a2dpSdKickProfileRequest(&theApp);
                    break;

                /* Ignore these states */
                case a2dp_state_disconnecting:
                case a2dp_state_connected:
                case a2dp_state_streaming:
                case a2dp_state_initiating:
                case a2dp_state_discovering:
                case a2dp_state_initialising:
                    break;

                default:
                    unhandledState(id);
                    break;
            }
            break;

        case APP_DISCOVER_TIMEOUT_IND:
            /* Check the current state */
            switch (state_a2dp)
            {
                case a2dp_state_discovering:
                    a2dpDiscoverTimeout();
                    break;

                /* Should not have the timeout firing if we're in any other state */
                case a2dp_state_initialising:
                case a2dp_state_accepting:
                case a2dp_state_initiating:
                case a2dp_state_connected:
                case a2dp_state_streaming:
                case a2dp_state_disconnecting:
                default:
                    unhandledState(id);
                    break;
            }
            break;

        case APP_LED_TIMEOUT_IND:
            /* 
                Regardless of the state we want to update the flashing LED 
                as each state has a different flashing duty cycle 
            */
            a2dpSdUpdateLed(0, state_a2dp);
            break;

		case APP_CONNECT_TIMEOUT_IND:
			/* Check the current state */
            switch (state_a2dp)
            {
				/* The timeout could fire while we're trying to connect or even just after we've connected. */
				case a2dp_state_initiating:
				case a2dp_state_accepting:
                case a2dp_state_connected:
                case a2dp_state_streaming:
					/* Stop any further connect attempts. */
					theApp.connect_timer_expired = 1;
                    break;

                /* Should not have the timeout firing if we're in any other state */
                case a2dp_state_initialising:
				case a2dp_state_discovering:
                case a2dp_state_disconnecting:
                default:
                    unhandledState(id);
                    break;
            }
			break;

        case APP_BUTTON_PRESS_IND:
            /* Button pressed, just update the flashing LEDs action taken on release */
            a2dpSdUpdateLed(1, state_a2dp);
            break;

        case APP_BUTTON_RELEASE_IND:
            /* Check the current state */
            switch (state_a2dp)
            {
                case a2dp_state_accepting:
                case a2dp_state_initiating:
                case a2dp_state_connected:
                case a2dp_state_streaming:
                case a2dp_state_disconnecting:
                case a2dp_state_discovering:
                    /* 
                        Button release triggers discover request, the message 
                        handler for this message will make sure we're in the 
                        right state to initiate the discovery 
                    */
                    MessageSend(&theApp.task, APP_DISCOVER_REQ, 0);

                    /* Update the LED flashing */
                    a2dpSdUpdateLed(1, state_a2dp);
                    break;

                case a2dp_state_initialising:
                default:
                    unhandledState(id);
                    break;
            }
            break;

        /* The connection lib initialisation has completed */
        case CL_INIT_CFM:
            /* Check the current state */
            switch (state_a2dp)
            {
                case a2dp_state_initialising:
                {
                    if (((CL_INIT_CFM_T *) message)->status == success)
                        /* Proceed with app init. */
                        a2dpSdClInitSuccess(&theApp);
                    else
                        /* Connection lib init failed, something has gone horribly wrong. */
                        Panic();
                }
                break;

                case a2dp_state_discovering:            
                case a2dp_state_accepting:
                case a2dp_state_initiating:
                case a2dp_state_connected:
                case a2dp_state_streaming:
                case a2dp_state_disconnecting:
                default:
                    unhandledState(id);
                    break;
            }
            break;

        case CL_DM_INQUIRE_RESULT:
            /* Check the current state */
            switch (state_a2dp)
            {
                case a2dp_state_discovering:
                    /* Check if this is an inquiry result or complete event */
                    if (((CL_DM_INQUIRE_RESULT_T *) message)->status == inquiry_status_result)
                    {
                        /* Handle the inquiry result */
                        a2dpSdInquiryResult(&(((CL_DM_INQUIRE_RESULT_T *) message)->bd_addr));
                    }
                    break;

                case a2dp_state_accepting:
                    /* 
                        If we're discovering and the discovery timeout message fires
                        we issue an inquiry cancel request. An inquiry result message
                        with a status of ready will be returned to indicate the inquiry 
                        was cancelled. Just ignore this.
                    */
                    break;

                /* Should not be discovering in any other state */
                case a2dp_state_initialising:
                case a2dp_state_initiating:
                case a2dp_state_connected:
                case a2dp_state_streaming:
                case a2dp_state_disconnecting:
                default:
                    unhandledState(id);
                    break;
            }
            break;

        case CL_SDP_SERVICE_SEARCH_CFM:
            /* Check the current state */
            switch (state_a2dp)
            {
                case a2dp_state_discovering:
                    {
                        CL_SDP_SERVICE_SEARCH_CFM_T *cfm = (CL_SDP_SERVICE_SEARCH_CFM_T *) message;

                        /* Check if the SDP search succeeded */
                        if (cfm->status == sdp_response_success)
                        {
                            /* The device does support the required service */
                            a2dpDiscoverServiceSearchSuccess(cfm);
                        }
                        else
                        {
                            /* The device does not support the required service */
                            a2dpDiscoverServiceSearchFail(&theApp);
                        }
                    }
                    break;

                case a2dp_state_accepting:
                    /* 
                        If we're discovering and the discovery timeout message fires
                        we issue an SDP terminate request. This will be ignored if there 
                        is no search open or a search cfm primitive will be returned
                        indicating the search was terminated. In either case we're not 
                        interested so just ignore the message.
                    */
                    break;

                /* Should not be discovering in any other state */
                case a2dp_state_initialising:
                case a2dp_state_initiating:
                case a2dp_state_connected:
                case a2dp_state_streaming:
                case a2dp_state_disconnecting:
                default:
                    unhandledState(id);
                    break;
            }
            break;

        case CL_SM_PIN_CODE_IND:
            {
                /* Check the current state */
                switch (state_a2dp)
                {
                case a2dp_state_discovering:
                case a2dp_state_accepting:
                case a2dp_state_initiating:
                    a2dpSdHandlePinCodeInd((CL_SM_PIN_CODE_IND_T *) message);
                    break;

                case a2dp_state_initialising:
                case a2dp_state_connected:
                case a2dp_state_streaming:
                case a2dp_state_disconnecting:              
                default:
                    unhandledState(id);
                    break;
                }
            }
            break;

        case CL_SM_AUTHORISE_IND:
                /* Check the current state */
                switch (state_a2dp)
                {
                case a2dp_state_discovering:
                case a2dp_state_accepting:
                case a2dp_state_initiating:
                case a2dp_state_connected:
                case a2dp_state_streaming:
                    a2dpSdHandleAuthoriseInd(&theApp, (CL_SM_AUTHORISE_IND_T *) message);
                    break;

                case a2dp_state_disconnecting:
                    a2dpSdHandleAuthoriseIndReject((CL_SM_AUTHORISE_IND_T *) message);
                    break;

                case a2dp_state_initialising:
                default:
                    unhandledState(id);
                    break;
                }
            break;

            /* Ignored prims */
        case CL_SM_AUTHENTICATE_CFM:
		case CL_DM_ACL_OPENED_IND:
		case CL_DM_ACL_CLOSED_IND:
            break;

		case CL_SM_ENCRYPTION_CHANGE_IND:
        case CL_DM_ROLE_CFM:
        case CL_DM_REMOTE_NAME_COMPLETE:
        case CL_DM_CLASS_OF_DEVICE_CFM:
        case CL_DM_LOCAL_BD_ADDR_CFM:
        case CL_DM_LINK_QUALITY_CFM:
        case CL_DM_RSSI_CFM:
        case CL_DM_REMOTE_FEATURES_CFM:
        case CL_DM_CLOCK_OFFSET_CFM:
        case CL_SM_SECURITY_LEVEL_CFM:
        case CL_SDP_REGISTER_CFM:
        case CL_SDP_UNREGISTER_CFM:
        case CL_SDP_OPEN_SEARCH_CFM:
        case CL_SDP_CLOSE_SEARCH_CFM:
        case CL_SDP_ATTRIBUTE_SEARCH_CFM:
        case CL_SDP_SERVICE_SEARCH_ATTRIBUTE_CFM:
        case CL_L2CAP_REGISTER_CFM:
        case CL_L2CAP_UNREGISTER_CFM:
        case CL_L2CAP_CONNECT_CFM:
        case CL_L2CAP_CONNECT_IND:
        case CL_L2CAP_DISCONNECT_IND:
        case CL_RFCOMM_REGISTER_CFM:
        case CL_RFCOMM_CONNECT_CFM:
        case CL_RFCOMM_CONNECT_IND:
        case CL_RFCOMM_DISCONNECT_IND:
        case CL_RFCOMM_CONTROL_IND:
        case CL_DM_LINK_POLICY_IND:
            unhandledState(id);
            break;
                
        case A2DP_INIT_CFM:     
            /* Check the local state */
            switch (state_a2dp)
            {
                case a2dp_state_initialising:
                {
                    /* Check the outcome of the init request. */
                    if (((A2DP_INIT_CFM_T *) message)->status == a2dp_success)
                    {
                        /* Profile instance init ok so store the ptr to it */
                        theApp.a2dp = ((A2DP_INIT_CFM_T *) message)->a2dp;
                        
                        /* Handle the a2dp init cfm */
                        a2dpSdA2dpLibInitSuccess(&theApp);
                    }
                    else
                        /* A2DP lib init failed, something has gone horribly wrong. */
                        Panic();
                }
                break;

                case a2dp_state_discovering:            
                case a2dp_state_accepting:
                case a2dp_state_initiating:
                case a2dp_state_connected:

⌨️ 快捷键说明

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