summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/module/BG5Module.js
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ihealth-sdk/module/BG5Module.js')
-rwxr-xr-xlibs/ihealth-sdk/module/BG5Module.js184
1 files changed, 184 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/module/BG5Module.js b/libs/ihealth-sdk/module/BG5Module.js
new file mode 100755
index 0000000..9e1f895
--- /dev/null
+++ b/libs/ihealth-sdk/module/BG5Module.js
@@ -0,0 +1,184 @@
1/**
2 * Created by gaoyuanlong on 16/11/17.
3 */
4'use strict';
5
6
7var {NativeModules} = require('react-native');
8
9var RCTModule = NativeModules.BG5Module
10
11/**
12 * @module BG5Module
13 */
14module.exports = {
15 Event_Notify: RCTModule.Event_Notify,
16
17 /**
18 * Keep BG5 connecting.
19 * @param {string} mac Device's mac address
20 */
21 holdLink: function (mac){
22 if (RCTModule != null) {
23 RCTModule.holdLink(mac);
24 } else {
25 console.log('~~~~~ BG5 holdLink RCTModule is null')
26 }
27 },
28
29 /**
30 * Get battery level of BG5 device.
31 * @param {string} mac Device's mac address
32 */
33 getBattery: function (mac){
34 if (RCTModule != null) {
35 RCTModule.getBattery(mac);
36 } else {
37 console.log('~~~~~ BG5 getBattery RCTModule is null')
38 }
39 },
40
41 /**
42 * Set time to BG5 device.
43 * @param {string} mac Device's mac address
44 */
45 setTime: function (mac){
46 if (RCTModule != null) {
47 RCTModule.setTime(mac);
48 } else {
49 console.log('~~~~~ BG5 setTime RCTModule is null')
50 }
51 },
52
53 /**
54 * Set unit to BG5 device.
55 * @param {string} mac Device's mac address
56 * @param {number} type 1:mmol/L 2:mg/dL
57 */
58 setUnit: function (mac, type){
59 if (RCTModule != null) {
60 RCTModule.setUnit(mac, type);
61 } else {
62 console.log('~~~~~ BG5 setUnit RCTModule is null')
63 }
64 },
65
66 /**
67 * Start measure with specific measure type.
68 * @param {string} mac Device's mac address
69 * @param {number} type Measure type, 1.Measure with blood measure, 2.Measure with control liquid
70 */
71 startMeasure: function (mac, type){
72 if (RCTModule != null) {
73 RCTModule.startMeasure(mac, type);
74 } else {
75 console.log('~~~~~ BG5 startMeasure RCTModule is null')
76 }
77 },
78
79 /**
80 * Get offline data of BG5 device.
81 * @param {string} mac Device's mac address
82 */
83 getOfflineData: function (mac){
84 if (RCTModule != null) {
85 RCTModule.getOfflineData(mac);
86 } else {
87 console.log('~~~~~ BG5 getOffineData RCTModule is null')
88 }
89 },
90
91 /**
92 * Delete the offline data in BG5 device.
93 * @param {string} mac Device's mac address
94 */
95 deleteOfflineData: function (mac){
96 if (RCTModule != null) {
97 RCTModule.deleteOfflineData(mac);
98 } else {
99 console.log('~~~~~ BG5 deleteOfflineData RCTModule is null')
100 }
101 },
102
103 /**
104 * Set bottle message to BG5 device.
105 * @param {string} mac Device's mac address
106 * @param {number} stripType GOD(value 1) or GDH(value 2)
107 * @param {number} measureType measure with blood(value 1) or measure with control liquid(value 2)
108 * @param {number} QRCode the QR code send to the deivce(GOD strip), GDH ignore
109 * @param {number} stripNum the left count of strip, range [1, 255]
110 * @param {string} overDate the expire time of the strip, format: yyyy-MM-dd, should be valid
111 */
112 setBottleMessage: function (mac, stripType, measureType, QRCode, stripNum, overDate){
113 if (RCTModule != null) {
114 RCTModule.setBottleMessageWithInfo(mac, stripType, measureType, QRCode, stripNum, overDate);
115 } else {
116 console.log('~~~~~ BG5 setBottleMessage RCTModule is null')
117 }
118 },
119
120 /**
121 * Get bottle message from BG5 device.
122 * @param {string} mac Device's mac address
123 */
124 getBottleMessage: function (mac){
125 if (RCTModule != null) {
126 RCTModule.getBottleMessage(mac);
127 } else {
128 console.log('~~~~~ BG5 getBottleMessage RCTModule is null')
129 }
130 },
131
132 /**
133 * Set bottleId to BG5 device.
134 * @param {string} mac Device's mac address
135 * @param {string} ID UserID set to device
136 */
137 setBottleID: function (mac, ID){
138 if (RCTModule != null) {
139 RCTModule.setBottleId(mac, ID);
140 } else {
141 console.log('~~~~~ BG5 setBottleID RCTModule is null')
142 }
143 },
144
145 /**
146 * Get bottleId from BG5 device.
147 * @param {string} mac Device's mac address
148 */
149 getBottleID: function (mac){
150 if (RCTModule != null) {
151 RCTModule.getBottleId(mac);
152 } else {
153 console.log('~~~~~ BG5 getBottleID RCTModule is null')
154 }
155 },
156
157 disConnect: function (mac){
158 if (RCTModule != null) {
159 RCTModule.disConnect(mac);
160 } else {
161 console.log('~~~~~ BG5 getBottleID RCTModule is null')
162 }
163 },
164
165 /**
166 * Parse bottle info from QRCode, include strip expire time,strip number,bottle id
167 * @param {string} QRCode
168 */
169 getBottleInfoFromQR: function(QRCode){
170 if (RCTModule != null) {
171 RCTModule.getBottleInfoFromQR(QRCode);
172 }else {
173 console.log('~~~~~ RCTModule is null')
174 }
175 },
176 /**
177 * Get all connected BG5 device
178 *
179 * e.g. {"devices":["A4D5783FB00C","A4D5783FFE58"]}
180 */
181 getAllConnectedDevices: function () {
182 RCTModule.getAllConnectedDevices()
183 },
184}