📄 enfora.cpp
字号:
{
return StringCchPrintfA( szCmd, cchCmd, "AT%%ALS=%u\r", dwAddressId );
}
HRESULT PDD_CreateCommand_GetCurrentAddressId(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
return StringCchCopyA( szCmd, cchCmd, "AT%ALS?\r" );
}
static HRESULT ParseGetCurrentAddressId(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetCurrentAddressId);
UINT nValue;
DWORD* pdwAddressId = NULL;
HRESULT hr = S_OK;
pBlob = NULL;
cbBlob = 0;
pdwAddressId = (DWORD*)AllocBlob(sizeof(DWORD));
if (!pdwAddressId) {
hr = E_OUTOFMEMORY;
goto Error;
}
*pdwAddressId = 0;
// Parse "<prefix>%ALS: <addressID><postfix>"
if (!ParseRspPrefix(szRsp, szRsp) ||
!MatchStringBeginning(szRsp, "%ALS: ", szRsp) ||
!ParseUInt(szRsp, TRUE, nValue, szRsp) ||
!ParseRspPostfix(szRsp, szRsp)) {
hr = E_FAIL;
goto Error;
}
*pdwAddressId = nValue;
pBlob = (void*)pdwAddressId;
cbBlob = sizeof(DWORD);
Error:
if (FAILED(hr)) {
FreeBlob(pdwAddressId);
}
return hr;
}
HRESULT PDD_BeginRadioPowerOn()
{
return E_NOTIMPL;
}
HRESULT PDD_BeginGPRSContextDeactivation()
{
EnterCriticalSection(&g_csGPRSDeactLock);
// In case the previous deactivation attempt did not result in a expected ME DEACT notification
// after a response was received, we want to be sure to not confuse the response for that
// transaction with that for this new transaction, so we clear it
g_fDeactResponseRcvd = FALSE;
LeaveCriticalSection(&g_csGPRSDeactLock);
return S_OK;
}
HRESULT PDD_WaitForSIMReady()
{
return E_NOTIMPL;
}
HRESULT PDD_CreateCommand_GetEquipmentInfo(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
return StringCchCopyA( szCmd, cchCmd, "AT+CGMI;+CGMM;+CGMR;D*#06#\r" );
}
HRESULT PDD_CreateCommand_SetupBeforeRadioOn(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in const bool fPrefixPresent)
{
return StringCchCopyA( szCmd, cchCmd, ( fPrefixPresent ) ? "%SATC=1,0901FF7F00000010;" : "AT%SATC=1,0901FF7F00000010;" );
}
HRESULT PDD_CreateCommand_CleanupBeforeRadioOff(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in const bool fPrefixPresent)
{
return E_NOTIMPL;
}
HRESULT PDD_CreateCommand_GetSimToolkitProfile(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
return StringCchCopyA( szCmd, cchCmd, "AT%SATC?\r" );
}
static HRESULT ParseGetSimToolkitProfile(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetSimToolkitProfile);
UINT i;
UINT nValue;
UINT cbProfileString;
LPSTR szProfileString = NULL;
LPCSTR pchProfileStringWalk;
UINT cbProfile;
BYTE* pbProfileWalk;
BYTE* pbProfile = NULL;
HRESULT hr = S_OK;
pBlob = NULL;
cbBlob = 0;
// Parse "<prefix>%SATC: <mode>,"
if (!ParseRspPrefix(szRsp, szRsp) ||
!MatchStringBeginning(szRsp, "%SATC: ", szRsp) ||
!ParseUInt(szRsp, TRUE, nValue, szRsp) ||
!MatchStringBeginning(szRsp, ",", szRsp)) {
hr = E_FAIL;
goto Error;
}
// Parse "<profile>"
// NOTE: we take ownership of allocated szProfileString
if (!ParseUnlimitedUnquotedString(szRsp, '\r', szProfileString, cbProfileString, szRsp)) {
hr = E_FAIL;
goto Error;
}
DEBUGCHK(0 == (cbProfileString - 1) % 2);
cbProfile = (cbProfileString - 1) / 2;
// Allocate the byte array of needed size
pbProfile = (BYTE*)AllocBlob(cbProfile);
if (!pbProfile) {
hr = E_OUTOFMEMORY;
goto Error;
}
// Decode the profile
pbProfileWalk = pbProfile;
pchProfileStringWalk = szProfileString;
for (i = 0; i < cbProfile; i++) {
*pbProfileWalk = SemiByteCharsToByte(*pchProfileStringWalk, *(pchProfileStringWalk + 1));
pbProfileWalk++;
pchProfileStringWalk += 2;
}
// Parse "<postfix>"
if (!ParseRspPostfix(szRsp, szRsp)) {
hr = E_FAIL;
goto Error;
}
pBlob = (void*)pbProfile;
cbBlob = cbProfile;
Error:
if (FAILED(hr)) {
FreeBlob(pbProfile);
}
delete[] szProfileString;
return hr;
}
HRESULT PDD_CreateCommand_SetSimToolkitProfile(__out_ecount(cchCmd) LPSTR szCmd, size_t cchCmd, __in_ecount(cchSTKPS) LPCSTR szSTKProfileString, size_t cchSTKPS)
{
return StringCchPrintfA( szCmd, cchCmd, "AT%%SATC=1,%s;+CFUN=1\r", szSTKProfileString );
}
HRESULT PDD_CreateCommand_SimToolkitEnvelopeCmd(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in_ecount(dwSize) const BYTE* lpbCommand, __in const DWORD dwSize)
{
LPSTR szCmdTemp = NULL;
HRESULT hr = E_FAIL;
// Add "AT%SATE=<command><CR>"
// NOTE: caller will take ownership of allocated szCmdTemp
BOOL fOk = ComposeCmdWithByteArray("AT%SATE=", lpbCommand, dwSize, "\r", szCmdTemp);
if (fOk && szCmdTemp)
{
hr = StringCchCopyA( szCmd, cchCmd, szCmdTemp );
delete [] szCmdTemp;
}
return hr;
}
static HRESULT ParseSendSimToolkitEnvelopeCmd(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseSendSimToolkitEnvelopeCmd);
UINT i;
UINT cbResponseString;
LPSTR szResponseString = NULL;
LPCSTR pchResponseStringWalk;
UINT cbResponse;
BYTE* pbResponseWalk;
BYTE* pbResponse = NULL;
HRESULT hr = S_OK;
pBlob = NULL;
cbBlob = 0;
// Parse "<prefix>%SATE: "
if (!ParseRspPrefix(szRsp, szRsp) ||
!MatchStringBeginning(szRsp, "%SATE: ", szRsp)) {
hr = E_FAIL;
goto Error;
}
// Parse "<response>"
// NOTE: we take ownership of allocated szResponseString
if (!ParseUnlimitedUnquotedString(szRsp, '\r', szResponseString, cbResponseString, szRsp)) {
hr = E_FAIL;
goto Error;
}
DEBUGCHK(0 == (cbResponseString - 1) % 2);
cbResponse = (cbResponseString - 1) / 2;
// Allocate the byte array of needed size
pbResponse = (BYTE*)AllocBlob(cbResponse);
if (!pbResponse) {
hr = E_OUTOFMEMORY;
goto Error;
}
// Decode the response
pbResponseWalk = pbResponse;
pchResponseStringWalk = szResponseString;
for (i = 0; i < cbResponse; i++) {
*pbResponseWalk = SemiByteCharsToByte(*pchResponseStringWalk, *(pchResponseStringWalk + 1));
pbResponseWalk++;
pchResponseStringWalk += 2;
}
// Parse "<postfix>"
if (!ParseRspPostfix(szRsp, szRsp)) {
hr = E_FAIL;
goto Error;
}
pBlob = (void*)pbResponse;
cbBlob = cbResponse;
Error:
if (FAILED(hr)) {
FreeBlob(pbResponse);
}
delete[] szResponseString;
return hr;
}
HRESULT PDD_CreateCommand_SIMTKCmdResponsePrefix(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in const DWORD dwResponseType)
{
// For newer OEM1 stacks the SIM toolkit envelope and response command can have quotes
// (but are not required) around the data portion of the response. Although, having
// quotes around the data is a more proper form, we do not add them at this time to
// remain as compatible as possible with older stacks.
return StringCchCopyA( szCmd, cchCmd, ( SIM_NOTIFY_SETUPMENU_REPLY == dwResponseType ) ? "AT%SATE=" : "AT%SATR=" );
}
HRESULT PDD_CreateCommand_SIMTKEventDownloadPrefix(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
return StringCchCopyA( szCmd, cchCmd, "AT%SATE=" );
}
HRESULT PDD_CreateCommand_BuildInfoQuery(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
return StringCchCopyA( szCmd, cchCmd, "AT$V0\r" );
}
static HRESULT ParseBuildInfo(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
// HW-SPECIFIC: This parses response to a AT$V0 to get the firmware build number
FUNCTION_TRACE(ParseBuildInfo);
HRESULT hr = S_OK;
CHAR * szBuildInfo = NULL;
pBlob = NULL;
cbBlob = 0;
szBuildInfo = (CHAR*)AllocBlob(MAX_PATH);
if (!ParseUnquotedString(szRsp, '\r', szBuildInfo, MAX_PATH, szRsp))
{
hr = E_FAIL;
goto Error;
}
pBlob = szBuildInfo;
cbBlob = MAX_PATH;
Error:
if (FAILED(hr)) {
FreeBlob(szBuildInfo);
}
return hr;
return S_OK;
}
HRESULT PDD_CreateCommand_BatteryInfoQuery(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
return StringCchCopyA( szCmd, cchCmd, "AT%A0\r" );
}
static HRESULT ParseBatteryInfo(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
#define VOLTAGE_RESP_FIELD "ADC 1 ="
LPCSTR pch;
DWORD* pdwVoltage;
FUNCTION_TRACE(ParseBatteryInfo);
#ifdef SUPPRESS_ONLINE_BATTERY_INFO
LPCSTR szOrigRsp=szRsp;
#endif // SUPPRESS_ONLINE_BATTERY_INFO
pBlob = NULL;
cbBlob = 0;
pdwVoltage = (DWORD *)AllocBlob(sizeof(DWORD));
if( NULL == pdwVoltage)
{
ASSERT( FALSE );
goto Error;
}
*pdwVoltage = 0UL;
// search for ADC 1
pch = const_cast<char*>(strstr( szRsp, VOLTAGE_RESP_FIELD ));
if( NULL == pch )
{
ASSERT( FALSE );
goto Error;
}
pch += strlen( VOLTAGE_RESP_FIELD );
while( *pch == ' ' ) // remove leading spaces
{
pch++;
}
if ( sscanf( pch, "%x", pdwVoltage ) < 0 )
{
ASSERT( FALSE );
goto Error;
}
pBlob = pdwVoltage;
cbBlob = sizeof(DWORD);
#ifdef SUPPRESS_ONLINE_BATTERY_INFO
strncpyz(gszGetBatteryInfoLast,szOrigRsp,sizeof(gszGetBatteryInfoLast));
#endif // SUPPRESS_ONLINE_BATTERY_INFO
return S_OK;
Error:
FreeBlob(pdwVoltage);
return E_FAIL;
}
HRESULT PDD_RebootRadio()
{
return E_NOTIMPL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -