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

📄 hostag_main.c

📁 bluetooth audio gateway
💻 C
字号:
#include "hostag_private.h"

#include <host.h>
#include <print.h>
#include <sched.h>
#include <stdlib.h>




/*
    hostAgPutHostMsg

    Sends messages to the client using host communications over BCSP
    channel 13.
*/
void hostAgPutHostMsg(void *msg)
{
    (void) HostSendMessage((uint16 *)msg);
}


/*
    handleHostMessage
    Handles messages from the client that arrive over BCSP channel 13
*/
void handleHostMessage(void)
{
    uint16 *data;

    while((data = HostGetMessage()) != NULL)
    {
        switch(data[1])
        {
            /* Message sent to EAG so driver can check the EAG is up and running */
        case AG_START_REQ:
            PRINT(("hostag_main: StartReq received\n"));
            hostAgStartReq((AG_START_REQ_T *)((void *)(data+2)), data[0]);
            break;
            
            /* Request to start an inquiry */
        case AG_INQUIRY_REQ:
            PRINT(("hostag_main: InquiryReq received\n"));
            hostAgInquiryReq((AG_INQUIRY_REQ_T *)((void *)(data+2)));            
            break;
                        
            /* Request to initiate pairing */
        case AG_PAIR_REQ:
            PRINT(("hostag_main: PairReq received\n"));
            hostAgPairReq((AG_PAIR_REQ_T *)((void *)(data+2)));
            break;
            
            /* Send the user supplied PIN code to the Connection Manager */
        case AG_PIN_CODE_RES:
            PRINT(("hostag_main: PINcodeRes received\n"));
            hostAgPinRes((AG_PIN_CODE_RES_T *)((void *)(data+2)));
            break;
            
            /* Send the user supplied link key to the Connection Manager */
        case AG_LINK_KEY_RES:
            PRINT(("hostag_main: LinkKeyRes received\n"));
            hostAgLinkKeyRes((AG_LINK_KEY_RES_T *)((void *)(data+2)));
            break;
            
            /* Handle an RFCOMM connection request */
        case AG_CONNECT_AS_MASTER_REQ:
            PRINT(("hostag_main: ConnectAsMasterReq received\n"));
            hostAgConnectAsMasterReq((AG_CONNECT_AS_MASTER_REQ_T *)((void *)(data+2)));
            break;
            
            /* Handle request to connect as a slave */
        case AG_CONNECT_AS_SLAVE_REQ:
            PRINT(("hostag_main: ConnectAsSlaveReq received\n"));
            hostAgConnectAsSlaveReq((AG_CONNECT_AS_SLAVE_REQ_T *)((void *)(data+2)));
            break;
            
            /* Request to disconnect an RFCOMM connection */
        case AG_RFCOMM_DISCONNECT_REQ:
            PRINT(("hostag_main: DisconnectRFCOMMReq received\n"));
            hostAgRfcommDisconnectReq((AG_RFCOMM_DISCONNECT_REQ_T *)((void *)(data+2)));
            break;

            /* request to create a SCO connection */
        case AG_CREATE_SCO_REQ:
            PRINT(("hostag_main: CreateSCOReq received\n"));
            hostAgCreateScoReq((AG_CREATE_SCO_REQ_T *)((void *)(data+2)));
            break;
            
            /* Request to disconnect a SCO connection */
        case AG_SCO_DISCONNECT_REQ:
            PRINT(("hostag_main: DisconnectSCOReq received\n"));
            hostAgScoDisconnectReq((AG_SCO_DISCONNECT_REQ_T *)((void *)(data+2)));
            break;
                        
            /* Send a ring request */
        case AG_RING_REQ:
            PRINT(("hostag_main: RingReq received\n"));
            hostAgRingReq((AG_RING_REQ_T *)((void *)(data+2)));
            break;
            
            /* Volume level change request */
        case AG_VOLUME_CHANGE_REQ:
            PRINT(("hostag_main: VolChangeReq received\n"));
            hostAgVolumeGainReq((AG_VOLUME_CHANGE_REQ_T *)((void *)(data+2)));
            break;

            /* Microphone level change request */
        case AG_MIC_CHANGE_REQ:
            PRINT(("hostag_main: MicChangeReq received\n"));
            hostAgMicrophoneChangeReq((AG_MIC_CHANGE_REQ_T *)((void *)(data+2)));
            break;

            /* Send manufacturer specific data */
        case AG_DATA_REQ:
            PRINT(("hostag_main: CustomDataReq received\n"));
            hostAgDataReq((AG_DATA_REQ_T *)((void *)(data+2)));
            break;

            /* AG must send the call status to the HF */
        case AG_SEND_CALL_STATUS_REQ:
            PRINT(("hostag_main: SendCallStatusReq received\n"));
            hostAgCallStatusReq((AG_SEND_CALL_STATUS_REQ_T *)((void *)(data+2)));
            break;

		case AG_SEND_CALL_SETUP_REQ:
			PRINT(("hostag_main: SendCallSetupReq received\n"));
			hostAgCallSetupReq((AG_SEND_CALL_SETUP_REQ_T *)((void *)(data+2)));
			break;

		case AG_SEND_SERVICE_STATUS_REQ:
			PRINT(("hostag_main: SendServiceStatusReq received\n"));
			hostAgServiceReqAction((AG_SEND_SERVICE_STATUS_REQ_T *)((void *)(data+2)));
			break;

            /* Store link key in Bluestack security manager for faster authentication */
        case AG_SM_ADD_DEVICE_REQ:
            PRINT(("hostag_main: SmAddDeviceRequest received \n"));
            hostAgSmAddDeviceReq((AG_SM_ADD_DEVICE_REQ_T *)((void *)(data+2)));
            break;            

            /* Request to cancel the current state e.g. inquiry, pairing etc */
        case AG_CANCEL_REQ:
            PRINT(("hostag_main: CancelReq received\n"));
            hostAgCancelReq();
            break;
            
        default:
            PRINT(("hostag_main: Unrecognised message type 0x%x received from host.\n", data[1]));
            break;
        }
        /* Must free the message otherwise we'll be in all sorts of trouble */
        free(data);
    }
}

⌨️ 快捷键说明

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