The Journey  
The Game

The Paper - Page 10 - Getting Cell IDs

The Workflow of C++ Game-Development on a Series 60 Platform device

Andreas Jakl, Revision 1.0, July 2004

4.2 Location service: getting cell-ids

Retrieving the network information and, as part of it, the cell-id only works when the etelbgsm.h file is available (see chapter 3.2.2). You need to link your application to gsmbas.lib and etel.lib (defined in the .mmp file).

4.2.1 Telephony server

For preparation, several steps are required. First, a connection to the telephony server has to be opened (a short overview about the server-client model can be found in chapter 2.4.2). The code should also include proper error handling as opening a connection may fail. These parts have been omitted in this paper, they can be found in the full source code of The Journey .

        _LIT(KTsyName, "phonetsy.tsy");


        // Load the profile of the phone
        iTelServer.LoadPhoneModule( KTsyName );

        // Get the phone name
        RTelServer::TPhoneInfo phoneInfo;
        iTelServer.GetPhoneInfo( 0, phoneInfo );

        // Open the phone by name
        iPhone.Open( iTelServer, phoneInfo.iName );


After the connection has been established, the LoadPhoneModule() function has to be executed. The TSY file that is loaded is an extension module to the telephony server that handles the interaction between this server and a particular telephony device or family of devices [11].

Next, we fetch phone information, which also contains the name. On the emulator it is called Calypso , the codename of the Nokia 7650 .

Finally the additional header file is needed for the first time. iPhone of class type RBasicGsmPhone is being opened, with the telephony server and the name of the phone as arguments.

4.2.2 Getting the cell-id

If all calls succeed without returning any error code, the network info can be retrieved using one simple function:

    MBasicGsmPhoneNetwork::TCurrentNetworkInfo ni;
    iPhone.GetCurrentNetworkInfo( ni );

If the call succeeded without returning an error code (again, error handling has been omitted in the printed source code), ni will be filled with some interesting information:


Every GSM mast sends out its own cell-id. The number stored in this unsigned integer variable is therefore the code of the nearest mast.


Mobile Country Code. The code defining the country in which a mobile subscriber resides [15].


Mobile Network Code. The MCC and MNC together are a unique identification number of the network the phone is logged into.

Location area

A location area normally consists of several base stations. It defines an area where the mobile can move without notifying the network about its exact position [15].

Network name

Available in a short and a long version, this is name of the network the phone is currently logged into. It is the same network name that is displayed on the idle screen of most mobile phones.

The emulator will always return cell-id 0. To test the application in the emulator, you can set a breakpoint after you fetch the ID and then change the content of the variable where you store it through the IDE.

For The Journey, only movement is important (Fig. 4.1), not full location tracking. To achieve this, the area id of the network should maybe be taken into account as well.

Figure 4.1: A screenshot of the game waiting for the user to move to another location.

4.2.3 Closing connections

When you do not need to gather information anymore, or when your application is closed, you have to close the connection to the servers. This is done by the following piece of code:

    iTelServer.UnloadPhoneModule( KTsyName );
< Rich Text Editor Control Contents File Access >
© 2004 Andreas Jakl. All Rights Reserved.
Privacy Statement | Contact and Imprint
The Journey