Skip to main content

Sport

The Sport module provides comprehensive management and synchronization of sport activity data from wearable devices. It enables retrieval of detailed metrics including distance, steps, calories, heart rate zones, and sport-specific measurements (swimming, jump rope, elliptical, rowing). The module supports multiple sport types and provides structured data models for analyzing athletic performance and health metrics.

Prerequisites

  • Device must support sport activity tracking and data synchronization
  • User must have performed at least one sport activity on the device
  • Device connectivity must be established before initiating data synchronization
  • Timestamp parameters must be valid Unix timestamps (in seconds)

Data Models

TSSportModel

PropertyTypeDescription
summaryTSSportSummaryModel *Summary information of the sport activity including statistics and performance metrics
sportItemsNSArray<TSSportItemModel *> *Detailed metrics and measurements recorded during the activity
heartRateItemsNSArray<TSHRValueItem *> *Heart rate measurements recorded throughout the activity

TSSportSummaryModel

PropertyTypeDescription
startTimeNSTimeIntervalUnix timestamp indicating when the activity started
endTimeNSTimeIntervalUnix timestamp indicating when the activity ended
durationdoubleTotal duration of the activity in seconds
userIDNSString *Unique identifier for the user who performed the activity
macAddressNSString *MAC address of the recording device
sportIDlongUnique identifier for the sport activity session
typeTSSportTypeEnumType of sport activity performed
stepsUInt32Total number of steps taken during the activity
distanceUInt32Total distance covered in meters
calorieUInt32Total calories burned in calories
maxHrValueUInt8Highest heart rate recorded in BPM
minHrValueUInt8Lowest heart rate recorded in BPM
avgHrValueUInt8Average heart rate during the activity in BPM
maxPacefloatHighest pace recorded in seconds per kilometer
minPacefloatLowest pace recorded in seconds per kilometer
avgPacefloatAverage pace in seconds per kilometer
maxSpeedfloatHighest speed recorded in meters per second
minSpeedfloatLowest speed recorded in meters per second
avgSpeedfloatAverage speed in meters per second
maxCadenceUInt8Highest cadence recorded in steps per minute
minCadenceUInt8Lowest cadence recorded in steps per minute
avgCadenceUInt8Average cadence in steps per minute
warmHrDurationUInt32Time spent in warm-up heart rate zone in seconds
fatBurnHrDurationUInt32Time spent in fat burning heart rate zone in seconds
aerobicHrDurationUInt32Time spent in aerobic heart rate zone in seconds
anaerobicHrDurationUInt32Time spent in anaerobic heart rate zone in seconds
extremeHrDurationUInt32Time spent in extreme heart rate zone in seconds
warmHrRatioUInt8Percentage of time in warm-up zone (0-100)
fatBurnHrRatioUInt8Percentage of time in fat burning zone (0-100)
aerobicHrRatioUInt8Percentage of time in aerobic zone (0-100)
anaerobicHrRatioUInt8Percentage of time in anaerobic zone (0-100)
extremeHrRatioUInt8Percentage of time in extreme zone (0-100)
displayConfigsNSData * _NullableBitmap of enabled display metrics (maximum 32 bytes)

TSSportDailyModel

PropertyTypeDescription
sportRecordsNSArray<TSSportModel *> *Array of all sport activities performed during the day
sportCountNSUIntegerTotal number of sport activities performed
totalDurationNSTimeIntervalCombined duration of all activities in seconds
maxHeartRateUInt8Highest heart rate recorded across all activities in BPM
minHeartRateUInt8Lowest heart rate recorded across all activities in BPM

TSSportItemModel

PropertyTypeDescription
userIDNSString *Unique identifier for the user
macAddressNSString *MAC address of the recording device
sportIDlongUnique identifier for the sport activity session
typeUInt16Type of sport activity
distanceNSIntegerTotal distance covered in meters
stepsNSIntegerTotal number of steps taken
caloriesNSIntegerTotal calories burned
paceNSIntegerCurrent pace in seconds per kilometer
cadenceNSIntegerStep cadence in steps per minute
speedNSIntegerSpeed in meters per minute
swimStyleintSwimming style (1: Freestyle, 2: Breaststroke, 3: Backstroke, 4: Butterfly)
swimLapsintTotal number of swimming laps completed
swimStrokesintTotal number of swimming strokes
swimStrokeFreqintSwimming stroke frequency in strokes per minute
swolfintSwimming efficiency (SWOLF) score
jumpCountintTotal number of successful jumps
jumpBkCountintNumber of times rope skipping was interrupted
jumpConsCountintHighest number of consecutive jumps
elCountintTotal number of elliptical strides
elFrequecyintCurrent elliptical stride frequency in strides per minute
elMaxFrequecyintHighest elliptical stride frequency in strides per minute
elMinFrequecyintLowest elliptical stride frequency in strides per minute
rowCountintTotal number of rowing strokes completed
rowFrequecyintCurrent rowing frequency in strokes per minute
rowMaxFrequecyintHighest rowing frequency in strokes per minute
rowMinFrequecyintLowest rowing frequency in strokes per minute

Enumerations

TSSportTypeEnum

ValueNameDescription
0x01TSSportTypeOutdoorCyclingOutdoor Cycling
0x05TSSportTypeOutdoorRunningOutdoor Running
0x09TSSportTypeIndoorRunningIndoor Running
0x0DTSSportTypeOutdoorWalkingOutdoor Walking
0x11TSSportTypeClimbingClimbing
0x15TSSportTypeBasketballBasketball
0x19TSSportTypeSwimmingSwimming
0x1DTSSportTypeBadmintonBadminton
0x21TSSportTypeFootballFootball
0x25TSSportTypeEllipticalElliptical
0x29TSSportTypeYogaYoga
0x2DTSSportTypePingPongTable Tennis
0x31TSSportTypeRopeSkippingRope Skipping
0x35TSSportTypeRowingRowing Machine
0x39TSSportTypeLazyBikeLazy Bike
0x3DTSSportTypeFitnessBikeFitness Bike
0x41TSSportTypeFreeTrainingFree Training
0x45TSSportTypeTennisTennis
0x49TSSportTypeBaseballBaseball
0x4DTSSportTypeRugbyRugby
0x51TSSportTypeCricketCricket
0x55TSSportTypeFreeSportsFree Sports
0x59TSSportTypeStrengthTrainingStrength Training
0x5DTSSportTypeIndoorWalkingIndoor Walking
0x61TSSportTypeIndoorCyclingIndoor Cycling
0x65TSSportTypeDumbbellDumbbell
0x69TSSportTypeDanceDance
0x6DTSSportTypeHulaHoopHula Hoop
0x71TSSportTypeGolfGolf
0x75TSSportTypeLongJumpLong Jump
0x79TSSportTypeSitUpSit-up
0x7DTSSportTypeVolleyballVolleyball
0x81TSSportTypeParkourParkour
0x85TSSportTypeHikingHiking
0x89TSSportTypeHockeyHockey
0x8DTSSportTypeBoatingBoating
0x91TSSportTypeHIITHigh Intensity Interval Training
0x95TSSportTypeSoftballSoftball
0x99TSSportTypeTrailRunningTrail Running
0x9DTSSportTypeSkiingSkiing
0xA1TSSportTypeTreadmillTreadmill
0xA5TSSportTypeRelaxationRelaxation
0xA9TSSportTypeCrossTrainingCross Training
0xADTSSportTypePilatesPilates
0xB1TSSportTypeCrossMatchCross Match
0xB5TSSportTypeFunctionalTrainingFunctional Training
0xB9TSSportTypePhysicalTrainingPhysical Training
0xBDTSSportTypeMixedCardioMixed Cardio
0xC1TSSportTypeLatinDanceLatin Dance
0xC5TSSportTypeStreetDanceStreet Dance
0xC9TSSportTypeFreeSparringFree Sparring
0xCDTSSportTypeBalletBallet
0xD1TSSportTypeAustralianFootballAustralian Football
0xD5TSSportTypeBowlingBowling
0xD9TSSportTypeSquashSquash
0xDDTSSportTypeCurlingCurling
0xE1TSSportTypeSnowboardingSnowboarding
0xE5TSSportTypeFishingFishing
0xE9TSSportTypeFrisbeeFrisbee
0xEDTSSportTypeAlpineSkiingAlpine Skiing
0xF1TSSportTypeCoreTrainingCore Training
0xF5TSSportTypeSkatingSkating
0xF9TSSportTypeFitnessGamingFitness Gaming
0xFDTSSportTypeAerobicsAerobics
0x0101TSSportTypeGroupCallisthenicsGroup Calisthenics
0x0105TSSportTypeKickBoxingKick Boxing
0x0109TSSportTypeFencingFencing
0x010DTSSportTypeStairClimbingStair Climbing
0x0111TSSportTypeAmericanFootballAmerican Football
0x0115TSSportTypeFoamRollingFoam Rolling
0x0119TSSportTypePickleballPickleball
0x011DTSSportTypeBoxingBoxing
0x0121TSSportTypeTaekwondoTaekwondo
0x0125TSSportTypeKarateKarate
0x0129TSSportTypeFlexibilityFlexibility
0x012DTSSportTypeHandballHandball
0x0131TSSportTypeHandcarHandcar
0x0135TSSportTypeMeditationMeditation
0x0139TSSportTypeWrestlingWrestling
0x013DTSSportTypeSteppingStepping
0x0141TSSportTypeTaiChiTai Chi
0x0145TSSportTypeGymnasticsGymnastics
0x0149TSSportTypeTrackAndFieldTrack and Field
0x014DTSSportTypeMartialArtsMartial Arts
0x0151TSSportTypeLeisureSportsLeisure Sports
0x0155TSSportTypeSnowSportsSnow Sports
0x0159TSSportTypeLacrosseLacrosse
0x015DTSSportTypeHorizontalBarHorizontal Bar
0x0161TSSportTypeParallelBarsParallel Bars
0x0165TSSportTypeRollerSkatingRoller Skating
0x0169TSSportTypeDartsDarts
0x016DTSSportTypeArcheryArchery
0x0171TSSportTypeHorseRidingHorse Riding
0x0175TSSportTypeShuttlecockShuttlecock
0x0179TSSportTypeIceHockeyIce Hockey
0x017DTSSportTypeAbdominalTrainingAbdominal Training
0x0181TSSportTypeVO2MaxTestVO2 Max Test
0x0185TSSportTypeJudoJudo
0x0189TSSportTypeTrampoliningTrampolining
0x018DTSSportTypeSkateboardSkateboard
0x0191TSSportTypeHoverBoardHover Board
0x0195TSSportTypeInlineSkatingInline Skating
0x0199TSSportTypeTreadmillRunningTreadmill Running
0x019DTSSportTypeDivingDiving
0x01A1TSSportTypeSurfingSurfing
0x01A5TSSportTypeSnorkelingSnorkeling
0x01A9TSSportTypePullUpPull-up
0x01ADTSSportTypePushUpPush-up
0x01B1TSSportTypePlankPlank
0x01B5TSSportTypeRockClimbingRock Climbing
0x01B9TSSportTypeHighJumpHigh Jump
0x01BDTSSportTypeBungeeJumpingBungee Jumping
0x01C1TSSportTypeNationalDanceNational Dance
0x01C5TSSportTypeHuntingHunting
0x01C9TSSportTypeShootingShooting
0x01CDTSSportTypeMarathonMarathon
0x01D1TSSportTypeSpinningBikeSpinning Bike
0x01D5TSSportTypePoolSwimmingPool Swimming
0x01D9TSSportTypeOpenWaterSwimmingOpen Water Swimming
0x01DDTSSportTypeBallroomDanceBallroom Dance
0x01E1TSSportTypeZumbaZumba
0x01E5TSSportTypeJazzDanceJazz Dance
0x01E9TSSportTypeStepMachineStep Machine
0x01EDTSSportTypeStairMachineStair Machine
0x01F1TSSportTypeCroquetCroquet
0x01F5TSSportTypeWaterPoloWater Polo
0x01F9TSSportTypeWallBallWall Ball
0x01FDTSSportTypeBilliardsBilliards
0x0201TSSportTypeSepakTakrawSepak Takraw
0x0205TSSportTypeStretchingStretching
0x0209TSSportTypeFreeGymnasticsFree Gymnastics
0x020DTSSportTypeBarbellBarbell
0x0211TSSportTypeWeightliftingWeightlifting
0x0215TSSportTypeDeadliftDeadlift
0x0219TSSportTypeBurpeeBurpee
0x021DTSSportTypeJumpingJackJumping Jack
0x0221TSSportTypeUpperBodyTrainingUpper Body Training
0x0225TSSportTypeLowerBodyTrainingLower Body Training
0x0229TSSportTypeBackTrainingBack Training
0x022DTSSportTypeBeachBuggyBeach Buggy
0x0231TSSportTypeParaglidingParagliding
0x0235TSSportTypeFlyAKiteFly a Kite
0x0239TSSportTypeTugOfWarTug of War
0x023DTSSportTypeTriathlonTriathlon
0x0241TSSportTypeSnowmobileSnowmobile
0x0245TSSportTypeSnowCarSnow Car
0x0249TSSportTypeSledSled
0x024DTSSportTypeSkiBoardSki Board
0x0251TSSportTypeCrossCountrySkiingCross Country Skiing
0x0255TSSportTypeIndoorSkatingIndoor Skating
0x0259TSSportTypeKabaddiKabaddi
0x025DTSSportTypeMuayThaiMuay Thai
0x0261TSSportTypeKickboxingKickboxing
0x0265TSSportTypeRacingRacing
0x0269TSSportTypeIndoorFitnessIndoor Fitness
0x026DTSSportTypeOutdoorSoccerOutdoor Soccer
0x0271TSSportTypeBellyDanceBelly Dance
0x0275TSSportTypeSquareDanceSquare Dance

TSSportDisplayMetric

ValueNameDescription
1TSSportDisplayMetricDurationDuration
2TSSportDisplayMetricHeartRateHeart Rate
3TSSportDisplayMetricStepsSteps
4TSSportDisplayMetricDistanceDistance
5TSSportDisplayMetricCaloriesCalories
6TSSportDisplayMetricAvgSpeedAverage Speed
7TSSportDisplayMetricAvgPaceAverage Pace
8TSSportDisplayMetricAvgCadenceAverage Cadence
9TSSportDisplayMetricAvgStrideAverage Stride
10TSSportDisplayMetricTotalAscentTotal Ascent
11TSSportDisplayMetricTotalDescentTotal Descent
12TSSportDisplayMetricSwimLapsSwim Laps
13TSSportDisplayMetricSwimStrokesSwim Strokes
14TSSportDisplayMetricSwimStyleSwim Style
15TSSportDisplayMetricSwimStrokeRateSwim Stroke Rate
16TSSportDisplayMetricSwimEfficiencySwim Efficiency (SWOLF)
17TSSportDisplayMetricTriggerCountTrigger Count
18TSSportDisplayMetricTriggerRateTrigger Rate
19TSSportDisplayMetricInterruptionCountInterruption Count
20TSSportDisplayMetricContinuousCountContinuous Count

Callback Types

Sport Data Synchronization Completion Block

void (^)(NSArray<TSSportModel *> *_Nullable sports, NSError *_Nullable error)
ParameterTypeDescription
sportsNSArray<TSSportModel *> *Array of synchronized sport activities, or nil if error occurred
errorNSError *Error object containing details if synchronization failed, or nil on success

API Reference

Synchronize sport history data within a specified time range

Retrieves sport activity data from the device for activities that occurred between the specified start and end times.

- (void)syncHistoryDataFormStartTime:(NSTimeInterval)startTime
endTime:(NSTimeInterval)endTime
completion:(nonnull void (^)(NSArray<TSSportModel *> *_Nullable sports, NSError *_Nullable error))completion;
ParameterTypeDescription
startTimeNSTimeIntervalUnix timestamp (in seconds) for the beginning of the sync period
endTimeNSTimeIntervalUnix timestamp (in seconds) for the end of the sync period
completionvoid (^)(NSArray<TSSportModel *> *_Nullable, NSError *_Nullable)Callback block executed when synchronization completes

Code Example:

// Get current date and date from 7 days ago
NSDate *endDate = [NSDate date];
NSDate *startDate = [endDate dateByAddingTimeInterval:-(7 * 24 * 60 * 60)];

NSTimeInterval startTime = [startDate timeIntervalSince1970];
NSTimeInterval endTime = [endDate timeIntervalSince1970];

id<TSSportInterface> sportInterface = (id<TSSportInterface>)kitManager.getService(TSServiceTypeSport);

[sportInterface syncHistoryDataFormStartTime:startTime
endTime:endTime
completion:^(NSArray<TSSportModel *> * _Nullable sports, NSError * _Nullable error) {
if (error) {
TSLog(@"Sport sync failed: %@", error.localizedDescription);
return;
}

for (TSSportModel *sport in sports) {
TSLog(@"Sport Type: %ld, Duration: %.0f seconds", (long)sport.summary.type, sport.summary.duration);
TSLog(@"Distance: %u m, Steps: %u", sport.summary.distance, sport.summary.steps);
TSLog(@"Avg HR: %u BPM, Calories: %u", sport.summary.avgHrValue, sport.summary.calorie);
}
}];

Synchronize sport history data from a specified start time until now

Retrieves sport activity data from the device for all activities that occurred from the specified start time until the current moment.

- (void)syncHistoryDataFormStartTime:(NSTimeInterval)startTime
completion:(nonnull void (^)(NSArray<TSSportModel *> *_Nullable sports, NSError *_Nullable error))completion;
ParameterTypeDescription
startTimeNSTimeIntervalUnix timestamp (in seconds) for the beginning of the sync period
completionvoid (^)(NSArray<TSSportModel *> *_Nullable, NSError *_Nullable)Callback block executed when synchronization completes

Code Example:

// Get timestamp for 30 days ago
NSDate *thirtyDaysAgo = [[NSDate date] dateByAddingTimeInterval:-(30 * 24 * 60 * 60)];
NSTimeInterval startTime = [thirtyDaysAgo timeIntervalSince1970];

id<TSSportInterface> sportInterface = (id<TSSportInterface>)kitManager.getService(TSServiceTypeSport);

[sportInterface syncHistoryDataFormStartTime:startTime
completion:^(NSArray<TSSportModel *> * _Nullable sports, NSError * _Nullable error) {
if (error) {
TSLog(@"Sport sync failed: %@", error.localizedDescription);
return;
}

TSLog(@"Total activities synced: %lu", (unsigned long)sports.count);

NSUInteger totalSteps = 0;
NSUInteger totalDistance = 0;
UInt8 maxHeartRate = 0;

for (TSSportModel *sport in sports) {
totalSteps += sport.summary.steps;
totalDistance += sport.summary.distance;
if (sport.summary.maxHrValue > maxHeartRate) {
maxHeartRate = sport.summary.maxHrValue;
}
}

TSLog(@"Total Steps: %lu, Total Distance: %lu m, Max HR: %u BPM",
(unsigned long)totalSteps, (unsigned long)totalDistance, maxHeartRate);
}];

Important Notes

  1. **Timestamp Format**: All time parameters use Unix timestamps in seconds. Convert NSDate objects using timeIntervalSince1970 property.

  2. **Data Retrieval Timing**: Synchronization operations are asynchronous. Ensure device connectivity is established before initiating sync operations.

  3. **Time Range Validation**: Verify that startTime is less than endTime to avoid unexpected behavior. The device will only return activities that fall within the specified time range.

  4. **Heart Rate Zones Calculation**: The five heart rate zones are calculated based on user age and maximum heart rate formula (220 - age). Verify user age is correctly set on the device for accurate zone classification.

  5. **Sport-Specific Metrics**: Different sport types populate different metric fields. For example, swimming activities populate swimStyle, swimLaps, and SWOLF values, while jump rope activities use jumpCount and jumpConsCount.

  6. **Display Metrics Configuration**: The displayConfigs bitmap in TSSportSummaryModel indicates which metrics the device is configured to display. Check hasDisplayMetric: before relying on specific metric availability.

  7. **Heart Rate Data Frequency**: heartRateItems array may contain heart rate measurements at varying intervals depending on device firmware and activity type.

  8. **Performance Considerations**: Large time ranges or devices with many activities may require extended synchronization time. Consider breaking up large date ranges into smaller chunks for better responsiveness.

  9. **Pace Units**: Pace values are measured in seconds per kilometer (s/km). Convert to minutes per kilometer by dividing by 60.

  10. **Summary vs. Detailed Items**: TSSportSummaryModel contains aggregated statistics, while TSSportItemModel array contains granular data points. Use summary data for overview displays and detailed items for in-depth analysis.