BloodPressure Module
This module provides comprehensive blood pressure measurement and monitoring capabilities. It enables manual blood pressure measurements initiated by users, automatic periodic monitoring on the device, real-time data synchronization, and historical data retrieval. Blood pressure data includes systolic (high pressure) and diastolic (low pressure) values, which are critical cardiovascular health indicators.
Prerequisites
- The connected wearable device must support blood pressure measurement functionality
- Device must be properly paired and connected before measurement operations
- For automatic monitoring, the device must support automatic monitoring features
- Network connectivity is required for data synchronization operations
- Appropriate user permissions must be granted for health data access
Data Models
TSBPValueItem
Single blood pressure measurement record.
| Property | Type | Description |
|---|---|---|
systolic | UInt16 | Systolic (high) blood pressure value in mmHg |
diastolic | UInt16 | Diastolic (low) blood pressure value in mmHg |
isUserInitiated | BOOL | Indicates whether the measurement was initiated by the user (manual) or by automatic monitoring |
timestamp | NSTimeInterval | Measurement timestamp (inherited from TSHealthValueItem) |
TSBPDailyModel
Daily aggregated blood pressure data for a single day.
| Property | Type | Description |
|---|---|---|
maxSystolicItem | TSBPValueItem * | Blood pressure item with the highest systolic value recorded during the day |
minSystolicItem | TSBPValueItem * | Blood pressure item with the lowest systolic value recorded during the day |
maxDiastolicItem | TSBPValueItem * | Blood pressure item with the highest diastolic value recorded during the day |
minDiastolicItem | TSBPValueItem * | Blood pressure item with the lowest diastolic value recorded during the day |
manualItems | NSArray<TSBPValueItem *> * | Array of user-initiated blood pressure measurements, ordered chronologically |
autoItems | NSArray<TSBPValueItem *> * | Array of automatically monitored blood pressure measurements, ordered chronologically |
dayStartTime | NSTimeInterval | Start timestamp of the day (inherited from TSHealthDailyModel) |
Enumerations
No enumerations are defined for this module.
Callback Types
TSCompletionBlock
typedef void (^TSCompletionBlock)(NSError *_Nullable error);
Completion callback for operations that may succeed or fail.
| Parameter | Type | Description |
|---|---|---|
error | NSError * | Error information if operation failed; nil if successful |
Measurement Start Handler
void (^)(BOOL success, NSError * _Nullable error)
Callback invoked when a blood pressure measurement starts or fails to start.
| Parameter | Type | Description |
|---|---|---|
success | BOOL | YES if measurement started successfully, NO otherwise |
error | NSError * | Error information if failed to start; nil if successful |
Measurement Data Handler
void (^)(TSBPValueItem * _Nullable data, NSError * _Nullable error)
Callback to receive real-time blood pressure measurement data during an active measurement.
| Parameter | Type | Description |
|---|---|---|
data | TSBPValueItem * | Real-time blood pressure measurement data; nil if error occurs |
error | NSError * | Error information if data reception failed; nil if successful |
Measurement End Handler
void (^)(BOOL success, NSError * _Nullable error)
Callback invoked when a blood pressure measurement ends (normally or abnormally).
| Parameter | Type | Description |
|---|---|---|
success | BOOL | YES if measurement ended normally, NO if interrupted |
error | NSError * | Error information if measurement ended abnormally; nil if normal end |
Configuration Fetch Handler
void (^)(TSAutoMonitorBPConfigs * _Nullable configuration, NSError * _Nullable error)
Callback to receive the current automatic monitoring configuration.
| Parameter | Type | Description |
|---|---|---|
configuration | TSAutoMonitorBPConfigs * | Current automatic monitoring configuration; nil if error occurs |
error | NSError * | Error information if fetch failed; nil if successful |
Raw Data Sync Handler
void (^)(NSArray<TSBPValueItem *> * _Nullable bpItems, NSError * _Nullable error)
Callback to receive synchronized raw blood pressure measurement records.
| Parameter | Type | Description |
|---|---|---|
bpItems | NSArray<TSBPValueItem *> * | Array of raw blood pressure measurement items; nil if error occurs |
error | NSError * | Error information if sync failed; nil if successful |
Daily Data Sync Handler
void (^)(NSArray<TSBPDailyModel *> * _Nullable dailyModels, NSError * _Nullable error)
Callback to receive synchronized daily aggregated blood pressure data.
| Parameter | Type | Description |
|---|---|---|
dailyModels | NSArray<TSBPDailyModel *> * | Array of daily blood pressure models; nil if error occurs |
error | NSError * | Error information if sync failed; nil if successful |
API Reference
Check if device supports manual blood pressure measurement
Query whether the connected device supports user-initiated blood pressure measurements.
- (BOOL)isSupportActivityMeasureByUser;
Returns: BOOL – YES if the device supports manual blood pressure measurement, NO otherwise.
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
if ([bpInterface isSupportActivityMeasureByUser]) {
TSLog(@"Device supports manual blood pressure measurement");
} else {
TSLog(@"Device does not support manual blood pressure measurement");
}
Start blood pressure measurement
Initiate a blood pressure measurement with specified parameters and receive callbacks for start, real-time data, and completion events.
- (void)startMeasureWithParam:(TSActivityMeasureParam *_Nonnull)measureParam
startHandler:(void(^_Nullable)(BOOL success, NSError * _Nullable error))startHandler
dataHandler:(void(^_Nullable)(TSBPValueItem * _Nullable data, NSError * _Nullable error))dataHandler
endHandler:(void(^_Nullable)(BOOL success, NSError * _Nullable error))endHandler;
| Parameter | Type | Description |
|---|---|---|
measureParam | TSActivityMeasureParam * | Parameters for the measurement activity including duration and other settings |
startHandler | void (^)(BOOL success, NSError *) | Block called when measurement starts or fails; receives success status and error if applicable |
dataHandler | void (^)(TSBPValueItem *, NSError *) | Block to receive real-time measurement data; called repeatedly during measurement or with error |
endHandler | void (^)(BOOL success, NSError *) | Block called when measurement ends normally or is interrupted; receives completion status and error if applicable |
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
TSActivityMeasureParam *param = [[TSActivityMeasureParam alloc] init];
param.duration = 60; // 60 seconds
[bpInterface startMeasureWithParam:param
startHandler:^(BOOL success, NSError * _Nullable error) {
if (success) {
TSLog(@"Blood pressure measurement started");
} else {
TSLog(@"Failed to start measurement: %@", error.localizedDescription);
}
} dataHandler:^(TSBPValueItem * _Nullable data, NSError * _Nullable error) {
if (data) {
TSLog(@"Real-time BP: Systolic=%u, Diastolic=%u",
data.systolic, data.diastolic);
} else if (error) {
TSLog(@"Error receiving data: %@", error.localizedDescription);
}
} endHandler:^(BOOL success, NSError * _Nullable error) {
if (success) {
TSLog(@"Blood pressure measurement completed normally");
} else {
TSLog(@"Measurement interrupted or failed: %@",
error ? error.localizedDescription : @"unknown error");
}
}];
Stop blood pressure measurement
Terminate the currently active blood pressure measurement.
- (void)stopMeasureCompletion:(nonnull TSCompletionBlock)completion;
| Parameter | Type | Description |
|---|---|---|
completion | void (^)(NSError *) | Completion block called when the measurement stops or fails to stop; receives error if applicable |
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
[bpInterface stopMeasureCompletion:^(NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to stop measurement: %@", error.localizedDescription);
} else {
TSLog(@"Blood pressure measurement stopped successfully");
}
}];
Check if device supports automatic blood pressure monitoring
Query whether the connected device supports automatic periodic blood pressure monitoring.
- (BOOL)isSupportAutomaticMonitoring;
Returns: BOOL – YES if the device supports automatic blood pressure monitoring, NO otherwise.
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
if ([bpInterface isSupportAutomaticMonitoring]) {
TSLog(@"Device supports automatic blood pressure monitoring");
} else {
TSLog(@"Device does not support automatic blood pressure monitoring");
}
Check if device supports configuring monitor time range
Query whether the device allows configuration of the start and end times for automatic blood pressure monitoring.
- (BOOL)isSupportMonitorScheduleTime;
Returns: BOOL – YES if the device supports configuring start/end times for monitoring, NO otherwise.
Discussion: When this method returns YES, the startTime and endTime fields of TSMonitorSchedule are effective.
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
if ([bpInterface isSupportMonitorScheduleTime]) {
TSLog(@"Device supports configuring monitor time range");
} else {
TSLog(@"Device does not support configuring monitor time range");
}
Check if device supports configuring monitor interval
Query whether the device allows configuration of the monitoring interval for automatic blood pressure checks.
- (BOOL)isSupportMonitorScheduleInterval;
Returns: BOOL – YES if the device supports configuring monitoring interval, NO otherwise.
Discussion: When this method returns YES, the interval field of TSMonitorSchedule is effective.
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
if ([bpInterface isSupportMonitorScheduleInterval]) {
TSLog(@"Device supports configuring monitor interval");
} else {
TSLog(@"Device does not support configuring monitor interval");
}
Configure automatic blood pressure monitoring
Push automatic blood pressure monitoring configuration to the device.
- (void)pushAutoMonitorConfigs:(TSAutoMonitorBPConfigs *_Nonnull)configuration
completion:(nonnull TSCompletionBlock)completion;
| Parameter | Type | Description |
|---|---|---|
configuration | TSAutoMonitorBPConfigs * | Configuration parameters for automatic monitoring including schedule and other settings |
completion | void (^)(NSError *) | Completion block called when configuration is applied or fails; receives error if applicable |
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
TSAutoMonitorBPConfigs *config = [[TSAutoMonitorBPConfigs alloc] init];
// Configure monitoring schedule
config.enabled = YES;
// Set other configuration properties as needed
[bpInterface pushAutoMonitorConfigs:config
completion:^(NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to configure automatic monitoring: %@",
error.localizedDescription);
} else {
TSLog(@"Automatic blood pressure monitoring configured successfully");
}
}];
Get current automatic blood pressure monitoring configuration
Retrieve the current automatic monitoring configuration from the device.
- (void)fetchAutoMonitorConfigsWithCompletion:(nonnull void (^)(TSAutoMonitorBPConfigs *_Nullable configuration, NSError *_Nullable error))completion;
| Parameter | Type | Description |
|---|---|---|
completion | void (^)(TSAutoMonitorBPConfigs *, NSError *) | Completion block with the current configuration or error; configuration is nil if error occurs |
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
[bpInterface fetchAutoMonitorConfigsWithCompletion:^(TSAutoMonitorBPConfigs * _Nullable configuration, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to fetch configuration: %@", error.localizedDescription);
} else if (configuration) {
TSLog(@"Current auto-monitor config: enabled=%@",
configuration.enabled ? @"YES" : @"NO");
}
}];
Synchronize raw blood pressure data within a time range
Retrieve all raw blood pressure measurements recorded between two specific timestamps.
- (void)syncRawDataFromStartTime:(NSTimeInterval)startTime
endTime:(NSTimeInterval)endTime
completion:(nonnull void (^)(NSArray<TSBPValueItem *> *_Nullable bpItems, NSError *_Nullable error))completion;
| Parameter | Type | Description |
|---|---|---|
startTime | NSTimeInterval | Start time for data synchronization (Unix timestamp in seconds since 1970-01-01 00:00:00 UTC) |
endTime | NSTimeInterval | End time for data synchronization (Unix timestamp in seconds since 1970-01-01 00:00:00 UTC); must be later than startTime |
completion | void (^)(NSArray<TSBPValueItem *> *, NSError *) | Completion block with array of synchronized raw BP items or error; items are nil if error occurs |
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
// Sync data for the last 7 days
NSTimeInterval endTime = [[NSDate date] timeIntervalSince1970];
NSTimeInterval startTime = endTime - (7 * 24 * 3600);
[bpInterface syncRawDataFromStartTime:startTime
endTime:endTime
completion:^(NSArray<TSBPValueItem *> * _Nullable bpItems, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to sync raw BP data: %@", error.localizedDescription);
} else {
TSLog(@"Synced %lu raw BP measurements", (unsigned long)bpItems.count);
for (TSBPValueItem *item in bpItems) {
TSLog(@"BP: %u/%u at %@", item.systolic, item.diastolic,
[NSDate dateWithTimeIntervalSince1970:item.timestamp]);
}
}
}];
Synchronize raw blood pressure data from start time to now
Retrieve all raw blood pressure measurements from a specified start time until the current moment.
- (void)syncRawDataFromStartTime:(NSTimeInterval)startTime
completion:(nonnull void (^)(NSArray<TSBPValueItem *> *_Nullable bpItems, NSError *_Nullable error))completion;
| Parameter | Type | Description |
|---|---|---|
startTime | NSTimeInterval | Start time for data synchronization (Unix timestamp in seconds since 1970-01-01 00:00:00 UTC) |
completion | void (^)(NSArray<TSBPValueItem *> *, NSError *) | Completion block with array of synchronized raw BP items or error; items are nil if error occurs |
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
// Sync all BP data since January 1, 2024
NSDateComponents *components = [[NSDateComponents alloc] init];
components.year = 2024;
components.month = 1;
components.day = 1;
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *startDate = [calendar dateFromComponents:components];
[bpInterface syncRawDataFromStartTime:[startDate timeIntervalSince1970]
completion:^(NSArray<TSBPValueItem *> * _Nullable bpItems, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to sync BP data: %@", error.localizedDescription);
} else {
TSLog(@"Successfully synced %lu BP records", (unsigned long)bpItems.count);
}
}];
Synchronize daily blood pressure data within a time range
Retrieve daily aggregated blood pressure statistics for the specified date range. Time parameters are automatically normalized to day boundaries (00:00:00 to 23:59:59).
- (void)syncDailyDataFromStartTime:(NSTimeInterval)startTime
endTime:(NSTimeInterval)endTime
completion:(nonnull void (^)(NSArray<TSBPDailyModel *> *_Nullable dailyModels, NSError *_Nullable error))completion;
| Parameter | Type | Description |
|---|---|---|
startTime | NSTimeInterval | Start time normalized to 00:00:00 of the specified date (Unix timestamp); must be earlier than endTime |
endTime | NSTimeInterval | End time normalized to 23:59:59 of the specified date (Unix timestamp); must be later than startTime and not in the future |
completion | void (^)(NSArray<TSBPDailyModel *> *, NSError *) | Completion block with array of daily BP models or error; each model represents one day; models are nil if error occurs |
Discussion: This method synchronizes daily aggregated blood pressure data within the given time range. Time parameters are automatically normalized to day boundaries. Data is returned in ascending chronological order with each element representing one day's aggregated data.
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
// Sync daily data for the last 30 days
NSDate *endDate = [NSDate date];
NSDate *startDate = [endDate dateByAddingTimeInterval:-(30 * 24 * 3600)];
[bpInterface syncDailyDataFromStartTime:[startDate timeIntervalSince1970]
endTime:[endDate timeIntervalSince1970]
completion:^(NSArray<TSBPDailyModel *> * _Nullable dailyModels, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to sync daily BP data: %@", error.localizedDescription);
} else {
TSLog(@"Retrieved daily BP data for %lu days", (unsigned long)dailyModels.count);
for (TSBPDailyModel *dailyModel in dailyModels) {
TSLog(@"Date: %@, Max: %u/%u, Min: %u/%u, Measurements: %lu",
[NSDate dateWithTimeIntervalSince1970:dailyModel.dayStartTime],
[dailyModel maxSystolic], [dailyModel maxDiastolic],
[dailyModel minSystolic], [dailyModel minDiastolic],
(unsigned long)dailyModel.allMeasuredItems.count);
}
}
}];
Synchronize daily blood pressure data from start time to now
Retrieve daily aggregated blood pressure statistics from a specified start date until the current date. Start time is automatically normalized to 00:00:00 of the specified day.
- (void)syncDailyDataFromStartTime:(NSTimeInterval)startTime
completion:(nonnull void (^)(NSArray<TSBPDailyModel *> *_Nullable dailyModels, NSError *_Nullable error))completion;
| Parameter | Type | Description |
|---|---|---|
startTime | NSTimeInterval | Start time normalized to 00:00:00 of the specified date (Unix timestamp); data syncs from this time to current time |
completion | void (^)(NSArray<TSBPDailyModel *> *, NSError *) | Completion block with array of daily BP models or error; each model represents one day; models are nil if error occurs |
Discussion: This method is a convenience wrapper that automatically sets the end time to the current time. Start time is normalized to 00:00:00 of the specified day. Data is returned in ascending chronological order with each element representing one day's aggregated data.
Code Example:
id<TSBloodPressureInterface> bpInterface = /* obtained from device */;
// Sync daily BP data from January 1, 2024 to today
NSDateComponents *components = [[NSDateComponents alloc] init];
components.year = 2024;
components.month = 1;
components.day = 1;
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *startDate = [calendar dateFromComponents:components];
[bpInterface syncDailyDataFromStartTime:[startDate timeIntervalSince1970]
completion:^(NSArray<TSBPDailyModel *> * _Nullable dailyModels, NSError * _Nullable error) {
if (error) {
TSLog(@"Failed to sync daily BP data: %@", error.localizedDescription);
} else {
TSLog(@"Successfully retrieved %lu days of BP data", (unsigned long)dailyModels.count);
// Access specific daily data
if (dailyModels.count > 0) {
TSBPDailyModel *todayData = dailyModels.lastObject;
TSLog(@"Today's BP - Max: %u/%u, Min: %u/%u",
[todayData maxSystolic], [todayData maxDiastolic],
[todayData minSystolic], [todayData minDiastolic]);
TSLog(@"Manual measurements: %lu, Auto measurements: %lu",
(unsigned long)todayData.manualItems.count,
(unsigned long)todayData.autoItems.count);
}
}
}];
Important Notes
-
**Device Capability
Verification**: Always check device capabilities usingisSupportActivityMeasureByUser,isSupportAutomaticMonitoring,isSupportMonitorScheduleTime, andisSupportMonitorScheduleIntervalbefore attempting related operations. -
**Measurement Handler
Lifecycle**: All three handlers (start, data, end) are required for comprehensive measurement control. The data handler may be called multiple times during an active measurement to provide real-time updates. -
**Time Range
Parameters**: For data synchronization methods, always provide valid Unix timestamps (seconds since 1970-01-01 00:00:00 UTC). The SDK automatically normalizes daily data time ranges to day boundaries. -
**Automatic Monitoring
Configuration**: Device support for monitoring intervals and time ranges varies by device model. CheckisSupportMonitorScheduleTimeandisSupportMonitorScheduleIntervalbefore using those fields in configuration. -
**Data
Aggregation**: Daily data models automatically aggregate raw measurements into min/max values for both systolic and diastolic pressures, plus separate lists for manual and automatic measurements. -
**Completion Handler
Threading**: All completion handlers are invoked on the main thread, making it safe to update UI elements directly in the callbacks. -
**Error
Handling**: Always check the error parameter in completion handlers. A non-nil error indicates operation failure, and data should not be relied upon when errors are present. -
**Measurement
Duration**: TheTSActivityMeasureParampassed tostartMeasureWithParam:should be configured appropriately for the device, typically 30-60 seconds for blood pressure measurements. -
**User-Initiated vs
Automatic**: Use theisUserInitiatedproperty ofTSBPValueItemto distinguish between user-initiated manual measurements and device automatic monitoring results. -
**Data
Consistency**: Daily models organize measurements chronologically and maintain separate extrema tracking for systolic and diastolic pressures to provide comprehensive health insights.