polarofficial/polar-ble-sdk

Continuous Heart Rate extraction question - Xcode

Jasmyn19 opened this issue · 1 comments

Platform your question concerns:

  • Android
  • iOS
  • Other
  • Platform is not relevant for this question

Device:

  • Polar OH1
  • Polar Verity Sense
  • Polar H10
  • Polar H9
  • Other
  • Device is not relevant for this question

My team and I are new to coding and haven't coded in swift before. We are trying to use the polar SDK to connect to a polar h10 band and use the heart rate values continuously in a game. We tried using the example IOS code, but are not sure how to extract the heart rate values to be used in our game code. We have been able to connect to the device, but cannot seem to stream/extract heart rate values. How do we use the SDK functions to extract the heart rate values to use as a continuously updating variable?

Once you're connected to the device, you should check if the real time stream feature is available. Your "manager" class needs to implement PolarBleApiDeviceFeaturesObserver, so that you can override function bleSdkFeatureReady like here.

Once it's enabled you should be able to start HR streaming in a fashion similar to this one. You need to subscribe to polarBleApi.startHrStreaming and in the callback you will receive real time HR as data samples. Make sure to dispose the connection once you finished listening to the HR stream.