How to retrive the IMSI number

IMSI is an abbreviation for "International Mobile Subscriber Identity". The IMSI number is a unique 15-digit code that is attached to every SIM (Subscriber Identification Module) card and makes it possible for mobile networks to identify the home country and network of a subscriber.

The structure of the IMSI is as follow:

MCC MNC MSIN

Where:
-  MCC is the Mobile Country Code which indicate from which country the SIM comes. This list of country code is defined in recommendation ITU E.212. You can get a list of these on Wikipedia
-  MNC is the Mobile Network Code and identifies the network operator (Orange, Vodafone, etc....). The link to the Wikipedia list of Mobile Network Code
-  MSIN is the Mobile Subscriber Identification Number which identifies the user (but is different from the phone number!).

UIQ platform

The IMSI number can be obtained from Sony Ericsson P800 and P900 smartphones for use in C++ applications by reading the contents of the file C:\System\data\imsi.txt

This file will be updated automatically if the SIM card is changed.

Some system processes keep this file open and therefore the file needs to be opened in shared mode for readers. This is done by using the EFileShareReadersOnly flag when opening the file. The following C++ code reads the contents of imsi.txt and displays it on the screen:

RFs fs;
fs.Connect();
RFile file;

_LIT(KImsiFileName,"C:\\System\\data\\imsi.txt");

TInt res = file.Open(fs,KImsiFileName,
 EFileShareReadersOnly|EFileStreamText);

if(res != KErrNone)
{
 gConsole->Printf(_L("Open failed: %d\n"),res);
}
else
{
 TBuf8<128> buf;
 file.Read(buf);
 file.Close();
 fs.Close();

 TBuf<128> printBuf;
 printBuf.Copy(buf);
 gConsole->Printf(_L("IMSI: "));
 gConsole->Printf(printBuf);  
 gConsole->Printf(_L("\n"));
}

Series 60 Platform

On the Series 60 platform, the same is possible for the phones that support the 3rd Party Telephony API (this means phones based on S60 v2 FP3 and later).

The IMSI can be obtained using the following code:

CTelephony telephony = CTelephony::NewL();
TRequestStatus status;
CTelephony::TSubscriberIdV1 subscriberId;
CTelephony::TSubscriberIdV1Pckg subscriberIdPckg(subscriberId);
telephony->GetSubscriberId(status, subscriberIdPckg));
User::WaitForRequest(status);
User::LeaveIfError(status);
TPtrC theIMSI(subscriberId.iSubscriberId);

This tip was originally posted on SonyEricsson Developer Site for the UIQ version and on Symbian site for the Series 60 one

> Obtaining the IMSI number on P800 and P900

Is there a way to get the IMSI from 3650. Also Is there a way to map this number to the phone number. Or can we access phone number directly

> Obtaining the IMSI number on P800 and P900

1) No, you cannot retrieve IMSI using open APIs. This may be possible however using etelagsm or etelbgsm APIs.

2) No. A phone cannot deduct its number from the IMSI nor its IMSI from its number.

3) Same as 1).

> Obtaining the IMSI number on P800 and P900

The following code worked on 3660

RTelServer server; CleanupClosePushL(server); User::LeaveIfError(server.Connect());

//Load in the phone device driver User::LeaveIfError(server.LoadPhoneModule(KTsyName));

//Find the number of phones available from the tel server TInt numberPhones; User::LeaveIfError(server.EnumeratePhones(numberPhones));

//Check there are available phones if (numberPhones < 1) User::Leave(KErrNotFound);

//Get info about the first available phone RTelServer::TPhoneInfo info; User::LeaveIfError(server.GetPhoneInfo(0, info));

//Use this info to open a connection to the phone, the phone is identified by its name RAdvGsmPhone phone; CleanupClosePushL(phone); User::LeaveIfError(phone.Open(server, info.iName));

TRequestStatus satus; RAdvGsmPhone::TSubscriberId imsiNumber; phone.GetSubscriberId(satus, imsiNumber); User::WaitForRequest(satus);

// imsiNumber is a TBuf which contains the IMSI number

CleanupStack::PopAndDestroy(2);//phone, line //Unload the phone device driver User::LeaveIfError(server.UnloadPhoneModule(KTsyName)); //Close the connection to the tel server and remove it from the cleanup stack CleanupStack::PopAndDestroy(&server);

> Obtaining the IMSI number on P800 and P900

to make the above code to run

Dont forget to include : #include <etelagsm.h> as a header file

and LIBRARY gsmadv.lib and LIBRARY etel.lib

in the mmp file

Also find and copy etelagsm.h and etelbgsm.h to Epoc32\Include folder

> Obtaining the IMSI number on P800 and P900

hi gaurav i am also making the sam project and i had downloaded the c++ borland mobile edition but getting progra fail error and adldb.pl path not found

can u suggest me which c++ u write this imsidn code and which SDK u had used please reply soon

> How to retrive the IMSI number

How can i get IMSI on Nokia 7650 ?

> How to retrieve the IMSI number

Hi,

I was wondering which is the recommended way to retrieve such kind of information.

Is it through the CTelephony API, or it can also be done using the plpvariant.dll/lib?

For instance, one can use the

TPlpVariantMachineId aId; PlpVariant::GetMachineIdL( aId );

piece of code to retrieve the IMEI.

Or shall I prefer the

CTelephony::GetPhoneId(...).

?

> How to retrieve the IMSI number

Dear all,

How can I do to get IMSI of my 6600 ?

There is no imsi.txt on my 6600 and the 3rd party function does not work for it either So what can we do ?

Thanks HN

> How to retrive the IMSI number

Is the imsi.txt on UIQ secure? Can I change/write it?

> How to retrive the IMSI number

Hi I have a Philips 355on the orange network and every time i switch on my phone It says IMSI failed. How do I correct this problem? I have just bought a new orange sim card and I am still having the same problem.

Many Thanks,

Fiona.

fionaross19@aol.com

> How to retrive the IMSI number

Just a follow-up to the 3rd party ETEL APIs: They are also missing from the following very popular Nokia S60 devices: 6630 and 6680, to my knowledge. This is what Symbian reps had to say about it:

"The standard way for third party developers to access IMEI/IMSI information is to use Etel3rdParty API's. We included these in v8 for inclusion into Series 60 2nd Edition FP2 (and above). However in the case of the 6630 the required files were not included on the device and so this method will not work.

Also on v7.0s, S60 2nd Ed FP1 we included these files but again it appears that devices did not include this and so would not be available for third party developers.

There is information here http://www3.symbian.com/faq.nsf/0/8DA91C7B8610E79980256F0800547B5C?OpenDocument but ultimately you will need to check with Nokia regarding the 6630."

So, anybody know of "The Right Way" to do this on these aforementioned devices (6600, 6630 and 6680) ?

> How to retrive the IMSI number

How can i get IMSI on Panasonic X700 ?

CTelephony, etelagsm.h/etelbgsm.h = RAdvGsmPhone doesn't work. Any other idea?

> How to retrive the IMSI number

hi can u tell me which c++ are u using Or can u tell me that i am using c++ borland mobile edition for this how can i include these files in it

and which sdk to download

and i am not able to build the program and abldb.pl path nt found error comes

reply