Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestOfflineRecordingSettings fails passing polar-data-type ppi #528

Open
8 tasks
abbjetmus opened this issue Dec 13, 2024 · 9 comments
Open
8 tasks

requestOfflineRecordingSettings fails passing polar-data-type ppi #528

abbjetmus opened this issue Dec 13, 2024 · 9 comments
Labels
question Further information is requested

Comments

@abbjetmus
Copy link

Platform your question concerns:

  • [ X] Android
  • iOS
  • Other
  • Platform is not relevant for this question

Device:

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

Description:

Hi!
I'm adding offline recording support to a Flutter library that wraps the polar sdks. And I'm calling requestOfflineRecordingSettings where I want to pass ppi but it is failing, shouldn't I be able to store ppi data offline?
Image from Android docs:
image

My Flutter code, calling requestOfflineRecordingSettings for acc works but not ppi.

                    var settingsAcc =
                        await polar.requestOfflineRecordingSettings(
                            identifier.value, PolarDataType.acc);

                    var settingsPpi =
                        await polar.requestOfflineRecordingSettings(
                            identifier.value, PolarDataType.ppi);

                    await polar.setLocalTime(identifier.value, DateTime.now());

                    // Start offline recording (with optional encryption)
                    await polar.startOfflineRecording(
                        identifier.value, PolarDataType.acc,
                        settings: settingsAcc);

                    // Start offline recording (with optional encryption)
                    await polar.startOfflineRecording(
                        identifier.value, PolarDataType.ppi,
                        settings: settingsPpi);```
                        
                        
                    E/flutter (21957): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(com.polar.sdk.api.errors.PolarOperationNotSupported, null, null, null)

E/flutter (21957): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
E/flutter (21957): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter (21957):
E/flutter (21957): #2 Polar.requestOfflineRecordingSettings (package:polar/src/polar_base.dart:595:22)
E/flutter (21957):
E/flutter (21957): #3 _PolarListPageState.build.. (package:polar_variety_sense_example/pages/polar_list_page.dart:153:25)
E/flutter (21957):


@abbjetmus abbjetmus added the question Further information is requested label Dec 13, 2024
@jimmyzumthurm
Copy link
Member

jimmyzumthurm commented Dec 13, 2024

Hi,

PPI measurement type doesn't expose any settings for our devices as this a computed data type in a fixed format that cannot be configured. You can start the offline measement by passing the start command (0x02) with the measurement type (0x03), but with MSB=1 for offline recording, so 0x02 0x03 for online stream and 0x02 0x83 for offline recording without any other parameters.

Requesting the settings for PPI should return no parameters at all in the response

@abbjetmus
Copy link
Author

I don't understand what you mean with the commands, do you mean I should pass a string with "0x02 0x83" to start offline recording for PPI?

Trying to pass a string I get type errors since it expects: val feature: PolarBleApi.PolarDeviceDataType!

    private fun startOfflineRecording(call: MethodCall, result: Result) {
        val arguments = call.arguments as List<*>
        val identifier = arguments[0] as String
        val feature = gson.fromJson(arguments[1] as String, PolarDeviceDataType::class.java)
        val settings = gson.fromJson(arguments[2] as String, PolarSensorSetting::class.java)

        wrapper.api
            .startOfflineRecording(identifier, feature, settings)
            .subscribe({
                runOnUiThread { result.success(null) }
            }, {
                runOnUiThread {
                    result.error("ERROR_STARTING_RECORDING", it.message, null)
                }
            })
            .discard()
    }

The above is not in sdk-mode, but I might use sdk-mode if the recording time offline becomes to short due to high frequency.

Also do I understand correctly that PPI is not supported in sdk-mode, I have to use PPG and calculate PPI myself?

image

@abbjetmus
Copy link
Author

Oh I see I'm not using raw BLE commands, I want to trigger PPI offline recording using the polar SDK according to the docs. How do I do that?

@abbjetmus
Copy link
Author

abbjetmus commented Dec 16, 2024

I understand now, if a start PPG then since PPI is computed it will probably automatically be calculated if not in sdk mode. The the issue is how do I retrieve the PPI data?

I need to pass an entry when calling getOfflineRecord, though I might just change the entrys type to type: PolarDataType.ppi. Didn't work and the path is obviously to a PPG file.

image
image

@abbjetmus
Copy link
Author

abbjetmus commented Dec 17, 2024

@jimmyzumthurm please do you have any response on how to retrieve the offline PPI values when not in sdk mode using the android sdk?

@jimmyzumthurm
Copy link
Member

Hi @abbjetmus , sorry for the misunderstanding I thought you were using your own implementation of the SDK.

It is correct that PPI data is not available when using SDK Mode.

PPI data is not calculated by the device unless explicitly requested from the SDK for either online or offline stream. I'm no SDK expert so I don't really know how to call this function without passing any settings.

@abbjetmus
Copy link
Author

I understand! But someone from Polar needs to know how you start PPI offline recording and retrieve PPI offline recording when NOT in SDK Mode using the native SDKs? Is there someone I can reach out to get this answer...

@abbjetmus
Copy link
Author

abbjetmus commented Dec 19, 2024

@jimmyzumthurm from this issue, the questioner seems to have PPI recording working, I'm eager to understanding how I can get it working using the sdk:

#411

@abbjetmus
Copy link
Author

I managed to get it right, I always tried to assign null to settings, should be an empty map settings instead.

if (!offlineRecordingStatus.contains(PolarDataType.acc)) {
                      var settingsAcc =
                          await polar.requestOfflineRecordingSettings(
                              identifier.value, PolarDataType.acc);

                      await polar.startOfflineRecording(
                          identifier.value, PolarDataType.acc,
                          settings: settingsAcc);
                    }

                    if (!offlineRecordingStatus.contains(PolarDataType.ppi)) {
                      await polar.startOfflineRecording(
                        identifier.value,
                        PolarDataType.ppi,
                        settings: PolarSensorSetting(<PolarSettingType, int>{}),
                      );
                    }```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants