⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ttpcom.cpp

📁 我自己编译的armv4i wince60模拟器的bps源文件,已经验证可以使用,欢迎下载
💻 CPP
📖 第 1 页 / 共 5 页
字号:
{
    // On OEM2 we need to reset the CPINN event in case one has happened previously.
    if (NULL != g_hCPINNEvent)
    {
        ResetEvent(g_hCPINNEvent);
    }

    return S_OK;
}

// Prepare to deactivate GPRS context

HRESULT PDD_BeginGPRSContextDeactivation()
{
   return E_NOTIMPL;
}

// Wait for the SIM to be ready

HRESULT PDD_WaitForSIMReady()
{
    HRESULT hr = S_OK;
    
    // On OEM2 we really can't allow any other commands to go down after a CFUN=1 until we get a +CPINN notification.
    // Note that this restriction doesn't apply if the previous equipment state is RIL_EQSTATE_DISABLETX, 
    // RIL_EQSTATE_DISABLERX, or RIL_EQSTATE_DISABLETXANDRX.
    if (NULL != g_hCPINNEvent)
        {
        DWORD dwWaitResult = WaitForSingleObject(g_hCPINNEvent, 30000);
        switch (dwWaitResult)
            {
            case WAIT_OBJECT_0:
                break;
            case WAIT_TIMEOUT:
                // hr = E_TIMEOUT;
                DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : Timeout for CPINN event - this is only an error if the previous RIL_EQSTATE was RIL_EQSTATE_MINIMUM\r\n")));
                break;
            default:
                hr = E_FAIL;
                DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : Error waiting for CPINN event\n")));
                break;
            }
        }
    
    return hr;
}

// Create GetEquipmentInfo command

HRESULT PDD_CreateCommand_GetEquipmentInfo(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
   return StringCchCopyA( szCmd, cchCmd, "AT+CGMI;+CGMM;+CGMR;+CGSN\r" );
}

// Create command for any setup before radio on

HRESULT PDD_CreateCommand_SetupBeforeRadioOn(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in const bool fPrefixPresent)
{
    return E_NOTIMPL;
}

// Create command for any cleanup before radio off

HRESULT PDD_CreateCommand_CleanupBeforeRadioOff(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in const bool fPrefixPresent)
{
    return StringCchCopyA( szCmd, cchCmd, ( fPrefixPresent ) ? "+CGATT=0;" : "AT+CGATT=0;" );
}

// Create GetSimToolkitProfile command

HRESULT PDD_CreateCommand_GetSimToolkitProfile(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
    return E_NOTIMPL;
}
    
// Create SetSimToolkitProfile command

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+STPD=%d,%s\r", cchSTKPS, szSTKProfileString );
}

// Create SimToolkitEnvelopeCmd command

HRESULT PDD_CreateCommand_SimToolkitEnvelopeCmd(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in_ecount(dwSize) const BYTE* lpbCommand, __in const DWORD dwSize)
{
    // For OEM2, we really aren't sending a Envelope command, since OEM2 does
    // not have such a command. However, the RILDrv_SendSimToolkitEnvelopeCmd
    // call is used exclusively to select a menu item from the main menu.
    // To maintain API compatibility RILDrv_SendSimToolkitEnvelopeCmd will 
    // send the OEM2 Menu Selection command +STMS.

   return StringCchPrintfA( szCmd, cchCmd, "AT+STMS=%s\r", lpbCommand );
}

// Create SIMTKCmdResponsePrefix command

HRESULT PDD_CreateCommand_SIMTKCmdResponsePrefix(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in const DWORD dwResponseType)
{
    return StringCchCopyA( szCmd, cchCmd, ( SIM_NOTIFY_SETUPMENU_REPLY == dwResponseType ) ? "AT+STMS=" : "AT+STCR=" ); 
}

// Create SIMTKEventDownloadPrefix command

HRESULT PDD_CreateCommand_SIMTKEventDownloadPrefix(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
    return StringCchCopyA( szCmd, cchCmd, "AT+STEV=" ); 
}

HRESULT PDD_CreateCommand_BuildInfoQuery(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
   return E_NOTIMPL;
}

HRESULT PDD_CreateCommand_BatteryInfoQuery(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
   return E_NOTIMPL;
}

HRESULT PDD_RebootRadio()
{
    TCHAR tszComName[6];
    bool fResult = FALSE;
    if (!GetRegistrySZ(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("ComPort"), tszComName, 6))
    {
        _tcsncpyz(tszComName, TEXT("MUX1:"), 6);
    }

    // Try to open the COM port
    HANDLE hRebootPort = CreateFile(tszComName, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
    if (INVALID_HANDLE_VALUE != hRebootPort)
    {
        DWORD dwBytesReturned = 0;

        fResult = (DeviceIoControl(hRebootPort, IOCTL_TTPCOM_REBOOT, NULL, 0, NULL, 0,  &dwBytesReturned, NULL) != 0);
        CloseHandle(hRebootPort);
    }

    return fResult ? S_OK : E_FAIL;
}

HRESULT PDD_CreateCommand_GetPostRebootDiagnostics(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
   return E_NOTIMPL;
}


HRESULT
PDD_CreateCommand_GetNITZSupported(
    __out_ecount(cchCmd) LPSTR szCmd,
    __in size_t cchCmd
)
{
    return E_NOTIMPL;
}


HRESULT PDD_GetResponseObject(__out CResponse*& pNewRsp, __in const CResponse* pSrcRsp)
{
   if (NULL == pSrcRsp) {
    pNewRsp = new CResponseTTPCOM;
    }
   else {
    pNewRsp = new CResponseTTPCOM(*(static_cast<const CResponseTTPCOM*>(pSrcRsp)));    
    }

   return (pNewRsp ? S_OK : E_OUTOFMEMORY);
}
    
HRESULT PDD_Initialize(__out const RILPDDParams*& prppRILPDDParams)
{
    bool fRetVal = TRUE;

    g_hCPINNEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    if (!g_hCPINNEvent)
    {
        fRetVal = FALSE;
        goto Error;
    }

Error:
    return fRetVal ? S_OK : E_FAIL;
}

HRESULT PDD_Deinitialize()
{
    if (g_hCPINNEvent)
    {
        (void)CloseHandle(g_hCPINNEvent);
        g_hCPINNEvent = NULL;
    }

    return S_OK;
}

HRESULT PDD_CreateCommand_ChangeLockingPassword(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in const DWORD dwFacility, __in LPCSTR lpszOldPassword, __in LPCSTR lpszNewPassword)
{
    // Other hardware uses +CPIN and will fail if no PIN request is pending, per GSM 07.07
    return StringCchPrintfA( szCmd, cchCmd, "AT+CPIN=\"%s\",\"%s\"\r", lpszOldPassword, lpszNewPassword );
}

HRESULT PDD_SetDownlinkVolume(__in const DWORD dwDownlinkVolume)
{
    g_dwCacheDownlinkVolume = dwDownlinkVolume;
    return S_OK;    
}

HRESULT PDD_GetDownlinkVolume(__in const bool fNormalized, __out UINT& uiDownlinkVolume)
{
   // downlink volume on OEM2 is in the range 0-100, not 0-255, so nomalize here.
   uiDownlinkVolume = (fNormalized ? (g_dwCacheDownlinkVolume*100/255) : g_dwCacheDownlinkVolume);
   return S_OK;
}

HRESULT PDD_SetUplinkVolume(__in const DWORD dwUplinkVolume)
{
    g_dwCacheUplinkVolume = dwUplinkVolume;
    return S_OK;    
}

HRESULT PDD_GetUplinkVolume(__out UINT& uiUplinkVolume)
{
   uiUplinkVolume = g_dwCacheUplinkVolume;
   return S_OK;
}

BOOL CResponseTTPCOM::ParseSTC(LPCSTR& rszPointer)
{
    FUNCTION_TRACE(CResponse::ParseSTC);
        
    UINT nstCommand;
    char szCmd[MAX_PATH];
    BOOL fRet = FALSE;

    // Get the command ID.
    if (!ParseUInt(rszPointer, FALSE, nstCommand, rszPointer))
    {
        goto Error;
    }

    // 81 is end of proactive session
    if (81 == nstCommand)
    {
        // End of Proactive session.
        m_dwCode=RIL_NOTIFY_SIMTOOLKITSESSIONEND;
        m_fUnsolicited = TRUE;
    }
    // SIM toolkit commands.
    else if(nstCommand >= 0)
    {
        // Ignore command ID of 0. 
        // A command of 0 signifies that there is no SIM toolkit support on the SIM.
        if (nstCommand != 0)
        {
            // echo back command to get the data. Ignore the response and let the notification
            // parsing handle it.
            (void)_snprintfz(szCmd, MAX_PATH, "AT+STGC=%d\r", nstCommand);
            if (!QueueCmdIgnoreRsp(APIID_NONE, szCmd, CMDOPT_IGNORERSP, g_TimeoutCmdInit, NULL, NULL, 2, 0, 0))
            {
                goto Error;
            }
        }
        
        // Send an empty SIM Toolkit event notification to let others know something is happening. 
        // Upper SIM toolkit layers will just ignore this, but an appropriate code needs
        // to be sent to prevent errors reported and problems for further command processing.
        m_dwCode = RIL_NOTIFY_SIMTOOLKITEVENT;
        m_fUnsolicited = TRUE;

    }

    fRet = TRUE;

    Error:
    return fRet;
}

BOOL CResponseTTPCOM::ParseNotificationOEM
(
    LPCSTR& szPointer,
    BOOL& fExpectCRLF,
    BOOL fDataOnNotificationPort
#ifdef RIL_WATSON_REPORT    
    , BOOL& fErrorNotification
#endif
)
{
    BOOL fRetVal = TRUE;
        
    if (MatchStringAnywhere(szPointer, "+CCRASHED 0", szPointer))
    {
        m_fUnsolicited = FALSE;
        g_fSignalQualityReceived = FALSE;
        
#ifdef RIL_RADIO_RESILIENCE
        // This indicates a radio reboot
        SignalCriticalError(RILLOG_EVENT_GENERALREINIT, __LINE__, __FILE__);        
        MakeError(RIL_E_RADIOREBOOTED);
#endif // RIL_RADIO_RESILIENCE
    }
    else if (MatchStringAnywhere(szPointer, "+CCRASHED 2", szPointer))
    {
        m_fUnsolicited = FALSE;
        g_fSignalQualityReceived = FALSE;
        
#ifdef RIL_RADIO_RESILIENCE
        // This indicates a radio reboot failure
        SignalCriticalError(RILLOG_EVENT_GENERALREINIT, __LINE__, __FILE__);        
        MakeError(RIL_E_RADIOREBOOTED);
#endif // RIL_RADIO_RESILIENCE
        DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : Radio has crashed - Cold Boot required.\r\n")));
        ASSERT(0);
    }
    // SIM Toolkit command notification.
    else if (MatchStringBeginning(szPointer, "+STC: ", szPointer))
    {
        if(!ParseSTC(szPointer))
        {
            fRetVal = FALSE;
            goto Error;
        }
    }
    // SIM toolkit Get Command Notification
    else if (MatchStringBeginning(szPointer, "+STGC: ", szPointer) )
    {
        // Parse the SIM toolkit get command response.
        if (!ParseSIMToolkitCmdOrRsp(szPointer, RIL_NOTIFY_SIMTOOLKITCMD))
        {
            fRetVal = FALSE;
            goto Error;
        }
    }
    // SIM toolkit Unsolicited Data notification
    else if (MatchStringBeginning(szPointer, "+STUD: ", szPointer))
    {
        // Parse the SIM toolkit unsolicited data.
        if (!ParseSIMToolkitCmdOrRsp(szPointer, RIL_NOTIFY_SIMTOOLKITEVENT))
        {
            fRetVal = FALSE;
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "+ERRMSG: ", szPointer))
    {
        // OEM2 protocol stack emits asserts prefixed with +ERRMSG, the error
        // message follows without any quotation marks, ignore this for now
        // Should be hooked into the event logger longer term
        ParseJunk(1, szPointer);
    }
    else if (MatchStringBeginning(szPointer, "+CSQN: ", szPointer))
    {        
        LPCSTR szPostfix;
        if (!FindRspPostfix(szPointer, szPostfix))
        {
            // This isn't a complete signal quality notification -- no need to parse it
            fRetVal = FALSE;
            goto Error;
        }
        if (!g_fSignalQualityReceived)
        {
            memset(&g_rsq, 0x00, sizeof(RILSIGNALQUALITY));
        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -