Quick question. I am using the mangOH red with the WP8548 and i am trying to read the battery level using the Input Power Supply Monitoring API provided by modem Services. The battery level returned by le_ips_GetBatteryLevel always equals to zero, according to the documentation that means the battery is drained or it doesn’t have a battery connected. The battery definetly isn’t drained because i am able to power my platform only using the battery. Also le_ips_GetPowerSource always tells me it is powered by an external source and not the battery (even after disconnecting all usb connections).
Am I using the API wrong or is it because of the mangOH board?
root@swi-mdm9x15:~# cm ips read
Voltage: 3692 mV
Powered by an external source
root@swi-mdm9x15:~# cm info
Device: WP8548
IMEI: 359377060821351
IMEISV: 30
FSN: LL919601200810
Firmware Version: SWI9X15Y_07.14.01.00 595652d jenkins 2018/10/26 08:34:29
Bootloader Version: SWI9X15Y_07.14.01.00 595652d jenkins 2018/10/26 08:48:35
MCU Version: 002.004
PRI Part Number (PN): 9906351
PRI Revision: 01.01
Carrier PRI Name: GENERIC
Carrier PRI Revision: 001.042_000
SKU: 1103113
Last Reset Cause: Unknown
Resets Count: Expected: -1 Unexpected: -1
But according to: cm - Legato Docs cm ips read should also display the battery level and specify that it is powered by the battery if one is connected and powering the board
But “cm ips” obviously doesn’t display the battery value and displays it is powered by an external source even if it is powered by a battery. Also i can use the API in the app and get the power source and voltage levels.
Edit: With BatteryLevel i mean the battery percentage and not the voltage, sorry if that was unclear
I looked throug the source code and found following function:
static unsigned int ComputePercentage
(
unsigned int mAh
)
{
// Compute the battery charge percentage, rounding up from half a percent or higher.
uint32_t percentTimesTen = 1000UL * mAh / Capacity;
unsigned int percentage = (percentTimesTen / 10);
if ((percentTimesTen % 10) >= 5)
{
percentage += 1;
}
// Clamp at 100%
if (percentage > 100)
{
LE_WARN("Battery monitor reports available charge (%u mAh) higher than maximum of %u mAh.",
mAh,
(unsigned int)Capacity);
percentage = 100;
}
return percentage;
}
“Capacity” is just the battery Capacity, which i could set myself depending on the battery.
The mAh is the remaining charge calculated in another function using:
char path[256];
int pathLen = snprintf(path, sizeof(path), "%s/%s", MonitorDirPath, ChargeNowFileName);
LE_ASSERT(pathLen < sizeof(path));
int32_t uAh;
le_result_t r = util_ReadIntFromFile(path, &uAh);
if (r == LE_OK)
{
*charge = uAh / 1000;
}
The weird thing is, “MonitorDirPath” is set via:
static const char MonitorDirPath = “/sys/class/power_supply/LTC2942”;
and it seems i don’t have the path on my mangOH specified in MonitorDirPath
I am not sure if it’s worth installing just yet. Because the final version of the Project i am working on will be independent from the mangOH red and the WP will have its own custom carrier board.