@ihealth/ihealthlibrary-react-native
Version:
React Native Model for iHealth Library
115 lines (89 loc) • 3.13 kB
Markdown
# KN550 Workflow
## import KN550 module
```js
import {
BP550BTModule,
BPProfileModule
} from '@ihealth/ihealthlibrary-react-native';
```
## APIs
### add and remove listener
```js
// add
notifyListener = DeviceEventEmitter.addListener(BP550BTModule.Event_Notify, (event) => {
console.log(event);
});
// remove
notifyListener.remove();
```
### get battery
```js
BP550BTModule.getBattery(mac);
notifyListener = DeviceEventEmitter.addListener(BP550BTModule.Event_Notify, (event) => {
if (event.action === BPProfileModule.ACTION_BATTERY_BP) {
console.log(event[BPProfileModule.BATTERY_BP]);
}
});
```
### get KN550 function
```js
BP550BTModule.getFunctionInfo(mac);
notifyListener = DeviceEventEmitter.addListener(BP550BTModule.Event_Notify, (event) => {
if (event.action === BPProfileModule.ACTION_FUNCTION_INFORMATION_BP) {
console.log(event[BPProfileModule.FUNCTION_IS_UPAIR_MEASURE]);
console.log(event[BPProfileModule.FUNCTION_IS_ARM_MEASURE]);
console.log(event[BPProfileModule.FUNCTION_HAVE_ANGLE_SENSOR]);
console.log(event[BPProfileModule.FUNCTION_HAVE_OFFLINE]);
console.log(event[BPProfileModule.FUNCTION_HAVE_HSD]);
console.log(event[BPProfileModule.FUNCTION_HAVE_ANGLE_SETTING]);
console.log(event[BPProfileModule.FUNCTION_IS_MULTI_UPLOAD]);
console.log(event[BPProfileModule.FUNCTION_HAVE_SELF_UPDATE]);
}
});
```
### get quantity of data stored in the KN550 device
```js
BP550BTModule.getOfflineNum(mac);
notifyListener = DeviceEventEmitter.addListener(BP550BTModule.Event_Notify, (event) => {
if (e.action === BPProfileModule.ACTION_HISTORICAL_NUM_BP) {
console.log(event[BPProfileModule.HISTORICAL_NUM_BP]);
}
});
```
### get data stored in the KN550 device
```js
BP550BTModule.getOfflineData(mac);
notifyListener = DeviceEventEmitter.addListener(BP550BTModule.Event_Notify, (event) => {
if (event.action === BPProfileModule.ACTION_HISTORICAL_DATA_BP) {
let dataArray = event[BPProfileModule.HISTORICAL_DATA_BP];
if (dataArray == undefined) {
result = "There is not offline data in device"
}else {
for (let i = 0; i < dataArray.length; i++) {
let offlineData = dataArray[i];
console.log(offlineData[BPProfileModule.MEASUREMENT_DATE_BP]);
console.log(offlineData[BPProfileModule.HIGH_BLOOD_PRESSURE_BP]);
console.log(offlineData[BPProfileModule.LOW_BLOOD_PRESSURE_BP]);
console.log(offlineData[BPProfileModule.PULSE_BP]);
console.log(offlineData[BPProfileModule.MEASUREMENT_AHR_BP]);
console.log(offlineData[BPProfileModule.MEASUREMENT_HSD_BP]);
console.log(offlineData[BPProfileModule.DATAID]);
}
}
}
});
```
### disconnect device
```js
BP550BTModule.disconnect(mac);
```
### get device information
```js
iHealthDeviceManagerModule.getDevicesIDPS(mac, (event) => {
console.info(event);
})
```
### get all connected devices
```js
BP550BTModule.getAllConnectedDevices();
```