diff options
| author | hc <haocheng.xie@respiree.com> | 2026-04-13 15:17:52 +0800 |
|---|---|---|
| committer | hc <haocheng.xie@respiree.com> | 2026-04-13 15:17:52 +0800 |
| commit | d6d9a09d505d11148599a95a5be3e1351edbe0ac (patch) | |
| tree | a5f5891983d1ff207e99f683a5e151519cef4980 /libs/ihealth-sdk/doc/bg5.md | |
| parent | e4fb9966e762852bf17f21c8406501d42fae0b61 (diff) | |
Local iHealth SDK, device detail screen, iOS event fixes
Diffstat (limited to 'libs/ihealth-sdk/doc/bg5.md')
| -rw-r--r-- | libs/ihealth-sdk/doc/bg5.md | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/doc/bg5.md b/libs/ihealth-sdk/doc/bg5.md new file mode 100644 index 0000000..38493ad --- /dev/null +++ b/libs/ihealth-sdk/doc/bg5.md | |||
| @@ -0,0 +1,195 @@ | |||
| 1 | # BG5 Workflow | ||
| 2 | |||
| 3 | ## Import BG5 Module | ||
| 4 | |||
| 5 | ```js | ||
| 6 | import { | ||
| 7 | BG5Module, | ||
| 8 | BGProfileModule | ||
| 9 | } from '@ihealth/ihealthlibrary-react-native'; | ||
| 10 | ``` | ||
| 11 | |||
| 12 | ## APIs | ||
| 13 | |||
| 14 | ### Add and remove listener | ||
| 15 | |||
| 16 | ```js | ||
| 17 | // add | ||
| 18 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 19 | console.log(event); | ||
| 20 | }); | ||
| 21 | |||
| 22 | // remove | ||
| 23 | notifyListener.remove(); | ||
| 24 | ``` | ||
| 25 | |||
| 26 | ### set time | ||
| 27 | |||
| 28 | If you use new bg5 or it has not been used for a long time. You should sync current time with bg5. | ||
| 29 | |||
| 30 | ```js | ||
| 31 | BG5Module.setTime(mac); | ||
| 32 | |||
| 33 | // response | ||
| 34 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 35 | if (event.action === BGProfileModule.ACTION_SET_TIME) { | ||
| 36 | console.log("set time"); | ||
| 37 | } | ||
| 38 | }); | ||
| 39 | ``` | ||
| 40 | |||
| 41 | ### set unit | ||
| 42 | |||
| 43 | The API can change the unit of the bg5 display. | ||
| 44 | |||
| 45 | ```js | ||
| 46 | // 1: mmol/L 2: mg/dL | ||
| 47 | BG5Module.setUnit(mac, 1); | ||
| 48 | |||
| 49 | // response | ||
| 50 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 51 | if (event.action === BGProfileModule.ACTION_SET_UNIT) { | ||
| 52 | console.log("set unit"); | ||
| 53 | } | ||
| 54 | }); | ||
| 55 | ``` | ||
| 56 | |||
| 57 | ### get bottle information from barcode | ||
| 58 | |||
| 59 | 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. | ||
| 60 | |||
| 61 | ```js | ||
| 62 | BG5Module.getBottleInfoFromQR(QRCode); | ||
| 63 | |||
| 64 | // response | ||
| 65 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 66 | if (event.action === BGProfileModule.ACTION_CODE_ANALYSIS) { | ||
| 67 | console.log(event[BGProfileModule.STRIP_NUM_BG]); | ||
| 68 | console.log(event[BGProfileModule.STRIP_EXPIRETIME_BG]); | ||
| 69 | console.log(event[BGProfileModule.BOTTLEID_BG]); | ||
| 70 | } | ||
| 71 | }); | ||
| 72 | ``` | ||
| 73 | |||
| 74 | ### set bottle id | ||
| 75 | |||
| 76 | ```js | ||
| 77 | BG5Module.getBottleInfoFromQR(QRCode); | ||
| 78 | |||
| 79 | // response | ||
| 80 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 81 | if (event.action === BGProfileModule.ACTION_SET_BOTTLEID) { | ||
| 82 | console.log("Set bottleID"); | ||
| 83 | } | ||
| 84 | }); | ||
| 85 | ``` | ||
| 86 | |||
| 87 | ### get bottle id | ||
| 88 | |||
| 89 | ```js | ||
| 90 | BG5Module.getBottleInfoFromQR(QRCode); | ||
| 91 | |||
| 92 | // response | ||
| 93 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 94 | if (event.action === BGProfileModule.ACTION_GET_BOTTLEID) { | ||
| 95 | console.log(event[BGProfileModule.GET_BOTTLEID]); | ||
| 96 | } | ||
| 97 | }); | ||
| 98 | ``` | ||
| 99 | |||
| 100 | ### Set bottle message | ||
| 101 | |||
| 102 | When you use a new bg5 device or you open a new strip bottle, must set bottle message to bg5 device. | ||
| 103 | |||
| 104 | ```js | ||
| 105 | /** | ||
| 106 | * mac device mac address | ||
| 107 | * stripType 1: GOD, 2: GDH | ||
| 108 | * measureType 1: measure with real blood, 2: measure with control solution | ||
| 109 | * barcode for GOD strip, you can scan barcode at top of the bottle. for GDH strip, set null. | ||
| 110 | * unusedStrip unused strip. | ||
| 111 | * expireDay check the expire day on the bottle, and stirp is expired after opening for 90 days. | ||
| 112 | */ | ||
| 113 | BG5Module.setBottleMessage(mac, 1, 1, QRCode, 25, "2027-07-15"); | ||
| 114 | |||
| 115 | // response | ||
| 116 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 117 | if (event.action === BGProfileModule.ACTION_SET_BOTTLEMESSAGE) { | ||
| 118 | console.log("set bottle message success"); | ||
| 119 | } | ||
| 120 | }); | ||
| 121 | ``` | ||
| 122 | |||
| 123 | ### get bottle message | ||
| 124 | |||
| 125 | ```js | ||
| 126 | BG5Module.getBottleMessage(mac); | ||
| 127 | |||
| 128 | // response | ||
| 129 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 130 | if (event.action === BGProfileModule.ACTION_GET_BOTTLEMESSAGE) { | ||
| 131 | console.log(event[BGProfileModule.GET_EXPIRECTIME]); | ||
| 132 | console.log(event[BGProfileModule.GET_USENUM]); | ||
| 133 | } | ||
| 134 | }); | ||
| 135 | ``` | ||
| 136 | |||
| 137 | ### start a measurement | ||
| 138 | |||
| 139 | ```js | ||
| 140 | // * measureType 1: measure with real blood, 2: measure with control solution | ||
| 141 | BG5Module.startMeasure(mac, 1); | ||
| 142 | |||
| 143 | // response | ||
| 144 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 145 | if (event.action === BGProfileModule.ACTION_STRIP_IN) { | ||
| 146 | console.log("strip in"); | ||
| 147 | |||
| 148 | } else if (event.action === BGProfileModule.ACTION_STRIP_OUT) { | ||
| 149 | console.log("strip out"); | ||
| 150 | |||
| 151 | } else if (event.action === BGProfileModule.ACTION_GET_BLOOD) { | ||
| 152 | console.log("analysis blood"); | ||
| 153 | |||
| 154 | } else if (event.action === BGProfileModule.ACTION_ONLINE_RESULT_BG) { | ||
| 155 | console.log(event[BGProfileModule.ONLINE_RESULT_BG]); | ||
| 156 | console.log(event[BGProfileModule.DATA_ID]); | ||
| 157 | } | ||
| 158 | }); | ||
| 159 | ``` | ||
| 160 | |||
| 161 | ### get data stored in the bg5 device | ||
| 162 | |||
| 163 | ```js | ||
| 164 | BG5Module.getOfflineData(mac); | ||
| 165 | |||
| 166 | // response | ||
| 167 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 168 | if (event.action === BGProfileModule.ACTION_GET_OFFLINEDATA_COUNT) { | ||
| 169 | console.log(event[BGProfileModule.GET_OFFLINEDATA_COUNT]); | ||
| 170 | console.log(event[BGProfileModule.GET_OFFLINEDATA]); | ||
| 171 | } | ||
| 172 | }); | ||
| 173 | ``` | ||
| 174 | |||
| 175 | ### delete the data stored in the bg5 device | ||
| 176 | |||
| 177 | ```js | ||
| 178 | BG5Module.deleteOfflineData(mac); | ||
| 179 | |||
| 180 | // response | ||
| 181 | notifyListener = DeviceEventEmitter.addListener(BG5Module.Event_Notify, (event) => { | ||
| 182 | if (event.action === BGProfileModule.ACTION_DELETE_OFFLINEDATA) { | ||
| 183 | console.log("delete data"); | ||
| 184 | } | ||
| 185 | }); | ||
| 186 | ``` | ||
| 187 | |||
| 188 | ### keep link with phone | ||
| 189 | |||
| 190 | The BG5 use regular bluetooth communicate with phone. For save the power, if there is no communication, bg5 will turn off. | ||
| 191 | The api is used to keep link with phone. | ||
| 192 | |||
| 193 | ```js | ||
| 194 | BG5Module.holdLink(mac); | ||
| 195 | ``` \ No newline at end of file | ||
