summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/doc/po3.md
blob: 1a11df1524bffd6f42a186bfd017e2c08749484c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# PO3 Workflow

## Import PO3 Module

```js
import {
  PO3Module,
  POProfileModule
} from '@ihealth/ihealthlibrary-react-native';
```

## APIs

### Add and remove listener

```js
// add
notifyListener = DeviceEventEmitter.addListener(PO3Module.Event_Notify,  (event) => {
    console.log(event);
});

// remove
notifyListener.remove();
```

### get battery

```js
PO3Module.getBattery(mac);

// response
notifyListener = DeviceEventEmitter.addListener(PO3Module.Event_Notify,  (event) => {
    if (event.action === POProfileModule.ACTION_BATTERY_PO) {
        console.log(event[POProfileModule.BATTERY_PO]);
    }
});
```

### start a measurement with app

```js
PO3Module.startMeasure(mac);

// response
notifyListener = DeviceEventEmitter.addListener(PO3Module.Event_Notify,  (event) => {
    if (event.action === POProfileModule.ACTION_LIVEDA_PO) {
        console.log(event[POProfileModule.PULSE_WAVE_PO]);
        console.log(event[POProfileModule.PI_PO]);
        console.log(event[POProfileModule.PULSE_STRENGTH_PO]);
        console.log(event[POProfileModule.BLOOD_OXYGEN_PO]);
        console.log(event[POProfileModule.PULSE_RATE_PO]);
    } else if(){
        // final result
        console.log(event[POProfileModule.PULSE_WAVE_PO]);
        console.log(event[POProfileModule]);
        console.log(event[POProfileModule.PI_PO]);
        console.log(event[POProfileModule.PULSE_STRENGTH_PO]);
        console.log(event[POProfileModule.BLOOD_OXYGEN_PO]);
        console.log(event[POProfileModule.PULSE_RATE_PO]);
    }
});
```

### get data stored in the po3 device

```js
PO3Module.getHistoryData(mac);

// response
notifyListener = DeviceEventEmitter.addListener(PO3Module.Event_Notify,  (event) => {
    if (event.action === POProfileModule.ACTION_NO_OFFLINEDATA_PO) {
        console.log("There is no more data stored in the po3 device.");
    } else if (event.action === POProfileModule.ACTION_OFFLINEDATA_PO) {
        const dataArray = event[POProfileModule.OFFLINEDATA_PO];
        for (let i = 0; i < dataArray.length; i++) {
                let offlineData = dataArray[i];
                console.log(offlineData[POProfileModule.MEASUREMENT_DATE_BP]);
                console.log(offlineData[POProfileModule.HIGH_BLOOD_PRESSURE_BP]);
                console.log(offlineData[POProfileModule.LOW_BLOOD_PRESSURE_BP]);
                console.log(offlineData[POProfileModule.PULSE_BP]);
                console.log(offlineData[POProfileModule.MEASUREMENT_AHR_BP]);
                console.log(offlineData[POProfileModule.MEASUREMENT_HSD_BP]);
                console.log(offlineData[POProfileModule.DATAID]);
            }
    }
});
```