summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/doc/hs2.md
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ihealth-sdk/doc/hs2.md')
-rw-r--r--libs/ihealth-sdk/doc/hs2.md84
1 files changed, 84 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/doc/hs2.md b/libs/ihealth-sdk/doc/hs2.md
new file mode 100644
index 0000000..c393577
--- /dev/null
+++ b/libs/ihealth-sdk/doc/hs2.md
@@ -0,0 +1,84 @@
1# HS2 Workflow
2
3## import HS2 module
4
5```js
6import {
7 HS2Module,
8 HSProfileModule
9} from '@ihealth/ihealthlibrary-react-native';
10```
11
12## APIs
13
14### add and remove listener
15
16```js
17// add
18notifyListener = DeviceEventEmitter.addListener(HS2Module.Event_Notify, (event) => {
19 console.log(event);
20});
21
22// remove
23notifyListener.remove();
24```
25
26### start a measurement
27
28The API is asyn function. It will return message until finish measurement.
29
30```js
31HS2Module.startMeasure(mac);
32
33notifyListener = DeviceEventEmitter.addListener(HS2Module.Event_Notify, (event) => {
34 if (event.action === HSProfileModule.ACTION_ONLINE_RESULT_HS) {
35 console.log(event[HSProfileModule.DATAID]);
36 console.log(event[HSProfileModule.WEIGHT_HS]);
37 console.log(event[HSProfileModule.FAT_HS]);
38 console.log(event[HSProfileModule.WATER_HS]);
39 console.log(event[HSProfileModule.MUSCLE_HS]);
40 console.log(event[HSProfileModule.SKELETON_HS]);
41 console.log(event[HSProfileModule.FATELEVEL_HS]);
42 console.log(event[HSProfileModule.DCI_HS]);
43 }
44});
45```
46
47### get data stored in the HS2 device
48
49```js
50HS2Module.getOfflineData(mac);
51
52notifyListener = DeviceEventEmitter.addListener(HS2Module.Event_Notify, (event) => {
53 if (event.action === HSProfileModule.ACTION_HISTORICAL_DATA_HS) {
54 let dataArray = event[HSProfileModule.HISTORDATA_HS];
55 if (dataArray == undefined) {
56 result = "There is not offline data in device"
57 }else {
58 for (let i = 0; i < dataArray.length; i++) {
59 let offlineData = dataArray[i];
60 console.log(offlineData[HSProfileModule.MEASUREMENT_DATE_HS]);
61 console.log(offlineData[HSProfileModule.WEIGHT_HS]);
62 console.log(offlineData[HSProfileModule.FAT_HS]);
63 console.log(offlineData[HSProfileModule.WATER_HS]);
64 console.log(offlineData[HSProfileModule.MUSCLE_HS]);
65 console.log(offlineData[HSProfileModule.SKELETON_HS]);
66 console.log(offlineData[HSProfileModule.FATELEVEL_HS]);
67 console.log(offlineData[HSProfileModule.DATAID]);
68 }
69 }
70 }
71});
72```
73
74### disconnect device
75
76```js
77BP3LModule.disConnect(mac);
78```
79
80### get all connected devices
81
82```js
83BP3LModule.getAllConnectedDevices();
84```