summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/doc/am5.md
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ihealth-sdk/doc/am5.md')
-rw-r--r--libs/ihealth-sdk/doc/am5.md215
1 files changed, 215 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/doc/am5.md b/libs/ihealth-sdk/doc/am5.md
new file mode 100644
index 0000000..4465b35
--- /dev/null
+++ b/libs/ihealth-sdk/doc/am5.md
@@ -0,0 +1,215 @@
1# AM4 Workflow
2
3## Import AM5 Module
4
5```js
6import {
7 AM5Module,
8 AM5ProfileModule
9} from '@ihealth/ihealthlibrary-react-native';
10```
11
12## APIs
13
14### Add and remove listener
15
16```js
17// add
18notifyListener = DeviceEventEmitter.addListener(AM5Module.Event_Notify, (event) => {
19 console.log(event);
20});
21
22// remove
23notifyListener.remove();
24```
25
26### get all connected am5 devices
27
28```js
29AM5Module.getAllConnectedDevices();
30
31// {"action": "action_get_all_connected_devices", "devices": ["DD4173E7F41E"]}
32```
33
34### disconnect a am5 devices
35
36```js
37AM5Module.disconnect(mac);
38```
39
40### Binding apps and devices
41
42```js
43AM5Module.bindDevice(mac);
44
45// response
46// {"action": "action_user_bind", "description": "no error", "mac": "DD4173E7F41E", "status": 3, "type": "AM5"}
47notifyListener = DeviceEventEmitter.addListener(AM5Module.Event_Notify, (event) => {
48 if (event.action === AM5ProfileModule.ACTION_USER_BIND) {
49 if (3 === event[AM5ProfileModule.OPERATION_STATUS]) {
50 console.log('bind success');
51 } else if (4 === event[AM5ProfileModule.OPERATION_STATUS]) {
52 console.log('bind fail');
53 }
54 }
55});
56```
57
58### UnBind apps and devices
59
60```js
61AM5Module.unBindDevice(mac);
62
63// response
64// {"action": "action_user_unbind", "description": "no error", "mac": "DD4173E7F41E", "status": 3, "type": "AM5"}
65notifyListener = DeviceEventEmitter.addListener(AM5Module.Event_Notify, (event) => {
66 if (event.action === AM5ProfileModule.ACTION_USER_UNBIND) {
67 if (3 === event[AM5ProfileModule.OPERATION_STATUS]) {
68 console.log('unbind success');
69 } else if (4 === event[AM5ProfileModule.OPERATION_STATUS]) {
70 console.log('unbind fail');
71 }
72 }
73});
74```
75
76### Get information of the device
77
78```js
79AM5Module.getBasicInfo(mac);
80
81// response
82// {"action": "action_basic_info", "battStatus": 0, "bind_confirm_method": 0, "bind_confirm_timeout": 0, "deivceId": 7041, "energe": 63, "firmwareVersion": 40, "mac": "DD4173E7F41E", "mode": 1, "pairFlag": 0, "reboot": 0, "type": "AM5"}
83notifyListener = DeviceEventEmitter.addListener(AM5Module.Event_Notify, (event) => {
84 if (event.action === AM5ProfileModule.ACTION_BASIC_INFO) {
85 console.log(AM5ProfileModule.BASIC_ENERGE);
86 }
87});
88```
89
90### Set current time of the device
91
92```js
93AM5Module.setTime(mac);
94
95// response
96// {"action": "TIME", "mac": "DD4173E7F41E", "result": true, "type": "AM5"}
97notifyListener = DeviceEventEmitter.addListener(AM5Module.Event_Notify, (event) => {
98 if (event.action === "TIME") {
99 console.log('set success');
100 }
101});
102```
103
104### Set user info
105
106```js
107/**
108 * @param year Year of birth
109 * @param month Month of birth
110 * @param day Day of birth
111 * @param weight weight
112 * @param height height
113 * @param gender gender male: 1, female: 2
114 */
115AM5Module.setUserInfo(mac, 1990, 1, 1, 75, 176, 1);
116
117// response
118// {"action": "USER_INFO", "mac": "DD4173E7F41E", "result": true, "type": "AM5"}
119notifyListener = DeviceEventEmitter.addListener(AM5Module.Event_Notify, (event) => {
120 if (event.action === "USER_INFO") {
121 console.log('set success');
122 }
123});
124```
125
126### Set unit
127
128```js
129/**
130 * When you never set them, treat them as defaults
131 * @param {string} mac Device's mac address
132 * @param type 0: Distance unit unit: 0 default ; 1 KM ; 2 MI
133 * @param type 1: Wight unit unit: 0 default ; 1 KG ; 2 LB ; 3 ST
134 * @param type 2: Temperature unit unit: 0 default ; 1 °C ; 2 °F
135 * @param type 3: Distance at each step unit: distance (cm) (default 0cm)
136 * @param type 4: Language unit: 0 default ; 1 zh ; 2 en ; 3 fr ; 4 de ; 5 it ; 6 es ; 7 ja ; 8 po ; 9 cz
137 * @param type 5: Time Mode unit: 0 default ; 1 24 hour system ; 2 12 hour system
138 * @param type 6: Distance at each step of run unit: distance (cm) (default 0cm)
139 * @param type 7: GPS calibration switch unit: 0 default ; 1 open ; 2 close
140*/
141AM5Module.setUnit(mac, [1, 3, 2]);
142
143// response
144// {"action": "UNIT", "mac": "DD4173E7F41E", "result": true, "type": "AM5"}
145notifyListener = DeviceEventEmitter.addListener(AM5Module.Event_Notify, (event) => {
146 if (event.action === "UNIT") {
147 console.log('set success');
148 }
149});
150```
151
152### Set Hand Wear Mode
153
154```js
155/**
156 * @param {string} mac Device's mac address
157 * @param mode 0 left-hand 1 right-hand
158 */
159AM5Module.setHandWearMode(mac, 1);
160
161// response
162// {"action": "HAND_MODE", "mac": "DD4173E7F41E", "result": true, "type": "AM5"}
163notifyListener = DeviceEventEmitter.addListener(AM4Module.Event_Notify, (event) => {
164 if (event.action === "HAND_MODE") {
165 console.log('set success');
166 }
167});
168```
169
170### Get the live data of the device
171
172```js
173/**
174 * @param {string} mac Device's mac address
175 */
176AM5Module.getLiveData(mac);
177
178// response
179// {"action": "action_live_data", "dbp": 0, "heartRate": 0, "mac": "DD4173E7F41E", "sbp": 0, "totalActiveTime": 0, "totalCalories": 0, "totalDistances": 0, "totalStep": 0, "type": "AM5"}
180notifyListener = DeviceEventEmitter.addListener(AM5Module.Event_Notify, (event) => {
181 if (event.action === AM5ProfileModule.ACTION_LIVE_DATA) {
182 console.log('set success');
183 }
184});
185```
186
187### Sync health data from device
188
189```js
190/**
191 * @param {string} mac Device's mac address
192 */
193AM5Module.syncHealthData(mac);
194
195// response
196
197// 1. {"action": "action_sync_health_data", "mac": "DD4173E7F41E", "status": 0, "type": "AM5"}
198// 2. {"action": "action_sync_health_data", "mac": "DD4173E7F41E", "progress": 2, "status": 2, "type": "AM5"}
199
200// 3. {"action": "action_sync_health_data_sport", "dId": 7041, "date": "Aug 16, 2021 12:00:00 AM", "day": 16, "items": [ {"activeTime": 0, "calory": 0, "dId": 7041, "date": "Aug 16, 2021 12:00:00 AM", "day": 16, "distance": 0, "month": 8, "sportDataId": 1, "stepCount": 0, "year": 2021}], "mac": "DD4173E7F41E", "month": 8, "sportDataId": 3, "startTime": 0, "timeSpace": 15, "totalActiveTime": 473, "totalCalory": 40, "totalDistance": 718, "totalStepCount": 998, "type": "AM5", "year": 2021}
201
202// 4. {"action": "action_sync_health_data_sleep", "awakeCount": 2, "dId": 7041, "date": "Aug 27, 2021 12:00:00 AM", "day": 27,"deepSleepCount": 7, "deepSleepMinutes": 157, "items":
203// [{"dId": 7041, "date": "Aug 27, 2021 12:00:00 AM", "day": 27, "month": 8, "offsetMinute": 19, "sleepDataId": 2, "sleepStatus": 2, "year": 2021},
204// {"dId": 7041, "date": "Aug 27, 2021 12:00:00 AM", "day": 27, "month": 8, "offsetMinute": 28, "sleepDataId": 3, "sleepStatus": 3, "year": 2021}, {"dId": 7041, "date": "Aug 27, 2021 12:00:00 AM", "day": 27, "month": 8, "offsetMinute": 56, "sleepDataId": 4, "sleepStatus": 2, "year": 2021}], "lightSleepCount": 9, "lightSleepMinutes": 327, "mac": "DD4173E7F41E", "month": 8, "sleepDataId": 1, "sleepEndedTimeH": 9, "sleepEndedTimeM": 10, "totalSleepMinutes": 533, "type": "AM5", "year": 2021}
205
206// 5. {"action": "action_sync_health_data_heart_rate", "dId": 7041, "date": "Aug 16, 2021 12:00:00 AM", "day": 16, "items": [ {"activeTime": 0, "calory": 0, "dId": 7041, "date": "Aug 16, 2021 12:00:00 AM", "day": 16, "distance": 0, "month": 8, "sportDataId": 1, "stepCount": 0, "year": 2021}]}
207
208// 6. {"action": "action_sync_health_data", "mac": "DD4173E7F41E", "progress": 100, "status": 3, "type": "AM5"}
209
210notifyListener = DeviceEventEmitter.addListener(AM5Module.Event_Notify, (event) => {
211 if (event.action === AM5ProfileModule.ACTION_SYNC_HEALTH_DATA) {
212 console.log('get success');
213 }
214});
215```