le_sim_interface.h

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