Thales' cellular IoT products business is now part of Telit Cinterion, find out more.

You are here

Telit Cinterion IoT Developer Community

How to query PIN counter on EHSx

Tutorial, March 22, 2016 - 10:02am, 8230 views

EHSx doesn't have a special command like AT^**** on BGS2 to query available remaining PIN counter, but this doesn't mean one has to give up on EHSx or any module that doesn't have a PIN counter query command.

To read SIM PIN counter more complex procedure is required:

1. Check whether the card is SIM or USIM AT+CRSM=242 The response can be for example +CRSM: 144,0,"62298202782183023F00A509800131830400006D988A01058B032F0603C60C90016083010183010A83010D" (USIM response – the firs byte is 0x62) or +CRSM: 144,0,"000000007F2002FAFFAAFF010E1300170600838A818A0083000022" (SIM response) 

2. For USIM scenario (see also ETSI TS 102 221), use AT+CSIM=14,"00A4000C027FFF" to select the USIM Application directory first, then send additional commands:

a. Use AT+CSIM=10,"0020000100" to check the PIN counter 

b. Use AT+CSIM=10,"002C000100" to check the PUK counter 

c. Use AT+CSIM=10,"0020008100" to check the PIN2 counter 

d. Use AT+CSIM=10,"002C008100" to check the PUK2 counter

The responses will be either

+CSIM: 4,"63CX" where X is the hex-value of remaining retries for the  corresponding key (usually X is 0-A = 0-10 retries remaining)

+CSIM: 4,"6A88" which means that the corresponding key is not initialized (= not available)

+CSIM: 4,"6983" which means that the corresponding key is blocked. 

Appears every subsequent check after 63C0 has been reached (example: 63C3 -> 63C2 -> 63C1 -> 63C0 -> 6983 -> 6983 .).

Example for PIN counter check with prior USIM Application directory selection:

AT+CSIM=14,"00A4000C027FFF";+CSIM=10,"0020000100"

+CSIM: 4,"9000" -> response of USIM Application directory selection, 

-> will always be '9000' = successful

+CSIM: 4,"63C3" -> 3 retries left

OK

Examples for AT+CPIN with wrong PIN:

AT+CPIN=9998

+CME ERROR: incorrect password

AT+CSIM=14,"00A4000C027FFF";+CSIM=10,"0020000100"

+CSIM: 4,"9000" -> response of USIM Application directory selection, 

'9000' = successful

+CSIM: 4,"63C2" -> 2 retries left

Examples for AT+CPIN with correct PIN:

AT+CPIN=9999

OK

AT+CSIM=14,"00A4000C027FFF";+CSIM=10,"0020000100"

+CSIM: 4,"9000" -> response of USIM Application directory selection, 

'9000' = successful

+CSIM: 4,"63C3" -> 3 retries left

Example for PUK (UNBLOCK PIN) retry counter:

AT+CSIM=14,"00A4000C027FFF";+CSIM=10,"002C000100"

+CSIM: 4,"9000" -> response of USIM Application directory selection, 

'9000' = successful

+CSIM: 4,"63CA" -> A = 10 retries left

3. SIM scenario (see also 3GPP TS 11.11)

The AT+CRSM=242 response for SIM is for example:

+CRSM: 144,0,"000000007F2002FAFFAAFF010E1300170600838A818A0083000022"

The following PIN/PUK status bytes have to be decoded, they are available at fixed positions within the CRSM response:

Byte 19 = PIN status, decoding see below (example 0x83 = PIN initialized, 3 false presentations remaining) Byte 20 = PUK status, decoding see below (example 0x8A = PUK initialized, 10 false presentations remaining) Byte 21 = PIN2 status, decoding see below (example 0x81 = PIN2 initialized, 1 false presentation remaining) Byte 22 = PUK2 status, decoding see below (example 0x8A = PUK2 initialized, 10 false presentations remaining) Decoding guide for each PIN/PUK status Bytes:

Bit 8: 0 = code not initialized, 1 = code initialized Bits 4-1: number of false presentations remaining

(example)

[2016-03-22 15:41:35.8] ati

[2016-03-22 15:41:36.8] Cinterion

[2016-03-22 15:41:36.8] EHS5-E

[2016-03-22 15:41:36.8] REVISION 03.001

[2016-03-22 15:41:36.8] OK

[2016-03-22 15:41:37.5] at+cpin?

[2016-03-22 15:41:40.2] +CPIN: SIM PIN

[2016-03-22 15:41:40.2] OK

[2016-03-22 15:41:54.2] AT+CRSM=242

[2016-03-22 15:41:54.3] +CRSM: 145,98,"6242820278218410A0000000871002FF47F00189000001FFA5118001718103010A3282010A83040000C3F08A01058B032F0605C6099001C08301018301818104000013BC"

[2016-03-22 15:41:54.3] OK

[2016-03-22 15:42:06.7] AT+CSIM=10,"0020000100"

[2016-03-22 15:42:08.0] +CSIM: 4,"63C3"

[2016-03-22 15:42:08.0] OK

[2016-03-22 15:42:37.7] at+cmee=2

[2016-03-22 15:42:41.6] OK

[2016-03-22 15:42:43.4] at+cpin="1234"

[2016-03-22 15:42:48.2] +CME ERROR: incorrect password

[2016-03-22 15:43:01.8] AT+CSIM=10,"0020000100"

[2016-03-22 15:43:01.9] +CSIM: 4,"63C2"

[2016-03-22 15:43:01.9] OK

[2016-03-22 15:43:15.6] at+cpin="2222"

[2016-03-22 15:43:15.7] +CME ERROR: incorrect password

[2016-03-22 15:43:19.0] AT+CSIM=10,"0020000100"

[2016-03-22 15:43:19.1] +CSIM: 4,"63C1"

Based on the knowledge, we can wrap the used AT commands inside a Java MIDlet so that it can help us to check the SIM PIN/PUK status on one given SIM card.

Author

antonyshen's picture
antonyshen