blob: 38ad65c04c8591564d307163c0ea9e5f62dfa42c [file] [log] [blame]
b.liu68a94c92025-05-24 12:53:41 +08001/**
2 @file
3 ql_sim.h
4
5 @brief
6 This file provides the definitions for sim, and declares the
7 API functions.
8
9*/
10/*============================================================================
11 Copyright (c) 2017 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
12 Quectel Wireless Solution Proprietary and Confidential.
13 =============================================================================*/
14/*===========================================================================
15
16 EDIT HISTORY FOR MODULE
17
18This section contains comments describing changes made to the module.
19Notice that changes are listed in reverse chronological order.
20
21
22WHEN WHO WHAT, WHERE, WHY
23---------- ------------ ----------------------------------------------------
2421/08/2019 Nebula.li create
25=============================================================================*/
26
27#ifndef __QL_SIM_H__
28#define __QL_SIM_H__
29
30#include <stdlib.h>
31#include <stdint.h>
32#include <string.h>
33
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39typedef unsigned char UINT8;
40typedef unsigned short UINT16;
41typedef unsigned long UINT32;
42typedef unsigned int UINT;
43
44typedef enum
45{
46 QL_SIM_SUCCESS,
47 QL_SIM_GENERIC_FAILURE,
48 QL_SIM_RADIO_NOT_AVAILABLE,
49 QL_SIM_INCORRECT_PASSWORD,
50 QL_SIM_CARD_NO_INSERTED,
51 QL_SIM_CARD_BUSY,
52 QL_SIM_CARD_BLOCKED,
53}QL_SIM_ERROR_CODE;
54
55
56#define QL_SIM_MCC_LEN 4 /** Length of the MCC. */
57#define QL_SIM_MNC_MAX 4 /** Maximum length of the MNC. */
58#define QL_SIM_PLMN_NUM_MAX 24 /** Maximum number of PLMN data sets. */
59typedef struct
60{
61 uint8_t mcc[QL_SIM_MCC_LEN]; /**< MCC value in ASCII characters.*/
62 uint8_t mnc[QL_SIM_MNC_MAX]; /**< MNC value in ASCII characters.*/
63}QL_SIM_PLMN_INFO;
64typedef struct
65{
66 uint32_t preferred_operator_list_num; /**< Must be set to the number of elements in preferred_operator_list. */
67 QL_SIM_PLMN_INFO preferred_operator_list[QL_SIM_PLMN_NUM_MAX]; /**< Preferred operator list. */
68}QL_SIM_PREFERRED_OPERATOR_LIST; /* Message */
69
70#define QL_SIM_PIN_LEN_MAX 16 /** Maximum length of PIN data. */
71#define QUEC_CI_SIM_MAX_CMD_DATA_SIZE 261
72
73typedef struct
74{
75 uint8_t pin_value[QL_SIM_PIN_LEN_MAX]; /* Value of the PIN */
76}QL_SIM_VERIFY_PIN_INFO;
77
78typedef struct
79{
80 uint8_t old_pin_value[QL_SIM_PIN_LEN_MAX]; /**< Value of the old PIN as a sequence of ASCII characters. */
81 uint8_t new_pin_value[QL_SIM_PIN_LEN_MAX]; /**< Value of the new PIN as a sequence of ASCII characters. */
82}QL_SIM_CHANGE_PIN_INFO;
83
84typedef struct
85{
86 uint8_t puk_value[QL_SIM_PIN_LEN_MAX]; /**< Value of the PUK as a sequence of ASCII characters. */
87 uint8_t new_pin_value[QL_SIM_PIN_LEN_MAX]; /**< Value of the new PIN as a sequence of ASCII characters. */
88}QL_SIM_UNBLOCK_PIN_INFO;
89
90typedef enum
91{
92 QL_SIM_STAT_NOT_INSERTED,
93 QL_SIM_STAT_READY,
94 QL_SIM_STAT_SIM_PIN,
95 QL_SIM_STAT_SIM_PUK,
96 QL_SIM_STAT_PH_SIM_LOCK_PIN,
97 QL_SIM_STAT_PH_SIM_LOCK_PUK,
98 QL_SIM_STAT_PH_FSIM_PIN,
99 QL_SIM_STAT_PH_FSIM_PUK,
100 QL_SIM_STAT_SIM_PIN2,
101 QL_SIM_STAT_SIM_PUK2,
102 QL_SIM_STAT_PH_NET_PIN,
103 QL_SIM_STAT_PH_NET_PUK,
104 QL_SIM_STAT_PH_NET_SUB_PIN,
105 QL_SIM_STAT_PH_NET_SUB_PUK,
106 QL_SIM_STAT_PH_SP_PIN,
107 QL_SIM_STAT_PH_SP_PUK,
108 QL_SIM_STAT_PH_CORP_PIN,
109 QL_SIM_STAT_PH_CORP_PUK,
110 QL_SIM_STAT_BUSY,
111 QL_SIM_STAT_BLOCKED,
112 QL_SIM_STAT_UNKNOWN
113}QL_SIM_CARD_STATE; /**< Card state. */
114typedef enum
115{
116 QL_SIM_CARD_TYPE_UNKNOWN = 0, /**< Unidentified card type. */
117 QL_SIM_CARD_TYPE_ICC = 1, /**< Card of SIM or RUIM type. */
118 QL_SIM_CARD_TYPE_UICC = 2, /**< Card of USIM or CSIM type. */
119}QL_SIM_CARD_TYPE;
120
121typedef enum CI_SIM_PRIM
122{
123 CI_SIM_PRIM_EXECCMD_REQ = 1, /**< \brief Requests to execute a SIM command \details */
124 CI_SIM_PRIM_EXECCMD_CNF, /**< \brief Confirms the request to execute a SIM command \details */
125 CI_SIM_PRIM_DEVICE_IND, /**< \brief Indicates that the current SIM status changed \details */
126 CI_SIM_PRIM_PERSONALIZEME_REQ, /**< \brief Requests that ME personalization be activated, deactivated, disabled, or queried \details */
127 CI_SIM_PRIM_PERSONALIZEME_CNF, /**< \brief Confirms the request to activate, deactivate, disable, or query ME personalization \details */
128 CI_SIM_PRIM_OPERCHV_REQ, /**< \brief Requests that CHVs be verified, enabled, disabled, changed, unblocked, or queried \details */
129 CI_SIM_PRIM_OPERCHV_CNF, /**< \brief Confirms the request to verify, enable, disable, change, unblock, or query CHVs \details */
130 CI_SIM_PRIM_DOWNLOADPROFILE_REQ, /**< \brief Requests a download of the profile that shows ME capabilities relevant to SIM Application Toolkit functionality \details The functionality of this primitive is equivalent to using the SIM command TERMINAL PROFILE in the CI_SIM_PRIM_EXECCMD_REQ primitive.
131 * This primitive saves upper layer effort to build a header for the Terminal Profile SIM command.
132 * If the pProfile pointer is NULL for this request, the communications interface assumes that the application layer does not support
133 * SIM Application Toolkit operations. */
134 CI_SIM_PRIM_DOWNLOADPROFILE_CNF, /**< \brief Confirms the request to download the profile that shows ME capabilities relevant to SIM Application Toolkit functionality \details */
135 CI_SIM_PRIM_ENDATSESSION_IND, /**< \brief \details NOT SUPPORTED REMOVE FROM API */
136 CI_SIM_PRIM_PROACTIVE_CMD_IND, /**< \brief Indicates a SIMAT proactive command \details This primitive forwards the SIMAT proactive command with its original syntax. The primitive CI_SIM_PRIM_ENABLE_SIMAT_INDS_REQ enables and disables proactive command indication. */
137 CI_SIM_PRIM_PROACTIVE_CMD_RSP, /**< \brief Responds to the SIMAT proactive command \details The primitive forwards a SIMAT proactive command response from the entity, such as DISPLAY or TERMINAL, that received the proactive command. */
138 CI_SIM_PRIM_ENVELOPE_CMD_REQ, /**< \brief Requests that an ENVELOPE command be executed \details */
139 CI_SIM_PRIM_ENVELOPE_CMD_CNF, /**< \brief Confirms the request to execute an ENVELOPE command \details */
140 CI_SIM_PRIM_GET_SUBSCRIBER_ID_REQ, /**< \brief Requests the subscriber ID \details */
141 CI_SIM_PRIM_GET_SUBSCRIBER_ID_CNF, /**< \brief Confirms the request for the subscriber ID \details */
142 CI_SIM_PRIM_GET_PIN_STATE_REQ, /**< \brief Requests the current PIN state \details */
143 CI_SIM_PRIM_GET_PIN_STATE_CNF, /**< \brief Confirms the request for the current PIN state \details */
144 CI_SIM_PRIM_GET_TERMINALPROFILE_REQ, /**< \brief Requests the SIMAT terminal profile \details */
145 CI_SIM_PRIM_GET_TERMINALPROFILE_CNF, /**< \brief Confirms the request and returns the SIMAT terminal profile \details */
146 CI_SIM_PRIM_ENABLE_SIMAT_INDS_REQ, /**< \brief Requests that SIMAT related indications, such as the proactive SIM command indication and the SIMAT session ended indication, be enabled or disabled \details */
147 CI_SIM_PRIM_ENABLE_SIMAT_INDS_CNF, /**< \brief Confirms the request to enable or disable SIMAT related indications \details */
148 CI_SIM_PRIM_LOCK_FACILITY_REQ, /**< \brief Requests to lock, unlock, or query SIM-related ME \details */
149 CI_SIM_PRIM_LOCK_FACILITY_CNF, /**< \brief Confirms a request to lock, unlock, or query SIM-related ME \details */
150 CI_SIM_PRIM_GET_FACILITY_CAP_REQ, /**< \brief Requests the bitmask of supported SIM-related facility codes \details */
151 CI_SIM_PRIM_GET_FACILITY_CAP_CNF, /**< \brief Confirms the request for the bitmask of supported SIM-related facility codes \details */
152 CI_SIM_PRIM_GET_SIMAT_NOTIFY_CAP_REQ, /**< \brief Requests SIM Application Toolkit (SIMAT) notification capability information. \details */
153 CI_SIM_PRIM_GET_SIMAT_NOTIFY_CAP_CNF, /**< \brief Confirms the request for SIM Application Toolkit (SIMAT) notification capability information \details */
154 CI_SIM_PRIM_GET_CALL_SETUP_ACK_IND, /**< \brief Indicates that the SIM Application Toolkit (SIMAT) has initiated an outgoing CALL SETUP operation, and requests confirmation/acknowledgment from the mobile user \details The application returns the required acknowledgment in a CI_SIM_PRIM_GET_CALL_SETUP_ACK_RSP response. */
155 CI_SIM_PRIM_GET_CALL_SETUP_ACK_RSP, /**< \brief Responds with an acknowledgment from the mobile user for an outgoing CALL SETUP indication \details The mobile user may accept (allow) or reject (disallow) the SIMAT initiated CALL SETUP operation.
156* If the user allows the CALL SETUP, it proceeds. If the user disallows the CALL SETUP, it is aborted.
157* If the CALL SETUP is allowed to proceed, the MO call progression is managed by the normal call control procedures. See the
158* CI CC Service Group API definition for more information. */
159
160 /* service provider name */
161 CI_SIM_PRIM_GET_SERVICE_PROVIDER_NAME_REQ, /**< \brief Requests the service provider name, as stored on SIM or USIM \details The PIN status is not required to read this information. */
162 CI_SIM_PRIM_GET_SERVICE_PROVIDER_NAME_CNF, /**< \brief Confirms the request to get the service provider name, as stored on SIM or USIM \details The service provider name is coded as 7-bit GSM characters, with the most-significant bit of each character set to zero.
163 * The service provider name pointer is NULL if the result code indicates an error. */
164
165 /* Message Waiting Information */
166 CI_SIM_PRIM_GET_MESSAGE_WAITING_INFO_REQ, /**< \brief Requests to get message waiting information stored on SIM or USIM \details The PIN status is required to read this information. */
167 CI_SIM_PRIM_GET_MESSAGE_WAITING_INFO_CNF, /**< \brief Confirms the request to get message waiting information stored on SIM or USIM \details If the result code indicates an error, the message waiting status information is not useful.
168 * There is a difference between the message categories defined for 2G and 3G SIM storage. This is rationalized by the CCI implementation. */
169 CI_SIM_PRIM_SET_MESSAGE_WAITING_INFO_REQ, /**< \brief Requests to set message waiting information on SIM or USIM \details Requires PIN status to write this information. There is a difference between the message categories defined for 2G and 3G SIM storage. This is rationalized by the CCI implementation. */
170 CI_SIM_PRIM_SET_MESSAGE_WAITING_INFO_CNF, /**< \brief Confirms a request to set the message waiting information on SIM or USIM \details */
171
172 /* SIM Service Table */
173 CI_SIM_PRIM_GET_SIM_SERVICE_TABLE_REQ, /**< \brief Requests to get the SIM Service Table from SIM or USIM \details The PIN status is required to read this information. If CPHS features are not supported by the handset, this information is unavailable. */
174 CI_SIM_PRIM_GET_SIM_SERVICE_TABLE_CNF, /**< \brief Confirms the request to get the SIM Service Table from SIM or USIM \details If CPHS features are not supported by the handset, this information is unavailable. */
175
176 /* CPHS Customer Service Profile */
177 CI_SIM_PRIM_GET_CUSTOMER_SERVICE_PROFILE_REQ, /**< \brief Requests to get the CPHS customer service profile from SIM or USIM \details The PIN status is required to read this information. If CPHS features are not supported by the handset, this information is unavailable. */
178 CI_SIM_PRIM_GET_CUSTOMER_SERVICE_PROFILE_CNF, /**< \brief Confirms the request and returns the CPHS customer service profile from SIM or USIM. \details If CPHS features are not supported by the handset, this information is unavailable. */
179
180 /* Display Alpha and Icon Identifiers */
181 CI_SIM_PRIM_SIMAT_DISPLAY_INFO_IND, /**< \brief Indicates to the application that text and optionally an icon should be displayed.
182 * The text to be displayed results from a SAT transaction such as SS, SMS, USSD, SS, or send DTMF. \details */
183
184 /* Default Language */
185 CI_SIM_PRIM_GET_DEFAULT_LANGUAGE_REQ, /**< \brief Requests the default language stored on the SIM/USIM card \details */
186 CI_SIM_PRIM_GET_DEFAULT_LANGUAGE_CNF, /**< \brief Confirms the request to get the default language stored on the SIM/USIM card and returns the first entry in the EF_LP file \details Extract from ETSI TS 102.221: "the language code is a pair of alphanumeric characters, as defined in ISO 639 [30].
187 * Each alphanumeric character shall be coded on one byte using the SMS default 7-bit coded alphabet as defined in TS 23.038
188 * ("Man-machine Interface (MMI) of the User Equipment", revision 3.4.0, Doc Number 3GPP TS 22.030)
189 * with bit 8 set to 0.". 'FF FF' means undefined default language. */
190
191 /* Generic SIM commands */
192 CI_SIM_PRIM_GENERIC_CMD_REQ, /**< \brief Requests to send a generic command to the SIM/USIM card
193 * \details The request reflects the structure of a SIM application protocol data unit (APDU),
194 * as defined in ETSI 102.221. The 'class of instruction' element is not controlled by the user, comm. use class 0x0 or 0xa depending on the command.
195 * Note that updating a file using this command only updates the file on the SIM; it does not trigger a REFRESH of the ME memory. */
196 CI_SIM_PRIM_GENERIC_CMD_CNF, /**< \brief Confirms a request to send a generic command to the SIM or USIM \details */
197
198 /* Indication of card type, status and PIN state */
199 CI_SIM_PRIM_CARD_IND, /**< \brief Indicates that the current SIM/USIM status changed \details This indication is sent each time CI_SIM_PRIM_DEVICE_IND is sent. */
200
201 CI_SIM_PRIM_IS_EMERGENCY_NUMBER_REQ, /**< \brief Requests to determine if the specified dial number is an emergency call code \details */
202 CI_SIM_PRIM_IS_EMERGENCY_NUMBER_CNF, /**< \brief Confirms the request to determine if the specified number is an emergency call code \details If a SIM card is present, the EF_ECC SIM card file is searched for the specified number. If a SIM card is not present, a default table of possible emergency call codes is searched for the specified number, as per TS 22.101. */
203
204 CI_SIM_PRIM_SIM_OWNED_IND, /**< \brief Indicates whether the SIM is owned
205 * \details This indication is sent each time a SIM-OK notification is received
206 * from the protocol stack and indicates that the SIM card can be accessed. SIM owned is TRUE if the IMSI did not change
207 * since the last SIM-OK notification. */
208 CI_SIM_PRIM_SIM_CHANGED_IND, /**< \brief Indicates whether the IMSI on the current SIM has changed
209 * \details This indication is sent each time a SIM-OK notification is received
210 * from the protocol stack. */
211 CI_SIM_PRIM_DEVICE_STATUS_REQ, /**< \brief Requests SIM status \details */
212 CI_SIM_PRIM_DEVICE_STATUS_CNF, /**< \brief Confirms the request for the current SIM status \details */
213 CI_SIM_PRIM_READ_MEP_CODES_REQ, /**< \brief Requests the MEP codes for a specified category \details This operation does not require a password.*/
214 CI_SIM_PRIM_READ_MEP_CODES_CNF, /**< \brief Confirms the request and returns the MEP codes for the specified category \details */
215 CI_SIM_PRIM_UDP_LOCK_REQ, /**< \brief Requests an activate, deactivate, or query UDP lock \details An operation can be done on only one category at a time. A password is required for an unlock operation. */
216 CI_SIM_PRIM_UDP_LOCK_CNF, /**< \brief Confirms the UDP lock request \details */
217 CI_SIM_PRIM_UDP_CHANGE_PASSWORD_REQ, /**< \brief Requests to set a new password for a UDP lock \details */
218 CI_SIM_PRIM_UDP_CHANGE_PASSWORD_CNF, /**< \brief Confirms the request to set a new password for a UDP lock \details */
219 CI_SIM_PRIM_UDP_ASL_REQ, /**< \brief Requests to manipulate the UDP authorized SIM list \details */
220 CI_SIM_PRIM_UDP_ASL_CNF, /**< \brief Confirms the request to manipulate the UDP authorized SIM list \details */
221/* Michal Bukai - Virtual SIM support - START */
222 CI_SIM_PRIM_SET_VSIM_REQ, /**< \brief Requests to enable virtual SIM
223 * \details Virtual SIM can be enabled if no SIM is inserted.
224 * An error is sent if the user tried to enable virtual SIM while a SIM is inserted.
225 * The application needs to reset the communication subsystem after receiving a confirmation. */
226 CI_SIM_PRIM_SET_VSIM_CNF, /**< \brief Confirms setting virtual SIM
227 * \details Virtual SIM can be enabled if no SIM is inserted.
228 * An error is sent if the user tried to enable virtual SIM while a SIM is inserted.
229 * The application needs to reset the communication subsystem after receiving a confirmation. */
230 CI_SIM_PRIM_GET_VSIM_REQ, /**< \brief Requests the current setting of the virtual SIM (enabled / disabled) \details*/
231 CI_SIM_PRIM_GET_VSIM_CNF, /**< \brief Confirms the request and returns the current setting of the virtual SIM (enabled / disabled) \details*/
232/* Michal Bukai - Virtual SIM support - END */
233/*Michal Bukai - OTA support for AT&T - START*/
234 CI_SIM_PRIM_CHECK_MMI_STATE_IND, /**< \brief \details NOT SUPPORTED REMOVE FROM API */
235 CI_SIM_PRIM_CHECK_MMI_STATE_RSP, /**< \brief \details NOT SUPPORTED REMOVE FROM API */
236/*Michal Bukai - OTA support for AT&T - END*/
237/*Michal Bukai - BT SAP support - START*/
238 CI_SIM_PRIM_BTSAP_CONNECT_REQ, /**< \brief Requests to start a BT SAP session \details */
239 CI_SIM_PRIM_BTSAP_CONNECT_CNF, /**< \brief Confirms the request to start a BT SAP session \details */
240 CI_SIM_PRIM_BTSAP_DISCONNECT_REQ, /**< \brief Requests to disconnect from a BT SAP session \details */
241 CI_SIM_PRIM_BTSAP_DISCONNECT_CNF, /**< \brief Confirms the request to disconnect from a BT SAP session \details */
242 CI_SIM_PRIM_BTSAP_TRANSFER_APDU_REQ, /**< \brief Requests to transfer APDU to the SIM/USIM \details */
243 CI_SIM_PRIM_BTSAP_TRANSFER_APDU_CNF, /**< \brief Confirms the request to transfer APDU to the SIM/USIM and may return a response APDU from the SIM/USIM \details */
244 CI_SIM_PRIM_BTSAP_TRANSFER_ATR_REQ, /**< \brief Requests to get Answer To Reset data from SIM/USIM \details */
245 CI_SIM_PRIM_BTSAP_TRANSFER_ATR_CNF, /**< \brief Confirms the request to get Answer To Reset data from SIM/USIM \details */
246 CI_SIM_PRIM_BTSAP_SIM_CONTROL_REQ, /**< \brief Requests to control SIM/USIM status, this command can be used to power off, power on or reset the SIM/USIM \details */
247 CI_SIM_PRIM_BTSAP_SIM_CONTROL_CNF, /**< \brief Confirms the SIM control request \details */
248 CI_SIM_PRIM_BTSAP_STATUS_IND, /**< \brief indicates a change in the availably of the subscription module during BT SAP connection \details */
249 CI_SIM_PRIM_BTSAP_STATUS_REQ, /**< \brief Requests the subscription module availability status during BT SAP connection \details */
250 CI_SIM_PRIM_BTSAP_STATUS_CNF, /**< \brief Confirms the request and returns the status of the subscription module during BT SAP connection \details */
251 CI_SIM_PRIM_BTSAP_SET_TRANSPORT_PROTOCOL_REQ, /**< \brief Requests to set transport protocol \details */
252 CI_SIM_PRIM_BTSAP_SET_TRANSPORT_PROTOCOL_CNF, /**< \brief Confirms the request to set transport protocol \details */
253/*Michal Bukai - BT SAP support - END*/
254/*Michal Bukai - Add IMSI to MEP code group - START*/
255 CI_SIM_PRIM_MEP_ADD_IMSI_REQ, /**< \brief Requests to add the current IMSI to MEP SIM /USIM code group
256 * \details This operation requires a password.
257 * This operation requires that SIM/USIM personalization is deactivated.*/
258 CI_SIM_PRIM_MEP_ADD_IMSI_CNF, /**< \brief Confirms the request to add the current IMSI to MEP SIM /USIM code group. \details */
259/*Michal Bukai - Add IMSI to MEP code group - END*/
260/*Michal Bukai - SIM Logic CH - NFC\ISIM support - START*/
261 CI_SIM_PRIM_OPEN_LOGICAL_CHANNEL_REQ, /**< \brief Requests to open a logical channel that will be used to access the UICC application identified by DFname. \details The UICC will open a new logical channel; select the application identified by the DFname, and return a session ID that will be used to identify the new channel.*/
262 CI_SIM_PRIM_OPEN_LOGICAL_CHANNEL_CNF, /**< \brief Confirms the request to open a logical channel and returns the session ID. \details */
263 CI_SIM_PRIM_CLOSE_LOGICAL_CHANNEL_REQ, /**< \brief Requests to close a logical channel. \details */
264 CI_SIM_PRIM_CLOSE_LOGICAL_CHANNEL_CNF, /**< \brief Confirms the request to close a logical channel. \details */
265/*Michal Bukai - SIM Logic CH - NFC\ISIM support support - END*/
266/*Michal Bukai - additional SIMAT primitives - START*/
267 CI_SIM_PRIM_SIMAT_CC_STATUS_IND, /**< \brief Indicates the SIM Application Toolkit (SIMAT) call control status response
268 * \details If call control service in SIMAT is activated, all dialled digit strings, supplementary service control strings and USSD strings are passed to the UICC before the call setup request,
269 * the supplementary service operation or the USSD operation is sent to the network.
270 * The SIMAT has the ability to allow, bar or modify the request.
271 * In addition SIMAT has the ability to replace the request by another operation, for instance call request may be replaced by SS or USSD operation.
272 */
273 CI_SIM_PRIM_SIMAT_SEND_CALL_SETUP_RSP_IND, /**< \brief Indicates the response sent to SIM Application Toolkit (SIMAT) after call setup. \details */
274 CI_SIM_PRIM_SIMAT_SEND_SS_USSD_RSP_IND, /**< \brief Indicates the response sent to SIM Application Toolkit (SIMAT) after SS or USSD operation. \details */
275 CI_SIM_PRIM_SIMAT_SM_CONTROL_STATUS_IND, /**< \brief Indicates the SIM Application Toolkit (SIMAT) short message control status response.
276 \details If SM control service in SIMAT is activated, all MO short messages are passed to the UICC before the short message is sent to the network.
277 * The SIMAT has the ability to allow, bar or modify the destination address.
278 */
279 CI_SIM_PRIM_SIMAT_SEND_SM_RSP_IND, /**< \brief Indicates the response sent to SIM Application Toolkit (SIMAT) after SM operation. \details */
280/*Michal Bukai - additional SIMAT primitives - END*/
281
282/*Michal Bukai - RSAP support - START*/
283 CI_SIM_PRIM_RSAP_CONN_REQ_IND, /**< \brief Request to connect to a remote SIM received from the protocol stack \details */
284 CI_SIM_PRIM_RSAP_CONN_REQ_RSP, /**< \Response to protocol stack request to connect to a remote SIM \details */
285 CI_SIM_PRIM_RSAP_STAT_REQ, /**< \brief Request received from a SAP conversion module to update the RSAP card status.
286 * \details This request is actually an indication from a remote SAP conversion module indicating a status change in the remote connection or card status */
287 CI_SIM_PRIM_RSAP_STAT_CNF, /**< \brief Confirms that the update of the remote card status was received by the protocol stack \details */
288 CI_SIM_PRIM_RSAP_DISCONN_REQ_IND, /**< \brief Request to disconnect from a remote SIM received from the protocol stack \details */
289 CI_SIM_PRIM_RSAP_DISCONN_REQ_RSP, /**< \Response to protocol stack request to disconnect from a remote SIM \details */
290 CI_SIM_PRIM_RSAP_GET_ATR_IND, /**< \brief Request to get ATR from a remote SIM received from the protocol stack \details */
291 CI_SIM_PRIM_RSAP_GET_ATR_RSP, /**< \brief Response from a remote SIM with the ATR APDU \details */
292 CI_SIM_PRIM_RSAP_GET_STATUS_REQ_IND, /**< \brief Request from the protocol stack to get the RSAP connection status.
293 * \details The request is answered by CI_SIM_PRIM_RSAP_CONN_STAT_REQ */
294
295 CI_SIM_PRIM_RSAP_SET_TRAN_P_REQ_IND, /**< \brief Request from the protocol stack to change the transport protocol of the remote SIM \details */
296 CI_SIM_PRIM_RSAP_SET_TRAN_P_REQ_RSP, /**< \brief Response to a protocol stack request to change the transport protocol of the remote SIM.
297 * \details If the requested transport protocol is supported by the remote SIM and by the SAP conversion module,
298 * the requested transport protocol is selected and the remote SIM is reset. If the requested transport protocol is not supported,
299 * SIM status is changed to CARD_NOT_ACC. The request is followed by CI_SIM_PRIM_RSAP_CONN_STAT_REQ, which indicates the new remote SIM status.*/
300 CI_SIM_PRIM_RSAP_SIM_CONTROL_REQ_IND, /**< \brief Request from the protocol stack to control the remote SIM status.
301 * \details This command can be used to power off, power on, or reset the remote SIM */
302 CI_SIM_PRIM_RSAP_SIM_CONTROL_REQ_RSP, /**< \brief Response to a protocol stack request to control the remote SIM status.
303 * \details The response is followed by CI_SIM_PRIM_RSAP_CONN_STAT_REQ, which indicates the new status of the remote SIM.*/
304 CI_SIM_PRIM_RSAP_SIM_SELECT_REQ, /**< \brief Request to select the local or remote SIM \details */
305 CI_SIM_PRIM_RSAP_SIM_SELECT_CNF, /**< \brief Confirms the request to select the local or remote SIM \details */
306 CI_SIM_PRIM_RSAP_STATUS_IND, /**< \brief Indicates that the current SIM/USIM status changed during RSAP connection \details */
307 CI_SIM_PRIM_RSAP_TRANSFER_APDU_IND, /**< \brief Request from the protocol stack to transfer APDU to the remote SIM \details */
308 CI_SIM_PRIM_RSAP_TRANSFER_APDU_RSP, /**< \brief Request from the protocol stack to transfer APDU to the remote SIM.
309 * \details A response APDU is returned if the transfer of APDU is successful.*/
310 /*Michal Bukai - RSAP support - END*/
311
312 CI_SIM_PRIM_DEVICE_RSP, /**< \brief Response to CI_SIM_PRIM_DEVICE_RSP.
313 * \details This response is confirms that the CI_SIM_PRIM_DEVICE_RSP has been received and handled. Specially the SIM clock stop level. This indicates the Comm that D2 can be enabled on SIM driver level.*/
314//ICC ID feature
315 CI_SIM_PRIM_ICCID_IND, /**< \brief Indicates the content of the EF-ICCID file. This indication is sent at init. The EF-ICCID can be accessed even if PIN is required.*/
316 CI_SIM_PRIM_GET_ICCID_REQ, /**< \brief Request to get the content of the EF-ICCID file. Can be sent if ICC is ready.
317 * \details Can be sent when the SIM state is CI_SIM_ST_READY or CI_SIM_ST_INSERTED. Otherwise the request will fail.*/
318
319 CI_SIM_PRIM_GET_ICCID_CNF, /**< \brief Confirmation with the ICC id to the request to get the ICC Id.*/
320//ICC ID feature
321 CI_SIM_PRIM_EAP_AUTHENTICATION_REQ, /**< \brief Requests to exchange EAP packets with the UICC. */
322 CI_SIM_PRIM_EAP_AUTHENTICATION_CNF, /**< \brief Confirms the EAP authentication request and returns the authentication response */
323
324 CI_SIM_EAP_RETRIEVE_PARAMETERS_REQ, /**< \brief Requests to retrieve EAP parameters from the UICC. */
325 CI_SIM_EAP_RETRIEVE_PARAMETERS_CNF, /**< \brief Confirms the request to retrieve EAP parameters and returns the contents of the
326 * \elementary file corresponding to requested parameter.*/
327
328 CI_SIM_PRIM_GET_NUM_UICC_APPLICATIONS_REQ,/**< \brief Requests to get number of applications available on the UICC. */
329 CI_SIM_PRIM_GET_NUM_UICC_APPLICATIONS_CNF,/**< \brief Confirms the request to get number of applications available on the UICC. */
330
331 CI_SIM_PRIM_GET_UICC_APPLICATIONS_INFO_REQ, /**< \brief Requests to get list of applications available on the UICC. */
332 CI_SIM_PRIM_GET_UICC_APPLICATIONS_INFO_CNF, /**< \brief Confirms the request to get list of applications available on the UICC. */
333 /* ADD NEW COMMON PRIMITIVES HERE, BEFORE 'CI_SIM_PRIM_LAST_COMMON_PRIM' */
334 /*2013.12.11, added by Xili for CQ00051618, begin*/
335 CI_SIM_PRIM_ISIM_AID_IND, /**< \brief Indicates the content of the ISIM Aid. This indication is sent at init if it had one. */
336 /*2013.12.11, added by Xili for CQ00051618, end*/
337
338 /* Add by jungle for CQ00057999 on 2014-04-02 Begin */
339 CI_SIM_PRIM_APP_PIN_REQ,
340 CI_SIM_PRIM_APP_PIN_CNF,
341 /* Add by jungle for CQ00057999 on 2014-04-02 End*/
342
343 /*2014.05.08, added by Xili for CQ00060947, begin*/
344 CI_SIM_PRIM_ADMIN_DATA_IND,
345 /*2014.05.08, added by Xili for CQ00060947, end*/
346
347 /*2015.03.19, mod by Xili for adding ECC list indication, CQ00088196 begin*/
348 CI_SIM_PRIM_ECC_LIST_IND,
349 /*2015.03.19, mod by Xili for adding ECC list indication, CQ00088196 end*/
350
351 /* Mod by jungle for CQ00089692 on 2015-04-08 Begin */
352 CI_SIM_PRIM_EXEC_LARGE_CMD_CNF,
353 CI_SIM_PRIM_GENERIC_LARGE_CMD_CNF,
354 /* Mod by jungle for CQ00089692 on 2015-04-08 End */
355
356 CI_SIM_PRIM_UPDATE_COUNT_REQ,
357 CI_SIM_PRIM_UPDATE_COUNT_CNF,
358
359 /* END OF COMMON PRIMITIVES LIST */
360 CI_SIM_PRIM_LAST_COMMON_PRIM
361
362 /* The customer specific extension primitives are added starting from
363 * CI_SIM_PRIM_firstCustPrim = CI_SIM_PRIM_LAST_COMMON_PRIM as the first identifier.
364 * The actual primitive names and IDs are defined in the associated
365 * 'ci_sim_cust_xxx.h' file.
366 */
367
368 /* DO NOT ADD ANY MORE PRIMITIVES HERE */
369
370} _QuecCiSimPrim;
371
372typedef struct
373{
374 uint8_t pin1_num_retries; /**< Number of PIN 1 retries. */
375 uint8_t puk1_num_retries; /**< Number of PUK 1 retries. */
376 uint8_t pin2_num_retries; /**< Number of PIN 2 retries. */
377 uint8_t puk2_num_retries; /**< Number of PUK 2 retries. */
378}QL_SIM_CARD_PIN_INFO;
379
380typedef struct
381{
382 QL_SIM_CARD_TYPE card_type; // SIM card type
383 QL_SIM_CARD_STATE card_state; //SIM card state
384 QL_SIM_CARD_PIN_INFO card_pin_info; // PIN info
385}QL_SIM_CARD_STATUS_INFO;
386
387
388#define QL_SIM_DATA_LEN_MAX 255
389typedef struct
390{
391 uint32_t data_len; /**< Must be set to the number of elements in data. */
392 uint8_t data[QL_SIM_DATA_LEN_MAX]; /**< Data retrieved from the card. */
393}QL_SIM_CARD_FILE_DATA;
394
395typedef enum
396{
397 QL_SIM_FILE_TYPE_UNKNOWN = 0,/**< Unknown file type */
398 QL_SIM_FILE_TYPE_TRANSPARENT = 1,/**< File structure consisting of a sequence of bytes. */
399 QL_SIM_FILE_TYPE_CYCLIC = 2,/**< File structure consisting of a sequence of records, each containing the same fixed size in
400 chronological order. Once all the records have been used, the oldest data is overwritten. */
401 QL_SIM_FILE_TYPE_LINEAR_FIXED = 3, /**< File structure consisting of a sequence of records, each containing the same fixed size. */
402}QL_SIM_FILE_TYPE;
403
404typedef enum
405{
406 QL_SIM_FILE_ACCESS_TYPE_ALWAYS =0,
407 QL_SIM_FILE_ACCESS_TYPE_CHV1 =1,
408 QL_SIM_FILE_ACCESS_TYPE_CHV2 =2,
409 QL_SIM_FILE_ACCESS_TYPE_ADM =3,
410}QL_SIM_FILE_ACCESS_TYPE;
411
412typedef enum
413{
414 QL_SIM_FILE_STATUS_INVALID =0,
415 QL_SIM_FILE_STATUS_EFFECTIVE =1,
416}QL_SIM_FILE_STATUS;
417
418typedef struct
419{
420 QL_SIM_FILE_ACCESS_TYPE read_access;
421 QL_SIM_FILE_ACCESS_TYPE update_access;
422}QL_SIM_FILE_ACCESS_INFO;
423
424typedef struct
425{
426 unsigned int id;
427 QL_SIM_FILE_TYPE type; /**< File type: */
428 QL_SIM_FILE_ACCESS_INFO access; /**< File access conditions: */
429 QL_SIM_FILE_STATUS status; /**< File status: */
430 unsigned int size; /**< Size of transparent files.*/
431 unsigned int record_len; /**< Size of each cyclic or linear fixed file record.*/
432 unsigned int record_count; /**< Number of cyclic or linear fixed file records.*/
433}QL_SIM_FILE_INFO;
434
435typedef struct
436{
437 int sw1;
438 int sw2;
439}QL_SIM_FILE_OPERATION_RET;
440
441typedef struct
442{ // when write, if phonenum is empty, it means to delete this item specified by index
443 int index; // the record index in phone book
444 uint8_t username[32]; // username
445 uint8_t phonenum[24]; // Phone number, it can include '+'*/
446}QL_SIM_PHONE_BOOK_RECORD_INFO;
447
448typedef struct
449{
450 int total; //total number of locations
451 int used; //used number of locations
452}QL_SIM_PHONEBOOK_STATE;
453
454#define QL_SIM_PHONE_BOOK_RECORDS_MAX_COUNT 20
455typedef struct
456{
457 int record_count; //the count of record
458 QL_SIM_PHONE_BOOK_RECORD_INFO record[QL_SIM_PHONE_BOOK_RECORDS_MAX_COUNT]; // the list of record
459}QL_SIM_PHONE_BOOK_RECORDS_INFO;
460
461typedef enum
462{
463 QL_SIM_PHONE_BOOK_STORAGE_DC,
464 QL_SIM_PHONE_BOOK_STORAGE_EN,
465 QL_SIM_PHONE_BOOK_STORAGE_FD,
466 QL_SIM_PHONE_BOOK_STORAGE_LD,
467 QL_SIM_PHONE_BOOK_STORAGE_MC,
468 QL_SIM_PHONE_BOOK_STORAGE_ME,
469 QL_SIM_PHONE_BOOK_STORAGE_MT,
470 QL_SIM_PHONE_BOOK_STORAGE_ON,
471 QL_SIM_PHONE_BOOK_STORAGE_RC,
472 QL_SIM_PHONE_BOOK_STORAGE_SM,
473 QL_SIM_PHONE_BOOK_STORAGE_AP,
474 QL_SIM_PHONE_BOOK_STORAGE_MBDN,
475 QL_SIM_PHONE_BOOK_STORAGE_MN,
476 QL_SIM_PHONE_BOOK_STORAGE_SDN,
477 QL_SIM_PHONE_BOOK_STORAGE_ICI,
478 QL_SIM_PHONE_BOOK_STORAGE_OCI,
479}QL_SIM_PHONE_BOOK_STORAGE;
480
481
482
483typedef enum
484{
485 QL_SIM_CARD_STATUS_UPDATE_EVENT = 0, /**< Card status update event. */
486
487}QL_SIM_NFY_MSG_ID;
488
489typedef void (*QL_SIM_CardStatusIndMsgHandlerFunc_t)
490(
491 QL_SIM_NFY_MSG_ID msg_id,
492 void *pv_data,
493 int pv_data_len,
494 void *contextPtr
495);
496
497
498QL_SIM_ERROR_CODE ql_sim_init();
499
500QL_SIM_ERROR_CODE ql_sim_release();
501
502/* Add callback function if anything changed specified by the mask in QL_LOC_Set_Indications*/
503QL_SIM_ERROR_CODE ql_sim_add_event_handler(QL_SIM_CardStatusIndMsgHandlerFunc_t handlerPtr, void* contextPtr);
504
505/*===========================================================================
506
507 FUNCTION: ql_sim_get_imsi
508
509===========================================================================*/
510/*
511 @brief
512 Function sends a command to the modem to retrieve the IMSI (for 3GPP)
513 or IMSI_M (for 3GPP2) from the SIM in ASCII form
514
515 @return
516 void
517*/
518/*=========================================================================*/
519QL_SIM_ERROR_CODE ql_sim_get_imsi
520(
521 uint8_t *imsi, ///< [OUT] IMSI buffer
522 size_t imsiLen ///< [IN] IMSI buffer length
523);
524
525
526/*===========================================================================
527
528 FUNCTION: ql_sim_get_iccid
529
530===========================================================================*/
531/*
532 @brief
533 Function sends a command to the modem to retrieve the ICCID from
534 SIM in ASCII form
535
536 @return
537 QL_SIM_ERROR_CODE
538*/
539/*=========================================================================*/
540QL_SIM_ERROR_CODE ql_sim_get_iccid
541(
542 uint8_t *iccid, ///< [OUT] ICCID
543 size_t iccidLen ///< [IN] ICCID buffer length
544);
545
546
547/*===========================================================================
548
549 FUNCTION: QL_SIM_GetPhoql_sim_get_phonenumberneNumber
550
551===========================================================================*/
552/*
553 @brief
554 Function sends a command to the modem to retrieve the device phone
555 number from MSISDN (for 3GPP) or MDN (for 3GPP2) from the SIM in
556 ASCII form
557
558 @return
559 QL_SIM_ERROR_CODE
560*/
561/*=========================================================================*/
562QL_SIM_ERROR_CODE ql_sim_get_phonenumber
563(
564 uint8_t *phone_num, ///< [OUT] phone number
565 size_t phoneLen ///< [IN] phone number buffer length
566);
567
568/*===========================================================================
569
570 FUNCTION: ql_sim_get_operator_plmn_list
571
572===========================================================================*/
573/*
574 @brief
575 Function sends multiple record based read commands to the modem
576 to retrieve a list of operator preffered PLMN.
577
578 @note
579 Function should only be called for SIM/USIM
580
581 @return
582 QL_SIM_ERROR_CODE
583*/
584/*=========================================================================*/
585QL_SIM_ERROR_CODE ql_sim_get_operator_plmn_list
586(
587 QL_SIM_PREFERRED_OPERATOR_LIST *pt_info ///< [OUT] Preferred operator list
588);
589
590/*===========================================================================
591
592 FUNCTION: ql_sim_verify_pin
593
594===========================================================================*/
595/*
596 @brief
597 Function sends a command to the modem to verify either PIN1 or PIN2
598
599 @return
600 QL_SIM_ERROR_CODE
601*/
602/*=========================================================================*/
603QL_SIM_ERROR_CODE ql_sim_verify_pin
604(
605 QL_SIM_VERIFY_PIN_INFO *pt_info // [IN] PIN/PIN2
606);
607
608
609/*===========================================================================
610
611 FUNCTION: ql_sim_change_pin
612
613===========================================================================*/
614/*
615 @brief
616 Function sends a command to the modem to change the value of
617 either PIN
618
619 @return
620 QL_SIM_ERROR_CODE
621*/
622/*=========================================================================*/
623QL_SIM_ERROR_CODE ql_sim_change_pin
624(
625 QL_SIM_CHANGE_PIN_INFO *pt_info // [IN] PIN
626);
627
628
629/*===========================================================================
630
631 FUNCTION: ql_sim_unblock_pin
632
633===========================================================================*/
634/*
635 @brief
636 Function sends a command to the modem to unblock a PIN1 or PIN2 that
637 has been blocked
638
639 @return
640 QL_SIM_ERROR_CODE
641*/
642/*=========================================================================*/
643QL_SIM_ERROR_CODE ql_sim_unblock_pin
644(
645 QL_SIM_UNBLOCK_PIN_INFO *pt_info // [IN] input PUK/PUK2 and new PIN/PIN2
646);
647
648/*===========================================================================
649
650 FUNCTION: ql_sim_enable_pin
651
652===========================================================================*/
653/*
654 @brief
655 Function sends a command to the modem to enable PIN
656
657 @return
658 QL_SIM_ERROR_CODE
659*/
660/*=========================================================================*/
661QL_SIM_ERROR_CODE ql_sim_enable_pin
662(
663 QL_SIM_VERIFY_PIN_INFO *pt_info // [IN] PIN
664);
665
666/*===========================================================================
667
668 FUNCTION: ql_sim_disable_pin
669
670===========================================================================*/
671/*
672 @brief
673 Function sends a command to the modem to disable PIN
674
675 @return
676 QL_SIM_ERROR_CODE
677*/
678/*=========================================================================*/
679QL_SIM_ERROR_CODE ql_sim_disable_pin
680(
681 QL_SIM_VERIFY_PIN_INFO *pt_info // [IN] PIN
682);
683
684
685/*===========================================================================
686
687 FUNCTION: ql_sim_get_card_status
688
689===========================================================================*/
690/*
691 @brief
692 Function get sim card status informations
693
694 @return
695 QL_SIM_ERROR_CODE
696*/
697/*=========================================================================*/
698QL_SIM_ERROR_CODE ql_sim_get_card_status
699(
700 QL_SIM_CARD_STATUS_INFO *pt_info ///< [OUT] sim card status info output
701);
702
703
704
705/*===========================================================================
706
707 FUNCTION: ql_sim_get_file_info
708
709===========================================================================*/
710/*
711 @brief
712 Function sends a command to the modem to retrieve the file info
713
714 @return
715 QL_SIM_ERROR_CODE
716*/
717/*=========================================================================*/
718QL_SIM_ERROR_CODE ql_sim_get_file_info
719(
720 unsigned int fileid,
721 QL_SIM_FILE_INFO *file_info, // [OUT] output file info
722 QL_SIM_FILE_OPERATION_RET *operation_ret // [OUT] return the operation status code
723);
724
725/*===========================================================================
726
727 FUNCTION: ql_sim_read_file
728
729===========================================================================*/
730/*
731 @brief
732 Function get the data of a EF file.
733
734 @return
735 QL_SIM_ERROR_CODE
736*/
737/*=========================================================================*/
738QL_SIM_ERROR_CODE ql_sim_read_file
739(
740 unsigned int fileid, // EF file id
741 unsigned int index, // the index of record for a record EF file, the offest of date for a transparent EF file.
742 unsigned int data_max_len, // the max length of output data.
743 QL_SIM_CARD_FILE_DATA *file_data, // [OUT] File data
744 QL_SIM_FILE_OPERATION_RET *operation_ret // [OUT] return the operation status code
745);
746
747/*===========================================================================
748
749 FUNCTION: ql_sim_write_file
750
751===========================================================================*/
752/*
753 @brief
754 Function write data to a EF file.
755
756 @return
757 QL_SIM_ERROR_CODE
758*/
759/*=========================================================================*/
760QL_SIM_ERROR_CODE ql_sim_write_file
761(
762 unsigned int fileid, // EF file id
763 int index, // the index of record for a record EF file, the offest of date for a transparent EF file.
764 QL_SIM_CARD_FILE_DATA *file_data, ///< [IN] File data of the specified one by pt_info
765 QL_SIM_FILE_OPERATION_RET *operation_ret // [OUT] return the operation status code
766);
767
768
769/*===========================================================================
770
771 FUNCTION: ql_sim_read_phonebook_record
772
773===========================================================================*/
774/*
775 @brief
776 Function will get the phone book record.
777
778 @return
779 QL_SIM_ERROR_CODE
780*/
781/*=========================================================================*/
782QL_SIM_ERROR_CODE ql_sim_read_phonebook_record
783(
784 QL_SIM_PHONE_BOOK_STORAGE storage, //IN the storage position of the phone book
785 int start_index, // the start index of records, 0: read record by username.
786 int end_index, // the end index of records
787 uint8_t *username, // the username in a record, it is valid when start_index is 0
788 QL_SIM_PHONE_BOOK_RECORDS_INFO *records // the list of records
789);
790
791
792/*===========================================================================
793
794 FUNCTION: ql_sim_write_phonebook_record
795
796===========================================================================*/
797/*
798 @brief
799 Function will write a record to a phone book.
800
801 @return
802 QL_SIM_ERROR_CODE
803*/
804/*=========================================================================*/
805QL_SIM_ERROR_CODE ql_sim_write_phonebook_record
806(
807 QL_SIM_PHONE_BOOK_STORAGE storage, //IN the storage position of the phone book
808 QL_SIM_PHONE_BOOK_RECORD_INFO *record //IN a record
809);
810
811
812/*===========================================================================*/
813/*
814 @brief
815 Function will return the state of currently selected phonebook
816
817 @return
818 QL_SIM_ERROR_CODE
819*/
820/*=========================================================================*/
821QL_SIM_ERROR_CODE ql_sim_get_phonebook_state(QL_SIM_PHONEBOOK_STATE *state);
822
823
824/*===========================================================================*/
825/*
826 @brief
827 Function will request to select the local or remote SIM
828
829 @return
830 QL_SIM_ERROR_CODE
831*/
832/*=========================================================================*/
833QL_SIM_ERROR_CODE ql_sim_select(UINT service, UINT is_remote);
834
835
836#ifdef __cplusplus
837}
838#endif
839
840#endif