le_sim_interface.h

Go to the documentation of this file.
1 /*
2  * ====================== WARNING ======================
3  *
4  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
5  * DO NOT MODIFY IN ANY WAY.
6  *
7  * ====================== WARNING ======================
8  */
9 
10 /**
11  * @page c_sim SIM
12  *
13  * @ref le_sim_interface.h "API Reference"
14  *
15  * <HR>
16  *
17  * This file contains prototype definitions for SIM API.
18  *
19  * A subscriber identity module or subscriber identification module (SIM) is an integrated circuit
20  * that securely stores the international mobile subscriber identity (IMSI) and related key used
21  * to identify and authenticate subscribers on M2M devices.
22  *
23  * Most SIM cards can store a number of SMS messages and phone book contacts.
24  *
25  * le_sim_GetSelectedCard() returns the selected SIM card number.
26  *
27  * @section le_sim_binding IPC interfaces binding
28  *
29  * All the functions of this API are provided by the @b modemService.
30  *
31  * Here's a code sample binding to modem services:
32  * @verbatim
33  bindings:
34  {
35  clientExe.clientComponent.le_sim -> modemService.le_sim
36  }
37  @endverbatim
38  *
39  *
40  * @section le_sim_SelectCard Select a card to use
41  * le_sim_SelectCard() function is used to select the SIM. By default, the SIM in slot 1 is used.
42  * @note The SIM selection is not reset persistent; this function has to be called at each start-up.
43  *
44  * @note: It is recommended to wait for a SIM handler notification after a new SIM selection before
45  * calling le_sim API functions.
46  *
47  * A sample code can be seen in the following page:
48  * - @subpage c_simTestSelect
49  *
50  * @section le_sim_id SIM identification information
51  * \b ICCID:
52  * Each SIM is internationally identified by its integrated circuit card identifier (ICCID). ICCIDs
53  * are stored in the SIM cards and engraved or printed on the SIM card body.
54  * The ICCID is defined by the ITU-T recommendation E.118 as the
55  * Primary Account Number. According to E.118, the number is up to 19 digits long, including a
56  * single check digit calculated using the Luhn algorithm. However, the GSM Phase 1 (ETSI
57  * Recommendation GSM 11.11) defined the ICCID length as 10 octets (20 digits) with
58  * operator-specific structure.
59  *
60  * le_sim_GetICCID() API reads the identification number (ICCID).
61  *
62  * Using this API selects the requested SIM.
63  *
64  * \b IMSI:
65  * The International Mobile Subscriber Identity or IMSI is a unique identification associated with
66  * all cellular networks. The IMSI is used in any mobile network that connects with other
67  * networks. For GSM, UMTS and LTE network, this number is provisioned in the SIM card.
68  *
69  * An IMSI is usually presented as a 15 digit long number, but can be shorter. The first 3 digits
70  * are the mobile country code (MCC), are followed by the mobile network code (MNC), either 2
71  * digits (European standard) or 3 digits (North American standard). The length of the MNC depends
72  * on the value of the MCC. The remaining digits are the mobile subscription identification number
73  * (MSIN) within the network's customer base.
74  *
75  * \b Home \b Network \b Name:
76  * le_sim_GetHomeNetworkOperator() retrieves the Home Network Name.
77  *
78  * le_sim_GetIMSI() API reads the international mobile subscriber identity (IMSI).
79  *
80  * Using this API selects the requested SIM.
81  *
82  * \b Phone \b Number:
83  * le_sim_GetSubscriberPhoneNumber() API reads the Phone Number associated to the SIM.
84  * If the phone number has not been provisioned, it will return the empty string.
85  *
86  * Using this API selects the requested SIM.
87  *
88  * \b Home \b Network \b Information:
89  * - le_sim_GetHomeNetworkOperator()function retrieves the Home Network Name.
90  * - le_sim_GetHomeNetworkMccMnc()function retrieves the Home Network MCC (Mobile Country Code)
91  * and MNC (Mobile Network Code).
92  *
93  * A sample code can be seen in the following page:
94  * - @subpage c_simTestIdentification
95  *
96  * @section le_sim_auth SIM Authentication
97  * le_sim_EnterPIN() enters the PIN (Personal Identification Number) code that's
98  * required before any Mobile equipment functionality can be used.
99  *
100  * Using this API selects the requested SIM.
101  *
102  * le_sim_GetRemainingPINTries() returns the number of remaining PIN entry attempts
103  * before the SIM will become blocked.
104  *
105  * Using this API selects the requested SIM.
106  *
107  * le_sim_ChangePIN() must be called to change the PIN code.
108  *
109  * Using this API selects the requested SIM.
110  *
111  * le_sim_Lock() locks the SIM card: it enables requests for the PIN code.
112  *
113  * Using this API selects the requested SIM.
114  *
115  * le_sim_Unlock() unlocks the SIM card: it disables requests for the PIN code.
116  *
117  * Using this API selects the requested SIM.
118  *
119  * le_sim_Unblock() unblocks the SIM card. The SIM card is blocked after X unsuccessful
120  * attempts to enter the PIN. le_sim_Unblock() requires the PUK (Personal Unblocking) code
121  * to set a new PIN code.
122  *
123  * A sample code can be seen in the following page:
124  * - @subpage c_simTestAuthentication
125  *
126  * @section le_sim_state SIM states
127  * le_sim_IsPresent() API advises the SIM is inserted (and locked) or removed.
128  *
129  * Using this API selects the requested SIM.
130  *
131  * le_sim_IsReady() API advises the SIM is ready (PIN code correctly entered
132  * or not required).
133  *
134  * Using this API selects the requested SIM.
135  *
136  * The le_sim_GetState() API retrieves the SIM state:
137  * - LE_SIM_INSERTED : SIM card is inserted and locked.
138  * - LE_SIM_ABSENT : SIM card is absent.
139  * - LE_SIM_READY : SIM card is inserted and unlocked.
140  * - LE_SIM_BLOCKED : SIM card is blocked.
141  * - LE_SIM_BUSY : SIM card is busy.
142  * - LE_SIM_STATE_UNKNOWN : Unknown SIM state.
143  *
144  * Using this API selects the requested SIM.
145  *
146  * A handler function must be registered to receive SIM's state notifications.
147  * le_sim_AddNewStateHandler() API allows the User to register that handler.
148  *
149  * The handler must satisfy the following prototype:
150  * typedef void(*le_sim_NewStateHandlerFunc_t)(@ref le_sim_Id_t simId, @c le_sim_States_t simState);
151  *
152  * When a new SIM's state is notified, the handler is called.
153  *
154  * Call le_sim_GetState() to retrieve the new state of the SIM.
155  *
156  * @note If two (or more) applications have registered a handler function for notifications, they
157  * will all receive it and will be passed the same SIM.
158  *
159  * The application can uninstall the handler function by calling le_sim_RemoveNewStateHandler() API.
160  *
161  * A sample code can be seen in the following page:
162  * - @subpage c_simTestStates
163  *
164  * @section le_sim_profile_switch Local SIM profile switch
165  *
166  * As soon as there are several subscriptions/profiles in the eUICC (multi-profile), and one of
167  * them is dedicated to emergency calls (ex: eCall, ERA-Glonass), local swap is needed to swap as
168  * quickly as possible to the emergency profile in case of need.
169  *
170  * “Local swap” means that the User's application must be able to directly request the eUICC to
171  * swap to Emergency Call Subscription (ECS).
172  *
173  * Local swap puts the eUICC in a temporary state, meaning the commercial subscription is replaced
174  * by emergency subscription for a limited time, event triggering the swap back to commercial
175  * subscription being controlled by the User's application.
176  *
177  * The le_sim_LocalSwapToEmergencyCallSubscription() function requests the multi-profile eUICC to
178  * swap to ECS and to refresh. The User's application must wait for eUICC reboot to be finished and
179  * network connection available.
180  *
181  * The le_sim_LocalSwapToCommercialSubscription() function requests the multi-profile eUICC to swap
182  * back to commercial subscription and to refresh. The User's application must wait for eUICC reboot
183  * to be finished and network connection available.
184  *
185  * The User's application can install an handler with le_sim_AddNewStateHandler() to receive eUICC's
186  * state notifications.
187  *
188  * @warning
189  * - If you use a Morpho or Oberthur card, the SIM_REFRESH PRO-ACTIVE command must be accepted with
190  * le_sim_AcceptSimToolkitCommand() in order to complete the profile swap procedure.
191  * - If you use a Giesecke & Devrient (G&D) card, be sure that your platform has disabled
192  * security restrictions for channel management APDU commands, otherwise local SIM profile switch
193  * could not work.
194  *
195  * The le_sim_IsEmergencyCallSubscriptionSelected() function must be called to get the current
196  * subscription.
197  *
198  * @warning There is no standard method to interrogate the current selected subscription. The
199  * returned value of this function is based on the last executed local swap command. This means
200  * that this function will always return LE_NOT_FOUND error at Legato startup.
201  *
202  * A sample code can be seen in the following page:
203  * - @subpage c_simTestProfileSwitch
204  *
205  * @section le_sim_stk SIM Toolkit
206  *
207  * The SIM application Toolkit allows the SIM card to initiates commands or asking input from the
208  * modem to accept/reject SIM operations.
209  *
210  * One of the use case is the remote provisioning of an embedded UICC (eUICC).
211  *
212  * The embedded UICC (eUICC) format supports multiple subscription profiles, which can be remotely
213  * provisioned, updated or selected through SIM tool kit procedures (Bearer Independent Protocol
214  * -BIP-, SIM refresh).
215  *
216  * It is mainly used for in-vehicle emergency call service (eCall).
217  *
218  * An eUICC can be remotely managed to change the Mobile Network Operator subscription.
219  *
220  * The le_sim_AddSimToolkitEventHandler() function registers a handler to be notified of SIM
221  * Toolkit events.
222  *
223  * The le_sim_RemoveSimToolkitEventHandler() function unregisters the handler.
224  *
225  * The le_sim_AcceptSimToolkitCommand() allows the device to accept the last SIM Toolkit command.
226  *
227  * The le_sim_RejectSimToolkitCommand() forbids the device to accept the last SIM Toolkit command.
228  *
229  * A sample code can be seen in the following page:
230  * - @subpage c_simTestSimToolkit
231  *
232  * Information related to SIM Toolkit platform constraints can be seen in the
233  * @subpage platformConstraintsStk page.
234  *
235  * @section le_sim_access SIM access
236  *
237  * The application can send an APDU (Application Protocol Data Unit) to the SIM using
238  * le_sim_SendApdu() API. The user must encode the APDU as specified by in recommendation 3GPP 11.11,
239  * 3GPP 51.011, 3GPP 31.102, 3GPP 31.103 or ETSI TS 102 221.
240  * @note Between two successive call to le_sim_SendApdu() API, there is no locking
241  * protection. In this situation, some command types and parameters can modify SIM files incorrectly.
242  *
243  * Using le_sim_SendSimCommand() API, the application has easier but more limited access to the
244  * SIM database. The command is transmitted to the SIM, which gives information through swi1 and
245  * swi2 about the execution of the command (see 3GPP recommendation previously mentioned for
246  * their coding).
247  * Some parameters are platform dependent, see @subpage platformConstraintsSim for their coding.
248  *
249  * A sample code can be seen in the following page:
250  * - @subpage c_simTestApdu
251  *
252  * <HR>
253  *
254  * Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
255  */
256 /**
257  * @file le_sim_interface.h
258  *
259  * Legato @ref c_sim include file.
260  *
261  * Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
262  */
263 /**
264  * @page c_simTestProfileSwitch Sample code for Local SIM profile switch
265  *
266  * @include "apps/test/modemServices/sim/simProfileSwap/simTestComp/simTest.c"
267  */
268 /**
269  * @page c_simTestSimToolkit Sample code for Local SIM Toolkit
270  *
271  * @include "apps/test/modemServices/sim/simToolkit/simToolkitComp/simToolkitTest.c"
272  */
273 /**
274  * @page c_simTestAuthentication Sample code for SIM Authentication
275  *
276  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Define
277  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/main.c" Print
278  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Authentication
279  */
280 /**
281  * @page c_simTestIdentification Sample code for SIM Identification
282 
283  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/main.c" Print
284  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Identification
285  */
286 /**
287  * @page c_simTestSelect Sample code for SIM Select
288  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Select
289  */
290 /**
291  * @page c_simTestStates Sample code for SIM States
292  *
293  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/main.c" Print
294  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Display
295  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" State handler
296  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" State
297  */
298 /**
299  * @page c_simTestApdu Sample code for SIM access
300  * @snippet "apps/test/modemServices/sim/simIntegrationTest/simTestComp/simTest.c" Apdu
301  */
302 
303 #ifndef LE_SIM_INTERFACE_H_INCLUDE_GUARD
304 #define LE_SIM_INTERFACE_H_INCLUDE_GUARD
305 
306 
307 #include "legato.h"
308 
309 // Interface specific includes
310 #include "le_mdmDefs_interface.h"
311 
312 
313 //--------------------------------------------------------------------------------------------------
314 /**
315  *
316  * Connect the current client thread to the service providing this API. Block until the service is
317  * available.
318  *
319  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
320  * called before any other functions in this API. Normally, ConnectService is automatically called
321  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
322  *
323  * This function is created automatically.
324  */
325 //--------------------------------------------------------------------------------------------------
327 (
328  void
329 );
330 
331 //--------------------------------------------------------------------------------------------------
332 /**
333  *
334  * Try to connect the current client thread to the service providing this API. Return with an error
335  * if the service is not available.
336  *
337  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
338  * called before any other functions in this API. Normally, ConnectService is automatically called
339  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
340  *
341  * This function is created automatically.
342  *
343  * @return
344  * - LE_OK if the client connected successfully to the service.
345  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
346  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
347  * - LE_COMM_ERROR if the Service Directory cannot be reached.
348  */
349 //--------------------------------------------------------------------------------------------------
351 (
352  void
353 );
354 
355 //--------------------------------------------------------------------------------------------------
356 /**
357  *
358  * Disconnect the current client thread from the service providing this API.
359  *
360  * Normally, this function doesn't need to be called. After this function is called, there's no
361  * longer a connection to the service, and the functions in this API can't be used. For details, see
362  * @ref apiFilesC_client.
363  *
364  * This function is created automatically.
365  */
366 //--------------------------------------------------------------------------------------------------
368 (
369  void
370 );
371 
372 
373 //--------------------------------------------------------------------------------------------------
374 /**
375  * Minimum PIN length (4 digits)
376  */
377 //--------------------------------------------------------------------------------------------------
378 #define LE_SIM_PIN_MIN_LEN 4
379 
380 
381 //--------------------------------------------------------------------------------------------------
382 /**
383  * Maximum PIN length (8 digits)
384  */
385 //--------------------------------------------------------------------------------------------------
386 #define LE_SIM_PIN_MAX_LEN 8
387 
388 
389 //--------------------------------------------------------------------------------------------------
390 /**
391  * Maximum PIN length (8 digits)
392  * One extra byte is added for the null character.
393  */
394 //--------------------------------------------------------------------------------------------------
395 #define LE_SIM_PIN_MAX_BYTES 9
396 
397 
398 //--------------------------------------------------------------------------------------------------
399 /**
400  * PUK length (8 digits)
401  */
402 //--------------------------------------------------------------------------------------------------
403 #define LE_SIM_PUK_MAX_LEN 8
404 
405 
406 //--------------------------------------------------------------------------------------------------
407 /**
408  * PUK length (8 digits)
409  * One extra byte is added for the null character.
410  */
411 //--------------------------------------------------------------------------------------------------
412 #define LE_SIM_PUK_MAX_BYTES 9
413 
414 
415 //--------------------------------------------------------------------------------------------------
416 /**
417  * ICCID length
418  * According to GSM Phase 1
419  */
420 //--------------------------------------------------------------------------------------------------
421 #define LE_SIM_ICCID_LEN 20
422 
423 
424 //--------------------------------------------------------------------------------------------------
425 /**
426  * ICCID length
427  * One extra byte is added for the null character.
428  */
429 //--------------------------------------------------------------------------------------------------
430 #define LE_SIM_ICCID_BYTES 21
431 
432 
433 //--------------------------------------------------------------------------------------------------
434 /**
435  * IMSI length
436  */
437 //--------------------------------------------------------------------------------------------------
438 #define LE_SIM_IMSI_LEN 15
439 
440 
441 //--------------------------------------------------------------------------------------------------
442 /**
443  * IMSI length
444  * One extra byte is added for the null character.
445  */
446 //--------------------------------------------------------------------------------------------------
447 #define LE_SIM_IMSI_BYTES 16
448 
449 
450 //--------------------------------------------------------------------------------------------------
451 /**
452  * APDU length
453  */
454 //--------------------------------------------------------------------------------------------------
455 #define LE_SIM_APDU_MAX_BYTES 255
456 
457 
458 //--------------------------------------------------------------------------------------------------
459 /**
460  * SIM response length
461  */
462 //--------------------------------------------------------------------------------------------------
463 #define LE_SIM_RESPONSE_MAX_BYTES 256
464 
465 
466 //--------------------------------------------------------------------------------------------------
467 /**
468  * SIM file identifier length
469  */
470 //--------------------------------------------------------------------------------------------------
471 #define LE_SIM_FILE_ID_LEN 4
472 
473 
474 //--------------------------------------------------------------------------------------------------
475 /**
476  * SIM file identifier length
477  * One extra byte is added for the null character.
478  */
479 //--------------------------------------------------------------------------------------------------
480 #define LE_SIM_FILE_ID_BYTES 5
481 
482 
483 //--------------------------------------------------------------------------------------------------
484 /**
485  * SIM data command length
486 
487  */
488 //--------------------------------------------------------------------------------------------------
489 #define LE_SIM_DATA_MAX_BYTES 100
490 
491 
492 //--------------------------------------------------------------------------------------------------
493 /**
494  * SIM file path length
495  */
496 //--------------------------------------------------------------------------------------------------
497 #define LE_SIM_PATH_MAX_LEN 100
498 
499 
500 //--------------------------------------------------------------------------------------------------
501 /**
502  * SIM file path length
503  * One extra byte is added for the null character.
504  */
505 //--------------------------------------------------------------------------------------------------
506 #define LE_SIM_PATH_MAX_BYTES 101
507 
508 
509 //--------------------------------------------------------------------------------------------------
510 /**
511  * SIM states.
512  *
513  */
514 //--------------------------------------------------------------------------------------------------
515 typedef enum
516 {
518  ///< SIM card is inserted and locked.
519 
521  ///< SIM card is absent.
522 
524  ///< SIM card is inserted and unlocked.
525 
527  ///< SIM card is blocked.
528 
530  ///< SIM card is busy.
531 
533  ///< Unknown SIM state.
534 }
536 
537 
538 //--------------------------------------------------------------------------------------------------
539 /**
540  * SIM identifiers.
541  *
542  */
543 //--------------------------------------------------------------------------------------------------
544 typedef enum
545 {
547  ///< Embedded SIM
548 
550  ///< SIM inserted in external slot 1
551 
553  ///< SIM inserted in external slot 2
554 
556  ///< Remote SIM
557 
558  LE_SIM_ID_MAX = 4
559 }
561 
562 
563 //--------------------------------------------------------------------------------------------------
564 /**
565  * Card Manufacturer.
566  *
567  */
568 //--------------------------------------------------------------------------------------------------
569 typedef enum
570 {
572  ///< Oberthur.
573 
575  ///< Gemalto.
576 
578  ///< G&D.
579 
581  ///< Morpho.
582 
583  LE_SIM_MANUFACTURER_MAX = 4
584 }
586 
587 
588 //--------------------------------------------------------------------------------------------------
589 /**
590  * SIM commands.
591  */
592 //--------------------------------------------------------------------------------------------------
593 typedef enum
594 {
596  ///< Read a file record.
597 
599  ///< Read a transparent elementary file.
600 
602  ///< Update a file record.
603 
605  ///< Update a transparent elementary file.
606 
608  ///< Max value
609 }
611 
612 
613 //--------------------------------------------------------------------------------------------------
614 /**
615  * SIM Toolkit events.
616  */
617 //--------------------------------------------------------------------------------------------------
618 typedef enum
619 {
621  ///< SIM card ask to open a logical channel.
622 
624  ///< SIM card ask for a refresh.
625 
627  ///< Unknown SIM Toolkit event.
628 }
630 
631 
632 //--------------------------------------------------------------------------------------------------
633 /**
634  * Reference type used by Add/Remove functions for EVENT 'le_sim_NewState'
635  */
636 //--------------------------------------------------------------------------------------------------
637 typedef struct le_sim_NewStateHandler* le_sim_NewStateHandlerRef_t;
638 
639 
640 //--------------------------------------------------------------------------------------------------
641 /**
642  * Reference type used by Add/Remove functions for EVENT 'le_sim_SimToolkitEvent'
643  */
644 //--------------------------------------------------------------------------------------------------
645 typedef struct le_sim_SimToolkitEventHandler* le_sim_SimToolkitEventHandlerRef_t;
646 
647 
648 //--------------------------------------------------------------------------------------------------
649 /**
650  * Handler for sim state changes.
651  *
652  *
653  * @param simId
654  * The SIM identifier.
655  * @param simState
656  * The SIM state.
657  * @param contextPtr
658  */
659 //--------------------------------------------------------------------------------------------------
660 typedef void (*le_sim_NewStateHandlerFunc_t)
661 (
662  le_sim_Id_t simId,
663  le_sim_States_t simState,
664  void* contextPtr
665 );
666 
667 
668 //--------------------------------------------------------------------------------------------------
669 /**
670  * Handler for Sim Toolkit Events.
671  *
672  *
673  * @param simId
674  * The SIM identifier.
675  * @param stkEvent
676  * The SIM state.
677  * @param contextPtr
678  */
679 //--------------------------------------------------------------------------------------------------
681 (
682  le_sim_Id_t simId,
683  le_sim_StkEvent_t stkEvent,
684  void* contextPtr
685 );
686 
687 //--------------------------------------------------------------------------------------------------
688 /**
689  * Add handler function for EVENT 'le_sim_NewState'
690  *
691  * This event provides information on sim state changes.
692  */
693 //--------------------------------------------------------------------------------------------------
695 (
696  le_sim_NewStateHandlerFunc_t handlerPtr,
697  ///< [IN]
698 
699  void* contextPtr
700  ///< [IN]
701 );
702 
703 //--------------------------------------------------------------------------------------------------
704 /**
705  * Remove handler function for EVENT 'le_sim_NewState'
706  */
707 //--------------------------------------------------------------------------------------------------
709 (
710  le_sim_NewStateHandlerRef_t addHandlerRef
711  ///< [IN]
712 );
713 
714 //--------------------------------------------------------------------------------------------------
715 /**
716  * Add handler function for EVENT 'le_sim_SimToolkitEvent'
717  *
718  * This event provides information on Sim Toolkit application.
719  */
720 //--------------------------------------------------------------------------------------------------
722 (
724  ///< [IN]
725 
726  void* contextPtr
727  ///< [IN]
728 );
729 
730 //--------------------------------------------------------------------------------------------------
731 /**
732  * Remove handler function for EVENT 'le_sim_SimToolkitEvent'
733  */
734 //--------------------------------------------------------------------------------------------------
736 (
738  ///< [IN]
739 );
740 
741 //--------------------------------------------------------------------------------------------------
742 /**
743  * Get the current selected card.
744  *
745  * @return Number of the current selected SIM card.
746  */
747 //--------------------------------------------------------------------------------------------------
749 (
750  void
751 );
752 
753 //--------------------------------------------------------------------------------------------------
754 /**
755  * Select a SIM.
756  *
757  * @return LE_FAULT Function failed to select the requested SIM
758  * @return LE_OK Function succeeded.
759  *
760  */
761 //--------------------------------------------------------------------------------------------------
763 (
764  le_sim_Id_t simId
765  ///< [IN] The SIM identifier.
766 );
767 
768 //--------------------------------------------------------------------------------------------------
769 /**
770  * Retrieves the integrated circuit card identifier (ICCID) of the SIM card (20 digits)
771  *
772  * @return LE_OK ICCID was successfully retrieved.
773  * @return LE_OVERFLOW iccidPtr buffer was too small for the ICCID.
774  * @return LE_BAD_PARAMETER if a parameter is invalid
775  * @return LE_FAULT The ICCID could not be retrieved.
776  *
777  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
778  * function will not return.
779  */
780 //--------------------------------------------------------------------------------------------------
782 (
783  le_sim_Id_t simId,
784  ///< [IN] The SIM identifier.
785 
786  char* iccid,
787  ///< [OUT] ICCID
788 
789  size_t iccidNumElements
790  ///< [IN]
791 );
792 
793 //--------------------------------------------------------------------------------------------------
794 /**
795  * Retrieves the identification number (IMSI) of the SIM card. (max 15 digits)
796  *
797  * @return LE_OVERFLOW The imsiPtr buffer was too small for the IMSI.
798  * @return LE_BAD_PARAMETER The parameters are invalid.
799  * @return LE_FAULT The function failed.
800  * @return LE_TIMEOUT No response was received.
801  * @return LE_OK The function succeeded.
802  *
803  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
804  * function will not return.
805  */
806 //--------------------------------------------------------------------------------------------------
808 (
809  le_sim_Id_t simId,
810  ///< [IN] The SIM identifier.
811 
812  char* imsi,
813  ///< [OUT] IMSI
814 
815  size_t imsiNumElements
816  ///< [IN]
817 );
818 
819 //--------------------------------------------------------------------------------------------------
820 /**
821  * Verify if the SIM card is present or not.
822  *
823  * @return true SIM card is present.
824  * @return false SIM card is absent
825  *
826  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
827  * function will not return.
828  */
829 //--------------------------------------------------------------------------------------------------
830 bool le_sim_IsPresent
831 (
832  le_sim_Id_t simId
833  ///< [IN] The SIM identifier.
834 );
835 
836 //--------------------------------------------------------------------------------------------------
837 /**
838  * Verify if the SIM is ready (PIN code correctly inserted or not
839  * required).
840  *
841  * @return true PIN is correctly inserted or not required.
842  * @return false PIN must be inserted
843  *
844  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
845  * function will not return.
846  */
847 //--------------------------------------------------------------------------------------------------
848 bool le_sim_IsReady
849 (
850  le_sim_Id_t simId
851  ///< [IN] The SIM identifier.
852 );
853 
854 //--------------------------------------------------------------------------------------------------
855 /**
856  * This function must be called to enter the PIN code.
857  *
858  * @return LE_BAD_PARAMETER The parameters are invalid.
859  * @return LE_NOT_FOUND The function failed to select the SIM card for this operation.
860  * @return LE_UNDERFLOW The PIN code is not long enough (min 4 digits).
861  * @return LE_FAULT The function failed to enter the PIN code.
862  * @return LE_OK The function succeeded.
863  *
864  * @note If PIN code is too long (max 8 digits), it is a fatal error, the
865  * function will not return.
866  *
867  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
868  * function will not return.
869  */
870 //--------------------------------------------------------------------------------------------------
872 (
873  le_sim_Id_t simId,
874  ///< [IN] The SIM identifier.
875 
876  const char* pin
877  ///< [IN] The PIN code.
878 );
879 
880 //--------------------------------------------------------------------------------------------------
881 /**
882  * Change the PIN code.
883  *
884  * @return LE_NOT_FOUND Function failed to select the SIM card for this operation.
885  * @return LE_UNDERFLOW PIN code is/are not long enough (min 4 digits).
886  * @return LE_FAULT Function failed to change the PIN code.
887  * @return LE_OK Function succeeded.
888  *
889  * @note If PIN code is too long (max 8 digits), it is a fatal error, the
890  * function will not return.
891  *
892  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
893  * function will not return.
894  */
895 //--------------------------------------------------------------------------------------------------
897 (
898  le_sim_Id_t simId,
899  ///< [IN] The SIM identifier.
900 
901  const char* oldpin,
902  ///< [IN] The old PIN code.
903 
904  const char* newpin
905  ///< [IN] The new PIN code.
906 );
907 
908 //--------------------------------------------------------------------------------------------------
909 /**
910  * Get the number of remaining PIN insertion tries.
911  *
912  * @return LE_NOT_FOUND The function failed to select the SIM card for this operation.
913  * @return LE_FAULT The function failed to get the number of remaining PIN insertion tries.
914  * @return A positive value The function succeeded. The number of remaining PIN insertion tries.
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 );
925 
926 //--------------------------------------------------------------------------------------------------
927 /**
928  * Unlock the SIM card: it disables the request of the PIN code.
929  *
930  * @return LE_NOT_FOUND Function failed to select the SIM card for this operation.
931  * @return LE_UNDERFLOW PIN code is not long enough (min 4 digits).
932  * @return LE_FAULT The function failed to unlock the SIM card.
933  * @return LE_OK Function succeeded.
934  *
935  * @note If PIN code is too long (max 8 digits), it is a fatal error, the
936  * function will not return.
937  *
938  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
939  * function will not return.
940  */
941 //--------------------------------------------------------------------------------------------------
943 (
944  le_sim_Id_t simId,
945  ///< [IN] The SIM identifier.
946 
947  const char* pin
948  ///< [IN] The PIN code.
949 );
950 
951 //--------------------------------------------------------------------------------------------------
952 /**
953  * Lock the SIM card: it enables the request of the PIN code.
954  *
955  * @return LE_NOT_FOUND Function failed to select the SIM card for this operation.
956  * @return LE_UNDERFLOW PIN code is not long enough (min 4 digits).
957  * @return LE_FAULT The function failed to unlock the SIM card.
958  * @return LE_OK Function succeeded.
959  *
960  * @note If PIN code is too long (max 8 digits), it is a fatal error, the
961  * function will not return.
962  *
963  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
964  * function will not return.
965  */
966 //--------------------------------------------------------------------------------------------------
968 (
969  le_sim_Id_t simId,
970  ///< [IN] The SIM identifier.
971 
972  const char* pin
973  ///< [IN] The PIN code.
974 );
975 
976 //--------------------------------------------------------------------------------------------------
977 /**
978  * Unblock the SIM card.
979  *
980  * @return LE_NOT_FOUND Function failed to select the SIM card for this operation.
981  * @return LE_UNDERFLOW PIN code is not long enough (min 4 digits).
982  * @return LE_OUT_OF_RANGE PUK code length is not correct (8 digits).
983  * @return LE_FAULT The function failed to unlock the SIM card.
984  * @return LE_OK Function succeeded.
985  *
986  * @note If new PIN or puk code are too long (max 8 digits), it is a fatal error, the
987  * function will not return.
988  *
989  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
990  * function will not return.
991  */
992 //--------------------------------------------------------------------------------------------------
994 (
995  le_sim_Id_t simId,
996  ///< [IN] The SIM identifier.
997 
998  const char* puk,
999  ///< [IN] The PUK code.
1000 
1001  const char* newpin
1002  ///< [IN] The PIN code.
1003 );
1004 
1005 //--------------------------------------------------------------------------------------------------
1006 /**
1007  * Get the SIM state.
1008  *
1009  * @return Current SIM state.
1010  *
1011  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1012  * function will not return.
1013  */
1014 //--------------------------------------------------------------------------------------------------
1016 (
1017  le_sim_Id_t simId
1018  ///< [IN] The SIM identifier.
1019 );
1020 
1021 //--------------------------------------------------------------------------------------------------
1022 /**
1023  * Get the SIM Phone Number.
1024  *
1025  * @return
1026  * - LE_OK on success
1027  * - LE_OVERFLOW if the Phone Number can't fit in phoneNumberStr
1028  * - LE_BAD_PARAMETER if a parameter is invalid
1029  * - LE_FAULT on any other failure
1030  *
1031  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1032  * function will not return.
1033  */
1034 //--------------------------------------------------------------------------------------------------
1036 (
1037  le_sim_Id_t simId,
1038  ///< [IN] The SIM identifier.
1039 
1040  char* phoneNumberStr,
1041  ///< [OUT] The phone Number.
1042 
1043  size_t phoneNumberStrNumElements
1044  ///< [IN]
1045 );
1046 
1047 //--------------------------------------------------------------------------------------------------
1048 /**
1049  * This function must be called to get the Home Network Name information.
1050  *
1051  * @return
1052  * - LE_OK on success
1053  * - LE_OVERFLOW if the Home Network Name can't fit in nameStr
1054  * - LE_NOT_FOUND if the network is not found
1055  * - LE_BAD_PARAMETER if a parameter is invalid
1056  * - LE_FAULT on any other failure
1057  *
1058  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1059  * function will not return.
1060  */
1061 //--------------------------------------------------------------------------------------------------
1063 (
1064  le_sim_Id_t simId,
1065  ///< [IN] The SIM identifier.
1066 
1067  char* nameStr,
1068  ///< [OUT] the home network Name
1069 
1070  size_t nameStrNumElements
1071  ///< [IN]
1072 );
1073 
1074 //--------------------------------------------------------------------------------------------------
1075 /**
1076  * This function must be called to get the Home Network MCC MNC.
1077  *
1078  * @return
1079  * - LE_OK on success
1080  * - LE_NOT_FOUND if Home Network has not been provisioned
1081  * - LE_FAULT for unexpected error
1082  *
1083  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
1084  * function will not return.
1085  */
1086 //--------------------------------------------------------------------------------------------------
1088 (
1089  le_sim_Id_t simId,
1090  ///< [IN] The SIM identifier.
1091 
1092  char* mccPtr,
1093  ///< [OUT] Mobile Country Code
1094 
1095  size_t mccPtrNumElements,
1096  ///< [IN]
1097 
1098  char* mncPtr,
1099  ///< [OUT] Mobile Network Code
1100 
1101  size_t mncPtrNumElements
1102  ///< [IN]
1103 );
1104 
1105 //--------------------------------------------------------------------------------------------------
1106 /**
1107  * This function must be called to request the multi-profile eUICC to swap to ECS and to refresh.
1108  * The User's application must wait for eUICC reboot to be finished and network connection
1109  * available.
1110  *
1111  * @return
1112  * - LE_OK on success
1113  * - LE_BAD_PARAMETER invalid SIM identifier
1114  * - LE_BUSY when a profile swap is already in progress
1115  * - LE_FAULT for unexpected error
1116  *
1117  * @warning If you use a Morpho or Oberthur card, the SIM_REFRESH PRO-ACTIVE command must be
1118  * accepted with le_sim_AcceptSimToolkitCommand() in order to complete the profile swap
1119  * procedure.
1120  */
1121 //--------------------------------------------------------------------------------------------------
1123 (
1124  le_sim_Id_t simId,
1125  ///< [IN] The SIM identifier.
1126 
1127  le_sim_Manufacturer_t manufacturer
1128  ///< [IN] The card manufacturer.
1129 );
1130 
1131 //--------------------------------------------------------------------------------------------------
1132 /**
1133  * This function must be called to request the multi-profile eUICC to swap back to commercial
1134  * subscription and to refresh.
1135  * The User's application must wait for eUICC reboot to be finished and network connection
1136  * available.
1137  *
1138  * @return
1139  * - LE_OK on success
1140  * - LE_BAD_PARAMETER invalid SIM identifier
1141  * - LE_BUSY when a profile swap is already in progress
1142  * - LE_FAULT for unexpected error
1143  *
1144  * @warning If you use a Morpho or Oberthur card, the SIM_REFRESH PRO-ACTIVE command must be
1145  * accepted with le_sim_AcceptSimToolkitCommand() in order to complete the profile swap
1146  * procedure.
1147  */
1148 //--------------------------------------------------------------------------------------------------
1150 (
1151  le_sim_Id_t simId,
1152  ///< [IN] The SIM identifier.
1153 
1154  le_sim_Manufacturer_t manufacturer
1155  ///< [IN] The card manufacturer.
1156 );
1157 
1158 //--------------------------------------------------------------------------------------------------
1159 /**
1160  * This function must be called to get the current subscription.
1161  *
1162  * @return
1163  * - LE_OK on success
1164  * - LE_BAD_PARAMETER invalid SIM identifier
1165  * - LE_NOT_FOUND cannot determine the current selected subscription
1166  * - LE_FAULT for unexpected errors
1167  *
1168  * @warning There is no standard method to interrogate the current selected subscription. The
1169  * returned value of this function is based on the last executed local swap command. This means
1170  * that this function will always return LE_NOT_FOUND error at Legato startup.
1171  */
1172 //--------------------------------------------------------------------------------------------------
1174 (
1175  le_sim_Id_t simId,
1176  ///< [IN] The SIM identifier
1177 
1178  bool* isEcsPtr
1179  ///< [OUT] true if Emergency Call Subscription (ECS) is selected,
1180  ///< false if Commercial Subscription is selected
1181 );
1182 
1183 //--------------------------------------------------------------------------------------------------
1184 /**
1185  * Accept the last SIM Toolkit command.
1186  *
1187  * @return LE_FAULT Function failed.
1188  * @return LE_OK Function succeeded.
1189  */
1190 //--------------------------------------------------------------------------------------------------
1192 (
1193  le_sim_Id_t simId
1194  ///< [IN] The SIM identifier.
1195 );
1196 
1197 //--------------------------------------------------------------------------------------------------
1198 /**
1199  * Reject the last SIM Toolkit command.
1200  *
1201  * @return LE_FAULT Function failed.
1202  * @return LE_OK Function succeeded.
1203  */
1204 //--------------------------------------------------------------------------------------------------
1206 (
1207  le_sim_Id_t simId
1208  ///< [IN] The SIM identifier.
1209 );
1210 
1211 //--------------------------------------------------------------------------------------------------
1212 /**
1213  * Send APDU command to the SIM.
1214  *
1215  * @return
1216  * - LE_OK Function succeeded.
1217  * - LE_FAULT The function failed.
1218  * - LE_BAD_PARAMETER A parameter is invalid.
1219  * - LE_NOT_FOUND The function failed to select the SIM card for this operation.
1220  */
1221 //--------------------------------------------------------------------------------------------------
1223 (
1224  le_sim_Id_t simId,
1225  ///< [IN] The SIM identifier.
1226 
1227  const uint8_t* commandApduPtr,
1228  ///< [IN] APDU command.
1229 
1230  size_t commandApduNumElements,
1231  ///< [IN]
1232 
1233  uint8_t* responseApduPtr,
1234  ///< [OUT] SIM response.
1235 
1236  size_t* responseApduNumElementsPtr
1237  ///< [INOUT]
1238 );
1239 
1240 //--------------------------------------------------------------------------------------------------
1241 /**
1242  * Send a command to the SIM.
1243  *
1244  * @return
1245  * - LE_OK Function succeeded.
1246  * - LE_FAULT The function failed.
1247  * - LE_BAD_PARAMETER A parameter is invalid.
1248  * - LE_NOT_FOUND - The function failed to select the SIM card for this operation
1249  * - The requested SIM file is not found
1250  * - LE_OVERFLOW Response buffer is too small to copy the SIM answer.
1251  */
1252 //--------------------------------------------------------------------------------------------------
1254 (
1255  le_sim_Id_t simId,
1256  ///< [IN] The SIM identifier.
1257 
1258  le_sim_Command_t command,
1259  ///< [IN] The SIM command.
1260 
1261  const char* fileIdentifier,
1262  ///< [IN] File identifier
1263 
1264  uint8_t p1,
1265  ///< [IN] Parameter P1 passed to the SIM
1266 
1267  uint8_t p2,
1268  ///< [IN] Parameter P2 passed to the SIM
1269 
1270  uint8_t p3,
1271  ///< [IN] Parameter P3 passed to the SIM
1272 
1273  const uint8_t* dataPtr,
1274  ///< [IN] data command.
1275 
1276  size_t dataNumElements,
1277  ///< [IN]
1278 
1279  const char* path,
1280  ///< [IN] path of the elementary file
1281 
1282  uint8_t* sw1Ptr,
1283  ///< [OUT] Status Word 1 received from the SIM
1284 
1285  uint8_t* sw2Ptr,
1286  ///< [OUT] Status Word 2 received from the SIM
1287 
1288  uint8_t* responsePtr,
1289  ///< [OUT] SIM response.
1290 
1291  size_t* responseNumElementsPtr
1292  ///< [INOUT]
1293 );
1294 
1295 
1296 #endif // LE_SIM_INTERFACE_H_INCLUDE_GUARD
1297 
le_sim_NewStateHandlerRef_t le_sim_AddNewStateHandler(le_sim_NewStateHandlerFunc_t handlerPtr, void *contextPtr)
Read a transparent elementary file.
Definition: le_sim_interface.h:598
bool le_sim_IsPresent(le_sim_Id_t simId)
le_sim_Id_t
Definition: le_sim_interface.h:544
le_result_t le_sim_SendCommand(le_sim_Id_t simId, le_sim_Command_t command, const char *fileIdentifier, uint8_t p1, uint8_t p2, uint8_t p3, const uint8_t *dataPtr, size_t dataNumElements, const char *path, uint8_t *sw1Ptr, uint8_t *sw2Ptr, uint8_t *responsePtr, size_t *responseNumElementsPtr)
le_result_t
Definition: le_basics.h:35
le_result_t le_sim_Lock(le_sim_Id_t simId, const char *pin)
le_result_t le_sim_LocalSwapToEmergencyCallSubscription(le_sim_Id_t simId, le_sim_Manufacturer_t manufacturer)
le_result_t le_sim_GetSubscriberPhoneNumber(le_sim_Id_t simId, char *phoneNumberStr, size_t phoneNumberStrNumElements)
SIM card is busy.
Definition: le_sim_interface.h:529
void(* le_sim_SimToolkitEventHandlerFunc_t)(le_sim_Id_t simId, le_sim_StkEvent_t stkEvent, void *contextPtr)
Definition: le_sim_interface.h:681
le_sim_StkEvent_t
Definition: le_sim_interface.h:618
le_result_t le_sim_GetHomeNetworkOperator(le_sim_Id_t simId, char *nameStr, size_t nameStrNumElements)
Update a transparent elementary file.
Definition: le_sim_interface.h:604
le_result_t le_sim_Unblock(le_sim_Id_t simId, const char *puk, const char *newpin)
Embedded SIM.
Definition: le_sim_interface.h:546
Oberthur.
Definition: le_sim_interface.h:571
le_sim_States_t
Definition: le_sim_interface.h:515
void(* le_sim_NewStateHandlerFunc_t)(le_sim_Id_t simId, le_sim_States_t simState, void *contextPtr)
Definition: le_sim_interface.h:661
struct le_sim_SimToolkitEventHandler * le_sim_SimToolkitEventHandlerRef_t
Definition: le_sim_interface.h:645
le_result_t le_sim_Unlock(le_sim_Id_t simId, const char *pin)
SIM card is absent.
Definition: le_sim_interface.h:520
SIM card is inserted and locked.
Definition: le_sim_interface.h:517
void le_sim_RemoveSimToolkitEventHandler(le_sim_SimToolkitEventHandlerRef_t addHandlerRef)
Read a file record.
Definition: le_sim_interface.h:595
le_result_t le_sim_AcceptSimToolkitCommand(le_sim_Id_t simId)
le_result_t le_sim_GetHomeNetworkMccMnc(le_sim_Id_t simId, char *mccPtr, size_t mccPtrNumElements, char *mncPtr, size_t mncPtrNumElements)
Max value.
Definition: le_sim_interface.h:607
Unknown SIM Toolkit event.
Definition: le_sim_interface.h:626
void le_sim_ConnectService(void)
SIM card ask to open a logical channel.
Definition: le_sim_interface.h:620
Gemalto.
Definition: le_sim_interface.h:574
SIM card ask for a refresh.
Definition: le_sim_interface.h:623
SIM inserted in external slot 1.
Definition: le_sim_interface.h:549
void le_sim_DisconnectService(void)
struct le_sim_NewStateHandler * le_sim_NewStateHandlerRef_t
Definition: le_sim_interface.h:637
le_result_t le_sim_SendApdu(le_sim_Id_t simId, const uint8_t *commandApduPtr, size_t commandApduNumElements, uint8_t *responseApduPtr, size_t *responseApduNumElementsPtr)
le_result_t le_sim_ChangePIN(le_sim_Id_t simId, const char *oldpin, const char *newpin)
le_result_t le_sim_SelectCard(le_sim_Id_t simId)
le_sim_Manufacturer_t
Definition: le_sim_interface.h:569
Remote SIM.
Definition: le_sim_interface.h:555
int32_t le_sim_GetRemainingPINTries(le_sim_Id_t simId)
bool le_sim_IsReady(le_sim_Id_t simId)
le_sim_SimToolkitEventHandlerRef_t le_sim_AddSimToolkitEventHandler(le_sim_SimToolkitEventHandlerFunc_t handlerPtr, void *contextPtr)
le_result_t le_sim_RejectSimToolkitCommand(le_sim_Id_t simId)
void le_sim_RemoveNewStateHandler(le_sim_NewStateHandlerRef_t addHandlerRef)
SIM card is blocked.
Definition: le_sim_interface.h:526
le_result_t le_sim_EnterPIN(le_sim_Id_t simId, const char *pin)
le_result_t le_sim_IsEmergencyCallSubscriptionSelected(le_sim_Id_t simId, bool *isEcsPtr)
G&D.
Definition: le_sim_interface.h:577
le_result_t le_sim_GetIMSI(le_sim_Id_t simId, char *imsi, size_t imsiNumElements)
Morpho.
Definition: le_sim_interface.h:580
le_sim_Command_t
Definition: le_sim_interface.h:593
le_sim_Id_t le_sim_GetSelectedCard(void)
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:552
le_result_t le_sim_TryConnectService(void)
Unknown SIM state.
Definition: le_sim_interface.h:532
le_result_t le_sim_GetICCID(le_sim_Id_t simId, char *iccid, size_t iccidNumElements)
SIM card is inserted and unlocked.
Definition: le_sim_interface.h:523
Update a file record.
Definition: le_sim_interface.h:601