polarofficial / polar-ble-sdk

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

Unstable connection and broadcast when both iOS and Android is connected and in background. #257

Closed JasurSalimov closed 2 years ago

JasurSalimov commented 2 years ago

Platform your question concerns:

Device:

Description: Our company develops OU7 Training App, you can see it in the AppStore as well. The problem is when we start training on both Android device and iOS device with Polar H10 connected to both. In foreground everything works fine, however when we go to background on both devices connected, the iOS device does not receive the updates as frequently as it should be. Every 3-5 seconds one broadcast from polar. But android in the other hand works fine. So the question is, can you please suggest the way to resolve the problem and did it work in the same way when your team connected both devices? Does this problem related to iOS hardware and software capabilities and restrictions ?

JOikarinen commented 2 years ago

Hi @JasurSalimov,

I just played around with OU7 Training App, very nice app! About the issue, can you confirm I got the steps correctly:

STEPS:

  1. You have enabled the dual BLE connection option in H10.
  2. Android app creates connection to H10 and starts receiving heart rate updates via hrNotificationReceived
  3. iOS app creates connection to the same H10 and starts receiving heart rate updates via PolarBleApiDeviceHrObserver
  4. move iOS app to background

OBSERVED BEHAVIOR:

QUESTIONS:

JasurSalimov commented 2 years ago

Hi @JOikarinen, Yes when returned to foreground everything again works fine and roughly once a second, but in background the problem is as mentioned.

JOikarinen commented 2 years ago

Hi @JasurSalimov,

today I came back on this issue. In your original description you mentioned "broadcast", so it make me think that maybe the problem you see is not related to BLE connection but BLE broadcasting.

In Polar BLE SDK you have option to listen the broadcast data from Polar sensors, in this scenario you are not actually creating a BLE connection to the device. The Polar BLE SDK just scans for the advertisement packets. In this scenario you use the startListenForPolarHrBroadcasts (iOS / Android) API.

If you are actually listening the broadcast then I may know the reason for you issue. The reason is how the iOS operating system works when screen is turned off or the app is moved away from foreground. In this case the iOS operating system starts filter the data it gives. This filtering is seen as slower updates on heart rate data.

JasurSalimov commented 2 years ago

Hi @JOikarinen, yes the problem was exactly because of the broadcast. Actually changing the API helped. Thanks for response. All the best.