polarofficial / polar-ble-sdk

Repository includes SDK and code examples. More info https://polar.com/en/developers
Other
445 stars 147 forks source link

Continuous Heart Rate extraction question - Xcode #457

Open Jasmyn19 opened 2 months ago

Jasmyn19 commented 2 months ago

Platform your question concerns:

Device:

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?

orestesgaolin commented 1 month ago

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.