📄 ag_error.c
字号:
/* Performs an inquiry and returns the results to the phone */
#include "ag_private.h"
#include "ag.h"
#include <message.h>
#include <print.h>
/*
agErrorInd
Error message received from the Connection Manager. Translate the
error code into an AG error code and send to the client.
*/
void agErrorInd(const CM_ERROR_IND_T *ind)
{
switch(ind->error)
{
case CmErrorConnectRequestWhenNotIdle:
agSendErrorToClient(AgErrorConnectRequestWhenNotIdle, &ind->addr);
break;
case CmErrorPairRequestWhenNotIdle:
agSendErrorToClient(AgErrorPairRequestWhenNotIdle, &ind->addr);
break;
case CmErrorInquiryRequestWhenNotIdle:
agSendErrorToClient(AgErrorInquiryRequestWhenNotIdle, &ind->addr);
break;
case CmErrorCancelWhenIdle:
agSendErrorToClient(AgErrorCancelWhenIdle, &ind->addr);
break;
case CmErrorDataRequestWhenNotConnected:
agSendErrorToClient(AgErrorDataRequestWhenNotConnected, &ind->addr);
break;
case CmErrorScoRequestWhenScoConnected:
agSendErrorToClient(AgErrorScoRequestWhenScoConnected, &ind->addr);
break;
case CmErrorDisconnectRequestWhenNotConnected:
agSendErrorToClient(AgErrorDisconnectRequestWhenNotConnected, &ind->addr);
break;
case CmErrorSmDeviceDatabaseError:
agSendErrorToClient(AgErrorSmDeviceDatabaseError, &ind->addr);
break;
case CmWarnLocalSniffNotEnabled:
agSendErrorToClient(AgWarnLocalSniffNotEnabled, &ind->addr);
break;
case CmWarnLocalParkNotEnabled:
agSendErrorToClient(AgWarnLocalParkNotEnabled, &ind->addr);
break;
case CmWarnLocalLowPwrModeNotEnabled:
agSendErrorToClient(AgWarnLocalLowPwrModeNotEnabled, &ind->addr);
break;
case CmWarnRemDevDoesNotSupportSniffMode:
agSendErrorToClient(AgWarnRemoteDevDoesNotSupportSniffMode, &ind->addr);
break;
case CmWarnRemDevDoesNotSupportParkMode:
agSendErrorToClient(AgWarnRemoteDevDoesNotSupportParkMode, &ind->addr);
break;
case CmWarnRemoteLowPwrModeNotEnabled:
agSendErrorToClient(AgWarnRemoteLowPwrModeNotEnabled, &ind->addr);
break;
default:
PRINT(("ag_error: Unknown error type 0x%x\n", ind->error));
break;
}
}
/*
agSendErrorToClient
Send a given error message to the client.
*/
void agSendErrorToClient(ag_error_code_t error_reason, const BD_ADDR_T *rem_device)
{
if (rem_device == 0)
handleErrorInd(UNDEFINED_HANDLE, error_reason);
else
handleErrorInd(agGetConnectionHandle(rem_device), error_reason);
}
/*
agCancelReqAction
Cancel the current state that the Connection Manager is in
e.g. inquiry, pair etc.
*/
void agCancelReqAction(void)
{
if (AGState.currentState == AgInquiring ||
AGState.currentState == AgPairing ||
AGState.currentState == AgConnecting)
{
MAKE_MSG(CM_CANCEL_REQ);
agPutCmMsg(msg);
}
else if (AGState.currentState == AgConnected)
{
/* RFCOMM up sending rings but they have been cancelled */
agStopRings();
/* TODO need to send a call ind for calls rejected by action at the AG */
}
else
{
agSendErrorToClient(AgErrorCannotCancelThisMode, 0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -