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

📄 ag_main.c

📁 bluetooth audio gateway
💻 C
字号:
#include "ag.h"
#include "ag_private.h"
#include "ag_parse.h"

#ifdef PIO_EAG_ENABLED
#include "pioag.h"
#endif

#include <message.h>
#include <print.h>
#include <sched.h>
#include <stdlib.h>
#include <timer.h>
#include <vm.h>


struct agStruct AGState;

/*
    agPutCmMsg

    Sends messages to the Connection Manager's queue.
*/
void agPutCmMsg(void * msg)
{
    MessagePut(0,msg) ;
}


int main(void)
{
    /* init the timer library */
    PRINT(("This is eag driver!\n"));  
    TimerInit() ;

#ifdef PIO_EAG_ENABLED
    /* 
        If the EAG is being controlled via pio lines then we need to call
        an init function here to start up the application
    */
    pioAgInit();
#endif

    /* Start off the scheduler */
    Sched();

    /* Should never get here since the sched function doesn't return */
    return 0;
}


/*
    AG task 

    This receives messages queued for task 1. In this case this is
    messages sent from the Connection Manager.
*/

DECLARE_TASK(1)
{
    void *msg ;
    MessageType type ;    

    msg = MessageGet(1,&type) ;
    if (msg)
    {        
        switch (type)
        {
                /*  Connection Manager is ready to be used*/
            case CM_INIT_CFM:
                PRINT(("ag_main: CM_INIT_CFM\n"));
                agInitCfm();
                break;
                
                /* SDP service registered */
            case CM_SERVICE_REGISTER_CFM:
                PRINT(("ag_main: CM_SERVICE_REGISTER_CFM\n"));
                agServiceRegisterCfm((CM_SERVICE_REGISTER_CFM_T *)msg);
                break;

                /* A single Inquiry result received */
            case CM_INQUIRY_RESULT_IND:
                PRINT(("ag_main: CM_INQUIRY_RESULT_IND\n"));
                handleInquiryResultInd((CM_INQUIRY_RESULT_IND_T *)msg);
                break;

                /* Inquiry has completed */
            case CM_INQUIRY_COMPLETE_CFM:
                PRINT(("ag_main: CM_INQUIRY_COMPLETE_CFM\n"));
                agInquiryCompleteCfm((CM_INQUIRY_COMPLETE_CFM_T *)msg);
                break ;

                /* Request for a PIN code whilst pairing */
            case CM_PIN_CODE_REQ:
                PRINT(("ag_main: CM_PIN_CODE_REQ\n"));
                agPinCodeReq((CM_PIN_CODE_REQ_T *)msg);
                break;

                /* Confirmation that pairing has completed (could be success or failure) */
            case CM_PAIR_CFM:
                PRINT(("ag_main: CM_PAIR_CFM\n"));
                agPairCfm((CM_PAIR_CFM_T *)msg);
                break;

                /* Link key request */
            case CM_LINK_KEY_REQ:
                PRINT(("ag_main: CM_LINK_KEY_REQ\n"));
                agLinkKeyReq((CM_LINK_KEY_REQ_T *)msg);
                break;

                /* Status of the attempt to open an RFCOMM connection*/
            case CM_CONNECT_CFM:
                PRINT(("ag_main: CM_CONNECT_CFM\n"));
                agConnectCfm((CM_CONNECT_CFM_T *)msg);
                break;

                /* Indicates that an RFCOMM connection has been disconnected */
            case CM_CONNECT_STATUS_IND:
                PRINT(("ag_main: CM_CONNECT_STATUS_IND\n"));
                agRfcommStatusInd((CM_CONNECT_STATUS_IND_T *)msg);
                break;

                /* Indicates the status of a SCO connection */
            case CM_SCO_STATUS_IND:
                PRINT(("ag_main: CM_SCO_STATUS_IND\n"));
                agScoStatusInd((CM_SCO_STATUS_IND_T *)msg);
                break;
                
                /* Contains extra service record data that the app requested */
            case CM_SDP_SUPPORTED_FEATURES_CFM:
                agSdpFeaturesCfm((CM_SDP_SUPPORTED_FEATURES_CFM_T *)msg);
                break;

                /* error message */
            case CM_ERROR_IND:
                PRINT(("ag_main: CM_ERROR_IND\n"));
                agErrorInd((CM_ERROR_IND_T *)msg);
                break;

				/* Service we tried to connect to is not available at remote device */
			case CM_UNSUPPORTED_SERVICE_IND:
				agUnsupportedServiceInd((CM_UNSUPPORTED_SERVICE_IND_T *) msg);
				break;

                /* Ignored or deprecated primitives */
            case CM_OPEN_CFM: /* deprecated */
			case CM_CONTROL_IND: /* ignored */
                break;
            default :
                PRINT(("ag_main: Unrecognised msg type 0x%x from CM\n", type));
                break ;
        }
        MessageDestroy(msg);
    }
}

⌨️ 快捷键说明

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