Skip to main content
Version: v3

HeartRate

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

HeartRate Sensor.

info

permission code: data:user.hd.heart_rate

Methods

getCurrent

Get the current heart rate measurement, this method needs to be used in the onCurrentChange callback function

getCurrent(): number

getLast

Get the most recent heart rate measurement (single measurement or heart rate monitoring measurement, continuous heart rate measurement onCurrentChange results are not counted)

getLast(): number

getToday

Get the heart rate measurement data in minutes from 0:00 to the current moment of the day, the longest array is 60*24

getToday(): Array<number>

onCurrentChange

Start from API_LEVEL 2.1

Call this method and start measuring heart rate continuously, call the callback function when there is a measurement result, call the getCurrent method in the callback function to get the heart rate measurement value, if you want to stop the heart rate measurement, you need to call the offCurrentChange method

onCurrentChange(callback: () => void): void

offCurrentChange

Start from API_LEVEL 2.1

Cancel continuous heart rate measurement and cancel callback function listeners

offCurrentChange(callback: () => void): void

onLastChange

Start from API_LEVEL 2.1

Register the heart rate single measurement change event callback function

onLastChange(callback: () => void): void

offLastChange

Start from API_LEVEL 2.1

Cancel the heart rate single measurement change event callback function

offLastChange(callback: () => void): void

getDailySummary

Start from API_LEVEL 3.0

Get daily heart rate statistics

getDailySummary(): Result

Result

PropertyTypeDescriptionAPI_LEVEL
maximumMaximumMaximum heart rate information3.0

Maximum

PropertyTypeDescriptionAPI_LEVEL
hr_valuenumberMaximum heart rate value3.0
timenumberMeasurement time of maximum heart rate3.0

getResting

Start from API_LEVEL 3.0

Get current resting heart rate

getResting(): number

getAFibRecord

Start from API_LEVEL 3.0

Get Atrial Fibrillation Data Array

getAFibRecord(): Result

Result

TypeDescription
Array<AfibInfo>Atrial Fibrillation Information Array

AfibInfo

PropertyTypeDescriptionAPI_LEVEL
flagnumberAtrial fibrillation test results, 0 - normal, 1 - high alert, 2 - low alert, 3 - atrial fibrillation3.0
valnumberAtrial fibrillation data value, integer value 0 - 2553.0
maxValuenumberAtrial fibrillation data maximum value, integer value 0 - 2553.0
minValuenumberAtrial fibrillation data minimum value, integer value 0 - 2553.0
timenumberTime of Atrial fibrillation data acquisition, UTC seconds3.0
durationnumberDuration in seconds3.0

onRestingChange

Start from API_LEVEL 3.0

After calling this method, the device starts real-time resting heart rate measurement and registers a callback function, which is called when there is a measurement result, in which the getResting method can be called to get the resting heart rate measurement value, and if you need to stop the resting heart rate measurement, you need to call the offRestingChange method

onRestingChange(callback: () => void): void

offRestingChange

Start from API_LEVEL 3.0

Cancel continuous resting heart rate measurement and cancel callback function listeners

offRestingChange(callback: () => void): void

Example

import { HeartRate } from '@zos/sensor'

const heartRate = new HeartRate()
const lastValue = heartRate.getLast()

const callback = () => {
console.log(heartRate.getCurrent())
}

heartRate.onCurrentChange(callback)

// When not needed for use
heartRate.offCurrentChange(callback)