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/bg5s.md | |
| parent | e4fb9966e762852bf17f21c8406501d42fae0b61 (diff) | |
Local iHealth SDK, device detail screen, iOS event fixes
Diffstat (limited to 'libs/ihealth-sdk/doc/bg5s.md')
| -rw-r--r-- | libs/ihealth-sdk/doc/bg5s.md | 176 |
1 files changed, 176 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/doc/bg5s.md b/libs/ihealth-sdk/doc/bg5s.md new file mode 100644 index 0000000..06bc6d4 --- /dev/null +++ b/libs/ihealth-sdk/doc/bg5s.md | |||
| @@ -0,0 +1,176 @@ | |||
| 1 | # BG5S Workflow | ||
| 2 | |||
| 3 | ## Import BG5S Module | ||
| 4 | |||
| 5 | ```js | ||
| 6 | import { | ||
| 7 | BG5SModule, | ||
| 8 | BG5SProfileModule | ||
| 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(BG5SModule.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 | BG5SModule.setTime(mac); | ||
| 32 | |||
| 33 | // response | ||
| 34 | // {"type":"BG5S","mac":"5C0272267365","action":"action_set_time"} | ||
| 35 | notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => { | ||
| 36 | if (event.action === BG5SProfileModule.ACTION_SET_TIME) { | ||
| 37 | console.log("set time"); | ||
| 38 | } | ||
| 39 | }); | ||
| 40 | ``` | ||
| 41 | |||
| 42 | ### Set Unit | ||
| 43 | |||
| 44 | The API can change the unit of the bg5 display. | ||
| 45 | |||
| 46 | ```js | ||
| 47 | // 1: mmol/L 2: mg/dL | ||
| 48 | BG5SModule.setUnit(mac, 1); | ||
| 49 | |||
| 50 | // response | ||
| 51 | // {"type":"BG5S","mac":"5C0272267365","action":"action_set_unit"} | ||
| 52 | notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => { | ||
| 53 | if (event.action === BG5SProfileModule.ACTION_SET_UNIT) { | ||
| 54 | console.log("set Unit"); | ||
| 55 | } | ||
| 56 | }); | ||
| 57 | ``` | ||
| 58 | |||
| 59 | ### get bg5s status information | ||
| 60 | |||
| 61 | ```js | ||
| 62 | BG5SModule.getStatusInfo(mac); | ||
| 63 | |||
| 64 | // response | ||
| 65 | // {"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"} | ||
| 66 | |||
| 67 | notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => { | ||
| 68 | if (event.action === BG5SProfileModule.ACTION_GET_STATUS_INFO) { | ||
| 69 | console.log(event[BG5SProfileModule.INFO_BATTERY_LEVEL]); | ||
| 70 | console.log(event[BG5SProfileModule.INFO_TIME]); | ||
| 71 | console.log(event[BG5SProfileModule.INFO_TIMEZONE]); | ||
| 72 | console.log(event[BG5SProfileModule.INFO_USED_STRIP]); | ||
| 73 | console.log(event[BG5SProfileModule.INFO_OFFLINE_DATA_NUM]); | ||
| 74 | console.log(event[BG5SProfileModule.INFO_CODE_VERSION_BLOOD]); | ||
| 75 | console.log(event[BG5SProfileModule.INFO_CODE_VERSION_CTL]); | ||
| 76 | console.log(event[BG5SProfileModule.INFO_UNIT]); | ||
| 77 | } | ||
| 78 | }); | ||
| 79 | ``` | ||
| 80 | |||
| 81 | ### delete userd strip | ||
| 82 | |||
| 83 | ```js | ||
| 84 | BG5SModule.deleteUsedStrip(QRCode); | ||
| 85 | |||
| 86 | // response | ||
| 87 | // {"type":"BG5S","mac":"5C0272267365","action":"action_delete_used_strip"} | ||
| 88 | notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => { | ||
| 89 | if (event.action === BG5SProfileModule.ACTION_DELETE_USED_STRIP) { | ||
| 90 | |||
| 91 | } | ||
| 92 | }); | ||
| 93 | ``` | ||
| 94 | |||
| 95 | ### delete offline data | ||
| 96 | |||
| 97 | ```js | ||
| 98 | BG5SModule.deleteOfflineData(QRCode); | ||
| 99 | |||
| 100 | // response | ||
| 101 | // {"type":"BG5S","mac":"5C0272267365","action":"action_delete_offline_data"} | ||
| 102 | notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => { | ||
| 103 | if (event.action === BG5SProfileModule.ACTION_DELETE_OFFLINE_DATA) { | ||
| 104 | |||
| 105 | } | ||
| 106 | }); | ||
| 107 | ``` | ||
| 108 | |||
| 109 | ### get offline data | ||
| 110 | |||
| 111 | ```js | ||
| 112 | BG5SModule.getOfflineData(mac); | ||
| 113 | |||
| 114 | // response | ||
| 115 | // {"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"} | ||
| 116 | |||
| 117 | notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => { | ||
| 118 | if (event.action === BG5SProfileModule.ACTION_GET_OFFLINE_DATA) { | ||
| 119 | console.log(event[BG5SProfileModule.OFFLINE_DATA]); | ||
| 120 | } | ||
| 121 | }); | ||
| 122 | ``` | ||
| 123 | |||
| 124 | ### adjust offline data | ||
| 125 | |||
| 126 | ```js | ||
| 127 | BG5SModule.adjustOfflineData(mac); | ||
| 128 | |||
| 129 | // response | ||
| 130 | // {"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"} | ||
| 131 | |||
| 132 | notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => { | ||
| 133 | if (event.action === "action_adjust_offline_data") { | ||
| 134 | console.log(event[BG5SProfileModule.OFFLINE_DATA]); | ||
| 135 | } | ||
| 136 | }); | ||
| 137 | ``` | ||
| 138 | |||
| 139 | ### start a measurement | ||
| 140 | |||
| 141 | ```js | ||
| 142 | // * measureType 1: measure with real blood, 2: measure with control solution | ||
| 143 | BG5SModule.startMeasure(mac, 1); | ||
| 144 | |||
| 145 | // response | ||
| 146 | notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => { | ||
| 147 | if (event.action === BG5SProfileModule.ACTION_STRIP_IN) { | ||
| 148 | console.log("strip in"); | ||
| 149 | |||
| 150 | } else if (event.action === BG5SProfileModule.ACTION_STRIP_OUT) { | ||
| 151 | console.log("strip out"); | ||
| 152 | |||
| 153 | } else if (event.action === BG5SProfileModule.ACTION_GET_BLOOD) { | ||
| 154 | console.log("analysis blood"); | ||
| 155 | |||
| 156 | } else if (event.action === BG5SProfileModule.ACTION_RESULT) { | ||
| 157 | // {"dataID":"FCB4230B3F081306DCC0404090861A36","result_value":84,"type":"BG5S","mac":"5C0272267365","action":"action_result"} | ||
| 158 | console.log(event[BG5SProfileModule.RESULT_VALUE]); | ||
| 159 | console.log(event[BG5SProfileModule.DATA_ID]); | ||
| 160 | } | ||
| 161 | }); | ||
| 162 | ``` | ||
| 163 | |||
| 164 | ### get data stored in the bg5 device | ||
| 165 | |||
| 166 | ```js | ||
| 167 | BG5SModule.setOfflineModel(mac, true); | ||
| 168 | |||
| 169 | // response | ||
| 170 | // // {"type":"BG5S","mac":"5C0272267365","action":"action_delete_offline_data"} | ||
| 171 | notifyListener = DeviceEventEmitter.addListener(BG5SModule.Event_Notify, (event) => { | ||
| 172 | if (event.action === BG5SProfileModule.ACTION_SET_OFFLINE_MEASUREMENT_MODE) { | ||
| 173 | |||
| 174 | } | ||
| 175 | }); | ||
| 176 | ``` \ No newline at end of file | ||
