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

📄 ag_atreply.c

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

#include <message.h>
#include <print.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define SERVICE_INDEX		1
#define CALL_INDEX			2
#define CALL_SETUP_INDEX	3


/*
    agSendCiev
    
    Generate and send the CIEV response with the given parameters
*/
static void agSendCiev(uint16 ind, uint16 value)
{
    if (AGState.hfIndicatorUpdateEnabled)
    {                
        /* if status updates are enabled */                                
        char buf [20];
        sprintf(buf, "\r\n+CIEV:%d,%d\r\n", ind, value);
        (void) agSendATmessage(buf, strlen(buf));
    }
}


/*
    agSendOk

    Send an OK AT command to acknowledge AT cmd received from headset.
*/
void agSendOk(void)
{
    char *ok_str = "\r\nOK\r\n";
    
	/* TODO what if this fails */
	(void) agSendATmessage(ok_str, strlen(ok_str));
}


/*
    agSendERROR

    Send an ERROR AT command if response from headset is not
    recognised.
*/
void agSendError(void)
{
    char *error_str = "\r\nERROR\r\n";

    /* TODO check return code */
    (void) agSendATmessage(error_str, strlen(error_str));
}


/*
    agSendServiceInd

    Set status of the service indicator and send it.
*/
void agSendServiceInd(uint16 value)
{
    AGState.hfServiceIndicator = value;
    agSendCiev(SERVICE_INDEX, AGState.hfServiceIndicator);
}


/*
    agSendCallInd

    Set the status of the call indicator and send it.
*/

void agSendCallInd(uint16 value)
{
    /* set the ind value even if we can't send the update immediately */    
    AGState.hfCallIndicator = value;    	
    agSendCiev(CALL_INDEX, AGState.hfCallIndicator);

	/* If sending call active always send call_setup no call */
	if (AGState.hfCallIndicator)
		agSendCallSetupInd(call_setup_no_call);
}


/*
	agSendCallSetupInd

	Send the call_setup indicator to the HF
*/
void agSendCallSetupInd(ag_call_setup_vals_t value)
{
	PRINT(("send call_setup\n"));
	agSendCiev(CALL_SETUP_INDEX, value);
}


/*
    agCallStatusReqAction
    
    The call can be answered at the AG at which point the spec requires that
    the AG notifies the hands-free that there is a call active. The embedded
    AG cannot determine if the call has been answered so the driver app must
    send a SEND_CALL_STATUS_REQ message so the call ind is sent out.
*/
void agCallStatusReqAction(uint16 status)
{
    agSendCallInd(status);
}


/*
	agCallSetupReqAction

	The off chip driver needs to be able to indicate to the other end that the
	remote party is being alerted and the call is being established so these
	indicators can be sent to the HF unit.
*/
void agCallSetupReqAction(ag_call_setup_vals_t call_setup)
{
	agSendCallSetupInd(call_setup);
}


/*
	agServiceStatusReqAction

	The off-chip driver needs to be able to send a service registration
	indicator to the AG.
*/
void agServiceStatusReqAction(uint16 status)
{
	agSendServiceInd(status);
}

⌨️ 快捷键说明

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