It is often a requirement for devices operating on battery to report the battery charge level to the user.
The Bluetooth Battery Service defines how to expose a battery charge level through a BLE link. It allows a client - usually a smartphone application - of a device to read the current battery charge level and follow its evolution.
The BatteryService class implements the Bluetooth Battery Service as defined by the Bluetooth SIG. Makers of BLE devices operating on battery can use the API to expose interoperably the charge level of their products.
BatteryService class reference
|Public Member Functions|
|BatteryService (BLE &_ble, uint8_t level=100)|
|Instantiate a battery service. More...|
|void||updateBatteryLevel (uint8_t newLevel)|
|Update the battery charge level that the service exposes. More...|
|Reference to the underlying BLE instance that this object is attached to. More...|
|The current battery level represented as an integer from 0% to 100%. More...|
|ReadOnlyGattCharacteristic< uint8_t >||batteryLevelCharacteristic|
|The GATT characteristic, which exposes the charge level. More...|
- Bluetooth Battery Service specification.