Skip to main content

AM6

info
  1. AM6 is a low-power activity tracker. It can track activity, sleep, heart rate and Blood oxygen.
  2. First use requires charging until the dial of watch displays a QR code.
  3. After the user successfully bound, AM6 will enter the dial activity UI, if the user unbound will return to the QR code UI.

Connection to device

1.Listen to device notify

int callbackId = iHealthDevicesManager.getInstance().registerClientCallback(new iHealthDevicesCallback() {

@Override
public void onScanDevice(String mac, String deviceType, int rssi, Map manufactorData) {
if ((manufacturerData != null) && (manufacturerData.get("isBound") != null)) {
boolean isBound = (boolean) manufacturerData.get("isBound");
Log.i(TAG,"isBound AM6 - " + isBound);
}
}

@Override
public void onDeviceConnectionStateChange(String mac, String deviceType, int status, int errorID, Map manufactorData) { }

@Override
public void onScanError(String reason, long latency) { }

@Override
public void onScanFinish() { }


@Override
public void onSDKStatus(int statusId, String statusMessage) {
if (iHealthDevicesManager.SDK_STATUS_BLUETOOTH_DISABLE == statusId) {
Log.i("", "Bluetooth service is disable!");

} else if (iHealthDevicesManager.SDK_STATUS_LOCATION_DISABLE == statusId) {
Log.i("", "Location service is disable!");

} else if (iHealthDevicesManager.SDK_STATUS_BLUETOOTH_PERMISSION == statusId) {
Log.i("", "Miss android permission: " + statusMessage);

} else if (iHealthDevicesManager.SDK_STATUS_LICENSE_EXPIRED == statusId) {
Log.i("", "License is not match with application id or is expired!");

} else if (iHealthDevicesManager.SDK_STATUS_LICENSE_DEVICE_PERMISSION == statusId) {
Log.i("", "Need this device permission!");

}
}
});

iHealthDevicesManager.getInstance().addCallbackFilterForDeviceType(mClientCallbackId, iHealthDevicesManager.TYPE_AM6);
iHealthDevicesManager.getInstance().addCallbackFilterForAddress(int clientCallbackId, String... macs)

2.Scan for AM6 devices

iHealthDevicesManager.getInstance().startDiscovery(DiscoveryTypeEnum.AM6);

3.Connect to AM6 devices

info

AM6 supports direct connection to the device without scanning, but after disconnection, the device cannot be connected immediately, because the phone needs time to release the GATT service, we recommend waiting for 2 seconds and trying to connect again. Connecting after scanning does not have this problem.

iHealthDevicesManager.getInstance().connectDevice(mac, iHealthDevicesManager.TYPE_AM6)

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);

API reference

How to bind user with AM6

info
  1. AM6 is used for the first time or is in an unbound state, and AM6 displays a QR code.
  2. Call the API startBind, AM6 enters the binding state.
  3. Call the API bindUserSuccess and pass user id to AM6, AM6 will save user id, and then will display UI of successful binding.
  4. Call the API bindUserFail, AM6 will display UI of failure binding, and then fall back to UI of QR code.

am6 binding

Start to Bind user

Am6 enters the binding state.

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.startBind();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_StartBind.equals(action)) {
Log.i("", "start to bind user");
}
}
}

Bind user success

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
byte[] userId = new byte[16];
/**
* @param userId must be a 16 byte array
*/
control.bindUserSuccess(userId);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_BindUserSuccess.equals(action)) {
Log.i("", "Bind user success");

} else if (OtherDeviceProfile.ACTION_ERROR.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(OtherDeviceProfile.ERROR_NUM);
int errorMessage = obj.getInt(OtherDeviceProfile.ERROR_DESCRIPTION);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Bind user fail

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.bindUserFail();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_BindUserFail.equals(action)) {
Log.i("", "Bind user fail");
}
}
}

Unbind user

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
byte[] userId = new byte[16];
/**
* @param userId must be a 16 byte array
*/
control.unBindUser(userId);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_UnbindUser.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/*
* 0: failure, 1: success
*/
int status = obj.getInt(Am6Profile.UnbindUser_Status);

} catch (JSONException e) {
e.printStackTrace();
}

} else if (OtherDeviceProfile.ACTION_ERROR.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(OtherDeviceProfile.ERROR_NUM);
int errorMessage = obj.getInt(OtherDeviceProfile.ERROR_DESCRIPTION);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

How to get started with AM6

Get AM6 information and sync time

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param is24Hour Time format is 12 hour or 24 hour
*/
control.getDeviceInfoAndSyncTime(boolean is24Hour);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_getDeviceInfoAndSetTime.equals(action)) {
try {
JSONObject obj = new JSONObject(message);

// The battery level of AM6, the range is 0~100
int battery = obj.getInt(Am6Profile.GetDeviceInfo_Battery);

// The hardware version of AM6
String hardwareVersion = obj.getString(Am6Profile.GetDeviceInfo_Hardware_Version);

// The sdk version of AM6
String sdkVersion = obj.getString(Am6Profile.GetDeviceInfo_SDK_Version);

// The firmware version of AM6
String firmwareVersion = obj.getString(Am6Profile.GetDeviceInfo_Firmware_Version);

// Is it bound, 0: no, 1: yes
int bindStatus = obj.getInt(Am6Profile.GetDeviceInfo_Bind_Status);

// Is it charging, 0: no, 1: yes
int charge = obj.getInt(Am6Profile.GetDeviceInfo_Charge);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Set user information of the device

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param userId must be a 16 byte array
* @param gender 0: male, 1: female
* @param age 1 ~ 255
* @param height unit is cm 1 ~ 255
* @param weight unit is kg 1 ~ 300
*/
control.setUserInfo(String userId, int gender, int age, int height, float weight);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_SetUserInfo.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/*
* Is setting user information successful? If it fails, please check whether the userId is same with the bound user.
* 0: failure, 1: success
*/
int result = obj.getInt(Am6Profile.SetUser_Result);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (OtherDeviceProfile.ACTION_ERROR.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(OtherDeviceProfile.ERROR_NUM);
int errorMessage = obj.getInt(OtherDeviceProfile.ERROR_DESCRIPTION);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Set Notification

info

Before setting notification information, please set the mobile platform type.

Set phone platform

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.setPhonePlatform();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_SetPhonePlatform.equals(action)) {
Log.i("", "Set phone platform");
}
}
}

Notify Message

info
Message Type
Others0
Call1
SMS2
iHealth3
Facebook4
Wechat5
Instagram6
Twitter7
Facebook messenger8
WhatsApp9
Gmail10
Email11
Yahoo mail12
Spotify13
Apple music14
YouTube15
Uber16
Google map17
Google calendar18
Strava19
Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param date timestamp
* @param status when message type is Call, the status can be set to 0: call ansered; 1: missed call; 2: call was hung up
* @param type message type
* @param title Maximum is 128 UTF-8 byte
* @param content Maximum is 512 UTF-8 byte
*/
control.notifyMessage(long date, int status, int type, byte[] title, byte[] content);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_NotifyMessage.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/*
* 0: failure, 1: success
*/
int result = obj.getInt(Am6Profile.NotifyMessage_Result);

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Device settings

Find device

info

Call the API once, the watch only vibrates 6 times for about 5 seconds. So if you want to achieve continuous vibration, please continue to call the API after 5 seconds.

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param start 0: start finding; 1: stop finding
*/
control.findDevice(int start);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_FindDevice.equals(action)) {
Log.i("", "Find device");
try {
JSONObject obj = new JSONObject(message);
/*
* 0: failure, 1: success
*/
int status = obj.getInt(Am6Profile.FindDevice_Status);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (OtherDeviceProfile.ACTION_ERROR.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(OtherDeviceProfile.ERROR_NUM);
int errorMessage = obj.getInt(OtherDeviceProfile.ERROR_DESCRIPTION);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Find phone

info

When the mobile phone is connected, click AM6 to find the function of the mobile phone, and the SDK will receive the message.

// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_FindPhone.equals(action)) {
Log.i("", "Find phone");
try {
JSONObject obj = new JSONObject(message);
/*
* 0: start to find; 1: stop to find
*/
int status = obj.getInt(Am6Profile.FindPhone_Status);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Reboot device

info

After calling this API, AM6 will be disconnected.

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.rebootDevice();

Set wearing hand

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param hand 0: left hand; 1: right hand
*/
control.setWearHand(int hand);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_SetWearHand.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.SetWearHand_Result);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Get wearing hand

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getWearHand();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetWearHand.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.GetWearHand_Result);

/**
* @return hand 0: left; 1: right
*/
int result = obj.getInt(Am6Profile.GetWearHand_Hand);

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Set target reminder

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param enable true: open; false: close
* @param calorie 0 ~ 65535
* @param step 0 ~ 65534
*/
control.setTargetRemind(boolean enable, int calorie, int step);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_SetTargetReminder.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.SetTargetReminder_Result);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (OtherDeviceProfile.ACTION_ERROR.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(OtherDeviceProfile.ERROR_NUM);
int errorMessage = obj.getInt(OtherDeviceProfile.ERROR_DESCRIPTION);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Get target reminder

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getTargetRemind();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetTargetReminder.equals(action)) {
try {
JSONObject obj = new JSONObject(message);

/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.GetTargetReminder_Result);

/**
* @return enable true: open; false: close
*/
boolean enable = obj.getBoolean(Am6Profile.GetTargetReminder_Enable);

/**
* @return calorie
*/
int calorie = obj.getInt(Am6Profile.GetTargetReminder_Calorie);

/**
* @return step
*/
int step = obj.getInt(Am6Profile.GetTargetReminder_Step);

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Set sedentary reminder

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param type 0: close; 1: open
* @param start This is the minute from the day starts, such as 10:10 am, it is 60 * 10 + 10, the range is 0 ~ 1439
* @param end This is the minute from the day starts, such as 10:10 am, it is 60 * 10 + 10, the range is 0 ~ 1439
*/
control.setSedentaryRemind(int enable, int start, int end);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_SetSedentaryReminder.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.SetSedentaryReminder_Result);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (OtherDeviceProfile.ACTION_ERROR.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(OtherDeviceProfile.ERROR_NUM);
int errorMessage = obj.getInt(OtherDeviceProfile.ERROR_DESCRIPTION);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Get sedentary reminder

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getSedentaryRemind();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetSedentaryReminder.equals(action)) {
try {
JSONObject obj = new JSONObject(message);

/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.GetSedentaryReminder_Result);

/**
* @return enable 0: close; 1: open
*/
int enable = obj.getInt(Am6Profile.GetSedentaryReminder_Enable);

/**
* @return start
*/
int start = obj.getInt(Am6Profile.GetSedentaryReminder_StartTime);

/**
* @return stop
*/
int stop = obj.getInt(Am6Profile.GetSedentaryReminder_EndTime);

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Set raise to light

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param enable 0: close; 1: open
* @param start This is the minute from the day starts, such as 10:10 am, it is 60 * 10 + 10, the range is 0 ~ 1439
* @param end This is the minute from the day starts, such as 10:10 am, it is 60 * 10 + 10, the range is 0 ~ 1439
*/
control.setRaiseToLight(int enable, int start, int end);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_SetRaiseToLight.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.SetRaiseToLight_Result);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (OtherDeviceProfile.ACTION_ERROR.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(OtherDeviceProfile.ERROR_NUM);
int errorMessage = obj.getInt(OtherDeviceProfile.ERROR_DESCRIPTION);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Get raise to light

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getRaiseToLight();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetRaiseToLight.equals(action)) {
try {
JSONObject obj = new JSONObject(message);

/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.GetRaiseToLight_Result);

/**
* @return enable 0: close; 1: open
*/
int enable = obj.getInt(Am6Profile.GetRaiseToLight_Enable);

/**
* @return start
*/
int start = obj.getInt(Am6Profile.GetRaiseToLight_StartTime);

/**
* @return stop
*/
int stop = obj.getInt(Am6Profile.GetRaiseToLight_EndTime);

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Set do not disturb mode

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param type 0: close; 1: open
* @param start This is the minute from the day starts, such as 10:10 am, it is 60 * 10 + 10, the range is 0 ~ 1439
* @param end This is the minute from the day starts, such as 10:10 am, it is 60 * 10 + 10, the range is 0 ~ 1439
*/
control.setDoNotDisturbMode(int enable, int start, int end);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_SetDoNotDisturb.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.SetDoNotDisturb_Result);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (OtherDeviceProfile.ACTION_ERROR.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(OtherDeviceProfile.ERROR_NUM);
int errorMessage = obj.getInt(OtherDeviceProfile.ERROR_DESCRIPTION);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Get do not disturb mode

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getDoNotDisturbMode();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetDoNotDisturb.equals(action)) {
try {
JSONObject obj = new JSONObject(message);

/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.GetDoNotDisturb_Result);

/**
* @return enable 0: close; 1: open
*/
int enable = obj.getInt(Am6Profile.GetDoNotDisturb_Enable);

/**
* @return start
*/
int start = obj.getInt(Am6Profile.GetDoNotDisturb_StartTime);

/**
* @return stop
*/
int stop = obj.getInt(Am6Profile.GetDoNotDisturb_EndTime);

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Set alarm clock

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);

Am6Command.AlarmClockInfo info = new Am6Command.AlarmClockInfo();
info.ts = 600; // This is the minute from the day starts, such as 10:10 am, it is 60 * 10 + 10, the range is 0 ~ 1439
info.isOpen = true; // is open or close.
info.week = new boolean[]{true, true, true ,true, true, true, true}; //which day is repeat, the array format is [sun, mon, tus, wed, thur, fri, sat]. true means repeat; false means don't.
/**
* @param info
*/
control.setAlarmClockList(Am6Command.AlarmClockInfo info);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_SetAlarmClockList.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.SetAlarmClockList_Status);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Get alarm clock

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getAlarmClockList();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.GetAlarmClockList_List.equals(action)) {
try {
JSONObject obj = new JSONObject(message);

/**
* @return result 0: failure; 1: success
*/
int status = obj.getInt(Am6Profile.GetAlarmClockList_Status);

/**
* @return enable 0: close; 1: open
*/
int enable = obj.getInt(Am6Profile.GetAlarmClockList_Enable);

/**
* @return time This is the minute from the day starts, such as 10:10 am, it is 60 * 10 + 10.
*/
int time = obj.getInt(Am6Profile.GetAlarmClockList_Time);

/**
* @return week //whick day is repeat, the array format is [sun, mon, tus, wed, thur, fri, sat]. 1 means repeat; 0 means don't.
*/
JSONArray week = obj.getJSONArray(Am6Profile.GetAlarmClockList_Week);

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

How to sync data with AM6

Ready to sync data

important

Before synchronizing data each time, it is recommended to notify Am6 to prepare for synchronizing data, which will ensure that there is no error between the transmitted data and the table display data

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.readySyncData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_ReadySyncData.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.ReadySyncData_Status);

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Daily data

info

The daily report is a summary of the data for the day.

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getDailyData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetDailyData.equals(action)) {
try {
JSONArray arr = new JSONArray(message);
for (JSONObject obj : arr) {

// The date of daily report, date format is "yyyy-MM-DD HH:MM:SS"
String date = obj.getString(Am6Profile.GetDailyData_Date);

// The step of daily report
int step = obj.getInt(Am6Profile.GetDailyData_Step);

// The calorie of daily report
int calorie = obj.getInt(Am6Profile.GetDailyData_Calorie);

// The blood oxygen of daily report
int bloodOxygen = obj.getInt(Am6Profile.GetDailyData_BloodOxygen);

// The heart rate of daily report
int heartRate = obj.getInt(Am6Profile.GetDailyData_HeartRate);

// The min heart rate of daily report
int minHeartRate = obj.getInt(Am6Profile.GetDailyData_MinHeartRate);

// The max heart rate of daily report
int maxHeartRate = obj.getInt(Am6Profile.GetDailyData_MaxHeartRate);

// The mean heart rate of daily report
int meanHeartRate = obj.getInt(Am6Profile.GetDailyData_MeanHeartRate);

// The rest heart rate of daily report
int restHeartRate = obj.getInt(Am6Profile.GetDailyData_RestHeartRate);

// The time of day when the minimum heart rate occurs, date format is "yyyy-MM-DD HH:MM:SS"
// If the value is "2000-00-00 00:00:00", it means don't have heart rate result.
String minHeartRateTime = obj.getString(Am6Profile.GetDailyData_MinHeartRateTime);

// The time of day when your maximum heart rate occurs, date format is "yyyy-MM-DD HH:MM:SS"
// If the value is "2000-00-00 00:00:00", it means don't have heart rate result.
String maxHeartRateTime = obj.getString(Am6Profile.GetDailyData_MaxHeartRateTime);

// The standing time of daily report
int effectiveStand = obj.getInt(Am6Profile.GetDailyData_EffectiveStand);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Step Data

info

The data is counted every hour. The data includes steps, calories, and distance.

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getStepData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetStepData.equals(action)) {
try {
JSONArray arr = new JSONArray(message);
for (JSONObject obj : arr) {

// The start time of this day, date format is "yyyy-MM-DD HH:MM:SS"
String date = obj.getString(Am6Profile.GetStepData_Date);

JSONArray array = obj.getJSONArray(Am6Profile.GetStepData_List);
for (JSONObject o: array) {
int step = obj.getInt(Am6Profile.GetStepData_Step);
int calorie = obj.getInt(Am6Profile.GetStepData_Calorie);
int distance = obj.getInt(Am6Profile.GetStepData_Distance);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Sleep data

info

This API returns sleep detail data in the form of sleep segments. Each sleep segment contains start date and sleep details. The start date starts at 0:00 of the current day. The sleep details include the sleep mode and the start time of this mode. For example, a person goes to bed at 2023-06-27 23:11 in the evening and wakes up at 2023-06-28 02:19 o'clock the next morning.

[{"am6_getSleepData_date":"2023-06-27 00:00:00","am6_getSleepData_list":[ {"am6_getSleepData_mode":2,"am6_getSleepData_mode_date":"23:11"}, {"am6_getSleepData_mode":1,"am6_getSleepData_mode_date":"23:39"}, {"am6_getSleepData_mode":2,"am6_getSleepData_mode_date":"23:57"}, {"am6_getSleepData_mode":1,"am6_getSleepData_mode_date":"00:26"}, {"am6_getSleepData_mode":2,"am6_getSleepData_mode_date":"00:41"}, {"am6_getSleepData_mode":1,"am6_getSleepData_mode_date":"01:09"}, {"am6_getSleepData_mode":2,"am6_getSleepData_mode_date":"01:18"}, {"am6_getSleepData_mode":0,"am6_getSleepData_mode_date":"01:19"}, {"am6_getSleepData_mode":2,"am6_getSleepData_mode_date":"01:51"}, {"am6_getSleepData_mode":0,"am6_getSleepData_mode_date":"02:19"}]}]

Sleep Mode
1start to sleep
2light sleep
3deep sleep
4wake
5exit sleep
6rapid eye movement (REM)
Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getSleepData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetSleepData.equals(action)) {
try {
JSONObject obj = new JSONObject

// The date of sleep, date format is "yyyy-MM-DD HH:MM:SS"
String date = obj.getString(Am6Profile.GetSleepData_Date);

// The sleep detail list
JSONArray arr = obj.getJSONArray(Am6Profile.GetSleepData_List);
for (JSONObject o : arr) {

// The mode of sleep
int sleepMode = o.getInt(Am6Profile.GetSleepData_Mode);

// The start time of this sleep mode, date format is "yyyy-MM-DD HH:MM:SS"
String sleepModeDate = o.getString(Am6Profile.GetSleepData_Mode_Duration);
}

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Heart rate data

info

The data is counted every 5 minutes. The data includes heart rate data.

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getHeartRateData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetHeartRateData.equals(action)) {
try {
JSONArray arr = new JSONArray(message);
for (JSONObject obj : arr) {

// The start time of this day, date format is "yyyy-MM-DD HH:MM:SS"
String date = obj.getString(Am6Profile.GetHeartRateData_Date);

JSONArray array = obj.getJSONArray(Am6Profile.GetHeartRateData_List);
for (JSONObject o: array) {
// The value of heart rate
int heartRate = obj.getInt(Am6Profile.GetHeartRateData_HeartRate);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Blood oxygen data

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getBloodOxygenData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetBloodOxygenData.equals(action)) {
try {
JSONArray arr = new JSONArray(message);
for (JSONObject obj : arr) {

// The time of measure blood oxygen, date format is "yyyy-MM-DD HH:MM:SS"
String date = obj.getString(Am6Profile.GetBloodOxygenData_Date);

// The value of blood oxygen
int bloodOxygen = obj.getInt(Am6Profile.GetBloodOxygenData_BloodOxygen);

}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Activity data

warning

There are a lot of active data, please pay attention to memory management when processing data

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
control.getActivityData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_GetActivityData.equals(action)) {

try {
JSONArray totalArray = new JSONArray(message);

for (JSONObject totalObj: totalArray) {
// The start time of activity
String date = totalObj.getString(Am6Profile.GetActivityData_Date);

// Activity point data
JSONArray pointArr = object.getJSONArray(Am6Profile.GetActivityData_List);
// A data point is generated every 10 seconds
for (JSONObject obj : pointArr) {
int calorie = obj.getInt(Am6Profile.GetActivityData_Calorie);
int step = obj.getInt(Am6Profile.GetActivityData_Step);
int heartRate = obj.getInt(Am6Profile.GetActivityData_HeartRate);
int distance = obj.getInt(Am6Profile.GetActivityData_Distance);
}

// activity daily report
JSONObject reportObj = object.getObject(Am6Profile.GetActivityData_Report);

// The start time of activity, date format is "yyyy-MM-DD HH:MM:SS"
String startTime = reportObj.getString(Am6Profile.GetActivityData_StartDate);

// The end time of activity, date format is "yyyy-MM-DD HH:MM:SS"
String endTime = reportObj.getString(Am6Profile.GetActivityData_EndDate);

// The total time of activity, the unit is second
int totalTime = reportObj.getInt(Am6Profile.GetActivityData_TotalTime);

// The total distance of activity, the unit is meter
int totalDistance = reportObj.getInt(Am6Profile.GetActivityData_TotalDistance);

// The total calorie of activity, the unit is meter
int totalCalorie = reportObj.getInt(Am6Profile.GetActivityData_TotalCalorie);

// The total step of activity
int totalStep = reportObj.getInt(Am6Profile.GetActivityData_TotalStep);

// The max running pace, the unit is second / 100 meter
int maxPace = reportObj.getInt(Am6Profile.GetActivityData_MaxPace);

// The min running pace, the unit is second / 100 meter
int minPace = reportObj.getInt(Am6Profile.GetActivityData_MinPace);

// The max freguency of step
int maxStepFrequency = reportObj.getInt(Am6Profile.GetActivityData_MaxStepFrequency);

// The average heart rate
int aveHeartRate = reportObj.getInt(Am6Profile.GetActivityData_AveHeartRate);

// The max heart rate
int maxHeartRate = reportObj.getInt(Am6Profile.GetActivityData_MaxHeartRate);

// The min heart rate
int minHeartRate = reportObj.getInt(Am6Profile.GetActivityData_MinHeartRate);

// The training effect
int training = reportObj.getInt(Am6Profile.GetActivityData_TrainingEffect);

// The max oxygen uptake, the unit is milliliter/minute
int maxOxygenUpdake = reportObj.getInt(Am6Profile.GetActivityData_MaxOxygenUptake);

// The body energy expenditure, the range is 0 ~ 100
int bodyCost = reportObj.getInt(Am6Profile.GetActivityData_BodyEnergyCost);

// The estimated recovery time
int recoveryTime = reportObj.getInt(Am6Profile.GetActivityData_EstimatedRecoveryTime);

// The ultimate heart rate duration, the unit is second
int peakTime = reportObj.getInt(Am6Profile.GetActivityData_PeakTime);

// The anaerobic endurance duration, the unit is second
int anaerobicTime = reportObj.getInt(Am6Profile.GetActivityData_AnaerobicTime);

// The aerobic endurance duration, the unit is second
int cardioTime = reportObj.getInt(Am6Profile.GetActivityData_CardioTime);

// The fat burning duration, the unit is second
int fatReductionTime = reportObj.getInt(Am6Profile.GetActivityData_FatReductionTime);

// The warm up time, the unit is secode
int warmUpTime = reportObj.getInt(Am6Profile.GetActivityData_WarmUpTime);
}

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Delete data

warning

Please ensure that the data is complete, and call the delete data API carefully

Am6Control control = iHealthDevicesManager.getInstance().getAm6Control(mDeviceMac);
/**
* @param num 0x1: step and calorie data;
0x2: sleep data;
0x4: heart rate data;
0x8: blood oxygen data;
0x10: daily report;
0x20: activity data;
0x8000: All data
*/
control.deleteData(int num);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Am6Profile.Action_DeleteData.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/**
* @return result 0: failure; 1: success
*/
int result = obj.getInt(Am6Profile.DeleteData_Result);

} catch (JSONException e) {
e.printStackTrace();
}
}
}
}

Error Message

Error
Error IdError Message
1003InputParameterError