Up to: Mika Raento's Symbian Programming pages

Symbian Programming - Getting the current Cell Id

3rd edition

Since 2nd ed FP3 the current cellid is a supported API within CTelephony. For example code see ContextSensors/src/log_cellid.cpp.

1st/2nd edition

Updated for 6600!

The Series 60 SDK doesn't officially support access to the current GSM Cell Id. The necessary libs are available, and the older Communicator 9200 SDK (at least version 0.9) contains the necessary .h files.

So first you need etel.h and etelbgsm.h from the 9200 SDK. Copy these to the \Symbian\6.1\Series60\Epoc32\Include directory.

You need to link your app to gsmbas.lib and etel.lib.

Now you can run the following code (note: this won't work on the emulator, only on the real phone):

	RBasicGsmPhone phone;
	RTelServer server;		

	User::LeaveIfError( server.Connect() );
	// load a phone profile
	_LIT(KGsmModuleName, "phonetsy.tsy");
	User::LeaveIfError( server.LoadPhoneModule( KGsmModuleName ) );

	// initialize the phone object
	RTelServer::TPhoneInfo info;
	User::LeaveIfError( server.GetPhoneInfo( 0, info ) );
	User::LeaveIfError( phone.Open( server, info.iName ) );

	MBasicGsmPhoneNetwork::TCurrentNetworkInfo ni;
	User::LeaveIfError( phone.GetCurrentNetworkInfo( ni ) );

Now the .iCellId, iLocationAreaCode and .iNetworkInfo.iShortName fields of the MBasicGsmPhoneNetwork::TCurrentNetworkInfo should be populated. After use be sure to release the resources with:

	phone.Close();
	server.UnloadPhoneModule( KGsmModuleName );

	server.Close();

All this should work for the 6600 as well. You have the option of just compiling with the 1.2 SDK or copying the headers to the 2.0 SDK (if you need 6600 specific features).

There are other functions and data available through these objects at well. The headers should provide you with enough information to guess what they are. Not all of them are really implemented though. According to a Forum Nokia post by dgobin you can get to the information by:

We use the NotifyChangeOfCurrentNetwork, so that works as well.


Mika Raento, mikie(at)iki.fi