ZTSport
public final class ZTSport
ZTSport provides methods to ork with ZTSport insoles & shoes
-
ZTSportKit SDK version
Declaration
Swift
public static let sdkVersion: String
-
ZTSportKit SDK activity version
Declaration
Swift
public static let activityPluginVersion: String
-
Shared instance
Declaration
Swift
public static let shared: ZTSport
-
Connected ZTDevice. Connection is done using ZTCoreKit.
Declaration
Swift
public var connectedDevice: ZTDevice? { get }
-
Activity is runnign on modules If nil is returned
ZTSport.shared.readGeneralState()
should be called to update itDeclaration
Swift
public var isActivityRunning: Bool? { get }
-
Current running activity instance
Declaration
Swift
public internal(set) var currentActivity: ZTSportActivity? { get set }
-
Last serial number of device connected
Declaration
Swift
public var lastSerialNumber: String? { get }
-
Current algorithm mode
Declaration
Swift
public private(set) var currentMode: ZTActivityMode? { get set }
-
Activity state change observer
Declaration
Swift
public let onActivityStateChange: ZTSignal<(String?, ZTDeviceActualState, Error?)>
-
Activity state change observer
Declaration
Swift
public let onActivityStopped: ZTSignal<(String?, ZTDeviceActualState, Error?)>
-
Activity segment data received
Declaration
Swift
public let onActivityDataReceived: ZTSignal<(Data?)>
-
Notify about activity from previous session exist without calling stop
Declaration
Swift
public let onActivityRestoreStarted: ZTSignal<(Bool)>
-
Notify about activity data was sent when activity is stopped
Declaration
Swift
public let onActivityStopRequestSent: ZTSignal<(String?, Error?)>
-
Notify about raw data transfer state change
Declaration
Swift
public let onRawDataFlowStateChange: ZTSignal<(ZTSport.RawDataFlowState?, Error?)>
-
Notify about raw data transfer progress
Declaration
Swift
public let onRawDataFlowProgresss: ZTSignal<(Float)>
-
Get actual state of connected device
Declaration
Swift
public func readGeneralState(completion: @escaping ((ZTDeviceActualState?) -> Void))
Parameters
completion
ZTDeviceActualState?
-
Algorithm selection to use with activity
Declaration
Swift
public func setMode(mode: ZTActivityMode, completion: @escaping ZTBaseResult)
Parameters
mode
ZTActivityMode
- algo type
-
Retrieve routing data for activity
Declaration
Swift
public func getMapRouteData(activityId: String, completion: @escaping (([String : Any]?, Data?, Error?) -> Void))
Parameters
id
Activity id
completion
( array of
ZTSportActivitySummary
,Error
) -
Retrieve route segment details
Declaration
Swift
public func getSegmentDetails(activityId: String, segmentId: String, completion: @escaping ((ZTActivityRunAnalysis?, Error?) -> Void))
Parameters
activityId
activity id
segmentId
segment id
completion
(
ZTSportSegmentDetails
,Error
) -
Retrieve route segment details
Declaration
Swift
public func getSegmentDetails(activityId: String, segmentId: String, completion: @escaping (([String : Any]?, Data?, Error?) -> Void))
Parameters
activityId
activity id
segmentId
segment id
completion
(
[String: Any]]
,Error
) -
Retrieve activity data for time range
Declaration
Swift
public func getActivitySummary(id: String, fields: [ZTSportActivity.Field] = [], include: [String]? = nil, completion: @escaping (ZTResultObject<ZTSportActivitySummary>))
Parameters
id
activity ID
fields
Array of
ZTSportActivity.Field
to include in responseinclude
addtitional information to include, e.g. “supplimentalData.geoThumbnail” , “attributes.goalType”, “attributes.goalValue”
completion
(
ZTSportActivitySummary
,Error
) -
Retrieve activity summary list
Declaration
Swift
public func getActivitiesSummary(code: String?, offset: Int, limit: Int, fields: [ZTSportActivity.Field] = [], include: [String]? = nil, whereOptions: [String: Any]? = nil, duration: [String: Any]? = nil, start: Date? = nil, end: Date? = nil, completion: @escaping (ZTResultArray<ZTSportActivitySummary>))
Parameters
code
shoe code
Optional
offset
starting index of the activities
limit
number of objects to return
fields
Array of
ZTSportActivity.Field
to include in responseinclude
addtitional information to include, e.g. “supplimentalData.geoThumbnail” , “attributes.goalType”, “attributes.goalValue”
completion
callback with array of activities
-
Retrieve activity data for time range
Declaration
Swift
public func getActivitySummary(id: String, fields: [String] = [], include: [String]? = nil, whereOptions: [String: Any]? = nil, duration: [String: Any]? = nil, start: Date? = nil, end: Date? = nil, completion: @escaping (ZTResultObject<ZTSportActivitySummary>))
Parameters
id
activity ID
fields
Array of
ZTSportActivity.Field
to include in responseinclude
addtitional information to include, e.g. “supplimentalData.geoThumbnail” , “attributes.goalType”, “attributes.goalValue”
completion
(
ZTSportActivitySummary
,Error
) -
Retrieve activity summary list
Declaration
Swift
public func getActivitiesSummary(code: String?, offset: Int, limit: Int, fields: [String], include: [String]? = nil, whereOptions: [String: Any]? = nil, duration: [String: Any]? = nil, start: Date? = nil, end: Date? = nil, completion: @escaping (ZTResultArray<ZTSportActivitySummary>))
Parameters
code
shoe code
Optional
offset
starting index of the activities
limit
number of objects to return
fields
Array of
ZTSportActivity.Field
to include in responseinclude
addtitional information to include, e.g. “supplimentalData.geoThumbnail” , “attributes.goalType”, “attributes.goalValue”
completion
callback with array of activities
-
Add activity data for current activity
Declaration
Swift
public func addActivityData(timestamp: TimeInterval, data: [Any], completion: @escaping (ZTBaseResult))
Parameters
timestamp
TimeInterval
current timestampdata
[Any]
array of activity datacompletion
The closure called when the
Data
is saved. -
Retrieve timeline rollup
Declaration
Swift
public func getActivityTimelineRollup(start: Date, end: Date, completion: @escaping (ZTResultObject<ZTTimelineRollup>))
Parameters
start
to include activities from
Date
end
to include activites up to
Date
completion
(
ZTSportTimelineRollup
?,Error
?) -
Retrieve run analysis for activity
Declaration
Swift
public func getActivityRunAnalysis(activityId: String, completion: @escaping (ZTResultObject<ZTActivityRunAnalysis>))
Parameters
activityId
Activity id
completion
callback with array of activities
-
Retrieve activity analysis
Declaration
Swift
public func getPeriodActivityAnalysis(code: String?, period: ZTPeriod, completion: @escaping (ZTResultObject<ZTActivityAnalysis>))
Parameters
code
shoe code
period
to include activities from
Date
completion
callback with array of activities
-
Retrieve sqi optimisation to get range of the SQI and its optimized value for stepLength and cadence
Declaration
Swift
public func getAnalysisSqiOptimisation(activityId: String, completion: @escaping (([String : Any]?, Error?) -> Void))
Parameters
activityId
Activity id
completion
callback with optional dictionary
[String: Any]?
andError
-
Start activity. Result of activity start command can be observed in completion handler.
Declaration
Swift
public func startActivity(attributes: [String: Any], userParameters: ZTUserDataParameters? = nil, enableRawData: Bool = false, samplingMode: ZTSamplingMode? = nil, timeout: Double = 15, completion: ZTActivityResult?)
Parameters
attributes
attributes for activity. It may include
goal
andgoalValue
or any additional attributes for this activityuserParameters
ZTUserDataParameters?
optional with height, weight and shoe sizeenableRawData
enable raw data mode to write raw data
enableFastSampling
enable 208Hz mode (default is 104Hz)
timeout
timeout to start activity
completion
(activityId?, ZTError?)
-
Stop activity
Declaration
Swift
public func stopActivity(timeout: Double = 30, completion: ZTActivityResult?)
Parameters
timeout
timeout to stop activity in seconds
completion
(activityId?, Error?)
-
Goals enum
Declaration
Swift
enum ActivityGoal : String, Codable