9. Health Settings

Manage device settings functions, specific settings include: sensor settings, sedentary reminders, continuous heart rate measurement, exercise heart rate reminders, sleep detection, fall detection, wrist lifting detection, personal information, Bluetooth disconnection reminders

9.1. Read Setting Status

//WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
WatchManager watchManager = WatchManager.getInstance();
//Initialize health function implementation
HealthOpImpl healthOp = new HealthOpImpl(watchManager);
//Register RCSP event listener
healthOp.getRcspOp().registerOnRcspEventListener(new OnRcspEventListener() {
    @Override
    public void onHealthSettingChange(BluetoothDevice device, HealthSettingInfo healthSettingInfo) {
        //Health setting information will be called back here
        int funcFlag = healthSettingInfo.getFuncFlag(); //Current function flag
        switch (funcFlag){
            case AttrAndFunCode.HEALTH_SETTING_TYPE_SENSOR://Sensor setting switch
                SensorInfo sensorInfo = healthSettingInfo.getSensorInfo();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_SEDENTARY_REMINDER://Sedentary reminder
                SedentaryReminder sedentaryReminder = healthSettingInfo.getSedentaryReminder();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_HEART_RATE_MEASURE://Continuous heart rate measurement
                HeartRateMeasure heartRateMeasure = healthSettingInfo.getHeartRateMeasure();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_EXERCISE_HEART_RATE_REMINDER: //Exercise heart rate measurement
                ExerciseHeartRateReminder exerciseHeartRateReminder = healthSettingInfo.getExerciseHeartRateReminder();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_AUTOMATIC_PRESSURE_DETECTION://Automatic pressure detection
                AutomaticPressureDetection automaticPressureDetection = healthSettingInfo.getAutomaticPressureDetection();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_SLEEP_DETECTION: //Sleep detection
                SleepDetection sleepDetection = healthSettingInfo.getSleepDetection();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_FALL_DETECTION: //Fall detection
                FallDetection fallDetection = healthSettingInfo.getFallDetection();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_LIFT_WRIST_DETECTION: //Wrist lifting detection
                LiftWristDetection liftWristDetection = healthSettingInfo.getLiftWristDetection();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_USER_INFO: //Personal information
                UserInfo userInfo = healthSettingInfo.getUserInfo();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_DISCONNECT_REMINDER: //Bluetooth disconnection reminder
                DisconnectReminder disconnectReminder = healthSettingInfo.getDisconnectReminder();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_BLOOD_OXYGEN_MEASUREMENT_ALERT:  //Blood oxygen measurement reminder
                BloodOxygenMeasurementAlert bloodOxygenMeasurementAlert = healthSettingInfo.getBloodOxygenMeasurementAlert();
                break;
            case AttrAndFunCode.HEALTH_SETTING_TYPE_EMERGENCY_CONTACT: //Emergency contact
                EmergencyContact emergencyContact = healthSettingInfo.getEmergencyContact();
                break;
        }
    }
});
// mask Set function corresponding mask
// 1. Get all settings
//int mask = 0xffffffff;

// 2. Get partial settings Type value is: AttrAndFunCode.HEALTH_SETTING_TYPE_XXX, XXX is the corresponding type, such as getting sensors and sleep detection,
//Query sensor settings and sleep detection settings
//3. Different functions correspond to different Bit positions, corresponding Bit set to 1, indicating query this function
int mask = 0x01 << AttrAndFunCode.HEALTH_SETTING_TYPE_SENSOR
            | 0x01 << AttrAndFunCode.HEALTH_SETTING_TYPE_SLEEP_DETECTION;
//Execute to read health setting information and wait for result callback
healthOp.readHealthSettings(healthOp.getConnectedDevice(), mask, new OnOperationCallback<Boolean>() {
    @Override
    public void onSuccess(Boolean result) {
        //Success callback
        //Results will be called back in OnRcspEventListener#onHealthSettingChange
    }

    @Override
    public void onFailed(BaseError error) {
        //Failure callback
        //error - Error information
    }
});
//Get cached setting status, using cached status requires active acquisition of status first, to avoid status inconsistency, sdk does not automatically acquire device setting status
HealthSettingInfo healthSettingInfo = healthOp.getRcspOp().getDeviceInfo().getHealthSettingInfo();

9.2. Modify Setting Status

//WatchManager is a subclass of WatchOpImpl, must configure sdk in 1.3
WatchManager watchManager = WatchManager.getInstance();
//Initialize health function implementation
HealthOpImpl healthOp = new HealthOpImpl(watchManager);
//Get cached setting status, using cached status requires active acquisition of status first, to avoid status inconsistency, sdk does not automatically acquire device setting status
HealthSettingInfo healthSettingInfo = watchManager.getDeviceInfo().getHealthSettingInfo();
//Example: Modify Bluetooth disconnection reminder setting status
final DisconnectReminder disconnectReminder = healthSettingInfo.getDisconnectReminder();
//Perform modification operation
disconnectReminder.setEnable(false);
//Execute configuration health setting information function and wait for result callback
healthOp.configHealthSettings(healthOp.getConnectedDevice(), disconnectReminder, new OnOperationCallback<Boolean>() {
    @Override
    public void onSuccess(Boolean result) {
        //Success callback
        //After successful modification, you can re-read health setting information
        //int mask = 1 << disconnectReminder.toAttr().getType();
        //healthOp.readHealthSettings(healthOp.getConnectedDevice(), mask, null);
    }

    @Override
    public void onFailed(BaseError error) {
        //Failure callback
        //error - Error information
    }
});

9.3. Setting Item Description

Setting

Identifier

Data Model

Configurable Items

Sensor Function

0x01

SensorInfo

Pedometer sensor, heart rate sensor, blood oxygen sensor, altitude barometer sensor
Get sensor instance through SensorInfo’s getXXX() method
Switch state enable: false: off, true: on
Record switch state recordEnable: false: off, true: on

Sedentary Reminder

0x02

SedentaryReminder

Switch state enable: false: off, true: on
Reminder mode mode: 0x00: screen on, 0x01: vibration
Lunch break freeLunchBreak: off/on (lunch break time is 12:00-14:00)
Start time: startHour, startMin
End time: endHour, endMin

Continuous Heart Rate Measurement

0x03

HeartRateMeasure

Switch state enable: false: off, true: on
Reminder mode mode: 0x00: smart, 0x01: real-time

Exercise Heart Rate Reminder

0x04

ExerciseHeartRateReminder

Switch state enable: false: off, true: on
Upper heart rate max: (0-255)
Heart rate zone division spaceMode: 0x00: maximum heart rate percentage, 0x01: stored heart rate percentage

Automatic Pressure Detection

0x05

AutomaticPressureDetection

Switch state enable: false: off, true: on
Mode mode: 0: relax, 1: normal, 2: moderate, 3: high

Sleep Detection

0x06

SleepDetection

Status status: 0x00: off, 0x01: all-day on, 0x02 custom time period
Start time: startHour, startMin
End time: endHour, endMin

Fall Detection

0x07

FallDetection

Switch state enable: false: off, true: on
Reminder mode mode: 0x00: screen on, 0x01: vibration, 0x02: phone call
Phone number: mobile

Wrist Lifting Detection

0x08

LiftWristDetection

Status status: 0x00: off, 0x01: all-day on, 0x02 custom time period
Reminder mode mode: 0x00: screen on, 0x01: vibration
Start time: startHour, startMin
End time: endHour, endMin

Personal Information

0x09

UserInfo

Height: height, unit: cm, rounded
Weight: weight, unit: kg, rounded
Birth year: birthYear
Birth month: birthMonth
Birth day: birthDay
Gender sex: 0x00: female 0x01: male

Bluetooth Disconnection Reminder

0x0A

DisconnectReminder

Status status: 0x00: off, 0x01: on
Reminder mode mode: 0x00: screen on, 0x01: vibration

Blood Oxygen Measurement Reminder

0x0B

BloodOxygenMeasurementAlert

Status status: 0x00: off, 0x01: on
Mode mode: 0: smart mode 1: timer mode
Blood oxygen lower limit value limitingValue: 0-100

Emergency Contact

0x0C

EmergencyContact

Phone number length phoneLen
Phone number number

Reference Constants

public class AttrAndFunCode {
    ...
    //Health device settings
    public final static int HEALTH_SETTING_TYPE_SENSOR = 0x01;//Sensor function
    public final static int HEALTH_SETTING_TYPE_SEDENTARY_REMINDER = 0x02;//Sedentary reminder
    public final static int HEALTH_SETTING_TYPE_HEART_RATE_MEASURE = 0x03;//Continuous heart rate measurement
    public final static int HEALTH_SETTING_TYPE_EXERCISE_HEART_RATE_REMINDER = 0x04;//Exercise heart rate reminder
    public final static int HEALTH_SETTING_TYPE_AUTOMATIC_PRESSURE_DETECTION = 0x05;//Automatic pressure detection
    public final static int HEALTH_SETTING_TYPE_SLEEP_DETECTION = 0x06;//Sleep detection
    public final static int HEALTH_SETTING_TYPE_FALL_DETECTION = 0x07;//Fall detection
    public final static int HEALTH_SETTING_TYPE_LIFT_WRIST_DETECTION = 0x08;//Wrist lifting detection
    public final static int HEALTH_SETTING_TYPE_USER_INFO = 0x09;//Personal information
    public final static int HEALTH_SETTING_TYPE_DISCONNECT_REMINDER = 0x0A;//Bluetooth disconnection reminder
    public final static int HEALTH_SETTING_TYPE_BLOOD_OXYGEN_MEASUREMENT_ALERT = 0x0B; //Blood oxygen measurement reminder
    public final static int HEALTH_SETTING_TYPE_EMERGENCY_CONTACT = 0x0C; //Emergency contact
    ...
}