npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-polar-ble-sdk

v1.0.7

Published

RN Wrapper for polar's native SDKs

Downloads

9

Readme

RN-Polar-Ble-Sdk

A React Native Wrapper for Polar's BLE SDK

Getting started

This should work :

$ npm install rn-polar-ble-sdk --save

Though I only used this repo as a local git submodule at the moment

Usage

import {
  NativeModules,
  NativeEventEmitter,
} from 'react-native';

import PolarBleSdk from 'rn-polar-ble-sdk';

const polarEmitter = new NativeEventEmitter(NativeModules.PolarBleSdkModule);

////////// currently available events

polarEmitter.addListener('connectionState', ({ id, state }) => {
  console.log(`device ${id} connection state : ${state}`);
});

polarEmitter.addListener('firmwareVersion', ({ id, value }) => {
  console.log(`device ${id} firmware version : ${value}`);  
});

polarEmitter.addListener('batteryLevel', ({ id, value }) => {
  console.log(`device ${id} battery level : ${value}`);  
});

polarEmitter.addListener('ecgFeatureReady', ({ id }) => {
  console.log(`ecg feature ready on device ${id}`);    
});

polarEmitter.addListener('accelerometerFeatureReady', ({ id }) => {
  console.log(`accelerometer feature ready on device ${id}`);    
});

polarEmitter.addListener('ppgFeatureReady', ({ id }) => {
  console.log(`ppg feature ready on device ${id}`);      
});

polarEmitter.addListener('ppiFeatureReady', ({ id }) => {
  console.log(`ppi feature ready on device ${id}`);    
});

polarEmitter.addListener('hrData', (data) => {
  const {
    id,
    hr,
    contact,
    contactSupported,
    rrAvailable,
    rrs,
    rrsMs,  
  } = data;
});

polarEmitter.addListener('accData', (data) => {
  const { id, timeStamp, samples } = data;
  const { x, y, z } = samples[0];
});

polarEmitter.addListener('ecgData', (data) => {
  const { id, timeStamp, samples } = data;
  const value = samples[0];
});

polarEmitter.addListener('ppgData', (data) => {
  const { id, timeStamp, samples } = data;
  const { ppg0, ppg1, ppg2, ambient } = samples[0];
});

polarEmitter.addListener('ppiData', (data) => {
  const { id, timeStamp, samples } = data;
  const {
    hr,
    ppInMs,
    ppErrorEstimate,
    blockerBit,
    skinContactStatus,
    skinContactSupported,
  } = samples[0];
});

////////// currently available methods

// polar device's id also appearing in the advertised device name
const id = '12345XYZ';

// attempt to connect to device
PolarBleSdk.connectToDevice(id);

// now wait for the 'connectionState' event to be emitted with the right id
// and a 'connected' state value, then wait for corresponding 'xxxFeatureReady'
// event to be emitted with the right id before calling
// PolarBleSdk.startXxxStreaming() to start receiving the data from event
// 'xxxData' (except for hrData, which is emitted continuously by both H10 and
// OH1 as soon as the device is connected)

// will work with both H10 and OH1 devices
PolarBleSdk.startAccStreaming()
PolarBleSdk.stopAccStreaming();

// will only work with H10 devices
PolarBleSdk.startEcgStreaming();
PolarBleSdk.stopEcgStreaming();

// will only work with OH1 devices
PolarBleSdk.startPpgStreaming()
PolarBleSdk.stopPpgStreaming();
PolarBleSdk.startPpiStreaming();
PolarBleSdk.stopPpiStreaming();

// whenever you are done with the device you can disconnect it
// (active streams will be stopped automatically)
PolarBleSdk.disconnectFromDevice(id);

iOS issues

Polar's BLE sdk relies on Carthage as a dependency manager, and you will need to install it in order to rebuild the sdk if you use XCode >= 12. The rebuild process is automated in ios/scripts/build_frameworks.sh which is executed in the npm preinstall hook, but you still need to provide your admin password manually at the end of the rebuild.