Skip to content

mikaelbr/node-heartrate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

heartrate NPM version Dependency Status

A Node.js Stream for getting heart rate from Bluetooth Low Energy devices. This is experimental and tested only with the Wahoo Blue HR device.

Usage and Installation

npm install --save heartrate
var BleHR = require('heartrate');
var stream = new BleHR('foo12345bar1234fo12345bar1234123');
stream.pipe(process.stdout);

API

new BleHR(UUID)

Parameter: UUID is string with the UUID. Returns: BleHR instance

or new BleHR(options)

Parameter: option is object of options. Returns: BleHR instance

Defaults:

{
  "log": false,
  "uuid": undefined
}

uuid is required

new BleHR(UUID).getBodyLocation([callback(error, location)])

Parameter: Function callback with the location in string format Returns: BleHR instance (it self)

Get string representation of body sensor location. E.g. Chest, Ear Lobe. Either get data by using the callback or listening to the bodyLocation event.

Example:

var stream = new BleHR('foo12345bar1234fo12345bar1234123');
stream.getBodyLocation().on('bodyLocation', function (error, location) {
  console.log("Location:", location); // Chest
});

new BleHR(UUID).getBatteryLevel([callback(error, level)])

Parameter: Function callback with the current battery level in percentage Returns: BleHR instance (it self)

Get battery level of device in percentage. Interval 0 - 100. Either get data by using the callback or listening to the batteryLevel event.

Example:

var stream = new BleHR('foo12345bar1234fo12345bar1234123');
stream.getBatteryLevel(function (err, level) {
  console.log("BatteryLevel:", level); // BatteryLevel: 47
});

BleHR.list() (static)

Returns: EventEmitter instance

Emits all discovered devices on data event.

Example:

BleHR.list().on('data', function (device) {
  console.log(device.uuid);
});

BleHR.list.print() (static)

Sugar for printing all devices found.

Example:

BleHR.list.print();
// UUID: foo12345bar1234fo12345bar1234123
//   Local Name        = Wahoo HRM v2.1
//   Service Data      =
//   Service UUIDs     = 180d

License

MIT License

About

A Bluethooth Low Energy heart rate stream

Resources

License

Stars

Watchers

Forks

Packages

No packages published