adaptation for book and plug demo

Dependents:   BookAndPlug

Fork of BLE_API by Bluetooth Low Energy

Embed: (wiki syntax)

« Back to documentation index

BatteryService Class Reference

BatteryService Class Reference

BLE Battery Service. More...

#include <BatteryService.h>

Public Member Functions

 BatteryService (BLE &_ble, uint8_t level=100)
void updateBatteryLevel (uint8_t newLevel)
 Update the battery level with a new value.

Protected Attributes

BLEble
 A reference to the underlying BLE instance that this object is attached to.
uint8_t batteryLevel
 The current battery level represented as an integer from 0% to 100%.
ReadOnlyGattCharacteristic
< uint8_t > 
batteryLevelCharacteristic
 A ReadOnlyGattCharacteristic that allows access to the peer device to the batteryLevel value through BLE.

Detailed Description

BLE Battery Service.

This service displays the battery level from 0% to 100%, represented as an 8bit number. Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.battery_service.xml Battery Level Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.battery_level.xml

Definition at line 28 of file BatteryService.h.


Constructor & Destructor Documentation

BatteryService ( BLE _ble,
uint8_t  level = 100 
)
Parameters:
[in]_bleBLE object for the underlying controller.
[in]level8bit batterly level. Usually used to represent percentage of batterly charge remaining.

Definition at line 36 of file BatteryService.h.


Member Function Documentation

void updateBatteryLevel ( uint8_t  newLevel )

Update the battery level with a new value.

Valid values lie between 0 and 100, anything outside this range will be ignored.

Parameters:
newLevelUpdate to battery level.

Definition at line 54 of file BatteryService.h.


Field Documentation

uint8_t batteryLevel [protected]

The current battery level represented as an integer from 0% to 100%.

Definition at line 69 of file BatteryService.h.

A ReadOnlyGattCharacteristic that allows access to the peer device to the batteryLevel value through BLE.

Definition at line 74 of file BatteryService.h.

BLE& ble [protected]

A reference to the underlying BLE instance that this object is attached to.

The services and characteristics will be registered in this BLE instance.

Definition at line 64 of file BatteryService.h.