Sport
The Sport module provides comprehensive methods for synchronizing sport activity data from the device, including detailed metrics, heart rate data, and activity summaries for various sport types. This module enables you to retrieve historical sport activity records with full granularity data including performance metrics, heart rate zones, and sport-specific measurements.
Prerequisites
- Device must be connected and support sport activity data synchronization
- User must have proper permissions to access health data
- Device firmware must support the sport data protocol
- Valid start time and end time parameters (Unix timestamps in seconds)
Data Models
TSSportModel
Complete sport activity session containing detailed metrics and measurements.
| Property | Type | Description |
|---|---|---|
summary | TSSportSummaryModel * | Sport activity summary data including statistics and achievements |
sportItems | NSArray<TSSportItemModel *> * | Array of detailed sport item metrics recorded during activity |
heartRateItems | NSArray<TSHRValueItem *> * | Array of heart rate measurements during activity |
TSSportSummaryModel
Summary statistics and performance metrics for a complete sport activity.
| Property | Type | Description |
|---|---|---|
startTime | NSTimeInterval | Unix timestamp (seconds) when activity started |
endTime | NSTimeInterval | Unix timestamp (seconds) when activity ended |
duration | double | Total duration in seconds |
userID | NSString * | Unique identifier of user who performed activity |
macAddress | NSString * | MAC address of recording device |
sportID | long | Unique identifier for sport activity session |
type | TSSportTypeEnum | Type of sport activity |
steps | UInt32 | Total steps taken during activity |
distance | UInt32 | Total distance in meters |
calorie | UInt32 | Total calories burned |
maxHrValue | UInt8 | Highest heart rate in BPM |
minHrValue | UInt8 | Lowest heart rate in BPM |
avgHrValue | UInt8 | Average heart rate in BPM |
maxPace | float | Fastest pace in seconds per kilometer |
minPace | float | Slowest pace in seconds per kilometer |
avgPace | float | Average pace in seconds per kilometer |
maxSpeed | float | Highest speed in meters per second |
minSpeed | float | Lowest speed in meters per second |
avgSpeed | float | Average speed in meters per second |
maxCadence | UInt16 | Highest step cadence in steps per minute |
minCadence | UInt16 | Lowest step cadence in steps per minute |
avgCadence | UInt16 | Average step cadence in steps per minute |
warmHrDuration | UInt32 | Time in warm-up heart rate zone (seconds) |
fatBurnHrDuration | UInt32 | Time in fat burning heart rate zone (seconds) |
aerobicHrDuration | UInt32 | Time in aerobic heart rate zone (seconds) |
anaerobicHrDuration | UInt32 | Time in anaerobic heart rate zone (seconds) |
extremeHrDuration | UInt32 | Time in extreme heart rate zone (seconds) |
warmHrRatio | UInt8 | Percentage of time in warm-up zone (0-100) |
fatBurnHrRatio | UInt8 | Percentage of time in fat burning zone (0-100) |
aerobicHrRatio | UInt8 | Percentage of time in aerobic zone (0-100) |
anaerobicHrRatio | UInt8 | Percentage of time in anaerobic zone (0-100) |
extremeHrRatio | UInt8 | Percentage of time in extreme zone (0-100) |
displayConfigs | NSData * | Display configuration bitmap (nullable, max 32 bytes) |
TSSportItemModel
Detailed metrics for a specific segment or measurement point during sport activity.
| Property | Type | Description |
|---|---|---|
userID | NSString * | Unique identifier of user |
macAddress | NSString * | MAC address of recording device |
sportID | long | Unique identifier for sport activity session |
type | UInt16 | Type of sport activity |
distance | NSInteger | Total distance covered in meters |
steps | NSInteger | Total steps taken |
calories | NSInteger | Total calories burned |
pace | NSInteger | Current pace in seconds per kilometer |
cadence | NSInteger | Step cadence in steps per minute |
speed | NSInteger | Speed in meters per minute |
swimStyle | int | Swimming style (1=Freestyle, 2=Breaststroke, 3=Backstroke, 4=Butterfly) |
swimLaps | int | Number of swimming laps completed |
swimStrokes | int | Total swimming strokes |
swimStrokeFreq | int | Swimming stroke frequency in strokes per minute |
swolf | int | SWOLF score (Swimming + Golf efficiency) |
jumpCount | int | Total successful jump rope jumps |
jumpBkCount | int | Number of jump rope interruptions |
jumpConsCount | int | Highest consecutive jump rope count |
elCount | int | Total elliptical machine strides |
elFrequecy | int | Current elliptical frequency in strides per minute |
elMaxFrequecy | int | Maximum elliptical frequency in strides per minute |
elMinFrequecy | int | Minimum elliptical frequency in strides per minute |
rowCount | int | Total rowing strokes completed |
rowFrequecy | int | Current rowing frequency in strokes per minute |
rowMaxFrequecy | int | Maximum rowing frequency in strokes per minute |
rowMinFrequecy | int | Minimum rowing frequency in strokes per minute |
TSSportDailyModel
Daily aggregation of all sport activities for a specific date.
| Property | Type | Description |
|---|---|---|
sportRecords | NSArray<TSSportModel *> * | Array of all sport activities performed that day |
sportCount | NSUInteger | Total number of sport activities |
totalDuration | NSTimeInterval | Total duration of all activities in seconds |
maxHeartRate | UInt8 | Highest heart rate recorded across all activities |
minHeartRate | UInt8 | Lowest heart rate recorded across all activities |
Enumerations
TSSportTypeEnum
All supported sport activity types.
| Value | Hex | Name (English) | Name (Chinese) |
|---|---|---|---|
TSSportTypeOutdoorCycling | 0x01 | Outdoor Cycling | 户外骑行 |
TSSportTypeOutdoorRunning | 0x05 | Outdoor Running | 户外跑步 |
TSSportTypeIndoorRunning | 0x09 | Indoor Running | 室内跑步 |
TSSportTypeOutdoorWalking | 0x0D | Outdoor Walking | 户外健走 |
TSSportTypeClimbing | 0x11 | Climbing | 登山 |
TSSportTypeBasketball | 0x15 | Basketball | 篮球 |
TSSportTypeSwimming | 0x19 | Swimming | 游泳 |
TSSportTypeBadminton | 0x1D | Badminton | 羽毛球 |
TSSportTypeFootball | 0x21 | Football | 足球 |
TSSportTypeElliptical | 0x25 | Elliptical | 椭圆机 |
TSSportTypeYoga | 0x29 | Yoga | 瑜伽 |
TSSportTypePingPong | 0x2D | Table Tennis | 乒乓球 |
TSSportTypeRopeSkipping | 0x31 | Rope Skipping | 跳绳 |
TSSportTypeRowing | 0x35 | Rowing Machine | 划船机 |
TSSportTypeLazyBike | 0x39 | Lazy Bike | 懒人车 |
TSSportTypeFitnessBike | 0x3D | Fitness Bike | 健身车 |
TSSportTypeFreeTraining | 0x41 | Free Training | 自由训练 |
TSSportTypeTennis | 0x45 | Tennis | 网球 |
TSSportTypeBaseball | 0x49 | Baseball | 棒球 |
TSSportTypeRugby | 0x4D | Rugby | 橄榄球 |
TSSportTypeCricket | 0x51 | Cricket | 板球 |
TSSportTypeFreeSports | 0x55 | Free Sports | 自由运动 |
TSSportTypeStrengthTraining | 0x59 | Strength Training | 力量训练 |
TSSportTypeIndoorWalking | 0x5D | Indoor Walking | 室内走路 |
TSSportTypeIndoorCycling | 0x61 | Indoor Cycling | 室内骑行 |
TSSportTypeDumbbell | 0x65 | Dumbbell | 哑铃 |
TSSportTypeDance | 0x69 | Dance | 舞蹈 |
TSSportTypeHulaHoop | 0x6D | Hula Hoop | 呼啦圈 |
TSSportTypeGolf | 0x71 | Golf | 高尔夫 |
TSSportTypeLongJump | 0x75 | Long Jump | 跳远 |
TSSportTypeSitUp | 0x79 | Sit-up | 仰卧起坐 |
TSSportTypeVolleyball | 0x7D | Volleyball | 排球 |
TSSportTypeParkour | 0x81 | Parkour | 跑酷 |
TSSportTypeHiking | 0x85 | Hiking | 徒步 |
TSSportTypeHockey | 0x89 | Hockey | 曲棍球 |
TSSportTypeBoating | 0x8D | Boating | 划船 |
TSSportTypeHIIT | 0x91 | HIIT | HIIT高强度间歇训练 |
TSSportTypeSoftball | 0x95 | Softball | 垒球 |
TSSportTypeTrailRunning | 0x99 | Trail Running | 越野跑 |
TSSportTypeSkiing | 0x9D | Skiing | 滑雪 |
TSSportTypeTreadmill | 0xA1 | Treadmill | 漫步机 |
TSSportTypeRelaxation | 0xA5 | Relaxation | 整理放松 |
TSSportTypeCrossTraining | 0xA9 | Cross Training | 交叉训练 |
TSSportTypePilates | 0xAD | Pilates | 普拉提 |
TSSportTypeCrossMatch | 0xB1 | Cross Match | 交叉配合 |
TSSportTypeFunctionalTraining | 0xB5 | Functional Training | 功能性训练 |
TSSportTypePhysicalTraining | 0xB9 | Physical Training | 体能训练 |
TSSportTypeMixedCardio | 0xBD | Mixed Cardio | 混合有氧 |
TSSportTypeLatinDance | 0xC1 | Latin Dance | 拉丁舞 |
TSSportTypeStreetDance | 0xC5 | Street Dance | 街舞 |
TSSportTypeFreeSparring | 0xC9 | Free Sparring | 自由搏击 |
TSSportTypeBallet | 0xCD | Ballet | 芭蕾 |
TSSportTypeAustralianFootball | 0xD1 | Australian Football | 澳式足球 |
TSSportTypeBowling | 0xD5 | Bowling | 保龄球 |
TSSportTypeSquash | 0xD9 | Squash | 壁球 |
TSSportTypeCurling | 0xDD | Curling | 冰壶 |
TSSportTypeSnowboarding | 0xE1 | Snowboarding | 单板滑雪 |
TSSportTypeFishing | 0xE5 | Fishing | 钓鱼 |
TSSportTypeFrisbee | 0xE9 | Frisbee | 飞盘 |
TSSportTypeAlpineSkiing | 0xED | Alpine Skiing | 高山滑雪 |
TSSportTypeCoreTraining | 0xF1 | Core Training | 核心训练 |
TSSportTypeSkating | 0xF5 | Skating | 滑冰 |
TSSportTypeFitnessGaming | 0xF9 | Fitness Gaming | 健身游戏 |
TSSportTypeAerobics | 0xFD | Aerobics | 健身操 |
TSSportTypeGroupCallisthenics | 0x0101 | Group Calisthenics | 团体操 |
TSSportTypeKickBoxing | 0x0105 | Kick Boxing | 搏击操 |
TSSportTypeFencing | 0x0109 | Fencing | 击剑 |
TSSportTypeStairClimbing | 0x010D | Stair Climbing | 爬楼 |
TSSportTypeAmericanFootball | 0x0111 | American Football | 美式橄榄球 |
TSSportTypeFoamRolling | 0x0115 | Foam Rolling | 泡沫轴筋膜放松 |
TSSportTypePickleball | 0x0119 | Pickleball | 匹克球 |
TSSportTypeBoxing | 0x011D | Boxing | 拳击 |
TSSportTypeTaekwondo | 0x0121 | Taekwondo | 跆拳道 |
TSSportTypeKarate | 0x0125 | Karate | 空手道 |
TSSportTypeFlexibility | 0x0129 | Flexibility | 柔韧度 |
TSSportTypeHandball | 0x012D | Handball | 手球 |
TSSportTypeHandcar | 0x0131 | Handcar | 手摇车 |
TSSportTypeMeditation | 0x0135 | Meditation | 舒缓冥想类运动 |
TSSportTypeWrestling | 0x0139 | Wrestling | 摔跤 |
TSSportTypeStepping | 0x013D | Stepping | 踏步 |
TSSportTypeTaiChi | 0x0141 | Tai Chi | 太极 |
TSSportTypeGymnastics | 0x0145 | Gymnastics | 体操 |
TSSportTypeTrackAndField | 0x0149 | Track and Field | 田径 |
TSSportTypeMartialArts | 0x014D | Martial Arts | 武术 |
TSSportTypeLeisureSports | 0x0151 | Leisure Sports | 休闲运动 |
TSSportTypeSnowSports | 0x0155 | Snow Sports | 雪上运动 |
TSSportTypeLacrosse | 0x0159 | Lacrosse | 长曲棍球 |
TSSportTypeHorizontalBar | 0x015D | Horizontal Bar | 单杠 |
TSSportTypeParallelBars | 0x0161 | Parallel Bars | 双杠 |
TSSportTypeRollerSkating | 0x0165 | Roller Skating | 轮滑 |
TSSportTypeDarts | 0x0169 | Darts | 飞镖 |
TSSportTypeArchery | 0x016D | Archery | 射箭 |
TSSportTypeHorseRiding | 0x0171 | Horse Riding | 骑马 |
TSSportTypeShuttlecock | 0x0175 | Shuttlecock | 毽球 |
TSSportTypeIceHockey | 0x0179 | Ice Hockey | 冰球 |
TSSportTypeAbdominalTraining | 0x017D | Abdominal Training | 腰腹训练 |
TSSportTypeVO2MaxTest | 0x0181 | VO2 Max Test | 最大摄氧量测试 |
TSSportTypeJudo | 0x0185 | Judo | 柔道 |
TSSportTypeTrampolining | 0x0189 | Trampolining | 蹦床 |
TSSportTypeSkateboard | 0x018D | Skateboard | 滑板 |
TSSportTypeHoverBoard | 0x0191 | Hover Board | 平衡车 |
TSSportTypeInlineSkating | 0x0195 | Inline Skating | 溜旱冰 |
TSSportTypeTreadmillRunning | 0x0199 | Treadmill Running | 跑步机 |
TSSportTypeDiving | 0x019D | Diving | 跳水 |
TSSportTypeSurfing | 0x01A1 | Surfing | 冲浪 |
TSSportTypeSnorkeling | 0x01A5 | Snorkeling | 浮潜 |
TSSportTypePullUp | 0x01A9 | Pull-up | 引体向上 |
TSSportTypePushUp | 0x01AD | Push-up | 俯卧撑 |
TSSportTypePlank | 0x01B1 | Plank | 平板支撑 |
TSSportTypeRockClimbing | 0x01B5 | Rock Climbing | 攀岩 |
TSSportTypeHighJump | 0x01B9 | High Jump | 跳高 |
TSSportTypeBungeeJumping | 0x01BD | Bungee Jumping | 蹦极 |
TSSportTypeNationalDance | 0x01C1 | National Dance | 民族舞 |
TSSportTypeHunting | 0x01C5 | Hunting | 打猎 |
TSSportTypeShooting | 0x01C9 | Shooting | 射击 |
TSSportTypeMarathon | 0x01CD | Marathon | 马拉松 |
TSSportTypeSpinningBike | 0x01D1 | Spinning Bike | 动感单车 |
TSSportTypePoolSwimming | 0x01D5 | Pool Swimming | 泳池游泳 |
TSSportTypeOpenWaterSwimming | 0x01D9 | Open Water Swimming | 开放水域游泳 |
TSSportTypeBallroomDance | 0x01DD | Ballroom Dance | 交际舞 |
TSSportTypeZumba | 0x01E1 | Zumba | 尊巴 |
TSSportTypeJazzDance | 0x01E5 | Jazz Dance | 爵士舞 |
TSSportTypeStepMachine | 0x01E9 | Step Machine | 踏步机 |
TSSportTypeStairMachine | 0x01ED | Stair Machine | 爬楼机 |
TSSportTypeCroquet | 0x01F1 | Croquet | 门球 |
TSSportTypeWaterPolo | 0x01F5 | Water Polo | 水球 |
TSSportTypeWallBall | 0x01F9 | Wall Ball | 墙球 |
TSSportTypeBilliards | 0x01FD | Billiards | 台球 |
TSSportTypeSepakTakraw | 0x0201 | Sepak Takraw | 藤球 |
TSSportTypeStretching | 0x0205 | Stretching | 拉伸 |
TSSportTypeFreeGymnastics | 0x0209 | Free Gymnastics | 自由体操 |
TSSportTypeBarbell | 0x020D | Barbell | 杠铃 |
TSSportTypeWeightlifting | 0x0211 | Weightlifting | 举重 |
TSSportTypeDeadlift | 0x0215 | Deadlift | 硬拉 |
TSSportTypeBurpee | 0x0219 | Burpee | 波比跳 |
TSSportTypeJumpingJack | 0x021D | Jumping Jack | 开合跳 |
TSSportTypeUpperBodyTraining | 0x0221 | Upper Body Training | 上肢训练 |
TSSportTypeLowerBodyTraining | 0x0225 | Lower Body Training | 下肢训练 |
TSSportTypeBackTraining | 0x0229 | Back Training | 背部训练 |
TSSportTypeBeachBuggy | 0x022D | Beach Buggy | 沙滩车 |
TSSportTypeParagliding | 0x0231 | Paragliding | 滑翔伞 |
TSSportTypeFlyAKite | 0x0235 | Fly a Kite | 放风筝 |
TSSportTypeTugOfWar | 0x0239 | Tug of War | 拔河 |
TSSportTypeTriathlon | 0x023D | Triathlon | 铁人三项 |
TSSportTypeSnowmobile | 0x0241 | Snowmobile | 雪地摩托 |
TSSportTypeSnowCar | 0x0245 | Snow Car | 雪车 |
TSSportTypeSled | 0x0249 | Sled | 雪橇 |
TSSportTypeSkiBoard | 0x024D | Ski Board | 滑雪板 |
TSSportTypeCrossCountrySkiing | 0x0251 | Cross Country Skiing | 越野滑雪 |
TSSportTypeIndoorSkating | 0x0255 | Indoor Skating | 室内滑冰 |
TSSportTypeKabaddi | 0x0259 | Kabaddi | 卡巴迪 |
TSSportTypeMuayThai | 0x025D | Muay Thai | 泰拳 |
TSSportTypeKickboxing | 0x0261 | Kickboxing | 踢拳 |
TSSportTypeRacing | 0x0265 | Racing | 赛车 |
TSSportTypeIndoorFitness | 0x0269 | Indoor Fitness | 室内健身 |
TSSportTypeOutdoorSoccer | 0x026D | Outdoor Soccer | 户外足球 |
TSSportTypeBellyDance | 0x0271 | Belly Dance | 肚皮舞 |
TSSportTypeSquareDance | 0x0275 | Square Dance | 广场舞 |
TSSportDisplayMetric
Display metrics that can be shown during sport activities.
| Value | Name (English) | Name (Chinese) |
|---|---|---|
TSSportDisplayMetricDuration | Duration | 持续时间 |
TSSportDisplayMetricHeartRate | Heart Rate | 心率 |
TSSportDisplayMetricSteps | Steps | 步数 |
TSSportDisplayMetricDistance | Distance | 距离 |
TSSportDisplayMetricCalories | Calories | 卡路里 |
TSSportDisplayMetricAvgSpeed | Average Speed | 平均速度 |
TSSportDisplayMetricAvgPace | Average Pace | 平均配速 |
TSSportDisplayMetricAvgCadence | Average Cadence | 平均步频 |
TSSportDisplayMetricAvgStride | Average Stride | 平均步幅 |
TSSportDisplayMetricTotalAscent | Total Ascent | 累计上升 |
TSSportDisplayMetricTotalDescent | Total Descent | 累计下降 |
TSSportDisplayMetricSwimLaps | Swim Laps | 游泳趟数 |
TSSportDisplayMetricSwimStrokes | Swim Strokes | 游泳划水次数 |
TSSportDisplayMetricSwimStyle | Swim Style | 泳姿 |
TSSportDisplayMetricSwimStrokeRate | Swim Stroke Rate | 游泳划水频率 |
TSSportDisplayMetricSwimEfficiency | Swim Efficiency (SWOLF) | 游泳效率(SWOLF) |
TSSportDisplayMetricTriggerCount | Trigger Count | 触发次数 |
TSSportDisplayMetricTriggerRate | Trigger Rate | 触发频率 |
TSSportDisplayMetricInterruptionCount | Interruption Count | 中断次数 |
TSSportDisplayMetricContinuousCount | Continuous Count | 连续次数 |
Callback Types
Sync Completion Handler
void (^)(NSArray<TSSportModel *> *_Nullable sports, NSError *_Nullable error)
Completion block called when sport history synchronization completes.
| Parameter | Type | Description |
|---|---|---|
sports | NSArray<TSSportModel *> * | Array of synchronized sport activities (nil on error) |
error | NSError * | Error object if synchronization failed (nil on success) |
API Reference
Synchronize sport history data within time range
Retrieve all sport activities that occurred between specified start and end times.
- (void)syncHistoryDataFormStartTime:(NSTimeInterval)startTime
endTime:(NSTimeInterval)endTime
completion:(nonnull void (^)(NSArray<TSSportModel *> *_Nullable sports, NSError *_Nullable error))completion;
| Parameter | Type | Description |
|---|---|---|
startTime | NSTimeInterval | Unix timestamp (seconds) for sync start |
endTime | NSTimeInterval | Unix timestamp (seconds) for sync end |
completion | void (^)(NSArray<TSSportModel *> *, NSError *) | Block called with results or error |
Code Example:
// Get sport data for the past 7 days
NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
NSTimeInterval sevenDaysAgo = now - (7 * 24 * 60 * 60);
id<TSSportInterface> sportInterface = (id<TSSportInterface>)kit;
[sportInterface syncHistoryDataFormStartTime:sevenDaysAgo
endTime:now
completion:^(NSArray<TSSportModel *> *sports, NSError *error) {
if (error) {
TSLog(@"Sport sync failed: %@", error.localizedDescription);
return;
}
TSLog(@"Synced %lu sport activities", (unsigned long)sports.count);
for (TSSportModel *sport in sports) {
TSSportSummaryModel *summary = sport.summary;
TSLog(@"Activity: %ld, Type: %ld, Duration: %.0f seconds, Distance: %u meters",
summary.sportID, (long)summary.type, summary.duration, summary.distance);
TSLog(@"Max HR: %u bpm, Avg HR: %u bpm, Calories: %u",
summary.maxHrValue, summary.avgHrValue, summary.calorie);
TSLog(@"Heart rate zones - Warm: %u%%, Fat Burn: %u%%, Aerobic: %u%%, Anaerobic: %u%%, Extreme: %u%%",
summary.warmHrRatio, summary.fatBurnHrRatio, summary.aerobicHrRatio,
summary.anaerobicHrRatio, summary.extremeHrRatio);
}
}];
Synchronize sport history data from start time until now
Retrieve all sport activities from a specified start time to the present moment.
- (void)syncHistoryDataFormStartTime:(NSTimeInterval)startTime
completion:(nonnull void (^)(NSArray<TSSportModel *> *_Nullable sports, NSError *_Nullable error))completion;
| Parameter | Type | Description |
|---|---|---|
startTime | NSTimeInterval | Unix timestamp (seconds) for |