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; };
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| KAknSignalNotifierUid, RNotifier & struct SAknSignalNotifyParams | janknepper | General Symbian C++ | 1 | 2004-08-12 12:37 |
| How to Get MobInfo in 3rd Edition!!! | Tanya | General Symbian C++ | 10 | 2008-08-11 18:12 |
| UMTS network info (cell id, lac, signal strength) | lux.nico | General Symbian C++ | 2 | 2008-02-09 20:56 |
| Attenuating/Limiting Bluetooth Signal | stevenjames | Bluetooth Technology | 3 | 2006-03-21 06:00 |
| Nokia E70 with 3G in Reception area of screen | cs97jb | General Discussion | 3 | 2006-10-24 07:53 |
