0.3.2 • Published 7 years ago

checkoutmyworkout-heart-rate-monitor v0.3.2

Weekly downloads
24
License
MIT
Repository
gitlab
Last release
7 years ago

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

  1. Node.js
  2. React Native
  3. react-native-ble-plx (be sure to have the right settings for your profile to be given Bluetooth permissions for your app)
  4. 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

  1. React Native
  2. react-native-ble-plx
  3. contributing template from Billie Thompson

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

License

This project is licensed under the MIT License - see the LICENSE.md file for details

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago