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

📄 hosthf_main.c

📁 蓝牙HANDFREE软件源代码
💻 C
字号:
#include "hosthf_private.h"
#include "handsfree.h"

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


/*
    hostHfPutGuiMsg

    Sends messages to the client using host communications over BCSP
    channel 13.
*/
void hostHfPutGuiMsg(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 START_REQ:
			{
				START_REQ_T *req = (START_REQ_T *) ((void *)(data+2));
				startReqAction(req->supported_features, (uint16) frameworkHandsFree);
            }
            break;
            
            /* Request to put device into pairing mode */
        case PAIR_REQ:
			{
				PAIR_REQ_T *req = (PAIR_REQ_T *) ((void *)(data+2));
				pairReqAction(req->timeout, frameworkHandsFree);
            }
            break;
            
            /* Cancel the current mode of the hands-free device*/
        case CANCEL_REQ:
            cancelCurrentStateAction();
            break;
            
            /* Disconnect the specified connection to the given address */
        case DISCONNECT_REQ:
			{
				DISCONNECT_REQ_T *req = (DISCONNECT_REQ_T *) ((void *)(data+2));
				disconnectReqAction(req->linkType);
            }
            break;
            
            /* Volume change request from GUI */
        case VOLUME_CHANGE_REQ:
			{
				VOLUME_CHANGE_REQ_T *req = (VOLUME_CHANGE_REQ_T *) ((void *)(data+2));
				volumeReqAction(req->increment, req->gain);
            }
            break;
            
            /* Request to dial specified number to be sent to AG */
        case DIAL_NUMBER_REQ:
            hostHfDialNumberReq((DIAL_NUMBER_REQ_T *)((void *)(data+2)));
            break;
            
            /* Send request to dial number in the specified memory location */
        case DIAL_MEMORY_REQ:
            hostHfDialMemoryReq((DIAL_MEMORY_REQ_T *)((void *)(data+2)));
            break;
            
            /* Last number redial request */
        case LAST_NUMBER_REDIAL_REQ:
            lastNumberRedialAction();
            break;
            
            /* Transfer audio connection from AG to HF but HF sets up SCO */
        case AUDIO_TRANSFER_REQ:
			{
				AUDIO_TRANSFER_REQ_T *req = (AUDIO_TRANSFER_REQ_T *)((void *)(data+2));
				callTransferReqAction(req->pktType);
            }
            break;
            
            /* Accept an incoming call */
        case ANSWER_REQ:
            callAnswerAction();
            break;
            
            /* Reject an incoming call */
        case HANG_UP_REQ:
            callRejectAction();
            break;

            /* Enable caller id reporting on the AG */
        case CALLER_ID_REQ:
			{
				CALLER_ID_REQ_T *req = (CALLER_ID_REQ_T *) ((void *)(data+2));
				hfCallerIdEnableAction(req->enable);
			}
            break;

            /* Request to toggle the mute setting on the local microphone */
        case MUTE_MIC_REQ:
            hfToggleMuteMicAction();
            break;

            /* Enable or disable voice dialling at the AG */
        case VOICE_DIAL_REQ:
			{
				VOICE_DIAL_REQ_T *req = (VOICE_DIAL_REQ_T *) ((void *)(data+2));
				startVoiceDialAction(req->enable);
			}            
            break;

            /* Disable the NR/ EC functionality of the AG */
        case NREC_DISABLE_REQ:
			disableNrecAction();            
            break;

		case SEND_DTMF_REQ:
			{
				SEND_DTMF_REQ_T *req = (SEND_DTMF_REQ_T *)((void *)(data+2));
				sendDtmfReqAction(req->dtmf);
			}
			break;

        default:
            PRINT(("main: Unrecognised message type 0x%x received from host.\n", data[1]));
            handleErrorInd(HfErrorUnknownOrUnhandledState);
            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 + -