PolarSleepApi
public protocol PolarSleepApi
Protocol defining methods to get Polar Sleep Data
-
getSleepRecordingState(identifier:AsynchronoustimeoutMs: ) Get sleep recording state
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_sleep_dataThrows
timeout(description:)if timeout is exceeded before state is received.Declaration
Swift
@available(*, deprecated, message: "Use getSleepRecordingStatus(identifier:timeoutMs:﹚, which reports unknown state instead of off") func getSleepRecordingState(identifier: String, timeoutMs: UInt64) async throws -> BoolParameters
identifierThe Polar device ID or BT address
timeoutMsTimeout in milliseconds while waiting for the first sleep recording state event
Return Value
AnyPublisher emitting a single Bool value indicating if sleep recording is ongoing
-
Declaration
Swift
@available(*, deprecated, message: "Use observeSleepRecordingStatus(identifier:﹚, which reports unknown state instead of off") func observeSleepRecordingState(identifier: String) -> AsyncThrowingStream<[Bool], Error>Return Value
Publisher stream of Bool values indicating if sleep recording is ongoing
-
getSleepRecordingStatus(identifier:AsynchronoustimeoutMs: ) Get sleep recording status.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_sleep_dataThrows
timeout(description:)if timeout is exceeded before a status is received.Declaration
Swift
func getSleepRecordingStatus(identifier: String, timeoutMs: UInt64) async throws -> PolarSleepRecordingStatusParameters
identifierThe Polar device ID or BT address
timeoutMsTimeout in milliseconds while waiting for the first sleep recording status event
Return Value
The sleep recording status.
.unknownmeans the device did not report the state. -
Observe sleep recording status.
Declaration
Swift
func observeSleepRecordingStatus(identifier: String) -> AsyncThrowingStream<[PolarSleepRecordingStatus], Error>Return Value
Stream of sleep recording status batches.
.unknownmeans the device did not report the state. -
stopSleepRecording(identifier:Asynchronous) Declaration
Swift
func stopSleepRecording(identifier: String) async throwsReturn Value
Publisher stream
-
getSleep(identifier:AsynchronousfromDate: toDate: ) Declaration
Swift
func getSleep(identifier: String, fromDate: Date, toDate: Date) async throws -> [PolarSleepData.PolarSleepAnalysisResult]Return Value
Publisher emitting an array of
PolarSleepDatafor the specified period. -
getSleepData(identifier:Default implementation, asynchronousfromDate: toDate: ) - Deprecated: Use
getSleep(identifier:fromDate:toDate:)instead.
Default Implementation
Declaration
Swift
@available(*, deprecated, renamed: "getSleep(identifier:fromDate:toDate:﹚") func getSleepData(identifier: String, fromDate: Date, toDate: Date) async throws -> [PolarSleepData.PolarSleepAnalysisResult] - Deprecated: Use
-
getSleepRecordingState(identifier:Extension method, asynchronous) Get sleep recording state with default timeout of 30 seconds.
Declaration
Swift
@available(*, deprecated, message: "Use getSleepRecordingStatus(identifier:﹚, which reports unknown state instead of off") func getSleepRecordingState(identifier: String) async throws -> Bool -
getSleepRecordingStatus(identifier:Extension method, asynchronous) Get sleep recording status with default timeout of 30 seconds.
Declaration
Swift
func getSleepRecordingStatus(identifier: String) async throws -> PolarSleepRecordingStatus
View on GitHub