1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
'use strict';
var {
NativeModules,
DeviceEventEmitter
} = require('react-native');
var AMProfileModule = require('./AMProfileModule.js');
var RCTModule = NativeModules.AM4Module
/**
* @module AM4Module
*/
module.exports = {
Event_Notify: RCTModule.Event_Notify,
/**
* Get AM4 device's IDPS information.
* @param {string} mac Device's mac address
*/
getIdps: function (mac) {
RCTModule.getIdps(mac)
},
/**
* Reset AM4 device.
* @param {string} mac Device's mac address
*/
reset: function (mac) {
RCTModule.reset(mac)
},
/**
* Get user's ID
* @param {string} mac Device's mac address
*/
getUserId: function (mac) {
RCTModule.getUserId(mac)
},
/**
* Get alarms' count
* @param {string} mac Device's mac address
*/
getAlarmClockNum: function (mac) {
RCTModule.getAlarmClockNum(mac)
},
/**
* Get alarm information by id
* @param {string} mac Device's mac address
* @param {array} alarmIDArray Alarm id array to be query.<br/>
* <ul>
* <li>The parameters should be 1, 2, or 3</li>
* <li>The duplicate parameters will be IGNORED</li>
* <li>The query result will be in ascending order of id.</li>
* <li>If specified alarm not set yet, the result will not include the id.</li>
* </ul>
*/
getAlarmClockDetail: function (mac, alarmIDArray) {
RCTModule.getAlarmClockDetail(mac, alarmIDArray)
},
/**
* Set alarm
* @param {string} mac Device's mac address
* @param {number} id Alarm id<br/>
* <b>Range:</b> 1, 2 or 3
* @param {number} hour Alarm hour part<br/>
* <b>Range:</b> [0, 23]
* @param {number} min Alarm minute part<br/>
* <b>Range:</b> [0, 59]
* @param {boolean} isRepeat Indicates whether it will repeat:
* <ul>
* <li>true indicates that it will repeat as the <b>weeks</b> parameter</li>
* <li>false indicates that it will only play one time and <b>IGNORE</b> the <b>weeks</b> parameter</li>
* </ul>
* @param {array} weekArray The days in a week to repeat the alarm, week[0~6] indicates Sun~Sat.<br/>
* And 1 indicates open, 0 indicates close.<br/>
* <b>For example:</b><br/>
* {0, 1, 1, 1, 1, 1, 0} means the alarm will repeat on Mon, Tue, Wed, Thu, Fri.
* @param {boolean} isOn true if want to set the alarm, false to unset it.
*/
setAlarmClock: function (mac, id, hour, min, isRepeat, weekArray, isOn) {
RCTModule.setAlarmClock(mac, id, hour, min, isRepeat, weekArray, isOn)
},
/**
* Delete alarm by id
* @param {string} mac Device's mac address
* @param {number} id Alarm id(should be 1, 2 or 3)
*/
deleteAlarmClock: function (mac, id) {
RCTModule.deleteAlarmClock(mac, id)
},
/**
* Get activity remind setting.
* @param {string} mac Device's mac address
*/
getActivityRemind: function (mac) {
RCTModule.getActivityRemind(mac)
},
/**
* Set/Unset activity remind
* @param {string} mac Device's mac address
* @param {number} hour Activity remind hour part<br/>
* <b>Range:</b> [0, 23]
* @param {number} min Activity remind minute part<br/>
* <b>Range:</b>[0, 59]
* @param {boolean} isOn true if want to set activity remind, false to unset it.
*/
setActivityRemind: function (mac, hour, min, isOn) {
RCTModule.setActivityRemind(mac, hour, min, isOn)
},
/**
* Get device state and battery information
* @param {string} mac Device's mac address
*/
queryAMState: function (mac) {
RCTModule.queryAMState(mac)
},
/**
* Set user ID
* @param {string} mac Device's mac address
* @param {number} id new user id <br/>
* <b>Range:</b> [1, 2147483647(0x7FFFFFFF)]
*/
setUserId: function (mac, id) {
if (id < 1 || id > 0x7FFFFFFF) {
let result = {
"mac": mac,
"type": "AM4",
"action" : AMProfileModule.ACTION_ERROR_AM,
}
result[AMProfileModule.ERROR_NUM_AM] = AMProfileModule.ERROR_ID_ILLEGAL_ARGUMENT
result[AMProfileModule.ERROR_DESCRIPTION_AM] = 'setUserId() parameter id should be in the range [1, 2147483647(0x7FFFFFFF)]'
DeviceEventEmitter.emit(RCTModule.Event_Notify, result)
return
}
RCTModule.setUserId(mac, id)
},
/**
* Get user information
* @param {string} mac Device's mac address
*/
getUserInfo: function (mac) {
RCTModule.getUserInfo(mac)
},
/**
* Set user's BMR
* @param {string} mac Device's mac address
* @param {number} bmr User's BMR<br/>
* <b>Range:</b> [1, 32767(0x7FFF)]
*/
setUserBmr: function (mac, bmr) {
RCTModule.setUserBmr(mac, bmr)
},
/**
* Get the activity data.
* @param {string} mac Device's mac address
*/
syncActivityData: function (mac) {
RCTModule.syncActivityData(mac)
},
/**
* Get the sleep data.
* @param {string} mac Device's mac address
*/
syncSleepData: function (mac) {
RCTModule.syncSleepData(mac)
},
/**
* Get current time activity data.
* @param {string} mac Device's mac address
*/
syncRealData: function (mac) {
RCTModule.syncRealData(mac)
},
/**
* Set the system time to AM device.
* @param {string} mac Device's mac address
*/
syncRealTime: function (mac) {
RCTModule.syncRealTime(mac)
},
/**
* Set hour mode
* @param {string} mac Device's mac address
* @param {number} hourMode The value should be one of following:
* <ul>
* <li>{@link module:AMProfileModule.AM_SET_12_HOUR_MODE AMProfileModule.AM_SET_12_HOUR_MODE(0)}</li>
* <li>{@link module:AMProfileModule.AM_SET_24_HOUR_MODE AMProfileModule.AM_SET_24_HOUR_MODE(1)}</li>
* <li>{@link module:AMProfileModule.AM_SET_EXCEPT_EUROPE_12_HOUR_MODE AMProfileModule.AM_SET_EXCEPT_EUROPE_12_HOUR_MODE(2)}</li>
* <li>{@link module:AMProfileModule.AM_SET_EUROPE_12_HOUR_MODE AMProfileModule.AM_SET_EUROPE_12_HOUR_MODE(3)}</li>
* <li>{@link module:AMProfileModule.AM_SET_EXCEPT_EUROPE_24_HOUR_MODE AMProfileModule.AM_SET_EXCEPT_EUROPE_24_HOUR_MODE(4)}</li>
* <li>{@link module:AMProfileModule.AM_SET_EUROPE_24_HOUR_MODE AMProfileModule.AM_SET_EUROPE_24_HOUR_MODE(5)}</li>
* </ul>
*/
setHourMode: function (mac, hourMode) {
RCTModule.setHourMode(mac, hourMode)
},
/**
* Get hour mode
* @param {string} mac Device's mac address
*/
getHourMode: function (mac) {
RCTModule.getHourMode(mac)
},
/**
* Disconnect device
* @param {string} mac Device's mac address
*/
disconnect: function (mac) {
RCTModule.disconnect(mac)
},
/**
* Set user information
* @param {string} mac Device's mac address
* @param {number} age User's age<br/>
* <b>Range:</b> [1, 255]
* @param {number} height User's height(int in cm)<br/>
* <b>Range:</b> [1, 255]
* @param {number} weight User's weight(float)<br/>
* <b>Range:</b> [1.0, 255.0]
* @param {number} gender User's gender<br/>
* <b>Value:</b>
* <ul>
* <li>{@link module:AMProfileModule.AM_SET_FEMALE AMProfileModule.AM_SET_FEMALE(0)}</li>
* <li>{@link module:AMProfileModule.AM_SET_MALE AMProfileModule.AM_SET_MALE(1)}</li>
* </ul>
* @param {number} unit Distance's unit type(kilometre or miles)<br/>
* <b>Value:</b>
* <ul>
* <li>{@link module:AMProfileModule.AM_SET_UNIT_IMPERIAL_STANDARD AMProfileModule.AM_SET_UNIT_IMPERIAL_STANDARD(0)} (miles)</li>
* <li>{@link module:AMProfileModule.AM_SET_UNIT_METRIC AMProfileModule.AM_SET_UNIT_METRIC(1)} (kilometre)</li>
* </ul>
* @param {number} target The goal of maximum steps<br/>
* <b>Range:</b> [4, 2147483647(0x7FFFFFFF)]
* @param {number} activityLevel The level of activity strength<br/>
* <ul>
* <li>1 indicates sedentary</li>
* <li>2 indicates active</li>
* <li>3 indicates very active</li>
* </ul>
* @param {number} min swim target time(in minutes)<br/>
* <b>Range:</b> [1, 1439(23 * 60 + 59)]
*/
setUserInfo: function (mac, age, height, weight, gender, unit, target, activityLevel, min) {
RCTModule.setUserInfo(mac, age, height, weight, gender, unit, target, activityLevel, min)
},
/**
* Get stage report data
* @param {string} mac Device's mac address
*/
syncStageReportData: function (mac) {
RCTModule.syncStageReportData(mac)
},
/**
* Send random number to device to prepare for binding, the number will be displayed on the device.
* @param {string} mac Device's mac address
*/
sendRandom: function (mac) {
RCTModule.sendRandom(mac)
},
/**
* Get swim parameters
* @param {string} mac Device's mac address
*/
checkSwimPara: function (mac) {
RCTModule.checkSwimPara(mac)
},
/**
* Set swim parameters
* @param {string} mac Device's mac address
* @param {boolean} isOpen Set true to open swim function, set false to close it.
* @param {number} poolLength the swimming pool's length.<br/>
* <b>Range:</b> [1, 255]
* @param {number} hours The cut out time's hour part<br/>
* <b>Range:</b> [0, 23]
* @param {number} minutes The cut out time's minute part<br/>
* Range[0, 59]
* @param {number} unit The pool length's unit type(metre or yard).
* <ul>
* <li>{@link module:AMProfileModule.AM_SET_UNIT_IMPERIAL_STANDARD AMProfileModule.AM_SET_UNIT_IMPERIAL_STANDARD(0)} (yard)</li>
* <li>{@link module:AMProfileModule.AM_SET_UNIT_METRIC AMProfileModule.AM_SET_UNIT_METRIC(1)} (metre)</li>
* </ul>
*/
setSwimPara: function (mac, isOpen, poolLength, hours, minutes, unit) {
RCTModule.setSwimPara(mac, isOpen, poolLength, hours, minutes, unit)
},
/**
* Get all connected AM4 device
*
* e.g. {"devices":["A4D5783FB00C","A4D5783FFE58"]}
*/
getAllConnectedDevices: function () {
RCTModule.getAllConnectedDevices()
},
}
|