diff options
Diffstat (limited to 'libs/ihealth-sdk/doc/hs2s.md')
| -rw-r--r-- | libs/ihealth-sdk/doc/hs2s.md | 307 |
1 files changed, 307 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/doc/hs2s.md b/libs/ihealth-sdk/doc/hs2s.md new file mode 100644 index 0000000..b72995a --- /dev/null +++ b/libs/ihealth-sdk/doc/hs2s.md | |||
| @@ -0,0 +1,307 @@ | |||
| 1 | # HS2S Workflow | ||
| 2 | |||
| 3 | ## import HS2S module | ||
| 4 | |||
| 5 | ```js | ||
| 6 | import { | ||
| 7 | HS2SModule, | ||
| 8 | HS2SProfileModule | ||
| 9 | } from '@ihealth/ihealthlibrary-react-native'; | ||
| 10 | ``` | ||
| 11 | |||
| 12 | ## APIs | ||
| 13 | |||
| 14 | ### add and remove listener | ||
| 15 | |||
| 16 | ```js | ||
| 17 | // add | ||
| 18 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 19 | console.log(event); | ||
| 20 | }); | ||
| 21 | |||
| 22 | // remove | ||
| 23 | notifyListener.remove(); | ||
| 24 | ``` | ||
| 25 | |||
| 26 | ### get device information | ||
| 27 | |||
| 28 | ```js | ||
| 29 | HS2SModule.getDeviceInfo(mac); | ||
| 30 | |||
| 31 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 32 | if (event.action === "action_get_device_info") { | ||
| 33 | console.log(event["battery"]); | ||
| 34 | console.log(event["unit_current"]); | ||
| 35 | console.log(event["user_count"]); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | ``` | ||
| 39 | |||
| 40 | ### get device battery | ||
| 41 | |||
| 42 | ```js | ||
| 43 | HS2SModule.getBattery(mac); | ||
| 44 | |||
| 45 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 46 | if (event.action === "action_get_battery_hs") { | ||
| 47 | console.log(event["battery_hs"]); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | ``` | ||
| 51 | |||
| 52 | ### set Unit | ||
| 53 | |||
| 54 | ```js | ||
| 55 | HS2SModule.setUnit(mac); | ||
| 56 | |||
| 57 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 58 | if (event.action === "action_set_unit") { | ||
| 59 | console.log(event["result"]); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | ``` | ||
| 63 | |||
| 64 | ### get user information | ||
| 65 | |||
| 66 | ```js | ||
| 67 | HS2SModule.getUserInfo(mac); | ||
| 68 | |||
| 69 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 70 | if (event.action === "action_get_user_info") { | ||
| 71 | console.log(event["user_info-count"]); | ||
| 72 | let array = event["user_info_array"]; | ||
| 73 | console.log(array["body_building"]); | ||
| 74 | console.log(array["impedance"]); | ||
| 75 | console.log(array["height"]); | ||
| 76 | console.log(array["age"]); | ||
| 77 | console.log(array["gender"]); | ||
| 78 | console.log(array["weight"]); | ||
| 79 | console.log(array["create_time"]); | ||
| 80 | console.log(array["user_id"]); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | ``` | ||
| 84 | |||
| 85 | ### create user | ||
| 86 | |||
| 87 | ```js | ||
| 88 | HS2SModule.updateUserInfo(mac); | ||
| 89 | |||
| 90 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 91 | if (event.action === "action_create_or_update_user_info") { | ||
| 92 | console.log(event["result"]); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | ``` | ||
| 96 | |||
| 97 | ### delete user | ||
| 98 | |||
| 99 | ```js | ||
| 100 | HS2SModule.deleteUser(mac, userId); | ||
| 101 | |||
| 102 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 103 | if (event.action === "action_delete_user_info") { | ||
| 104 | console.log(event["result"]); | ||
| 105 | } | ||
| 106 | } | ||
| 107 | ``` | ||
| 108 | |||
| 109 | ### get the number of offline data | ||
| 110 | |||
| 111 | ```js | ||
| 112 | HS2SModule.getMemoryDataCount(mac, userId); | ||
| 113 | |||
| 114 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 115 | if (event.action === "action_history_data_num") { | ||
| 116 | console.log(event["history_data_count"]); | ||
| 117 | } | ||
| 118 | } | ||
| 119 | ``` | ||
| 120 | |||
| 121 | ### get offline data | ||
| 122 | |||
| 123 | ```js | ||
| 124 | HS2SModule.getMemoryData(mac, userId); | ||
| 125 | |||
| 126 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 127 | if (event.action === "action_history_data") { | ||
| 128 | let arr = event["history_data"]; | ||
| 129 | arr.forEach(function(result) { | ||
| 130 | console.log(result["fat_weight"]); | ||
| 131 | console.log(result["fat_control"]; | ||
| 132 | console.log(result["weight_control"]; | ||
| 133 | console.log(result["standard_weight"]; | ||
| 134 | console.log(result["skeletal_muscle_mass"]; | ||
| 135 | console.log(result["body_water_rate"]; | ||
| 136 | console.log(result["muscle_mas"]; | ||
| 137 | console.log(result["instruction_type"]; | ||
| 138 | console.log(result["body_building"]; | ||
| 139 | console.log(result["height"]; | ||
| 140 | console.log(result["gender"]; | ||
| 141 | console.log(result["muscle_control"]; | ||
| 142 | console.log(result["physical_age"]; | ||
| 143 | console.log(result["visceral_fat_grade"]; | ||
| 144 | console.log(result["protein_rate"]; | ||
| 145 | console.log(result["bone_salt_content"]; | ||
| 146 | console.log(result["visceral_fat_grade"]; | ||
| 147 | console.log(result["measure_time"]; | ||
| 148 | console.log(result["age"]; | ||
| 149 | console.log(result["impedance"]; | ||
| 150 | console.log(result["weight"]; | ||
| 151 | }) | ||
| 152 | } | ||
| 153 | } | ||
| 154 | ``` | ||
| 155 | |||
| 156 | ### delete offline data by user id | ||
| 157 | |||
| 158 | ```js | ||
| 159 | HS2SModule.deleteMemoryData(mac, userId); | ||
| 160 | |||
| 161 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 162 | if (event.action === "action_delete_history_data") { | ||
| 163 | console.log(event["result"]); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | ``` | ||
| 167 | |||
| 168 | ### get the number of anonymous offline data | ||
| 169 | |||
| 170 | ```js | ||
| 171 | HS2SModule.getAnonymousMemoryDataCount(mac); | ||
| 172 | |||
| 173 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 174 | if (event.action === "action_anonymous_data_num") { | ||
| 175 | console.log(event["anonymous_data_count"]); | ||
| 176 | } | ||
| 177 | } | ||
| 178 | ``` | ||
| 179 | |||
| 180 | ### get anonymous offline data | ||
| 181 | |||
| 182 | ```js | ||
| 183 | HS2SModule.getAnonymousMemoryData(mac); | ||
| 184 | |||
| 185 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 186 | if (event.action === "action_anonymous_data") { | ||
| 187 | let arr = event["history_data"]; | ||
| 188 | arr.forEach(function(result) { | ||
| 189 | console.log(result["instruction_type"]; | ||
| 190 | console.log(result["body_building"]; | ||
| 191 | console.log(result["height"]; | ||
| 192 | console.log(result["gender"]; | ||
| 193 | console.log(result["measure_time"]; | ||
| 194 | console.log(result["age"]; | ||
| 195 | console.log(result["impedance"]; | ||
| 196 | console.log(result["weight"]; | ||
| 197 | }) | ||
| 198 | } | ||
| 199 | } | ||
| 200 | ``` | ||
| 201 | |||
| 202 | ### delete anonymous offline data | ||
| 203 | |||
| 204 | ```js | ||
| 205 | HS2SModule.deleteAnonymousMemoryData(mac); | ||
| 206 | |||
| 207 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 208 | if (event.action === "action_delete_anonymous_data") { | ||
| 209 | console.log(event["result"]); | ||
| 210 | } | ||
| 211 | } | ||
| 212 | ``` | ||
| 213 | |||
| 214 | ### start a online measurement | ||
| 215 | |||
| 216 | The API is asyn function. It will return message until finish measurement. | ||
| 217 | |||
| 218 | ```js | ||
| 219 | HS2SModule.measure(mac); | ||
| 220 | |||
| 221 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 222 | if (event.action === "action_specify_users") { | ||
| 223 | console.log(event["result"]); | ||
| 224 | // 1: success, 0: failure | ||
| 225 | |||
| 226 | } else if (event.action === "action_online_real_time_weight") { | ||
| 227 | console.log(event["weight"]); | ||
| 228 | |||
| 229 | } else if (event.action === "action_online_result") { | ||
| 230 | console.log(event["weight"]); | ||
| 231 | |||
| 232 | } else if (event.action === "action_body_fat_result") { | ||
| 233 | let bodyFat = event["data_body_fat_result"]; | ||
| 234 | let fat_weight = bodyFat["fat_weight"]; | ||
| 235 | let fat_control = bodyFat["fat_control"]; | ||
| 236 | let weight_control = bodyFat["weight_control"]; | ||
| 237 | let standard_weight = bodyFat["standard_weight"]; | ||
| 238 | let skeletal_muscle_mass = bodyFat["skeletal_muscle_mass"]; | ||
| 239 | let body_water_rate = bodyFat["body_water_rate"]; | ||
| 240 | let muscle_mas = bodyFat["muscle_mas"]; | ||
| 241 | let instruction_type = bodyFat["instruction_type"]; | ||
| 242 | let body_building = bodyFat["body_building"]; | ||
| 243 | let height = bodyFat["height"]; | ||
| 244 | let gender = bodyFat["gender"]; | ||
| 245 | let muscle_control = bodyFat["muscle_control"]; | ||
| 246 | let physical_age = bodyFat["physical_age"]; | ||
| 247 | let visceral_fat_grade = bodyFat["visceral_fat_grade"]; | ||
| 248 | let protein_rate = bodyFat["protein_rate"]; | ||
| 249 | let bone_salt_content = bodyFat["bone_salt_content"]; | ||
| 250 | let visceral_fat_grade = bodyFat["visceral_fat_grade"]; | ||
| 251 | let measure_time = bodyFat["measure_time"]; | ||
| 252 | let age = bodyFat["age"]; | ||
| 253 | let impedance = bodyFat["impedance"]; | ||
| 254 | let weight = bodyFat["weight"]; | ||
| 255 | |||
| 256 | } else if (event.action === "action_measure_finish_at_critical") { } | ||
| 257 | }); | ||
| 258 | ``` | ||
| 259 | |||
| 260 | ### start heart rate measurement mode | ||
| 261 | |||
| 262 | ```js | ||
| 263 | HS2SModule.resetDevice(mac); | ||
| 264 | |||
| 265 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 266 | if (event.action === HS2SProfileModule.ACTION_HS2S_MEASURE_HEARTRATE) { | ||
| 267 | |||
| 268 | } | ||
| 269 | } | ||
| 270 | ``` | ||
| 271 | |||
| 272 | ### stop heart rate measurement mode | ||
| 273 | |||
| 274 | ```js | ||
| 275 | HS2SModule.resetDevice(mac); | ||
| 276 | |||
| 277 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 278 | if (event.action === HS2SProfileModule.ACTION_HS2S_EXIT_MEASURE_HEARTRATE_STATUS) { | ||
| 279 | // {"status":0,"heartrate":78} | ||
| 280 | console.log(event.message); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | ``` | ||
| 284 | |||
| 285 | ### reset device | ||
| 286 | |||
| 287 | ```js | ||
| 288 | HS2SModule.resetDevice(mac); | ||
| 289 | |||
| 290 | notifyListener = DeviceEventEmitter.addListener(HS2SModule.Event_Notify, (event) => { | ||
| 291 | if (event.action === "action_restore_factory_settings") { | ||
| 292 | console.log(event["result"]); | ||
| 293 | } | ||
| 294 | } | ||
| 295 | ``` | ||
| 296 | |||
| 297 | ### disconnect device | ||
| 298 | |||
| 299 | ```js | ||
| 300 | HS2SModule.disConnect(mac); | ||
| 301 | ``` | ||
| 302 | |||
| 303 | ### get all connected devices | ||
| 304 | |||
| 305 | ```js | ||
| 306 | HS2SModule.getAllConnectedDevices(); | ||
| 307 | ``` | ||
