le_sim_interface.h
Go to the documentation of this file.
22 * A subscriber identity module or subscriber identification module (SIM) is an integrated circuit23 * that securely stores the international mobile subscriber identity (IMSI) and related key used to42 * le_sim_SelectCard() function is used to select the SIM identifier. By default, the SIM in slot 146 * SIM identifier. le_sim_GetSelectedCard() returns the current selected card, not necessarily the49 * @note The SIM selection is not reset persistent; this function has to be called at each start-up.51 * @note It is recommended to wait for a SIM handler notification after a new SIM selection before59 * automatically selects a SIM slot according to the rule: "If an external SIM is inserted in slot 175 * Each SIM is internationally identified by its integrated circuit card identifier (ICCID). ICCIDs87 * @note During the initialization phase of the service, each new subscription to the ICCID change89 * freshly registered clients to receive any ICCID changes that occured during the module start-up95 * The International Mobile Subscriber Identity or IMSI is a unique identification associated with101 * digits (European standard) or 3 digits (North American standard). The length of the MNC depends102 * on the value of the MCC. The remaining digits are the mobile subscription identification number108 * A eUICC is a SIM card with a remote provisioning function, and is designed to not be removed or109 * changed. It is able to store multiple communication profiles but only one is enabled (recognized110 * by the device and used for communication). With conventional SIM cards, the ICCID is used as the112 * profile, and a new identifier is defined, called the eUICCID (EID), which is used as the unique197 * typedef void(*le_sim_NewStateHandlerFunc_t)(@ref le_sim_Id_t simId, @c le_sim_States_t simState);203 * @note If two (or more) applications have registered a handler function for notifications, they206 * The application can uninstall the handler function by calling le_sim_RemoveNewStateHandler() API.220 * them is dedicated to emergency calls (ex: eCall, ERA-Glonass), local swap is needed to swap as226 * Local swap puts the eUICC in a temporary state, meaning the commercial subscription is replaced230 * The le_sim_LocalSwapToEmergencyCallSubscription() function requests the multi-profile eUICC to231 * swap to ECS and to refresh. The User's application must wait for eUICC reboot to be finished and234 * The le_sim_LocalSwapToCommercialSubscription() function requests the multi-profile eUICC to swap235 * back to commercial subscription and to refresh. The User's application must wait for eUICC reboot238 * eUICC allows support of multiple SIM profiles. These profiles can also be managed remotely from241 * switching SIM profiles is subject to a user agreement. This way, the customer application will242 * be able to properly finalize its current procedure (emergency call for instance) before accepting253 * The User's application can install a handler with le_sim_AddNewStateHandler() to receive eUICC's257 * - If you use a Morpho or Oberthur card, the SIM_REFRESH PRO-ACTIVE command must be accepted with260 * security restrictions for channel management APDU commands, otherwise local SIM profile switch294 * @note Some platforms do not support FPLMN APIs. Please refer to the @ref platformConstraintsSim303 * supports multiple subscription profiles, which can be remotely provisioned, updated or selected321 * - The le_sim_GetSimToolkitRefreshMode() API gets the mode of the Refresh command, as defined in349 * Some parameters are platform dependent, see @subpage platformConstraintsSim "SIM constraints" for354 * Logical channels are specified by the standard ETSI TS 102 221 in the section 8.7. If they are358 * - upon request, the card assigns a number to open a new channel. This channel remains open until396 * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Authentication402 * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Identification436 //--------------------------------------------------------------------------------------------------440 //--------------------------------------------------------------------------------------------------443 //--------------------------------------------------------------------------------------------------446 * Connect the current client thread to the service providing this API. Block until the service is449 * For each thread that wants to use this API, either ConnectService or TryConnectService must be450 * called before any other functions in this API. Normally, ConnectService is automatically called455 //--------------------------------------------------------------------------------------------------461 //--------------------------------------------------------------------------------------------------464 * Try to connect the current client thread to the service providing this API. Return with an error467 * For each thread that wants to use this API, either ConnectService or TryConnectService must be468 * called before any other functions in this API. Normally, ConnectService is automatically called477 * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).480 //--------------------------------------------------------------------------------------------------486 //--------------------------------------------------------------------------------------------------490 * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants493 //--------------------------------------------------------------------------------------------------500 //--------------------------------------------------------------------------------------------------506 * longer a connection to the service, and the functions in this API can't be used. For details, see511 //--------------------------------------------------------------------------------------------------518 //--------------------------------------------------------------------------------------------------522 //--------------------------------------------------------------------------------------------------525 //--------------------------------------------------------------------------------------------------530 //--------------------------------------------------------------------------------------------------533 //--------------------------------------------------------------------------------------------------538 //--------------------------------------------------------------------------------------------------541 //--------------------------------------------------------------------------------------------------546 //--------------------------------------------------------------------------------------------------549 //--------------------------------------------------------------------------------------------------554 //--------------------------------------------------------------------------------------------------557 //--------------------------------------------------------------------------------------------------561 //--------------------------------------------------------------------------------------------------564 //--------------------------------------------------------------------------------------------------568 //--------------------------------------------------------------------------------------------------571 //--------------------------------------------------------------------------------------------------575 //--------------------------------------------------------------------------------------------------578 //--------------------------------------------------------------------------------------------------582 //--------------------------------------------------------------------------------------------------585 //--------------------------------------------------------------------------------------------------590 //--------------------------------------------------------------------------------------------------593 //--------------------------------------------------------------------------------------------------597 //--------------------------------------------------------------------------------------------------600 //--------------------------------------------------------------------------------------------------605 //--------------------------------------------------------------------------------------------------608 //--------------------------------------------------------------------------------------------------612 //--------------------------------------------------------------------------------------------------615 //--------------------------------------------------------------------------------------------------620 //--------------------------------------------------------------------------------------------------623 //--------------------------------------------------------------------------------------------------627 //--------------------------------------------------------------------------------------------------630 //--------------------------------------------------------------------------------------------------635 //--------------------------------------------------------------------------------------------------638 //--------------------------------------------------------------------------------------------------642 //--------------------------------------------------------------------------------------------------645 //--------------------------------------------------------------------------------------------------652 //--------------------------------------------------------------------------------------------------661 //--------------------------------------------------------------------------------------------------665 //--------------------------------------------------------------------------------------------------672 //--------------------------------------------------------------------------------------------------679 //--------------------------------------------------------------------------------------------------688 //--------------------------------------------------------------------------------------------------692 //--------------------------------------------------------------------------------------------------699 //--------------------------------------------------------------------------------------------------706 //--------------------------------------------------------------------------------------------------715 //--------------------------------------------------------------------------------------------------719 //--------------------------------------------------------------------------------------------------726 //--------------------------------------------------------------------------------------------------733 //--------------------------------------------------------------------------------------------------742 //--------------------------------------------------------------------------------------------------746 //--------------------------------------------------------------------------------------------------753 //--------------------------------------------------------------------------------------------------759 //--------------------------------------------------------------------------------------------------765 //--------------------------------------------------------------------------------------------------771 //--------------------------------------------------------------------------------------------------777 //--------------------------------------------------------------------------------------------------785 //--------------------------------------------------------------------------------------------------792 //--------------------------------------------------------------------------------------------------804 //--------------------------------------------------------------------------------------------------815 //--------------------------------------------------------------------------------------------------831 //--------------------------------------------------------------------------------------------------842 //--------------------------------------------------------------------------------------------------855 //--------------------------------------------------------------------------------------------------866 //--------------------------------------------------------------------------------------------------876 //--------------------------------------------------------------------------------------------------883 //--------------------------------------------------------------------------------------------------894 //--------------------------------------------------------------------------------------------------901 //--------------------------------------------------------------------------------------------------917 //--------------------------------------------------------------------------------------------------926 //--------------------------------------------------------------------------------------------------941 //--------------------------------------------------------------------------------------------------952 //--------------------------------------------------------------------------------------------------962 //--------------------------------------------------------------------------------------------------969 //--------------------------------------------------------------------------------------------------982 //--------------------------------------------------------------------------------------------------991 //--------------------------------------------------------------------------------------------------1006 //--------------------------------------------------------------------------------------------------1015 //--------------------------------------------------------------------------------------------------1030 //--------------------------------------------------------------------------------------------------1039 //--------------------------------------------------------------------------------------------------1056 //--------------------------------------------------------------------------------------------------1067 //--------------------------------------------------------------------------------------------------1076 //--------------------------------------------------------------------------------------------------1083 //--------------------------------------------------------------------------------------------------1096 //--------------------------------------------------------------------------------------------------1107 //--------------------------------------------------------------------------------------------------1120 * @note The home network name can be given even if the device is not registered on the network.1122 //--------------------------------------------------------------------------------------------------1133 //--------------------------------------------------------------------------------------------------1145 //--------------------------------------------------------------------------------------------------1160 //--------------------------------------------------------------------------------------------------1162 * This function must be called to request the multi-profile eUICC to swap to ECS and to refresh.1173 * @note Please ensure that the eUICC is selected using le_sim_SelectCard() and in a ready state1180 //--------------------------------------------------------------------------------------------------1189 //--------------------------------------------------------------------------------------------------1203 * @note Please ensure that the eUICC is selected using le_sim_SelectCard() and in a ready state1210 //--------------------------------------------------------------------------------------------------1219 //--------------------------------------------------------------------------------------------------1233 //--------------------------------------------------------------------------------------------------1243 //--------------------------------------------------------------------------------------------------1251 //--------------------------------------------------------------------------------------------------1258 //--------------------------------------------------------------------------------------------------1266 //--------------------------------------------------------------------------------------------------1273 //--------------------------------------------------------------------------------------------------1285 //--------------------------------------------------------------------------------------------------1294 //--------------------------------------------------------------------------------------------------1304 //--------------------------------------------------------------------------------------------------1313 //--------------------------------------------------------------------------------------------------1323 //--------------------------------------------------------------------------------------------------1338 //--------------------------------------------------------------------------------------------------1351 //--------------------------------------------------------------------------------------------------1382 //--------------------------------------------------------------------------------------------------1394 //--------------------------------------------------------------------------------------------------1401 //--------------------------------------------------------------------------------------------------1415 //--------------------------------------------------------------------------------------------------1422 //--------------------------------------------------------------------------------------------------1430 //--------------------------------------------------------------------------------------------------1437 //--------------------------------------------------------------------------------------------------1445 //--------------------------------------------------------------------------------------------------1451 //--------------------------------------------------------------------------------------------------1454 * If the FPLMNListRef, mcc or mnc is not valid then this function will kill the calling client.1461 //--------------------------------------------------------------------------------------------------1472 //--------------------------------------------------------------------------------------------------1482 //--------------------------------------------------------------------------------------------------1491 //--------------------------------------------------------------------------------------------------1499 //--------------------------------------------------------------------------------------------------1506 //--------------------------------------------------------------------------------------------------1519 //--------------------------------------------------------------------------------------------------1534 //--------------------------------------------------------------------------------------------------1536 * Read the next FPLMN network from the list of FPLMN objects retrieved with le_sim_ReadFPLMNList().1546 //--------------------------------------------------------------------------------------------------1561 //--------------------------------------------------------------------------------------------------1570 //--------------------------------------------------------------------------------------------------1577 //--------------------------------------------------------------------------------------------------1586 //--------------------------------------------------------------------------------------------------1593 //--------------------------------------------------------------------------------------------------1601 //--------------------------------------------------------------------------------------------------1608 //--------------------------------------------------------------------------------------------------1618 //--------------------------------------------------------------------------------------------------1635 //--------------------------------------------------------------------------------------------------1645 //--------------------------------------------------------------------------------------------------le_result_t le_sim_RejectSimToolkitCommand(le_sim_Id_t simId)void le_sim_ConnectService(void)void le_sim_DisconnectService(void)le_result_t le_sim_WriteFPLMNList(le_sim_Id_t simId, le_sim_FPLMNListRef_t FPLMNListRef)le_result_t le_sim_GetHomeNetworkOperator(le_sim_Id_t simId, char *nameStr, size_t nameStrSize)le_result_t le_sim_GetIMSI(le_sim_Id_t simId, char *imsi, size_t imsiSize)void le_sim_DeleteFPLMNList(le_sim_FPLMNListRef_t FPLMNListRef)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)void le_sim_RemoveIccidChangeHandler(le_sim_IccidChangeHandlerRef_t handlerRef)le_sim_States_t le_sim_GetState(le_sim_Id_t simId)le_result_t le_sim_GetAutomaticSelection(bool *enablePtr)le_sim_Id_t le_sim_GetSelectedCard(void)void(* le_sim_SimToolkitEventHandlerFunc_t)(le_sim_Id_t simId, le_sim_StkEvent_t stkEvent, void *contextPtr)Definition: le_sim_common.h:433void(* le_sim_ProfileUpdateHandlerFunc_t)(le_sim_Id_t simId, le_sim_StkEvent_t stkEvent, void *contextPtr)Definition: le_sim_common.h:417le_sim_FPLMNListRef_t le_sim_ReadFPLMNList(le_sim_Id_t simId)le_result_t le_sim_CloseLogicalChannel(uint8_t channel)le_result_t le_sim_SetPower(le_sim_Id_t simId, le_onoff_t power)LE_FULL_API void le_sim_SetServerDisconnectHandler(le_sim_DisconnectHandler_t disconnectHandler, void *contextPtr)struct le_sim_IccidChangeHandler * le_sim_IccidChangeHandlerRef_tDefinition: le_sim_common.h:391void le_sim_RemoveNewStateHandler(le_sim_NewStateHandlerRef_t handlerRef)le_result_t le_sim_GetEID(le_sim_Id_t simId, char *eid, size_t eidSize)le_result_t le_sim_LocalSwapToEmergencyCallSubscription(le_sim_Id_t simId, le_sim_Manufacturer_t manufacturer)void(* le_sim_DisconnectHandler_t)(void *)Definition: le_sim_interface.h:441le_result_t le_sim_IsEmergencyCallSubscriptionSelected(le_sim_Id_t simId, bool *isEcsPtr)le_sim_IccidChangeHandlerRef_t le_sim_AddIccidChangeHandler(le_sim_IccidChangeHandlerFunc_t handlerPtr, void *contextPtr)le_result_t le_sim_GetNextFPLMNOperator(le_sim_FPLMNListRef_t FPLMNListRef, char *mccPtr, size_t mccPtrSize, char *mncPtr, size_t mncPtrSize)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_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_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_GetSubscriberPhoneNumber(le_sim_Id_t simId, char *phoneNumberStr, size_t phoneNumberStrSize)le_result_t le_sim_TryConnectService(void)int32_t le_sim_GetRemainingPINTries(le_sim_Id_t simId)le_result_t le_sim_EnterPIN(le_sim_Id_t simId, const char *LE_NONNULL pin)bool le_sim_IsPresent(le_sim_Id_t simId)le_result_t le_sim_Reset(le_sim_Id_t simId)le_sim_SimToolkitEventHandlerRef_t le_sim_AddSimToolkitEventHandler(le_sim_SimToolkitEventHandlerFunc_t handlerPtr, void *contextPtr)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_SetAutomaticSelection(bool enable)void(* le_sim_IccidChangeHandlerFunc_t)(le_sim_Id_t simId, const char *LE_NONNULL iccid, void *contextPtr)Definition: le_sim_common.h:449le_result_t le_sim_OpenLogicalChannel(uint8_t *channelPtrPtr)le_sim_ProfileUpdateHandlerRef_t le_sim_AddProfileUpdateHandler(le_sim_ProfileUpdateHandlerFunc_t handlerPtr, void *contextPtr)le_result_t le_sim_Lock(le_sim_Id_t simId, const char *LE_NONNULL pin)le_result_t le_sim_GetSimToolkitRefreshMode(le_sim_Id_t simId, le_sim_StkRefreshMode_t *refreshModePtr)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_sim_SimMode_t le_sim_GetSimMode(void)le_sim_NewStateHandlerRef_t le_sim_AddNewStateHandler(le_sim_NewStateHandlerFunc_t handlerPtr, void *contextPtr)le_result_t le_sim_LocalSwapToCommercialSubscription(le_sim_Id_t simId, le_sim_Manufacturer_t manufacturer)le_result_t le_sim_GetSimToolkitRefreshStage(le_sim_Id_t simId, le_sim_StkRefreshStage_t *refreshStagePtr)struct le_sim_NewStateHandler * le_sim_NewStateHandlerRef_tDefinition: le_sim_common.h:367struct le_sim_ProfileUpdateHandler * le_sim_ProfileUpdateHandlerRef_tDefinition: le_sim_common.h:375le_result_t le_sim_ChangePIN(le_sim_Id_t simId, const char *LE_NONNULL oldpin, const char *LE_NONNULL newpin)le_result_t le_sim_GetICCID(le_sim_Id_t simId, char *iccid, size_t iccidSize)struct le_sim_SimToolkitEventHandler * le_sim_SimToolkitEventHandlerRef_tDefinition: le_sim_common.h:383le_result_t le_sim_Unblock(le_sim_Id_t simId, const char *LE_NONNULL puk, const char *LE_NONNULL newpin)void le_sim_RemoveSimToolkitEventHandler(le_sim_SimToolkitEventHandlerRef_t handlerRef)void le_sim_RemoveProfileUpdateHandler(le_sim_ProfileUpdateHandlerRef_t handlerRef)void(* le_sim_NewStateHandlerFunc_t)(le_sim_Id_t simId, le_sim_States_t simState, void *contextPtr)Definition: le_sim_common.h:401le_result_t le_sim_SelectCard(le_sim_Id_t simId)le_result_t le_sim_AcceptSimToolkitCommand(le_sim_Id_t simId)bool le_sim_IsReady(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)