Esempio n. 1
0
//--------------------------------------------------------------------------------------------------
void TestSim_SimCardInformation
(
    void
)
{
    char iccid[PA_SIM_CARDID_MAX_LEN+1];
    char imsi[PA_SIM_IMSI_MAX_LEN+1];
    char phoneNumber[LE_MDMDEFS_PHONE_NUM_MAX_BYTES];

    // Start in ABSENT state
    CurrentSimState = LE_SIM_ABSENT;
    pa_simSimu_ReportSimState(CurrentSimState);

    // Wait the handlers' calls
    SynchTest();

    // Check state handler result
    CheckStateHandlerResult();

    // Try to get information: error are expected as there's no SIM
    LE_ASSERT( le_sim_GetICCID(CurrentSimId, iccid, PA_SIM_CARDID_MAX_LEN) == LE_FAULT );
    LE_ASSERT( le_sim_GetIMSI(CurrentSimId, imsi, PA_SIM_IMSI_MAX_LEN) == LE_FAULT );
    LE_ASSERT( le_sim_GetSubscriberPhoneNumber( CurrentSimId,
                                                phoneNumber,
                                                LE_MDMDEFS_PHONE_NUM_MAX_BYTES ) == LE_FAULT );

    // SIM is now ready
    CurrentSimState = LE_SIM_READY;
    pa_simSimu_ReportSimState(CurrentSimState);

    // Wait the handlers' calls
    SynchTest();

    // Check state handler result
    CheckStateHandlerResult();

    // Try to get informations, check values (OK expected)
    LE_ASSERT( le_sim_GetICCID(CurrentSimId, iccid, PA_SIM_CARDID_MAX_LEN+1) == LE_OK );
    LE_ASSERT( strncmp(iccid,Iccid,PA_SIM_CARDID_MAX_LEN) == 0 );
    LE_ASSERT( le_sim_GetIMSI(CurrentSimId, imsi, PA_SIM_IMSI_MAX_LEN+1) == LE_OK );
    LE_ASSERT( strncmp(imsi,Imsi,PA_SIM_IMSI_MAX_LEN) == 0 );
    LE_ASSERT( le_sim_GetSubscriberPhoneNumber( CurrentSimId,
                                                phoneNumber,
                                                LE_MDMDEFS_PHONE_NUM_MAX_BYTES ) == LE_OK );
    LE_ASSERT( strncmp(phoneNumber,PhoneNum,LE_MDMDEFS_PHONE_NUM_MAX_BYTES) == 0 );

    // Try to get infomartions with a too small buffer (error expected)
    LE_ASSERT( le_sim_GetICCID(CurrentSimId, iccid, PA_SIM_CARDID_MAX_LEN) == LE_OVERFLOW );
    LE_ASSERT( le_sim_GetIMSI(CurrentSimId, imsi, PA_SIM_IMSI_MAX_LEN) == LE_OVERFLOW );

    // Check that all handlers have been called as expected
    LE_ASSERT(le_sem_GetValue(ThreadSemaphore) == 0);
}
Esempio n. 2
0
//--------------------------------------------------------------------------------------------------
void simTest_Create
(
    le_sim_Id_t simId,
    const char* pinPtr
)
{
    bool            presence = false;
    char            iccid[LE_SIM_ICCID_BYTES] = {0};
    char            imsi[LE_SIM_IMSI_BYTES] = {0};
    char            eid[LE_SIM_EID_BYTES] = {0};

    // Enter PIN code
    LE_ASSERT_OK(le_sim_EnterPIN(simId, pinPtr));

    // Get ICCID
    LE_ASSERT_OK(le_sim_GetICCID(simId, iccid, sizeof(iccid)));
    Print( iccid );

    // Get EID
    LE_ASSERT_OK(le_sim_GetEID(simId, eid, sizeof(eid)));
    Print( eid );

    // Get IMSI
    LE_ASSERT_OK(le_sim_GetIMSI(simId, imsi, sizeof(imsi)));
    Print( imsi );

    // Check if SIM present
    presence = le_sim_IsPresent(simId);
    LE_ASSERT(presence);
}
Esempio n. 3
0
//--------------------------------------------------------------------------------------------------
void simTest_Create
(
    le_sim_Id_t simId,
    const char* pinPtr
)
{
    bool            presence = false;
    char            iccid[LE_SIM_ICCID_BYTES] = {0};
    char            imsi[LE_SIM_IMSI_BYTES] = {0};
    le_result_t     res;

    // Enter PIN code
    res = le_sim_EnterPIN(simId, pinPtr);
    LE_ASSERT(res==LE_OK);

    // Get ICCID
    res = le_sim_GetICCID(simId, iccid, sizeof(iccid));
    LE_ASSERT(res==LE_OK);
    Print( iccid );

    // Get IMSI
    res = le_sim_GetIMSI(simId, imsi, sizeof(imsi));
    LE_ASSERT(res==LE_OK);
    Print( imsi );

    // Check if SIM present
    presence = le_sim_IsPresent(simId);
    LE_ASSERT(presence);
}
Esempio n. 4
0
//--------------------------------------------------------------------------------------------------
void Testle_sim_Create()
{
    bool            presence=false;
    le_sim_ObjRef_t simRef;
    char            iccid[LE_SIM_ICCID_BYTES] = {0};
    char            imsi[LE_SIM_IMSI_BYTES] = {0};
    uint32_t        i=1;
    le_result_t     res;

    do
    {
        simRef = le_sim_Create(i);
        CU_ASSERT_PTR_NOT_NULL(simRef);

        res = le_sim_GetICCID(simRef, iccid, sizeof(iccid));
        CU_ASSERT_EQUAL(res, LE_OK);

        res = le_sim_GetIMSI(simRef, imsi, sizeof(imsi));
        CU_ASSERT_EQUAL(res, LE_OK);

        presence=le_sim_IsPresent(simRef);
        CU_ASSERT_TRUE(presence);

        le_sim_Delete(simRef);
        i++;
    } while (i<=le_sim_CountSlots());
}
Esempio n. 5
0
//--------------------------------------------------------------------------------------------------
void simTest_SimGetIccid
(
    le_sim_Id_t simId
)
{
    le_result_t     res;
    char            iccid[LE_SIM_ICCID_BYTES];
    char            string[100];

    memset(iccid, 0, LE_SIM_ICCID_BYTES);

    LE_INFO("SimId %d", simId);

    // Get SIM ICCID
    res = le_sim_GetICCID(simId, iccid, sizeof(iccid));

    LE_ASSERT(res == LE_OK);

    sprintf(string, "\nSIM Card ICCID: '%s'\n", iccid);
    Print(string);
}
Esempio n. 6
0
// -------------------------------------------------------------------------------------------------
static bool ProcessCommand
(
    const char* textPtr,      ///< [IN] Check this text to see if it's a valid command.
    const char* requesterPtr  ///< [IN] If not NULL, then any response text is SMSed to this target.
)
{
    char buffer[10240];

    // Start looking for a match...
    if (strcmp(textPtr, "Crash") == 0)
    {
        // As the name implies, we are going to be crashing the application.  So simply append to
        // the output log and crash the app.  This is done to allow demonstration of the supervisor
        // policies.
        int x = 10;
        int y = 0;

        LE_ERROR("Something wicked this way comes...");
        LE_ERROR("Data result: %d", x / y);
    }
    else if (strcmp(textPtr, "Status") == 0)
    {
        // The status command allows the caller to query the current state of the modem.  A friendly
        // version of this status is constructed and returned to the caller.
        le_onoff_t radioStatus;
        const char * radioStatusPtr;
        le_mrc_NetRegState_t netRegState;
        uint32_t signalQuality;

        if(le_mrc_GetRadioPower(&radioStatus) != LE_OK)
        {
            radioStatusPtr = "in an unknown state";
        }
        else
        {
            radioStatusPtr = (radioStatus == LE_OFF) ? "off" : "on";
        }

        if(le_mrc_GetNetRegState(&netRegState) != LE_OK)
        {
            netRegState = LE_MRC_REG_UNKNOWN;
        }

        if(le_mrc_GetSignalQual(&signalQuality) != LE_OK)
        {
            signalQuality = 0;
        }

        sprintf(buffer, "The radio is %s and is %s. The signal strength is %s.",
                radioStatusPtr,
                GetNetStateString(netRegState),
                GetSignalString(signalQuality));
    }
    else if (strcmp(textPtr, "Sim") == 0)
    {
        // Like the status command, this command queries the underling hardware for information.
        // This information is turned into a string that can then be returned to the caller.
        le_sim_Id_t simId;
        le_sim_States_t simState;

        char iccid[100];
        char imsi[100];
        int pos = 0;

        simId = le_sim_GetSelectedCard();
        simState = le_sim_GetState(simId);

        pos += snprintf(buffer + pos, sizeof(buffer) - pos,
                "SIM %u is %s.",
                simId,
                GetSimStateString(simState));

        if(le_sim_GetICCID(simId, iccid, sizeof(iccid)) == LE_OK)
        {
            pos += snprintf(buffer + pos, sizeof(buffer) - pos,
                    " ICCID=%s", iccid);
        }

        if(le_sim_GetIMSI(simId, imsi, sizeof(imsi)) == LE_OK)
        {
            pos += snprintf(buffer + pos, sizeof(buffer) - pos,
                    " IMSI=%s", imsi);
        }

    }
    else if (strcmp(textPtr, "Online") == 0)
    {
        le_utf8_Copy(buffer, "Requesting data connection.", sizeof(buffer), NULL);
        GoOnline();
    }
    else if (strcmp(textPtr, "Offline") == 0)
    {
        le_utf8_Copy(buffer, "Releasing data connection.", sizeof(buffer), NULL);
        GoOffline(buffer);
    }
    else if (strcmp(textPtr, "TestDataConnectionV4") == 0)
    {
        TestDataConnectionV4(buffer);
    }
    else if (strcmp(textPtr, "TestDataConnectionV6") == 0)
    {
        TestDataConnectionV6(buffer);
    }
    else if (strcmp(textPtr, "Netinfo") == 0)
    {
        Netinfo(buffer);
    }
    else if (strcmp(textPtr, "DataInfo") == 0)
    {
        Datainfo(buffer);
    }
    else if (strcmp(textPtr, "DataReset") == 0)
    {
        DataReset(buffer);
    }
    else if (strcmp(textPtr, "Scan") == 0)
    {
        PerformScan(buffer, sizeof(buffer), requesterPtr);
    }
    else
    {
        return false;
    }

    // Check to see if any processing has occurred.  If so, check to see if the request came from a
    // local or remote requester.
    // If the requester was local, (requesterPtr == NULL) then simply log our response to the SMS log.
    // Otherwise, attempt to SMS the response string to the original caller.
    if (requesterPtr != NULL)
    {
        SendMessage(requesterPtr, buffer);
    }
    else if (OutputFilePtr != NULL)
    {
        fprintf(OutputFilePtr, "## %s ##\n", buffer);
        fflush(OutputFilePtr);
    }

    // Let the calling function know if we did any processing or not.
    return true;
}