×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Question how to retrieve data from CTelephony

    Hello Everyone,
    I have been trying to retrieve cellId by using CTelephony class . So far i have been able to do this. Its executing with no problems but its returning a wrong CellId everytime. i.e - '0'.. Please help

    following are the code files ..
    CellidDetector.h

    Code:
    /*
     ============================================================================
     Name		: CellidDetector.h
     Author	  : Abhishek karmakar
     Version	 : 1.0
     Copyright   : Your copyright notice
     Description : CCellidDetector declaration
     ============================================================================
     */
    
    #ifndef CELLIDDETECTOR_H
    #define CELLIDDETECTOR_H
    
    #include <e32base.h>	// For CActive, link against: euser.lib
    #include <e32std.h>		// For RTimer, link against: euser.lib
    #include <Etel3rdParty.h>	// Starting from S60 2nd Edition, access to telephony functionality and device IMEI/IMSI information was supposed to be provided by the ETEL third-party telephony library (etel3rdparty.dll, class CTelephony). 
    #include <etelbgsm.h>	
    class CCellidDetector : public CActive
    	{
    public:
    	// Cancel and destroy
    	~CCellidDetector();
    
    	// Two-phased constructor.
    	static CCellidDetector* NewL();
    
    	// Two-phased constructor.
    	static CCellidDetector* NewLC();
    
    public:	// New functions
    	// Function for making the initial request
    	void StartL();
    
    	TUint GetNetworkCellId(TUint& aCellId);
    
    private:
    	// C++ constructor
    	CCellidDetector();
    
    	// Second-phase constructor
    	void ConstructL();
    
    private:
    	// From CActive
    	// Handle completion
    	void RunL();
    
    	// How to cancel me
    	void DoCancel();
    
    	// Override to handle leaves from RunL(). Default implementation causes
    	// the active scheduler to panic.
    	TInt RunError(TInt aError);
    
    private:
    	enum TCellidDetectorState
    		{
    		EGetPhoneInfo, EDone
    		// Error condition
    		};
    
    private:
    	TInt iState; // State of the active object
    	RTimer iTimer; // Provides async timing service
    	//TInt							iState;		
    	// Pointer to a newly created CTelephony object. 
        CTelephony *          			iTelephony;   			
        // Defines information related to a mobile phone network.
        CTelephony::TNetworkInfoV1      iNetworkInfo;   	
        // Controls a single scheduling loop in the current active scheduler.
        CActiveSchedulerWait            iActiveSchedulerWait;	
        // On GSM/WCDMA networks, the cell identity code.
        TUint							iCellId;
    
    	};
    
    #endif // CELLIDDETECTOR_H
    the CellidDetector.cpp

    Code:
    /*
     ============================================================================
     Name		: CellidDetector.cpp
     Author	  : Abhishek karmakar
     Version	 : 1.0
     Copyright   : Your copyright notice
     Description : CCellidDetector implementation
     ============================================================================
     */
    
    #include "CellidDetector.h"
    
    CCellidDetector::CCellidDetector() :
    	CActive(EPriorityStandard) // Standard priority
    	{
    	}
    
    CCellidDetector* CCellidDetector::NewLC()
    	{
    	CCellidDetector* self = new (ELeave) CCellidDetector();
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	return self;
    	}
    
    CCellidDetector* CCellidDetector::NewL()
    	{
    	CCellidDetector* self = CCellidDetector::NewLC();
    	CleanupStack::Pop(); // self;
    	return self;
    	}
    
    void CCellidDetector::ConstructL()
    	{
    	User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
    	iTelephony = CTelephony::NewL();
    	CActiveScheduler::Add(this); // Add to scheduler
    	}
    
    CCellidDetector::~CCellidDetector()
    	{
    	Cancel(); // Cancel any request, if outstanding
    	iTimer.Close(); // Destroy the RTimer object
    	// Delete instance variables if any
    	}
    
    void CCellidDetector::DoCancel()
    	{
    	//iTimer.Cancel();
    
    	iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
    	}
    
    void CCellidDetector::StartL()
    	{
    	Cancel(); // Cancel any request, just to be sure
    	iState = EGetPhoneInfo;
    
    	CTelephony::TNetworkInfoV1Pckg networkInfoPckg(iNetworkInfo); //A typedef'd packaged CTelephony::TNetworkInfoV1 for passing through a generic API method.
    	
    	iTelephony->GetCurrentNetworkInfo(iStatus, networkInfoPckg); //Retrieve over-the-air network information about the currently registered mobile network. 
    
    	SetActive(); // Tell scheduler a request is active
    	iActiveSchedulerWait.Start();
    	}
    
    void CCellidDetector::RunL()
    	{
    	iState = EDone;
    	if (iActiveSchedulerWait.IsStarted()) // Reports whether this CActiveSchedulerWait object is currently started.
    		{
    		iActiveSchedulerWait.AsyncStop(); // Stops the scheduling loop owned by this object.
    		if (iStatus == KErrNone)
    			{
    			iCellId = iNetworkInfo.iCellId;
    			}
    		else
    			{
    			// ***********Handle Error here ************
    			}
    		}
    	}
    
    TInt CCellidDetector::RunError(TInt aError)
    	{
    	return aError;
    	}
    
    TUint CCellidDetector::GetNetworkCellId(TUint& aCellId)
    	{
    	StartL();
    	aCellId = iCellId;
    	return aCellId;
    	}
    And in the appuid i have added a new button where i am writing this code ..

    Code:
    	TUint cellId;
    			TUint hasil;
    			CCellidDetector* devCellidUtility = CCellidDetector::NewL();
    			CleanupStack::PushL(devCellidUtility);
    			hasil = devCellidUtility->GetNetworkCellId(cellId);
    			CleanupStack::PopAndDestroy(devCellidUtility);
    			_LIT(KFormatString, "CellId : %d");
    			TBuf <50> aString;
    			aString.Format(KFormatString, hasil);
    			
    			
    			
    			CAknConfirmationNote* note1 = new (ELeave) CAknConfirmationNote( ETrue ); //Waiting
    			note1->ExecuteLD(aString);
    headers used..
    Code:
    #include <Etel3rdParty.h>	
    #include <etelbgsm.h>
    its returning the CellId as 0 ..

    Please help ..
    Many thanks ..

    Abhishek karmakar
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  2. #2
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: how to retrieve data from CTelephony

    Hi,

    Have you added the following capability in your mmp file.
    Location, ReadDeviceData, ReadUserData

  3. #3
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: how to retrieve data from CTelephony

    i think the declaration of icellid variable would be like this:

    CTelephony::TCallId iCallId;

    not lik TUInt icallid

  4. #4
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Smile Re: how to retrieve data from CTelephony

    hello kkrish/vineet,

    Thank you for your replies. First what Krish said was correct. we have to add ReadDeviceData. and then we need to sign the application .I did it through OpenSighned and there for got a signed sis file .. which worked for me .

    Thank you again for the support.
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

Similar Threads

  1. Replies: 47
    Last Post: 2009-02-23, 13:19
  2. Hoe Retrieve data coding scheme from gsm 03.38
    By martin.virile in forum General Development Questions
    Replies: 0
    Last Post: 2007-01-08, 07:06
  3. retrieve & store data in Nokia 3100
    By business2share in forum Mobile Java General
    Replies: 0
    Last Post: 2004-09-29, 16:04
  4. Smart way to retrieve data by OutPutStream from RMS ?
    By akokchai in forum Mobile Java General
    Replies: 7
    Last Post: 2003-07-11, 22:20
  5. Replies: 0
    Last Post: 2002-12-04, 15:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •