📄 rilsimtk_magneto.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of your Microsoft Windows CE
// Source Alliance Program license form. If you did not accept the terms of
// such a license, you are not authorized to use this source code.
//
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2003 Intrinsyc Europe Ltd.
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2004 Siemens AG
//
// Version: 1.1.2.5
// Date: 11. Jan. 2006
//////////////////////////////////////////////////////////////////////////////
#include "precomp.h"
//#include "rilsimtk.h"
// Macros to round values to DWORD boundaries and add them
#define ROUNDTODWORD2(a, b) (ROUNDTODWORD(a) + ROUNDTODWORD(b))
#define ROUNDTODWORD3(a, b, c) (ROUNDTODWORD2(a, b) + ROUNDTODWORD(c))
#define ROUNDTODWORD4(a, b, c, d) (ROUNDTODWORD2(a, b) + ROUNDTODWORD2(c, d))
BOOL gfSimGetInputUcs2=FALSE;
/////////////////////merge from rilsimtk.cppfile/////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Functions for SAT handling without difference between Magneto and Ozone.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Constructor
//
//////////////////////////////////////////////////////////////////////////////
//modified by viking wang
CSimToolkitHandling::CSimToolkitHandling(CRilHandle *pDevice) {
InitializeCriticalSection(&m_csLockBuffer);
m_pRilDevice = pDevice;
m_fNoResponse = FALSE;
//if(m_bCmdBuffer == NULL)
m_bCmdBuffer =(BYTE*) new DWORD[SIMTK_MAX_LENGTH/4];
}
//////////////////////////////////////////////////////////////////////////////
//
// Destructor
//
//////////////////////////////////////////////////////////////////////////////
CSimToolkitHandling::~CSimToolkitHandling() {
Deinit();
delete m_bCmdBuffer;
DeleteCriticalSection(&m_csLockBuffer);
}
//////////////////////////////////////////////////////////////////////////////
//
// Initialize and start the SAT handling.
//
// Params:
// pRilHandle: Pointer to the connected CRilHandle instance which is needed
// internally.
//
// Return:
// TRUE or FALSE depending on the success of the operation.
//
//////////////////////////////////////////////////////////////////////////////
BOOL CSimToolkitHandling::Init(CRilHandle* pRilDevice) {
/*
HRESULT hr;
if (!pRilDevice) {
return FALSE;
}
// Store the RIL device
m_pRilDevice = pRilDevice;
// Enable SAT handling
// if (!QueueInternalCmd(COMMAND_PORT, m_pRilDevice, "AT^SSTA=1,1\r", CMDOPT_NONE, APIID_FETCHSIMTOOLKITCMD, 0, 2, 10000))
//if(!QueueInternalCmd( m_pRilDevice, "AT+PPSTAC=1\r", CMDOPT_NONE, APIID_FETCHSIMTOOLKITCMD,
// 1, 2, 1000,
// NULL, 0,
// NULL, NULL, NULL
// ))
if(!QueueCmd(pHandle, "AT+PPSTAC=1\r", CMDOPT_NONE, APIID_GETSIMTOOLKITPROFILE,
NULL, NULL, hr))
{
RILRetailTrace((TEXT("RilDrv: SimToolkit Error - Failed to queue SAT enable cmd -> SimToolkit NOT enabled !!!\r\n")));
return FALSE;
}
*/
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////
//
// Stop the SAT handling.
//
// Return:
// TRUE or FALSE depending on the success of the operation.
//
//////////////////////////////////////////////////////////////////////////////
BOOL CSimToolkitHandling::Deinit(void) {
// Nothing to do for now
m_pRilDevice = 0;
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////
//
// Get the SAT profile.
//
// Params:
// pHandle: Pointer to CRilInstanceHandle to be used for the operation.
//
// Return:
// S_OK on successs, E_FAIL otherwise.
//
//////////////////////////////////////////////////////////////////////////////
HRESULT CSimToolkitHandling::GetProfile(CRilInstanceHandle* pHandle)
{
HRESULT hr;
if(!QueueCmd(pHandle, "AT+PPSTAC?\r", CMDOPT_NONE, APIID_GETSIMTOOLKITPROFILE,
ParseGetProfile, NULL, hr))
/* if(!QueueInternalCmd(pHandle->GetDevice(), "AT+PPSTAC?\r", CMDOPT_NONE, APIID_FETCHSIMTOOLKITCMD,
2, 1, 1000,
ParseGetProfile, 0,
NULL, NULL, NULL
)) */
{
hr = E_FAIL;
return hr;
}
return S_OK;
}
//////////////////////////////////////////////////////////////////////////////
//
// Set the SAT profile.
//
// Params:
// pHandle: Pointer to CRilInstanceHandle to be used for the operation.
//
// Return:
// Currently only E_NOTIMPL because Siemens modules doesn't support setting
// of SAT profile.
//
//////////////////////////////////////////////////////////////////////////////
HRESULT CSimToolkitHandling::SetProfile(CRilInstanceHandle* pHandle)
{
return E_NOTIMPL;
}
//////////////////////////////////////////////////////////////////////////////
//
// Put a SAT command into the command queue.
//
// Params:
// dwCmd: Number of SAT command.
//
// Return:
// S_OK on successs, E_FAIL otherwise.
//
//////////////////////////////////////////////////////////////////////////////
HRESULT CSimToolkitHandling::QueueSimToolkitCmd(DWORD dwCmd)
{
char szCmd[32];
HRESULT hr = S_OK;
DEBUGMSG(ZONE_ERROR, (TEXT("+CSimToolkitHandling::QueueSimToolkitCmd!\r\n")));
sprintf(szCmd, "AT+PPSTGI=%d\r", dwCmd);
//if (!QueueInternalCmd(COMMAND_PORT, m_pRilDevice, szCmd, CMDOPT_NONE, APIID_FETCHSIMTOOLKITCMD, 0, SIMTK_CMD_RETRIES, SIMTK_CMD_RETRY_DELAY, ParseGetCommand, NULL, this)) {
if(!QueueInternalCmd( m_pRilDevice, szCmd, CMDOPT_NONE, APIID_FETCHSIMTOOLKITCMD,
2, 1, 1000,
NULL, 0,
ParseGetCommand, this, NULL
))
/*if (!QueueCmdIgnoreRsp(APIID_NONE, szCmd, CMDOPT_IGNORERSP, g_TimeoutCmdInit, ParseGetCommand, NULL, 2, 0, 0))
{
RILRetailTrace((TEXT("RilDrv: SimToolkit Error - Failed to queue SAT cmd %d\r\n"), dwCmd));
return E_FAIL;
}*/
DEBUGMSG(ZONE_ERROR, (TEXT("-CSimToolkitHandling::QueueSimToolkitCmd!\r\n")));
return S_OK;
}
//////////////////////////////////////////////////////////////////////////////
//
// Parsing function called to parse a SAT notification.
//
// Params:
// rszPointer: Pointer to the received SAT notification.
// Return:
// TRUE or FALSE depending on the success of the operation.
//
//////////////////////////////////////////////////////////////////////////////
BOOL CSimToolkitHandling::ParseNotification(LPCSTR& rszPointer)
{
LPCSTR szDummy;
UINT nValue;
DEBUGMSG(ZONE_ERROR, (TEXT("+CSimToolkitHandling::ParseNotification()\r\n")));
if (!ParseUInt(rszPointer, FALSE, nValue, rszPointer)) {
RILRetailTrace((TEXT("RilDrv: ParseSIMToolkitNotification: failed to find value\r\n")));
return FALSE;
}
// Look for the "<postfix>" (don't increase string pointer, postfix is scanned again in global response handler)
if (!ParseRspPostfix(rszPointer, szDummy)) {
RILRetailTrace((TEXT("RilDrv: ParseSIMToolkitNotification: failed to find postfix\r\n")));
return FALSE;
}
// if (nValue == 255)
//{
// Full SIM reset, this corresponds to a SAT-Refresh with details 4
//void* pBlob;
//UINT cbBlob;
//return SUCCEEDED(ParseRefresh("4\r\n", pBlob, cbBlob));
// return TRUE;
//}
/* else if((nValue == 254) || ((nValue > 100) && (nValue < 200)))
{
DEBUGMSG(ZONE_ERROR, (TEXT("CSimToolkitHandling::ParseNotification(m_PrilDevice=%u)\r\n"), m_pRilDevice));
return m_pRilDevice->BroadcastRealBlobNotification(RIL_NOTIFY_SIMTOOLKITSESSIONEND, NULL, 0);
return TRUE;
} */
//else
{
if(nValue == 129)
{ //HRESULT hr;
//QueueCmd(NULL, "AT+PPSTUR=129,0\r", CMDOPT_NONE, APIID_SENDSIMTOOLKITCMDRESPONSE, NULL, NULL, hr);
if(!QueueInternalCmd( m_pRilDevice, "AT+PPSTUR=129,0\r", CMDOPT_NONE, APIID_FETCHSIMTOOLKITCMD,
2, 1, 1000,
NULL, 0,
NULL, this, NULL
))
{
RILRetailTrace((TEXT("RilDrv: SimToolkit Error - Failed to queue SAT cmd +PPSTUR=129,0\r\n")));
return E_FAIL;
}
return m_pRilDevice->BroadcastRealBlobNotification(RIL_NOTIFY_SIMTOOLKITSESSIONEND, NULL, 0);
}
if((nValue != 37) && (nValue != 5) )
return SUCCEEDED(QueueSimToolkitCmd(nValue)); /* modified by viking wang on Aug 13.2007 */
else
return TRUE;
}
return FALSE;
}
//////////////////////////////////////////////////////////////////////////////
//
// Parsing callback if something went wrong -> try to bring the module back
// into a proper state.
//
// Return:
// S_OK on successs, E_FAIL otherwise.
//
//////////////////////////////////////////////////////////////////////////////
HRESULT CSimToolkitHandling::ParseRspError(LPCSTR szRsp, LPVOID pParam)
{
CSimToolkitHandling* pInstance = (CSimToolkitHandling*)pParam;
HRESULT hr = S_OK;
RILRetailTrace((TEXT("RilDrv: SimToolkit: Response-Error\r\n")));
if (!pInstance) {
return E_FAIL;
}
/*
if(!QueueInternalCmd(pHandle, szCmd, CMDOPT_NONE, APIID_SENDSIMTOOLKITCMDRESPONSE,
dwTimeout, dwRetries, dwRetryDelay,
pfnParse, dwRetriesOnError,
pfnParseWithData, pParseData, NULL
))*/
//if (!QueueInternalCmd(COMMAND_PORT, pInstance->m_pRilDevice, "AT^SSTR=254\r", CMDOPT_NONE, APIID_SENDSIMTOOLKITCMDRESPONSE, 0, SIMTK_CMD_RETRIES, SIMTK_CMD_RETRY_DELAY)) {
if(!QueueInternalCmd( pInstance->m_pRilDevice, "AT^SSTR=254\r", CMDOPT_NONE, APIID_SENDSIMTOOLKITCMDRESPONSE,
2, 2, 1000,
NULL, 0,
NULL, NULL, NULL
))
{
RILRetailTrace((TEXT("RilDrv: SimToolkit Error - Failed to queue quit cmd\r\n")));
return E_FAIL;
}
if (!pInstance->m_pRilDevice->BroadcastRealBlobNotification(RIL_NOTIFY_SIMTOOLKITSESSIONEND, NULL, 0))
{
RILRetailTrace((TEXT("RilDrv: SimToolkit Error - Failed broadcast RIL_NOTIFY_SIMTOOLKITSESSIONEND\r\n")));
hr = E_FAIL;
}
return hr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -