diff options
Diffstat (limited to 'libs/ihealth-sdk/module/BG5SModule.js')
| -rw-r--r-- | libs/ihealth-sdk/module/BG5SModule.js | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/module/BG5SModule.js b/libs/ihealth-sdk/module/BG5SModule.js new file mode 100644 index 0000000..28ee38d --- /dev/null +++ b/libs/ihealth-sdk/module/BG5SModule.js | |||
| @@ -0,0 +1,145 @@ | |||
| 1 | /** | ||
| 2 | * @author chenxuewei | ||
| 3 | */ | ||
| 4 | 'use strict'; | ||
| 5 | |||
| 6 | |||
| 7 | var { NativeModules, Platform } = require('react-native'); | ||
| 8 | |||
| 9 | var RCTModule = NativeModules.BG5SModule; | ||
| 10 | |||
| 11 | /** | ||
| 12 | * @module BG5SModule | ||
| 13 | */ | ||
| 14 | module.exports = { | ||
| 15 | |||
| 16 | Event_Notify: RCTModule.Event_Notify, | ||
| 17 | |||
| 18 | /** | ||
| 19 | * Get status information of BG5 device. | ||
| 20 | * @param {string} mac Device's mac address | ||
| 21 | */ | ||
| 22 | getStatusInfo: function (mac){ | ||
| 23 | |||
| 24 | if (RCTModule != null) { | ||
| 25 | RCTModule.getStatusInfo(mac); | ||
| 26 | } else { | ||
| 27 | console.log('~~~~~ BG5S getStatusInfo RCTModule is null') | ||
| 28 | } | ||
| 29 | }, | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Set time to BG5 device. | ||
| 33 | * @param {string} mac Device's mac address | ||
| 34 | */ | ||
| 35 | setTime: function (mac, date, timezone){ | ||
| 36 | if (RCTModule != null) { | ||
| 37 | RCTModule.setTime(mac, date, timezone); | ||
| 38 | } else { | ||
| 39 | console.log('~~~~~ BG5S setTime RCTModule is null') | ||
| 40 | } | ||
| 41 | }, | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Set unit to BG5 device. | ||
| 45 | * @param {string} mac Device's mac address | ||
| 46 | * @param {number} type 1:mmol/L 2:mg/dL | ||
| 47 | */ | ||
| 48 | setUnit: function (mac, type){ | ||
| 49 | if (RCTModule != null) { | ||
| 50 | RCTModule.setUnit(mac, type); | ||
| 51 | } else { | ||
| 52 | console.log('~~~~~ BG5S setUnit RCTModule is null') | ||
| 53 | } | ||
| 54 | }, | ||
| 55 | |||
| 56 | /** | ||
| 57 | * Delete the offline data in BG5 device. | ||
| 58 | * @param {string} mac Device's mac address | ||
| 59 | */ | ||
| 60 | deleteUsedStrip: function (mac){ | ||
| 61 | if (RCTModule != null) { | ||
| 62 | RCTModule.deleteUsedStrip(mac); | ||
| 63 | } else { | ||
| 64 | console.log('~~~~~ BG5S deleteUsedStrip RCTModule is null') | ||
| 65 | } | ||
| 66 | }, | ||
| 67 | |||
| 68 | /** | ||
| 69 | * Delete the offline data in BG5 device. | ||
| 70 | * @param {string} mac Device's mac address | ||
| 71 | */ | ||
| 72 | deleteOfflineData: function (mac){ | ||
| 73 | if (RCTModule != null) { | ||
| 74 | RCTModule.deleteOfflineData(mac); | ||
| 75 | } else { | ||
| 76 | console.log('~~~~~ BG5S deleteOfflineData RCTModule is null') | ||
| 77 | } | ||
| 78 | }, | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Delete the offline data in BG5 device. | ||
| 82 | * @param {string} mac Device's mac address | ||
| 83 | */ | ||
| 84 | getOfflineData: function (mac){ | ||
| 85 | if (RCTModule != null) { | ||
| 86 | RCTModule.getOfflineData(mac); | ||
| 87 | } else { | ||
| 88 | console.log('~~~~~ BG5S getOfflineData RCTModule is null') | ||
| 89 | } | ||
| 90 | }, | ||
| 91 | |||
| 92 | /** | ||
| 93 | * Start measure with specific measure type. | ||
| 94 | * @param {string} mac Device's mac address | ||
| 95 | * @param {number} type Measure type, 1.Measure with blood measure, 2.Measure with control liquid | ||
| 96 | */ | ||
| 97 | startMeasure: function (mac, type){ | ||
| 98 | if (RCTModule != null) { | ||
| 99 | RCTModule.startMeasure(mac, type); | ||
| 100 | } else { | ||
| 101 | console.log('~~~~~ BG5S startMeasure RCTModule is null') | ||
| 102 | } | ||
| 103 | }, | ||
| 104 | |||
| 105 | /** | ||
| 106 | * Get offline data of BG5 device. | ||
| 107 | * @param {string} mac Device's mac address | ||
| 108 | */ | ||
| 109 | adjustOfflineData: function (mac, timeString, originData){ | ||
| 110 | if (RCTModule != null) { | ||
| 111 | RCTModule.adjustOfflineData(mac, timeString, originData); | ||
| 112 | } else { | ||
| 113 | console.log('~~~~~ BG5S adjustOfflineData RCTModule is null') | ||
| 114 | } | ||
| 115 | }, | ||
| 116 | |||
| 117 | setOfflineModel: function (mac, enable) { | ||
| 118 | if (RCTModule != null) { | ||
| 119 | RCTModule.getAllConnectedDevices(mac, enable); | ||
| 120 | } else { | ||
| 121 | console.log('~~~~~ BG5S adjustOfflineData RCTModule is null') | ||
| 122 | } | ||
| 123 | }, | ||
| 124 | |||
| 125 | disConnect: function (mac){ | ||
| 126 | if (RCTModule != null) { | ||
| 127 | if (Platform.OS === 'ios'){ | ||
| 128 | RCTModule.disConnect(mac); | ||
| 129 | } else { | ||
| 130 | RCTModule.disconnect(mac); | ||
| 131 | } | ||
| 132 | } else { | ||
| 133 | console.log('~~~~~ BG5S disConnect RCTModule is null') | ||
| 134 | } | ||
| 135 | }, | ||
| 136 | |||
| 137 | /** | ||
| 138 | * Get all connected BG5S device | ||
| 139 | * | ||
| 140 | * e.g. {"devices":["A4D5783FB00C","A4D5783FFE58"]} | ||
| 141 | */ | ||
| 142 | getAllConnectedDevices: function () { | ||
| 143 | RCTModule.getAllConnectedDevices() | ||
| 144 | }, | ||
| 145 | } | ||
