#include <hwrmpower.h>
Link against: hwrmpowerclient.lib
class CHWRMPower : public CBase, public CBase |
Public Member Functions | |
---|---|
~CHWRMPower() | |
IMPORT_C void | GetBaseTimeIntervalL(TInt &) |
IMPORT_C void | GetBatteryInfo(TRequestStatus &, TBatteryConsumptionData &) |
IMPORT_C void | GetBatteryVoltageInfo(TRequestStatus &, TBatteryVoltageData &) |
IMPORT_C CHWRMPower * | NewL() |
IMPORT_C CHWRMPower * | NewLC() |
IMPORT_C TInt | SetPowerReportObserver(MHWRMBatteryPowerObserver *) |
IMPORT_C TInt | StartAveragePowerReporting(TRequestStatus &, const TUint &) |
IMPORT_C void | StopAveragePowerReportingL() |
HW Resource Manager Power API is a library API providing the ability to request detailed information regarding the battery capacity, voltage and current consumption.
The API consists of the classes CHWRMPower, MHWRMBatteryConsumptionObserver and MHWRMBatteryVoltageObserver. If the client requires periodical measurements of the Average Voltage and/or Average Consumption, it should also provide callback pointer of the MHWRMBatteryConsumptionObserver and/or MHWRMBatteryVoltageObserver implementing class for the NewL() method.
Usage:
#include <hwrmpower.h> // A CHWRMPower instance can be created by using NewL() or NewLC() methods. // Periodical measurements are required so callbacks are provided. Assume // the calling object implements both interfaces. CHWRMPower* power = CHWRMPower::NewL(this, this); // Get battery info. TRequestStatus& status; TBatteryConsumptionData batteryConsumptionData; power->GetBatteryInfo(status, batteryConsumptionData); User::WaitForRequest(status); User::LeaveIfError(status.Int()); // Start receiving periodical power measurements. // // Note: There is a maximum reporting period defined for each product through the // CenRep Key KPowerMaxReportingPeriod defined in HWRMPowerDomainCRKeys.h. // The reporting will stop after this maximum reporting period by default. // The application can configure this dynamically. // Setting maximum report period to zero results in infinite notifications. // TRequestStatus& statusStart; TInt intervalMultiple = 3; // Three times the base time interval. // // Note: The base time interval is different for each product. // GetBaseTimeIntervalL API returns this value. // power->StartAverageVoltageReporting(statusStart, intervalMultiple); User::WaitForRequest(statusStart); User::LeaveIfError(statusStart.Int()); // Measurements are being when the ProcessVoltageMeasurement() method // of the MHWRMBatteryVoltageObserver interface is called. // Stop receiving measurements when done power->StopAverageVoltageReportingL(); // To clean up, delete the created object: delete power;
IMPORT_C void | GetBatteryInfo | ( | TRequestStatus & | aStatus, |
TBatteryConsumptionData & | aBatteryConsumptionData | |||
) |
Parameters | |
---|---|
aStatus | This will be completed when the data are ready or an error occurs. |
aBatteryConsumptionData | The nominal battery info is returned in this parameter. Valid only when aStatus.Int() == KErrNone |
IMPORT_C void | GetBatteryVoltageInfo | ( | TRequestStatus & | aStatus, |
TBatteryVoltageData & | aBatteryVoltageData | |||
) |
Parameters | |
---|---|
aStatus | This will be completed when the data are ready or an error occurs. |
aBatteryVoltageData | The nominal battery info is returned in this parameter. Valid only when aStatus.Int() == KErrNone |
IMPORT_C CHWRMPower * | NewL | ( | ) | [static] |
Two-phased constructor for creating a CHWRMPower client.
IMPORT_C CHWRMPower * | NewLC | ( | ) | [static] |
Two-phased constructor for creating a CHWRMPower client. Leaves instance to CleanupStack.
IMPORT_C TInt | SetPowerReportObserver | ( | MHWRMBatteryPowerObserver * | aPowerReportCallback | ) |
IMPORT_C TInt | StartAveragePowerReporting | ( | TRequestStatus & | aStatus, |
const TUint & | aInterval | |||
) |
Post Start request to HWRM Server to start battery Power measurements
Parameters | |
---|---|
aStatus | This will be completed when measurements start or an error occurs. |