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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# BG5S Workflow
## Import BG5S Module
```js
import {
BG5SModule,
BG5SProfileModule
} from '@ihealth/ihealthlibrary-react-native';
```
## APIs
### Add and remove listener
```js
// add
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
console.log(event);
});
// remove
notifyListener.remove();
```
### Set time
If you use new bg5 or it has not been used for a long time. You should sync current time with bg5.
```js
BG5SModule.setTime(mac);
// response
// {"type":"BG5S","mac":"5C0272267365","action":"action_set_time"}
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
if (event.action === BG5SProfileModule.ACTION_SET_TIME) {
console.log("set time");
}
});
```
### Set Unit
The API can change the unit of the bg5 display.
```js
// 1: mmol/L 2: mg/dL
BG5SModule.setUnit(mac, 1);
// response
// {"type":"BG5S","mac":"5C0272267365","action":"action_set_unit"}
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
if (event.action === BG5SProfileModule.ACTION_SET_UNIT) {
console.log("set Unit");
}
});
```
### get bg5s status information
```js
BG5SModule.getStatusInfo(mac);
// response
// {"info_unit":2,"info_code_version_ctl":3,"info_code_version_blood":3,"info_offline_data_num":0,"info_used_strip":0,////"info_timezone":8,"info_time":"2017-01-01 00:40:37","info_battery_level":71,"type":"BG5S","mac":"5C0272267365","action":"action_get_status_info"}
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
if (event.action === BG5SProfileModule.ACTION_GET_STATUS_INFO) {
console.log(event[BG5SProfileModule.INFO_BATTERY_LEVEL]);
console.log(event[BG5SProfileModule.INFO_TIME]);
console.log(event[BG5SProfileModule.INFO_TIMEZONE]);
console.log(event[BG5SProfileModule.INFO_USED_STRIP]);
console.log(event[BG5SProfileModule.INFO_OFFLINE_DATA_NUM]);
console.log(event[BG5SProfileModule.INFO_CODE_VERSION_BLOOD]);
console.log(event[BG5SProfileModule.INFO_CODE_VERSION_CTL]);
console.log(event[BG5SProfileModule.INFO_UNIT]);
}
});
```
### delete userd strip
```js
BG5SModule.deleteUsedStrip(QRCode);
// response
// {"type":"BG5S","mac":"5C0272267365","action":"action_delete_used_strip"}
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
if (event.action === BG5SProfileModule.ACTION_DELETE_USED_STRIP) {
}
});
```
### delete offline data
```js
BG5SModule.deleteOfflineData(QRCode);
// response
// {"type":"BG5S","mac":"5C0272267365","action":"action_delete_offline_data"}
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
if (event.action === BG5SProfileModule.ACTION_DELETE_OFFLINE_DATA) {
}
});
```
### get offline data
```js
BG5SModule.getOfflineData(mac);
// response
// {"offline_data":[{"dataID":"D8615BFEB73C3928D83131894D68E87B","data_measure_timezone":8,"data_measure_time":"2019-04-22 01:31:47","data_value":1023,"data_time_proof":false}],"type":"BG5S","mac":"5C0272267365","action":"action_get_offline_data"}
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
if (event.action === BG5SProfileModule.ACTION_GET_OFFLINE_DATA) {
console.log(event[BG5SProfileModule.OFFLINE_DATA]);
}
});
```
### adjust offline data
```js
BG5SModule.adjustOfflineData(mac);
// response
// {"offline_data":[{"dataID":"D8615BFEB73C3928D83131894D68E87B","data_measure_timezone":8,"data_measure_time":"2019-04-22 01:31:47","data_value":1023,"data_time_proof":false}],"type":"BG5S","mac":"5C0272267365","action":"action_get_offline_data"}
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
if (event.action === "action_adjust_offline_data") {
console.log(event[BG5SProfileModule.OFFLINE_DATA]);
}
});
```
### start a measurement
```js
// * measureType 1: measure with real blood, 2: measure with control solution
BG5SModule.startMeasure(mac, 1);
// response
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
if (event.action === BG5SProfileModule.ACTION_STRIP_IN) {
console.log("strip in");
} else if (event.action === BG5SProfileModule.ACTION_STRIP_OUT) {
console.log("strip out");
} else if (event.action === BG5SProfileModule.ACTION_GET_BLOOD) {
console.log("analysis blood");
} else if (event.action === BG5SProfileModule.ACTION_RESULT) {
// {"dataID":"FCB4230B3F081306DCC0404090861A36","result_value":84,"type":"BG5S","mac":"5C0272267365","action":"action_result"}
console.log(event[BG5SProfileModule.RESULT_VALUE]);
console.log(event[BG5SProfileModule.DATA_ID]);
}
});
```
### get data stored in the bg5 device
```js
BG5SModule.setOfflineModel(mac, true);
// response
// // {"type":"BG5S","mac":"5C0272267365","action":"action_delete_offline_data"}
notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => {
if (event.action === BG5SProfileModule.ACTION_SET_OFFLINE_MEASUREMENT_MODE) {
}
});
```
|