?? ag_microphone.c
字號:
#include "ag_private.h"
#include "ag.h"
#include <stdlib.h>
#include <string.h>
/*
sendMicrophoneGain
Send out a microphone gain AT cmd
*/
static void sendMicrophoneGain(uint8 gain)
{
/*
Check gain is in the range allowed by the supported profile.
Gain is unsigned so will always be >= zero
*/
if (gain <= 15)
{
uint8 *ptr;
const char *at_mic_str = "\r\n+VGM=??\r\n";
uint16 buflen = strlen(at_mic_str);
char *buf = (char *) agAlloc(buflen);
memcpy(buf, at_mic_str, buflen);
ptr = (uint8 *)buf;
while (*ptr != '=')
ptr ++ ;
/* insert the mic gain */
ptr[1] = '0' + gain /10;
ptr[2] = '0' + gain % 10;
/* TODO maybe should set a pending flag in case this fails */
(void) agSendATmessage(buf, buflen);
agMicChangeInd(AGState.remote_addr, gain);
free(buf);
}
/* TODO else send error to app telling it gain was not in range */
}
/*
agMicChangeReqAction
Request to send a set microphone gain AT command.
Because this is not supported internally i.e. you cannot set the
mic gain on the EAG (in the same way that you can set the volume
level for example) this function just checks the parameters sent
to it are valid and sends out the AT command.
*/
void agMicChangeReqAction(uint8 gain)
{
if (agIsCurrentlyHandsFree())
{
/* HFP does not need SCO to be up to send mic gain */
sendMicrophoneGain(gain);
}
else
{
/* Make sure there is a SCO connected */
if (agScoConnectedQuery())
sendMicrophoneGain(gain);
else
agSendErrorToClient(AgErrorUnexpectedPrimitive, 0);
}
}
/*
agMicChangeInd
Inform the user of a change in the microphone gain. Similarly to the
volume command, this is generated when a VGM AT command is received
from the remote device.
*/
void agMicChangeInd(BD_ADDR_T addr, uint16 gain)
{
/* inform the interface */
handleMicrophoneChangeInd(agGetConnectionHandle(&addr), (uint8) gain);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -