le_sim_interface.h

Go to the documentation of this file.
1 
2 
3 /*
4  * ====================== WARNING ======================
5  *
6  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
7  * DO NOT MODIFY IN ANY WAY.
8  *
9  * ====================== WARNING ======================
10  */
11 
12 /**
13  * @page c_sim SIM
14  *
15  * @ref le_sim_interface.h "API Reference" <br>
16  * @ref platformConstraintsSim "SIM constraints"
17  *
18  * <HR>
19  *
20  * This file contains prototype definitions for SIM API.
21  *
22  * A subscriber identity module or subscriber identification module (SIM) is an integrated circuit
23  * that securely stores the international mobile subscriber identity (IMSI) and related key used to
24  * identify and authenticate subscribers on M2M devices.
25  *
26  * Most SIM cards can store a number of SMS messages and phone book contacts.
27  *
28  * le_sim_GetSelectedCard() returns the selected SIM card number.
29  *
30  * @section le_sim_binding IPC interfaces binding
31  *
32  * All the functions of this API are provided by the @b modemService.
33  *
34  * Here's a code sample binding to modem services:
35  * @verbatim
36  bindings:
37  {
38  clientExe.clientComponent.le_sim -> modemService.le_sim
39  }
40  @endverbatim
41  *
42  *
43  * @section le_sim_SelectCard Select a card to use
44  * le_sim_SelectCard() function is used to select the SIM identifier. By default, the SIM in slot 1
45  * is used.
46  * Additionally, any Legato SIM API with a SIM card identifier passed in parameter, selects that
47  * SIM identifier. le_sim_GetSelectedCard() returns the current selected card, not necessarily the
48  * one set previously by le_sim_SelectCard().
49  *
50  * @note The SIM selection is not reset persistent; this function has to be called at each start-up.
51  *
52  * @note It is recommended to wait for a SIM handler notification after a new SIM selection before
53  * calling le_sim API functions.
54  *
55  *
56  * A sample code can be seen in the following page:
57  * - @subpage c_simTestSelect
58  *
59  * @section le_sim_id SIM identification information
60  * \b ICCID:
61  * Each SIM is internationally identified by its integrated circuit card identifier (ICCID). ICCIDs
62  * are stored in the SIM cards and engraved or printed on the SIM card body.
63  * The ICCID is defined by the ITU-T recommendation E.118 as the
64  * Primary Account Number. According to E.118, the number is up to 19 digits long, including a
65  * single check digit calculated using the Luhn algorithm. However, the GSM Phase 1 (ETSI
66  * Recommendation GSM 11.11) defined the ICCID length as 10 octets (20 digits) with
67  * operator-specific structure.
68  *
69  * le_sim_GetICCID() API reads the identification number (ICCID).
70  *
71  * Using this API selects the requested SIM.
72  *
73  * \b IMSI:
74  * The International Mobile Subscriber Identity or IMSI is a unique identification associated with
75  * all cellular networks. The IMSI is used in any mobile network that connects with other
76  * networks. For GSM, UMTS and LTE network, this number is provisioned in the SIM card.
77  *
78  * An IMSI is usually presented as a 15 digit long number, but can be shorter. The first 3 digits
79  * are the mobile country code (MCC), are followed by the mobile network code (MNC), either 2
80  * digits (European standard) or 3 digits (North American standard). The length of the MNC depends
81  * on the value of the MCC. The remaining digits are the mobile subscription identification number
82  * (MSIN) within the network's customer base.
83  *
84  * \b EID:
85  * The EID (also called eUICCID) is the unique identifier for the embedded Universal Integrated
86  * Circuit Card (eUICC).
87  * A eUICC is a SIM card with a remote provisioning function, and is designed to not be removed or
88  * changed. It is able to store multiple communication profiles but only one is enabled (recognized
89  * by the device and used for communication). With conventional SIM cards, the ICCID is used as the
90  * unique key to identify the SIM card, but with eUICC, the ICCID is the key used to identify a
91  * profile, and a new identifier is defined, called the eUICCID (EID), which is used as the unique
92  * key for the embedded SIM.
93  * le_sim_GetEID() API reads the EID.
94  *
95  * \b Home \b Network \b Name:
96  * le_sim_GetHomeNetworkOperator() retrieves the Home Network Name.
97  *
98  * le_sim_GetIMSI() API reads the international mobile subscriber identity (IMSI).
99  *
100  * Using this API selects the requested SIM.
101  *
102  * \b Phone \b Number:
103  * le_sim_GetSubscriberPhoneNumber() API reads the Phone Number associated to the SIM.
104  * If the phone number has not been provisioned, it will return the empty string.
105  *
106  * Using this API selects the requested SIM.
107  *
108  * \b Home \b Network \b Information:
109  * - le_sim_GetHomeNetworkOperator()function retrieves the Home Network Name.
110  * - le_sim_GetHomeNetworkMccMnc()function retrieves the Home Network MCC (Mobile Country Code)
111  * and MNC (Mobile Network Code).
112  *
113  * A sample code can be seen in the following page:
114  * - @subpage c_simTestIdentification
115  *
116  * @section le_sim_auth SIM Authentication
117  * le_sim_EnterPIN() enters the PIN (Personal Identification Number) code that's
118  * required before any Mobile equipment functionality can be used.
119  *
120  * Using this API selects the requested SIM.
121  *
122  * le_sim_GetRemainingPINTries() returns the number of remaining PIN entry attempts
123  * before the SIM will become blocked.
124  *
125  * Using this API selects the requested SIM.
126  *
127  * le_sim_GetRemainingPUKTries() returns the number of remaining PUK entry attempts
128  * before the SIM will become blocked.
129  *
130  * Using this API selects the requested SIM.
131  *
132  * le_sim_ChangePIN() must be called to change the PIN code.
133  *
134  * Using this API selects the requested SIM.
135  *
136  * le_sim_Lock() locks the SIM card: it enables requests for the PIN code.
137  *
138  * Using this API selects the requested SIM.
139  *
140  * le_sim_Unlock() unlocks the SIM card: it disables requests for the PIN code.
141  *
142  * Using this API selects the requested SIM.
143  *
144  * le_sim_Unblock() unblocks the SIM card. The SIM card is blocked after X unsuccessful
145  * attempts to enter the PIN. le_sim_Unblock() requires the PUK (Personal Unblocking) code
146  * to set a new PIN code.
147  *
148  * A sample code can be seen in the following page:
149  * - @subpage c_simTestAuthentication
150  *
151  * @section le_sim_state SIM states
152  * le_sim_IsPresent() API advises the SIM is inserted (and locked) or removed.
153  *
154  * Using this API selects the requested SIM.
155  *
156  * le_sim_IsReady() API advises the SIM is ready (PIN code correctly entered
157  * or not required).
158  *
159  * Using this API selects the requested SIM.
160  *
161  * The le_sim_GetState() API retrieves the SIM state:
162  * - LE_SIM_INSERTED : SIM card is inserted and locked.
163  * - LE_SIM_ABSENT : SIM card is absent.
164  * - LE_SIM_READY : SIM card is inserted and unlocked.
165  * - LE_SIM_BLOCKED : SIM card is blocked.
166  * - LE_SIM_BUSY : SIM card is busy.
167  * - LE_SIM_STATE_UNKNOWN : Unknown SIM state.
168  *
169  * Using this API selects the requested SIM.
170  *
171  * A handler function must be registered to receive SIM's state notifications.
172  * le_sim_AddNewStateHandler() API allows the User to register that handler.
173  *
174  * The handler must satisfy the following prototype:
175  * typedef void(*le_sim_NewStateHandlerFunc_t)(@ref le_sim_Id_t simId, @c le_sim_States_t simState);
176  *
177  * When a new SIM's state is notified, the handler is called.
178  *
179  * Call le_sim_GetState() to retrieve the new state of the SIM.
180  *
181  * @note If two (or more) applications have registered a handler function for notifications, they
182  * will all receive it and will be passed the same SIM.
183  *
184  * The application can uninstall the handler function by calling le_sim_RemoveNewStateHandler() API.
185  *
186  * @warning Your platform might need a reboot to detect a SIM insertion or removal.
187  * Please refer to the @ref platformConstraintsSim "SIM constraints" page or your platform
188  * documentation for further details.
189  *
190  * A sample code can be seen in the following page:
191  * - @subpage c_simTestStates
192  *
193  * @section le_sim_profile_switch Local SIM profile switch
194  *
195  * As soon as there are several subscriptions/profiles in the eUICC (multi-profile), and one of
196  * them is dedicated to emergency calls (ex: eCall, ERA-Glonass), local swap is needed to swap as
197  * quickly as possible to the emergency profile in case of need.
198  *
199  * “Local swap” means that the User's application must be able to directly request the eUICC to
200  * swap to Emergency Call Subscription (ECS).
201  *
202  * Local swap puts the eUICC in a temporary state, meaning the commercial subscription is replaced
203  * by emergency subscription for a limited time, event triggering the swap back to commercial
204  * subscription being controlled by the User's application.
205  *
206  * The le_sim_LocalSwapToEmergencyCallSubscription() function requests the multi-profile eUICC to
207  * swap to ECS and to refresh. The User's application must wait for eUICC reboot to be finished and
208  * network connection available.
209  *
210  * The le_sim_LocalSwapToCommercialSubscription() function requests the multi-profile eUICC to swap
211  * back to commercial subscription and to refresh. The User's application must wait for eUICC reboot
212  * to be finished and network connection available.
213  *
214  * The User's application can install an handler with le_sim_AddNewStateHandler() to receive eUICC's
215  * state notifications.
216  *
217  * @warning
218  * - If you use a Morpho or Oberthur card, the SIM_REFRESH PRO-ACTIVE command must be accepted with
219  * le_sim_AcceptSimToolkitCommand() in order to complete the profile swap procedure.
220  * - If you use a Giesecke & Devrient (G&D) card, be sure that your platform has disabled
221  * security restrictions for channel management APDU commands, otherwise local SIM profile switch
222  * could not work.
223  *
224  * The le_sim_IsEmergencyCallSubscriptionSelected() function must be called to get the current
225  * subscription.
226  *
227  * @warning There is no standard method to interrogate the current selected subscription. The
228  * returned value of this function is based on the last executed local swap command. This means
229  * that this function will always return LE_NOT_FOUND error at Legato startup.
230  *
231  * A sample code can be seen in the following page:
232  * - @subpage c_simTestProfileSwitch
233  *
234  * @section le_sim_Reset SIM Reset
235  *
236  * The le_sim_Reset() function resets the SIM card.
237  *
238  * @section le_sim_FPLMNList Read / Write FPLMN List from SIM
239  *
240  * The le_sim_CreateFPLMNList() function creates the empty FPLMN list.
241  *
242  * The le_sim_AddFPLMNOperator() function adds the FPLMN network into FPLMN list.
243  *
244  * The le_sim_WriteFPLMNList() function writes FPLMN list into the SIM.
245  *
246  * The le_sim_ReadFPLMNList() function reads the FPLMN list from the SIM card.
247  *
248  * The le_sim_GetFirstFPLMNOperator() function fetches the first FPLMN operator from FPLMN list.
249  *
250  * The le_sim_GetNextFPLMNOperator() function fetches the next FPLMN operator from FPLMN list.
251  *
252  * The le_sim_DeleteFPLMNList() function releases all allocated resources associated with the
253  * List object.
254  *
255  * @note Some platforms do not support FPLMN APIs. Please refer to the @ref platformConstraintsSim
256  * "SIM constraints" page or your platform documentation for further details.
257  *
258  * @section le_sim_stk SIM Toolkit
259  *
260  * The SIM application Toolkit allows the SIM card to initiate commands or asking input from the
261  * modem to accept/reject SIM operations.
262  *
263  * One of the use case is the remote provisioning of an embedded UICC (eUICC): the eUICC format
264  * supports multiple subscription profiles, which can be remotely provisioned, updated or selected
265  * through SIM Toolkit procedures (Bearer Independent Protocol @em BIP, SIM refresh).
266  *
267  * It is mainly used for in-vehicle emergency call service (eCall).
268  *
269  * An eUICC can be remotely managed to change the Mobile Network Operator subscription.
270  *
271  * The le_sim_AddSimToolkitEventHandler() API registers a handler to be notified of SIM
272  * Toolkit events. The le_sim_RemoveSimToolkitEventHandler() API unregisters the handler.
273  *
274  * The last received SIM Toolkit command can:
275  * - Either be accepted by the device with the le_sim_AcceptSimToolkitCommand() API
276  * - Or be rejected by the device with the le_sim_RejectSimToolkitCommand() API.
277  * Note that if no handler is registered, refresh requests are automatically accepted.
278  *
279  * In case the last SIM Toolkit command is a Refresh command (@ref LE_SIM_REFRESH), additional
280  * information can be retrieved:
281  * - The le_sim_GetSimToolkitRefreshStage() API gets the stage of the Refresh command.
282  * - The le_sim_GetSimToolkitRefreshMode() API gets the mode of the Refresh command, as defined in
283  * ETSI TS 102 223 sections 6.4.7 and 8.6.
284  *
285  * A sample code using the SIM Toolkit APIs can be seen in the following page:
286  * - @subpage c_simTestSimToolkit
287  *
288  * Information related to SIM Toolkit platform constraints can be found in the
289  * @ref platformConstraintsStk "SIM Toolkit platform constraints" page.
290  *
291  * @section le_sim_access SIM access
292  *
293  * The SIM card content can be accessed and/or modified by several methods.
294  *
295  * @subsection le_sim_accessApdu APDU
296  *
297  * The application can send an APDU (Application Protocol Data Unit) to the SIM using
298  * le_sim_SendApdu() API. The user must encode the APDU as specified by in recommendation 3GPP
299  * 11.11, 3GPP 51.011, 3GPP 31.102, 3GPP 31.103 or ETSI TS 102 221.
300  * @note Between two successive calls to le_sim_SendApdu() API, there is no locking
301  * protection. In this situation, some command types and parameters can modify SIM files
302  * incorrectly.
303  *
304  * @subsection le_sim_accessCommand Commands
305  *
306  * Using le_sim_SendCommand(), the application has easier but more limited access to the
307  * SIM database. The command is transmitted to the SIM, which gives information through swi1 and
308  * swi2 about the execution of the command (see 3GPP recommendation previously mentioned for
309  * their coding).
310  * Some parameters are platform dependent, see @subpage platformConstraintsSim "SIM constraints" for
311  * their coding.
312  *
313  * @subsection le_sim_accessLogicalChannel Logical channels
314  *
315  * Logical channels are specified by the standard ETSI TS 102 221 in the section 8.7. If they are
316  * supported by the SIM card, logical channels allow to send independent APDUs on the different
317  * channels. In this case:
318  * - the basic channel 0 is always available and opened.
319  * - upon request, the card assigns a number to open a new channel. This channel remains open until
320  * it is explicitly closed or the SIM card is deactivated.
321  *
322  * Use le_sim_OpenLogicalChannel() API to open a logical channel on the SIM card. APDUs can then
323  * be sent to the SIM card with le_sim_SendApduOnChannel(). When the logical channel is not
324  * needed anymore, it can be closed using le_sim_CloseLogicalChannel().
325  *
326  * @subsection le_sim_accessSampleCode Sample code
327  *
328  * A sample code can be seen in the following page:
329  * - @subpage c_simTestApdu
330  *
331  * <HR>
332  *
333  * Copyright (C) Sierra Wireless Inc.
334  */
335 /**
336  * @file le_sim_interface.h
337  *
338  * Legato @ref c_sim include file.
339  *
340  * Copyright (C) Sierra Wireless Inc.
341  */
342 /**
343  * @page c_simTestProfileSwitch Sample code for Local SIM profile switch
344  *
345  * @include "apps/test/modemServices/sim/simProfileSwap/simTestComp/simTest.c"
346  */
347 /**
348  * @page c_simTestSimToolkit Sample code for Local SIM Toolkit
349  *
350  * @include "apps/test/modemServices/sim/simToolkit/simToolkitComp/simToolkitTest.c"
351  */
352 /**
353  * @page c_simTestAuthentication Sample code for SIM Authentication
354  *
355  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Define
356  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/main.c" Print
357  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Authentication
358  */
359 /**
360  * @page c_simTestIdentification Sample code for SIM Identification
361  *
362  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/main.c" Print
363  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Identification
364  */
365 /**
366  * @page c_simTestSelect Sample code for SIM Select
367  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Select
368  */
369 /**
370  * @page c_simTestStates Sample code for SIM States
371  *
372  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/main.c" Print
373  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Display
374  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" State handler
375  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" State
376  */
377 /**
378  * @page c_simTestApdu Sample code for SIM access
379  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Apdu
380  */
381 
382 #ifndef LE_SIM_INTERFACE_H_INCLUDE_GUARD
383 #define LE_SIM_INTERFACE_H_INCLUDE_GUARD
384 
385 
386 #include "legato.h"
387 
388 // Interface specific includes
389 #include "le_mdmDefs_interface.h"
390 
391 
392 //--------------------------------------------------------------------------------------------------
393 /**
394  * Type for handler called when a server disconnects.
395  */
396 //--------------------------------------------------------------------------------------------------
397 typedef void (*le_sim_DisconnectHandler_t)(void *);
398 
399 //--------------------------------------------------------------------------------------------------
400 /**
401  *
402  * Connect the current client thread to the service providing this API. Block until the service is
403  * available.
404  *
405  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
406  * called before any other functions in this API. Normally, ConnectService is automatically called
407  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
408  *
409  * This function is created automatically.
410  */
411 //--------------------------------------------------------------------------------------------------
413 (
414  void
415 );
416 
417 //--------------------------------------------------------------------------------------------------
418 /**
419  *
420  * Try to connect the current client thread to the service providing this API. Return with an error
421  * if the service is not available.
422  *
423  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
424  * called before any other functions in this API. Normally, ConnectService is automatically called
425  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
426  *
427  * This function is created automatically.
428  *
429  * @return
430  * - LE_OK if the client connected successfully to the service.
431  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
432  * bound.
433  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
434  * - LE_COMM_ERROR if the Service Directory cannot be reached.
435  */
436 //--------------------------------------------------------------------------------------------------
438 (
439  void
440 );
441 
442 //--------------------------------------------------------------------------------------------------
443 /**
444  * Set handler called when server disconnection is detected.
445  *
446  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
447  * to continue without exiting, it should call longjmp() from inside the handler.
448  */
449 //--------------------------------------------------------------------------------------------------
451 (
452  le_sim_DisconnectHandler_t disconnectHandler,
453  void *contextPtr
454 );
455 
456 //--------------------------------------------------------------------------------------------------
457 /**
458  *
459  * Disconnect the current client thread from the service providing this API.
460  *
461  * Normally, this function doesn't need to be called. After this function is called, there's no
462  * longer a connection to the service, and the functions in this API can't be used. For details, see
463  * @ref apiFilesC_client.
464  *
465  * This function is created automatically.
466  */
467 //--------------------------------------------------------------------------------------------------
469 (
470  void
471 );
472 
473 
474 //--------------------------------------------------------------------------------------------------
475 /**
476  * Minimum PIN length (4 digits)
477  */
478 //--------------------------------------------------------------------------------------------------
479 #define LE_SIM_PIN_MIN_LEN 4
480 
481 //--------------------------------------------------------------------------------------------------
482 /**
483  * Maximum PIN length (8 digits)
484  */
485 //--------------------------------------------------------------------------------------------------
486 #define LE_SIM_PIN_MAX_LEN 8
487 
488 //--------------------------------------------------------------------------------------------------
489 /**
490  * Maximum PIN length (8 digits)
491  * One extra byte is added for the null character.
492  */
493 //--------------------------------------------------------------------------------------------------
494 #define LE_SIM_PIN_MAX_BYTES 9
495 
496 //--------------------------------------------------------------------------------------------------
497 /**
498  * PUK length (8 digits)
499  */
500 //--------------------------------------------------------------------------------------------------
501 #define LE_SIM_PUK_MAX_LEN 8
502 
503 //--------------------------------------------------------------------------------------------------
504 /**
505  * PUK length (8 digits)
506  * One extra byte is added for the null character.
507  */
508 //--------------------------------------------------------------------------------------------------
509 #define LE_SIM_PUK_MAX_BYTES 9
510 
511 //--------------------------------------------------------------------------------------------------
512 /**
513  * ICCID length
514  * According to GSM Phase 1
515  */
516 //--------------------------------------------------------------------------------------------------
517 #define LE_SIM_ICCID_LEN 20
518 
519 //--------------------------------------------------------------------------------------------------
520 /**
521  * ICCID length
522  * One extra byte is added for the null character.
523  */
524 //--------------------------------------------------------------------------------------------------
525 #define LE_SIM_ICCID_BYTES 21
526 
527 //--------------------------------------------------------------------------------------------------
528 /**
529  * IMSI length
530  */
531 //--------------------------------------------------------------------------------------------------
532 #define LE_SIM_IMSI_LEN 15
533 
534 //--------------------------------------------------------------------------------------------------
535 /**
536  * IMSI length
537  * One extra byte is added for the null character.
538  */
539 //--------------------------------------------------------------------------------------------------
540 #define LE_SIM_IMSI_BYTES 16
541 
542 //--------------------------------------------------------------------------------------------------
543 /**
544  * APDU length
545  */
546 //--------------------------------------------------------------------------------------------------
547 #define LE_SIM_APDU_MAX_BYTES 255
548 
549 //--------------------------------------------------------------------------------------------------
550 /**
551  * SIM response length
552  */
553 //--------------------------------------------------------------------------------------------------
554 #define LE_SIM_RESPONSE_MAX_BYTES 256
555 
556 //--------------------------------------------------------------------------------------------------
557 /**
558  * SIM file identifier length
559  */
560 //--------------------------------------------------------------------------------------------------
561 #define LE_SIM_FILE_ID_LEN 4
562 
563 //--------------------------------------------------------------------------------------------------
564 /**
565  * SIM file identifier length
566  * One extra byte is added for the null character.
567  */
568 //--------------------------------------------------------------------------------------------------
569 #define LE_SIM_FILE_ID_BYTES 5
570 
571 //--------------------------------------------------------------------------------------------------
572 /**
573  * SIM data command length
574  *
575  */
576 //--------------------------------------------------------------------------------------------------
577 #define LE_SIM_DATA_MAX_BYTES 100
578 
579 //--------------------------------------------------------------------------------------------------
580 /**
581  * SIM file path length
582  */
583 //--------------------------------------------------------------------------------------------------
584 #define LE_SIM_PATH_MAX_LEN 100
585 
586 //--------------------------------------------------------------------------------------------------
587 /**
588  * SIM file path length
589  * One extra byte is added for the null character.
590  */
591 //--------------------------------------------------------------------------------------------------
592 #define LE_SIM_PATH_MAX_BYTES 101
593 
594 //--------------------------------------------------------------------------------------------------
595 /**
596  * eUICC identifier (EID) length
597  */
598 //--------------------------------------------------------------------------------------------------
599 #define LE_SIM_EID_LEN 32
600 
601 //--------------------------------------------------------------------------------------------------
602 /**
603  * eUICC identifier (EID) length
604  * One extra byte is added for the null character.
605  */
606 //--------------------------------------------------------------------------------------------------
607 #define LE_SIM_EID_BYTES 33
608 
609 //--------------------------------------------------------------------------------------------------
610 /**
611  * Reference type for FPLMN list.
612  */
613 //--------------------------------------------------------------------------------------------------
614 typedef struct le_sim_FPLMNList* le_sim_FPLMNListRef_t;
615 
616 
617 //--------------------------------------------------------------------------------------------------
618 /**
619  * SIM states.
620  *
621  */
622 //--------------------------------------------------------------------------------------------------
623 typedef enum
624 {
626  ///< SIM card is inserted and locked.
628  ///< SIM card is absent.
630  ///< SIM card is inserted and unlocked.
632  ///< SIM card is blocked.
634  ///< SIM card is busy.
636  ///< Unknown SIM state.
637 }
639 
640 
641 //--------------------------------------------------------------------------------------------------
642 /**
643  * SIM identifiers.
644  *
645  */
646 //--------------------------------------------------------------------------------------------------
647 typedef enum
648 {
650  ///< Embedded SIM
652  ///< SIM inserted in external slot 1
654  ///< SIM inserted in external slot 2
656  ///< Remote SIM
657  LE_SIM_ID_MAX = 4
658  ///<
659 }
661 
662 
663 //--------------------------------------------------------------------------------------------------
664 /**
665  * Card Manufacturer.
666  *
667  */
668 //--------------------------------------------------------------------------------------------------
669 typedef enum
670 {
672  ///< Oberthur.
674  ///< Gemalto.
676  ///< G&D.
678  ///< Morpho.
680  ///< Valid.
681  LE_SIM_MANUFACTURER_MAX = 5
682  ///<
683 }
685 
686 
687 //--------------------------------------------------------------------------------------------------
688 /**
689  * SIM commands.
690  */
691 //--------------------------------------------------------------------------------------------------
692 typedef enum
693 {
695  ///< Read a file record.
697  ///< Read a transparent elementary file.
699  ///< Update a file record.
701  ///< Update a transparent elementary file.
703  ///< Max value
704 }
706 
707 
708 //--------------------------------------------------------------------------------------------------
709 /**
710  * SIM Toolkit events.
711  */
712 //--------------------------------------------------------------------------------------------------
713 typedef enum
714 {
716  ///< SIM card asks to open a logical channel.
718  ///< SIM card asks for a refresh.
720  ///< Unknown SIM Toolkit event.
721 }
723 
724 
725 //--------------------------------------------------------------------------------------------------
726 /**
727  * SIM Toolkit Refresh modes, defined in ETSI TS 102 223 sections 6.4.7 and 8.6.
728  */
729 //--------------------------------------------------------------------------------------------------
730 typedef enum
731 {
733  ///< Initialization and Full File Change Notification.
735  ///< File Change Notification.
737  ///< Initialization and File Change Notification.
739  ///< Initialization.
741  ///< SIM reset.
743  ///< Application reset.
745  ///< Session reset.
747  ///< Steering of Roaming as defined in 3GPP TS 23.122.
749  ///< Steering of Roaming for I-WLAN
750  ///< as defined in 3GPP TS 24.234.
752  ///< eUICC Profile State Change.
754  ///< Invalid SIM Toolkit Refresh mode.
755 }
757 
758 
759 //--------------------------------------------------------------------------------------------------
760 /**
761  * SIM Toolkit Refresh stages.
762  */
763 //--------------------------------------------------------------------------------------------------
764 typedef enum
765 {
767  ///< Waiting for OK to refresh.
769  ///< Refresh succeeded.
771  ///< Refresh failed.
773  ///< Invalid SIM Toolkit Refresh stage.
774 }
776 
777 
778 //--------------------------------------------------------------------------------------------------
779 /**
780  * Reference type used by Add/Remove functions for EVENT 'le_sim_NewState'
781  */
782 //--------------------------------------------------------------------------------------------------
783 typedef struct le_sim_NewStateHandler* le_sim_NewStateHandlerRef_t;
784 
785 
786 //--------------------------------------------------------------------------------------------------
787 /**
788  * Reference type used by Add/Remove functions for EVENT 'le_sim_SimToolkitEvent'
789  */
790 //--------------------------------------------------------------------------------------------------
791 typedef struct le_sim_SimToolkitEventHandler* le_sim_SimToolkitEventHandlerRef_t;
792 
793 
794 //--------------------------------------------------------------------------------------------------
795 /**
796  * Handler for sim state changes.
797  *
798  */
799 //--------------------------------------------------------------------------------------------------
800 typedef void (*le_sim_NewStateHandlerFunc_t)
801 (
802  le_sim_Id_t simId,
803  ///< The SIM identifier.
804  le_sim_States_t simState,
805  ///< The SIM state.
806  void* contextPtr
807  ///<
808 );
809 
810 //--------------------------------------------------------------------------------------------------
811 /**
812  * Handler for Sim Toolkit Events.
813  *
814  */
815 //--------------------------------------------------------------------------------------------------
817 (
818  le_sim_Id_t simId,
819  ///< The SIM identifier.
820  le_sim_StkEvent_t stkEvent,
821  ///< The SIM state.
822  void* contextPtr
823  ///<
824 );
825 
826 //--------------------------------------------------------------------------------------------------
827 /**
828  * Add handler function for EVENT 'le_sim_NewState'
829  *
830  * This event provides information on sim state changes.
831  *
832  */
833 //--------------------------------------------------------------------------------------------------
835 (
836  le_sim_NewStateHandlerFunc_t handlerPtr,
837  ///< [IN]
838  void* contextPtr
839  ///< [IN]
840 );
841 
842 //--------------------------------------------------------------------------------------------------
843 /**
844  * Remove handler function for EVENT 'le_sim_NewState'
845  */
846 //--------------------------------------------------------------------------------------------------
848 (
849  le_sim_NewStateHandlerRef_t handlerRef
850  ///< [IN]
851 );
852 
853 //--------------------------------------------------------------------------------------------------
854 /**
855  * Add handler function for EVENT 'le_sim_SimToolkitEvent'
856  *
857  * This event provides information on Sim Toolkit application.
858  *
859  */
860 //--------------------------------------------------------------------------------------------------
862 (
864  ///< [IN]
865  void* contextPtr
866  ///< [IN]
867 );
868 
869 //--------------------------------------------------------------------------------------------------
870 /**
871  * Remove handler function for EVENT 'le_sim_SimToolkitEvent'
872  */
873 //--------------------------------------------------------------------------------------------------
875 (
877  ///< [IN]
878 );
879 
880 //--------------------------------------------------------------------------------------------------
881 /**
882  * Get the current selected card.
883  *
884  * @return Number of the current selected SIM card.
885  */
886 //--------------------------------------------------------------------------------------------------
888 (
889  void
890 );
891 
892 //--------------------------------------------------------------------------------------------------
893 /**
894  * Select a SIM.
895  *
896  * @return LE_FAULT Function failed to select the requested SIM
897  * @return LE_OK Function succeeded.
898  *
899  */
900 //--------------------------------------------------------------------------------------------------
902 (
903  le_sim_Id_t simId
904  ///< [IN] The SIM identifier.
905 );
906 
907 //--------------------------------------------------------------------------------------------------
908 /**
909  * Retrieves the integrated circuit card identifier (ICCID) of the SIM card (20 digits)
910  *
911  * @return LE_OK ICCID was successfully retrieved.
912  * @return LE_OVERFLOW iccidPtr buffer was too small for the ICCID.
913  * @return LE_BAD_PARAMETER Invalid parameters.
914  * @return LE_FAULT The ICCID could not be retrieved.
915  *
916  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
917  * function will not return.
918  */
919 //--------------------------------------------------------------------------------------------------
921 (
922  le_sim_Id_t simId,
923  ///< [IN] The SIM identifier.
924  char* iccid,
925  ///< [OUT] ICCID
926  size_t iccidSize
927  ///< [IN]
928 );
929 
930 //--------------------------------------------------------------------------------------------------
931 /**
932  * Retrieves the identifier for the embedded Universal Integrated Circuit Card identifier (EID)
933  * (32 digits)
934  *
935  * @return LE_OK EID was successfully retrieved.
936  * @return LE_OVERFLOW eidPtr buffer was too small for the EID.
937  * @return LE_BAD_PARAMETER Invalid parameters.
938  * @return LE_FAULT The EID could not be retrieved.
939  *
940  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
941  * function will not return.
942  *
943  * @warning le_sim_GetEID() function is platform dependent. Please refer to the
944  * @ref platformConstraintsSim_EID section for full details.
945  */
946 //--------------------------------------------------------------------------------------------------
948 (
949  le_sim_Id_t simId,
950  ///< [IN] The SIM identifier.
951  char* eid,
952  ///< [OUT] EID
953  size_t eidSize
954  ///< [IN]
955 );
956 
957 //--------------------------------------------------------------------------------------------------
958 /**
959  * Retrieves the identification number (IMSI) of the SIM card. (max 15 digits)
960  *
961  * @return LE_OVERFLOW The imsiPtr buffer was too small for the IMSI.
962  * @return LE_BAD_PARAMETER The parameters are invalid.
963  * @return LE_FAULT The function failed.
964  * @return LE_TIMEOUT No response was received.
965  * @return LE_OK The function succeeded.
966  *
967  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
968  * function will not return.
969  */
970 //--------------------------------------------------------------------------------------------------
972 (
973  le_sim_Id_t simId,
974  ///< [IN] The SIM identifier.
975  char* imsi,
976  ///< [OUT] IMSI
977  size_t imsiSize
978  ///< [IN]
979 );
980 
981 //--------------------------------------------------------------------------------------------------
982 /**
983  * Verify if the SIM card is present or not.
984  *
985  * @return true SIM card is present.
986  * @return false SIM card is absent
987  *
988  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
989  * function will not return.
990  */
991 //--------------------------------------------------------------------------------------------------
992 bool le_sim_IsPresent
993 (
994  le_sim_Id_t simId
995  ///< [IN] The SIM identifier.
996 );
997 
998 //--------------------------------------------------------------------------------------------------
999 /**
1000  * Verify if the SIM is ready (PIN code correctly inserted or not
1001  * required).
1002  *
1003  * @return true PIN is correctly inserted or not required.
1004  * @return false PIN must be inserted
1005  *
1006  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1007  * function will not return.
1008  */
1009 //--------------------------------------------------------------------------------------------------
1010 bool le_sim_IsReady
1011 (
1012  le_sim_Id_t simId
1013  ///< [IN] The SIM identifier.
1014 );
1015 
1016 //--------------------------------------------------------------------------------------------------
1017 /**
1018  * This function must be called to enter the PIN code.
1019  *
1020  * @return LE_BAD_PARAMETER The parameters are invalid.
1021  * @return LE_NOT_FOUND The function failed to select the SIM card for this operation.
1022  * @return LE_UNDERFLOW The PIN code is not long enough (min 4 digits).
1023  * @return LE_FAULT The function failed to enter the PIN code.
1024  * @return LE_OK The function succeeded.
1025  *
1026  * @note If PIN code is too long (max 8 digits), it is a fatal error, the
1027  * function will not return.
1028  *
1029  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1030  * function will not return.
1031  */
1032 //--------------------------------------------------------------------------------------------------
1034 (
1035  le_sim_Id_t simId,
1036  ///< [IN] The SIM identifier.
1037  const char* LE_NONNULL pin
1038  ///< [IN] The PIN code.
1039 );
1040 
1041 //--------------------------------------------------------------------------------------------------
1042 /**
1043  * Change the PIN code.
1044  *
1045  * @return LE_NOT_FOUND Function failed to select the SIM card for this operation.
1046  * @return LE_UNDERFLOW PIN code is/are not long enough (min 4 digits).
1047  * @return LE_FAULT Function failed to change the PIN code.
1048  * @return LE_OK Function succeeded.
1049  *
1050  * @note If PIN code is too long (max 8 digits), it is a fatal error, the
1051  * function will not return.
1052  *
1053  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1054  * function will not return.
1055  */
1056 //--------------------------------------------------------------------------------------------------
1058 (
1059  le_sim_Id_t simId,
1060  ///< [IN] The SIM identifier.
1061  const char* LE_NONNULL oldpin,
1062  ///< [IN] The old PIN code.
1063  const char* LE_NONNULL newpin
1064  ///< [IN] The new PIN code.
1065 );
1066 
1067 //--------------------------------------------------------------------------------------------------
1068 /**
1069  * Get the number of remaining PIN insertion tries.
1070  *
1071  * @return LE_NOT_FOUND The function failed to select the SIM card for this operation.
1072  * @return LE_BAD_PARAMETER Invalid SIM identifier.
1073  * @return LE_FAULT The function failed to get the number of remaining PIN insertion tries.
1074  * @return A positive value The function succeeded. The number of remaining PIN insertion tries.
1075  *
1076  */
1077 //--------------------------------------------------------------------------------------------------
1079 (
1080  le_sim_Id_t simId
1081  ///< [IN] The SIM identifier.
1082 );
1083 
1084 //--------------------------------------------------------------------------------------------------
1085 /**
1086  * Get the number of remaining PUK insertion tries.
1087  *
1088  * @return LE_OK On success.
1089  * @return LE_NOT_FOUND The function failed to select the SIM card for this operation.
1090  * @return LE_BAD_PARAMETER Invalid SIM identifier.
1091  * @return LE_FAULT The function failed to get the number of remaining PUK insertion tries.
1092  *
1093  * @note If the caller is passing an null pointer to this function, it is a fatal error
1094  * and the function will not return.
1095  *
1096  */
1097 //--------------------------------------------------------------------------------------------------
1099 (
1100  le_sim_Id_t simId,
1101  ///< [IN] The SIM identifier.
1102  uint32_t* remainingPukTriesPtrPtr
1103  ///< [OUT] The number of remaining PUK insertion tries.
1104 );
1105 
1106 //--------------------------------------------------------------------------------------------------
1107 /**
1108  * Unlock the SIM card: it disables the request of the PIN code.
1109  *
1110  * @return LE_NOT_FOUND Function failed to select the SIM card for this operation.
1111  * @return LE_UNDERFLOW PIN code is not long enough (min 4 digits).
1112  * @return LE_FAULT The function failed to unlock the SIM card.
1113  * @return LE_OK Function succeeded.
1114  *
1115  * @note If PIN code is too long (max 8 digits), it is a fatal error, the
1116  * function will not return.
1117  *
1118  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1119  * function will not return.
1120  */
1121 //--------------------------------------------------------------------------------------------------
1123 (
1124  le_sim_Id_t simId,
1125  ///< [IN] The SIM identifier.
1126  const char* LE_NONNULL pin
1127  ///< [IN] The PIN code.
1128 );
1129 
1130 //--------------------------------------------------------------------------------------------------
1131 /**
1132  * Lock the SIM card: it enables the request of the PIN code.
1133  *
1134  * @return LE_NOT_FOUND Function failed to select the SIM card for this operation.
1135  * @return LE_UNDERFLOW PIN code is not long enough (min 4 digits).
1136  * @return LE_FAULT The function failed to unlock the SIM card.
1137  * @return LE_OK Function succeeded.
1138  *
1139  * @note If PIN code is too long (max 8 digits), it is a fatal error, the
1140  * function will not return.
1141  *
1142  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1143  * function will not return.
1144  */
1145 //--------------------------------------------------------------------------------------------------
1147 (
1148  le_sim_Id_t simId,
1149  ///< [IN] The SIM identifier.
1150  const char* LE_NONNULL pin
1151  ///< [IN] The PIN code.
1152 );
1153 
1154 //--------------------------------------------------------------------------------------------------
1155 /**
1156  * Unblock the SIM card.
1157  *
1158  * @return LE_NOT_FOUND Function failed to select the SIM card for this operation.
1159  * @return LE_UNDERFLOW PIN code is not long enough (min 4 digits).
1160  * @return LE_BAD_PARAMETER Invalid SIM identifier.
1161  * @return LE_OUT_OF_RANGE PUK code length is not correct (8 digits).
1162  * @return LE_FAULT The function failed to unlock the SIM card.
1163  * @return LE_OK Function succeeded.
1164  *
1165  * @note If new PIN or puk code are too long (max 8 digits), it is a fatal error, the
1166  * function will not return.
1167  *
1168  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1169  * function will not return.
1170  */
1171 //--------------------------------------------------------------------------------------------------
1173 (
1174  le_sim_Id_t simId,
1175  ///< [IN] The SIM identifier.
1176  const char* LE_NONNULL puk,
1177  ///< [IN] The PUK code.
1178  const char* LE_NONNULL newpin
1179  ///< [IN] The PIN code.
1180 );
1181 
1182 //--------------------------------------------------------------------------------------------------
1183 /**
1184  * Get the SIM state.
1185  *
1186  * @return Current SIM state.
1187  *
1188  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1189  * function will not return.
1190  */
1191 //--------------------------------------------------------------------------------------------------
1193 (
1194  le_sim_Id_t simId
1195  ///< [IN] The SIM identifier.
1196 );
1197 
1198 //--------------------------------------------------------------------------------------------------
1199 /**
1200  * Get the SIM Phone Number.
1201  *
1202  * @return
1203  * - LE_OK on success
1204  * - LE_OVERFLOW if the Phone Number can't fit in phoneNumberStr
1205  * - LE_BAD_PARAMETER if a parameter is invalid
1206  * - LE_FAULT on any other failure
1207  *
1208  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1209  * function will not return.
1210  */
1211 //--------------------------------------------------------------------------------------------------
1213 (
1214  le_sim_Id_t simId,
1215  ///< [IN] The SIM identifier.
1216  char* phoneNumberStr,
1217  ///< [OUT] The phone Number.
1218  size_t phoneNumberStrSize
1219  ///< [IN]
1220 );
1221 
1222 //--------------------------------------------------------------------------------------------------
1223 /**
1224  * This function must be called to get the Home Network Name information.
1225  *
1226  * @return
1227  * - LE_OK on success
1228  * - LE_OVERFLOW if the Home Network Name can't fit in nameStr
1229  * - LE_BAD_PARAMETER if a parameter is invalid
1230  * - LE_FAULT on any other failure
1231  *
1232  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1233  * function will not return.
1234  *
1235  * @note The home network name can be given even if the device is not registered on the network.
1236  */
1237 //--------------------------------------------------------------------------------------------------
1239 (
1240  le_sim_Id_t simId,
1241  ///< [IN] The SIM identifier.
1242  char* nameStr,
1243  ///< [OUT] the home network Name
1244  size_t nameStrSize
1245  ///< [IN]
1246 );
1247 
1248 //--------------------------------------------------------------------------------------------------
1249 /**
1250  * This function must be called to get the Home Network MCC MNC.
1251  *
1252  * @return
1253  * - LE_OK on success
1254  * - LE_NOT_FOUND if Home Network has not been provisioned
1255  * - LE_FAULT for unexpected error
1256  *
1257  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1258  * function will not return.
1259  */
1260 //--------------------------------------------------------------------------------------------------
1262 (
1263  le_sim_Id_t simId,
1264  ///< [IN] The SIM identifier.
1265  char* mccPtr,
1266  ///< [OUT] Mobile Country Code
1267  size_t mccPtrSize,
1268  ///< [IN]
1269  char* mncPtr,
1270  ///< [OUT] Mobile Network Code
1271  size_t mncPtrSize
1272  ///< [IN]
1273 );
1274 
1275 //--------------------------------------------------------------------------------------------------
1276 /**
1277  * This function must be called to request the multi-profile eUICC to swap to ECS and to refresh.
1278  * The User's application must wait for eUICC reboot to be finished and network connection
1279  * available.
1280  *
1281  * @return
1282  * - LE_OK on success
1283  * - LE_BAD_PARAMETER invalid SIM identifier
1284  * - LE_BUSY when a profile swap is already in progress
1285  * - LE_FAULT for unexpected error
1286  *
1287  * @warning If you use a Morpho or Oberthur card, the SIM_REFRESH PRO-ACTIVE command must be
1288  * accepted with le_sim_AcceptSimToolkitCommand() in order to complete the profile swap
1289  * procedure.
1290  */
1291 //--------------------------------------------------------------------------------------------------
1293 (
1294  le_sim_Id_t simId,
1295  ///< [IN] The SIM identifier.
1296  le_sim_Manufacturer_t manufacturer
1297  ///< [IN] The card manufacturer.
1298 );
1299 
1300 //--------------------------------------------------------------------------------------------------
1301 /**
1302  * This function must be called to request the multi-profile eUICC to swap back to commercial
1303  * subscription and to refresh.
1304  * The User's application must wait for eUICC reboot to be finished and network connection
1305  * available.
1306  *
1307  * @return
1308  * - LE_OK on success
1309  * - LE_BAD_PARAMETER invalid SIM identifier
1310  * - LE_BUSY when a profile swap is already in progress
1311  * - LE_FAULT for unexpected error
1312  *
1313  * @warning If you use a Morpho or Oberthur card, the SIM_REFRESH PRO-ACTIVE command must be
1314  * accepted with le_sim_AcceptSimToolkitCommand() in order to complete the profile swap
1315  * procedure.
1316  */
1317 //--------------------------------------------------------------------------------------------------
1319 (
1320  le_sim_Id_t simId,
1321  ///< [IN] The SIM identifier.
1322  le_sim_Manufacturer_t manufacturer
1323  ///< [IN] The card manufacturer.
1324 );
1325 
1326 //--------------------------------------------------------------------------------------------------
1327 /**
1328  * This function must be called to get the current subscription.
1329  *
1330  * @return
1331  * - LE_OK on success
1332  * - LE_BAD_PARAMETER invalid SIM identifier or null ECS pointer is passed
1333  * - LE_NOT_FOUND cannot determine the current selected subscription
1334  * - LE_FAULT for unexpected errors
1335  *
1336  * @warning There is no standard method to interrogate the current selected subscription. The
1337  * returned value of this function is based on the last executed local swap command. This means
1338  * that this function will always return LE_NOT_FOUND error at Legato startup.
1339  */
1340 //--------------------------------------------------------------------------------------------------
1342 (
1343  le_sim_Id_t simId,
1344  ///< [IN] The SIM identifier
1345  bool* isEcsPtr
1346  ///< [OUT] true if Emergency Call Subscription (ECS) is selected,
1347  ///< false if Commercial Subscription is selected
1348 );
1349 
1350 //--------------------------------------------------------------------------------------------------
1351 /**
1352  * Accept the last SIM Toolkit command.
1353  *
1354  * @return
1355  * - LE_OK The function succeeded.
1356  * - LE_FAULT The function failed.
1357  */
1358 //--------------------------------------------------------------------------------------------------
1360 (
1361  le_sim_Id_t simId
1362  ///< [IN] The SIM identifier.
1363 );
1364 
1365 //--------------------------------------------------------------------------------------------------
1366 /**
1367  * Reject the last SIM Toolkit command.
1368  *
1369  * @return
1370  * - LE_OK The function succeeded.
1371  * - LE_FAULT The function failed.
1372  */
1373 //--------------------------------------------------------------------------------------------------
1375 (
1376  le_sim_Id_t simId
1377  ///< [IN] The SIM identifier.
1378 );
1379 
1380 //--------------------------------------------------------------------------------------------------
1381 /**
1382  * Retrieve the mode of the last SIM Toolkit Refresh command.
1383  * The modes are defined in ETSI TS 102 223 sections 6.4.7 and 8.6.
1384  *
1385  * @return
1386  * - LE_OK The function succeeded.
1387  * - LE_BAD_PARAMETER A parameter is invalid.
1388  * - LE_UNAVAILABLE The last SIM Toolkit command is not a Refresh command.
1389  * - LE_FAULT The function failed.
1390  * - LE_UNSUPPORTED The platform does not support this operation.
1391  */
1392 //--------------------------------------------------------------------------------------------------
1394 (
1395  le_sim_Id_t simId,
1396  ///< [IN] The SIM identifier.
1397  le_sim_StkRefreshMode_t* refreshModePtr
1398  ///< [OUT] The Refresh mode.
1399 );
1400 
1401 //--------------------------------------------------------------------------------------------------
1402 /**
1403  * Retrieve the stage of the last SIM Toolkit Refresh command.
1404  *
1405  * @return
1406  * - LE_OK The function succeeded.
1407  * - LE_BAD_PARAMETER A parameter is invalid.
1408  * - LE_UNAVAILABLE The last SIM Toolkit command is not a Refresh command.
1409  * - LE_FAULT The function failed.
1410  */
1411 //--------------------------------------------------------------------------------------------------
1413 (
1414  le_sim_Id_t simId,
1415  ///< [IN] The SIM identifier.
1416  le_sim_StkRefreshStage_t* refreshStagePtr
1417  ///< [OUT] The Refresh stage.
1418 );
1419 
1420 //--------------------------------------------------------------------------------------------------
1421 /**
1422  * Send APDU command to the SIM.
1423  *
1424  * @return
1425  * - LE_OK Function succeeded.
1426  * - LE_FAULT The function failed.
1427  * - LE_BAD_PARAMETER A parameter is invalid.
1428  * - LE_NOT_FOUND The function failed to select the SIM card for this operation.
1429  */
1430 //--------------------------------------------------------------------------------------------------
1432 (
1433  le_sim_Id_t simId,
1434  ///< [IN] The SIM identifier.
1435  const uint8_t* commandApduPtr,
1436  ///< [IN] APDU command.
1437  size_t commandApduSize,
1438  ///< [IN]
1439  uint8_t* responseApduPtr,
1440  ///< [OUT] SIM response.
1441  size_t* responseApduSizePtr
1442  ///< [INOUT]
1443 );
1444 
1445 //--------------------------------------------------------------------------------------------------
1446 /**
1447  * Send a command to the SIM.
1448  *
1449  * @return
1450  * - LE_OK Function succeeded.
1451  * - LE_FAULT The function failed.
1452  * - LE_BAD_PARAMETER A parameter is invalid.
1453  * - LE_NOT_FOUND - The function failed to select the SIM card for this operation
1454  * - The requested SIM file is not found
1455  * - LE_OVERFLOW Response buffer is too small to copy the SIM answer.
1456  * - LE_UNSUPPORTED The platform does not support this operation.
1457  */
1458 //--------------------------------------------------------------------------------------------------
1460 (
1461  le_sim_Id_t simId,
1462  ///< [IN] The SIM identifier.
1463  le_sim_Command_t command,
1464  ///< [IN] The SIM command.
1465  const char* LE_NONNULL fileIdentifier,
1466  ///< [IN] File identifier
1467  uint8_t p1,
1468  ///< [IN] Parameter P1 passed to the SIM
1469  uint8_t p2,
1470  ///< [IN] Parameter P2 passed to the SIM
1471  uint8_t p3,
1472  ///< [IN] Parameter P3 passed to the SIM
1473  const uint8_t* dataPtr,
1474  ///< [IN] data command.
1475  size_t dataSize,
1476  ///< [IN]
1477  const char* LE_NONNULL path,
1478  ///< [IN] path of the elementary file
1479  uint8_t* sw1Ptr,
1480  ///< [OUT] Status Word 1 received from the SIM
1481  uint8_t* sw2Ptr,
1482  ///< [OUT] Status Word 2 received from the SIM
1483  uint8_t* responsePtr,
1484  ///< [OUT] SIM response.
1485  size_t* responseSizePtr
1486  ///< [INOUT]
1487 );
1488 
1489 //--------------------------------------------------------------------------------------------------
1490 /**
1491  * Reset the SIM.
1492  *
1493  * @return
1494  * - LE_FAULT Function failed.
1495  * - LE_OK Function succeeded.
1496  */
1497 //--------------------------------------------------------------------------------------------------
1499 (
1500  le_sim_Id_t simId
1501  ///< [IN] The SIM identifier.
1502 );
1503 
1504 //--------------------------------------------------------------------------------------------------
1505 /**
1506  * Create empty FPLMN list to insert FPLMN operators.
1507  *
1508  * @return
1509  * - Reference to the List object.
1510  * - Null pointer if not able to create list reference.
1511  */
1512 //--------------------------------------------------------------------------------------------------
1514 (
1515  void
1516 );
1517 
1518 //--------------------------------------------------------------------------------------------------
1519 /**
1520  * Add FPLMN network into the newly created FPLMN list.
1521  * If the FPLMNListRef, mcc or mnc is not valid then this function will kill the calling client.
1522  *
1523  * @return
1524  * - LE_FAULT Function failed.
1525  * - LE_OK Function succeeded.
1526  * - LE_OVERFLOW If FPLMN operator can not be inserted into FPLMN list.
1527  */
1528 //--------------------------------------------------------------------------------------------------
1530 (
1531  le_sim_FPLMNListRef_t FPLMNListRef,
1532  ///< [IN] FPLMN list reference.
1533  const char* LE_NONNULL mcc,
1534  ///< [IN] Mobile Country Code.
1535  const char* LE_NONNULL mnc
1536  ///< [IN] Mobile Network Code.
1537 );
1538 
1539 //--------------------------------------------------------------------------------------------------
1540 /**
1541  * Write FPLMN list into the SIM.
1542  * If the FPLMNListRef is not valid then this function will kill the calling client.
1543  *
1544  * @return
1545  * - LE_FAULT Function failed.
1546  * - LE_OK Function succeeded.
1547  *
1548  */
1549 //--------------------------------------------------------------------------------------------------
1551 (
1552  le_sim_Id_t simId,
1553  ///< [IN] The SIM identifier.
1554  le_sim_FPLMNListRef_t FPLMNListRef
1555  ///< [IN] FPLMN list reference.
1556 );
1557 
1558 //--------------------------------------------------------------------------------------------------
1559 /**
1560  * Read FPLMN list from the SIM.
1561  *
1562  * @return
1563  * - Reference to the List object.
1564  * - Null pointer if FPLMN list is not able to read from the SIM.
1565  */
1566 //--------------------------------------------------------------------------------------------------
1568 (
1569  le_sim_Id_t simId
1570  ///< [IN] The SIM identifier.
1571 );
1572 
1573 //--------------------------------------------------------------------------------------------------
1574 /**
1575  * Read the first FPLMN network from the list of FPLMN objects retrieved with
1576  * le_sim_ReadFPLMNList().
1577  * If the FPLMNListRef, mccPtr or mncPtr is not valid then this function will kill the calling
1578  * client.
1579  *
1580  * @return
1581  * - LE_FAULT Function failed.
1582  * - LE_OK Function succeeded.
1583  * - LE_OVERFLOW MCC/MNC string size is greater than string length parameter which has
1584  * been given into this function.
1585  */
1586 //--------------------------------------------------------------------------------------------------
1588 (
1589  le_sim_FPLMNListRef_t FPLMNListRef,
1590  ///< [IN] FPLMN list reference.
1591  char* mccPtr,
1592  ///< [OUT] Mobile Country Code.
1593  size_t mccPtrSize,
1594  ///< [IN]
1595  char* mncPtr,
1596  ///< [OUT] Mobile Network Code.
1597  size_t mncPtrSize
1598  ///< [IN]
1599 );
1600 
1601 //--------------------------------------------------------------------------------------------------
1602 /**
1603  * Read the next FPLMN network from the list of FPLMN objects retrieved with le_sim_ReadFPLMNList().
1604  * If the FPLMNListRef, mccPtr or mncPtr is not valid then this function will kill the calling
1605  * client.
1606  *
1607  * @return
1608  * - LE_FAULT Function failed.
1609  * - LE_OK Function succeeded.
1610  * - LE_OVERFLOW MCC/MNC string size is greater than string length parameter which has
1611  * been given into this function.
1612  */
1613 //--------------------------------------------------------------------------------------------------
1615 (
1616  le_sim_FPLMNListRef_t FPLMNListRef,
1617  ///< [IN] FPLMN list reference.
1618  char* mccPtr,
1619  ///< [OUT] Mobile Country Code.
1620  size_t mccPtrSize,
1621  ///< [IN]
1622  char* mncPtr,
1623  ///< [OUT] Mobile Network Code.
1624  size_t mncPtrSize
1625  ///< [IN]
1626 );
1627 
1628 //--------------------------------------------------------------------------------------------------
1629 /**
1630  * Delete the FPLMN list created by le_sim_ReadFPLMNList() or le_sim_CreateFPLMNList().
1631  * If the FPLMNListRef is not valid then this function will kill the calling client.
1632  *
1633  * @note
1634  * On failure, the process exits, so you don't have to worry about checking the returned
1635  * reference for validity.
1636  */
1637 //--------------------------------------------------------------------------------------------------
1639 (
1640  le_sim_FPLMNListRef_t FPLMNListRef
1641  ///< [IN] FPLMN list reference.
1642 );
1643 
1644 //--------------------------------------------------------------------------------------------------
1645 /**
1646  * Open a logical channel on the SIM card.
1647  *
1648  * @return
1649  * - LE_OK Function succeeded.
1650  * - LE_BAD_PARAMETER Invalid parameter.
1651  * - LE_FAULT Function failed.
1652  */
1653 //--------------------------------------------------------------------------------------------------
1655 (
1656  uint8_t* channelPtrPtr
1657  ///< [OUT] The number of the opened logical channel.
1658 );
1659 
1660 //--------------------------------------------------------------------------------------------------
1661 /**
1662  * Close a logical channel on the SIM card.
1663  *
1664  * @return
1665  * - LE_OK Function succeeded.
1666  * - LE_FAULT Function failed.
1667  */
1668 //--------------------------------------------------------------------------------------------------
1670 (
1671  uint8_t channel
1672  ///< [IN] The number of the logical channel to close.
1673 );
1674 
1675 //--------------------------------------------------------------------------------------------------
1676 /**
1677  * Send APDU command on a dedicated logical channel.
1678  *
1679  * @return
1680  * - LE_OK Function succeeded.
1681  * - LE_BAD_PARAMETER A parameter is invalid.
1682  * - LE_NOT_FOUND The function failed to select the SIM card for this operation.
1683  * - LE_FAULT The function failed.
1684  */
1685 //--------------------------------------------------------------------------------------------------
1687 (
1688  le_sim_Id_t simId,
1689  ///< [IN] The SIM identifier.
1690  uint8_t channel,
1691  ///< [IN] The logical channel number.
1692  const uint8_t* commandApduPtr,
1693  ///< [IN] APDU command.
1694  size_t commandApduSize,
1695  ///< [IN]
1696  uint8_t* responseApduPtr,
1697  ///< [OUT] SIM response.
1698  size_t* responseApduSizePtr
1699  ///< [INOUT]
1700 );
1701 
1702 #endif // LE_SIM_INTERFACE_H_INCLUDE_GUARD
le_sim_NewStateHandlerRef_t le_sim_AddNewStateHandler(le_sim_NewStateHandlerFunc_t handlerPtr, void *contextPtr)
Read a transparent elementary file.
Definition: le_sim_interface.h:696
bool le_sim_IsPresent(le_sim_Id_t simId)
le_result_t le_sim_GetHomeNetworkOperator(le_sim_Id_t simId, char *nameStr, size_t nameStrSize)
le_sim_Id_t
Definition: le_sim_interface.h:647
le_result_t le_sim_GetRemainingPUKTries(le_sim_Id_t simId, uint32_t *remainingPukTriesPtrPtr)
void(* le_sim_SimToolkitEventHandlerFunc_t)(le_sim_Id_t simId, le_sim_StkEvent_t stkEvent, void *contextPtr)
Definition: le_sim_interface.h:817
Initialization and Full File Change Notification.
Definition: le_sim_interface.h:732
Invalid SIM Toolkit Refresh mode.
Definition: le_sim_interface.h:753
le_result_t
Definition: le_basics.h:35
File Change Notification.
Definition: le_sim_interface.h:734
le_result_t le_sim_LocalSwapToEmergencyCallSubscription(le_sim_Id_t simId, le_sim_Manufacturer_t manufacturer)
le_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_SendApdu(le_sim_Id_t simId, const uint8_t *commandApduPtr, size_t commandApduSize, uint8_t *responseApduPtr, size_t *responseApduSizePtr)
SIM card is busy.
Definition: le_sim_interface.h:633
le_sim_StkEvent_t
Definition: le_sim_interface.h:713
le_result_t le_sim_GetHomeNetworkMccMnc(le_sim_Id_t simId, char *mccPtr, size_t mccPtrSize, char *mncPtr, size_t mncPtrSize)
Update a transparent elementary file.
Definition: le_sim_interface.h:700
Refresh succeeded.
Definition: le_sim_interface.h:768
le_result_t le_sim_GetFirstFPLMNOperator(le_sim_FPLMNListRef_t FPLMNListRef, char *mccPtr, size_t mccPtrSize, char *mncPtr, size_t mncPtrSize)
Initialization.
Definition: le_sim_interface.h:738
le_result_t le_sim_OpenLogicalChannel(uint8_t *channelPtrPtr)
le_result_t le_sim_GetSimToolkitRefreshMode(le_sim_Id_t simId, le_sim_StkRefreshMode_t *refreshModePtr)
Embedded SIM.
Definition: le_sim_interface.h:649
Oberthur.
Definition: le_sim_interface.h:671
le_sim_States_t
Definition: le_sim_interface.h:623
struct le_sim_SimToolkitEventHandler * le_sim_SimToolkitEventHandlerRef_t
Definition: le_sim_interface.h:791
Steering of Roaming as defined in 3GPP TS 23.122.
Definition: le_sim_interface.h:746
SIM card is absent.
Definition: le_sim_interface.h:627
SIM card is inserted and locked.
Definition: le_sim_interface.h:625
Read a file record.
Definition: le_sim_interface.h:694
void(* le_sim_NewStateHandlerFunc_t)(le_sim_Id_t simId, le_sim_States_t simState, void *contextPtr)
Definition: le_sim_interface.h:801
le_result_t le_sim_GetICCID(le_sim_Id_t simId, char *iccid, size_t iccidSize)
void le_sim_SetServerDisconnectHandler(le_sim_DisconnectHandler_t disconnectHandler, 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_AcceptSimToolkitCommand(le_sim_Id_t simId)
Session reset.
Definition: le_sim_interface.h:744
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_sim_FPLMNListRef_t le_sim_ReadFPLMNList(le_sim_Id_t simId)
Max value.
Definition: le_sim_interface.h:702
Waiting for OK to refresh.
Definition: le_sim_interface.h:766
Unknown SIM Toolkit event.
Definition: le_sim_interface.h:719
void le_sim_ConnectService(void)
Refresh failed.
Definition: le_sim_interface.h:770
SIM card asks to open a logical channel.
Definition: le_sim_interface.h:715
le_result_t le_sim_GetIMSI(le_sim_Id_t simId, char *imsi, size_t imsiSize)
Definition: le_sim_interface.h:748
Gemalto.
Definition: le_sim_interface.h:673
Invalid SIM Toolkit Refresh stage.
Definition: le_sim_interface.h:772
SIM card asks for a refresh.
Definition: le_sim_interface.h:717
le_result_t le_sim_CloseLogicalChannel(uint8_t channel)
SIM inserted in external slot 1.
Definition: le_sim_interface.h:651
void le_sim_DisconnectService(void)
struct le_sim_NewStateHandler * le_sim_NewStateHandlerRef_t
Definition: le_sim_interface.h:783
void le_sim_DeleteFPLMNList(le_sim_FPLMNListRef_t FPLMNListRef)
le_result_t le_sim_Reset(le_sim_Id_t simId)
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_WriteFPLMNList(le_sim_Id_t simId, le_sim_FPLMNListRef_t FPLMNListRef)
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_SelectCard(le_sim_Id_t simId)
le_sim_Manufacturer_t
Definition: le_sim_interface.h:669
le_result_t le_sim_GetEID(le_sim_Id_t simId, char *eid, size_t eidSize)
void(* le_sim_DisconnectHandler_t)(void *)
Definition: le_sim_interface.h:397
le_sim_StkRefreshStage_t
Definition: le_sim_interface.h:764
Remote SIM.
Definition: le_sim_interface.h:655
Valid.
Definition: le_sim_interface.h:679
le_result_t le_sim_GetSimToolkitRefreshStage(le_sim_Id_t simId, le_sim_StkRefreshStage_t *refreshStagePtr)
int32_t le_sim_GetRemainingPINTries(le_sim_Id_t simId)
le_sim_FPLMNListRef_t le_sim_CreateFPLMNList(void)
eUICC Profile State Change.
Definition: le_sim_interface.h:751
bool le_sim_IsReady(le_sim_Id_t simId)
le_sim_SimToolkitEventHandlerRef_t le_sim_AddSimToolkitEventHandler(le_sim_SimToolkitEventHandlerFunc_t handlerPtr, void *contextPtr)
void le_sim_RemoveSimToolkitEventHandler(le_sim_SimToolkitEventHandlerRef_t handlerRef)
void le_sim_RemoveNewStateHandler(le_sim_NewStateHandlerRef_t handlerRef)
le_sim_StkRefreshMode_t
Definition: le_sim_interface.h:730
le_result_t le_sim_RejectSimToolkitCommand(le_sim_Id_t simId)
struct le_sim_FPLMNList * le_sim_FPLMNListRef_t
Definition: le_sim_interface.h:614
le_result_t le_sim_GetSubscriberPhoneNumber(le_sim_Id_t simId, char *phoneNumberStr, size_t phoneNumberStrSize)
SIM card is blocked.
Definition: le_sim_interface.h:631
le_result_t le_sim_Unblock(le_sim_Id_t simId, const char *LE_NONNULL puk, const char *LE_NONNULL newpin)
SIM reset.
Definition: le_sim_interface.h:740
le_result_t le_sim_IsEmergencyCallSubscriptionSelected(le_sim_Id_t simId, bool *isEcsPtr)
G&D.
Definition: le_sim_interface.h:675
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)
Application reset.
Definition: le_sim_interface.h:742
Initialization and File Change Notification.
Definition: le_sim_interface.h:736
Morpho.
Definition: le_sim_interface.h:677
le_sim_Command_t
Definition: le_sim_interface.h:692
le_sim_Id_t le_sim_GetSelectedCard(void)
le_result_t le_sim_EnterPIN(le_sim_Id_t simId, const char *LE_NONNULL pin)
le_sim_States_t le_sim_GetState(le_sim_Id_t simId)
le_result_t le_sim_LocalSwapToCommercialSubscription(le_sim_Id_t simId, le_sim_Manufacturer_t manufacturer)
SIM inserted in external slot 2.
Definition: le_sim_interface.h:653
le_result_t le_sim_TryConnectService(void)
Unknown SIM state.
Definition: le_sim_interface.h:635
SIM card is inserted and unlocked.
Definition: le_sim_interface.h:629
Update a file record.
Definition: le_sim_interface.h:698