nRF Connect SDK API 2.8.99
|
int bt_fast_pair_fmdn_battery_level_set | ( | uint8_t | percentage_level | ) |
#include <include/bluetooth/services/fast_pair/fmdn.h>
Set the current battery level.
This function sets the current battery level. It is recommended to initialize the battery level with this API before you enable Fast Pair with the bt_fast_pair_enable API.
By default, the BT_FAST_PAIR_FMDN_BATTERY_LEVEL_NONE value is used, which means that battery levels do not show in the advertising payload. If you do not want to support the battery level indication, you should ignore this API and never call it in their application.
However, if the
CONFIG_BT_FAST_PAIR_FMDN_BATTERY_DULT
Kconfig is enabled, you must initialize battery level with this API before you enable Fast Pair with the bt_fast_pair_enable API. This requirement is necessary as the DULT battery mechanism does not support unknown battery levels. As a result, you must not call this API with the BT_FAST_PAIR_FMDN_BATTERY_LEVEL_NONE value in this configuration variant.
To keep the Android battery level indications accurate, you 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 FMDN Accessory specification in the advertising payload is implementation-specific. The mapping configuration is controlled by the following Kconfig options:
CONFIG_BT_FAST_PAIR_FMDN_BATTERY_LEVEL_LOW_THR
and
CONFIG_BT_FAST_PAIR_FMDN_BATTERY_LEVEL_CRITICAL_THR
.
percentage_level | Battery level as a percentage [0-100%] or BT_FAST_PAIR_FMDN_BATTERY_LEVEL_NONE value if the battery level is unknown. |