Join Now
Quality Rating:
  • Currently 4.0 / 5
(4.0 / 5 - 1 vote cast)
This page was last modified 17:16, 16 February 2008.

Reading Network Paramters in 3rd edition -Synchronously

From Forum Nokia Wiki

This code example will help you in getting different Network Parameters like: Cell Id, Network Id, Country ID and Network Name.


Contents

NetworkApp.h

#include <e32base.h>
#include <Etel3rdParty.h>
 
class CNetworkApp : public CActive
{
 
private:
        void ConstructL();
        CTelephony* iTelephony;
        CTelephony::TNetworkInfoV1 iNetworkInfoV1;
        CTelephony::TNetworkInfoV1Pckg iNetworkInfoV1Pckg;
 
public:
        CNetworkApp(
                TUint& CellId, TDes& NetworkId, TDes& CountryId, TDes& LongName);
        static void GetNetworkParameters(
                TUint& CellId, TDes& NetworkId, TDes& CountryId, TDes& LongName);
        ~CNetworkApp();
        TUint& iCellID;
        TDes&  iNetworkID;
        TDes&  iCountryCODE;
        TDes&  iLongNAME;
 
private:
        /*
           These are the pure virtual methods from CActive that
           MUST be implemented by all active objects
         */
        void RunL();
        void DoCancel();
};

NetworkApp.cpp

#include "NetworkApp.h"
 
void CNetworkApp::GetNetworkParameters(
        TUint& aCellID, TDes& aNetworkID, TDes& aCountryCODE,
        TDes& aLongName)
{
        CNetworkApp* self=
                new(ELeave) CNetworkApp(
                        aCellID, aNetworkID, aCountryCODE, aLongName);
        CleanupStack::PushL(self);
        self->ConstructL();
        CleanupStack::PopAndDestroy(self);
}
 
void CNetworkApp::ConstructL()
{
        iTelephony = CTelephony::NewL();
        CActiveScheduler::Add(this);        
 
        iTelephony->GetCurrentNetworkInfo(iStatus, iNetworkInfoV1Pckg);
        SetActive();
        CActiveScheduler::Start();
 
}
 
CNetworkApp::CNetworkApp(
        TUint& aCellID,TDes& aNetworkID,TDes& aCountryCODE,TDes& aLongName):
                CActive(EPriorityStandard), iNetworkInfoV1Pckg(iNetworkInfoV1),
                iCellID(aCellID), iNetworkID(aNetworkID), iCountryCODE(aCountryCODE),
                iLongNAME(aLongName)
{
        //default constructor
}
 
void CNetworkApp::RunL()
{
        if(iStatus==KErrNone)
        {
                iCellID = iNetworkInfoV1.iCellId;
                iNetworkID = iNetworkInfoV1.iNetworkId;
                iCountryCODE = iNetworkInfoV1.iCountryCode;
                iLongNAME= iNetworkInfoV1.iLongName;
                CActiveScheduler::Stop();
        }
}
 
void CNetworkApp::DoCancel()
{
        iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
}
 
CNetworkApp::~CNetworkApp()
{
        if(iTelephony)
        {
                iTelephony->Cancel();
                delete iTelephony;
                iTelephony = NULL;
        }
}

Instructions

Now do the following steps:
1) Create a sample "Hello World" type application.
2) Put NetworkApp.h file in your application's "inc" folder.
3) Put NetworkApp.cpp file in your application's "src" folder.
4) Open .mmp file and add entry SOURCE NetworkApp.cpp.
5) Open .mmp file and add entry LIBRARY etel3rdparty.lib.
7) Now you need to include following header in your class to read Network:
#include "NetworkApp.h". Let's say in for e.g.: "CYrAppUi.h"
8) You can then call the static function from any of your Commands.
For ex: in your CYrAppUi.h you need to include "NetworkApp.h"
And Call it like:

case EReadNetworkCommand1:
{
        TUint CellId;
        TBuf<30> NetworkId;
        TBuf<30> CountryId;
        TBuf<30> OperatorLongName;        
        CNetworkApp::GetNetworkParameters(
                CellId, NetworkId, CountryId, OperatorLongName );
 
        TBuf<160> iDisplayString;
        iDisplayString.Format(
                _L( "CellId-%d\nNetworkID-%S\nCountryID-%S\nNETWORK-%S" ),
                 CellId, &NetworkId, &CountryId, &OperatorLongName );
 
        CAknInformationNote* informationNote = new ( ELeave )
                CAknInformationNote;
        informationNote->ExecuteLD(iDisplayString);
}

9) Open .mmp file and add entry CAPABILITY ReadDeviceData.
10) You need to sign resulted .Sis file with your developer certificate to get it installed on your phone.

You can find a working application which is built in MS 2003 IDE with Carbide.vs Support. Here it goes: Network Information
Here is a library with similar functionality but for S60 2nd edition SDKs.


Related Links


Related Discussions
Thread Thread Starter Forum Replies Last Post
How to write a DB since mobile phone? alexandra_bustamante Mobile Java General 6 2004-09-20 14:57
MWS S60 Plugin installing error ! cyke64 Mobile Web Server 3 2008-01-19 08:33
KERN-Exec 3 on exit when using appuifw.Text() raf1hh Python 9 2008-10-12 18:19
App Common to series60 2'nd and 3'rd anoopd General Symbian C++ 7 2007-04-13 07:42
schedule for 3rd edition release? simo.salminen Python 1 2005-11-30 16:28
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX
     
    
            
            RDF Facets:
            
            
                        qfnZuserE5FtagQSxopenglX