📄 rilhand.cpp
字号:
#endif
{
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : SimReadyThread : Unable to construct or Init CCommand\r\n")));
goto SimReadyPhase2;
}
// Place the command into the command queue
// (this may block if the queue is full)
if (!g_pCmdQ->Put(pCmd, INFINITE))
{
goto SimReadyPhase2;
}
// Now, block until we get a response back
WaitForSingleObject(m_hSimReadyEvent, apiiInfo.dwTimeout);
// Sleep a bit before the next try
if (!m_fSimReady && !m_fQuitReadyStateThread)
{
Sleep(2000);
}
}
while (!m_fSimReady && !m_fQuitReadyStateThread);
RETAILMSG(1, (TEXT("[TI]gsm1>>>>>>>> Broadcast RIL_NOTIFY_SPECINITCOMPLETE.\r\n")));
if (m_fQuitReadyStateThread)
{
goto Error;
}
SimReadyPhase2:
//Dual-card: We should register the net by manual
//if (!IsPrimaryCard())
//{
QueueCmdIgnoreRsp(APIID_NONE, "AT+COPS=0\r", CMDOPT_INIT, g_TimeoutCmdInit, NULL, NULL, 0, 0, 0);
RETAILMSG(1, (TEXT("[TI]SimReadyPhase2 SEND COPS=0\r\n")));
Sleep(4000);//maybe the modem is busy when registering
//}
//#ifdef OEM2_DRIVER
#ifdef OEM1_DRIVER
// Create the needed event
m_fInitedForSMS = FALSE;
m_hInitedForSMSEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!m_hInitedForSMSEvent)
{
goto Error;
}
// for OEM2 platforms the measure of SMS readiness is a successful CNMI initialization
do
{
Sleep(10000); //retry every 10s
if (g_dwReadyState & RIL_READYSTATE_UNLOCKED)
{
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : SMSReadyThread : OEM2 Sending CNMI Init Command...\r\n")));
pCmd = new CCommand;
#ifdef RIL_CELL_BROADCAST
if (!pCmd || !pCmd->Init(NULL, "AT+CNMI=2,2,2,1,0\r", NULL, CMDOPT_SMSINIT | CMDOPT_IGNORERSP, EXECTIME_API_DEFAULT, g_TimeoutCmdInit, NULL, NULL, 0, 0, 0, APIID_NONE, NULL, NULL))
#else
if (!pCmd || !pCmd->Init(NULL, "AT+CNMI=2,2,0,1,0\r", NULL, CMDOPT_SMSINIT | CMDOPT_IGNORERSP, EXECTIME_API_DEFAULT, g_TimeoutCmdInit, NULL, NULL, 0, 0, 0, APIID_NONE, NULL, NULL))
#endif
{
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : SMSReadyThread : Unable to construct or Init CCommand\r\n")));
goto SimReadyPhase3;
}
// Place the command into the command queue
// (this may block if the queue is full)
if (!g_pCmdQ->Put(pCmd, INFINITE))
{
goto SimReadyPhase3;
}
// Now, block until we get a response back
WaitForSingleObject(m_hInitedForSMSEvent, g_TimeoutCmdInit);
}
}
while (!m_fInitedForSMS && !m_fQuitReadyStateThread && !g_fNoSIM);
if (m_fQuitReadyStateThread)
{
goto Error;
}
if(m_fInitedForSMS)
{
SendReadyStateNotification(RIL_READYSTATE_SMS);
ChangePBSMSRegState(RIL_SMSPB_CARD2_SMS, FALSE);
}
RETAILMSG(1, (TEXT("[TI] RILDrv : simreadythread phase2 end\r\n")));
SimReadyPhase3:
#if defined(OEM2_SIMTOOLKIT)
pCmd = new CCommand;
if (!pCmd || !pCmd->Init(NULL, "AT+STPD=12,0901FF7F602000106200000F\r", NULL, CMDOPT_IGNORERSP, EXECTIME_API_DEFAULT, g_TimeoutCmdInit, NULL, NULL, 0, 0, 0, APIID_NONE, NULL, NULL))
{
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : SIMReadyThread : Unable to create SIMTK cmnd\r\n")));
goto Error;
}
else
{
if (!g_pCmdQ->Put(pCmd, INFINITE))
{
goto Error;
}
}
#endif
// Create the needed event
m_fInitedForSIMPB = FALSE;
m_dwSIMPBLastSize = (DWORD)-1;
m_hInitedForSIMPBEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!m_hInitedForSIMPBEvent)
{
goto Error;
}
// This now only applies to OEM2 with new CSTAT command from OEM1
//now perform SIM phonebook ready check for OEM2 driver
//OEM2 driver does not support a SIM PB ready notification,
//and will simply fail read attempts for SIM PB entries that have not
//yet been copied from non-volatile SIM memory to volatile SIM memory.
//so for those platforms we'll poll every 10 seconds to see whether or not the number of
//SIM entries has stabilized to a steady state, at which point we'll
//call the SIM PB ready.
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : SIMPBReadyThread : OEM2 Sending select SIMPB Command...\r\n")));
pCmd = new CCommand;
if (!pCmd || !pCmd->Init(NULL, "AT+CPBS=\"MT\"\r", NULL, CMDOPT_IGNORERSP, EXECTIME_API_DEFAULT, g_TimeoutCmdInit, NULL, NULL, 0, 0, 0, APIID_NONE, NULL, NULL))
{
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : SIMPBReadyThread : Unable to construct or Init CCommand\r\n")));
goto Error;
}
// Place the command into the command queue
// (this may block if the queue is full)
if (!g_pCmdQ->Put(pCmd, INFINITE))
{
goto Error;
}
do
{
if (g_dwReadyState & RIL_READYSTATE_UNLOCKED)
{
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : SIMPBReadyThread : OEM2 Sending SIMPB size query Command...\r\n")));
pCmd = new CCommand;
if (!pCmd || !pCmd->Init(NULL, "AT+CPBS?\r", NULL, CMDOPT_SIMPBINIT | CMDOPT_IGNORERSP, EXECTIME_API_DEFAULT, g_TimeoutCmdInit, NULL, NULL, 0, 0, 0, APIID_NONE, NULL, NULL))
{
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : SIMPBReadyThread : Unable to construct or Init CCommand\r\n")));
goto Error;
}
// Place the command into the command queue
// (this may block if the queue is full)
if (!g_pCmdQ->Put(pCmd, INFINITE))
{
goto Error;
}
// Now, block until we get a response back
WaitForSingleObject(m_hInitedForSIMPBEvent, g_TimeoutCmdInit);
}
if (!m_fInitedForSIMPB && !m_fQuitReadyStateThread)
{
Sleep(10000); //retry every 10s
}
}
while (!m_fInitedForSIMPB && !m_fQuitReadyStateThread && !g_fNoSIM);
if (m_fQuitReadyStateThread)
{
goto Error;
}
if(m_fInitedForSIMPB)
{
SendReadyStateNotification(RIL_READYSTATE_SIM_PB);
ChangePBSMSRegState(RIL_SMSPB_CARD2_PB, FALSE);
}
RETAILMSG(1, (TEXT("[TI] RILDrv : simreadythread phase3 end\r\n")));
#endif
RETAILMSG(1, (TEXT("[TI]SetStackAllReadyState TRUE\r\n")));
SetStackAllReadyState(TRUE);
/* these could take a while to execute */
/* so do these last in this function */
#ifdef OEM2_DRIVER
/* read CPHS */
StartPlmnNameRead();
#ifdef RIL_ENABLE_EONS
/* read EONS */
StartEONSRead();
#endif
#endif
Error:
if (m_hSimReadyEvent)
{
CloseHandle(m_hSimReadyEvent);
m_hSimReadyEvent = NULL;
}
if (m_hInitedForSMSEvent)
{
CloseHandle(m_hInitedForSMSEvent);
m_hInitedForSMSEvent = NULL;
}
if (m_hInitedForSIMPBEvent)
{
CloseHandle(m_hInitedForSIMPBEvent);
m_hInitedForSIMPBEvent = NULL;
}
return 0;
}
//
// Launch a thread to see if the SIM is ready or not
//
void CRilHandle::StartReadyStateQuery()
{
m_fQuitReadyStateThread = FALSE;
HANDLE hThread = CreateThread(NULL, 0, SimReadyThreadProc, (LPVOID)this, 0, NULL);
if (NULL != hThread)
CloseHandle(hThread); // close handle we don't need
}
void CRilHandle::StopReadyStateQuery()
{
m_fQuitReadyStateThread = TRUE;
if (m_hSimReadyEvent)
{
SetEvent(m_hSimReadyEvent);
}
if (m_hInitedForSMSEvent)
{
SetEvent(m_hInitedForSMSEvent);
}
if (m_hInitedForSIMPBEvent)
{
SetEvent(m_hInitedForSIMPBEvent);
}
}
//
// Start initialization
//
BOOL CRilHandle::StartInit()
{
// // FUNCTION_TRACE(CRilHandle::StartInit);
SYNCBLOCK(m_cs);
DWORD dwTemp;
BOOL fRet = FALSE;
if (m_fInited)
{
fRet = TRUE;
goto Error;
}
// Read parameters from the registry
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("DataModeCmdDelay"), &dwTemp))
{
m_dwDataModeCmdDelay = dwTemp;
}
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("MaxDataModeTimeWithoutCmd"), &dwTemp))
{
m_dwMaxDataModeTimeWithoutCmd = dwTemp;
}
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("LastCLIP"), &dwTemp))
{
g_dwLastCLIP = dwTemp;
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : CRilHandle::StartInit : Retrieved LastCLIP=0x%x\r\n"),g_dwLastCLIP));
}
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("LastCLIR"), &dwTemp))
{
g_dwLastCLIR = dwTemp;
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : CRilHandle::StartInit : Retrieved LastCLIR=0x%x\r\n"),g_dwLastCLIR));
}
g_TimeoutCmdInit = TIMEOUT_CMD_INIT;
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("TimeoutCmdInit"), &dwTemp))
{
g_TimeoutCmdInit = dwTemp;
}
g_TimeoutCmdNoOp = TIMEOUT_CMD_NOOP;
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("TimeoutCmdNoOp"), &dwTemp))
{
g_TimeoutCmdNoOp = dwTemp;
}
g_TimeoutCmdOnline = TIMEOUT_CMD_ONLINE;
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("TimeoutCmdOnline"), &dwTemp))
{
g_TimeoutCmdOnline = dwTemp;
}
g_TimeoutAPIDefault = TIMEOUT_API_DEFAULT;
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("TimeoutAPIDefault"), &dwTemp))
{
g_TimeoutAPIDefault = dwTemp;
}
g_TimeoutDTRDrop = TIMEOUT_DTRDROP;
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("TimeoutDTRDrop"), &dwTemp))
{
g_TimeoutDTRDrop = dwTemp;
}
g_TimeoutWaitForInit = TIMEOUT_WAITFORINIT;
if (GetRegistryDWORD(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("TimeoutWaitForInit"), &dwTemp))
{
g_TimeoutWaitForInit = dwTemp;
}
//Get registration timeout from registry
g_TimeoutRegisterNetwork = TIMEOUT_REGISTERNW;
APIINFO apiiInfo;
const APIID apiid = APIID_REGISTERONNETWORK;
// Get the info about this API
memset(&apiiInfo,0,sizeof(apiiInfo));
GetAPIInfo(apiid, apiiInfo);
g_TimeoutRegisterNetwork = apiiInfo.dwTimeout;
// Create init event
m_hInitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!m_hInitEvent)
{
goto Error;
}
// Create data event
m_hDataEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!m_hDataEvent)
{
goto Error;
}
// Create the instance handle list
m_pInstances = new CDblList<CRilInstanceHandle>;
if (!m_pInstances)
{
goto Error;
}
// Open the serial port
m_pComDevice = COM_OpenInternal();
if (!m_pComDevice)
{
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : CRilHandle::StartInit : Couldn't open VSP\r\n")));
goto Error;
}
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : CRilHandle::StartInit : VSP is opened successfully\r\n")));
// Initialize the serial port
if (!m_pComDevice->InitComPortForRIL(NULL, NULL))
{
goto Error;
}
// Launch the auxiliary threads
if (!LaunchThreads())
{
goto Error;
}
//dual-card: we should read the regestry to get the card status
#if 0
#ifdef SCI_OLD
if (GetCardOnOff())
#endif
{
#if defined(NO_INIT_ON_BOOT)
GeneralInitDone(TRUE);
#else
// Send the first init string to the COM port
RETAILMSG(1,(TEXT("[TI][StartInit ] Try to send String----------------->.\r\n")));
if (!SendComInitString(COM_INIT_INDEX))
{
goto Error;
}
}
#ifdef SCI_OLD
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -