checkoutmyworkout-heart-rate-monitor v0.3.2
checkoutmyworkout-heart-rate-monitor
Javascript library to read heart rate from bluetooth devices. This library is a simple one, built on the fine work at https://github.com/Polidea/react-native-ble-plx.
Getting Started
These instructions will get you up and running with the checkoutmyworkout-heart-rate-monitor library. There is a working sample if you would like to start by cloning a working repository.
Prerequisites
- Node.js
- React Native
- react-native-ble-plx (be sure to have the right settings for your profile to be given Bluetooth permissions for your app)
- An actual Bluetooth heart rate monitor. We have tested with the Scosche RHYTHM+ and the Polar H10.
Installing
After you have the above prerequisites, you just need to install the checkoutmyworkout-heart-rate-monitor library:
npm install checkoutmyworkout-heart-rate-monitor
Then use it in your code:
import { HeartRateMonitor } from 'checkoutmyworkout-heart-rate-monitor';
...
HeartRateMonitor hrm = new HeartRateMonitor();
hrm.startHeartRateDevicesScan( (device, error) => {
if (error) {
hrm.stopHeartRateDevicesScan();
console.log(`error scanning for heart rate devices: ${JSON.stringify(error)}`)
}
else {
// In a real app you would probably not just take the first one,
// you would probably add all the devices scanned to a list and let
// your user choose. However, for clarity, we'll just take the first
// device and its ID here. You also wouldn't stop the monitor right
// away, but again, we do so for clarity in illustrating how to use
// the code.
hrm.stopHeartRateDevicesScan();
hrm.startHeartRateMonitor(device.id, (result) => {
console.log(`result.heartRate=${result.heartRate}`);
hrm.stopHeartRateMonitor(device.id);
});
}
});
Acknowledgements
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Brian Webb - Initial work - Brian Webb
License
This project is licensed under the MIT License - see the LICENSE.md file for details