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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# BG5 Workflow
## Import BG5 Module
```js
import {
BG5Module,
BGProfileModule
} from '@ihealth/ihealthlibrary-react-native';
```
## APIs
### Add and remove listener
```js
// add
notifyListener = DeviceEventEmitter.addListener(BG5Module.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
BG5Module.setTime(mac);
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.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
BG5Module.setUnit(mac, 1);
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.ACTION_SET_UNIT) {
console.log("set unit");
}
});
```
### get bottle information from barcode
When you scan the barcode at the top of bottle, you can get a string. Pass the string to this API, you can get bottle id, Number of the strips and expire day.
```js
BG5Module.getBottleInfoFromQR(QRCode);
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.ACTION_CODE_ANALYSIS) {
console.log(event[BGProfileModule.STRIP_NUM_BG]);
console.log(event[BGProfileModule.STRIP_EXPIRETIME_BG]);
console.log(event[BGProfileModule.BOTTLEID_BG]);
}
});
```
### set bottle id
```js
BG5Module.getBottleInfoFromQR(QRCode);
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.ACTION_SET_BOTTLEID) {
console.log("Set bottleID");
}
});
```
### get bottle id
```js
BG5Module.getBottleInfoFromQR(QRCode);
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.ACTION_GET_BOTTLEID) {
console.log(event[BGProfileModule.GET_BOTTLEID]);
}
});
```
### Set bottle message
When you use a new bg5 device or you open a new strip bottle, must set bottle message to bg5 device.
```js
/**
* mac device mac address
* stripType 1: GOD, 2: GDH
* measureType 1: measure with real blood, 2: measure with control solution
* barcode for GOD strip, you can scan barcode at top of the bottle. for GDH strip, set null.
* unusedStrip unused strip.
* expireDay check the expire day on the bottle, and stirp is expired after opening for 90 days.
*/
BG5Module.setBottleMessage(mac, 1, 1, QRCode, 25, "2027-07-15");
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.ACTION_SET_BOTTLEMESSAGE) {
console.log("set bottle message success");
}
});
```
### get bottle message
```js
BG5Module.getBottleMessage(mac);
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.ACTION_GET_BOTTLEMESSAGE) {
console.log(event[BGProfileModule.GET_EXPIRECTIME]);
console.log(event[BGProfileModule.GET_USENUM]);
}
});
```
### start a measurement
```js
// * measureType 1: measure with real blood, 2: measure with control solution
BG5Module.startMeasure(mac, 1);
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.ACTION_STRIP_IN) {
console.log("strip in");
} else if (event.action === BGProfileModule.ACTION_STRIP_OUT) {
console.log("strip out");
} else if (event.action === BGProfileModule.ACTION_GET_BLOOD) {
console.log("analysis blood");
} else if (event.action === BGProfileModule.ACTION_ONLINE_RESULT_BG) {
console.log(event[BGProfileModule.ONLINE_RESULT_BG]);
console.log(event[BGProfileModule.DATA_ID]);
}
});
```
### get data stored in the bg5 device
```js
BG5Module.getOfflineData(mac);
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.ACTION_GET_OFFLINEDATA_COUNT) {
console.log(event[BGProfileModule.GET_OFFLINEDATA_COUNT]);
console.log(event[BGProfileModule.GET_OFFLINEDATA]);
}
});
```
### delete the data stored in the bg5 device
```js
BG5Module.deleteOfflineData(mac);
// response
notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => {
if (event.action === BGProfileModule.ACTION_DELETE_OFFLINEDATA) {
console.log("delete data");
}
});
```
### keep link with phone
The BG5 use regular bluetooth communicate with phone. For save the power, if there is no communication, bg5 will turn off.
The api is used to keep link with phone.
```js
BG5Module.holdLink(mac);
```
|