summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/doc/am3s.md
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ihealth-sdk/doc/am3s.md')
-rw-r--r--libs/ihealth-sdk/doc/am3s.md388
1 files changed, 388 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/doc/am3s.md b/libs/ihealth-sdk/doc/am3s.md
new file mode 100644
index 0000000..e9446de
--- /dev/null
+++ b/libs/ihealth-sdk/doc/am3s.md
@@ -0,0 +1,388 @@
1# AM3S Workflow
2
3## Import AM3S Module
4
5```js
6import {
7 AM3SModule,
8 AMProfileModule
9} from '@ihealth/ihealthlibrary-react-native';
10```
11
12## APIs
13
14### Add and remove listener
15
16```js
17// add
18notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
19 console.log(event);
20});
21
22// remove
23notifyListener.remove();
24```
25
26### get all connected am3s devices
27
28```js
29AM3SModule.getAllConnectedDevices();
30```
31
32### disconnect a am3s devices
33
34```js
35AM3SModule.disconnect(mac);
36```
37
38### erase am3s memory
39
40```js
41AM3SModule.reset(mac);
42
43// response
44notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
45 if (event.action === AMProfileModule.ACTION_RESET_AM) {
46 if (0 === event[AMProfileModule.RESET_AM]) {
47 console.log('reset fail');
48 } else if (1 === event[AMProfileModule.RESET_AM]) {
49 console.log('reset success');
50 }
51 }
52});
53```
54
55### get the user id bound to the device
56
57```js
58AM3SModule.getUserId(mac);
59
60// response
61notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
62 if (event.action === AMProfileModule.ACTION_USERID_AM) {
63 console.log(event[AMProfileModule.USERID_AM]);
64 }
65});
66```
67
68### set the user id to the device
69
70```js
71// id: user id, the range is 0~0x7fffffff
72AM3SModule.setUserId(mac, id);
73
74// response
75notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
76 if (event.action === AMProfileModule.ACTION_SET_USERID_SUCCESS_AM) {
77 console.log('set success');
78 }
79});
80```
81
82### setAlarmClock
83
84```js
85
86/**
87 * id: alarm clock id, you can set up to 3 alarm clocks
88 * hour: clock hour
89 * min: clock minates
90 * isRepeat: one time or repeat
91 * weeks: available on the day of the week
92 * isOn: open or close
93 */
94
95AM3SModule.setAlarmClock(mac, 1, 12, 0, true, [1, 1, 1, 1, 1, 0, 0], false);
96
97// response
98notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
99 if (event.action === AMProfileModule.ACTION_SET_ALARMINFO_SUCCESS_AM) {
100 console.log('set success');
101 }
102});
103```
104
105### get alarm clock ids
106
107```js
108AM3SModule.getAlarmClockNum(mac);
109
110// response
111notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
112 if (event.action === AMProfileModule.ACTION_SET_ALARMINFO_SUCCESS_AM) {
113 console.log(event[AMProfileModule.GET_ALARMNUM_AM]); // e.g. 3
114 console.log(event[AMProfileModule.GET_ALARMNUM_ID_AM]); // e.g. [1, 2, 3]
115 }
116});
117```
118
119### get alarm clock detail
120
121```js
122AM3SModule.getAlarmClockDetail(mac, [1, 3, 2]);
123
124// response
125notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
126 if (event.action === AMProfileModule.ACTION_GET_ALARMINFO_AM) {
127 let dataArray = event[BPProfileModule.GET_ALARM_CLOCK_DETAIL];
128 if (dataArray == undefined) {
129 result = "There is not offline data in device"
130 }else {
131 for (let i = 0; i < dataArray.length; i++) {
132 let offlineData = dataArray[i];
133 console.log(offlineData[AMProfileModule.GET_ALARM_ID_AM]);
134 console.log(offlineData[AMProfileModule.GET_ALARM_TIME_AM]);
135 console.log(offlineData[AMProfileModule.GET_ALARM_ISREPEAT_AM]);
136 console.log(offlineData[AMProfileModule.GET_ALARM_WEEK_AM]);
137 console.log(offlineData[AMProfileModule.GET_ALARM_ISON_AM]);
138 }
139 }
140 }
141});
142```
143
144### delete alarm clock by id
145
146```js
147AM3SModule.deleteAlarmClock(mac, 1);
148
149// response
150notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
151 if (event.action === AMProfileModule.ACTION_DELETE_ALARM_SUCCESS_AM) {
152 console.log('delete success');
153 }
154});
155```
156
157### set activity reminder interval
158
159```js
160/**
161 * hour
162 * min
163 * isOn: open or close
164 */
165AM3SModule.setActivityRemind(mac, 0, 30, false);
166
167// response
168notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
169 if (event.action === AMProfileModule.ACTION_SET_ACTIVITYREMIND_SUCCESS_AM) {
170 console.log('set success');
171 }
172});
173```
174
175### get activity reminder interval
176
177```js
178AM3SModule.getActivityRemind(mac);
179
180// response
181notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
182 if (event.action === AMProfileModule.ACTION_GET_ACTIVITY_REMIND_AM) {
183 console.log('get success');
184 }
185});
186```
187
188### get am3s information
189
190```js
191AM3SModule.queryAMState(mac);
192
193// response
194notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
195 if (event.action === AMProfileModule.ACTION_QUERY_STATE_AM) {
196 // 0 indicates waist
197 // 1 indicates wrist
198 // 2 indicates sleep
199 console.log(event[AMProfileModule.QUERY_STATE_AM]);
200 // battery level 0~10
201 console.log(event[AMProfileModule.QUERY_BATTERY_AM]);
202 }
203});
204```
205
206### set user id to the am3s device
207
208```js
209// The user id range is from 0 to 0x7fffffff
210AM3SModule.setUserId(mac, 8);
211
212// response
213notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
214 if (event.action === AMProfileModule.ACTION_SET_USERID_SUCCESS_AM) {
215 console.log('set success');
216 }
217});
218```
219
220### set user information to the am3s device
221
222```js
223/**
224 * age
225 * height(cm)
226 * weight(lbs)
227 * gender 0: female, 1: male
228 * unit 0: miles, 1: kilometre
229 * target the goal of steps, the range is from 4 ~ 65535
230 * activityLevel 1: sedentary, 2: active, 3: very active
231 */
232AM3SModule.setUserInfo(mac, 25, 183, 80, AMProfileModule.AM_SET_MALE, AMProfileModule.AM_SET_UNIT_METRIC, 10000, 1, 30);
233
234// response
235notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
236 if (event.action === AMProfileModule.ACTION_SET_USERINFO_SUCCESS_AM) {
237 console.log('set success');
238 }
239});
240```
241
242### get user information stored in the am3s device
243
244```js
245AM3SModule.getUserInfo(mac);
246
247// response
248notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
249 if (event.action === AMProfileModule.ACTION_GET_USERINFO_AM) {
250 console.log(event[AMProfileModule.GET_USER_AGE_AM]);
251 console.log(event[AMProfileModule.GET_USER_STEP_AM]);
252 console.log(event[AMProfileModule.GET_USER_HEIGHT_AM]);
253 console.log(event[AMProfileModule.GET_USER_SEX_AM]);
254 console.log(event[AMProfileModule.GET_USER_WEIGHT_AM]);
255 console.log(event[AMProfileModule.GET_USER_UNIT_AM]);
256 console.log(event[AMProfileModule.GET_USER_AGE_AM]);
257 console.log(event[AMProfileModule.GET_USER_TARGET1_AM]);
258 console.log(event[AMProfileModule.GET_USER_TARGET2_AM]);
259 console.log(event[AMProfileModule.GET_USER_TARGET3_AM]);
260 }
261});
262```
263
264### set bmr to the am3s device
265
266```js
267// bmr Basal Metabolic Rate
268AM3SModule.setUserBmr(mac, 2000);
269
270// response
271notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
272 if (event.action === AMProfileModule.ACTION_SET_BMR_SUCCESS_AM) {
273 console.log('set success');
274 }
275});
276```
277
278### get activity steps
279
280```js
281AM3SModule.syncActivityData(mac);
282
283// response
284notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
285 if (event.action === AMProfileModule.ACTION_SYNC_ACTIVITY_DATA_AM) {
286 let dataArray = event[AMProfileModule.SYNC_ACTIVITY_EACH_DATA_AM];
287 if (dataArray == undefined) {
288 result = "There is not offline data in device"
289 }else {
290 for (let i = 0; i < dataArray.length; i++) {
291 let offlineData = dataArray[i];
292 console.log(offlineData[AMProfileModule.SYNC_ACTIVITY_DATA_TIME_AM]);
293 console.log(offlineData[AMProfileModule.SYNC_ACTIVITY_DATA_STEP_AM]);
294 console.log(offlineData[AMProfileModule.SYNC_ACTIVITY_DATA_CALORIE_AM]);
295 console.log(offlineData[AMProfileModule.SYNC_ACTIVITY_DATA_STEP_LENGTH_AM]);
296 console.log(offlineData[AMProfileModule.DATAID]);
297 }
298 }
299 }
300});
301```
302
303### get current activity steps
304
305```js
306AM3SModule.syncRealData(mac);
307
308// response
309notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
310 if (event.action === AMProfileModule.ACTION_SYNC_REAL_DATA_AM) {
311 console.log(offlineData[AMProfileModule.SYNC_REAL_STEP_AM]);
312 console.log(offlineData[AMProfileModule.SYNC_REAL_CALORIE_AM]);
313 console.log(offlineData[AMProfileModule.SYNC_REAL_TOTALCALORIE_AM]);
314 }
315});
316```
317
318### set current time to am3s device
319
320```js
321AM3SModule.syncRealData(mac);
322
323// response
324notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
325 if (event.action === AMProfileModule.ACTION_SYNC_TIME_SUCCESS_AM) {
326 console.log('set success');
327 }
328});
329```
330
331### set hour mode (12 or 24) to am3s device
332
333```js
334/**
335 * AMProfileModule.AM_SET_12_HOUR_MODE(0)
336 * AMProfileModule.AM_SET_24_HOUR_MODE(1)
337 * AMProfileModule.AM_SET_EXCEPT_EUROPE_12_HOUR_MODE(2)
338 * AMProfileModule.AM_SET_EUROPE_12_HOUR_MODE(3)
339 * AMProfileModule.AM_SET_EXCEPT_EUROPE_24_HOUR_MODE(4)
340 * AMProfileModule.AM_SET_EUROPE_24_HOUR_MODE
341 **/
342AM3SModule.setHourMode(mac, AMProfileModule.AM_SET_24_HOUR_MODE);
343
344// response
345notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
346 if (event.action === AMProfileModule.ACTION_SET_HOUR_MODE_SUCCESS_AM) {
347 console.log('set success');
348 }
349});
350```
351
352### get hour mode (12 or 24) from am3s device
353
354
355```js
356AM3SModule.getHourMode(mac);
357
358// response
359notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
360 if (event.action === AMProfileModule.ACTION_GET_HOUR_MODE_AM) {
361 console.log(event[AMProfileModule.GET_HOUR_MODE_AM]);
362 }
363});
364```
365
366### get sleep data stored in the am3s
367
368```js
369AM3SModule.syncSleepData(mac);
370
371// response
372notifyListener = DeviceEventEmitter.addListener(AM3SModule.Event_Notify, (event) => {
373 if (event.action === AMProfileModule.ACTION_SYNC_SLEEP_DATA_AM) {
374 let dataArray = event[AMProfileModule.SYNC_SLEEP_DATA_AM];
375 if (dataArray == undefined) {
376 result = "There is not offline data in device"
377 }else {
378 for (let i = 0; i < dataArray.length; i++) {
379 let offlineData = dataArray[i];
380 console.log(offlineData[AMProfileModule.SYNC_SLEEP_EACH_DATA_AM]);
381 console.log(offlineData[AMProfileModule.SYNC_SLEEP_DATA_TIME_AM]);
382 console.log(offlineData[AMProfileModule.SYNC_SLEEP_DATA_LEVEL_AM]);
383 console.log(offlineData[AMProfileModule.DATAID]);
384 }
385 }
386 }
387});
388```