📄 ag_state.c
字号:
#include "ag.h"
#include "ag_private.h"
/*
agRfcommConnectedQuery
Returns true if there is an RFCOMM connection up, false otherwise
*/
uint16 agRfcommConnectedQuery(void)
{
if (AGState.currentState == AgScoConnected ||
AGState.currentState == AgConnected)
return 1;
return 0;
}
/*
agScoConnectedQuery
Return true if there is a SCO connection up, false otherwise
*/
uint16 agScoConnectedQuery(void)
{
if (AGState.currentState == AgScoConnected)
return 1;
return 0;
}
/*
agIdleQuery
If the AG state is currently idle, return true, else return false
*/
uint16 agIdleQuery(void)
{
if (AGState.currentState == AgIdle)
return 1;
return 0;
}
/*
agSetCurrentState
Update the current state of the AG.
*/
void agSetCurrentState(ag_state_t new_state)
{
AGState.currentState = new_state;
}
/*
agSetCurrentProfile
Set the profile that the AG is currently connecting as.
*/
void agSetCurrentProfile(ag_profile_role_t new_role)
{
AGState.currentProfile = new_role;
}
/*
agIsCurrentlyHeadset
Returns true if the AG is currently in headset mode, false otherwise.
*/
uint16 agIsCurrentlyHeadset(void)
{
if (AGState.currentProfile & agHeadsetProfile)
return 1;
else
return 0;
}
/*
agIsCurrentlyHandsFree
Returns true if the AG is currently in hands free mode, false otherwise
*/
uint16 agIsCurrentlyHandsFree(void)
{
if (AGState.currentProfile & agHandsFreeProfile)
return 1;
else
return 0;
}
/*
agSetSupportedProfiles
Set the profiles supported by the AG
*/
void agSetSupportedProfiles(ag_profile_role_t profs)
{
ag_profile_role_t valid_mask = agHeadsetProfile | agHandsFreeProfile;
/* Ensure we only set this to the profiles we really can support */
AGState.supportedProfiles = profs & valid_mask;
/* Backwards compatibility - if supp profiles not set default to headset */
if (AGState.supportedProfiles == agProfileNotSet)
AGState.supportedProfiles = agHeadsetProfile;
}
/*
agIsHeadsetSupported
Return true if the headset is one of the supported profiles.
*/
uint16 agIsHeadsetSupported(void)
{
if (AGState.supportedProfiles & agHeadsetProfile)
return 1;
else
return 0;
}
/*
agIsHandsFreeSupported
Return true if the headset is one of the supported profiles.
*/
uint16 agIsHandsFreeSupported(void)
{
if (AGState.supportedProfiles & agHandsFreeProfile)
return 1;
else
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -