PolarOfflineRecordingApi

public protocol PolarOfflineRecordingApi

Offline recording API.

Offline recording makes it possible to record PolarBleApi.PolarDeviceDataType data to device memory. With Offline recording the Polar device and phone don’t need to be connected all the time, as offline recording continues in Polar device even the BLE disconnects.

Offline records saved into the device can be encrypted. The PolarRecordingSecret is provided for startOfflineRecording and setOfflineRecordingTrigger when encryption is wanted. The PolarRecordingSecret with same key must be provided in getOfflineRecord to correctly decrypt the data in the device.

Requires feature PolarBleSdkFeature.feature_polar_offline_recording

Note, offline recording is supported in Polar Verity Sense device (starting from firmware version 2.1.0)

  • Get the data types available in this device for offline recording

    Declaration

    Swift

    func getAvailableOfflineRecordingDataTypes(_ identifier: String) -> Single<Set<PolarDeviceDataType>>

    Return Value

    Single stream

    • success: set of available offline recording data types in this device
    • onError: see PolarErrors for possible errors invoked

  • Request the offline recording settings available in current operation mode. This request shall be used before the offline recording is started to decide currently available settings. The available settings depend on the state of the device.

    Declaration

    Swift

    func requestOfflineRecordingSettings(_ identifier: String, feature: PolarDeviceDataType) -> Single<PolarSensorSetting>

    Return Value

    Single stream

    • success: once after settings received from device
    • onError: see PolarErrors for possible errors invoked

  • Request all the settings available in the device. The request returns the all capabilities of the requested streaming feature not limited by the current operation mode.

    Declaration

    Swift

    func requestFullOfflineRecordingSettings(_ identifier: String, feature: PolarDeviceDataType) -> Single<PolarSensorSetting>

    Return Value

    Single stream

    • success: once after settings received from device
    • onError: see PolarErrors for possible errors invoked

  • Get status of offline recordings.

    Declaration

    Swift

    func getOfflineRecordingStatus(_ identifier: String) -> Single<[PolarDeviceDataType : Bool]>

    Parameters

    identifier

    polar device id

    Return Value

    Single stream

    • success: the dictionary indicating the offline recording status, if the value in dictionary is true the offline recording is currently recording
    • error: see PolarErrors for possible errors invoked

  • List offline recordings stored in the device.

    Declaration

    Swift

    func listOfflineRecordings(_ identifier: String) -> Observable<PolarOfflineRecordingEntry>

    Parameters

    identifier

    polar device id

    Return Value

    Completable

    • next : the found offline recording entry
    • completed: the listing completed
    • error: see PolarErrors for possible errors invoked

  • Fetch recording from the device.

    Note, the fetching of the recording may take several seconds if the recording is big.

    Declaration

    Swift

    func getOfflineRecord(_ identifier: String, entry: PolarOfflineRecordingEntry, secret: PolarRecordingSecret?) -> Single<PolarOfflineRecordingData>

    Parameters

    identifier

    polar device id

    entry

    The offline recording to be fetched

    secret

    If the secret is provided in startOfflineRecording or setOfflineRecordingTrigger then the same secret must be provided when fetching the offline record

    Return Value

    Single

    • success : the offline recording data
    • error: fetch recording request failed. see PolarErrors for possible errors invoked

  • Fetch number sub recordings in recording from the device.

    Declaration

    Swift

    func getSubRecordingCount(identifier: String, entry: PolarOfflineRecordingEntry) -> Single<Int>

    Parameters

    identifier

    polar device id

    entry

    The offline recording whose subrecording count will be checked

    Return Value

    Single

    • success : the offline recording subrecording count
    • error: fetch recording request failed. see PolarErrors for possible errors invoked

  • List split offline recordings stored in the device.

    Declaration

    Swift

    func listSplitOfflineRecordings(_ identifier: String) -> Observable<PolarOfflineRecordingEntry>

    Parameters

    identifier

    polar device id

    Return Value

    Completable

    • next : the found split offline recording entry
    • completed: the listing completed
    • error: see PolarErrors for possible errors invoked

  • Fetch split recording from the device.

    Note, the fetching of the recording may take several seconds if the recording is big.

    Declaration

    Swift

    func getSplitOfflineRecord(_ identifier: String, entry: PolarOfflineRecordingEntry, secret: PolarRecordingSecret?) -> Single<PolarOfflineRecordingData>

    Parameters

    identifier

    polar device id

    entry

    The split offline recording to be fetched

    secret

    If the secret is provided in startOfflineRecording or setOfflineRecordingTrigger then the same secret must be provided when fetching the offline record

    Return Value

    Single

    • success : the offline recording data
    • error: fetch recording request failed. see PolarErrors for possible errors invoked

  • Removes offline recording from the device

    Declaration

    Swift

    func removeOfflineRecord(_ identifier: String, entry: PolarOfflineRecordingEntry) -> Completable

    Parameters

    identifier

    polar device id

    entry

    entry to be removed

    Return Value

    Completable

    • completed : offline record is removed
    • error: offline record removal failed, see PolarErrors for possible errors invoked

  • Removes offline recording with all the subrecordings from the device. Empty parent directories are removed up to day directory.

    Declaration

    Swift

    func removeOfflineRecords(_ identifier: String, entry: PolarOfflineRecordingEntry) -> Single<Bool>

    Parameters

    identifier

    polar device id

    entry

    entry with the path to the offline recording

    Return Value

    Single

    • success : Offline record and its subrecords is/are removed. All empty parent directories up to day directory are removed.
    • error: offline record removal failed, see PolarErrors for possible errors invoked

  • Start offline recording.

    Declaration

    Swift

    func startOfflineRecording(_ identifier: String, feature: PolarDeviceDataType, settings: PolarSensorSetting?, secret: PolarRecordingSecret?) -> Completable

    Parameters

    identifier

    polar device id

    feature

    the feature to be started

    settings

    optional settings used for offline recording. PolarDeviceDataType.hr and PolarDeviceDataType.ppi do not require settings

    Return Value

    Completable

    • completed : offline recording is started successfully
    • error: see PolarErrors for possible errors invoked

  • Request to stop offline recording.

    Declaration

    Swift

    func stopOfflineRecording(_ identifier: String, feature: PolarDeviceDataType) -> Completable

    Parameters

    identifier

    polar device id

    feature

    the feature to be stopped

    Return Value

    Completable

    • completed : offline recording is stop successfully
    • error: offline recording stop failed. see PolarErrors for possible errors invoked

  • Sets the offline recording triggers for a given Polar device. The offline recording can be started automatically in the device by setting the triggers. The changes to the trigger settings will take effect on the next device startup.

    Automatically started offline recording can be stopped by stopOfflineRecording(). Also if user switches off the device power, the offline recording is stopped but starts again once power is switched on and the trigger event happens.

    Trigger functionality can be disabled by setting PolarOfflineRecordingTriggerMode.TRIGGER_DISABLED, the already running offline recording is not stopped by disable.

    Declaration

    Swift

    func setOfflineRecordingTrigger(
        _ identifier: String,
        trigger: PolarOfflineRecordingTrigger,
        secret: PolarRecordingSecret?
    ) -> Completable

    Parameters

    identifier

    Polar device ID

    trigger

    type of trigger to set

    secret

    optional secret; if provided, the offline recordings are encrypted in the device

    Return Value

    Completable

    • completed : the offline recording trigger was set successfully
    • error: the offline recording trigger was not set successfully; see PolarErrors for possible errors that may be invoked.

  • Retrieves the current offline recording trigger setup in the device.

    Declaration

    Swift

    func getOfflineRecordingTriggerSetup(_ identifier: String) -> Single<PolarOfflineRecordingTrigger>

    Parameters

    identifier

    polar device id

    Return Value

    Completable

    • success : the offline recording trigger setup in the device
    • error: fetching recording trigger setup failed, see PolarErrors for possible errors invoked