Class PolarBleApi
-
- All Implemented Interfaces:
-
com.polar.sdk.api.PolarActivityApi
,com.polar.sdk.api.PolarFirmwareUpdateApi
,com.polar.sdk.api.PolarH10OfflineExerciseApi
,com.polar.sdk.api.PolarOfflineRecordingApi
,com.polar.sdk.api.PolarOnlineStreamingApi
,com.polar.sdk.api.PolarRestServiceApi
,com.polar.sdk.api.PolarSdkModeApi
,com.polar.sdk.api.PolarSleepApi
,com.polar.sdk.api.PolarTemperatureApi
public abstract class PolarBleApi implements PolarOnlineStreamingApi, PolarOfflineRecordingApi, PolarH10OfflineExerciseApi, PolarSdkModeApi, PolarFirmwareUpdateApi, PolarActivityApi, PolarSleepApi, PolarRestServiceApi, PolarTemperatureApi
Polar BLE API.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
PolarBleApi.PolarBleSdkFeature
Features available in Polar BLE SDK library
public enum
PolarBleApi.PolarStoredDataType
The data types in Polar devices that are available for cleanup.
public interface
PolarBleApi.PolarBleApiLogger
Logger interface for logging events from SDK. Shall be used only for tracing and debugging purposes.
public enum
PolarBleApi.PolarDeviceDataType
The data types available in Polar devices for online streaming or offline recording.
public enum
PolarBleApi.PolarActivityDataType
The activity recording data types available in Polar devices.
-
Field Summary
Fields Modifier and Type Field Description private final Set<PolarBleApi.PolarBleSdkFeature>
features
-
Constructor Summary
Constructors Constructor Description PolarBleApi(Set<PolarBleApi.PolarBleSdkFeature> features)
-
Method Summary
Modifier and Type Method Description final Set<PolarBleApi.PolarBleSdkFeature>
getFeatures()
the set of the features API is used for. abstract Unit
setMtu(@IntRange(from = 70, to = 512) Integer mtu)
set mtu to lower than default (232 is the default for polar devices, minimum for H10 is 70 and for OH1 is 140) to minimize latency abstract Unit
shutDown()
Releases the SDK resources. abstract Unit
cleanup()
removes all known devices which are not in use currently abstract Unit
setPolarFilter(Boolean enable)
When enabled only Polar devices are found by the searchForDevice, if set to false any BLE devices with HR services are returned by the searchForDevice. abstract Boolean
isFeatureReady(String deviceId, PolarBleApi.PolarBleSdkFeature feature)
Check if the feature is ready. abstract Unit
foregroundEntered()
Optionally call when application enters to the foreground. abstract Unit
setApiCallback(PolarBleApiCallbackProvider callback)
Sets the API callback abstract Unit
setApiLogger(PolarBleApi.PolarBleApiLogger logger)
Sets the API logger abstract Flowable<PolarDeviceInfo>
searchForDevice()
Starts searching for BLE devices when subscribed. abstract Unit
setAutomaticReconnection(Boolean enable)
When enabled the reconnection is attempted if device connection is lost. abstract Completable
autoConnectToDevice(Integer rssiLimit, String service, Integer timeout, TimeUnit unit, String polarDeviceType)
Start connecting to a nearby Polar device. abstract Completable
autoConnectToDevice(Integer rssiLimit, String service, String polarDeviceType)
abstract Unit
connectToDevice(String identifier)
Request a connection to a BLE device. abstract Unit
disconnectFromDevice(String identifier)
Request disconnecting from a BLE device. abstract Completable
setLocalTime(String identifier, Calendar calendar)
Set the device time. abstract Single<Calendar>
getLocalTime(String identifier)
Get current time in device. abstract Flowable<PolarHrBroadcastData>
startListenForPolarHrBroadcasts(Set<String> deviceIds)
Start listening the heart rate from Polar devices when subscribed. abstract Single<ByteArray>
getFile(String identifier, String path)
Get file as ByteArray from device. abstract Single<PolarDiskSpaceData>
getDiskSpace(String identifier)
Get PolarDiskSpaceData from device. abstract Completable
setLedConfig(String identifier, LedConfig ledConfig)
Set LedConfig for device (Verity Sense 2.2.1+). abstract Completable
doFactoryReset(String identifier, Boolean preservePairingInformation)
Perform factory reset to given device. abstract Completable
doRestart(String identifier)
Perform restart device. abstract Single<LogConfig>
getLogConfig(String identifier)
Get LogConfig from device. abstract Completable
setLogConfig(String identifier, LogConfig logConfig)
Set LogConfig for device. abstract Completable
setWareHouseSleep(String identifier)
Set warehouse sleep setting to a given device. abstract Completable
turnDeviceOff(String identifier)
Turn of device by setting the device to sleep state. abstract Completable
doFirstTimeUse(String identifier, PolarFirstTimeUseConfig ftuConfig)
Configure the Polar device with first-time use settings and user identifier. abstract Single<Boolean>
isFtuDone(String identifier)
Check if the First Time Use has been done for the given device. abstract Completable
setUserDeviceSettings(String identifier, PolarUserDeviceSettings deviceUserSetting)
Set PolarUserDeviceSettings for device. abstract Single<PolarUserDeviceSettings>
getUserDeviceSettings(String identifier)
Get PolarUserDeviceSettings from device. abstract Flowable<ConcurrentLinkedQueue<String>>
deleteStoredDeviceData(String identifier, PolarBleApi.PolarStoredDataType dataType, LocalDate until)
Delete data PolarStoredDataType from a device. abstract Completable
deleteDeviceDateFolders(String identifier, LocalDate fromDate, LocalDate toDate)
Delete device date folders from a device. -
Methods inherited from class com.polar.sdk.api.PolarOnlineStreamingApi
getAvailableOnlineStreamDataTypes, requestFullStreamSettings, requestStreamSettings, startAccStreaming, startEcgStreaming, startGyroStreaming, startHrStreaming, startLocationStreaming, startMagnetometerStreaming, startPpgStreaming, startPpiStreaming, startPressureStreaming, startSkinTemperatureStreaming, startTemperatureStreaming, stopHrStreaming, stopStreaming
-
Methods inherited from class com.polar.sdk.api.PolarOfflineRecordingApi
getAvailableOfflineRecordingDataTypes, getOfflineRecord, getOfflineRecordingStatus, getOfflineRecordingTriggerSetup, getSplitOfflineRecord, listOfflineRecordings, listSplitOfflineRecordings, removeOfflineRecord, requestFullOfflineRecordingSettings, requestOfflineRecordingSettings, setOfflineRecordingTrigger, startOfflineRecording, stopOfflineRecording
-
Methods inherited from class com.polar.sdk.api.PolarH10OfflineExerciseApi
fetchExercise, listExercises, removeExercise, requestRecordingStatus, startRecording, stopRecording
-
Methods inherited from class com.polar.sdk.api.PolarSdkModeApi
disableSDKMode, enableSDKMode, isSDKModeEnabled
-
Methods inherited from class com.polar.sdk.api.PolarFirmwareUpdateApi
updateFirmware, updateFirmware
-
Methods inherited from class com.polar.sdk.api.PolarActivityApi
get247HrSamples, get247PPiSamples, getActiveTime, getCalories, getDistance, getNightlyRecharge, getSteps
-
Methods inherited from class com.polar.sdk.api.PolarSleepApi
getSleep, getSleepRecordingState, observeSleepRecordingState, stopSleepRecording
-
Methods inherited from class com.polar.sdk.api.PolarRestServiceApi
getRestApiDescription, listRestApiServices, putNotification, receiveRestApiEvents
-
Methods inherited from class com.polar.sdk.api.PolarTemperatureApi
getSkinTemperature
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
PolarBleApi
PolarBleApi(Set<PolarBleApi.PolarBleSdkFeature> features)
-
-
Method Detail
-
getFeatures
final Set<PolarBleApi.PolarBleSdkFeature> getFeatures()
the set of the features API is used for. By giving only the needed features the SDK may reserve only the required resources
-
setMtu
abstract Unit setMtu(@IntRange(from = 70, to = 512) Integer mtu)
set mtu to lower than default (232 is the default for polar devices, minimum for H10 is 70 and for OH1 is 140) to minimize latency
- Parameters:
mtu
- value between 70-512 to be set
-
shutDown
abstract Unit shutDown()
Releases the SDK resources. When the SDK is used on scope of the android component (e.g. Activity or Service) then the shutDown may be called on component destroy function. After shutDown the new instance of the SDK is needed:
-
setPolarFilter
abstract Unit setPolarFilter(Boolean enable)
When enabled only Polar devices are found by the searchForDevice, if set to false any BLE devices with HR services are returned by the searchForDevice. The default setting for Polar filter is true.
- Parameters:
enable
- false disables polar filter
-
isFeatureReady
abstract Boolean isFeatureReady(String deviceId, PolarBleApi.PolarBleSdkFeature feature)
Check if the feature is ready.
- Parameters:
deviceId
- polar device id or bt addressfeature
- feature to be requested- Returns:
true if feature is ready for use,
-
foregroundEntered
abstract Unit foregroundEntered()
Optionally call when application enters to the foreground. By calling foregroundEntered() you make sure BLE scan is restarted. BLE scan start is not working when Android device display is off (related to Android power save). By calling foregroundEntered() helps in some rare situations e.g. if connection is lost to the device and .setAutomaticReconnection is enabled, reconnection is created when application is back in foreground.
-
setApiCallback
abstract Unit setApiCallback(PolarBleApiCallbackProvider callback)
Sets the API callback
- Parameters:
callback
- instance of PolarBleApiCallbackProvider
-
setApiLogger
abstract Unit setApiLogger(PolarBleApi.PolarBleApiLogger logger)
Sets the API logger
- Parameters:
logger
- instance of PolarBleApiLogger
-
searchForDevice
abstract Flowable<PolarDeviceInfo> searchForDevice()
Starts searching for BLE devices when subscribed. Search continues as long as observable is subscribed or error. Each found device is emitted only once. By default searches only for Polar devices, but can be controlled by .setPolarFilter. If .setPolarFilter is false then searches for any BLE heart rate capable devices
- Returns:
Flowable stream of PolarDeviceInfo Produces: <BR></BR> - onNext for any new Polar (or BLE) device detected <BR></BR> - onError if scan start fails <BR></BR> - onComplete non produced unless stream is further configured
-
setAutomaticReconnection
abstract Unit setAutomaticReconnection(Boolean enable)
When enabled the reconnection is attempted if device connection is lost. By default automatic reconnection 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.
- Parameters:
enable
- true = automatic reconnection is enabled, false = automatic reconnection is disabled
-
autoConnectToDevice
abstract Completable autoConnectToDevice(Integer rssiLimit, String service, Integer timeout, TimeUnit unit, String polarDeviceType)
Start connecting to a nearby Polar device. PolarBleApiCallback.deviceConnected callback is invoked when connection to a nearby device is established.
- Parameters:
rssiLimit
- RSSI (Received Signal Strength Indication) value is typically from -40 to -60 (dBm), depends on the used Bluetooth chipset and/or antenna tuningservice
- in hex string format like "180D" PolarInvalidArgument invoked if not in correct formattimeout
- min time to search nearby device default = 2sunit
- time unit to be usedpolarDeviceType
- like H10, OH1 etc...- Returns:
rx Completable, complete invoked when nearby device found, and connection attempt started. deviceConnecting callback invoked to inform connection attempt
-
autoConnectToDevice
abstract Completable autoConnectToDevice(Integer rssiLimit, String service, String polarDeviceType)
-
connectToDevice
abstract Unit connectToDevice(String identifier)
Request a connection to a BLE device. Invokes PolarBleApiCallback.deviceConnected callback.
- Parameters:
identifier
- Polar device id found printed on the sensor/device (in format "12345678") or bt address (in format "00:11:22:33:44:55")
-
disconnectFromDevice
abstract Unit disconnectFromDevice(String identifier)
Request disconnecting from a BLE device. Invokes PolarBleApiCallback.deviceDisconnected callback.
- Parameters:
identifier
- Polar device id found printed on the sensor/device or bt address (in format "00:11:22:33:44:55")
-
setLocalTime
abstract Completable setLocalTime(String identifier, Calendar calendar)
Set the device time. Requires feature PolarBleSdkFeature.FEATURE_POLAR_DEVICE_TIME_SETUP
- Parameters:
identifier
- polar device id or bt addresscalendar
- time to set- Returns:
Completable stream
-
getLocalTime
abstract Single<Calendar> getLocalTime(String identifier)
Get current time in device. Requires feature PolarBleSdkFeature.FEATURE_POLAR_DEVICE_TIME_SETUP. Note, the H10 is not supporting time read.
- Parameters:
identifier
- polar device id or bt address- Returns:
Single observable which emits device time in Calendar instance when observable is subscribed
-
startListenForPolarHrBroadcasts
abstract Flowable<PolarHrBroadcastData> startListenForPolarHrBroadcasts(Set<String> deviceIds)
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
- Parameters:
deviceIds
- set of Polar device ids to filter or null for a any Polar device- Returns:
Flowable stream of PolarHrBroadcastData Produces: <BR></BR> - onNext when new advertisement is detected based on deviceId list as filter <BR></BR> - onError if scan start fails <BR></BR> - onComplete non produced unless stream is further configured
-
getFile
abstract Single<ByteArray> getFile(String identifier, String path)
Get file as ByteArray from device.
- Parameters:
identifier
- polar device id or bt addresspath
- filesystem file path- Returns:
Single observable which emits file bytes or error
-
getDiskSpace
abstract Single<PolarDiskSpaceData> getDiskSpace(String identifier)
Get PolarDiskSpaceData from device.
- Parameters:
identifier
- Polar device ID or BT address- Returns:
Single which emits PolarDiskSpaceData
-
setLedConfig
abstract Completable setLedConfig(String identifier, LedConfig ledConfig)
Set LedConfig for device (Verity Sense 2.2.1+).
- Parameters:
identifier
- Polar device ID or BT addressledConfig
- new LedConfig@return Completable emitting success or error
-
doFactoryReset
abstract Completable doFactoryReset(String identifier, Boolean preservePairingInformation)
Perform factory reset to given device.
- Parameters:
identifier
- Polar device ID or BT addresspreservePairingInformation
- preserve pairing information during factory reset- Returns:
Completable emitting success or error
-
doRestart
abstract Completable doRestart(String identifier)
Perform restart device.
- Parameters:
identifier
- Polar device ID or BT address- Returns:
Completable emitting success or error
-
getLogConfig
abstract Single<LogConfig> getLogConfig(String identifier)
Get LogConfig from device.
- Parameters:
identifier
- Polar device ID or BT address@return Single emitting LogConfig or error
-
setLogConfig
abstract Completable setLogConfig(String identifier, LogConfig logConfig)
Set LogConfig for device.
- Parameters:
identifier
- Polar device ID or BT addresslogConfig
- new LogConfig@return Completable emitting success or error
-
setWareHouseSleep
abstract Completable setWareHouseSleep(String identifier)
Set warehouse sleep setting to a given device. Warehouse sleep does factory reset to the device and makes it sleep.
- Parameters:
identifier
- Polar device ID or BT address- Returns:
Completable emitting success or error
-
turnDeviceOff
abstract Completable turnDeviceOff(String identifier)
Turn of device by setting the device to sleep state.
- Parameters:
identifier
- Polar device ID or BT address- Returns:
Completable emitting success or error
-
doFirstTimeUse
abstract Completable doFirstTimeUse(String identifier, PolarFirstTimeUseConfig ftuConfig)
Configure the Polar device with first-time use settings and user identifier.
- Parameters:
identifier
- Polar device ID or Bluetooth address.ftuConfig
- Configuration data for the first-time use, encapsulated in PolarFirstTimeUseConfig.- Returns:
Completable emitting success or error.
PolarFirstTimeUseConfig class requires valid values for each parameter within specific ranges:
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)
Sleep goal: In minutes between 300 to 660
Typical day: "MOSTLY_SITTING", "MOSTLY_STANDING", or "MOSTLY_MOVING"
-
isFtuDone
abstract Single<Boolean> isFtuDone(String identifier)
Check if the First Time Use has been done for the given device.
- Parameters:
identifier
- Polar device ID or Bluetooth address.- Returns:
Single emitting success with "true" or "false" response, or error.
-
setUserDeviceSettings
abstract Completable setUserDeviceSettings(String identifier, PolarUserDeviceSettings deviceUserSetting)
Set PolarUserDeviceSettings for device.
- Parameters:
identifier
- Polar device ID or BT address.deviceUserSetting
- New PolarUserDeviceSettings- Returns:
Completable emitting success or error.
-
getUserDeviceSettings
abstract Single<PolarUserDeviceSettings> getUserDeviceSettings(String identifier)
Get PolarUserDeviceSettings from device.
- Parameters:
identifier
- Polar device ID or BT address@return Single emitting PolarUserDeviceSettings or error
-
deleteStoredDeviceData
abstract Flowable<ConcurrentLinkedQueue<String>> deleteStoredDeviceData(String identifier, PolarBleApi.PolarStoredDataType dataType, LocalDate until)
Delete data PolarStoredDataType from a device. Note that you will need to await for completion.
- Parameters:
identifier
- , Polar device ID or BT addressdataType
- , PolarStoredDataType A specific data type that shall be deleteduntil
- , Data will be deleted from device from history until this date.- Returns:
Flowable success with the paths of the deleted data or error
-
deleteDeviceDateFolders
abstract Completable deleteDeviceDateFolders(String identifier, LocalDate fromDate, LocalDate toDate)
Delete device date folders from a device.
- Parameters:
identifier
- , Polar device ID or BT addressfromDate
- The starting date to delete date folders fromtoDate
- The ending date of last date to delete folders from- Returns:
Completable emitting success or error
-
-
-
-