📄 atcmd.cpp
字号:
GPRS_REGISTER_STATUS Card2Status = GPRS_SYSTEMTYPE_FLAG_GSM;
char RegNum[3][3] = {7,4,3,6,0,2,5,1}; //note the possible register number
/*note the possible register number
card2status
1 2 3
1 7 4 3
card1status 2 6 0 2
3 5 1 x
*/
DWORD DwRegNum = 0;
RETAILMSG(1, (TEXT("[TI]g_fNetworkSystemChanged=%d, g_bNetworkSystemType=%d\r\n"),g_fNetworkSystemChanged,g_bNetworkSystemType));
//get the card1status
for(int i=0;i<3;i++)
{
if(g_dwGPRSNotifyValue[i] == g_bNetworkSystemType)
{
Card1Status = (GPRS_REGISTER_STATUS)(i+1);
RETAILMSG(1, (TEXT("[TI] HandleRxData: Card1Status = %d\r\n"),Card1Status));
}
}
WaitForSingleObject(g_ShareMemMutexHandle, INFINITE);
RILDrv_Network_SetFlag(g_pShareMem->stSM_Option.nRILDriver1CallFlag, Card1Status);
ReleaseMutex(g_ShareMemMutexHandle);
CALLCTRL_SHARE_MEMORY_OPTION stShareMemOpt;
memset(&stShareMemOpt, 0, sizeof(CALLCTRL_SHARE_MEMORY_OPTION));
if (!RILDrv_CC_GetShareMemOpt(stShareMemOpt))
{
RETAILMSG(1, (TEXT("[TI] HandleRxData: call RILDrv_CC_GetShareMemOpt failed!")));
}
//get the card2status
Card2Status = (GPRS_REGISTER_STATUS)RILDrv_Network_GetFlag(stShareMemOpt.nRILDriver2CallFlag);
RETAILMSG(1, (TEXT("[TI] HandleRxData: RILDriver2CallFlag = %d,Card2Status = %d\r\n"),stShareMemOpt.nRILDriver2CallFlag,Card2Status));
//write to the register
if(Card1Status == GPRS_SYSTEMTYPE_FLAG_GSM && Card2Status == GPRS_SYSTEMTYPE_FLAG_GSM)
{
Broadstate = FALSE;
}
else
{
DwRegNum = RegNum[Card1Status-1][Card2Status-1];
SetRegistryDWORD(HKEY_LOCAL_MACHINE, TEXT("System\\Data Service\\ConnInfo"), TEXT("NetworkStatus"),DwRegNum);
RETAILMSG(1,(TEXT("[TI]HandleRxData: NetworkStatus is %d\r\n"),DwRegNum));
}
//broadcast the systemtype
if(Card1Status < Card2Status)
{
g_dwNetworkBroadType = g_dwGPRSNotifyValue[Card1Status - 1];
//write the reg for router
SetRegistryDWORD(HKEY_LOCAL_MACHINE, TEXT("System\\Data Service\\ConnInfo"), TEXT("CardAbilityID"),2);
}
else
{
g_dwNetworkBroadType = g_dwGPRSNotifyValue[Card2Status - 1];
//write the reg for router
SetRegistryDWORD(HKEY_LOCAL_MACHINE, TEXT("System\\Data Service\\ConnInfo"), TEXT("CardAbilityID"),1);
}
(void)BroadcastDWORDBlobNotification(RIL_NOTIFY_SYSTEMCHANGED, g_dwNetworkBroadType);
//broadcast the GPRS register state
if (Broadstate)
{
RETAILMSG(1, (TEXT("[TI]HandleRxData:broadcast the network status is GPRS\r\n")));
(void)BroadcastDWORDBlobNotification(RIL_NOTIFY_GPRSREGSTATUSCHANGED, RIL_REGSTAT_HOME);
(void)BroadcastDWORDBlobNotification(RIL_NOTIFY_REGSTATUSCHANGED, RIL_REGSTAT_HOME);
}
else
{
RETAILMSG(1, (TEXT("[TI]HandleRxData:broadcast the network status is unregistered\r\n")));
(void)BroadcastDWORDBlobNotification(RIL_NOTIFY_GPRSREGSTATUSCHANGED, RIL_REGSTAT_UNREGISTERED);
(void)BroadcastDWORDBlobNotification(RIL_NOTIFY_REGSTATUSCHANGED, RIL_REGSTAT_UNREGISTERED);
}
g_fNetworkSystemChanged = FALSE;
}
//xiangming add for the G/E icon function at 070718 end
#if defined(OEM1_DRIVER)
//wuguangliang added 2006-04-14
//Broadcast cached cpi notification to all client if incoming call tone is ready
if (g_CachedCPINotifs[0] && !g_bSetPhoneNumberTone)
{
UINT i = 0;
if (ISInCALLProgress())
{
// safe to send call progress notifications now.
for (i = 0; (i < MAX_CPINOTIFS) && (g_CachedCPINotifs[i]); i++)
{
CResponse *pRspCached = g_CachedCPINotifs[i];
void* pBlobCached;
UINT cbBlobCached;
pRspCached->GetBlob(pBlobCached, cbBlobCached);
(void)BroadcastRealBlobNotification(pRspCached->GetNotifyCode(), pBlobCached, cbBlobCached);
pRspCached->DeleteBlob();
pBlobCached = NULL;
cbBlobCached = 0;
delete pRspCached;
g_CachedCPINotifs[i] = NULL;
}
}
else
{
CResponse *pRspCached = g_CachedCPINotifs[i];
void* pBlobCached;
UINT cbBlobCached;
pRspCached->GetBlob(pBlobCached, cbBlobCached);
if (((RILCALLINFO*)pBlobCached)->dwType != RIL_CPISTAT_NEW_INCOMING)
{
(void)BroadcastRealBlobNotification(pRspCached->GetNotifyCode(), pBlobCached, cbBlobCached);
}
pRspCached->DeleteBlob();
pBlobCached = NULL;
cbBlobCached = 0;
delete pRspCached;
g_CachedCPINotifs[i] = NULL;
}
}
#endif
if ( g_cphschange )
{
/* let upper layer know about CPHS */
BroadcastRealBlobNotification( RIL_NOTIFY_REGSTATUSCHANGED, &g_dwRegStatus, sizeof(g_dwRegStatus) );
g_cphschange = FALSE;
}
#ifdef RIL_ENABLE_EONS
if ( g_eonschange )
{
/* let upper layer know about EONS */
BroadcastRealBlobNotification( RIL_NOTIFY_EONS, NULL, 0 );
g_eonschange = FALSE;
}
#endif
if (pRsp->FUnrecognized())
{
// We couldn't recognize this response -- assume it was corrupted and throw it away
#ifdef DEBUG
DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : CRilHandle::ResponseThread : Ignoring an unrecognized response: %d chars of %s\r\n"),
pRsp->GetLength(), VerboseString(TString(pRsp->GetData()))));
#endif // DEBUG
g_RilLog.LogEvent(RILLOG_ZONE_CMD, RILLOG_EVENT_UNRECOGNIZEDRSP, PrintableString(pRsp->GetData(), pRsp->GetLength()));
delete pRsp;
pRsp = NULL;
}
else if (!pRsp->FUnsolicited() ||
(RIL_RESULT_BUSY == pRsp->GetNotifyCode() && FWaitingForRsp() && (NULL != m_pCurrCommand && m_pCurrCommand->FDial()) ))
{
#if defined(OEM1_DRIVER) || defined(OEM2_DRIVER)
if (!pRsp->GetNotifyCode() && m_fInited)
{
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : CRilHandle::ResponseThread : Module reset itself?!, rebooting via CPM\r\n")));
if(!CreateProcess(TEXT("rs.exe"), NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL))
{
SignalCriticalError(RILLOG_EVENT_TOOMANYTIMEOUTS, __LINE__, __FILE__);
}
}
#endif
//
// This is a command result
//
// Is someone waiting for this command result?
#if defined(OEM2_DRIVER)
// On TTPCOM, some CPINN command responses come from notification COM port
if (FWaitingForRsp() && ((FALSE == fDataOnNotificationComPort) || pRsp->FCPINNRsp()))
#else
if (FWaitingForRsp() && (FALSE == fDataOnNotificationComPort))
#endif
{
#if 0 // NOT USED
// Treat +CLCC responses while waiting for dial as notifications
if ((m_pCurrCommand->FDial()) && (ParseCLCCNotification(this, m_pCurrCommand, pRsp)))
{
delete pRsp;
pRsp = NULL;
}
else
#endif // 0
#ifdef RIL_RADIO_RESILIENCE
if ( m_pCurrCommand && (RIL_RESULT_OK != pRsp->GetNotifyCode()) && (m_pCurrCommand->CmdOptIsSet(CMDOPT_CPINENTERED)) )
{
// Someone just tried to set the CPIN and failed. Flush the CPIN cache so we don't auto-unlock the phone or PUK the SIM.
SavePINSecure("");
}
if (RIL_RESULT_ERROR == pRsp->GetNotifyCode())
{
UINT cbSize = 0;
LPVOID pBlob = NULL;
pRsp->GetBlob(pBlob, cbSize);
if((sizeof(HRESULT) == cbSize) && (RIL_E_RADIOREBOOTED == *(HRESULT *)pBlob))
{
// Reset g_rcdRingingCallData.fCalltypeValid
g_rcdRingingCallData.fCalltypeValid = FALSE;
// The command failed because the radio rebooted.
// Send up a disconnect notification just in case.
(void)m_pComDevice->ExitDataMode();
(void)BroadcastDWORDBlobNotification(RIL_NOTIFY_DISCONNECT,
RIL_DISCINIT_REMOTE);
}
}
#endif // RIL_RADIO_RESILIENCE
// Yes -- place it into the Response Q
#ifdef OEM1_GPRS_DEACT
bool fQueueResponse = TRUE;
// The current command is a GPRS deactivation command
if (m_pCurrCommand && m_pCurrCommand->CmdOptIsSet(CMDOPT_DEACT)) {
// This is a ME DEACT notification (note that only a ME DEACT notification maps to a solicited
// response with a dwCode of RIL_NOTIFY_GPRS_DISCONNECT)
EnterCriticalSection(&g_csGPRSDeactLock);
if (RIL_NOTIFY_GPRS_DISCONNECT == pRsp->GetNotifyCode()) {
// The command response has already been received, convert the dwCode to look like a result
// and make this as the command response, reset all the flags as we are done
if (g_fDeactResponseRcvd) {
// AT+CGACT, 0, ME case - COMPLETE HERE
pRsp->MakeOK();
g_fDeactNotificationRcvd = g_fDeactResponseRcvd = FALSE;
}
// Otherwise, do not queue this response as we have to wait for the actual command response
else {
// AT+CGACT, ME, 0 case - INCOMPLETE HERE
fQueueResponse = FALSE;
(VOID) pRsp->UpdateDataPointer((UINT)strlen("4\r"));
}
}
// This is the response for the deactivation command
else {
g_fDeactResponseRcvd = TRUE;
// The ME DEACT notification has already been received
if (g_fDeactNotificationRcvd) {
// The ME DEACT notification is stale, wait for a new one, do not queue this response
// Note the calculation below is rollover safe but it will not work if the MEDEACT is as stale
// as 49 days - the assumption is we will not have such a stale ME DEACT under normal
// usage
if ((GetTickCount() - g_LastDeactNotificationRcvd) > STALE_MEDEACT_THRESHOLD) {
// Stale ME, AT+CGACT, 0 case (becomes AT+CGACT, 0, ME case) - INCOMPLETE HERE
g_fDeactNotificationRcvd = FALSE;
fQueueResponse = FALSE;
}
// The ME DEACT notification is not stale, this response becomes the real response
else {
// Fresh ME, AT+CGACT, 0 case - COMPLETE HERE
g_fDeactNotificationRcvd = g_fDeactResponseRcvd = FALSE;
}
//if we are in the process of radio off,we should fake a MEDEACT to MS whatever
RETAILMSG(1, (TEXT("[TI]g_fDeactNotificationRcvd is TRUE and g_isflymode is [%d]\r\n"),g_isflymode));
if(g_isflymode == MODEMMODE_FLYMODE)
{
RILGPRSCONTEXTACTIVATED rGPRSca;
memset(&rGPRSca, 0x00, sizeof(RILGPRSCONTEXTACTIVATED));
rGPRSca.cbSize = sizeof(rGPRSca);
rGPRSca.fActivated = FALSE;
rGPRSca.dwContextID = 1;
rGPRSca.dwEvent = RIL_RILGPRSCONTEXTACTIVATED_MEDEACT;
(void)BroadcastRealBlobNotification(RIL_NOTIFY_GPRS_DISCONNECT,
&rGPRSca, sizeof(rGPRSca));
fQueueResponse = TRUE;
(VOID) pRsp->UpdateDataPointer((UINT)strlen("0\r"));
RETAILMSG(1, (TEXT("[TI]RILDrv :Broadcast GPRS_DISCONNECT !!!!!\r\n")));
//g_bDeleteTimeout = FALSE;
}
}
// Otherwise, wait for a ME DEACT, do not queue this response
else {
// AT+CGACT, 0, ME case - INCOMPLETE HERE
if (RIL_RESULT_NOCARRIER == pRsp->GetNotifyCode())
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -