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

📄 ag_athandler.c

📁 bluetooth audio gateway
💻 C
📖 第 1 页 / 共 2 页
字号:
    }
    else if (s->mode == 0)
    {
        /* Disable event reporting. */
        AGState.hfIndicatorUpdateEnabled = 0;
    }
    else 
    {
        /* unrecognised mode value so send an error message */
        error_flag = 1;
    }

    /* send OK or ERROR to indicate outcome */
    if (error_flag)    
    {
        /* Couldn't parse the command properly so send ERROR */
        agSendError();
    }
    else
    {        
        agSendStatusIndToClient(*addr, CmConnectComplete);

        /* ack the command */
        agSendOk();
    }
}


/*
    handleCallAnswer
    
    Remote device's response to ring alert was to accept the call
    AT cmd: ATA
*/
void handleCallAnswer(const BD_ADDR_T * addr)
{
    /* ack the command */
    agSendOk();
    
    agCallAnswered(*addr);
}


/*
    handleCallHangUp

    Remote device's response to ring alert was to reject the call or
    the remote device wishes to terminate an ongoing call
    AT cmd: AT+CHUP
*/
void handleCallHangUp(const BD_ADDR_T * addr)
{
    /* ack the command */
    agSendOk();

	/* Handle the call reject */
    agCallRejected(*addr);
}


/*
    handleRemoteNumberDial

    Request from hands free device to dial the given number
    AT cmd: ATD num
*/
void handleRemoteNumberDial(const BD_ADDR_T * addr, const struct RemoteNumberDial *s)
{
    /* ack the cmd */
    agSendOk();

    /* Pass the number info to the driver app to dial it */
    agReceivedDialNumber(*addr, s->number.data, s->number.length);
}


/*
    handleRemoteMemoryDial

    Request from hands-free device to dial number in given memory location
    AT cmd: ATD> num
*/
void handleRemoteMemoryDial(const BD_ADDR_T * addr, const struct RemoteMemoryDial *s)
{    
    /* ack the cmd */
    agSendOk();

    /* Inform the client */
    agReceivedMemoryDial(*addr, s->memory.data, s->memory.length);
}


/*
    handleLastNumberRedial

    Request from hands-free device to redial the last number dialled
    AT cmd: AT+BLDN
*/
void handleLastNumberRedial(const BD_ADDR_T * addr)
{
    /* ack the cmd */
    agSendOk();

    /* Inform the client */
    agReceivedLastNumberRedial(*addr);
}


/*
    handleCallWaitingEnable

    Call waiting notification enable/ disable AT command
    AT cmd: AT+CCWA
*/
void handleCallWaitingEnable(const BD_ADDR_T * addr, const struct CallWaitingEnable *s)
{
    /* keep the compiler happy */
    addr=addr;

    /* ack the cmd */
    agSendOk();

    /* TODO take appropriate action */
    s = s;
    PRINT(("TODO Handle call waiting notification status %d\n", s->status));
}


/*
    handleCallHoldRequest

    Request from the hands free device instructing the AG what to do with
    the extra call (this is used in multiparty call handling)
    AT cmd: AT+CHLD
*/
void handleCallHoldRequest(const BD_ADDR_T * addr, const struct CallHoldRequest *s)
{
    /* keep the compiler happy */
    addr = addr;

    /* ack the cmd */
    agSendOk();

    /* TODO take appropriate action */
    s = s;
    PRINT(("TODO Call hold req arg %d\n", s->hold));
}


/*
    handleCallHoldTestCmd

    Request for the call hold settings on the AG
    AT cmd: AT+CHLD=?
*/
void handleCallHoldTestCmd(const BD_ADDR_T * addr)
{
    /* keep the compiler happy */
    addr = addr;

    /* Check the AG supports three way calling */
    if (getHfSupportedFeature(three_way_calls))
    {
        agSendCallHoldSettings();               

        /* ack the cmd */
        agSendOk();
    }
    else
    {   
        /* Send an error, the AG does not support this and the HF should know */
        agSendError();
    }   
}


/*
    handleCallerIdActivation

    Used by hands free to enable calling line identification notification
    AT cmd: AT+CLIP
*/
void handleCallerIdActivation(const BD_ADDR_T *addr, const struct CallerIdActivation *s)
{
    /* keep the compiler happy*/
    addr = addr;
    s = s;

    /* ack the cmd */
    agSendOk();

    /* TODO enable/ disable CLI notification */
    PRINT(("TODO enable CLI notification\n"));
}


/*
    handleEchoCancellingDisable

    If the AG supports this (indicated by supported features field in SDP
    record) then enable/ disable it otherwise reply with error
    AT cmd: AT+NREC
*/
void handleEchoCancellingDisable(const BD_ADDR_T * addr, const struct EchoCancellingDisable *s)
{    
    /* keep the compiler happy */
    addr = addr;

    /* Check if this is supported by the AG. */        
    if (getHfSupportedFeature(echo_cancel))
    {
        /* ack the cmd */
        agSendOk();

        /* TODO take appropriate action */
        s = s;
        PRINT(("TODO EC/ NR enable %d\n", s->enable));
    }
    else
    {
        /* This feature is not supported by the AG send an error */
        agSendError();
    }
}


/*
    handleVoiceRecognitionEnable

    If the AG supports voice recognition (indicated by supported 
    features field in SDP record), this command is used to activate
    and deactivate this function.
    AT cmd: AT+BVRA
*/
void handleVoiceRecognitionEnable(const BD_ADDR_T * addr, const struct VoiceRecognitionEnable *s)
{    
    /* keep the compiler happy */
    addr = addr;

	if (AGState.hfVoiceRecogEnable && s->enable)
	{		
		/* If voice recognition already enabled we cannot enable it again */
		agSendError();
		return;
	}

    /* Check if this is supported by the AG. */   
    if (getHfSupportedFeature(voice_recog))
    {
		/* ack the cmd */
		agSendOk();
		
		/* Update the local state and then pass on to the driver app */
		agVoiceRecognitionEnable(s->enable);
    }
    else
    {
        /* This feature is not supported by the AG send an error */
        agSendError();
    }
}


/*
    handleSpecificDataRequest

    Request for specific data input from the AG. 
    AT cmd: AT+BINP
*/
void handleSpecificDataRequest(const BD_ADDR_T * addr, const struct SpecificDataRequest *s)
{
    /* keep the compiler happy */
    addr = addr;

    /* 
        The hands free spec strongly recommends that this feature is 
        supported for both interoperability and compatibility but we must
        check anyway
    */
    if (getHfSupportedFeature(voice_tag))
    {
        if (s->request == 1)
        {
            /* Everything as expected so ack the cmd */
            agSendOk();

            /* TODO take appropriate action */
            PRINT(("TODO Voice tag phone num request\n"));
        }
        else
        {
            /* 
                Currently only returning a phone number is supported by 
                the hands free spec 
            */
            agSendError();
        }
    }
    else
    {
        /* This feature is not supported by the AG send an error */
        agSendError();
    }
}


/*
    handleDTMFGeneration

    Request to generate a DTMF tone
    AT cmd: AT+VTS
*/
void handleDTMFGeneration(const BD_ADDR_T * addr, const struct DTMFGeneration *s)
{
    /* keep the compiler happy */
    addr = addr;

    if (s->code.length != 1)
    {
        /* 
            Check we have only been sent one character else send error. AT
            command spec explicitly state this are should be a single 
            ASCII character
        */
        agSendError();
    }
    else
    {
        int dtmf_char = tolower((int) s->code.data[0]);        

		/* 
            Check the char sent is from the subset allowed by the spec 
            i.e. 0-9, #, *, A-D and nothing else!
        */
        if (isdigit(dtmf_char) || (dtmf_char == '#') ||  (dtmf_char == '*') ||
            (dtmf_char == 'a') || (dtmf_char == 'b') ||
            (dtmf_char == 'c') || (dtmf_char == 'd'))
        {
            /* ack the cmd */
            agSendOk();
            
            PRINT(("TODO DTMF char received %c\n", dtmf_char));

            /* TODO do something appropriate */
        }
        else
        {
            /* Char not in the subset defined in the AT command spec */
            agSendError();
        }

    }
}

⌨️ 快捷键说明

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