summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/doc/hs6.md
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ihealth-sdk/doc/hs6.md')
-rw-r--r--libs/ihealth-sdk/doc/hs6.md137
1 files changed, 137 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/doc/hs6.md b/libs/ihealth-sdk/doc/hs6.md
new file mode 100644
index 0000000..c951baa
--- /dev/null
+++ b/libs/ihealth-sdk/doc/hs6.md
@@ -0,0 +1,137 @@
1# HS6 Workflow
2
3## import HS6 module
4
5```js
6import {
7 HS6Module,
8 HS6ProfileModule
9} from '@ihealth/ihealthlibrary-react-native';
10```
11
12## APIs
13
14### add and remove listener
15
16```js
17// add
18notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
19 console.log(event);
20});
21
22// remove
23notifyListener.remove();
24```
25
26### init hs6
27
28```js
29// need the ihealth account, apply from ihealth developer website
30HS6Module.init("xxx.xxx@xxx.com");
31```
32
33### set wifi for hs6
34
35The api only support the 2.4G wifi.
36
37```js
38HS6Module.setWifi("xxxx", "1234567890");
39
40// response
41notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
42 if (event.action === HS6ProfileModule.ACTION_HS6_SETWIFI) {
43 console.log(event[HS6ProfileModule.SETWIFI_RESULT]);
44 }
45});
46```
47
48### bind user with hs6
49
50```js
51/**
52 * birthday
53 * weight(kg)
54 * height(cm)
55 * isSporter
56 * gender
57 * serialNumber
58 */
59HS6Module.bindDeviceHS6("1979-02-26 12:20:10", 85.0, 180, 2, 1, "ACCF2337A952");
60
61// response
62notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
63 if (event.action === HS6ProfileModule.ACTION_HS6_BIND) {
64 console.log(event[HS6ProfileModule.HS6_BIND_EXTRA]);
65 // 1: bind success, 2: the scale has no empty position, 3: bind fail
66 console.log(event[HS6ProfileModule.BIND_HS6_RESULT]);
67 console.log(event[HS6ProfileModule.HS6_MODEL]);
68 // The range is from 1~10
69 console.log(event[HS6ProfileModule.HS6_POSITION]);
70 // 1: setted, 0: not
71 console.log(event[HS6ProfileModule.HS6_SETTED_WIFI]);
72 }
73});
74```
75
76### unbind hs6
77
78```js
79HS6Module.unBindDeviceHS6("ACCF2337A952");
80
81// response
82notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
83 if (event.action === HS6ProfileModule.ACTION_HS6_UNBIND) {
84 console.log(event[HS6ProfileModule.HS6_UNBIND_RESULT]);
85 }
86});
87```
88
89### get token
90
91```js
92/**
93 * clientId,
94 * clientSecret,
95 * username,
96 * clientPara
97`*/
98HS6Module.getToken("xxx", "xxx", "xxx.xxx@xxx.com", "random_str");
99
100// response
101notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
102 if (event.action === HS6ProfileModule.ACTION_HS6_GET_TOKEN) {
103 console.log(event[HS6ProfileModule.GET_TOKEN_RESULT]);
104 }
105});
106```
107
108### set unit
109
110```js
111/**
112 * username
113 * unitType 0: Kg 1: lbs 2: st
114`*/
115HS6Module.setUnit("xxx.xxx@xxx.com", 0);
116
117// response
118notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
119 if (event.action === HS6ProfileModule.ACTION_HS6_SET_UNIT) {
120 console.log(event[HS6ProfileModule.SET_UNIT_RESULT]);
121 }
122});
123```
124
125### get data stored in cloud
126
127```js
128HS6Module.getCloudData("xxx", "xxx", "xxx.xxx@xxx.com", 0, 10);
129
130// response
131notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
132 if (event.action === HSProfileModule.ACTION_HS6_GET_CLOUDDATA) {
133
134 }
135});
136```
137