le_sim_interface.h File Reference

#include "legato.h"
#include "le_mdmDefs_interface.h"

Go to the source code of this file.

Macros

#define LE_SIM_PIN_MIN_LEN   4
 
#define LE_SIM_PIN_MAX_LEN   8
 
#define LE_SIM_PIN_MAX_BYTES   9
 
#define LE_SIM_PUK_MAX_LEN   8
 
#define LE_SIM_PUK_MAX_BYTES   9
 
#define LE_SIM_ICCID_LEN   20
 
#define LE_SIM_ICCID_BYTES   21
 
#define LE_SIM_IMSI_LEN   15
 
#define LE_SIM_IMSI_BYTES   16
 
#define LE_SIM_APDU_MAX_BYTES   255
 
#define LE_SIM_RESPONSE_MAX_BYTES   256
 
#define LE_SIM_FILE_ID_LEN   4
 
#define LE_SIM_FILE_ID_BYTES   5
 
#define LE_SIM_DATA_MAX_BYTES   100
 
#define LE_SIM_PATH_MAX_LEN   100
 
#define LE_SIM_PATH_MAX_BYTES   101
 
#define LE_SIM_EID_LEN   32
 
#define LE_SIM_EID_BYTES   33
 

Typedefs

typedef void(* le_sim_DisconnectHandler_t) (void *)
 
typedef struct le_sim_FPLMNList * le_sim_FPLMNListRef_t
 
typedef struct le_sim_NewStateHandler * le_sim_NewStateHandlerRef_t
 
typedef struct le_sim_ProfileUpdateHandler * le_sim_ProfileUpdateHandlerRef_t
 
typedef struct le_sim_SimToolkitEventHandler * le_sim_SimToolkitEventHandlerRef_t
 
typedef struct le_sim_IccidChangeHandler * le_sim_IccidChangeHandlerRef_t
 
typedef void(* le_sim_NewStateHandlerFunc_t) (le_sim_Id_t simId, le_sim_States_t simState, void *contextPtr)
 
typedef void(* le_sim_ProfileUpdateHandlerFunc_t) (le_sim_Id_t simId, le_sim_StkEvent_t stkEvent, void *contextPtr)
 
typedef void(* le_sim_SimToolkitEventHandlerFunc_t) (le_sim_Id_t simId, le_sim_StkEvent_t stkEvent, void *contextPtr)
 
typedef void(* le_sim_IccidChangeHandlerFunc_t) (le_sim_Id_t simId, const char *LE_NONNULL iccid, void *contextPtr)
 

Enumerations

enum  le_sim_States_t {
  LE_SIM_INSERTED = 0, LE_SIM_ABSENT = 1, LE_SIM_READY = 2, LE_SIM_BLOCKED = 3,
  LE_SIM_BUSY = 4, LE_SIM_POWER_DOWN = 5, LE_SIM_STATE_UNKNOWN = 6
}
 
enum  le_sim_Id_t {
  LE_SIM_EMBEDDED = 0, LE_SIM_EXTERNAL_SLOT_1 = 1, LE_SIM_EXTERNAL_SLOT_2 = 2, LE_SIM_REMOTE = 3,
  LE_SIM_ID_MAX = 4
}
 
enum  le_sim_Manufacturer_t {
  LE_SIM_OBERTHUR = 0, LE_SIM_GEMALTO = 1, LE_SIM_G_AND_D = 2, LE_SIM_MORPHO = 3,
  LE_SIM_VALID = 4, LE_SIM_MANUFACTURER_MAX = 5
}
 
enum  le_sim_Command_t {
  LE_SIM_READ_RECORD = 0, LE_SIM_READ_BINARY = 1, LE_SIM_UPDATE_RECORD = 2, LE_SIM_UPDATE_BINARY = 3,
  LE_SIM_COMMAND_MAX = 4
}
 
enum  le_sim_StkEvent_t { LE_SIM_OPEN_CHANNEL = 0, LE_SIM_REFRESH = 1, LE_SIM_STK_EVENT_MAX = 2 }
 
enum  le_sim_StkRefreshMode_t {
  LE_SIM_REFRESH_INIT_FULL_FCN = 0, LE_SIM_REFRESH_FCN = 1, LE_SIM_REFRESH_INIT_FCN = 2, LE_SIM_REFRESH_INIT = 3,
  LE_SIM_REFRESH_RESET = 4, LE_SIM_REFRESH_APP_RESET = 5, LE_SIM_REFRESH_SESSION_RESET = 6, LE_SIM_REFRESH_STEERING_OF_ROAMING = 7,
  LE_SIM_REFRESH_STEERING_OF_ROAMING_IWLAN = 8, LE_SIM_REFRESH_EUICC_PROFILE_CHANGE = 9, LE_SIM_REFRESH_MODE_MAX = 10
}
 
enum  le_sim_StkRefreshStage_t { LE_SIM_STAGE_WAITING_FOR_OK = 0, LE_SIM_STAGE_END_WITH_SUCCESS = 1, LE_SIM_STAGE_END_WITH_FAILURE = 2, LE_SIM_STAGE_MAX = 3 }
 

Functions

void le_sim_ConnectService (void)
 
le_result_t le_sim_TryConnectService (void)
 
void le_sim_SetServerDisconnectHandler (le_sim_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
void le_sim_DisconnectService (void)
 
le_sim_NewStateHandlerRef_t le_sim_AddNewStateHandler (le_sim_NewStateHandlerFunc_t handlerPtr, void *contextPtr)
 
void le_sim_RemoveNewStateHandler (le_sim_NewStateHandlerRef_t handlerRef)
 
le_sim_ProfileUpdateHandlerRef_t le_sim_AddProfileUpdateHandler (le_sim_ProfileUpdateHandlerFunc_t handlerPtr, void *contextPtr)
 
void le_sim_RemoveProfileUpdateHandler (le_sim_ProfileUpdateHandlerRef_t handlerRef)
 
le_sim_SimToolkitEventHandlerRef_t le_sim_AddSimToolkitEventHandler (le_sim_SimToolkitEventHandlerFunc_t handlerPtr, void *contextPtr)
 
void le_sim_RemoveSimToolkitEventHandler (le_sim_SimToolkitEventHandlerRef_t handlerRef)
 
le_sim_IccidChangeHandlerRef_t le_sim_AddIccidChangeHandler (le_sim_IccidChangeHandlerFunc_t handlerPtr, void *contextPtr)
 
void le_sim_RemoveIccidChangeHandler (le_sim_IccidChangeHandlerRef_t handlerRef)
 
le_sim_Id_t le_sim_GetSelectedCard (void)
 
le_result_t le_sim_SelectCard (le_sim_Id_t simId)
 
le_result_t le_sim_GetICCID (le_sim_Id_t simId, char *iccid, size_t iccidSize)
 
le_result_t le_sim_GetEID (le_sim_Id_t simId, char *eid, size_t eidSize)
 
le_result_t le_sim_GetIMSI (le_sim_Id_t simId, char *imsi, size_t imsiSize)
 
bool le_sim_IsPresent (le_sim_Id_t simId)
 
bool le_sim_IsReady (le_sim_Id_t simId)
 
le_result_t le_sim_EnterPIN (le_sim_Id_t simId, const char *LE_NONNULL pin)
 
le_result_t le_sim_ChangePIN (le_sim_Id_t simId, const char *LE_NONNULL oldpin, const char *LE_NONNULL newpin)
 
int32_t le_sim_GetRemainingPINTries (le_sim_Id_t simId)
 
le_result_t le_sim_GetRemainingPUKTries (le_sim_Id_t simId, uint32_t *remainingPukTriesPtrPtr)
 
le_result_t le_sim_Unlock (le_sim_Id_t simId, const char *LE_NONNULL pin)
 
le_result_t le_sim_Lock (le_sim_Id_t simId, const char *LE_NONNULL pin)
 
le_result_t le_sim_Unblock (le_sim_Id_t simId, const char *LE_NONNULL puk, const char *LE_NONNULL newpin)
 
le_sim_States_t le_sim_GetState (le_sim_Id_t simId)
 
le_result_t le_sim_GetSubscriberPhoneNumber (le_sim_Id_t simId, char *phoneNumberStr, size_t phoneNumberStrSize)
 
le_result_t le_sim_GetHomeNetworkOperator (le_sim_Id_t simId, char *nameStr, size_t nameStrSize)
 
le_result_t le_sim_GetHomeNetworkMccMnc (le_sim_Id_t simId, char *mccPtr, size_t mccPtrSize, char *mncPtr, size_t mncPtrSize)
 
le_result_t le_sim_LocalSwapToEmergencyCallSubscription (le_sim_Id_t simId, le_sim_Manufacturer_t manufacturer)
 
le_result_t le_sim_LocalSwapToCommercialSubscription (le_sim_Id_t simId, le_sim_Manufacturer_t manufacturer)
 
le_result_t le_sim_IsEmergencyCallSubscriptionSelected (le_sim_Id_t simId, bool *isEcsPtr)
 
le_result_t le_sim_AcceptSimToolkitCommand (le_sim_Id_t simId)
 
le_result_t le_sim_RejectSimToolkitCommand (le_sim_Id_t simId)
 
le_result_t le_sim_GetSimToolkitRefreshMode (le_sim_Id_t simId, le_sim_StkRefreshMode_t *refreshModePtr)
 
le_result_t le_sim_GetSimToolkitRefreshStage (le_sim_Id_t simId, le_sim_StkRefreshStage_t *refreshStagePtr)
 
le_result_t le_sim_SendApdu (le_sim_Id_t simId, const uint8_t *commandApduPtr, size_t commandApduSize, uint8_t *responseApduPtr, size_t *responseApduSizePtr)
 
le_result_t le_sim_SendCommand (le_sim_Id_t simId, le_sim_Command_t command, const char *LE_NONNULL fileIdentifier, uint8_t p1, uint8_t p2, uint8_t p3, const uint8_t *dataPtr, size_t dataSize, const char *LE_NONNULL path, uint8_t *sw1Ptr, uint8_t *sw2Ptr, uint8_t *responsePtr, size_t *responseSizePtr)
 
le_result_t le_sim_Reset (le_sim_Id_t simId)
 
le_sim_FPLMNListRef_t le_sim_CreateFPLMNList (void)
 
le_result_t le_sim_AddFPLMNOperator (le_sim_FPLMNListRef_t FPLMNListRef, const char *LE_NONNULL mcc, const char *LE_NONNULL mnc)
 
le_result_t le_sim_WriteFPLMNList (le_sim_Id_t simId, le_sim_FPLMNListRef_t FPLMNListRef)
 
le_sim_FPLMNListRef_t le_sim_ReadFPLMNList (le_sim_Id_t simId)
 
le_result_t le_sim_GetFirstFPLMNOperator (le_sim_FPLMNListRef_t FPLMNListRef, char *mccPtr, size_t mccPtrSize, char *mncPtr, size_t mncPtrSize)
 
le_result_t le_sim_GetNextFPLMNOperator (le_sim_FPLMNListRef_t FPLMNListRef, char *mccPtr, size_t mccPtrSize, char *mncPtr, size_t mncPtrSize)
 
void le_sim_DeleteFPLMNList (le_sim_FPLMNListRef_t FPLMNListRef)
 
le_result_t le_sim_OpenLogicalChannel (uint8_t *channelPtrPtr)
 
le_result_t le_sim_CloseLogicalChannel (uint8_t channel)
 
le_result_t le_sim_SendApduOnChannel (le_sim_Id_t simId, uint8_t channel, const uint8_t *commandApduPtr, size_t commandApduSize, uint8_t *responseApduPtr, size_t *responseApduSizePtr)
 
le_result_t le_sim_SetPower (le_sim_Id_t simId, le_onoff_t power)
 

Detailed Description

Legato SIM include file.

Macro Definition Documentation

◆ LE_SIM_APDU_MAX_BYTES

#define LE_SIM_APDU_MAX_BYTES   255

APDU length

◆ LE_SIM_DATA_MAX_BYTES

#define LE_SIM_DATA_MAX_BYTES   100

SIM data command length

◆ LE_SIM_EID_BYTES

#define LE_SIM_EID_BYTES   33

eUICC identifier (EID) length One extra byte is added for the null character.

◆ LE_SIM_EID_LEN

#define LE_SIM_EID_LEN   32

eUICC identifier (EID) length

◆ LE_SIM_FILE_ID_BYTES

#define LE_SIM_FILE_ID_BYTES   5

SIM file identifier length One extra byte is added for the null character.

◆ LE_SIM_FILE_ID_LEN

#define LE_SIM_FILE_ID_LEN   4

SIM file identifier length

◆ LE_SIM_ICCID_BYTES

#define LE_SIM_ICCID_BYTES   21

ICCID length One extra byte is added for the null character.

◆ LE_SIM_ICCID_LEN

#define LE_SIM_ICCID_LEN   20

ICCID length According to GSM Phase 1

◆ LE_SIM_IMSI_BYTES

#define LE_SIM_IMSI_BYTES   16

IMSI length One extra byte is added for the null character.

◆ LE_SIM_IMSI_LEN

#define LE_SIM_IMSI_LEN   15

IMSI length

◆ LE_SIM_PATH_MAX_BYTES

#define LE_SIM_PATH_MAX_BYTES   101

SIM file path length One extra byte is added for the null character.

◆ LE_SIM_PATH_MAX_LEN

#define LE_SIM_PATH_MAX_LEN   100

SIM file path length

◆ LE_SIM_PIN_MAX_BYTES

#define LE_SIM_PIN_MAX_BYTES   9

Maximum PIN length (8 digits) One extra byte is added for the null character.

◆ LE_SIM_PIN_MAX_LEN

#define LE_SIM_PIN_MAX_LEN   8

Maximum PIN length (8 digits)

◆ LE_SIM_PIN_MIN_LEN

#define LE_SIM_PIN_MIN_LEN   4

Minimum PIN length (4 digits)

◆ LE_SIM_PUK_MAX_BYTES

#define LE_SIM_PUK_MAX_BYTES   9

PUK length (8 digits) One extra byte is added for the null character.

◆ LE_SIM_PUK_MAX_LEN

#define LE_SIM_PUK_MAX_LEN   8

PUK length (8 digits)

◆ LE_SIM_RESPONSE_MAX_BYTES

#define LE_SIM_RESPONSE_MAX_BYTES   256

SIM response length

Typedef Documentation

◆ le_sim_DisconnectHandler_t

typedef void(* le_sim_DisconnectHandler_t) (void *)

Type for handler called when a server disconnects.

◆ le_sim_FPLMNListRef_t

typedef struct le_sim_FPLMNList* le_sim_FPLMNListRef_t

Reference type for FPLMN list.

◆ le_sim_IccidChangeHandlerFunc_t

typedef void(* le_sim_IccidChangeHandlerFunc_t) (le_sim_Id_t simId, const char *LE_NONNULL iccid, void *contextPtr)

Handler for ICCID change events.

◆ le_sim_IccidChangeHandlerRef_t

typedef struct le_sim_IccidChangeHandler* le_sim_IccidChangeHandlerRef_t

Reference type used by Add/Remove functions for EVENT 'le_sim_IccidChange'

◆ le_sim_NewStateHandlerFunc_t

typedef void(* le_sim_NewStateHandlerFunc_t) (le_sim_Id_t simId, le_sim_States_t simState, void *contextPtr)

Handler for sim state changes.

◆ le_sim_NewStateHandlerRef_t

typedef struct le_sim_NewStateHandler* le_sim_NewStateHandlerRef_t

Reference type used by Add/Remove functions for EVENT 'le_sim_NewState'

◆ le_sim_ProfileUpdateHandlerFunc_t

typedef void(* le_sim_ProfileUpdateHandlerFunc_t) (le_sim_Id_t simId, le_sim_StkEvent_t stkEvent, void *contextPtr)

Handler for profile update events.

◆ le_sim_ProfileUpdateHandlerRef_t

typedef struct le_sim_ProfileUpdateHandler* le_sim_ProfileUpdateHandlerRef_t

Reference type used by Add/Remove functions for EVENT 'le_sim_ProfileUpdate'

◆ le_sim_SimToolkitEventHandlerFunc_t

typedef void(* le_sim_SimToolkitEventHandlerFunc_t) (le_sim_Id_t simId, le_sim_StkEvent_t stkEvent, void *contextPtr)

Handler for Sim Toolkit Events.

◆ le_sim_SimToolkitEventHandlerRef_t

typedef struct le_sim_SimToolkitEventHandler* le_sim_SimToolkitEventHandlerRef_t

Reference type used by Add/Remove functions for EVENT 'le_sim_SimToolkitEvent'

Enumeration Type Documentation

◆ le_sim_Command_t

SIM commands.

Enumerator
LE_SIM_READ_RECORD 

Read a file record.

LE_SIM_READ_BINARY 

Read a transparent elementary file.

LE_SIM_UPDATE_RECORD 

Update a file record.

LE_SIM_UPDATE_BINARY 

Update a transparent elementary file.

LE_SIM_COMMAND_MAX 

Max value.

◆ le_sim_Id_t

SIM identifiers.

Enumerator
LE_SIM_EMBEDDED 

Embedded SIM.

LE_SIM_EXTERNAL_SLOT_1 

SIM inserted in external slot 1.

LE_SIM_EXTERNAL_SLOT_2 

SIM inserted in external slot 2.

LE_SIM_REMOTE 

Remote SIM.

◆ le_sim_Manufacturer_t

Card Manufacturer.

Enumerator
LE_SIM_OBERTHUR 

Oberthur.

LE_SIM_GEMALTO 

Gemalto.

LE_SIM_G_AND_D 

G&D.

LE_SIM_MORPHO 

Morpho.

LE_SIM_VALID 

Valid.

◆ le_sim_States_t

SIM states.

Enumerator
LE_SIM_INSERTED 

SIM card is inserted and locked.

LE_SIM_ABSENT 

SIM card is absent.

LE_SIM_READY 

SIM card is inserted and unlocked.

LE_SIM_BLOCKED 

SIM card is blocked.

LE_SIM_BUSY 

SIM card is busy.

LE_SIM_POWER_DOWN 

SIM card is powered down.

LE_SIM_STATE_UNKNOWN 

Unknown SIM state.

◆ le_sim_StkEvent_t

SIM Toolkit events.

Enumerator
LE_SIM_OPEN_CHANNEL 

SIM card asks to open a logical channel.

LE_SIM_REFRESH 

SIM card asks for a refresh.

LE_SIM_STK_EVENT_MAX 

Unknown SIM Toolkit event.

◆ le_sim_StkRefreshMode_t

SIM Toolkit Refresh modes, defined in ETSI TS 102 223 sections 6.4.7 and 8.6.

Enumerator
LE_SIM_REFRESH_INIT_FULL_FCN 

Initialization and Full File Change Notification.

LE_SIM_REFRESH_FCN 

File Change Notification.

LE_SIM_REFRESH_INIT_FCN 

Initialization and File Change Notification.

LE_SIM_REFRESH_INIT 

Initialization.

LE_SIM_REFRESH_RESET 

SIM reset.

LE_SIM_REFRESH_APP_RESET 

Application reset.

LE_SIM_REFRESH_SESSION_RESET 

Session reset.

LE_SIM_REFRESH_STEERING_OF_ROAMING 

Steering of Roaming as defined in 3GPP TS 23.122.

LE_SIM_REFRESH_STEERING_OF_ROAMING_IWLAN 

Steering of Roaming for I-WLAN as defined in 3GPP TS 24.234.

LE_SIM_REFRESH_EUICC_PROFILE_CHANGE 

eUICC Profile State Change.

LE_SIM_REFRESH_MODE_MAX 

Invalid SIM Toolkit Refresh mode.

◆ le_sim_StkRefreshStage_t

SIM Toolkit Refresh stages.

Enumerator
LE_SIM_STAGE_WAITING_FOR_OK 

Waiting for OK to refresh.

LE_SIM_STAGE_END_WITH_SUCCESS 

Refresh succeeded.

LE_SIM_STAGE_END_WITH_FAILURE 

Refresh failed.

LE_SIM_STAGE_MAX 

Invalid SIM Toolkit Refresh stage.

Function Documentation

◆ le_sim_AcceptSimToolkitCommand()

le_result_t le_sim_AcceptSimToolkitCommand ( le_sim_Id_t  simId)

Accept the last SIM Toolkit command.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed.
Parameters
[in]simIdThe SIM identifier.

◆ le_sim_AddFPLMNOperator()

le_result_t le_sim_AddFPLMNOperator ( le_sim_FPLMNListRef_t  FPLMNListRef,
const char *LE_NONNULL  mcc,
const char *LE_NONNULL  mnc 
)

Add FPLMN network into the newly created FPLMN list. If the FPLMNListRef, mcc or mnc is not valid then this function will kill the calling client.

Returns
  • LE_FAULT Function failed.
  • LE_OK Function succeeded.
  • LE_OVERFLOW If FPLMN operator can not be inserted into FPLMN list.
Parameters
[in]FPLMNListRefFPLMN list reference.
[in]mccMobile Country Code.
[in]mncMobile Network Code.

◆ le_sim_AddIccidChangeHandler()

le_sim_IccidChangeHandlerRef_t le_sim_AddIccidChangeHandler ( le_sim_IccidChangeHandlerFunc_t  handlerPtr,
void *  contextPtr 
)

Add handler function for EVENT 'le_sim_IccidChange'

This event provides information on ICCID

Parameters
[in]handlerPtr
[in]contextPtr

◆ le_sim_AddNewStateHandler()

le_sim_NewStateHandlerRef_t le_sim_AddNewStateHandler ( le_sim_NewStateHandlerFunc_t  handlerPtr,
void *  contextPtr 
)

Add handler function for EVENT 'le_sim_NewState'

This event provides information on sim state changes.

Parameters
[in]handlerPtr
[in]contextPtr

◆ le_sim_AddProfileUpdateHandler()

le_sim_ProfileUpdateHandlerRef_t le_sim_AddProfileUpdateHandler ( le_sim_ProfileUpdateHandlerFunc_t  handlerPtr,
void *  contextPtr 
)

Add handler function for EVENT 'le_sim_ProfileUpdate'

This event provides information on profile update

Parameters
[in]handlerPtr
[in]contextPtr

◆ le_sim_AddSimToolkitEventHandler()

le_sim_SimToolkitEventHandlerRef_t le_sim_AddSimToolkitEventHandler ( le_sim_SimToolkitEventHandlerFunc_t  handlerPtr,
void *  contextPtr 
)

Add handler function for EVENT 'le_sim_SimToolkitEvent'

This event provides information on Sim Toolkit application.

Parameters
[in]handlerPtr
[in]contextPtr

◆ le_sim_ChangePIN()

le_result_t le_sim_ChangePIN ( le_sim_Id_t  simId,
const char *LE_NONNULL  oldpin,
const char *LE_NONNULL  newpin 
)

Change the PIN code.

Returns
LE_NOT_FOUND Function failed to select the SIM card for this operation.
LE_UNDERFLOW PIN code is/are not long enough (min 4 digits).
LE_FAULT Function failed to change the PIN code.
LE_OK Function succeeded.
Note
If PIN code is too long (max 8 digits), it is a fatal error, the function will not return.
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.
[in]oldpinThe old PIN code.
[in]newpinThe new PIN code.

◆ le_sim_CloseLogicalChannel()

le_result_t le_sim_CloseLogicalChannel ( uint8_t  channel)

Close a logical channel on the SIM card.

Returns
  • LE_OK Function succeeded.
  • LE_FAULT Function failed.
Parameters
[in]channelThe number of the logical channel to close.

◆ le_sim_ConnectService()

void le_sim_ConnectService ( void  )

Connect the current client thread to the service providing this API. Block until the service is available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.

This function is created automatically.

◆ le_sim_CreateFPLMNList()

le_sim_FPLMNListRef_t le_sim_CreateFPLMNList ( void  )

Create empty FPLMN list to insert FPLMN operators.

Returns
  • Reference to the List object.
  • Null pointer if not able to create list reference.

◆ le_sim_DeleteFPLMNList()

void le_sim_DeleteFPLMNList ( le_sim_FPLMNListRef_t  FPLMNListRef)

Delete the FPLMN list created by le_sim_ReadFPLMNList() or le_sim_CreateFPLMNList(). If the FPLMNListRef is not valid then this function will kill the calling client.

Note
On failure, the process exits, so you don't have to worry about checking the returned reference for validity.
Parameters
[in]FPLMNListRefFPLMN list reference.

◆ le_sim_DisconnectService()

void le_sim_DisconnectService ( void  )

Disconnect the current client thread from the service providing this API.

Normally, this function doesn't need to be called. After this function is called, there's no longer a connection to the service, and the functions in this API can't be used. For details, see Client-specific Functions.

This function is created automatically.

◆ le_sim_EnterPIN()

le_result_t le_sim_EnterPIN ( le_sim_Id_t  simId,
const char *LE_NONNULL  pin 
)

This function must be called to enter the PIN code.

Returns
LE_BAD_PARAMETER The parameters are invalid.
LE_NOT_FOUND The function failed to select the SIM card for this operation.
LE_UNDERFLOW The PIN code is not long enough (min 4 digits).
LE_FAULT The function failed to enter the PIN code.
LE_OK The function succeeded.
Note
If PIN code is too long (max 8 digits), it is a fatal error, the function will not return.
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.
[in]pinThe PIN code.

◆ le_sim_GetEID()

le_result_t le_sim_GetEID ( le_sim_Id_t  simId,
char *  eid,
size_t  eidSize 
)

Retrieves the identifier for the embedded Universal Integrated Circuit Card identifier (EID) (32 digits)

Returns
LE_OK EID was successfully retrieved.
LE_OVERFLOW eidPtr buffer was too small for the EID.
LE_BAD_PARAMETER Invalid parameters.
LE_FAULT The EID could not be retrieved.
Note
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Warning
le_sim_GetEID() function is platform dependent. Please refer to the EID section for full details.
Parameters
[in]simIdThe SIM identifier.
[out]eidEID
[in]eidSize

◆ le_sim_GetFirstFPLMNOperator()

le_result_t le_sim_GetFirstFPLMNOperator ( le_sim_FPLMNListRef_t  FPLMNListRef,
char *  mccPtr,
size_t  mccPtrSize,
char *  mncPtr,
size_t  mncPtrSize 
)

Read the first FPLMN network from the list of FPLMN objects retrieved with le_sim_ReadFPLMNList(). If the FPLMNListRef, mccPtr or mncPtr is not valid then this function will kill the calling client.

Returns
  • LE_FAULT Function failed.
  • LE_OK Function succeeded.
  • LE_OVERFLOW MCC/MNC string size is greater than string length parameter which has been given into this function.
Parameters
[in]FPLMNListRefFPLMN list reference.
[out]mccPtrMobile Country Code.
[in]mccPtrSize
[out]mncPtrMobile Network Code.
[in]mncPtrSize

◆ le_sim_GetHomeNetworkMccMnc()

le_result_t le_sim_GetHomeNetworkMccMnc ( le_sim_Id_t  simId,
char *  mccPtr,
size_t  mccPtrSize,
char *  mncPtr,
size_t  mncPtrSize 
)

This function must be called to get the Home Network MCC MNC.

Returns
  • LE_OK on success
  • LE_NOT_FOUND if Home Network has not been provisioned
  • LE_FAULT for unexpected error
Note
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.
[out]mccPtrMobile Country Code
[in]mccPtrSize
[out]mncPtrMobile Network Code
[in]mncPtrSize

◆ le_sim_GetHomeNetworkOperator()

le_result_t le_sim_GetHomeNetworkOperator ( le_sim_Id_t  simId,
char *  nameStr,
size_t  nameStrSize 
)

This function must be called to get the Home Network Name information.

Returns
  • LE_OK on success
  • LE_OVERFLOW if the Home Network Name can't fit in nameStr
  • LE_BAD_PARAMETER if a parameter is invalid
  • LE_FAULT on any other failure
Note
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
The home network name can be given even if the device is not registered on the network.
Parameters
[in]simIdThe SIM identifier.
[out]nameStrthe home network Name
[in]nameStrSize

◆ le_sim_GetICCID()

le_result_t le_sim_GetICCID ( le_sim_Id_t  simId,
char *  iccid,
size_t  iccidSize 
)

Retrieves the integrated circuit card identifier (ICCID) of the SIM card (20 digits)

Returns
LE_OK ICCID was successfully retrieved.
LE_OVERFLOW iccidPtr buffer was too small for the ICCID.
LE_BAD_PARAMETER Invalid parameters.
LE_FAULT The ICCID could not be retrieved.
Note
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.
[out]iccidICCID
[in]iccidSize

◆ le_sim_GetIMSI()

le_result_t le_sim_GetIMSI ( le_sim_Id_t  simId,
char *  imsi,
size_t  imsiSize 
)

Retrieves the identification number (IMSI) of the SIM card. (max 15 digits)

Returns
LE_OVERFLOW The imsiPtr buffer was too small for the IMSI.
LE_BAD_PARAMETER The parameters are invalid.
LE_FAULT The function failed.
LE_TIMEOUT No response was received.
LE_OK The function succeeded.
Note
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.
[out]imsiIMSI
[in]imsiSize

◆ le_sim_GetNextFPLMNOperator()

le_result_t le_sim_GetNextFPLMNOperator ( le_sim_FPLMNListRef_t  FPLMNListRef,
char *  mccPtr,
size_t  mccPtrSize,
char *  mncPtr,
size_t  mncPtrSize 
)

Read the next FPLMN network from the list of FPLMN objects retrieved with le_sim_ReadFPLMNList(). If the FPLMNListRef, mccPtr or mncPtr is not valid then this function will kill the calling client.

Returns
  • LE_FAULT Function failed.
  • LE_OK Function succeeded.
  • LE_OVERFLOW MCC/MNC string size is greater than string length parameter which has been given into this function.
Parameters
[in]FPLMNListRefFPLMN list reference.
[out]mccPtrMobile Country Code.
[in]mccPtrSize
[out]mncPtrMobile Network Code.
[in]mncPtrSize

◆ le_sim_GetRemainingPINTries()

int32_t le_sim_GetRemainingPINTries ( le_sim_Id_t  simId)

Get the number of remaining PIN insertion tries.

Returns
LE_NOT_FOUND The function failed to select the SIM card for this operation.
LE_BAD_PARAMETER Invalid SIM identifier.
LE_FAULT The function failed to get the number of remaining PIN insertion tries.
A positive value The function succeeded. The number of remaining PIN insertion tries.
Parameters
[in]simIdThe SIM identifier.

◆ le_sim_GetRemainingPUKTries()

le_result_t le_sim_GetRemainingPUKTries ( le_sim_Id_t  simId,
uint32_t *  remainingPukTriesPtrPtr 
)

Get the number of remaining PUK insertion tries.

Returns
LE_OK On success.
LE_NOT_FOUND The function failed to select the SIM card for this operation.
LE_BAD_PARAMETER Invalid SIM identifier.
LE_FAULT The function failed to get the number of remaining PUK insertion tries.
Note
If the caller is passing an null pointer to this function, it is a fatal error and the function will not return.
Parameters
[in]simIdThe SIM identifier.
[out]remainingPukTriesPtrPtrThe number of remaining PUK insertion tries.

◆ le_sim_GetSelectedCard()

le_sim_Id_t le_sim_GetSelectedCard ( void  )

Get the current selected card.

Returns
Number of the current selected SIM card.

◆ le_sim_GetSimToolkitRefreshMode()

le_result_t le_sim_GetSimToolkitRefreshMode ( le_sim_Id_t  simId,
le_sim_StkRefreshMode_t refreshModePtr 
)

Retrieve the mode of the last SIM Toolkit Refresh command. The modes are defined in ETSI TS 102 223 sections 6.4.7 and 8.6.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_UNAVAILABLE The last SIM Toolkit command is not a Refresh command.
  • LE_FAULT The function failed.
  • LE_UNSUPPORTED The platform does not support this operation.
Parameters
[in]simIdThe SIM identifier.
[out]refreshModePtrThe Refresh mode.

◆ le_sim_GetSimToolkitRefreshStage()

le_result_t le_sim_GetSimToolkitRefreshStage ( le_sim_Id_t  simId,
le_sim_StkRefreshStage_t refreshStagePtr 
)

Retrieve the stage of the last SIM Toolkit Refresh command.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_UNAVAILABLE The last SIM Toolkit command is not a Refresh command.
  • LE_FAULT The function failed.
Parameters
[in]simIdThe SIM identifier.
[out]refreshStagePtrThe Refresh stage.

◆ le_sim_GetState()

le_sim_States_t le_sim_GetState ( le_sim_Id_t  simId)

Get the SIM state.

Returns
Current SIM state.
Note
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.

◆ le_sim_GetSubscriberPhoneNumber()

le_result_t le_sim_GetSubscriberPhoneNumber ( le_sim_Id_t  simId,
char *  phoneNumberStr,
size_t  phoneNumberStrSize 
)

Get the SIM Phone Number.

Returns
  • LE_OK on success
  • LE_OVERFLOW if the Phone Number can't fit in phoneNumberStr
  • LE_BAD_PARAMETER if a parameter is invalid
  • LE_FAULT on any other failure
Note
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.
[out]phoneNumberStrThe phone Number.
[in]phoneNumberStrSize

◆ le_sim_IsEmergencyCallSubscriptionSelected()

le_result_t le_sim_IsEmergencyCallSubscriptionSelected ( le_sim_Id_t  simId,
bool *  isEcsPtr 
)

This function must be called to get the current subscription.

Returns
  • LE_OK on success
  • LE_BAD_PARAMETER invalid SIM identifier or null ECS pointer is passed
  • LE_NOT_FOUND cannot determine the current selected subscription
  • LE_FAULT for unexpected errors
Warning
There is no standard method to interrogate the current selected subscription. The returned value of this function is based on the last executed local swap command. This means that this function will always return LE_NOT_FOUND error at Legato startup.
Parameters
[in]simIdThe SIM identifier
[out]isEcsPtrtrue if Emergency Call Subscription (ECS) is selected, false if Commercial Subscription is selected

◆ le_sim_IsPresent()

bool le_sim_IsPresent ( le_sim_Id_t  simId)

Verify if the SIM card is present or not.

Returns
true SIM card is present.
false SIM card is absent
Note
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.

◆ le_sim_IsReady()

bool le_sim_IsReady ( le_sim_Id_t  simId)

Verify if the SIM is ready (PIN code correctly inserted or not required).

Returns
true PIN is correctly inserted or not required.
false PIN must be inserted
Note
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.

◆ le_sim_LocalSwapToCommercialSubscription()

le_result_t le_sim_LocalSwapToCommercialSubscription ( le_sim_Id_t  simId,
le_sim_Manufacturer_t  manufacturer 
)

This function must be called to request the multi-profile eUICC to swap back to commercial subscription and to refresh. The User's application must wait for eUICC reboot to be finished and network connection available.

Returns
  • LE_OK on success
  • LE_BAD_PARAMETER invalid SIM identifier
  • LE_BUSY when a profile swap is already in progress
  • LE_FAULT for unexpected error
  • LE_DUPLICATE for duplicate operation
Note
Please ensure that the eUICC is selected using le_sim_SelectCard() and in a ready state before attempting a profile swap.
Warning
If you use a Morpho or Oberthur card, the SIM_REFRESH PRO-ACTIVE command must be accepted with le_sim_AcceptSimToolkitCommand() in order to complete the profile swap procedure.
Parameters
[in]simIdThe SIM identifier.
[in]manufacturerThe card manufacturer.

◆ le_sim_LocalSwapToEmergencyCallSubscription()

le_result_t le_sim_LocalSwapToEmergencyCallSubscription ( le_sim_Id_t  simId,
le_sim_Manufacturer_t  manufacturer 
)

This function must be called to request the multi-profile eUICC to swap to ECS and to refresh. The User's application must wait for eUICC reboot to be finished and network connection available.

Returns
  • LE_OK on success
  • LE_BAD_PARAMETER invalid SIM identifier
  • LE_BUSY when a profile swap is already in progress
  • LE_FAULT for unexpected error
  • LE_DUPLICATE for duplicate operation
Note
Please ensure that the eUICC is selected using le_sim_SelectCard() and in a ready state before attempting a profile swap.
Warning
If you use a Morpho or Oberthur card, the SIM_REFRESH PRO-ACTIVE command must be accepted with le_sim_AcceptSimToolkitCommand() in order to complete the profile swap procedure.
Parameters
[in]simIdThe SIM identifier.
[in]manufacturerThe card manufacturer.

◆ le_sim_Lock()

le_result_t le_sim_Lock ( le_sim_Id_t  simId,
const char *LE_NONNULL  pin 
)

Lock the SIM card: it enables the request of the PIN code.

Returns
LE_NOT_FOUND Function failed to select the SIM card for this operation.
LE_UNDERFLOW PIN code is not long enough (min 4 digits).
LE_FAULT The function failed to unlock the SIM card.
LE_OK Function succeeded.
Note
If PIN code is too long (max 8 digits), it is a fatal error, the function will not return.
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.
[in]pinThe PIN code.

◆ le_sim_OpenLogicalChannel()

le_result_t le_sim_OpenLogicalChannel ( uint8_t *  channelPtrPtr)

Open a logical channel on the SIM card.

Returns
  • LE_OK Function succeeded.
  • LE_BAD_PARAMETER Invalid parameter.
  • LE_FAULT Function failed.
Parameters
[out]channelPtrPtrThe number of the opened logical channel.

◆ le_sim_ReadFPLMNList()

le_sim_FPLMNListRef_t le_sim_ReadFPLMNList ( le_sim_Id_t  simId)

Read FPLMN list from the SIM.

Returns
  • Reference to the List object.
  • Null pointer if FPLMN list is not able to read from the SIM.
Parameters
[in]simIdThe SIM identifier.

◆ le_sim_RejectSimToolkitCommand()

le_result_t le_sim_RejectSimToolkitCommand ( le_sim_Id_t  simId)

Reject the last SIM Toolkit command.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed.
Parameters
[in]simIdThe SIM identifier.

◆ le_sim_RemoveIccidChangeHandler()

void le_sim_RemoveIccidChangeHandler ( le_sim_IccidChangeHandlerRef_t  handlerRef)

Remove handler function for EVENT 'le_sim_IccidChange'

Parameters
[in]handlerRef

◆ le_sim_RemoveNewStateHandler()

void le_sim_RemoveNewStateHandler ( le_sim_NewStateHandlerRef_t  handlerRef)

Remove handler function for EVENT 'le_sim_NewState'

Parameters
[in]handlerRef

◆ le_sim_RemoveProfileUpdateHandler()

void le_sim_RemoveProfileUpdateHandler ( le_sim_ProfileUpdateHandlerRef_t  handlerRef)

Remove handler function for EVENT 'le_sim_ProfileUpdate'

Parameters
[in]handlerRef

◆ le_sim_RemoveSimToolkitEventHandler()

void le_sim_RemoveSimToolkitEventHandler ( le_sim_SimToolkitEventHandlerRef_t  handlerRef)

Remove handler function for EVENT 'le_sim_SimToolkitEvent'

Parameters
[in]handlerRef

◆ le_sim_Reset()

le_result_t le_sim_Reset ( le_sim_Id_t  simId)

Reset the SIM.

Returns
  • LE_FAULT Function failed.
  • LE_OK Function succeeded.
Parameters
[in]simIdThe SIM identifier.

◆ le_sim_SelectCard()

le_result_t le_sim_SelectCard ( le_sim_Id_t  simId)

Select a SIM.

Returns
LE_FAULT Function failed to select the requested SIM
LE_OK Function succeeded.
Parameters
[in]simIdThe SIM identifier.

◆ le_sim_SendApdu()

le_result_t le_sim_SendApdu ( le_sim_Id_t  simId,
const uint8_t *  commandApduPtr,
size_t  commandApduSize,
uint8_t *  responseApduPtr,
size_t *  responseApduSizePtr 
)

Send APDU command to the SIM.

Returns
  • LE_OK Function succeeded.
  • LE_FAULT The function failed.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_NOT_FOUND The function failed to select the SIM card for this operation.
Parameters
[in]simIdThe SIM identifier.
[in]commandApduPtrAPDU command.
[in]commandApduSize
[out]responseApduPtrSIM response.
[in,out]responseApduSizePtr

◆ le_sim_SendApduOnChannel()

le_result_t le_sim_SendApduOnChannel ( le_sim_Id_t  simId,
uint8_t  channel,
const uint8_t *  commandApduPtr,
size_t  commandApduSize,
uint8_t *  responseApduPtr,
size_t *  responseApduSizePtr 
)

Send APDU command on a dedicated logical channel.

Returns
  • LE_OK Function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_NOT_FOUND The function failed to select the SIM card for this operation.
  • LE_FAULT The function failed.
Parameters
[in]simIdThe SIM identifier.
[in]channelThe logical channel number.
[in]commandApduPtrAPDU command.
[in]commandApduSize
[out]responseApduPtrSIM response.
[in,out]responseApduSizePtr

◆ le_sim_SendCommand()

le_result_t le_sim_SendCommand ( le_sim_Id_t  simId,
le_sim_Command_t  command,
const char *LE_NONNULL  fileIdentifier,
uint8_t  p1,
uint8_t  p2,
uint8_t  p3,
const uint8_t *  dataPtr,
size_t  dataSize,
const char *LE_NONNULL  path,
uint8_t *  sw1Ptr,
uint8_t *  sw2Ptr,
uint8_t *  responsePtr,
size_t *  responseSizePtr 
)

Send a command to the SIM.

Returns
  • LE_OK Function succeeded.
  • LE_FAULT The function failed.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_NOT_FOUND - The function failed to select the SIM card for this operation
    • The requested SIM file is not found
  • LE_OVERFLOW Response buffer is too small to copy the SIM answer.
  • LE_UNSUPPORTED The platform does not support this operation.
Parameters
[in]simIdThe SIM identifier.
[in]commandThe SIM command.
[in]fileIdentifierFile identifier
[in]p1Parameter P1 passed to the SIM
[in]p2Parameter P2 passed to the SIM
[in]p3Parameter P3 passed to the SIM
[in]dataPtrdata command.
[in]dataSize
[in]pathpath of the elementary file
[out]sw1PtrStatus Word 1 received from the SIM
[out]sw2PtrStatus Word 2 received from the SIM
[out]responsePtrSIM response.
[in,out]responseSizePtr

◆ le_sim_SetPower()

le_result_t le_sim_SetPower ( le_sim_Id_t  simId,
le_onoff_t  power 
)

Power up or down the current SIM.

Returns
LE_OK Function succeeded.
LE_FAULT Function failed.
Note
For SIM power cycle operation, it must wait until SIM state is LE_SIM_POWER_DOWN before powering on the SIM, otherwise power up SIM will fail.
Parameters
[in]simIdThe SIM identifier.
[in]powerThe power state.

◆ le_sim_SetServerDisconnectHandler()

void le_sim_SetServerDisconnectHandler ( le_sim_DisconnectHandler_t  disconnectHandler,
void *  contextPtr 
)

Set handler called when server disconnection is detected.

When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants to continue without exiting, it should call longjmp() from inside the handler.

◆ le_sim_TryConnectService()

le_result_t le_sim_TryConnectService ( void  )

Try to connect the current client thread to the service providing this API. Return with an error if the service is not available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.

This function is created automatically.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.

◆ le_sim_Unblock()

le_result_t le_sim_Unblock ( le_sim_Id_t  simId,
const char *LE_NONNULL  puk,
const char *LE_NONNULL  newpin 
)

Unblock the SIM card.

Returns
LE_NOT_FOUND Function failed to select the SIM card for this operation.
LE_UNDERFLOW PIN code is not long enough (min 4 digits).
LE_BAD_PARAMETER Invalid SIM identifier.
LE_OUT_OF_RANGE PUK code length is not correct (8 digits).
LE_FAULT The function failed to unlock the SIM card.
LE_OK Function succeeded.
Note
If new PIN or puk code are too long (max 8 digits), it is a fatal error, the function will not return.
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.
[in]pukThe PUK code.
[in]newpinThe PIN code.

◆ le_sim_Unlock()

le_result_t le_sim_Unlock ( le_sim_Id_t  simId,
const char *LE_NONNULL  pin 
)

Unlock the SIM card: it disables the request of the PIN code.

Returns
LE_NOT_FOUND Function failed to select the SIM card for this operation.
LE_UNDERFLOW PIN code is not long enough (min 4 digits).
LE_FAULT The function failed to unlock the SIM card.
LE_OK Function succeeded.
Note
If PIN code is too long (max 8 digits), it is a fatal error, the function will not return.
If the caller is passing a bad pointer into this function, it is a fatal error, the function will not return.
Parameters
[in]simIdThe SIM identifier.
[in]pinThe PIN code.

◆ le_sim_WriteFPLMNList()

le_result_t le_sim_WriteFPLMNList ( le_sim_Id_t  simId,
le_sim_FPLMNListRef_t  FPLMNListRef 
)

Write FPLMN list into the SIM. If the FPLMNListRef is not valid then this function will kill the calling client.

Returns
  • LE_FAULT Function failed.
  • LE_OK Function succeeded.
Parameters
[in]simIdThe SIM identifier.
[in]FPLMNListRefFPLMN list reference.