PolarBleApi
public protocol PolarBleApi : PolarActivityApi, PolarFirmwareUpdateApi, PolarH10OfflineExerciseApi, PolarOfflineRecordingApi, PolarOnlineStreamingApi, PolarSdkModeApi, PolarSleepApi, PolarTrainingSessionApi
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
enablefalse disable polar filter
-
Start connecting to a nearby device.
PolarBleApiObserverspolarDeviceConnected is invoked when a connection is established.Declaration
Swift
func startAutoConnectToDevice(_ rssi: Int, service: CBUUID?, polarDeviceType: String?) -> CompletableParameters
rssi(Received Signal Strength Indicator) value is typically between -40 to -55 dBm.
serviceoptional service to contain in device advertisement prior to connection attempt
polarDeviceTypelike 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
PolarBleApiObserverspolarDeviceConnected.Throws
InvalidArgument if identifier is invalid polar device id or invalid uuidDeclaration
Swift
func connectToDevice(_ identifier: String) throwsParameters
identifierPolar 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 uuidDeclaration
Swift
func disconnectFromDevice(_ identifier: String) throwsParameters
identifierPolar device id
-
Start searching for Polar device(s)
Declaration
Swift
func searchForDevice() -> Observable<PolarDeviceInfo>Parameters
onNextfor every new Polar device found
Return Value
Observable stream
- onNext: for every new Polar device found
-
Start searching for compatible device(s) with given device name prefix
Declaration
Swift
func searchForDevice(withRequiredDeviceNamePrefix: String?) -> Observable<PolarDeviceInfo>Parameters
requiredDeviceNamePrefixreturned devices are filtered based on given device name prefix string. Default: “Polar”
Return Value
Observable stream
- onNext: for every new 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
identifiersset 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) -> BoolParameters
identifierthe identifier of the device to check.
featurethe 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) -> CompletableParameters
identifierpolar device id or UUID
timetime to set
zonetime zone to set
Return Value
Completable stream
- success: when time has been set to device
- onError: see
PolarErrorsfor possible errors invoked
-
Get current time in device. Note, the H10 is not supporting time read.
Requires feature
PolarBleSdkFeature.feature_polar_device_time_setupDeclaration
Swift
@available(*, deprecated, message: "Use getLocalTimeWithZone(﹚ instead to also get timezone") func getLocalTime(_ identifier: String) -> Single<Date>Parameters
identifierpolar device id or UUID
timetime to set
zonetime zone to set
Return Value
Single stream
- success: once after settings received from device
- onError: see
PolarErrorsfor possible errors invoked
-
Get current time and timezone from device.
Requires feature
PolarBleSdkFeature.feature_polar_device_time_setupDeclaration
Swift
func getLocalTimeWithZone(_ identifier: String) -> Single<(Date, TimeZone)>Parameters
identifierPolar device id or UUID
Return Value
Single stream
- success: once after settings received from device, emits
(Date, TimeZone) - onError: see
PolarErrorsfor possible errors invoked
- success: once after settings received from device, emits
-
Get
PolarDiskSpaceDatafrom device.Declaration
Swift
func getDiskSpace(_ identifier: String) -> Single<PolarDiskSpaceData>Parameters
identifierpolar device id or UUID
Return Value
Single stream
- success: once after disk space received from device
- onError: see
PolarErrorsfor possible errors invoked
-
Set [LedConfig] to enable or disable blinking LEDs (Verity Sense 2.2.1+).
Declaration
Swift
func setLedConfig(_ identifier: String, ledConfig: LedConfig) -> CompletableParameters
identifierpolar device id or UUID
ledConfigto enable or disable LEDs blinking
Return Value
Completable stream
- success: when enable or disable sent to device
- onError: see
PolarErrorsfor possible errors invoked
-
Perform factory reset to given device.
Declaration
Swift
@available(*, deprecated, message: "Use doFactoryReset(_ identifier: String﹚ instead.") func doFactoryReset(_ identifier: String, preservePairingInformation: Bool) -> CompletableParameters
identifierpolar device id or UUID
preservePairingInformationpreserve pairing information during factory reset
Return Value
Completable stream
- success: when factory reset notification sent to device
- onError: see
PolarErrorsfor possible errors invoked
-
Perform factory reset to given device.
Declaration
Swift
func doFactoryReset(_ identifier: String) -> CompletableParameters
identifierpolar device id or UUID
Return Value
Completable stream
- success: when factory reset notification sent to device
- onError: see
PolarErrorsfor possible errors invoked
-
Perform restart to given device.
Declaration
Swift
@available(*, deprecated, message: "Use doRestart(_ identifier: String﹚ instead.") func doRestart(_ identifier: String, preservePairingInformation: Bool) -> CompletableParameters
identifierpolar device id or UUID
preservePairingInformationpreserve pairing information during restart
Return Value
Completable stream
- success: when restart notification sent to device
- onError: see
PolarErrorsfor possible errors invoked
-
Perform restart to given device.
Declaration
Swift
func doRestart(_ identifier: String) -> CompletableParameters
identifierpolar device id or UUID
Return Value
Completable stream
- success: when restart notification sent to device
- onError: see
PolarErrorsfor possible errors invoked
-
Get SD log configuration from a device (SDLOGS.BPB)
Declaration
Swift
func getSDLogConfiguration(_ identifier: String) -> Single<SDLogConfig>Parameters
identifierpolar device id or UUID
Return Value
Single stream
- success: A motley crew of boolean values describing the SD log configuration
- onError: see
PolarErrorsfor possible errors invoked
-
Set SD log configuration to a device (SDLOGS.BPB)
Declaration
Swift
func setSDLogConfiguration(_ identifier: String, logConfiguration: SDLogConfig) -> CompletableParameters
identifierpolar device id or UUID
logConfigurationA 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
PolarErrorsfor possible errors invoked
-
Set [FtuConfig] for device
Declaration
Swift
func doFirstTimeUse(_ identifier: String, ftuConfig: PolarFirstTimeUseConfig) -> CompletableParameters
identifierpolar device id or UUID
ftuConfigConfiguration data for the first-time use, encapsulated in [PolarFirstTimeUseConfig].
Return Value
Completable stream
- success: when enable or disable sent to device
- onError: see
PolarErrorsfor 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
identifierPolar device id or UUID
Return Value
Boolean
- success: true when FTU has been done, false otherwise
- onError: see
PolarErrorsfor possible errors invoked
-
Get the user¨s physical data from the given Polar device.
Declaration
Swift
func getUserPhysicalConfiguration(_ identifier: String) -> Maybe<PolarPhysicalConfiguration?>Parameters
identifierPolar device ID or UUID
Return Value
Maybe<PolarPhysicalConfiguration?>- Emits the
PolarPhysicalConfigurationif available - Emits
nilif not available - Errors are propagated as
PolarErrors
- Emits the
-
Set the device to warehouse sleep state. Factory reset will be performed in order to enable the setting.
Declaration
Swift
func setWarehouseSleep(_ identifier: String) -> CompletableParameters
identifierpolar device id or UUID
Return Value
Completable stream
- success: when warehouse sleep has been set together with factory reset
- onError: see
PolarErrorsfor possible errors invoked
-
Turn of device by setting the device to sleep state.
Declaration
Swift
func turnDeviceOff(_ identifier: String) -> CompletableParameters
identifierpolar device id or UUID
Return Value
Completable stream
- success: when device has successfully set to sleep
- onError: see
PolarErrorsfor 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
identifierpolar device id or UUID
Return Value
Single stream
- success: Collection of user device settings, like device location on user.
- onError: see
PolarErrorsfor possible errors invoked
-
Set Device User Settings to a device (UDEVSET.BPB)
Declaration
Swift
func setPolarUserDeviceSettings(_ identifier: String, polarUserDeviceSettings: PolarUserDeviceSettings) -> CompletableParameters
identifierPolar device id or UUID
polarUserDeviceSettingsCollection 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
PolarErrorsfor 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?) -> CompletableParameters
identifierPolar device id or UUID
fromDateThe starting date to delete date folders from
toDateThe ending date of last date to delete folders from
Return Value
Completable stream
- success: when date folders successfully deleted
- onError: see
PolarErrorsfor possible errors invoked
-
Waits for the device to establish a connection.
Declaration
Swift
func waitForConnection(_ identifier: String) -> CompletableReturn Value
Completable stream
- success: When connection is established
- onError: see
PolarErrorsfor possible errors invoked
-
Set user device location on a device.
Declaration
Swift
func setUserDeviceLocation(_ identifier: String, location: Int) -> CompletableParameters
identifierPolar device id or UUID
locationDevice location as an integer value (see
PolarUserDeviceSettings.DeviceLocation)Return Value
Completable stream
- success: when location is set successfully
- onError: see
PolarErrorsfor possible errors invoked
-
Set USB connection mode on a device.
Declaration
Swift
func setUsbConnectionMode(_ identifier: String, enabled: Bool) -> CompletableParameters
identifierPolar device id or UUID
enabledBoolean flag to enable or disable USB connection mode
Return Value
Completable stream
- success: when USB mode is set successfully
- onError: see
PolarErrorsfor possible errors invoked
-
Set automatic training detection settings on a device.
Declaration
Swift
func setAutomaticTrainingDetectionSettings( _ identifier: String, mode: Bool, sensitivity: Int, minimumDuration: Int ) -> CompletableParameters
identifierPolar device id or UUID
modeBoolean flag to enable or disable automatic training detection
sensitivitySensitivity level as integer, range [0, 100]. Higher values cause training to trigger more easily
minimumDurationMinimum training duration in seconds
Return Value
Completable stream
- success: when settings are applied successfully
- onError: see
PolarErrorsfor possible errors invoked
-
Request multi BLE connection mode status from device.
Declaration
Swift
func getMultiBLEConnectionMode(identifier: String) -> Single<Bool>Parameters
identifierPolar device id or UUID
Return Value
Single stream
- success: Boolean: true if multi BLE connection has been enabled, false otherwise.
- onError: see
PolarErrorsfor possible errors invoked
-
Enable multi BLE connection mode on a given device.
Declaration
Swift
func setMultiBLEConnectionMode(identifier: String, enable: Bool) -> CompletableParameters
identifierPolar device id or UUID
enableBoolean flag to enable or disable multi BLE connection mode
Return Value
Completable stream
- success: when multi BLE connection mode has been successfully set
- onError: see
PolarErrorsfor possible errors invoked
-
Notify device of the incoming data transfer operation(s). By using this method the device will handle data transfer operations more efficiently by setting it to faster data transfer mode. It also will cause the device to flush the latest data to files giving you the most up-to-date data.
Declaration
Swift
func sendInitializationAndStartSyncNotifications(identifier: String) -> CompletableParameters
identifierPolar device id or UUID
Return Value
Completable stream
- success: Initialization and synchronization start nofifications have been successfully sent
- onError: see
PolarErrorsfor possible errors invoked
-
Notify device that data transfer operations are completed. By calling this API device will set itself back to normal data transfer mode that will use less battery.
Declaration
Swift
func sendTerminateAndStopSyncNotifications(identifier: String) -> CompletableParameters
identifierPolar device id or UUID
Return Value
Completable stream
- success: Initialization and synchronization stop nofifications have been successfully sent
- onError: see
PolarErrorsfor 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.
Note that firmware update (FWU) turns on automatic reconnection automatically, and restores the setting automatically when operation completes. One should not change this setting during FWU.
Declaration
Swift
var automaticReconnection: Bool { get set }