nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches

◆ dult_battery_level_set()

int dult_battery_level_set ( const struct dult_user * user,
uint8_t percentage_level )

#include <include/dult.h>

Set the current battery level.

This function sets the current battery level. The battery level is an optional feature in the DULT specification and this API must not be used when the

CONFIG_DULT_BATTERY 

Kconfig is disabled.

If the

CONFIG_DULT_BATTERY 

Kconfig is enabled, this function must be called to initialize the battery level after registering the DULT user with dult_user_register and before enabling DULT with dult_enable function. Subsequent calls to update the battery level are allowed in the enabled mode.

To keep the battery level information accurate, the user should set the battery level to the new value with the help of this API as soon as the device battery level changes.

The exact mapping of the battery percentage to the battery level as defined by the DULT specification in the ANOS is implementation-specific. The mapping configuration is controlled by the following Kconfig options:

CONFIG_DULT_BATTERY_LEVEL_CRITICAL_THR 

,

CONFIG_DULT_BATTERY_LEVEL_LOW_THR 

and

CONFIG_DULT_BATTERY_LEVEL_MEDIUM_THR 

.

Parameters
userUser structure used to authenticate the user.
percentage_levelBattery level as a percentage [0-100%]
Returns
0 if the operation was successful. Otherwise, a (negative) error code is returned.