📄 gprs.cpp
字号:
{
goto Error;
}
// Parse <n> and throw away
if (!ParseUInt(szRsp, TRUE, nValue, szRsp))
{
goto Error;
}
// Parse ","
if (!MatchStringBeginning(szRsp, ",", szRsp))
{
goto Error;
}
// Parse <stat>
if (!ParseUInt(szRsp, TRUE, nValue, szRsp))
{
goto Error;
}
pdwRegStatus = (DWORD*)AllocBlob(sizeof(DWORD));
if (!pdwRegStatus)
{
goto Error;
}
if (NUM_REGSTATS > nValue)
{
*pdwRegStatus = g_rgdwRegStats[nValue];
}
else
{
*pdwRegStatus = RIL_REGSTAT_UNKNOWN;
}
g_dwGPRSRegStatus = *pdwRegStatus;
#ifdef RIL_WATSON_REPORT
// Copy gprs registration status to the info cache.
g_RilInfoCache.dwGPRSRegStatus = *pdwRegStatus;
#endif // RIL_WATSON_REPORT
pBlob = (void*)pdwRegStatus;
cbBlob = sizeof(DWORD);
hr = S_OK;
Error:
if (FAILED(hr))
{
FreeBlob(pdwRegStatus);
}
return hr;
}
// +CGREG?
HRESULT RILDrv_GetGPRSRegistrationStatus (DWORD dwParam)
{
FUNCTION_TRACE(RILDrv_GetGPRSRegistrationStatus);
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RILDrv_GetGPRSRegistrationStatus\r\n")));
HRESULT hr = E_INVALIDARG;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle)
{
goto Error;
}
if (!QueueCmd(pHandle,
"AT+CGREG?\r",
CMDOPT_NONE,
APIID_GETGPRSREGISTRATIONSTATUS,
ParseGetGPRSRegistrationStatus, // Parse fn
NULL, // Ptr to notification data
hr))
{
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
/*
+CGCLASS: <class>
<class>: a string parameter which indicates the GPRS mobile class (in descending order of functionality)
A class A (highest)
B classB
C class C in GPRS and circuit switched alternate mode
CG class C in GPRS only mode
CC class C in circuit switched only mode (lowest)
*/
HRESULT ParseGetGPRSClass(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetGPRSClass);
char szValue[MAX_PATH];
DWORD *pdwClass=NULL;
HRESULT hr = E_FAIL;
pBlob = NULL;
cbBlob = 0;
// Parse "<prefix>"
if (!ParseRspPrefix(szRsp, szRsp))
{
goto Error;
}
// Parse "+CGCLASS: "
if (!MatchStringBeginning(szRsp, "+CGCLASS: ", szRsp))
{
goto Error;
}
pdwClass = (DWORD*)AllocBlob(sizeof(DWORD));
if (!pdwClass)
{
goto Error;
}
// Parse <class>
if (!ParseString(szRsp, szValue, MAX_PATH, szRsp))
{
goto Error;
}
FlagFromString(szValue,g_GprsClass,NUM_GPRSCLASS,*pdwClass);
pBlob = (void*)pdwClass;
cbBlob = sizeof(DWORD);
hr = S_OK;
Error:
if (FAILED(hr))
{
FreeBlob(pdwClass);
}
return hr;
}
// +CGCLASS?
HRESULT RILDrv_GetGPRSClass (DWORD dwParam)
{
FUNCTION_TRACE(RILDrv_GetGPRSClass);
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RILDrv_GetGPRSClass\r\n")));
HRESULT hr = E_INVALIDARG;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle)
{
goto Error;
}
if (!QueueCmd(pHandle,
"AT+CGCLASS?\r",
CMDOPT_NONE,
APIID_GETGPRSCLASS,
ParseGetGPRSClass, // Parse fn
NULL, // Ptr to notification data
hr))
{
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
// +CGCLASS=[A|B|C|CG|CC]
HRESULT RILDrv_SetGPRSClass (DWORD dwParam, DWORD dwClass)
{
FUNCTION_TRACE(RILDrv_SetGPRSClass);
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RILDrv_SetGPRSClass\r\n")));
HRESULT hr = E_INVALIDARG;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle)
{
goto Error;
}
// Build command
char szCmd[MAX_PATH];
LPSTR szString;
if (!StringFromFlag(dwClass,g_GprsClass,NUM_GPRSCLASS,szString))
{
goto Error;
}
(void)_snprintfz(szCmd, MAX_PATH, "AT+CGCLASS=\"%s\"\r", szString);
if (!QueueCmd(pHandle,
szCmd,
CMDOPT_NONE,
APIID_SETGPRSCLASS,
NULL, // Parse fn
NULL, // Ptr to notification data
hr))
{
hr=E_FAIL;
goto Error;
}
Error:
return hr;
}
/*
+CGSMS: <service>
<service>: a numeric parameter which indicates the service or service preference to be used
0 GPRS
1 circuit switched
2 GPRS preferred (use circuit switched if GPRS not available)
3 circuit switched preferred (use GPRS if circuit switched not available)
*/
HRESULT ParseGetMOSMSService(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetMOSMSService);
UINT nValue;
HRESULT hr = E_FAIL;
DWORD *pdwMoSmsService=NULL;
pBlob = NULL;
cbBlob = 0;
// Parse "<prefix>"
if (!ParseRspPrefix(szRsp, szRsp))
{
goto Error;
}
// Parse "+CGSMS: "
if (!MatchStringBeginning(szRsp, "+CGSMS: ", szRsp))
{
goto Error;
}
// Parse <service>
if (!ParseUInt(szRsp, TRUE, nValue, szRsp))
{
goto Error;
}
pdwMoSmsService = (DWORD*)AllocBlob(sizeof(DWORD));
if (!pdwMoSmsService)
{
goto Error;
}
FlagFromValue(nValue,g_GprsMOSMSService,NUM_GPRSMOSMSSERVICE,*pdwMoSmsService);
pBlob = (void*)pdwMoSmsService;
cbBlob = sizeof(DWORD);
hr = S_OK;
Error:
if (FAILED(hr))
{
FreeBlob(pdwMoSmsService);
}
return hr;
}
// +CGSMS?
HRESULT RILDrv_GetMOSMSService (DWORD dwParam)
{
FUNCTION_TRACE(RILDrv_GetMOSMSService);
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RILDrv_GetMOSMSService\r\n")));
HRESULT hr = E_INVALIDARG;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle)
{
goto Error;
}
if (!QueueCmd(pHandle,
"AT+CGSMS?\r",
CMDOPT_NONE,
APIID_GETMOSMSSERVICE,
ParseGetMOSMSService, // Parse fn
NULL, // Ptr to notification data
hr))
{
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
// +CGSMS=[0|1|2|3]
HRESULT RILDrv_SetMOSMSService (DWORD dwParam, DWORD dwMoSmsService)
{
FUNCTION_TRACE(RILDrv_SetMOSMSService);
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RILDrv_SetMOSMSService\r\n")));
UINT Value;
HRESULT hr = E_INVALIDARG;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle)
{
goto Error;
}
// Build command
char szCmd[MAX_PATH];
if (!ValueFromFlag(dwMoSmsService,g_GprsMOSMSService,NUM_GPRSMOSMSSERVICE,Value))
{
goto Error;
}
(void)_snprintfz(szCmd, MAX_PATH, "AT+CGSMS=%u\r",Value);
if (!QueueCmd(pHandle,
szCmd,
CMDOPT_NONE,
APIID_SETMOSMSSERVICE,
NULL, // Parse fn
NULL, // Ptr to notification data
hr))
{
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
// +CGCLASS: (list of supported <class>s)
HRESULT ParseGetGprsCapsClass(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetGprsCapsClass);
DWORD *pdwClass = NULL;
HRESULT hr = E_FAIL;
pBlob = NULL;
cbBlob = 0;
// Parse "<prefix>"
if (!ParseRspPrefix(szRsp, szRsp))
{
goto Error;
}
// Parse "+CGCLASS: "
if (!MatchStringBeginning(szRsp, "+CGCLASS: ", szRsp))
{
goto Error;
}
pdwClass = (DWORD*)AllocBlob(sizeof(DWORD));
if (!pdwClass)
{
goto Error;
}
// Parse ,<class>
if (!ParseStringList(szRsp, g_GprsClass, NUM_GPRSCLASS, *pdwClass, szRsp))
{
goto Error;
}
pBlob = (void*)pdwClass;
cbBlob = sizeof(DWORD);
hr = S_OK;
Error:
if (FAILED(hr))
{
FreeBlob(pdwClass);
}
return hr;
}
// +CGDCONT: (range of supported <cid>s),<PDP_type>,,,(list of supported <d_comp>s),(list of supported <h_comp>s)[,(list of supported <pd1>s)[,...[,(list of supported <pdN>s)]]]
// [<CR><LF>+CGDCONT: (range of supported <cid>s),<PDP_type>,,,(list of supported <d_comp>s),(list of supported <h_comp>s)[,(list of supported <pd1>s)[,...[,(list of supported <pdN>s)]]]
// [...]]
HRESULT ParseGetGprsCapsContext(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetGprsCapsContext);
PBYTE pBuffer=NULL;
DWORD dwBufferSize=0;
RILGPRSCONTEXTCAPS GPRSContextCaps, *pGPRSContextCaps;
char szValue[MAX_PATH] = {0};
LPCSTR szParams = NULL;
LPCSTR szParamsEnd = NULL;
HRESULT hr = E_FAIL;
BOOL bSuccess;
pBlob = NULL;
cbBlob = 0;
// Parse "<prefix>"
if (!ParseRspPrefix(szRsp, szRsp))
{
goto Error;
}
// Parse "+CGDCONT: "
while (MatchStringBeginning(szRsp, "+CGDCONT: ", szRsp))
{
memset(&GPRSContextCaps, 0x00, sizeof(GPRSContextCaps));
// Parse (range of supported <cid>s)
if (!ParseRange(szRsp, GPRSContextCaps.ContextIDRange, szRsp))
{
goto Continue;
}
GPRSContextCaps.dwParams|= RIL_PARAM_GCONT_CONTEXTID;
// Parse ,<PDP_type>
if (!MatchStringBeginning(szRsp, ",", szRsp) ||
!ParseString(szRsp, szValue, MAX_PATH, szRsp))
{
goto Continue;
}
if (FlagFromString(szValue, g_GprsPDPTypes, NUM_GPRSPDPTYPES, GPRSContextCaps.dwProtoco
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -