PolarSleepApi

public protocol PolarSleepApi

Protocol defining methods to get Polar Sleep Data

  • Get sleep recording state

    Declaration

    Swift

    func getSleepRecordingState(identifier: String) -> Single<Bool>

    Parameters

    identifier

    The Polar device ID or BT address

    Return Value

    Single Bool value indicating if sleep recording is ongoing

  • Observe sleep recording state

    Declaration

    Swift

    func observeSleepRecordingState(identifier: String) -> Observable<[Bool]>

    Parameters

    identifier

    The Polar device ID or BT address

    Return Value

    Observable of Bool value indicating if sleep recording is ongoing

  • Stop sleep recording

    Declaration

    Swift

    func stopSleepRecording(identifier: String) -> Completable

    Parameters

    identifier

    The Polar device ID or BT address

    Return Value

    Completable stream

    • success: when sleep recording has been stopped
    • onError: see PolarErrors for possible errors invoked

  • Get sleep analysis data for a given period.

    Throws

    Throws Invalid argument exception if toDate is not after or equal to fromDate

    Declaration

    Swift

    func getSleepData(identifier: String, fromDate: Date, toDate: Date) -> Single<[PolarSleepData.PolarSleepAnalysisResult]>

    Parameters

    identifier

    The Polar device ID or BT address.

    fromDate

    The starting date of the period to retrieve sleep data from.

    toDate

    The ending date of the period to retrieve sleep until.

    Return Value

    A Single emitting an array of PolarSleepData representing the sleep analysis data for the specified period.