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