BloodOxygen
Start from API_LEVEL
2.0
. Please refer to API_LEVEL.
Blood oxygen Sensor.
info
permission code: data:user.hd.spo2
Methods
getCurrent
Get the current measured blood oxygen result
getCurrent(): Result
Result
Property | Type | Description | API_LEVEL |
---|---|---|---|
value | number | Blood oxygen measurement values | 2.0 |
time | number | Measurement time | 2.0 |
retCode | number | Result code, refer to retCode description | 2.0 |
retCode
Value | Type | Description | API_LEVEL |
---|---|---|---|
0 | number | Measurement invalid | 2.0 |
1 | number | Continue measuring | 2.0 |
2 | number | Measurement success | 2.0 |
3 | number | Measurement failure | 2.0 |
4 | number | Not wearing | 2.0 |
5 | number | Measurement timeout | 2.0 |
6 | number | Invalid wearing | 2.0 |
7 | number | Invalid signal | 2.0 |
8 | number | Low blood oxygen value | 2.0 |
9 | number | High blood oxygen value | 2.0 |
10 | number | Measurement invalid | 2.0 |
getLastDay
Returns the average blood sample data for the past 24 hours, with an array length of 24
getLastDay(): Array<number>
start
Start from API_LEVEL
2.1
Start blood oxygen measurement, it is recommended to call stop
to stop the last measurement before calling the start
method
start(): void
stop
Start from API_LEVEL
2.1
Cancel blood oxygen measurement
stop(): void
onChange
Register a callback function to listen for blood oxygen measurement change events
onChange(callback: () => void): void
offChange
Cancel a callback function to listen for blood oxygen measurement change events
offChange(callback: () => void): void
Example
import { BloodOxygen } from '@zos/sensor'
const bloodOxygen = new BloodOxygen()
const { value } = bloodOxygen.getCurrent()
const lastDay = bloodOxygen.getLastDay()
const callback = () => {
console.log(bloodOxygen.getCurrent())
}
bloodOxygen.onChange(callback)
bloodOxygen.stop()
bloodOxygen.start()
// When not needed for use
bloodOxygen.offChange(callback)