From d6d9a09d505d11148599a95a5be3e1351edbe0ac Mon Sep 17 00:00:00 2001 From: hc Date: Mon, 13 Apr 2026 15:17:52 +0800 Subject: Local iHealth SDK, device detail screen, iOS event fixes --- libs/ihealth-sdk/module/AM4Module.js | 321 +++++++++++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100755 libs/ihealth-sdk/module/AM4Module.js (limited to 'libs/ihealth-sdk/module/AM4Module.js') 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 @@ +'use strict'; + + +var { + NativeModules, + DeviceEventEmitter +} = require('react-native'); + +var AMProfileModule = require('./AMProfileModule.js'); + +var RCTModule = NativeModules.AM4Module + +/** + * @module AM4Module + */ +module.exports = { + + Event_Notify: RCTModule.Event_Notify, + + /** + * Get AM4 device's IDPS information. + * @param {string} mac Device's mac address + */ + getIdps: function (mac) { + RCTModule.getIdps(mac) + }, + + /** + * Reset AM4 device. + * @param {string} mac Device's mac address + */ + reset: function (mac) { + RCTModule.reset(mac) + }, + + /** + * Get user's ID + * @param {string} mac Device's mac address + */ + getUserId: function (mac) { + RCTModule.getUserId(mac) + }, + + /** + * Get alarms' count + * @param {string} mac Device's mac address + */ + getAlarmClockNum: function (mac) { + RCTModule.getAlarmClockNum(mac) + }, + + /** + * Get alarm information by id + * @param {string} mac Device's mac address + * @param {array} alarmIDArray Alarm id array to be query.
+ * + */ + getAlarmClockDetail: function (mac, alarmIDArray) { + RCTModule.getAlarmClockDetail(mac, alarmIDArray) + }, + + /** + * Set alarm + * @param {string} mac Device's mac address + * @param {number} id Alarm id
+ * Range: 1, 2 or 3 + * @param {number} hour Alarm hour part
+ * Range: [0, 23] + * @param {number} min Alarm minute part
+ * Range: [0, 59] + * @param {boolean} isRepeat Indicates whether it will repeat: + * + * @param {array} weekArray The days in a week to repeat the alarm, week[0~6] indicates Sun~Sat.
+ * And 1 indicates open, 0 indicates close.
+ * For example:
+ * {0, 1, 1, 1, 1, 1, 0} means the alarm will repeat on Mon, Tue, Wed, Thu, Fri. + * @param {boolean} isOn true if want to set the alarm, false to unset it. + */ + setAlarmClock: function (mac, id, hour, min, isRepeat, weekArray, isOn) { + RCTModule.setAlarmClock(mac, id, hour, min, isRepeat, weekArray, isOn) + }, + + /** + * Delete alarm by id + * @param {string} mac Device's mac address + * @param {number} id Alarm id(should be 1, 2 or 3) + */ + deleteAlarmClock: function (mac, id) { + RCTModule.deleteAlarmClock(mac, id) + }, + + /** + * Get activity remind setting. + * @param {string} mac Device's mac address + */ + getActivityRemind: function (mac) { + RCTModule.getActivityRemind(mac) + }, + + /** + * Set/Unset activity remind + * @param {string} mac Device's mac address + * @param {number} hour Activity remind hour part
+ * Range: [0, 23] + * @param {number} min Activity remind minute part
+ * Range:[0, 59] + * @param {boolean} isOn true if want to set activity remind, false to unset it. + */ + setActivityRemind: function (mac, hour, min, isOn) { + RCTModule.setActivityRemind(mac, hour, min, isOn) + }, + + /** + * Get device state and battery information + * @param {string} mac Device's mac address + */ + queryAMState: function (mac) { + RCTModule.queryAMState(mac) + }, + + /** + * Set user ID + * @param {string} mac Device's mac address + * @param {number} id new user id
+ * Range: [1, 2147483647(0x7FFFFFFF)] + */ + setUserId: function (mac, id) { + if (id < 1 || id > 0x7FFFFFFF) { + let result = { + "mac": mac, + "type": "AM4", + "action" : AMProfileModule.ACTION_ERROR_AM, + } + result[AMProfileModule.ERROR_NUM_AM] = AMProfileModule.ERROR_ID_ILLEGAL_ARGUMENT + result[AMProfileModule.ERROR_DESCRIPTION_AM] = 'setUserId() parameter id should be in the range [1, 2147483647(0x7FFFFFFF)]' + DeviceEventEmitter.emit(RCTModule.Event_Notify, result) + return + } + RCTModule.setUserId(mac, id) + }, + + /** + * Get user information + * @param {string} mac Device's mac address + */ + getUserInfo: function (mac) { + RCTModule.getUserInfo(mac) + }, + + /** + * Set user's BMR + * @param {string} mac Device's mac address + * @param {number} bmr User's BMR
+ * Range: [1, 32767(0x7FFF)] + */ + setUserBmr: function (mac, bmr) { + RCTModule.setUserBmr(mac, bmr) + }, + + /** + * Get the activity data. + * @param {string} mac Device's mac address + */ + syncActivityData: function (mac) { + RCTModule.syncActivityData(mac) + }, + + /** + * Get the sleep data. + * @param {string} mac Device's mac address + */ + syncSleepData: function (mac) { + RCTModule.syncSleepData(mac) + }, + + /** + * Get current time activity data. + * @param {string} mac Device's mac address + */ + syncRealData: function (mac) { + RCTModule.syncRealData(mac) + }, + + /** + * Set the system time to AM device. + * @param {string} mac Device's mac address + */ + syncRealTime: function (mac) { + RCTModule.syncRealTime(mac) + }, + + /** + * Set hour mode + * @param {string} mac Device's mac address + * @param {number} hourMode The value should be one of following: + * + */ + setHourMode: function (mac, hourMode) { + RCTModule.setHourMode(mac, hourMode) + }, + + /** + * Get hour mode + * @param {string} mac Device's mac address + */ + getHourMode: function (mac) { + RCTModule.getHourMode(mac) + }, + + /** + * Disconnect device + * @param {string} mac Device's mac address + */ + disconnect: function (mac) { + RCTModule.disconnect(mac) + }, + + /** + * Set user information + * @param {string} mac Device's mac address + * @param {number} age User's age
+ * Range: [1, 255] + * @param {number} height User's height(int in cm)
+ * Range: [1, 255] + * @param {number} weight User's weight(float)
+ * Range: [1.0, 255.0] + * @param {number} gender User's gender
+ * Value: + * + * @param {number} unit Distance's unit type(kilometre or miles)
+ * Value: + * + * @param {number} target The goal of maximum steps
+ * Range: [4, 2147483647(0x7FFFFFFF)] + * @param {number} activityLevel The level of activity strength
+ * + * @param {number} min swim target time(in minutes)
+ * Range: [1, 1439(23 * 60 + 59)] + */ + setUserInfo: function (mac, age, height, weight, gender, unit, target, activityLevel, min) { + RCTModule.setUserInfo(mac, age, height, weight, gender, unit, target, activityLevel, min) + }, + + /** + * Get stage report data + * @param {string} mac Device's mac address + */ + syncStageReportData: function (mac) { + RCTModule.syncStageReportData(mac) + }, + + /** + * Send random number to device to prepare for binding, the number will be displayed on the device. + * @param {string} mac Device's mac address + */ + sendRandom: function (mac) { + RCTModule.sendRandom(mac) + }, + + /** + * Get swim parameters + * @param {string} mac Device's mac address + */ + checkSwimPara: function (mac) { + RCTModule.checkSwimPara(mac) + }, + + /** + * Set swim parameters + * @param {string} mac Device's mac address + * @param {boolean} isOpen Set true to open swim function, set false to close it. + * @param {number} poolLength the swimming pool's length.
+ * Range: [1, 255] + * @param {number} hours The cut out time's hour part
+ * Range: [0, 23] + * @param {number} minutes The cut out time's minute part
+ * Range[0, 59] + * @param {number} unit The pool length's unit type(metre or yard). + * + */ + setSwimPara: function (mac, isOpen, poolLength, hours, minutes, unit) { + RCTModule.setSwimPara(mac, isOpen, poolLength, hours, minutes, unit) + }, + + /** + * Get all connected AM4 device + * + * e.g. {"devices":["A4D5783FB00C","A4D5783FFE58"]} + */ + getAllConnectedDevices: function () { + RCTModule.getAllConnectedDevices() + }, +} -- cgit