ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

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, uint16_t voltage=0)
void updateBatteryLevel (const uint8_t newLevel, const uint16_t newVoltage)
 Update the battery level with a new value.

Protected Attributes

BLE & ble
 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 31 of file BatteryService.h.


Constructor & Destructor Documentation

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

Definition at line 40 of file BatteryService.h.


Member Function Documentation

void updateBatteryLevel ( const uint8_t  newLevel,
const uint16_t  newVoltage 
)

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 65 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 86 of file BatteryService.h.

ReadOnlyGattCharacteristic<uint8_t> batteryLevelCharacteristic [protected]

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

Definition at line 91 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 81 of file BatteryService.h.