Check battery charging status

This snippet will let you check if the device battery is charging.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <device/battery.h>
#include <dlog.h> //for logging purposes
bool battery_charging = false;
if (device_battery_is_charging(&battery_charging) == DEVICE_ERROR_NONE)
{
    if (battery_charging == true)
    {
        LOGI("Battery is charging");
    }
    else
    {
        LOGI("Battery is not charging");
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX