user2160902
user2160902

Reputation: 19

How to read MSISDN from sim card by SIM_IO?

I need to read MSISDN in android, but we must use .c to finish it. I open a socket to send RIL_REQUEST_SIM_IO to ril. Here is the log.

D/RILC    (  106): [0004]> SIM_IO (cmd=0xB2,efid=0x6F40,path=3F007F10,1,4,30,(null),pin2=(null),aid=(null))
...
D/RILC    (  106): [0004]< SIM_IO {sw1=0x90,sw2=0x0,ffffffffffffffffffffffffffff0891684125205260f5ffffffffff}

Did I use the right parameters (P1 = 1, P2 = 4, P3 = 30)?

And how can I get the mobile phone number by response?

Thank you!☺

Upvotes: 1

Views: 7380

Answers (3)

N Fay&#231;al
N Fay&#231;al

Reputation: 139

In case it helps some1 later on: Encoding can be found on TS 51.011. File is called EF_MSISDN. Its identifier is 6F40.

MSISDN is preceded by its length, then the TON/NPI. It is also in a BCD inverted format

Upvotes: 0

Darvin
Darvin

Reputation: 1

the data (0xffffffffffffffffffffffffffff0891684125205260f5ffffffffff) yes it contains MSISDN

----08 = means the Length of dial no

----91 = means MSISDN Internatioal dial No

the rest (684125205260f5) value u nid to swap it side by side of each 1 byte. example 68 swap 86, 41 swap 14...so on then u will got the MSISDNnumber.

Upvotes: 0

Mike
Mike

Reputation: 49463

What is your confusion here? You wanted to know what you told the card? All this information is in ISO 7816-4 and a few other specs, but here's the details of what you did:

You sent a read record command to the SIM (0xB2) You asked for the Path:

3F00 -> (MF)
7F10 -> (DF_TELECOMM)
6F40 -> (MSISDN)

You set parameters:

P1 (record)                   = 1  (record 1)
P2 (reference control)        = 4  (this mean use record number set in P1)
P3 (Le meaning bytes to read) = 30 (bytes)

and you got back success (SW stands for status word, you got SW1/SW2 = 0x9000 which means success) and the data (0xffffffffffffffffffffffffffff0891684125205260f5ffffffffff)

Checkout E.164 on parsing your MSISDN.

Upvotes: 2

Related Questions