Health Data Overview (TSHealthBase)
This module provides comprehensive interfaces for managing active health measurements and automatic health monitoring. It enables applications to perform real-time health measurements (heart rate, blood pressure, blood oxygen, stress, temperature, ECG) and configure automatic monitoring schedules with customizable alert thresholds.
Prerequisites
- Device must be connected and authenticated before starting any measurement or configuration operation
- Check device capabilities to ensure it supports the desired measurement type
- Sufficient device battery level for extended measurement sessions
- Valid measurement parameters must be provided before initiating measurements
Data Models
TSActivityMeasureParam
Active measurement parameters model for controlling health measurement sessions.
| Property | Type | Description |
|---|---|---|
measureType | TSActiveMeasureType | Type of measurement to perform (heart rate, blood pressure, blood oxygen, stress, temperature, or ECG). Only one type can be selected at a time. |
interval | UInt8 | Sampling interval in seconds between consecutive measurements. Affects measurement frequency and data granularity. |
maxMeasureDuration | UInt8 | Maximum measurement duration in seconds. Measurement stops automatically after this duration. Default is 60 seconds. Set to 0 for continuous measurement until manual stop. Minimum valid value is 15 seconds. |
TSAutoMonitorConfigs
Configuration for automatic health monitoring with schedule and alert thresholds.
| Property | Type | Description |
|---|---|---|
schedule | TSMonitorSchedule * | Monitor schedule including enable switch, start/end times in minutes from midnight, and interval between measurements. |
alert | TSMonitorAlert * | Threshold-based alert policy. Unit depends on monitor type (percent for SpO2, bpm for heart rate, mmHg for blood pressure). |
TSAutoMonitorHRConfigs
Heart rate specific automatic monitoring configuration with separate alerts for resting and exercise heart rate.
| Property | Type | Description |
|---|---|---|
schedule | TSMonitorSchedule * | Monitor schedule including enable switch, start/end times in minutes from midnight, and interval. |
restHRAlert | TSMonitorAlert * | Threshold-based alert policy for resting heart rate in bpm (beats per minute). |
exerciseHRAlert | TSMonitorAlert * | Threshold-based alert policy for exercise heart rate in bpm (beats per minute). |
exerciseHRLimitMax | UInt8 | Maximum exercise heart rate for zone calculation. Used to calculate heart rate zones (warm-up, fat burning, aerobic, anaerobic, peak). Recommended range 100-220 bpm, typically calculated as 220 - age. |
TSAutoMonitorBPConfigs
Blood pressure specific automatic monitoring configuration with separate systolic and diastolic thresholds.
| Property | Type | Description |
|---|---|---|
schedule | TSMonitorSchedule * | Monitor schedule including enable switch, start/end times in minutes from midnight, and interval. |
alert | TSMonitorBPAlert * | Blood pressure threshold-based alert policy with separate systolic and diastolic limits in mmHg (millimeters of mercury). |
TSMonitorSchedule
Schedule configuration for automatic monitoring sessions.
| Property | Type | Description |
|---|---|---|
enabled | BOOL | Indicates whether the monitoring is enabled. Access via isEnabled getter. |
startTime | UInt16 | Start time in minutes from midnight (e.g., 480 for 8 AM). Valid range is 0-1440 minutes (0:00-24:00). |
endTime | UInt16 | End time in minutes from midnight (e.g., 1200 for 8 PM). Valid range is 0-1440 minutes (0:00-24:00), must be greater than startTime. |
interval | UInt16 | Interval between monitoring in minutes. Must be a multiple of 5 (5, 10, 15, 20, etc.). |
TSMonitorAlert
Generic alert configuration with upper and lower threshold limits.
| Property | Type | Description |
|---|---|---|
enabled | BOOL | Indicates whether alert checking is enabled. Access via isEnabled getter. |
upperLimit | UInt16 | Upper threshold for alert decision. Unit depends on monitor type (percent for SpO2, bpm for heart rate, mmHg for blood pressure). |
lowerLimit | UInt16 | Lower threshold for alert decision. Unit depends on monitor type (percent for SpO2, bpm for heart rate, mmHg for blood pressure). |
TSMonitorBPAlert
Blood pressure specific alert configuration with separate thresholds for systolic and diastolic pressure.
| Property | Type | Description |
|---|---|---|
enabled | BOOL | Indicates whether blood pressure alert checking is enabled. Access via isEnabled getter. |
systolicUpperLimit | UInt8 | Upper threshold for systolic blood pressure alert in mmHg. |
systolicLowerLimit | UInt8 | Lower threshold for systolic blood pressure alert in mmHg. |
diastolicUpperLimit | UInt8 | Upper threshold for diastolic blood pressure alert in mmHg. |
diastolicLowerLimit | UInt8 | Lower threshold for diastolic blood pressure alert in mmHg. |
TSHealthValueItem
Health value item model representing a single health measurement with timing and value type information.
| Property | Type | Description |
|---|---|---|
startTime | NSTimeInterval | Unix timestamp (in seconds) indicating when this data record started. |
endTime | NSTimeInterval | Unix timestamp (in seconds) indicating when this data record ended. |
duration | double | The total duration of this data record in seconds. Can be calculated as (endTime - startTime). |
valueType | TSItemValueType | Classifies sample as Normal raw point, Daily maximum/minimum, or Resting HR. Normal is a raw time-series sample (auto or manual), Max/Min are daily extrema derived from that day's normal samples, Resting is derived by algorithm. |
TSHealthDailyModel
Health data model for daily health records with start/end times and duration.
| Property | Type | Description |
|---|---|---|
startTime | NSTimeInterval | Unix timestamp (in seconds) indicating when this data record started. |
endTime | NSTimeInterval | Unix timestamp (in seconds) indicating when this data record ended. |
duration | double | The total duration of this data record in seconds. |
Enumerations
TSActiveMeasureType
Types of health measurements that can be selected.
| Value | Name | Description |
|---|---|---|
0 | TSMeasureTypeNone | No measurement selected. |
1 | TSMeasureTypeHeartRate | Real-time heart rate monitoring. |
2 | TSMeasureTypeBloodOxygen | Blood oxygen saturation SpO2 measurement. |
3 | TSMeasureTypeBloodPressure | Systolic and diastolic blood pressure measurement. |
4 | TSMeasureTypeStress | Mental stress level assessment. |
5 | TSMeasureTypeTemperature | Body temperature measurement. |
6 | TSMeasureTypeECG | Electrocardiogram recording. |
TSItemValueType
Heart rate data type classification distinguishing different types of heart rate records.
| Value | Name | Description |
|---|---|---|
0 | TSItemValueTypeNormal | Normal raw point (auto or manual), not a derived statistic. |
1 | TSItemValueTypeMax | Daily maximum derived from normal points of that day. |
2 | TSItemValueTypeMin | Daily minimum derived from normal points of that day. |
3 | TSItemValueTypeResting | Resting heart rate derived by algorithm based on rest/sleep window data. |
TSHealthValueType
Health value type for records stored in health tables.
| Value | Name | Description |
|---|---|---|
0 | TSHealthValueTypeNormal | Normal data record. |
1 | TSHealthValueTypeMax | Maximum value record. |
2 | TSHealthValueTypeMin | Minimum value record. |
3 | TSHealthValueTypeResting | Resting type record (heart rate only). |
Callback Types
TSCompletionBlock
void (^)(NSError * _Nullable)
Completion callback block invoked when an operation completes.
Parameters:
error(NSError * _Nullable): Error information if operation failed,nilif successful.
TSMeasureDataBlock
void (^)(TSHealthValueItem *value)
Callback block that delivers measurement data during a measurement session.
Parameters:
value(TSHealthValueItem *): Health value model containing measurement data with timing information.
Measurement Data Change Callback
void (^)(TSHealthValueItem * _Nullable realtimeData, NSError * _Nullable error)
Callback block invoked when measurement data is received during an active measurement.
Parameters:
realtimeData(TSHealthValueItem * _Nullable): Real-time measurement data from device,nilif error occurs.error(NSError * _Nullable): Error information if data reception fails,nilif successful.
Measurement End Callback
void (^)(BOOL isFinished, NSError * _Nullable error)
Callback block invoked when a measurement session ends.
Parameters:
isFinished(BOOL): Whether the measurement ended normally (YES) or was interrupted (NO).error(NSError * _Nullable): Error information if measurement ended abnormally,nilif normal end.
API Reference
Start health measurement with custom parameters
Initiates a health measurement session based on provided parameters with custom sampling interval and maximum duration.
+ (void)startMeasureWithParam:(TSActivityMeasureParam *)measureParam
completion:(TSCompletionBlock)completion;
Parameters:
| Name | Type | Description |
|---|---|---|
measureParam | TSActivityMeasureParam * | Measurement parameters including type, interval, and duration. |
completion | TSCompletionBlock | Completion callback indicating success or failure of starting measurement. |
Code Example:
TSActivityMeasureParam *param = [[TSActivityMeasureParam alloc] init];
param.measureType = TSMeasureTypeHeartRate;
param.interval = 5; // 5 seconds sampling interval
param.maxMeasureDuration = 60; // 60 seconds maximum duration
[TSActiveMeasureInterface startMeasureWithParam:param completion:^(NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to start measurement: %@", error.localizedDescription);
} else {
TSLog(@"Heart rate measurement started successfully");
}
}];
Stop ongoing health measurement
Stops the currently active health measurement session and terminates all ongoing data collection.
+ (void)stopMeasureWithParam:(TSActivityMeasureParam *)measureParam completion:(TSCompletionBlock)completion;
Parameters:
| Name | Type | Description |
|---|---|---|
measureParam | TSActivityMeasureParam * | Measurement parameters identifying which measurement to stop. |
completion | TSCompletionBlock | Completion callback indicating success or failure of stopping measurement. |
Code Example:
TSActivityMeasureParam *param = [[TSActivityMeasureParam alloc] init];
param.measureType = TSMeasureTypeHeartRate;
[TSActiveMeasureInterface stopMeasureWithParam:param completion:^(NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to stop measurement: %@", error.localizedDescription);
} else {
TSLog(@"Heart rate measurement stopped successfully");
}
}];
Register measurement data change notification
Registers a notification listener for real-time measurement data received during an active measurement session.
+ (void)registerMeasurement:(TSActivityMeasureParam *)param
dataDidChanged:(void(^)(TSHealthValueItem * _Nullable realtimeData, NSError * _Nullable error))dataDidChanged;
Parameters:
| Name | Type | Description |
|---|---|---|
param | TSActivityMeasureParam * | Measurement parameters identifying which measurement type to listen for. |
dataDidChanged | void(^)(TSHealthValueItem * _Nullable, NSError * _Nullable) | Callback block invoked when measurement data is received. realtimeData contains measurement data on success, error contains failure information. |
Code Example:
TSActivityMeasureParam *param = [[TSActivityMeasureParam alloc] init];
param.measureType = TSMeasureTypeHeartRate;
[TSActiveMeasureInterface registerMeasurement:param dataDidChanged:^(TSHealthValueItem * _Nullable realtimeData, NSError * _Nullable error) {
if (error) {
TSLog(@"Data reception error: %@", error.localizedDescription);
} else if (realtimeData) {
TSLog(@"Received heart rate data: value=%@, time=%@", realtimeData.value, @(realtimeData.startTime));
}
}];
Register measurement end notification
Registers a notification listener for measurement session completion events.
+ (void)registerActivityeasureDidFinished:(void(^)(BOOL isFinished, NSError * _Nullable error))didFinished;
Parameters:
| Name | Type | Description |
|---|---|---|
didFinished | void(^)(BOOL, NSError * _Nullable) | Callback block invoked when measurement ends. isFinished indicates normal completion (YES) or interruption (NO). error contains error information if abnormal end. |
Code Example:
[TSActiveMeasureInterface registerActivityeasureDidFinished:^(BOOL isFinished, NSError * _Nullable error) {
if (error) {
TSLog(@"Measurement ended with error: %@", error.localizedDescription);
} else if (isFinished) {
TSLog(@"Measurement completed successfully");
} else {
TSLog(@"Measurement was interrupted");
}
}];
Fetch heart rate auto monitor configurations
Retrieves current heart rate auto monitor configurations from the device including monitoring schedule, heart rate alerts, and maximum heart rate for zone calculation.
- (void)fetchHeartRateAutoMonitorConfigsWithCompletion:(void (^)(TSAutoMonitorHRConfigs *_Nullable configs, NSError *_Nullable error))completion;
Parameters:
| Name | Type | Description |
|---|---|---|
completion | void(^)(TSAutoMonitorHRConfigs * _Nullable, NSError * _Nullable) | Completion block receiving heart rate monitor configs and error. configs contains current configuration on success, error contains failure information. |
Code Example:
[deviceInterface fetchHeartRateAutoMonitorConfigsWithCompletion:^(TSAutoMonitorHRConfigs * _Nullable configs, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to fetch heart rate config: %@", error.localizedDescription);
} else if (configs) {
TSLog(@"Schedule enabled: %@", configs.schedule.isEnabled ? @"YES" : @"NO");
TSLog(@"Start time: %d, End time: %d", configs.schedule.startTime, configs.schedule.endTime);
TSLog(@"Max exercise HR: %d bpm", configs.exerciseHRLimitMax);
}
}];
Push heart rate auto monitor configuration to device
Sends heart rate auto monitor configuration to the device including monitoring schedule and alert thresholds.
- (void)pushHeartRateAutoMonitorConfig:(TSAutoMonitorHRConfigs *)config
completion:(TSCompletionBlock)completion;
Parameters:
| Name | Type | Description |
|---|---|---|
config | TSAutoMonitorHRConfigs * | Heart rate auto monitor configuration to be set on device. |
completion | TSCompletionBlock | Completion callback indicating operation result. |
Code Example:
TSAutoMonitorHRConfigs *config = [[TSAutoMonitorHRConfigs alloc] init];
// Configure schedule
TSMonitorSchedule *schedule = [[TSMonitorSchedule alloc] init];
schedule.enabled = YES;
schedule.startTime = 480; // 8:00 AM
schedule.endTime = 1200; // 8:00 PM
schedule.interval = 30; // 30 minutes
config.schedule = schedule;
// Configure resting heart rate alert
TSMonitorAlert *restAlert = [[TSMonitorAlert alloc] init];
restAlert.enabled = YES;
restAlert.lowerLimit = 40; // Lower limit
restAlert.upperLimit = 100; // Upper limit
config.restHRAlert = restAlert;
// Configure exercise heart rate alert
TSMonitorAlert *exerciseAlert = [[TSMonitorAlert alloc] init];
exerciseAlert.enabled = YES;
exerciseAlert.lowerLimit = 60;
exerciseAlert.upperLimit = 160;
config.exerciseHRAlert = exerciseAlert;
config.exerciseHRLimitMax = 180; // Max HR for zone calculation (220 - 40)
[deviceInterface pushHeartRateAutoMonitorConfig:config completion:^(NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to push heart rate config: %@", error.localizedDescription);
} else {
TSLog(@"Heart rate monitor config pushed successfully");
}
}];
Fetch blood pressure auto monitor configurations
Retrieves current blood pressure auto monitor configurations from the device including monitoring schedule and systolic/diastolic alert thresholds.
- (void)fetchBloodPressureAutoMonitorConfigsWithCompletion:(void (^)(TSAutoMonitorBPConfigs *_Nullable configs, NSError *_Nullable error))completion;
Parameters:
| Name | Type | Description |
|---|---|---|
completion | void(^)(TSAutoMonitorBPConfigs * _Nullable, NSError * _Nullable) | Completion block receiving blood pressure monitor configs and error. configs contains current configuration on success, error contains failure information. |
Code Example:
[deviceInterface fetchBloodPressureAutoMonitorConfigsWithCompletion:^(TSAutoMonitorBPConfigs * _Nullable configs, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to fetch blood pressure config: %@", error.localizedDescription);
} else if (configs) {
TSLog(@"BP monitoring enabled: %@", configs.schedule.isEnabled ? @"YES" : @"NO");
TSLog(@"Systolic alert: %d - %d mmHg", configs.alert.systolicLowerLimit, configs.alert.systolicUpperLimit);
TSLog(@"Diastolic alert: %d - %d mmHg", configs.alert.diastolicLowerLimit, configs.alert.diastolicUpperLimit);
}
}];
Push blood pressure auto monitor configuration to device
Sends blood pressure auto monitor configuration to the device including monitoring schedule and systolic/diastolic alert thresholds.
- (void)pushBloodPressureAutoMonitorConfig:(TSAutoMonitorBPConfigs *)config
completion:(TSCompletionBlock)completion;
Parameters:
| Name | Type | Description |
|---|---|---|
config | TSAutoMonitorBPConfigs * | Blood pressure auto monitor configuration to be set on device. |
completion | TSCompletionBlock | Completion callback indicating operation result. |
Code Example:
TSAutoMonitorBPConfigs *config = [[TSAutoMonitorBPConfigs alloc] init];
// Configure schedule
TSMonitorSchedule *schedule = [[TSMonitorSchedule alloc] init];
schedule.enabled = YES;
schedule.startTime = 420; // 7:00 AM
schedule.endTime = 1260; // 9:00 PM
schedule.interval = 60; // 60 minutes
config.schedule = schedule;
// Configure blood pressure alert thresholds
TSMonitorBPAlert *alert = [[TSMonitorBPAlert alloc] init];
alert.enabled = YES;
alert.systolicUpperLimit = 140; // Systolic upper limit
alert.systolicLowerLimit = 80; // Systolic lower limit
alert.diastolicUpperLimit = 90; // Diastolic upper limit
alert.diastolicLowerLimit = 60; // Diastolic lower limit
config.alert = alert;
[deviceInterface pushBloodPressureAutoMonitorConfig:config completion:^(NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to push blood pressure config: %@", error.localizedDescription);
} else {
TSLog(@"Blood pressure monitor config pushed successfully");
}
}];
Fetch blood oxygen auto monitor configurations
Retrieves current blood oxygen (SpO2) auto monitor configurations from the device including monitoring schedule and alert thresholds.
- (void)fetchBloodOxygenAutoMonitorConfigsWithCompletion:(void (^)(TSAutoMonitorConfigs *_Nullable configs, NSError *_Nullable error))completion;
Parameters:
| Name | Type | Description |
|---|---|---|
completion | void(^)(TSAutoMonitorConfigs * _Nullable, NSError * _Nullable) | Completion block receiving blood oxygen monitor configs and error. configs contains current configuration on success, error contains failure information. |
Code Example:
[deviceInterface fetchBloodOxygenAutoMonitorConfigsWithCompletion:^(TSAutoMonitorConfigs * _Nullable configs, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to fetch blood oxygen config: %@", error.localizedDescription);
} else if (configs) {
TSLog(@"SpO2 monitoring enabled: %@", configs.schedule.isEnabled ? @"YES" : @"NO");
TSLog(@"Alert range: %d%% - %d%%", configs.alert.lowerLimit, configs.alert.upperLimit);
}
}];
Push blood oxygen auto monitor configuration to device
Sends blood oxygen (SpO2) auto monitor configuration to the device including monitoring schedule and alert thresholds.
- (void)pushBloodOxygenAutoMonitorConfig:(TSAutoMonitorConfigs *)config
completion:(TSCompletionBlock)completion;
Parameters:
| Name | Type | Description |
|---|---|---|
config | TSAutoMonitorConfigs * | Blood oxygen auto monitor configuration to be set on device. |
completion | TSCompletionBlock | Completion callback indicating operation result. |
Code Example:
TSAutoMonitorConfigs *config = [[TSAutoMonitorConfigs alloc] init];
// Configure schedule
TSMonitorSchedule *schedule = [[TSMonitorSchedule alloc] init];
schedule.enabled = YES;
schedule.startTime = 0; // 12:00 AM (24-hour monitoring)
schedule.endTime = 1440; // 12:00 AM next day
schedule.interval = 120; // 120 minutes
config.schedule = schedule;
// Configure blood oxygen alert thresholds
TSMonitorAlert *alert = [[TSMonitorAlert alloc] init];
alert.enabled = YES;
alert.lowerLimit = 90; // Lower limit: 90%
alert.upperLimit = 100; // Upper limit: 100%
config.alert = alert;
[deviceInterface pushBloodOxygenAutoMonitorConfig:config completion:^(NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to push blood oxygen config: %@", error.localizedDescription);
} else {
TSLog(@"Blood oxygen monitor config pushed successfully");
}
}];
Fetch stress auto monitor configurations
Retrieves current stress auto monitor configurations from the device including monitoring schedule and stress level alert thresholds.
- (void)fetchStressAutoMonitorConfigsWithCompletion:(void (^)(TSAutoMonitorConfigs *_Nullable configs, NSError *_Nullable error))completion;
Parameters:
| Name | Type | Description |
|---|---|---|
completion | void(^)(TSAutoMonitorConfigs * _Nullable, NSError * _Nullable) | Completion block receiving stress monitor configs and error. configs contains current configuration on success, error contains failure information. |
Code Example:
[deviceInterface fetchStressAutoMonitorConfigsWithCompletion:^(TSAutoMonitorConfigs * _Nullable configs, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to fetch stress config: %@", error.localizedDescription);
} else if (configs) {
TSLog(@"Stress monitoring enabled: %@", configs.schedule.isEnabled ? @"YES" : @"NO");
TSLog(@"Interval: %d minutes", configs.schedule.interval);
}
}];
Push stress auto monitor configuration to device
Sends stress auto monitor configuration to the device including monitoring schedule and stress level alert thresholds.
- (void)pushStressAutoMonitorConfig:(TSAutoMonitorConfigs *)config
completion:(TSCompletionBlock)completion;
Parameters:
| Name | Type | Description |
|---|---|---|
config | TSAutoMonitorConfigs * | Stress auto monitor configuration to be set on device. |
completion | TSCompletionBlock | Completion callback indicating operation result. |
Code Example:
TSAutoMonitorConfigs *config = [[TSAutoMonitorConfigs alloc] init];
// Configure schedule
TSMonitorSchedule *schedule = [[TSMonitorSchedule alloc] init];
schedule.enabled = YES;
schedule.startTime = 480; // 8:00 AM
schedule.endTime = 1200; // 8:00 PM
schedule.interval = 30; // 30 minutes
config.schedule = schedule;
// Configure stress alert thresholds
TSMonitorAlert *alert = [[TSMonitorAlert alloc] init];
alert.enabled = YES;
alert.lowerLimit = 0; // Lower stress level
alert.upperLimit = 75; // High stress alert threshold
config.alert = alert;
[deviceInterface pushStressAutoMonitorConfig:config completion:^(NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to push stress config: %@", error.localizedDescription);
} else {
TSLog(@"Stress monitor config pushed successfully");
}
}];
Fetch temperature auto monitor configurations
Retrieves current temperature auto monitor configurations from the device including monitoring schedule and temperature alert thresholds.
- (void)fetchTemperatureAutoMonitorConfigsWithCompletion:(void (^)(TSAutoMonitorConfigs *_Nullable configs, NSError *_Nullable error))completion;
Parameters:
| Name | Type | Description |
|---|---|---|
completion | void(^)(TSAutoMonitorConfigs * _Nullable, NSError * _Nullable) | Completion block receiving temperature monitor configs and error. configs contains current configuration on success, error contains failure information. |
Code Example:
[deviceInterface fetchTemperatureAutoMonitorConfigsWithCompletion:^(TSAutoMonitorConfigs * _Nullable configs, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to fetch temperature config: %@", error.localizedDescription);
} else if (configs) {
TSLog(@"Temperature monitoring enabled: %@", configs.schedule.isEnabled ? @"YES" : @"NO");
TSLog(@"Alert range: %d°C - %d°C", configs.alert.lowerLimit, configs.alert.upperLimit);
}
}];
Push temperature auto monitor configuration to device
Sends temperature auto monitor configuration to the device including monitoring schedule and temperature alert thresholds.
- (void)pushTemperatureAutoMonitorConfig:(TSAutoMonitorConfigs *)config
completion:(TSCompletionBlock)completion;
Parameters:
| Name | Type | Description |
|---|---|---|
config | TSAutoMonitorConfigs * | Temperature auto monitor configuration to be set on device. |
completion | TSCompletionBlock | Completion callback indicating operation result. |
Code Example:
TSAutoMonitorConfigs *config = [[TSAutoMonitorConfigs alloc] init];
// Configure schedule
TSMonitorSchedule *schedule = [[TSMonitorSchedule alloc] init];
schedule.enabled = YES;
schedule.startTime = 360; // 6:00 AM
schedule.endTime = 1260; // 9:00 PM
schedule.interval = 60; // 60 minutes
config.schedule = schedule;
// Configure temperature alert thresholds
TSMonitorAlert *alert = [[TSMonitorAlert alloc] init];
alert.enabled = YES;
alert.lowerLimit = 35; // Lower limit: 35°C (Celsius)
alert.upperLimit = 38; // Upper limit: 38°C (fever threshold)
config.alert = alert;
[deviceInterface pushTemperatureAutoMonitorConfig:config completion:^(NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to push temperature config: %@", error.localizedDescription);
} else {
TSLog(@"Temperature monitor config pushed successfully");
}
}];
Important Notes
-
**Single Measurement Type at a
Time**: Only one measurement type can be active simultaneously. Starting a new measurement will stop any previously active measurement. -
**Register Before
Starting**: It is recommended to register measurement data and end notification observers before starting a measurement to ensure all callbacks are properly captured. -
**Thread
Safety**: All completion callbacks and observer blocks are called on the main thread. Long-running operations should be performed asynchronously. -
**Device Capability
Check**: Not all measurement types are supported by all devices. Always verify device capabilities before attempting to start a specific measurement type. -
**Schedule Time
Format**: Monitor schedule times are specified in minutes from midnight (0:00). For example, 480 represents 8:00 AM and 1200 represents 8:00 PM. -
**Interval
Alignment**: Monitor schedule intervals must be multiples of 5 minutes (5, 10, 15, 20, 25, 30, etc.). -
**Alert Unit
Consistency**: Unit specifications vary by measurement type - bpm for heart rate, percent (%) for blood oxygen and stress, mmHg for blood pressure, and Celsius (°C) for temperature. -
**Configuration
Persistence**: Device auto monitor configurations are persistent. Changes pushed to the device remain effective until explicitly modified. -
**Heart Rate
Zones**: TheexerciseHRLimitMaxin heart rate monitoring is used to calculate heart rate zones. Typically calculated as 220 minus the user's age for more accurate zone distribution. -
**Error
Handling**: Always check for errors in completion callbacks. Network issues, device disconnection, or invalid parameters may result in errors that should be handled gracefully.