PolarTrainingSessionApi
public protocol PolarTrainingSessionApi
Protocol defining methods to access training session data.
-
Get training session references for a given period. If fromDate and toDate are not given this method will return all training session references in the device. Otherwise returns list of training session references from the specified closed or half-open date interval.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataThrows
SeePolarErrorsfor possible errors.Declaration
Swift
func getTrainingSessionReferences( identifier: String, fromDate: Date?, toDate: Date? ) async throws -> [PolarTrainingSessionReference]Parameters
identifierThe Polar device ID or BT address.
fromDateThe starting date of the period to retrieve training session references from. Optional.
toDateThe ending date of the period to retrieve training session references from. Optional.
Return Value
An array of
PolarTrainingSessionReferenceobjects for the specified period. -
Get a specific training session using a reference.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataThrows
SeePolarErrorsfor possible errors.Declaration
Swift
func getTrainingSession( identifier: String, trainingSessionReference: PolarTrainingSessionReference ) async throws -> PolarTrainingSessionParameters
identifierThe Polar device ID or BT address.
trainingSessionReferenceThe reference to the training session to retrieve.
Return Value
PolarTrainingSessioncontaining the session data. -
Get a specific training session using a reference with progress updates.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataThrows
SeePolarErrorsfor possible errors.Declaration
Swift
func getTrainingSessionWithProgress( identifier: String, trainingSessionReference: PolarTrainingSessionReference, progressHandler: @escaping (PolarTrainingSessionProgress) -> Void ) async throws -> PolarTrainingSessionParameters
identifierThe Polar device ID or BT address.
trainingSessionReferenceThe reference to the training session to retrieve.
progressHandlerA closure called with
PolarTrainingSessionProgressas the session data is being fetched.Return Value
PolarTrainingSessioncontaining the complete session data. -
deleteTrainingSession(identifier:Asynchronousreference: ) Api for removing single training session from a Polar device. You can get a list of training sessions with
getTrainingSessionReferencesAPI.Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func deleteTrainingSession(identifier: String, reference: PolarTrainingSessionReference) async throwsParameters
identifierThe Polar device ID or BT address.
referencePolarTrainingSessionReference with path in device to the training session to be removed.
-
startExercise(identifier:Asynchronousprofile: ) Start an exercise session on the device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func startExercise(identifier: String, profile: PolarExerciseSession.SportProfile) async throwsParameters
identifierThe Polar device ID or BT address.
profileThe sport profile to use for the exercise session.
-
pauseExercise(identifier:Asynchronous) Pause an ongoing exercise session.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func pauseExercise(identifier: String) async throwsParameters
identifierThe Polar device ID or BT address.
-
resumeExercise(identifier:Asynchronous) Resume a paused exercise session.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func resumeExercise(identifier: String) async throwsParameters
identifierThe Polar device ID or BT address.
-
stopExercise(identifier:Asynchronous) Stop the current exercise session.
By default, the session is saved on the device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func stopExercise(identifier: String) async throwsParameters
identifierThe Polar device ID or BT address.
-
getExerciseStatus(identifier:Asynchronous) Get the current exercise session status from the device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataThrows
SeePolarErrorsfor possible errors invoked.Declaration
Swift
func getExerciseStatus(identifier: String) async throws -> PolarExerciseSession.ExerciseInfoParameters
identifierThe Polar device ID or BT address.
Return Value
The current
PolarExerciseSession.ExerciseInfofor the device. -
Observe exercise session status notifications from the device.
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_training_dataDeclaration
Swift
func observeExerciseStatus(identifier: String) -> AsyncThrowingStream<PolarExerciseSession.ExerciseInfo, Error>Parameters
identifierThe Polar device ID or BT address.
Return Value
AsyncThrowingStreamemittingPolarExerciseSession.ExerciseInfowhenever the session status changes.