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

📄 enfora.cpp

📁 Windows CE documentation and examples from the Windows CE development manuals. There are lots of exa
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            DEBUGMSG(ZONE_ATCMD, (TEXT("RILDrv : i : Parse CGEV: found NW REACT \r\n")));
        }
        // make sure the upper levels know that we discarded this
        if(!fSendingNotification)
            ParseJunk(1, szPointer);
     }
    // HW-SPECIFIC: OEM1 driver issues custom %SATI, %SATA, and %SATN notifications for SIM Toolkit events
    else if (MatchStringBeginning(szPointer, "%SATI: ", szPointer))
    {
        // Unhandled SIM Toolkit command notification
        if (!ParseSIMToolkitCmdOrRsp(szPointer, RIL_NOTIFY_SIMTOOLKITCMD))
        {
            fRetVal = FALSE;
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "%SATN: ", szPointer))
    {
        // Unhandled SIM Toolkit command or response notification
        if (!ParseSIMToolkitCmdOrRsp(szPointer, RIL_NOTIFY_SIMTOOLKITEVENT))
        {
            fRetVal = FALSE;
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "%SATA:", szPointer))
    {
        // SIMToolkit SetupCall notification
        if (!ParseSIMToolkitCallSetup(szPointer))
        {
            fRetVal = FALSE;
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "%SATE: ", szPointer))
    {
        // The %SATE response occurs only for SETUP MENU REPLY and is not needed.
        // The real data we are interested in will be in the upcoming %SATI notification.
        ParseJunk(1, szPointer);
    }
    else if (MatchStringBeginning(szPointer, "+EXT ERROR: ", szPointer))
    {
        UINT nCode = 0;
        
        if (!ParseExtError(szPointer, NULL, 0, rppTIPDDParams.pemEXTErrorTable, rppTIPDDParams.uiEXTErrorTableSize, nCode, TRUE))
        {
            DEBUGMSG(ZONE_ATCMD, (TEXT("RILDrv : i : Unrecognized EXT Error response\r\n")));
            fRetVal = FALSE;
            goto Error;
        }
#ifdef RIL_LAST_ERROR
        g_dwLastError = MAKELONG(nCode, RADIO_EXTERROR);
#endif
#ifdef RIL_WATSON_REPORT
        EnterCriticalSection(&g_csRilInfoCache);
        strncpyz(g_RilInfoCache.szLastError, szPointer, MAXLENGTH_CMD);
        LeaveCriticalSection(&g_csRilInfoCache);
        fErrorNotification = true;
#endif // RIL_WATSON_REPORT

        fExpectCRLF = FALSE;
    }
    else
    {
        // Treat the "no match" case as an error
        fRetVal = FALSE;
        goto Error;
    }

Error:
    return fRetVal;
}

BOOL CResponseTI::ParseSIMToolkitCmdOrRspOEM
(
   LPCSTR& rszPointer, // IN, OUT
   const DWORD dwNotifyCode, // IN
   RILSIMTOOLKITCMD*& pCmd, // OUT
   DWORD& dwCmdSize // OUT
)
{
    BYTE* pbDataWalk=NULL;
    LPCSTR szDummy=NULL;
    UINT i=0;
    UINT cbDataString=0;
    LPCSTR pchDataStringWalk=NULL;
    LPSTR szDataString = NULL;
    DWORD dwSIMResponse=0;
    
    BYTE* pbData = NULL;
    UINT cbData = 0;
    CRilSimToolkitCommand rstcCmd;    
    BOOL fRet = FALSE;

    // Determine if data is wrapped in quotes and Parse <data>
    // NOTE: we take ownership of allocated szDataString in both cases
    if ('\"' == *rszPointer)
    {
        // Look for a "<postfix>"
        if (!MatchStringAnywhere(rszPointer, "\"\r\n", szDummy))
        {
            // This isn't a complete SIM Toolkit notification -- no need to parse it
            goto Error;
        }

        if (!ParseUnlimitedString(rszPointer, szDataString, cbDataString, rszPointer))
        {
            goto Error;
        }
    }
    else
    {
        // Look for a "<postfix>"
        if (!FindRspPostfix(rszPointer, szDummy))
        {
            // This isn't a complete SIM Toolkit notification -- no need to parse it
            goto Error;
        }
    
        if (!ParseUnlimitedUnquotedString(rszPointer, '\r', szDataString, cbDataString, rszPointer))
        {
            goto Error;
        }
    }
    
    if ( (szDataString[0]=='\0') && (dwNotifyCode==RIL_NOTIFY_SIMTOOLKITCMD) )
    {
        m_dwCode=RIL_NOTIFY_SIMTOOLKITSESSIONEND;
    }
    else
    {
        DEBUGCHK(0 == (cbDataString - 1) % 2);

        if ( 0 == cbDataString )
        {
            goto Error;
        }
        cbData = (cbDataString - 1) / 2;
        if ( 0 == cbData  )
        {
            goto Error;
        }
        pbData = (BYTE*)AllocBlob(cbData);
        if (!pbData)
        {
            goto Error;
        }

        pbDataWalk = pbData;
        pchDataStringWalk = szDataString;
        for (i = 0; i < cbData; i++)
        {
            if ( (*(pchDataStringWalk + 1) != 0x0a) && (*(pchDataStringWalk + 1) != 0x0d))
            {
                *pbDataWalk = SemiByteCharsToByte(*pchDataStringWalk, *(pchDataStringWalk + 1));
                pbDataWalk++;
            }

            pchDataStringWalk += 2;
        }

        cbData = pbDataWalk - pbData;
        pCmd = NULL;
        dwCmdSize = 0;
        dwSIMResponse = SIM_RESPONSE_OK;
        dwSIMResponse = rstcCmd.ParseCommand((LPSTR)pbData, cbData, &pCmd, &dwCmdSize);

        if (SIM_RESPONSE_OK != dwSIMResponse)
        {
            // Error parsing the command. 
            // There was a critical error if an error notification was not created.
            if (NULL == pCmd || (0 >= dwCmdSize))
            {
                goto Error;
            }

            // With this radio, we occasionally receive notifications of 
            // radio handled responses which we do not want to send a response for.
            if (SIM_RESPONSE_ERR_COMMANDNUMBER != dwSIMResponse)
            {
                // Send a response to the radio
                if (FAILED(SendSIMToolkitErrorRsp(pCmd)))
                {
                    DEBUGCHK(FALSE);
                }
            }
        }
    
        if (!SetBlob((void*)pCmd, dwCmdSize))
        {
            goto Error;
        }
        m_dwCode = dwNotifyCode;
    }

    m_fUnsolicited = TRUE;
    fRet = TRUE;

Error:
    
    delete[] szDataString;
    FreeBlob(pbData);    
    return fRet;
}

void CResponseTI::Pre_ParseOKOrErrorOEM(const char* szPointer)
{
    // Necessary change to make battery driver calls work on this hardware
    if( strstr( szPointer, "ADC" ) )
    {
        LPCSTR pch;

        pch = const_cast<char*>(strstr( szPointer, "\n4\r" ));
        if( pch )
        {
            *(m_szData + (pch - m_szData) +1) = 0x30;
        }
    }
    
    return;
}
static DWORD WINAPI StartSIMRecordReadThreadCB( LPVOID lpThreadData )
{
    StartPlmnNameRead();
#ifdef RIL_ENABLE_EONS
    StartEONSRead();
#endif
    return 0;
}

void StartSIMRecordReadThread()
{
    /* do not block current thread -- do the SIM record read in another thread */
    HANDLE hThread = CreateThread(NULL, 0, &StartSIMRecordReadThreadCB, 0, 0, NULL);
    if ( hThread != NULL )
    {
        CloseHandle( hThread );
        hThread = NULL;
    }
}


HRESULT PDD_CreateCommand_GetATR(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd)
{
   return StringCchCopyA( szCmd, cchCmd, "AT%ATR?\r" );
}

//
//
//
static HRESULT ParseATRInfo(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
    FUNCTION_TRACE(ParseATRInfo);
    
    HRESULT hr = S_OK;
    RILATRINFO* pATRInfo = NULL;
    UINT uiPhase;
    UINT uiCurATRChar;
    UINT cbATRString;
    UINT cbATRData;
    LPSTR szATRString = NULL;
    LPCSTR pchATRStringWalk;
    BYTE* pbATRDataWalk;
    
    
    // Check parameters
    if (NULL == szRsp)
    {
        DEBUGCHK(FALSE);
        return E_INVALIDARG;
    }

    // Initialize output parameters
    pBlob = NULL;
    cbBlob = 0;

    pATRInfo = (RILATRINFO*)AllocBlob(sizeof(RILATRINFO));
    if (NULL == pATRInfo)
    {
        DEBUGCHK(FALSE);
        hr = E_OUTOFMEMORY;
        goto Error;
    }

    memset(pATRInfo, 0, sizeof(RILATRINFO));
    pATRInfo->cbSize = sizeof(RILATRINFO);
    
    // Parse "<prefix>%ATR: <Phase>,<ATR>"
    // We take ownership of szATRString and are responsible for freeing the memory.
    if (!ParseRspPrefix(szRsp, szRsp)                 ||
        !MatchStringBeginning(szRsp, "%ATR: ", szRsp) ||
        !ParseHexUInt(szRsp, TRUE, uiPhase, szRsp)    ||
        !MatchStringBeginning(szRsp, ",", szRsp)      ||
        !ParseUnlimitedUnquotedString(szRsp, '\r', szATRString, cbATRString, szRsp)) {
        hr = E_FAIL;
        goto Error;
    }

    // Assert that the data we received is an even length.
    DEBUGCHK(0 == (cbATRString-1) % 2);

    cbATRData = (cbATRString-1) / 2;
    pchATRStringWalk = szATRString;
    pbATRDataWalk = pATRInfo->rgbATR;
    
    // Check that the data is not larger than the space available in the structure.
    if (cbATRData > ARRAY_LENGTH(pATRInfo->rgbATR))
    {
        DEBUGCHK(!"ATR Data is larger than the structure buffer.");
        hr = E_FAIL;
        goto Error;
    }

    // Walk through the ATR string and convert to bytes.
    for (uiCurATRChar = 0 ; uiCurATRChar < cbATRData ; uiCurATRChar++)
    {
        *pbATRDataWalk = SemiByteCharsToByte(*pchATRStringWalk, *(pchATRStringWalk + 1));
        pbATRDataWalk++;
        pchATRStringWalk += 2;
    }


    // Everything is parsed, finish setting all the fields of the structure.
    pATRInfo->cbATRSize = cbATRData;
    pATRInfo->dwPhase = uiPhase;
    pATRInfo->dwParams = RIL_PARAM_ATR_ALL;

    // Everything is finished. Assign the results to the output parameters        
    pBlob = pATRInfo;
    cbBlob = sizeof(RILATRINFO);

Error:
    if (FAILED(hr)) 
    {
        FreeBlob(pATRInfo);
    }
    return hr;
}

HRESULT PDD_CreateCommand_TerminateSimToolkitSession(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in const DWORD dwCause)
{
   return StringCchPrintfA( szCmd, cchCmd, "AT%%SATT=%u\r", dwCause );
}

HRESULT PDD_CreateCommand_EnableSignalQualityNotification(__out_ecount(cchCmd) LPSTR szCmd, __in const size_t cchCmd, __in const bool fEnable)
{
   return StringCchPrintfA( szCmd, cchCmd, "AT%%CSQ=%u\r", (fEnable?1:0) );
}

// NDIS stuff
HRESULT PDD_GetRilNdisObject(__in const CRilHandle* pRilHandle, __out CRilNDIS*& pRilNdis)
{
    //Not supported
    return E_NOTIMPL;
}

HRESULT PDD_GetRilInstanceNdisObject(__in const CRilInstanceHandle* pRilInstanceHandle, __out CRilInstanceNDIS*& pRilInstanceNdis)
{
    //Not supported
  

⌨️ 快捷键说明

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