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