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