BLE Battery Service
BLE provides the Battery Service, used the expose the state of a battery within a device.
How To Connect
For information on how to connect to BLE devices, please see the BLE platform page.
How To Use
A short example of getting current battery level from a BLE device:
var Cylon = require('cylon'); Cylon.robot({ connections: { bluetooth: { adaptor: 'ble', uuid: '207377654321' } }, devices: { battery: { driver: 'ble-battery-service' } }, display: function(err, data) { if (!!err) { console.log("Error: ", err); return; } console.log("Data: ", data); }, work: function(my) { my.battery.getBatteryLevel(my.display); } }).start();
Commands
getBatteryLevel
Gets the current battery level of the BLE device
Params
-
callback (
Function
) to be triggered when battery data is read
Returns
- (
undefined
)