PolarBleApi
public protocol PolarBleApi : PolarActivityApi, PolarBleLowLevelApi, PolarDerivedMeasurementApi, PolarDeviceToHostNotificationsApi, PolarFirmwareUpdateApi, PolarH10OfflineExerciseApi, PolarLoggingApi, PolarOfflineExerciseV2Api, PolarOfflineRecordingApi, PolarOnlineStreamingApi, PolarRestServiceApi, PolarSdkModeApi, PolarSleepApi, PolarTemperatureApi, PolarTestApi, PolarTrainingSessionApi, PolarWatchFaceApi
API.
-
remove all known devices, which are not in use
Requires
Requires SDK feature(s): None (core API).Declaration
Swift
func cleanup() -
Enable or disable polar filter.
Requires
Requires SDK feature(s): None (core API).Declaration
Swift
func polarFilter(_ enable: Bool)Parameters
enablefalse disable polar filter
-
startAutoConnectToDevice(_:Asynchronousservice: polarDeviceType: ) Start connecting to a nearby device.
PolarBleApiObserverspolarDeviceConnected is invoked when a connection is established.Requires
Requires SDK feature(s): None (core API).Declaration
Swift
func startAutoConnectToDevice(_ rssi: Int, service: CBUUID?, polarDeviceType: String?) async throwsParameters
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
Completes 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.Requires
Requires SDK feature(s): None (core API).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.
Requires
Requires SDK feature(s): None (core API).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).
Requires
Requires SDK feature(s): None (core API).Declaration
Swift
func searchForDevice() -> AsyncThrowingStream<PolarDeviceInfo, Error>Return Value
AsyncThrowingStreamemittingPolarDeviceInfofor every new Polar device found. -
Start searching for compatible device(s) with a given device name prefix.
Requires
Requires SDK feature(s): None (core API).Declaration
Swift
@available(*, deprecated, message: "Use searchForDevice(withNameContaining: String﹚ instead.") func searchForDevice(withRequiredDeviceNamePrefix: String?) -> AsyncThrowingStream<PolarDeviceInfo, Error>Parameters
withRequiredDeviceNamePrefixReturned devices are filtered based on the given device name prefix. Pass
nilto return all devices. Default:"Polar"Return Value
AsyncThrowingStreamemittingPolarDeviceInfofor every new device found. -
Start searching for compatible device(s) with a given device name prefix.
Requires
Requires SDK feature(s): None (core API).Declaration
Swift
func searchForDevice(withNameContaining: String?) -> AsyncThrowingStream<PolarDeviceInfo, Error>Parameters
withNameContainingReturned devices are filtered based on the given device name prefix. Pass
nilto return all devices. Default:"Polar"Return Value
AsyncThrowingStreamemittingPolarDeviceInfofor 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
Requires
Requires SDK feature(s): None (core API).Declaration
Swift
func startListenForPolarHrBroadcasts(_ identifiers: Set<String>?) -> AsyncThrowingStream<PolarHrBroadcastData, Error>Parameters
identifiersset of Polar device ids to filter or null for a any Polar device
Return Value
AnyPublisher emitting multiple values
-
Check if the feature is ready.
Requires
Requires SDK feature(s): None (core API).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.
-
setLocalTime(_:Asynchronoustime: zone: ) Set local time to device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_time_setupThrows
seePolarErrorsfor possible errors invokedDeclaration
Swift
func setLocalTime(_ identifier: String, time: Date, zone: TimeZone) async throwsParameters
identifierpolar device id or UUID
timetime to set
zonetime zone to set
-
getLocalTime(_:Asynchronous) Get current time in device. Note, the H10 is not supporting time read.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_time_setupThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
@available(*, deprecated, message: "Use getLocalTimeWithZone(﹚ instead to also get timezone") func getLocalTime(_ identifier: String) async throws -> DateParameters
identifierpolar device id or UUID
Return Value
Daterepresenting the current device time. -
getLocalTimeWithZone(_:Asynchronous) Get current time and timezone from device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_time_setupThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func getLocalTimeWithZone(_ identifier: String) async throws -> (Date, TimeZone)Parameters
identifierPolar device id or UUID
Return Value
(Date, TimeZone)representing the current device time and timezone. -
getDiskSpace(_:Asynchronous) Get
PolarDiskSpaceDatafrom device.Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func getDiskSpace(_ identifier: String) async throws -> PolarDiskSpaceDataParameters
identifierpolar device id or UUID
Return Value
PolarDiskSpaceDatawith disk space information from the device. -
setLedConfig(_:AsynchronousledConfig: ) Set [LedConfig] to enable or disable blinking LEDs (Verity Sense 2.2.1+).
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_led_animationThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setLedConfig(_ identifier: String, ledConfig: LedConfig) async throwsParameters
identifierpolar device id or UUID
ledConfigto enable or disable LEDs blinking
-
setTelemetryEnabled(_:Asynchronousenabled: ) Enable or disable telemetry (trace logging / diagnostics) on the device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setTelemetryEnabled(_ identifier: String, enabled: Bool) async throwsParameters
identifierPolar device ID or BT address
enabledtrue = telemetry on, false = off
-
doFactoryReset(_:AsynchronouspreservePairingInformation: ) Perform factory reset to given device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
@available(*, deprecated, message: "Use doFactoryReset(_ identifier: String﹚ instead.") func doFactoryReset(_ identifier: String, preservePairingInformation: Bool) async throwsParameters
identifierpolar device id or UUID
preservePairingInformationpreserve pairing information during factory reset
-
doFactoryReset(_:Asynchronous) Perform factory reset to given device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func doFactoryReset(_ identifier: String) async throwsParameters
identifierpolar device id or UUID
-
doRestart(_:AsynchronouspreservePairingInformation: ) Perform restart to given device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
@available(*, deprecated, message: "Use doRestart(_ identifier: String﹚ instead.") func doRestart(_ identifier: String, preservePairingInformation: Bool) async throwsParameters
identifierpolar device id or UUID
preservePairingInformationpreserve pairing information during restart
-
doRestart(_:Asynchronous) Perform restart to given device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func doRestart(_ identifier: String) async throwsParameters
identifierpolar device id or UUID
-
doFirstTimeUse(_:AsynchronousftuConfig: ) Set [FtuConfig] for device
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor 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]
Declaration
Swift
func doFirstTimeUse(_ identifier: String, ftuConfig: PolarFirstTimeUseConfig) async throwsParameters
identifierpolar device id or UUID
ftuConfigConfiguration data for the first-time use, encapsulated in [PolarFirstTimeUseConfig].
- [PolarFirstTimeUseConfig] class enforces specific ranges and valid values for each parameter:
-
isFtuDone(_:Asynchronous) Check if the First Time Use has been done for the given Polar device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func isFtuDone(_ identifier: String) async throws -> BoolParameters
identifierPolar device id or UUID
Return Value
truewhen FTU has been done,falseotherwise. -
getUserPhysicalConfiguration(_:Asynchronous) Get the user’s physical data from the given Polar device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func getUserPhysicalConfiguration(_ identifier: String) async throws -> PolarPhysicalConfiguration?Parameters
identifierPolar device ID or UUID
Return Value
PolarPhysicalConfigurationif available, ornilif not set on device. -
setWarehouseSleep(_:Asynchronous) Set the device to warehouse sleep state. Factory reset will be performed in order to enable the setting.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setWarehouseSleep(_ identifier: String) async throwsParameters
identifierpolar device id or UUID
-
setHibernateMode(_:Asynchronous) Set hibernate mode on a given device. Hibernate puts the device into a low-power state that retains device time, unlike warehouse sleep (storage mode). Battery should last for tens, or even hundreds of days in hibernate.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setHibernateMode(_ identifier: String) async throwsParameters
identifierpolar device id or UUID
-
turnDeviceOff(_:Asynchronous) Turn of device by setting the device to sleep state.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func turnDeviceOff(_ identifier: String) async throwsParameters
identifierpolar device id or UUID
-
getPolarUserDeviceSettings(identifier:Asynchronous) Get Device User Settings to a device from proto in device (UDEVSET.BPB)
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func getPolarUserDeviceSettings(identifier: String) async throws -> PolarUserDeviceSettings.PolarUserDeviceSettingsResultParameters
identifierpolar device id or UUID
Return Value
PolarUserDeviceSettings.PolarUserDeviceSettingsResultcontaining the user device settings. -
Set Device User Settings to a device (UDEVSET.BPB)
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setPolarUserDeviceSettings(_ identifier: String, polarUserDeviceSettings: PolarUserDeviceSettings) async throwsParameters
identifierPolar device id or UUID
polarUserDeviceSettingsCollection of user device settings, like device location on user.
-
deleteStoredDeviceData(_:AsynchronousdataType: until: ) Delete data [PolarStoredDataType] from a device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func deleteStoredDeviceData(_ identifier: String, dataType: PolarStoredDataType.StoredDataType, until: Date?) async throwsParameters
identifierPolar device ID or BT address
dataTypePolarStoredDataType— a specific data type that shall be deleteduntilData will be deleted from device from history until this date.
-
deleteDeviceDateFolders(_:AsynchronousfromDate: toDate: ) Delete device date folders from a device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func deleteDeviceDateFolders(_ identifier: String, fromDate: Date?, toDate: Date?) async throwsParameters
identifierPolar device id or UUID
fromDateThe starting date to delete date folders from
toDateThe ending date of last date to delete folders from
-
deleteTelemetryData(_:Asynchronous) Delete telemetry data files from a device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func deleteTelemetryData(_ identifier: String) async throwsParameters
identifierPolar device id or UUID
-
waitForConnection(_:Asynchronous) Waits for the device to establish a connection.
Requires
Requires SDK feature(s): None (core API).Throws
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func waitForConnection(_ identifier: String) async throws -
setUserDeviceLocation(_:Asynchronouslocation: ) Set user device location on a device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setUserDeviceLocation(_ identifier: String, location: Int) async throwsParameters
identifierPolar device id or UUID
locationDevice location as an integer value (see
PolarUserDeviceSettings.DeviceLocation) -
setUsbConnectionMode(_:Asynchronousenabled: ) Set USB connection mode on a device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setUsbConnectionMode(_ identifier: String, enabled: Bool) async throwsParameters
identifierPolar device id or UUID
enabledBoolean flag to enable or disable USB connection mode
-
Set automatic training detection settings on a device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setAutomaticTrainingDetectionSettings( _ identifier: String, mode: Bool, sensitivity: Int, minimumDuration: Int ) async throwsParameters
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
-
setDaylightSavingTime(_:Asynchronous) Set the next Daylight Saving Time (DST) settings on the device in the current timezone. Gets the current timezone from the device and sets DST value based on that.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setDaylightSavingTime(_ identifier: String) async throwsParameters
identifierPolar device id or UUID
-
getMultiBLEConnectionMode(identifier:Asynchronous) Request multi BLE connection mode status from device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_features_configuration_serviceThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func getMultiBLEConnectionMode(identifier: String) async throws -> BoolParameters
identifierPolar device id or UUID
Return Value
trueif multi BLE connection mode is enabled,falseotherwise. -
setMultiBLEConnectionMode(identifier:Asynchronousenable: ) Enable multi BLE connection mode on a given device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_features_configuration_serviceThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setMultiBLEConnectionMode(identifier: String, enable: Bool) async throwsParameters
identifierPolar device id or UUID
enableBoolean flag to enable or disable multi BLE connection mode
-
getSensorInitiatedSecurityMode(identifier:Asynchronous) Request Sensor Initiated Security Mode status from device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_features_configuration_serviceThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func getSensorInitiatedSecurityMode(identifier: String) async throws -> BoolParameters
identifierPolar device id or UUID
Return Value
trueif Sensor Initiated Security Mode is enabled,falseotherwise. -
setSensorInitiatedSecurityMode(identifier:Asynchronousenable: ) Enable Sensor Initiated Security Mode on a given device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_features_configuration_serviceThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setSensorInitiatedSecurityMode(identifier: String, enable: Bool) async throwsParameters
identifierPolar device id or UUID
enableBoolean flag to enable or disable Sensor Initiated Security Mode
-
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.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func sendInitializationAndStartSyncNotifications(identifier: String) async throwsParameters
identifierPolar device id or UUID
-
sendTerminateAndStopSyncNotifications(identifier:Asynchronous) 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.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func sendTerminateAndStopSyncNotifications(identifier: String) async throwsParameters
identifierPolar device id or UUID
-
setAutomaticOHRMeasurementEnabled(_:Asynchronousenabled: ) Enable or disable AUTOS file generation on the device. AUTOS files contain 24/7 OHR data. Status of this setting can be read with getUserDeviceSettings().
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_device_controlThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func setAutomaticOHRMeasurementEnabled(_ identifier: String, enabled: Bool) async throwsParameters
identifierPolar device ID or BT address
enabledtrue = AUTOS files enabled, false = disabled
-
Get last received RSSI (Received Signal Strength Indicator) value for the connected device. The value is obtained from iOS BLE in 1 second interval. The value is typically between -40 to -55 dBm when the device is nearby.
Requires
Requires SDK feature(s): None (core API).Declaration
Swift
func getRSSIValue(_ identifier: String) throws -> IntParameters
identifierPolar device ID or BT address
Return Value
Integer value of the last received RSSI or error if the device is not connected or identifier is invalid.
-
Check if the device did disconnect from BLE due to removed pairing. If the device did disconnect due to removed pairing, the device will not be available for connection until it is paired again. It may be required to forget the device from iOS Bluetooth settings and pair it again.
Requires
Requires SDK feature(s): None (core API).Declaration
Swift
func checkIfDeviceDisconnectedDueRemovedPairing(_ identifier: String) throws -> BoolParameters
identifierPolar device ID or BT address
Return Value
True if was disconnected due to removed pairing, false otherwise (BLE connection is OK).
-
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 } -
Request last observed battery level value from device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_battery_infoDeclaration
Swift
func getBatteryLevel(identifier: String) throws -> IntReturn Value
Returns the level of battery charging percentage 0 - 100% Will return -1 if battery battery level is not available.
-
Request last observed charging status value from device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_battery_infoDeclaration
Swift
func getChargerState(identifier: String) throws -> BleBasClient.ChargeStateReturn Value
Returns
ChargeStatevalue indicating the last observed charging status of the device. Will return -1 if battery battery charging percentage level is not available.