Sample code for SIM Identification

//--------------------------------------------------------------------------------------------------
/**
* Print function.
*
*/
//--------------------------------------------------------------------------------------------------
void Print
(
char* string
)
{
bool sandboxed = (getuid() != 0);
 
if(sandboxed)
{
LE_INFO("%s", string);
}
else
{
fprintf(stderr, "%s\n", string);
}
}
//--------------------------------------------------------------------------------------------------
/**
* Test: Creation & information retrieving.
*
*/
//--------------------------------------------------------------------------------------------------
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);
}