summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/module/iHealthDeviceManagerModule.js
diff options
context:
space:
mode:
authorhc <haocheng.xie@respiree.com>2026-04-13 15:17:52 +0800
committerhc <haocheng.xie@respiree.com>2026-04-13 15:17:52 +0800
commitd6d9a09d505d11148599a95a5be3e1351edbe0ac (patch)
treea5f5891983d1ff207e99f683a5e151519cef4980 /libs/ihealth-sdk/module/iHealthDeviceManagerModule.js
parente4fb9966e762852bf17f21c8406501d42fae0b61 (diff)
Local iHealth SDK, device detail screen, iOS event fixes
Diffstat (limited to 'libs/ihealth-sdk/module/iHealthDeviceManagerModule.js')
-rw-r--r--libs/ihealth-sdk/module/iHealthDeviceManagerModule.js277
1 files changed, 277 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/module/iHealthDeviceManagerModule.js b/libs/ihealth-sdk/module/iHealthDeviceManagerModule.js
new file mode 100644
index 0000000..cee7b03
--- /dev/null
+++ b/libs/ihealth-sdk/module/iHealthDeviceManagerModule.js
@@ -0,0 +1,277 @@
1'use strict';
2
3
4var {NativeModules,Platform} = require('react-native');
5
6var RCTModule = NativeModules.iHealthDeviceManagerModule
7
8/**
9 * @module iHealthDeviceManagerModule
10 */
11module.exports = {
12 //Device Type
13 AM3S: RCTModule.AM3S,
14 /**
15 * Device type number for AM4(4) 1 << 2
16 */
17 AM4: RCTModule.AM4,
18 /**
19 * Device type number for PO3(8) 1 << 3
20 */
21 PO3: RCTModule.PO3,
22 /**
23 * Device type number for BP5(33554432) 1 << 25
24 */
25 BP5: RCTModule.BP5,
26 BP5S: RCTModule.BP5S,
27 /**
28 * Device type number for BP3L(32) 1 << 5
29 */
30 BP3L: RCTModule.BP3L,
31 /**
32 * Device type number for BP7S(16777216) 1 << 24
33 */
34 BP7: RCTModule.BP7,
35 BP7S: RCTModule.BP7S,
36 /**
37 * Device type number for Bp550BT(128) 1 << 7
38 */
39 KN550: RCTModule.KN550,
40 /**
41 * Device type number for HS2(131072) 1 << 17
42 */
43 HS2: RCTModule.HS2,
44 /**
45 * Device type number for HS4S(268435456) 1 << 28
46 */
47 HS4S: RCTModule.HS4S,
48 HS6: 10086,
49 /**
50 * Device type number for BG1(110)
51 */
52 BG1: RCTModule.BG1,
53 /**
54 * Device type number for BG5(4294967296) 1 << 32
55 */
56 BG5: RCTModule.BG5,
57
58 BG5S: RCTModule.BG5S,
59
60 ECG3: RCTModule.ECG3,
61
62 ECG3USB: RCTModule.ECG3USB,
63
64 BTM: RCTModule.BTM,
65
66 TS28B: RCTModule.TS28B,
67
68 NT13B: RCTModule.NT13B,
69
70 HS2S: RCTModule.HS2S,
71
72 BG1S: RCTModule.BG1S,
73
74 /**
75 * Notify event type for scan device result.("event_scan_device")
76 */
77 Event_Scan_Device: RCTModule.Event_Scan_Device,
78 /**
79 * Notify event type for scan action finish.("event_scan_finish")
80 */
81 Event_Scan_Finish: RCTModule.Event_Scan_Finish,
82 /**
83 * Notify event type for connect device successfully.("event_device_connected")
84 */
85 Event_Device_Connected: RCTModule.Event_Device_Connected,
86 /**
87 * Notify event type for connect device failed.("event_device_connect_failed")
88 */
89 Event_Device_Connect_Failed: RCTModule.Event_Device_Connect_Failed,
90 /**
91 * Notify event type for device disconnect.("event_device_disconnect")
92 */
93 Event_Device_Disconnect: RCTModule.Event_Device_Disconnect,
94 /**
95 * Notify event type for authenticate result.("event_authenticate_result")
96 */
97 Event_Authenticate_Result: RCTModule.Event_Authenticate_Result,
98
99
100 /**
101 * Authentication the configure information.
102 * Attentation: Please register to receive event(iHealthDeviceManagerModel.Event_Authenticate_Result) before call the api.
103 * @param {string} userName User's user name you use when you sign up
104 * @param {string} clientID User's client id.
105 * @param {string} clientSecret User's client secret.
106 * @return {callback} Callback with a json object. Eg.{"authen":2}
107 * <p/><li/>The measurement via SDK will be operated in the case of 1-3, and there is 10-day tryout if SDK Verification failed in case of SDK cannot connect Internet or Userid/clientID/clientSecret verification failed or SDK has not been authorized or User has not been authorized.
108 * SDK is fully functional during tryout period, but will be terminated without verification through Internet after 10 days.The interface needs to be re-called after analyzing the return parameters. SDK application requires Internet connection.
109 * If you encounter user status 4 with full internet access, please send Userid/clientID/clientSecret to this email sdk@ihealthlabs.com.cn to get help.
110 * <p/>
111 * The result value and description will be as below:
112 * <table style="width:200px;" cellpadding="2" cellspacing="0" border="1" bordercolor="#000000">
113 * <tbody>
114 * <tr><td>Value</td><td>Description</td></tr>
115 * <tr><td>1</td><td>New-user registration succeeded.</td></tr>
116 * <tr><td>2</td><td>User login succeeded.</td></tr>
117 * <tr><td>3</td><td>The user is iHealth user as well, measurement via SDK has been activated, and the data from the measurement belongs to the user.</td></tr>
118 * <tr><td>4</td><td>Testing without Internet connection succeeded.</td></tr>
119 * <tr><td>5</td><td>Userid/clientID/clientSecret verification failed.</td></tr>
120 * <tr><td>6</td><td>SDK has not been authorized.</td></tr>
121 * <tr><td>7</td><td>User has not been authorized.</td></tr>
122 * <tr><td>8</td><td>Internet error, verification failed.</td></tr>
123 * </tbody>
124 * </table>
125 */
126 authenConfigureInfo: function (userName, clientID, clientSecret) {
127 RCTModule.authenConfigureInfo(userName, clientID, clientSecret)
128 },
129 /**
130 * Authencation the appSecret
131 * @param {string} appSecret
132 * @return {callback} Callback with a boolen object. true:authencation success false:authencation failed .<br/>
133 */
134
135 authenAppSecret: function (appSecret, callback) {
136 RCTModule.authenAppSecret(appSecret, callback)
137 },
138
139 /**
140 * Start discovery iHealth device with type
141 * Attentation: Please register to receive event(iHealthDeviceManagerModel.Event_Scan_Device) before call the api.
142 *
143 * @param {number} type The type to be discovered.<br/>
144 * e.g. startDiscovery(iHealthDeviceManagerModule.AM4) will discover AM4 devices.<br/>
145 */
146 startDiscovery: function (type) {
147 RCTModule.startDiscovery(type)
148 },
149
150
151 /**
152 * Stop discovery iHealth device
153 * Attentation: Please register to receive event(iHealthDeviceManagerModel.Event_Scan_Finish) before call the api.
154 */
155 stopDiscovery: function () {
156 RCTModule.stopDiscovery()
157 },
158
159 /**
160 * Connect iHealth device
161 * Attentation: Please register to receive event(iHealthDeviceManagerModel.Event_Device_Connected or iHealthDeviceManagerModel.Event_Device_Connect_Failed) before call the api.
162 * @param {string} mac The mac address of device to be connected.<br/>
163 * e.g. "004D3208D5D4"
164 * @param {string} type Device type string.
165 * @return {callback} Callback with events {@link module:iHealthDeviceManagerModule.Event_Device_Connected Event_Device_Connected}
166 * or {@link module:iHealthDeviceManagerModule.Event_Device_Connect_Failed Event_Device_Connect_Failed}.
167 * And the mesage is format as {"errorid":0,"type":"BP5","mac":"8CDE52B62521"}
168 * <p/>The key and value in the message will be as below:
169 * <table style="width:200px;" cellpadding="2" cellspacing="0" border="1" bordercolor="#000000">
170 * <tbody>
171 * <tr><td>Key</td><td>value</td></tr>
172 * <tr><td>errorid</td><td>This value is to reflect the state of the system when the connection fails. Normally, it's 0.
173 Please note, this field is different from the ErrorId of the DeviceProfileModule.</td></tr>
174 * <tr><td>type</td><td>The device type. Eg.BP5</td></tr>
175 * <tr><td>mac</td><td>The mac address.</td></tr>
176 * </tbody>
177 * </table>
178 */
179 connectDevice: function (mac, type) {
180 RCTModule.connectDevice(mac, type)
181 },
182
183 /**
184 * Connect BTM device
185 * Attentation: Please register to receive event(iHealthDeviceManagerModel.Event_Device_Connected or iHealthDeviceManagerModel.Event_Device_Connect_Failed) before call the api.
186 * @param {string} mac The mac address of device to be connected.<br/>
187 * e.g. "004D3208D5D4"
188 * @param {string} type Device type string.
189 * @return {callback} Callback with events {@link module:iHealthDeviceManagerModule.Event_Device_Connected Event_Device_Connected}
190 * or {@link module:iHealthDeviceManagerModule.Event_Device_Connect_Failed Event_Device_Connect_Failed}.
191 * And the mesage is format as {"errorid":0,"type":"BP5","mac":"8CDE52B62521"}
192 * <p/>The key and value in the message will be as below:
193 * <table style="width:200px;" cellpadding="2" cellspacing="0" border="1" bordercolor="#000000">
194 * <tbody>
195 * <tr><td>Key</td><td>value</td></tr>
196 * <tr><td>errorid</td><td>This value is to reflect the state of the system when the connection fails. Normally, it's 0.
197 Please note, this field is different from the ErrorId of the DeviceProfileModule.</td></tr>
198 * <tr><td>username</td><td>the identification of the user, could be the form of email address or mobile phone</td></tr>
199 * <tr><td>mac</td><td>a valid FDIR-V3 mac.</td></tr>
200 * <tr><td>type</td><td>TYPE_FDIR_V3</td></tr>
201 * <tr><td>unit</td><td>Temperature unit.1: c 2: f</td></tr>
202 * <tr><td>measureTarget</td><td>Measuring target.1: body 2: object</td></tr>
203 * <tr><td>functionTarget</td><td>Offline target.1: offline 2: online</td></tr>
204 * <tr><td>hour</td><td>Standby time hours. eg. 24</td></tr>
205 * <tr><td>minute</td><td>Standby time minutes. eg.60</td></tr>
206 * <tr><td>second</td><td>Standby time seconds. eg.60</td></tr>
207 * </tbody>
208 * </table>
209 */
210 connectTherm: function (username, mac, type, unit, measureTarget, functionTarget, hour, minute, second) {
211 RCTModule.connectTherm(username, mac, type, unit, measureTarget, functionTarget, hour, minute, second)
212 },
213
214
215 /**
216 * Get information for iHealth device
217 *
218 * @param {string} mac The mac address of device.<br/>
219 * e.g. "004D3208D5D4"
220 * @return {callback} Callback with a map object.<br/>
221 * e.g. {"protocolstring":"com.jiuan.AMV12","accessoryname":"AM4","firmwareversion":"138","hardwareversion":"100","manufacture":"iHealth","serialnumber":"004D32079148","modenumber":"AM4 11070"}
222 */
223 getDevicesIDPS: function (mac, callback) {
224 RCTModule.getDevicesIDPS(mac, callback)
225 },
226
227 /**
228 * [Only for android] Disconnect an iHealth device that has been connected or in connecting status.
229 * Attentation: Please register to receive event(iHealthDeviceManagerModel.Event_Device_Disconnect or iHealthDeviceManagerModel.Event_Device_Connect_Failed) before call the api.
230 * @param {string} mac The mac address of device to be connected or in connecting.<br/>
231 * e.g. "004D3208D5D4"
232 * @param {string} type Device type string.
233 * @return {callback} Callback with events {@link module:iHealthDeviceManagerModule.Event_Device_Disconnect Event_Device_Disconnect}
234 * or {@link module:iHealthDeviceManagerModule.Event_Device_Connect_Failed Event_Device_Connect_Failed}.
235 * And the mesage is format as {"errorid":0,"type":"BP5","mac":"8CDE52B62521"}
236 * <p/>The key and value in the message will be as below:
237 * <table style="width:200px;" cellpadding="2" cellspacing="0" border="1" bordercolor="#000000">
238 * <tbody>
239 * <tr><td>Key</td><td>value</td></tr>
240 * <tr><td>errorid</td><td>This value is to reflect the state of the system when the connection fails. Normally, it's 0.
241 Please note, this field is different from the ErrorId of the DeviceProfileModule.</td></tr>
242 * <tr><td>type</td><td>The device type. Eg.BP5</td></tr>
243 * <tr><td>mac</td><td>The mac address.</td></tr>
244 * </tbody>
245 * </table>
246 */
247 disconnectDevice: function (mac, type) {
248 RCTModule.disconnectDevice(mac, type)
249 },
250
251 /**
252 * If you want to use the iHealth Device, you must first call authentication method before connect a device.
253 * To get a license, please refer to [iHealth Developer](https://dev.ihealthlabs.com).
254 * @param license The license file name is like 'com_example_android.pem'. Download the license file from the website, integrate to your native project.
255 * For android: should save the license file to the /assets/ folder.
256 * @return {callback} Callback with a map object.<br/>
257 * e.g. {"access": true}
258 */
259 sdkAuthWithLicense: function (license) {
260 RCTModule.sdkAuthWithLicense(license)
261 },
262
263 /**
264 * get the phone is support OTG or not
265 * @return true or false
266 */
267
268 isSupportOTG: function (callback){
269 if (Platform.OS === 'ios'){
270 callback(true);
271 } else {
272 RCTModule.isSupportOTG(callback);
273 }
274
275 },
276
277}