SIM

API Reference


This file contains prototype definitions for SIM API.

A subscriber identity module or subscriber identification module (SIM) is an integrated circuit that securely stores the international mobile subscriber identity (IMSI) and related key used to identify and authenticate subscribers on M2M devices.

Most SIM cards can store a number of SMS messages and phone book contacts.

le_sim_GetSelectedCard() returns the selected SIM card number.

IPC interfaces binding

All the functions of this API are provided by the modemService.

Here's a code sample binding to modem services:

bindings:
{
   clientExe.clientComponent.le_sim -> modemService.le_sim
}

Select a card to use

le_sim_SelectCard() function is used to select the SIM. By default, the SIM in slot 1 is used.

Note
The SIM selection is not reset persistent; this function has to be called at each start-up.
: It is recommended to wait for a SIM handler notification after a new SIM selection before calling le_sim API functions.

SIM identification information

ICCID: Each SIM is internationally identified by its integrated circuit card identifier (ICCID). ICCIDs are stored in the SIM cards and engraved or printed on the SIM card body. The ICCID is defined by the ITU-T recommendation E.118 as the Primary Account Number. According to E.118, the number is up to 19 digits long, including a single check digit calculated using the Luhn algorithm. However, the GSM Phase 1 (ETSI Recommendation GSM 11.11) defined the ICCID length as 10 octets (20 digits) with operator-specific structure.

le_sim_GetICCID() API reads the identification number (ICCID).

Using this API selects the requested SIM.

IMSI: The International Mobile Subscriber Identity or IMSI is a unique identification associated with all cellular networks. The IMSI is used in any mobile network that connects with other networks. For GSM, UMTS and LTE network, this number is provisioned in the SIM card.

An IMSI is usually presented as a 15 digit long number, but can be shorter. The first 3 digits are the mobile country code (MCC), are followed by the mobile network code (MNC), either 2 digits (European standard) or 3 digits (North American standard). The length of the MNC depends on the value of the MCC. The remaining digits are the mobile subscription identification number (MSIN) within the network's customer base.

Home Network Name: le_sim_GetHomeNetworkOperator() retrieves the Home Network Name.

le_sim_GetIMSI() API reads the international mobile subscriber identity (IMSI).

Using this API selects the requested SIM.

Phone Number: le_sim_GetSubscriberPhoneNumber() API reads the Phone Number associated to the SIM. If the phone number has not been provisioned, it will return the empty string.

Using this API selects the requested SIM.

Home Network Information:

SIM Authentication

le_sim_EnterPIN() enters the PIN (Personal Identification Number) code that's required before any Mobile equipment functionality can be used.

Using this API selects the requested SIM.

le_sim_GetRemainingPINTries() returns the number of remaining PIN entry attempts before the SIM will become blocked.

Using this API selects the requested SIM.

le_sim_ChangePIN() must be called to change the PIN code.

Using this API selects the requested SIM.

le_sim_Lock() locks the SIM card: it enables requests for the PIN code.

Using this API selects the requested SIM.

le_sim_Unlock() unlocks the SIM card: it disables requests for the PIN code.

Using this API selects the requested SIM.

le_sim_Unblock() unblocks the SIM card. The SIM card is blocked after X unsuccessful attempts to enter the PIN. le_sim_Unblock() requires the PUK (Personal Unblocking) code to set a new PIN code.

Using this API selects the requested SIM.

SIM states

le_sim_IsPresent() API advises the SIM is inserted (and locked) or removed.

Using this API selects the requested SIM.

le_sim_IsReady() API advises the SIM is ready (PIN code correctly entered or not required).

Using this API selects the requested SIM.

The le_sim_GetState() API retrieves the SIM state:

  • 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_STATE_UNKNOWN : Unknown SIM state.

Using this API selects the requested SIM.

A handler function must be registered to receive SIM's state notifications. le_sim_AddNewStateHandler() API allows the User to register that handler.

The handler must satisfy the following prototype: typedef void(*le_sim_NewStateHandlerFunc_t)(le_sim_Id_t simId, le_sim_States_t simState);

When a new SIM's state is notified, the handler is called.

Call le_sim_GetState() to retrieve the new state of the SIM.

Note
If two (or more) applications have registered a handler function for notifications, they will all receive it and will be passed the same SIM.

The application can uninstall the handler function by calling le_sim_RemoveNewStateHandler() API.

Local SIM profile switch

As soon as there are several subscriptions/profiles in the eUICC (multi-profile), and one of them is dedicated to emergency calls (ex: eCall, ERA-Glonass), local swap is needed to swap as quickly as possible to the emergency profile in case of need.

“Local swap” means that the User's application must be able to directly request the eUICC to swap to Emergency Call Subscription (ECS).

Local swap puts the eUICC in a temporary state, meaning the commercial subscription is replaced by emergency subscription for a limited time, event triggering the swap back to commercial subscription being controlled by the User's application.

The le_sim_LocalSwapToEmergencyCallSubscription() function requests 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.

The le_sim_LocalSwapToCommercialSubscription() function requests 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.

The User's application can install an handler with le_sim_AddNewStateHandler() to receive eUICC's state notifications.

Warning
If you use a Giesecke & Devrient (G&D) card, be sure that your platform has disabled security restrictions for channel management APDU commands, otherwise local SIM profile switch could not work.

The le_sim_IsEmergencyCallSubscriptionSelected() function must be called to get the current subscription.

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.

SIM Toolkit

The SIM application Toolkit allows the SIM card to initiates commands or asking input from the modem to accept/reject SIM operations.

One of the use case is the remote provisioning of an embedded UICC (eUICC).

The embedded UICC (eUICC) format supports multiple subscription profiles, which can be remotely provisioned, updated or selected through SIM tool kit procedures (Bearer Independent Protocol -BIP-, SIM refresh).

It is mainly used for in-vehicle emergency call service (eCall).

An eUICC can be remotely managed to change the Mobile Network Operator subscription.

The le_sim_AddSimToolkitEventHandler() function registers a handler to be notified of SIM Toolkit events.

The le_sim_RemoveSimToolkitEventHandler() function unregisters the handler.

The le_sim_AcceptSimToolkitCommand() allows the device to accept the last SIM Toolkit command.

The le_sim_RejectSimToolkitCommand() forbids the device to accept the last SIM Toolkit command.


Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.