import {
HS6Module,
HS6ProfileModule
} from '@ihealth/ihealthlibrary-react-native';
// add
notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
console.log(event);
});
// remove
notifyListener.remove();
// need the ihealth account, apply from ihealth developer website
HS6Module.init("[email protected]");
The api only support the 2.4G wifi.
HS6Module.setWifi("xxxx", "1234567890");
// response
notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
if (event.action === HS6ProfileModule.ACTION_HS6_SETWIFI) {
console.log(event[HS6ProfileModule.SETWIFI_RESULT]);
}
});
/**
* birthday
* weight(kg)
* height(cm)
* isSporter
* gender
* serialNumber
*/
HS6Module.bindDeviceHS6("1979-02-26 12:20:10", 85.0, 180, 2, 1, "ACCF2337A952");
// response
notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
if (event.action === HS6ProfileModule.ACTION_HS6_BIND) {
console.log(event[HS6ProfileModule.HS6_BIND_EXTRA]);
// 1: bind success, 2: the scale has no empty position, 3: bind fail
console.log(event[HS6ProfileModule.BIND_HS6_RESULT]);
console.log(event[HS6ProfileModule.HS6_MODEL]);
// The range is from 1~10
console.log(event[HS6ProfileModule.HS6_POSITION]);
// 1: setted, 0: not
console.log(event[HS6ProfileModule.HS6_SETTED_WIFI]);
}
});
HS6Module.unBindDeviceHS6("ACCF2337A952");
// response
notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
if (event.action === HS6ProfileModule.ACTION_HS6_UNBIND) {
console.log(event[HS6ProfileModule.HS6_UNBIND_RESULT]);
}
});
/**
* clientId,
* clientSecret,
* username,
* clientPara
`*/
HS6Module.getToken("xxx", "xxx", "[email protected]", "random_str");
// response
notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
if (event.action === HS6ProfileModule.ACTION_HS6_GET_TOKEN) {
console.log(event[HS6ProfileModule.GET_TOKEN_RESULT]);
}
});
/**
* username
* unitType 0: Kg 1: lbs 2: st
`*/
HS6Module.setUnit("[email protected]", 0);
// response
notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
if (event.action === HS6ProfileModule.ACTION_HS6_SET_UNIT) {
console.log(event[HS6ProfileModule.SET_UNIT_RESULT]);
}
});
HS6Module.getCloudData("xxx", "xxx", "[email protected]", 0, 10);
// response
notifyListener = DeviceEventEmitter.addListener(HS6Module.Event_Notify, (event) => {
if (event.action === HSProfileModule.ACTION_HS6_GET_CLOUDDATA) {
}
});