×
Namespaces

Variants
Actions

Archived:How can I determine when the battery is full using Symbian C++?

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Relevent to old versions of Symbian.

Article Metadata
Compatibility
Platform(s): S60 1st Edition
S60 2nd Edition
S60 2nd Edition (initial release)
S60 1st Edition
Article
Created: User:Technical writer 2 (12 Jan 2004)
Last edited: hamishwillee (06 May 2013)

Overview

How can I determine when the battery is full using Symbian C++?

Description

Create an observer class, derived from CActive, to listen for System Agent events:

class CSystemAgentObserver : public CActive
{
public: // Constructors and destructor
static CSystemAgentObserver* NewL( CApAppUi& aApAppUi );
virtual ~CSystemAgentObserver();
private:
void ConstructL( );
CSystemAgentObserver();
CSystemAgentObserver( CApAppUi& aApAppUi );
private:
void IssueRequest();
void DoCancel();
void RunL();
TInt RunError( TInt aError );
private:
CApAppUi& iApAppUi;
RSystemAgent iSystemAgent;
TSysAgentEvent iSAEvent;
};
In the implementation of this class, use the following code to issue a notification request for the event(s) that you are interested in:
iSAEvent.SetRequestStatus( iStatus );
if( !IsActive() )
{
iSystemAgent.NotifyOnAnyEvent( iSAEvent );
SetActive();
}
When an event comes in, use the following code to intercept the event in the RunL() method:
void CApAppUi::HandleSystemAgentEventL(const TInt aSaVariableUid,
const Tint aSaVariableState)
{
switch( aSaVariableUid )
{
case KUidChargerCStatusValue:
if( aSaVariableState == ESACChargerOn )
{
// Charger connected
}
else if( aSaVariableState == ESACChargerError )
{
// Charger error
}
else if( aSaVariableState == ESACChargerFull )
{
// Battery full
}
break;
}
}
Definitions used:
const TInt KUidChargerCStatusValue = 0x100052D7;
const TUid KUidChargerCStatus = {KUidChargerCStatusValue};
enum TSAChargerCStatus
{
ESACChargerOff,
ESACChargerOn,
ESACChargerAlmostFull,
ESACChargerFull,
ESACChargerError
}
This page was last modified on 6 May 2013, at 11:16.
18 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×