PolarDeviceTelemetryApi
public protocol PolarDeviceTelemetryApi
NOTE: this is an experimental API intended for Polar internal use only. Polar will not support 3rd party users with this API. Polar Telemetry API for streaming telemetry data from devices.
Provides access to telemetry specific BLE services for streaming telemetry data from device.
Typical usage:
1. Get available telemetry types for the device using `getAvailableTelemetryTypes` API.
2. Read connection parameters from the device
let configuration = try await api.getDeviceTelemetryConfiguration(identifier)
2. Start streaming and listen for telemetry data using `startTelemetryStreaming` API.
for try await telemetry in api.startTelemetry(identifier) {
try await sendTelemetryData(telemetry, configuration: configuration) // Not SDK API
}
Requires
Requires featurePolarBleSdkFeature.feature_telemetry_data_streaming.
-
getDeviceTelemetryConfiguration(telemetryType:Asynchronous_: ) NOTE: this is an experimental API intended for Polar internal use only. Polar will not support 3rd party users with this API. Read telemetry configuration from the device.
Reads the telemetry configuration from device or from BLE service.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_telemetry_data_streamingThrows
SeePolarErrorsfor possible errors.Declaration
Swift
func getDeviceTelemetryConfiguration(telemetryType: PolarDeviceTelemetryType, _ identifier: String) async throws -> DeviceTelemetryConfiguration?Parameters
identifierPolar device ID or BT address.
telemetryTypePolarDeviceTelemetryType to stream. If the desired telemetry type is not supported by the device, the API will throw an error.
Return Value
DeviceTelemetryConfigurationcontaining items that describe the incoming data configuration. Nil if configuration is not available. -
startTelemetry(telemetryType:Asynchronous_: ) NOTE: this is an experimental API intended for Polar internal use only. Polar will not support 3rd party users with this API. Request a device to start streaming telemetry data. Each element emitted by the stream is one unmodified raw data sent by the device.
The stream finishes when the device disconnects, an error occurs, or the returned stream is cancelled (which also disables the device notification).
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_telemetry_data_streamingDeclaration
Swift
func startTelemetry(telemetryType: PolarDeviceTelemetryType, _ identifier: String) async throws -> AsyncThrowingStream<DeviceTelemetryEvent, Error>Parameters
identifierPolar device ID or BT address.
telemetryTypePolarDeviceTelemetryType to stream. If the desired telemetry type is not supported by the device, the API will throw an error.
Return Value
AsyncThrowingStream<DeviceTelemetryEvent, Error>that emits oneDeviceTelemetryEventper received telemetry data item. -
stopTelemetry(telemetryType:Asynchronous_: ) NOTE: this is an experimental API intended for Polar internal use only. Polar will not support 3rd party users with this API. Request a device to stop streaming telemetry data.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_telemetry_data_streamingThrows
SeePolarErrorsfor possible errors.Declaration
Swift
func stopTelemetry(telemetryType: PolarDeviceTelemetryType, _ identifier: String) async throwsParameters
identifierPolar device ID or BT address.
telemetryTypePolarDeviceTelemetryType the device is desired to stop streaming. If the desired PolarDeviceTelemetryType is not supported by the device, the API will throw an error.
-
NOTE: this is an experimental API intended for Polar internal use only. Polar will not support 3rd party users with this API. Returns all telemetry types supported by this SDK for the given device.
The returned values are the
DeviceTelemetrySupportrepresentation of each currently available telemetry streaming type in device. Use this list to discover which telemetry types can be requested before starting a stream.Declaration
Swift
func getAvailableTelemetryTypes(_ identifier: String) -> DeviceTelemetrySupportParameters
identifierPolar device ID or BT address.
Return Value
DeviceTelemetrySupportcontaining available telemetry types for the device.