×

Discussion Board

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

    Question Values not retrieved using Ctelephony

    Hello All,

    A very Happy New Year to all the readers first of All.

    I tried out an application which is Supposed to send iCellId,iLocationAreaCode,iCountryCode,iNetworkId from the CTelephony Class.
    initially i tested with only one parameter that is iCellId and it was working fine but if i try to do the same thing and try to retrieve these four parameters its not giving me even one.

    i'll attach the code:

    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();
    
    	TBuf<30> GetNetworkCellId(TUint& aCellId,TUint& aLacId, TBuf<5> aMCC, TBuf<5> aMNC);
    
    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;
        TUint 							iLacId;
        TBuf<5>							iMCC;
        TBuf<5>							iMNC;
        TBuf<20> 						iCellnlacId;
        
    	};
    
    #endif // CELLIDDETECTOR_H
    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;
    			iLacId = iNetworkInfo.iLocationAreaCode;
    			iMCC = iNetworkInfo.iCountryCode;
    			iMNC = iNetworkInfo.iNetworkId;
    			}
    		else
    			{
    			// ***********Handle Error here ************
    			}
    		}
    	}
    
    TInt CCellidDetector::RunError(TInt aError)
    	{
    	return aError;
    	}
    
    TBuf<30> CCellidDetector::GetNetworkCellId(TUint& aCellId, TUint& aLacId, TBuf<5> aMCC, TBuf<5> aMNC)
    	{
    	StartL();
    	aCellId = iCellId;
    	aLacId = iLacId;
    	aMCC = iMCC;
    	aMNC = iMNC;
    	
    	iCellnlacId.AppendNum(iCellId);
    	iCellnlacId.Append(_L(","));
    	iCellnlacId.AppendNum(iLacId);
    	iCellnlacId.Append(_L(","));
    	iCellnlacId.Append(iMCC);
    	iCellnlacId.Append(_L(","));
    	iCellnlacId.Append(iMNC);
    	iCellnlacId.Append(_L(","));
    	
    	return iCellnlacId;
    	}
    and i am calling these classes from the AppUi of the application as follows.
    Code:
    TBuf<160> CMyProAppUi::GetNewData()
    	{
    		TUint cellId;
    		TUint lacid;
    		TBuf<5> mcc, mnc;
    		
    		CCellidDetector* devCellidUtility = CCellidDetector::NewL();
    		CleanupStack::PushL(devCellidUtility);
    		completeData = devCellidUtility->GetNetworkCellId(cellId, lacid, mcc, mnc);
    
    		CleanupStack::PopAndDestroy(devCellidUtility);
    
    		TTime time;
    		TDateTime dateTime;
    		time.HomeTime(); // set time to home time
    		CAknInformationNote* note = new (ELeave) CAknInformationNote;
    		TBuf<30> datetime;
    		dateTime = time.DateTime();
    
    		datetime.AppendNum(dateTime.Year());
    		datetime.Append(_L("-"));
    		datetime.AppendNum(dateTime.Month() + 1);
    		datetime.Append(_L("-"));
    		datetime.AppendNum(dateTime.Day() + 1);
    		datetime.Append(_L("-"));
    		datetime.AppendNum(dateTime.Hour());
    		datetime.Append(_L("-"));
    		datetime.AppendNum(dateTime.Minute());
    		datetime.Append(_L("-"));
    		datetime.AppendNum(dateTime.Second());
    
    		//note->ExecuteLD(datetime);
    		completeData.Append(datetime);
    	return completeData;
    	}
    Completedata is a TBuf..

    If i try to get only one value then i get it at the same time if i try to retrieve all the values then i am not able to retrieve any.

    Some directions toward the errors will be highly Appreciable.

    many thanks,
    Abhishek karmakar

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

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

    Re: Values not retrieved using Ctelephony

    Hi,

    Its achronous function check it in your RunL whether you were getting correct result there or not.

    One more thing chcek the capability as well in your mmp file
    Capability: ReadUserData, ReadDeviceData, Location
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

Similar Threads

  1. iError values in TMsvEntry
    By 76Richard76 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2010-02-15, 13:47
  2. Replies: 8
    Last Post: 2009-02-27, 11:37
  3. Replies: 5
    Last Post: 2007-11-20, 21:45
  4. Incorrect rgb values for jpg images on S40 3rd ed
    By bjudfar in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-05-29, 16:34

Posting Permissions

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