PolarBleApi

API.

  • remove all known devices, which are not in use

    Declaration

    Swift

    func cleanup()
  • Enable or disable polar filter.

    Declaration

    Swift

    func polarFilter(_ enable: Bool)

    Parameters

    enable

    false disable polar filter

  • Start connecting to a nearby device. PolarBleApiObservers polarDeviceConnected is invoked when a connection is established.

    Declaration

    Swift

    func startAutoConnectToDevice(_ rssi: Int, service: CBUUID?, polarDeviceType: String?) -> Completable

    Parameters

    rssi

    (Received Signal Strength Indicator) value is typically between -40 to -55 dBm.

    service

    optional service to contain in device advertisement prior to connection attempt

    polarDeviceType

    like H10, OH1 etc… or nil for any polar device

    Return Value

    Completable. Complete called when scan for nearby device has ended and connection attempt is started and deviceConnecting callback will be invoked.

  • Request a connection to a Polar device. Invokes PolarBleApiObservers polarDeviceConnected.

    Throws

    InvalidArgument if identifier is invalid polar device id or invalid uuid

    Declaration

    Swift

    func connectToDevice(_ identifier: String) throws

    Parameters

    identifier

    Polar device id printed on the sensor/device or UUID.

  • Disconnect from the current Polar device.

    Throws

    InvalidArgument if identifier is invalid polar device id or invalid uuid

    Declaration

    Swift

    func disconnectFromDevice(_ identifier: String) throws

    Parameters

    identifier

    Polar device id

  • Start searching for Polar device(s)

    Declaration

    Swift

    func searchForDevice() -> Observable<PolarDeviceInfo>

    Parameters

    onNext

    for every new polar device found

    Return Value

    Observable stream

    • onNext: for every new polar device found

  • Start listening the heart rate from Polar devices when subscribed. This observable listens BLE broadcast and parses heart rate from BLE broadcast. The BLE device don’t need to be connected when using this function, the heart rate is parsed from the BLE advertisement

    Declaration

    Swift

    func startListenForPolarHrBroadcasts(_ identifiers: Set<String>?) -> Observable<PolarHrBroadcastData>

    Parameters

    identifiers

    set of Polar device ids to filter or null for a any Polar device

    Return Value

    Observable stream

  • Check if the feature is ready.

    Declaration

    Swift

    func isFeatureReady(_ identifier: String, feature: PolarBleSdkFeature) -> Bool

    Parameters

    identifier

    the identifier of the device to check.

    feature

    the feature to check for readiness.

    Return Value

    a boolean indicating whether a specific feature is ready for use on a given device.

  • Set local time to device.

    Requires feature PolarBleSdkFeature.feature_polar_device_time_setup.

    Declaration

    Swift

    func setLocalTime(_ identifier: String, time: Date, zone: TimeZone) -> Completable

    Parameters

    identifier

    polar device id or UUID

    time

    time to set

    zone

    time zone to set

    Return Value

    Completable stream

    • success: when time has been set to device
    • onError: see PolarErrors for possible errors invoked

  • Get current time in device. Note, the H10 is not supporting time read.

    Requires feature PolarBleSdkFeature.feature_polar_device_time_setup

    Declaration

    Swift

    func getLocalTime(_ identifier: String) -> Single<Date>

    Parameters

    identifier

    polar device id or UUID

    time

    time to set

    zone

    time zone to set

    Return Value

    Single stream

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

  • Get PolarDiskSpaceData from device.

    Declaration

    Swift

    func getDiskSpace(_ identifier: String) -> Single<PolarDiskSpaceData>

    Parameters

    identifier

    polar device id or UUID

    Return Value

    Single stream

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

  • Set [LedConfig] to enable or disable blinking LEDs (Verity Sense 2.2.1+).

    Declaration

    Swift

    func setLedConfig(_ identifier: String, ledConfig: LedConfig) -> Completable

    Parameters

    identifier

    polar device id or UUID

    ledConfig

    to enable or disable LEDs blinking

    Return Value

    Completable stream

    • success: when enable or disable sent to device
    • onError: see PolarErrors for possible errors invoked

  • Perform factory reset to given device.

    Declaration

    Swift

    func doFactoryReset(_ identifier: String, preservePairingInformation: Bool) -> Completable

    Parameters

    identifier

    polar device id or UUID

    preservePairingInformation

    preserve pairing information during factory reset

    Return Value

    Completable stream

    • success: when factory reset notification sent to device
    • onError: see PolarErrors for possible errors invoked

  • Perform restart to given device.

    Declaration

    Swift

    func doRestart(_ identifier: String, preservePairingInformation: Bool) -> Completable

    Parameters

    identifier

    polar device id or UUID

    preservePairingInformation

    preserve pairing information during restart

    Return Value

    Completable stream

    • success: when restart notification sent to device
    • onError: see PolarErrors for possible errors invoked

  • Get SD log configuration from a device (SDLOGS.BPB)

    Declaration

    Swift

    func getSDLogConfiguration(_ identifier: String) -> Single<SDLogConfig>

    Parameters

    identifier

    polar device id or UUID

    Return Value

    Single stream

    • success: A motley crew of boolean values describing the SD log configuration
    • onError: see PolarErrors for possible errors invoked

  • Set SD log configuration to a device (SDLOGS.BPB)

    Declaration

    Swift

    func setSDLogConfiguration(_ identifier: String, logConfiguration: SDLogConfig) -> Completable

    Parameters

    identifier

    polar device id or UUID

    logConfiguration

    A motley crew of boolean values describing the SD log configuration

    Return Value

    Completable stream

    • success: When SD log configuration has been written to the device
    • onError: see PolarErrors for possible errors invoked

  • Set [FtuConfig] for device

    Declaration

    Swift

    func doFirstTimeUse(_ identifier: String, ftuConfig: PolarFirstTimeUseConfig) -> Completable

    Parameters

    identifier

    polar device id or UUID

    ftuConfig

    Configuration data for the first-time use, encapsulated in [PolarFirstTimeUseConfig].

    Return Value

    Completable stream

    • success: when enable or disable sent to device
    • onError: see PolarErrors for possible errors invoked
    • [PolarFirstTimeUseConfig] class enforces specific ranges and valid values for each parameter:
    • Gender: “Male” or “Female”
    • Height: 90 to 240 cm
    • Weight: 15 to 300 kg
    • Max heart rate: 100 to 240 bpm
    • Resting heart rate: 20 to 120 bpm
    • VO2 max: 10 to 95
    • Training background: One of the predefined levels (10, 20, 30, 40, 50, 60)
    • Typical day: One of [TypicalDay] values
    • Sleep goal: Minutes, valid range [300-660]

  • Check if the First Time Use has been done for the given Polar device.

    Declaration

    Swift

    func isFtuDone(_ identifier: String) -> Single<Bool>

    Parameters

    identifier

    Polar device id or UUID

    Return Value

    Boolean

    • success: true when FTU has been done, false otherwise
    • onError: see PolarErrors for possible errors invoked

  • Set the device to warehouse sleep state. Factory reset will be performed in order to enable the setting.

    Declaration

    Swift

    func setWarehouseSleep(_ identifier: String) -> Completable

    Parameters

    identifier

    polar device id or UUID

    Return Value

    Completable stream

    • success: when warehouse sleep has been set together with factory reset
    • onError: see PolarErrors for possible errors invoked

  • Get Device User Settings to a device from proto in device (UDEVSET.BPB)

    Declaration

    Swift

    func getPolarUserDeviceSettings(identifier: String) -> Single<PolarUserDeviceSettings.PolarUserDeviceSettingsResult>

    Parameters

    identifier

    polar device id or UUID

    Return Value

    Single stream

    • success: Collection of user device settings, like device location on user.
    • onError: see PolarErrors for possible errors invoked

  • Set Device User Settings to a device (UDEVSET.BPB)

    Declaration

    Swift

    func setPolarUserDeviceSettings(_ identifier: String, polarUserDeviceSettings: PolarUserDeviceSettings?) -> Completable

    Parameters

    identifier

    Polar device id or UUID

    polarUserDeviceSettings

    Collection of user device settings, like device location on user.

    Return Value

    Completable stream

    • success: When Device User Settings configuration has been written to the device
    • onError: see PolarErrors for possible errors invoked

  • Delete data [PolarStoredDataType] from a device.

    @param identifier, Polar device ID or BT address @param dataType, [PolarStoredDataType] A specific data type that shall be deleted @param until, Data will be deleted from device from history until this date. @return [Completable] emitting success or error

    Declaration

    Swift

    func deleteStoredDeviceData(_ identifier: String, dataType: PolarStoredDataType.StoredDataType, until: Date?) -> Completable
  • Delete device date folders from a device.

    Declaration

    Swift

    func deleteDeviceDateFolders(_ identifier: String, fromDate: Date?, toDate: Date?) -> Completable

    Parameters

    identifier

    Polar device id or UUID

    fromDate

    The starting date to delete date folders from

    toDate

    The ending date of last date to delete folders from

    Return Value

    Completable stream

    • success: when date folders successfully deleted
    • onError: see PolarErrors for possible errors invoked

  • Common GAP (Generic access profile) observer

    Declaration

    Swift

    var observer: PolarBleApiObserver? { get set }
  • Device info observer for DIS (Device information service) and BAS (Battery service) GATT (Generic attributes) client

    Declaration

    Swift

    var deviceInfoObserver: PolarBleApiDeviceInfoObserver? { get set }
  • Device observer for HR GATT client

    Declaration

    Swift

    @available(*, deprecated, message: "The functionality has changed. Please use the startHrStreaming API to get the heart rate data ")
    var deviceHrObserver: PolarBleApiDeviceHrObserver? { get set }
  • Bluetooth power state observer

    Declaration

    Swift

    var powerStateObserver: PolarBleApiPowerStateObserver? { get set }
  • Device features ready observer

    Declaration

    Swift

    var deviceFeaturesObserver: PolarBleApiDeviceFeaturesObserver? { get set }
  • Helper to check if Ble is currently powered

    Declaration

    Swift

    var isBlePowered: Bool { get }

    Return Value

    current power state

  • optional logger set to get traces from sdk

    Declaration

    Swift

    var logger: PolarBleApiLogger? { get set }
  • optional disable or enable automatic reconnection, by default it is enabled

    Declaration

    Swift

    var automaticReconnection: Bool { get set }