Example #1
0
static le_result_t SetIndicator()
{
    uint32_t wind;

    if ( pa_common_GetWindIndicator(&wind) != LE_OK)
    {
        return LE_NOT_POSSIBLE;
    }

    if ( pa_common_SetWindIndicator(wind|1|8) != LE_OK)
    {
        return LE_NOT_POSSIBLE;
    }

    atmgr_SubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),
                                   EventUnsolicitedId,
                                   "+WIND: 0",
                                   false);

    atmgr_SubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),
                                   EventUnsolicitedId,
                                   "+WIND: 1",
                                   false);

    return LE_OK;
}
Example #2
0
//--------------------------------------------------------------------------------------------------
static le_result_t SetIndicationHandler
(
    uint32_t  mode  ///< Unsolicited result mode
)
{
    char atcommand[ATCOMMAND_SIZE] ;

    atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cgerep=%d",mode);

    le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                                atcommand,
                                                NULL,
                                                NULL,
                                                30000);
    if ( result == LE_OK )
    {
    if (mode) {
        atmgr_SubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),
                                   UnsolicitedEvent,
                                   "+CGEV:",
                                   false);
    } else {
            atmgr_UnSubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),UnsolicitedEvent,"+CGEV:");
        }
    }

    return result;
}
Example #3
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_mdc_Init
(
    void
)
{
    if (atports_GetInterface(ATPORT_COMMAND)==NULL) {
        LE_WARN("DATA Module is not initialize in this session");
        return LE_FAULT;
    }

    if (atports_GetInterface(ATPORT_PPP)==false) {
        LE_WARN("PPP Module is not initialize in this session");
        return LE_FAULT;
    }

    NewSessionStateEvent = le_event_CreateIdWithRefCounting("NewSessionStateEvent");
    UnsolicitedEvent     = le_event_CreateId("SessionUnsolicitedEvent",sizeof(atmgr_UnsolResponse_t));
    NewSessionStatePool  = le_mem_CreatePool("NewSessionStatePool", sizeof(pa_mdc_SessionStateData_t));

    InternalEventCall = le_event_CreateId("MDCInternalEventCall",sizeof(atmgr_UnsolResponse_t));
    le_event_AddHandler("MDCUnsolHandler",InternalEventCall  ,MDCInternalHandler);

    // set unsolicited +CGEV to Register our own handler.
    SetIndicationHandler(2);

    le_event_AddHandler("MDCUnsolHandler",UnsolicitedEvent  ,CGEVUnsolHandler);

    return LE_OK;
}
Example #4
0
//--------------------------------------------------------------------------------------------------
static le_result_t SetPPPPort
(
    bool enable
)
{
    LE_DEBUG("PPP Port %s",(enable==true)?"Enable":"Disable");
    if ( enable ) {
        atmgr_StartInterface(atports_GetInterface(ATPORT_PPP));
    } else {
        atmgr_StopInterface(atports_GetInterface(ATPORT_PPP));
    }

    return LE_OK;
}
Example #5
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_mrc_SetRadioPower
(
    le_onoff_t    power   ///< [IN] The power state.
)
{
    char atcommand[ATCOMMAND_SIZE] ;

    if (power == LE_ON)
    {
        atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cfun=1");
    }
    else if (power == LE_OFF)
    {
        atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cfun=0");
    }
    else
    {
        return LE_FAULT;
    }

    return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                  atcommand,
                                  NULL,
                                  NULL,
                                  30000);
}
Example #6
0
//--------------------------------------------------------------------------------------------------
static le_result_t resetModem
(
    void
)
{
    atcmdsync_ResultRef_t  resRef=NULL;
    const char* finalRespOkPtr[] = {"+WIND: 4",NULL };
    const char* finalRespKoPtr[] = {"ERROR","+CME ERROR:","+CMS ERROR:","TIMEOUT",NULL};

    atcmd_Ref_t atReqRef = atcmd_Create();

    atcmd_AddCommand(atReqRef,"at+cfun=1",false);
    atcmd_AddData       (atReqRef,NULL,0);
    atcmd_SetTimer      (atReqRef,30000,atcmdsync_GetTimerExpiryHandler());
    atcmd_AddIntermediateResp    (atReqRef,atcmdsync_GetIntermediateEventId(),NULL);
    atcmd_AddFinalResp(atReqRef,atcmdsync_GetFinalEventId(),finalRespOkPtr);
    atcmd_AddFinalResp(atReqRef,atcmdsync_GetFinalEventId(),finalRespKoPtr);

    resRef = atcmdsync_SendCommand(atports_GetInterface(ATPORT_COMMAND),atReqRef);

    le_result_t result = atcmdsync_CheckCommandResult(resRef,finalRespOkPtr,finalRespKoPtr);

    le_mem_Release(atReqRef);   // Release e_atmgr_Object_CreateATCommand
    le_mem_Release(resRef);  // Release le_pa_at_SendSync

    return result;
}
Example #7
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_EnterPUK
(
    pa_sim_PukType_t   type, ///< [IN] puk type
    const pa_sim_Puk_t puk,  ///< [IN] PUK code
    const pa_sim_Pin_t pin   ///< [IN] new PIN code
)
{
    atcmdsync_ResultRef_t  resRef = NULL;
    char atcommand[ATCOMMAND_SIZE] ;

    atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cpin=%s,%s",puk,pin);

    le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                                atcommand,
                                                &resRef,
                                                NULL,
                                                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);
    }

    le_mem_Release(resRef); // release atcmdsync_SendCommandDefault
    return LE_OK;
}
Example #8
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_common_GetWindIndicator
(
    uint32_t*  windPtr
)
{
    le_result_t result = LE_OK;
    atcmdsync_ResultRef_t  resRef = NULL;
    const char* interRespPtr[] = {"+WIND:",NULL};

    LE_ASSERT(windPtr);

    result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                    "AT+WIND?",
                                    &resRef,
                                    interRespPtr,
                                    30000);

    if ( result == LE_OK )
    {
        char* line = atcmdsync_GetLine(resRef,0);
        if ( sscanf(line,"+WIND: %d",windPtr) != 1)
        {
            LE_DEBUG("cannot qet wind indicator");
            result = LE_FAULT;
        }
    }

    le_mem_Release(resRef);
    return result;
}
Example #9
0
//--------------------------------------------------------------------------------------------------
static le_result_t StartPDPConnection
(
    uint32_t profileIndex    ///< [IN] The profile identifier
)
{
    char atcommand[ATCOMMAND_SIZE] ;
    atcmd_Ref_t atReqRef=NULL;
    atcmdsync_ResultRef_t  atresRef;
    const char* finalRespOkPtr[] = { "CONNECT" , NULL };
    const char* finalRespKoPtr[] = { "NO CARRIER", "TIMEOUT", NULL};

    atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"ATD*99***%d#",profileIndex);

    atReqRef = atcmdsync_PrepareStandardCommand(atcommand,
                                                    NULL,
                                                    finalRespOkPtr,
                                                    finalRespKoPtr,
                                                    30000);
    atresRef = atcmdsync_SendCommand(atports_GetInterface(ATPORT_PPP),atReqRef);
    le_result_t result = atcmdsync_CheckCommandResult(atresRef,finalRespOkPtr,finalRespKoPtr);

    le_mem_Release(atReqRef);
    le_mem_Release(atresRef);

    return result;
}
Example #10
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_SelectCard
(
    uint32_t  cardNum     ///< [IN] The card number to be selected.
)
{
    char atcommand[ATCOMMAND_SIZE] ;

    if ((cardNum==1) || (cardNum==2)) {
        atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+whcnf=4,%d",cardNum);
    } else {
        LE_DEBUG("This card number (%d) is not supported",cardNum);
        return LE_NOT_POSSIBLE;
    }

    le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                                atcommand,
                                                NULL,
                                                NULL,
                                                30000);

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

    if (resetModem()!=LE_OK)
        {
        return LE_NOT_POSSIBLE;
        }

    NumCard = cardNum;

    return result;
}
Example #11
0
//--------------------------------------------------------------------------------------------------
static void SubscribeUnsolCREG
(
    pa_mrc_NetworkRegSetting_t  mode ///< [IN] The selected Network registration mode.
)
{
    atmgr_UnSubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),EventUnsolicitedId,"+CREG:");

    if ((mode==PA_MRC_ENABLE_REG_NOTIFICATION) || (mode==PA_MRC_ENABLE_REG_LOC_NOTIFICATION))
    {
        atmgr_SubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),
                                       EventUnsolicitedId,
                                       "+CREG:",
                                       false);
    }

    ThisMode=mode;
}
Example #12
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_mrc_GetRadioPower
(
     le_onoff_t*    powerPtr   ///< [OUT] The power state.
)
{
    int32_t result=LE_NOT_POSSIBLE;
    atcmdsync_ResultRef_t  resRef = NULL;
    const char* interRespPtr[] = {"+CFUN:",NULL};

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

    if ( result != LE_OK ) {
        le_mem_Release(resRef); // release atcmdsync_SendCommandDefaultExt
        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(resRef) == 2)
    {
        // it parse just the first line because of '\0'
        char* line = atcmdsync_GetLine(resRef,0);
        // it parse just the first line because of '\0'
        uint32_t numParam = atcmd_CountLineParameter(line);

        // Check is the +CREG intermediate response is in good format
        if (FIND_STRING("+CFUN:",atcmd_GetLineParameter(line,1)))
        {
            if (numParam==2)
            {
                if(atoi(atcmd_GetLineParameter(line,2)) != 0)
                {
                    *powerPtr = LE_ON;
                }
                else
                {
                    *powerPtr = LE_OFF;
                }
                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_SendCommand

    return result;
}
Example #13
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 #14
0
//--------------------------------------------------------------------------------------------------
static le_result_t StopPDPConnection
(
)
{
    return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                  "ATGH",
                                  NULL,
                                  NULL,
                                  30000);
}
Example #15
0
//--------------------------------------------------------------------------------------------------
static le_result_t pa_sim_GetRemainingAttempts
(
    uint32_t  idx,      ///< [IN] idx to read
    uint32_t* attemptsPtr  ///< [OUT] The number of attempts still possible
)
{
    le_result_t result=LE_NOT_POSSIBLE;
    atcmdsync_ResultRef_t  resRef = NULL;
    const char* interRespPtr[] = {"+CPINC:",NULL};

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

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

    if ( result != LE_OK ) {
        le_mem_Release(resRef); // release atcmdsync_SendCommandDefaultExt
        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(resRef) == 2)
    {
        // it parse just the first line because of '\0'
        char* line = atcmdsync_GetLine(resRef,0);
        uint32_t numParam = atcmd_CountLineParameter(line);
        // it parse just the first line because of '\0'
        if ((numParam==5) && (FIND_STRING("+CPINC:",atcmd_GetLineParameter(line,1))))
        {
            *attemptsPtr = atoi(atcmd_GetLineParameter(line,idx));

            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;
}
Example #16
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_common_Init
(
    void
)
{
    if (atports_GetInterface(ATPORT_COMMAND)==NULL) {
        LE_WARN("Common Module is not initialize in this session");
        return LE_FAULT;
    }

    return LE_OK;
}
Example #17
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_GetState
(
    le_sim_States_t* statePtr    ///< [OUT] SIM state
)
{
    int32_t result=LE_NOT_POSSIBLE;
    atcmd_Ref_t atReqRef;
    atcmdsync_ResultRef_t  resRef = NULL;

    const char* finalRespOkPtr[] = {"OK","+CPIN:",NULL};
    const char* finalRespKoPtr[] = {"ERROR","+CME ERROR:","+CMS ERROR:","TIMEOUT",NULL};

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

    *statePtr=LE_SIM_STATE_UNKNOWN;

    atReqRef = atcmd_Create();
    atcmd_AddCommand(atReqRef,"at+cpin?",false);
    atcmd_AddData(atReqRef,NULL,0);
    atcmd_SetTimer(atReqRef,30000,atcmdsync_GetTimerExpiryHandler());
    atcmd_AddIntermediateResp    (atReqRef,atcmdsync_GetIntermediateEventId(),NULL);
    atcmd_AddFinalResp(atReqRef,atcmdsync_GetFinalEventId(),finalRespOkPtr);
    atcmd_AddFinalResp(atReqRef,atcmdsync_GetFinalEventId(),finalRespKoPtr);

    resRef    = atcmdsync_SendCommand(atports_GetInterface(ATPORT_COMMAND),atReqRef);

    char* line = atcmdsync_GetFinalLine(resRef);

    // Check timeout
    if (FIND_STRING("TIMEOUT",line)) {
        LE_WARN("Modem failed");
        le_mem_Release(atReqRef); le_mem_Release(resRef);
        return LE_TIMEOUT;
    }

    if (CheckStatus(line,statePtr))
    {
        ReportStatus(NumCard,*statePtr);
        result = LE_OK;
    }

    le_mem_Release(atReqRef);  // Release atcmdsync_SetCommand
    le_mem_Release(resRef);     // Release atcmdsync_SendCommand

    return result;
}
Example #18
0
//--------------------------------------------------------------------------------------------------
static le_result_t StartPPPInterface
(
    void
)
{
    pid_t pid = fork();
    if ( pid == -1)
    {
        return LE_FAULT;
    } else if ( pid == 0) // child process
    {
        char* args[] = {
            "pppd",     /* argv[0], programme name. */
            "usepeerdns",
            "updetach",
            AT_PPP,
            NULL      /* list of argument must finished by NULL.  */
        };

        // warn: pppd 2.4.5 with this patch:
        // http://code.google.com/p/wl500g/source/browse/trunk/ppp/115-debian-always_setsid.patch
        // does not work.
        // the modem hangup when the process is forked.
        // So need to use a pppd version without this patch.
        execvp("pppd", args);
        return 99;

    } else {
        int statchild;
        wait(&statchild); // wait for child to finished
        if (WIFEXITED(statchild)) {
            LE_DEBUG("Child's exit code %d\n", WEXITSTATUS(statchild));
            if (WEXITSTATUS(statchild) == 0) {
                // Remove the NO CARRIER unsolicited
                atmgr_UnSubscribeUnsolReq (atports_GetInterface(ATPORT_COMMAND),InternalEventCall,"NO CARRIER");

                return LE_OK;
            } else
            {
                return LE_FAULT;
            }
        }
        else {
            LE_WARN("Child did not terminate with exit\n");
            return LE_FAULT;
        }

    }
}
Example #19
0
//--------------------------------------------------------------------------------------------------
static void MDCInternalHandler
(
    void* reportPtr
)
{
    atmgr_UnsolResponse_t* unsolPtr = reportPtr;

    LE_DEBUG("Handler received -%s-",unsolPtr->line);

    if ( FIND_STRING("NO CARRIER", unsolPtr->line) )
    {
        SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX);
        atmgr_UnSubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),InternalEventCall,"NO CARRIER");
    }
}
Example #20
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_mrc_ConfigureNetworkReg
(
    pa_mrc_NetworkRegSetting_t  setting ///< [IN] The selected Network registration setting.
)
{
    char atcommand[ATCOMMAND_SIZE] ;

    atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+creg=%d", setting);

    return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                  atcommand,
                                  NULL,
                                  NULL,
                                  30000);
}
Example #21
0
//--------------------------------------------------------------------------------------------------
static le_result_t AttachGPRS
(
    bool toAttach   ///< [IN] boolean value
)
{
    char atcommand[ATCOMMAND_SIZE] ;

    atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cgatt=%d",toAttach);

    return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                  atcommand,
                                  NULL,
                                  NULL,
                                  30000);
}
Example #22
0
//--------------------------------------------------------------------------------------------------
static le_result_t ActivateContext
(
    uint32_t profileIndex,    ///< [IN] The profile to read
    bool toActivate           ///< [IN] activation boolean
)
{
    char atcommand[ATCOMMAND_SIZE] ;

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

    return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                  atcommand,
                                  NULL,
                                  NULL,
                                  30000);
}
Example #23
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_mdc_WriteProfile
(
    uint32_t profileIndex,                    ///< [IN] The profile to write
    pa_mdc_ProfileData_t* profileDataPtr    ///< [IN] The profile data
)
{
    char atcommand[ATCOMMAND_SIZE] ;

    atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,
                         "at+cgdcont=%d,\"%s\",\"%s\"",profileIndex, "IP", profileDataPtr->apn);

    return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                  atcommand,
                                  NULL,
                                  NULL,
                                  30000);
}
Example #24
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_GetSelectedCard
(
    uint32_t*  cardNumPtr     ///< [OUT] The card number selected.
)
{
    le_result_t result=LE_OK;
    atcmdsync_ResultRef_t  resRef = NULL;
    const char* interRespPtr[] = {"+WHCNF: 4",NULL};

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

    if ( result != LE_OK ) {
        le_mem_Release(resRef); // release pa_at_SendSyncDefaultExt
        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(resRef) == 2)
    {
        char* line = atcmdsync_GetLine(resRef,0);
        if (FIND_STRING("+WHCNF: 4,1",line))
        {
            *cardNumPtr = 1;
        }
        else if (FIND_STRING("+WHCNF: 4,2",line))
        {
            *cardNumPtr = 2;
        }
        else
        {
            LE_WARN("this pattern is not expected");
            result =  LE_NOT_POSSIBLE;
        }
    }

    le_mem_Release(resRef);     // Release pa_at_SendSyncDefaultExt

    return result;
}
Example #25
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_common_SetWindIndicator
(
    uint32_t  wind
)
{
    atcmdsync_ResultRef_t  resRef = NULL;
    char atcommand[ATCOMMAND_SIZE];

    atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"AT+WIND=%d",wind);

    le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                                atcommand,
                                                &resRef,
                                                NULL,
                                                30000);

    le_mem_Release(resRef);
    return result;
}
Example #26
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_ChangePIN
(
    pa_sim_PinType_t   type,    ///< [IN] The code type
    const pa_sim_Pin_t oldcode, ///< [IN] Old code
    const pa_sim_Pin_t newcode  ///< [IN] New code
)
{
    atcmdsync_ResultRef_t  resRef = NULL;
    char atcommand[ATCOMMAND_SIZE] ;

    if (type==PA_SIM_PIN)
    {
        atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cpwd=\"SC\",%s,%s",oldcode,newcode);
    } else if (type==PA_SIM_PIN2)
    {
        atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cpwd=\"P2\",%s,%s",oldcode,newcode);
    } else
    {
        return LE_BAD_PARAMETER;
    }

    le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                                atcommand,
                                                &resRef,
                                                NULL,
                                                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);
    }

    le_mem_Release(resRef);     // Release atcmdsync_SendCommandDefault

    return LE_OK;
}
Example #27
0
//--------------------------------------------------------------------------------------------------
uint32_t pa_sim_CountSlots
(
    void
)
{
    atcmdsync_ResultRef_t  resRef = NULL;
    const char* interRespPtr[] = {"+WHCNF: 4",NULL};
    uint32_t numberOfSim=1;

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

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

    // If there is more than one line then it mean that the command is OK so the first line is
    if (atcmdsync_GetNumLines(resRef) == 2)
    {
        char* line = atcmdsync_GetLine(resRef,0);
        if (FIND_STRING("+WHCNF: 4,(0-3)",line))
        {
            numberOfSim = 2;
        }
        else
        {
            LE_WARN("this pattern is not expected");
            numberOfSim = 1;
        }
    } else {
        numberOfSim = 1;
    }

    le_mem_Release(resRef);     // Release pa_at_SendSyncDefaultExt

    return numberOfSim;
}
Example #28
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_Init
(
    void
)
{
    if (atports_GetInterface(ATPORT_COMMAND)==NULL) {
        LE_DEBUG("SIM Module is not initialize in this session");
        return LE_NOT_POSSIBLE;
    }

    SimEventPoolRef = le_mem_CreatePool("SimEventPool", sizeof(pa_sim_Event_t));
    SimEventPoolRef = le_mem_ExpandPool(SimEventPoolRef,DEFAULT_SIMEVENT_POOL_SIZE);

    EventUnsolicitedId    = le_event_CreateId("SIMEventIdUnsol",sizeof(atmgr_UnsolResponse_t));
    EventNewSimStateId    = le_event_CreateIdWithRefCounting("SIMEventIdNewState");
    le_event_AddHandler("SIMUnsolHandler",EventUnsolicitedId  ,SIMUnsolHandler);

    LE_DEBUG_IF(SetIndicator()!=LE_OK,"cannot set sim +WIND indicator");

    return LE_OK;
}
Example #29
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_mrc_Init
(
    void
)
{
    if (atports_GetInterface(ATPORT_COMMAND)==NULL) {
        LE_WARN("radio control Module is not initialize in this session");
        return LE_NOT_POSSIBLE;
    }

    EventUnsolicitedId    = le_event_CreateId("RCEventIdUnsol",sizeof(atmgr_UnsolResponse_t));
    EventNewRcStatusId    = le_event_CreateIdWithRefCounting("EventNewRcStatus");

    le_event_AddHandler("RCUnsolHandler",EventUnsolicitedId  ,CREGUnsolHandler);

    RegStatePoolRef = le_mem_CreatePool("regStatePool",sizeof(le_mrc_NetRegState_t));
    RegStatePoolRef = le_mem_ExpandPool(RegStatePoolRef,DEFAULT_REGSTATE_POOL_SIZE);

    SubscribeUnsolCREG(PA_MRC_ENABLE_REG_LOC_NOTIFICATION);

    pa_mrc_GetNetworkRegConfig(&ThisMode);

    return LE_OK;
}
Example #30
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;
}