nrf9160

Set command

The set command transmits a command to a selected Universal Integrated Circuit Card (UICC) using an opened logical channel. The UICC response is sent back to the Terminal Adapter (TA) as it is.

The command allows direct control of the currently selected UICC by a distant application on the Terminal Equipment (TE). The TE processes the UICC information.

The command transmitted to the UICC is formatted as a command Application Protocol Data Unit (APDU). ETSI TS 102 221, Ch. 10.1 defines four different cases of the command's APDU structure. The structure depends on whether the command sends data to UICC and whether the expected response has data bytes or only status bytes.

The cases are the following:

Le can be set to 00 if the exact amount of response data is not known. In this case, the maximum number of available data (up to 256 bytes) is returned in the <response> string.

If Le is omitted and the UICC has response data to send, or the amount of response data on the UICC is different from the Le, the UICC can indicate it by status byte values 61xx or 6Cxx where xx indicates the number of bytes available on the UICC. If the status byte value is 61xx, the response data can be read by issuing the GET RESPONSE command with Le value xx. If the status byte value is 6Cxx, the previous command must be repeated with the Le value xx to read the response data from the UICC.

This can result in failure due to a crossover if the modem firmware has sent another APDU between the original command and GET RESPONSE which clears the previous response data. The risk of crossover can be reduced by activating the modem in UICC only mode with the +CFUN=41 command. Depending on the UICC, there can still be some interfering Universal Subscriber Identity Module Application Toolkit (USAT) activity. If the GET RESPONSE command fails, the command must be issued again.

Note: Executing a Run GSM Algorithm command or an Authenticate command from the TE using the +CGLA command is not supported.

Syntax:

+CGLA=<sessionid>,<length>,<command>

Response syntax:

+CGLA: <length>,<response>
+CME ERROR code
11 – SIM PIN required.
12 – SIM PUK required.
13 – SIM failure.
14 – SIM busy.
17 – SIM PIN2 required.
18 – SIM PUK2 required.

The set command parameters and their defined values are the following:

<sessionid>
Integer.
Session ID used to target a specific application on a smart card, such as Universal Subscriber Identity Module (USIM), using the opened logical channel.
The <sessionid> must be acquired with the +CCHO command before entering +CGLA commands. It must be released with the +CCHC command after the last +CGLA command.
<length>
Integer. Number of hexadecimal characters in the <command> or <response> string.
<command>
The command passed to the SIM in hexadecimal format. Two characters per byte. Contains CLA, INS, P1, P2, and optionally Lc, Data, and Le bytes according to the command APDU structure specification in ETSI TS 102 221, Ch. 10.1.
<response>
The response from the SIM in hexadecimal format. Two characters per byte. Contains optional data bytes and SW1, SW2 according to the response APDU structure specification in ETSI TS 102 221, Ch. 10.2.

The following command example shows the STATUS command returning the currently selected AID on the channel when CLA is 80, INS is F2, P1 is 00, P2 is 01, and Le is 00. The response contains the DF name TLV object (tag, length, and AID) and status bytes SW1 and SW2:

AT+CGLA=2,10,"80F2000100"
+CGLA: 32,"840CA0000000871004FF49FF05899000"
OK

The following command example shows the SELECT command sending four bytes of data to UICC. The Le byte is omitted, so the UICC indicates only the available amount of response data by status bytes 611E with 30 bytes available. The CLA is 00, INS is A4, P1 is 08, P2 is 04, Lc is 04, and the sent data is 7FFF6F7B.

The GET RESPONSE command reads the response data of the previously issued SELECT command. The CLA is 00, INS is C0, P1 is 00, P2 is 00, and Le is 1E:

AT+CGLA=1,18,"00A40804047FFF6F7B"
+CGLA: 4,"611E"
OK

AT+CGLA=1,10,"00C000001E"
+CGLA: 64,"621C8202412183026F7BA5038001618A01058B036F0602800200128801689000"
OK

The following command example shows the SELECT command sending four bytes of data to UICC. Le byte is set to 00. The CLA is 00, INS is A4, P1 is 08, P2 is 04, Lc is 04, the sent data is 7FFF6F7B, and Le is 00. When the Le byte is 00, the modem automatically issues the GET RESPONSE command and returns full response data:

AT+CGLA=1,20,"00A40804047FFF6F7B00"
+CGLA: 64,"621C8202412183026F7BA5038001618A01058B036F0602800200128801689000"
OK