//-------------------------------------------------------------------------------------------------- void simTest_SimSelect ( ) { // Select the embedded SIM LE_ASSERT_OK(le_sim_SelectCard(LE_SIM_EMBEDDED)); // Get the selected card le_sim_Id_t simId = le_sim_GetSelectedCard(); LE_ASSERT(LE_SIM_EMBEDDED == simId); // Select the LE_SIM_EXTERNAL_SLOT_1 SIM LE_ASSERT_OK(le_sim_SelectCard(LE_SIM_EXTERNAL_SLOT_1)); // Get the selected card simId = le_sim_GetSelectedCard(); LE_ASSERT(LE_SIM_EXTERNAL_SLOT_1 == simId); // Check if SIM present if (!le_sim_IsPresent(LE_SIM_EMBEDDED)) { LE_INFO("SIM not present"); } // Get the selected card by le_sim_GetSelectedCard() // Notice that the selected card received is the one used by the // last Legato API and not the one set by le_sim_SelectCard(). simId = le_sim_GetSelectedCard(); LE_ASSERT(LE_SIM_EMBEDDED == simId); // Check SIM ready if (!le_sim_IsReady(LE_SIM_EXTERNAL_SLOT_1)) { LE_INFO("SIM not ready"); } // Get the selected card by le_sim_GetSelectedCard() // Notice that the selected card received is the one used by the // last Legato API and not the one set by le_sim_SelectCard(). simId = le_sim_GetSelectedCard(); LE_ASSERT(LE_SIM_EXTERNAL_SLOT_1 == simId); }
//-------------------------------------------------------------------------------------------------- void simTest_SimSelect ( ) { // Select the embedded SIM le_result_t res = le_sim_SelectCard(LE_SIM_EMBEDDED); LE_ASSERT(res == LE_OK); // Get the selected card le_sim_Id_t simId = le_sim_GetSelectedCard(); LE_ASSERT(simId == LE_SIM_EMBEDDED); // Select the embedded SIM res = le_sim_SelectCard(LE_SIM_EXTERNAL_SLOT_1); LE_ASSERT(res == LE_OK); // Get the selected card simId = le_sim_GetSelectedCard(); LE_ASSERT(simId == LE_SIM_EXTERNAL_SLOT_1); }
//-------------------------------------------------------------------------------------------------- void TestSim_AddHandlers ( void ) { int i; // Create a semaphore to coordinate the test ThreadSemaphore = le_sem_Create("HandlerSem",0); // int app context memset(AppCtx, 0, NB_CLIENT*sizeof(AppContext_t)); // Start tasks: simulate multi-user of le_sim // each thread subcribes to state handler using le_sim_AddNewStateHandler for (i=0; i < NB_CLIENT; i++) { char string[20]={0}; snprintf(string,20,"app%dhandler", i); AppCtx[i].appId = i; AppCtx[i].appThreadRef = le_thread_Create(string, AppHandler, &AppCtx[i]); le_thread_Start(AppCtx[i].appThreadRef); } // Wait that the tasks have started before continuing the test SynchTest(); // Sim is absent in this test CurrentSimState = LE_SIM_ABSENT; pa_simSimu_SetSelectCard(CurrentSimId); le_sim_SelectCard(CurrentSimId); pa_simSimu_ReportSimState(CurrentSimState); // The tasks have subscribe to state event handler: // wait the handlers' calls SynchTest(); // Check state handler result CheckStateHandlerResult(); // Check that we are in the expected states (sim absent) CheckSimStates(); // Check that no more call of the semaphore LE_ASSERT(le_sem_GetValue(ThreadSemaphore) == 0); }