Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
This page was last modified 17:14, 18 March 2008.

Monitoring signal strength with CTelephony

From Forum Nokia Wiki


CNwSignalCheck implementation illustrates how to check and monitor the signal strength of S60 3rd Edition devices with CTelephony API.

The implementation is pretty simple, and when using this one only thing to do in calling class is to implement the callback interface and then to construct an instance of the CNwSignalCheck.

When constructing CNwSignalCheck, the initial signal strength is checked with GetSignalStrength ()-function and after this function returns and calls back the RunL, all changes in the signal strength are monitored by calling NotifyChange for the signal strength status.


SignalStrenght.cpp

CNwSignalCheck::~CNwSignalCheck()
{
	Cancel();
	delete iTelephony;
}
 
void CNwSignalCheck::ConstructL(void)
{
    iTelephony = CTelephony::NewL();
    GetSignalInfo();
}
 
CNwSignalCheck::CNwSignalCheck(MNwSignalObserver& aObserver)
: CActive(EPriorityStandard),iObserver(aObserver),iSigStrengthV1Pckg(iSigStrengthV1)
{
	CActiveScheduler::Add(this);
}
 
void CNwSignalCheck::GetSignalInfo()
{
    if(iTelephony && !IsActive())
    {
    	iGettingSignal = ETrue;
   	 	iTelephony->GetSignalStrength(iStatus, iSigStrengthV1Pckg);
   	 	SetActive();
    }
}
 
void CNwSignalCheck::RunL()
{
    iObserver.SignalStatus(iSigStrengthV1.iSignalStrength,iSigStrengthV1.iBar);
 
	if(iStatus != KErrCancel)
	{
		iTelephony->NotifyChange(iStatus,CTelephony::ESignalStrengthChange,iSigStrengthV1Pckg);	
		SetActive();
	}
 
	iGettingSignal = EFalse;
}
 
void CNwSignalCheck::DoCancel()
{
	if(iGettingSignal)
    	iTelephony->CancelAsync(CTelephony::EGetSignalStrengthCancel);
	else
		iTelephony->CancelAsync(CTelephony::ESignalStrengthChangeCancel);
}


SignalStrenght.h

#include <Etel3rdParty.h>
 
 
class MNwSignalObserver
	{
	public:
		virtual void SignalStatus(TInt32 aStrength,TInt8 aBars) = 0;
	};
	
	
	
class CNwSignalCheck : public CActive
  { 
public:
    CNwSignalCheck(MNwSignalObserver& aObserver);
    void ConstructL(void);
	~CNwSignalCheck();
private:
	void GetSignalInfo();
    void RunL();
    void DoCancel();
private:
	MNwSignalObserver& 					iObserver;
    CTelephony* 						iTelephony;
    CTelephony::TSignalStrengthV1 		iSigStrengthV1;
    CTelephony::TSignalStrengthV1Pckg 	iSigStrengthV1Pckg;
    TBool								iGettingSignal;
   };
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX
     
    
            
            RDF Facets:
            
            
                        qfnZuserE5FtagQSxctelephonyX