Example #1
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_GetIMSI
(
    pa_sim_Imsi_t imsi   ///< [OUT] IMSI value
)
{
    le_result_t result;
    atcmdsync_ResultRef_t  resRef = NULL;
    // IMSI start with 0|1|2|3|4|5|6|7|8|9
    const char* interRespPtr[] = {"0","1","2","3","4","5","6","7","8","9",NULL};

    if (!imsi)
    {
        LE_DEBUG("One parameter is NULL");
        return LE_BAD_PARAMETER;
    }

    result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                    "at+cimi",
                                    &resRef,
                                    interRespPtr,
                                    30000);

    if ( result != LE_OK ) {
        le_mem_Release(resRef);
        return result;
    }

    le_sim_States_t simState=LE_SIM_STATE_UNKNOWN;
    char* line = atcmdsync_GetLine(resRef,0);
    if (CheckStatus(line,&simState))
    {
        ReportStatus(NumCard,simState);
    }

    // If there is more than one line then it mean that the command is OK so the first line is
    // the intermediate one
    if (atcmdsync_GetNumLines(resRef) == 2)
    {
        line = atcmdsync_GetLine(resRef,0);
        // copy just the first line because of '\0'
        atcmd_CopyStringWithoutQuote(imsi,
                                   line,
                                   strlen(line));

        result = LE_OK;
    }
    // it is not expected
    else {
        LE_WARN("this pattern is not expected");
        result=LE_NOT_POSSIBLE;
    }

    le_mem_Release(resRef);     // Release atcmdsync_SendCommandDefaultExt

    return result;
}
Example #2
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_mdc_GetGatewayAddress
(
    uint32_t profileIndex,                  ///< [IN] The profile to use
    le_mdmDefs_IpVersion_t ipVersion,               ///< [IN] IP Version
    char*  gatewayAddrStr,                  ///< [OUT] The gateway IP address in dotted format
    size_t gatewayAddrStrSize               ///< [IN] The size in bytes of the address buffer
)
{
    le_result_t result = LE_FAULT;
    char atcommand[ATCOMMAND_SIZE] ;
    char atintermediate[ATCOMMAND_SIZE];

    atcmdsync_PrepareString(atintermediate,ATCOMMAND_SIZE,"+CGPADDR: %d,",profileIndex);

    const char* interRespPtr[] = {atintermediate,NULL};
    atcmdsync_ResultRef_t  atRespPtr = NULL;

    atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cgpaddr=%d",profileIndex);

    result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                    atcommand,
                                    &atRespPtr,
                                    interRespPtr,
                                    30000);

    if ( result != LE_OK ) {
        le_mem_Release(atRespPtr);
        return result;
    }
    // If there is more than one line then it mean that the command is OK so the first line is
    // the intermediate one
    if (atcmdsync_GetNumLines(atRespPtr) == 2)
    {
        // it parse just the first line because of '\0'
        char* line = atcmdsync_GetLine(atRespPtr,0);
        uint32_t  numParam = atcmd_CountLineParameter(line);
        // it parse just the first line because of '\0'

        if (FIND_STRING("+CGPADDR:",atcmd_GetLineParameter(line,1)))
        {
            if (numParam==3)
            {
                if(atoi(atcmd_GetLineParameter(line,2)) == profileIndex)
                {
                    const char* pAddr = atcmd_GetLineParameter(line,3);
                    size_t length = strlen(pAddr);
                    if (length-2 < gatewayAddrStrSize) {
                        atcmd_CopyStringWithoutQuote(gatewayAddrStr,pAddr,gatewayAddrStrSize);
                        result = LE_OK;
                    } else {
                        result = LE_OVERFLOW;
                    }
                } else
                {
                    LE_WARN("This is not the good profile %d",
                            atoi(atcmd_GetLineParameter(line,2)));
                    result = LE_FAULT;
                }
            } else {
                LE_WARN("this pattern is not expected");
                result = LE_FAULT;
            }
        } else {
            LE_WARN("this pattern is not expected");
            result = LE_FAULT;
        }
    }

    le_mem_Release(atRespPtr);     // Release atcmdsync_SendCommandDefaultExt

    return result;
}
Example #3
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_GetCardIdentification
(
    pa_sim_CardId_t iccid     ///< [OUT] CCID value
)
{
    le_result_t result=LE_OK;
    atcmdsync_ResultRef_t  resRef = NULL;
    const char* interRespPtr[] = {"+CCID:",NULL};

    if (!iccid)
    {
        LE_DEBUG("One parameter is NULL");
        return LE_BAD_PARAMETER;
    }

    result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                    "at+ccid",
                                    &resRef,
                                    interRespPtr,
                                    30000);

    if ( result != LE_OK ) {
        le_mem_Release(resRef);
        return result;
    }

    le_sim_States_t simState=LE_SIM_STATE_UNKNOWN;
    char* line = atcmdsync_GetLine(resRef,0);
    if (CheckStatus(line,&simState))
    {
        ReportStatus(NumCard,simState);
    }

    // check error
    if (atcmdsync_GetNumLines(resRef) == 2)
    {

        line = atcmdsync_GetLine(resRef,0);
        uint32_t numParam = atcmd_CountLineParameter(line);
        // it parse just the first line because of '\0'

        if (FIND_STRING("+CCID:",atcmd_GetLineParameter(line,1)))
        {
            if (numParam==2)
            {
                atcmd_CopyStringWithoutQuote(iccid,
                                            atcmd_GetLineParameter(line,2),
                                            strlen(atcmd_GetLineParameter(line,2)));
                result = LE_OK;
            } else {
                LE_WARN("this pattern is not expected");
                result=LE_NOT_POSSIBLE;
            }
        } else {
            LE_WARN("this pattern is not expected");
            result=LE_NOT_POSSIBLE;
        }
    }

    le_mem_Release(resRef);     // Release atcmdsync_SendCommandDefaultExt
    return result;
}