Battery Charger Tutorial

This tutorial describes how to get the battery charger information.

Context

The client applications must check if the device can detect and provide the charger information.

Steps

  1. create an instance of [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]CTelephony
  2. use [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]CTelephony::GetIndicator() to get the charger information
  3. the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]GetIndicator() returns a packaged descriptor [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]CTelephony::TIndicatorV1 [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]TIndicatorV1 enables the client application to determine if the device can detect a charger connection. If the device can detect a charger connection then the clients can determine the status of the charger
  4. pass the enumeration [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]] CTelephony::EGetIndicatorCancel to cancel the asynchronous [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]GetIndicator() request.

Battery charger example

#include <e32base.h>
#include <Etel3rdParty.h>

class CClientApp : public CActive
    { 

private:
    CTelephony* iTelephony;
    CTelephony::TIndicatorV1 iIndicatorV1;
    CTelephony::TIndicatorV1Pckg iIndicatorV1Pckg;
public:
    CClientApp(CTelephony* aTelephony);
    void SomeFunction();

private:
    /*
       These are the pure virtual methods from CActive that  
       MUST be implemented by all active objects
       */
    void RunL();
    void DoCancel();
   };

CClientApp::CClientApp(CTelephony* aTelephony)
    : CActive(EPriorityStandard),
      iTelephony(aTelephony),
      iIndicatorV1Pckg(iIndicatorV1)
    {
    //default constructor
    }

void CClientApp::SomeFunction()
    {
    iTelephony->GetIndicator(iStatus, iIndicatorV1Pckg);
    SetActive();
    }

void CClientApp::RunL()
    {
    if(iStatus==KErrNone)
       {
       if(iIndicatorV1.iCapabilities & CTelephony::KIndChargerConnected)
          {
          // We can detect when a charger is connected
          if(iIndicatorV1.iIndicator & CTelephony::KIndChargerConnected)
             {} // Charger is connected
          else
             {} // Charger is not connected
          }
       else
          {} // We do not know whether a charger is connected
       }
    }

void CClientApp::DoCancel()
    {
    iTelephony->CancelAsync(CTelephony::EGetIndicatorCancel);
    }