PO3
WorkFlow
Scan and connect PO3 scale.
PO3 support online measurement and offline measurement.
Connection to device
1.Listen to device notify
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onScanDevice(String mac, String deviceType, int rssi, Map manufactorData) { }
@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 onDeviceNotify(String mac, String deviceType, String action, String message) { }
}
int callbackId = iHealthDevicesManager.getInstance().registerClientCallback(miHealthDevicesCallback);
iHealthDevicesManager.getInstance().addCallbackFilterForDeviceType(callbackId, iHealthDevicesManager.TYPE_PO3);
iHealthDevicesManager.getInstance().addCallbackFilterForAddress(callbackId, String... macs)
2.Scan for PO3 devices
iHealthDevicesManager.getInstance().startDiscovery(DiscoveryTypeEnum.PO3);
// Return
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onScanDevice(String mac, String deviceType, int rssi, Map manufactorData) {
Log.i(TAG, "onScanDevice - mac:" + mac + " - deviceType:" + deviceType + " - rssi:" + rssi + " - manufactorData:" + manufactorData);
}
}
3.Connect to PO3 devices
iHealthDevicesManager.getInstance().connectDevice("", mac, iHealthDevicesManager.TYPE_PO3)
Po3Control control = iHealthDevicesManager.getInstance().getPo3Control(mDeviceMac);
API reference
Set the PO3 time
info
The PO3 support this feature on firmware 3.2.0 or above. For versions 3.1.0 and later, the SDK automatically sets the time.
Po3Control control = iHealthDevicesManager.getInstance().getPo3Control(mDeviceMac);
control.setTime();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (PoProfile.ACTION_SET_TIME.equals(action)) {
Log.i("", "set time success")
}
}
}
Get the PO3 time
info
The PO3 support this feature on firmware 3.2.0 or above.
Po3Control control = iHealthDevicesManager.getInstance().getPo3Control(mDeviceMac);
control.getTime();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (PoProfile.ACTION_GET_TIME.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
String time = obj.getString(PoProfile.GET_TIME);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (PoProfile.ACTION_ERROR_PO.equals(action)) {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(PoProfile.ERROR_NUM_PO);
if (errorId == 403) {
Log.i("", "This firmware don't support this API");
}
}
}
}
Get the PO3 battery status
Po3Control control = iHealthDevicesManager.getInstance().getPo3Control(mDeviceMac);
control.getBattery();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (PoProfile.ACTION_BATTERY_PO.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int battery = obj.getInt(PoProfile.BATTERY_PO);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
Get the PO3 device infomation
info
The PO3 support this feature on firmware 3.1.1 or above.
Po3Control control = iHealthDevicesManager.getInstance().getPo3Control(mDeviceMac);
control.getDeviceInfo();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (PoProfile.ACTION_GET_DEVICE_INFO.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/*
* charge status 0: PO3 is not charging; 1: PO3 is charging
*/
int status = obj.getInt(PoProfile.GET_DEVICE_INFO_BATTERY_STATUS);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (PoProfile.ACTION_ERROR_PO.equals(action)) {
JSONObject obj = new JSONObject(message);
int errorId = obj.getInt(PoProfile.ERROR_NUM_PO);
if (errorId == 403) {
Log.i("", "This firmware don't support this API");
}
}
}
}
Notify the PO3 device infomation
info
The PO3 support this feature on firmware 3.1.1 or above.
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (PoProfile.ACTION_NOTIFY_DEVICE_INFO.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
/*
* charge status 0: PO3 is not charging; 1: PO3 is charging
*/
int status = obj.getInt(PoProfile.NOTIFY_INFO_BATTERY_STATUS);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
Start a measurement
warning
Don't recommend to call any other API during the measurement. Please call other API after the measurement.
Po3Control control = iHealthDevicesManager.getInstance().getPo3Control(mDeviceMac);
control.startMeasure();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (PoProfile.ACTION_LIVEDA_PO.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int bloodOxygen = obj.getInt(PoProfile.BLOOD_OXYGEN_PO);
int pulseRate = obj.getInt(PoProfile.PULSE_RATE_PO);
int pulseStrength = obj.getInt(PoProfile.PULSE_STRENGTH_PO);
int pi = obj.getInt(PoProfile.PI_PO);
JSONArray pulseWave = obj.getJSONArray(PoProfile.PULSE_WAVE_PO);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (PoProfile.ACTION_RESULTDATA_PO.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int bloodOxygen = obj.getInt(PoProfile.BLOOD_OXYGEN_PO);
int pulseRate = obj.getInt(PoProfile.PULSE_RATE_PO);
int pulseStrength = obj.getInt(PoProfile.PULSE_STRENGTH_PO);
int pi = obj.getInt(PoProfile.PI_PO);
JSONArray pulseWave = obj.getJSONArray(PoProfile.PULSE_WAVE_PO);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
Get offline data
info
Version 3.2.0 and above, PO3 history data remove the pulse wave and add the PI value and whether to repair the time
Po3Control control = iHealthDevicesManager.getInstance().getPo3Control(mDeviceMac);
control.getHistoryData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (PoProfile.ACTION_NO_OFFLINEDATA_PO.equals(action)) {
Log.i("", "No offline data");
} else if (PoProfile.ACTION_OFFLINEDATA_PO.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
JSONArray arr = obj.getJSONArray();
for (JSONObject obj : arr) {
int measureDate = obj.getInt(PoProfile.MEASURE_DATE_PO);
int bloodOxygen = obj.getInt(PoProfile.BLOOD_OXYGEN_PO);
int pulseRate = obj.getInt(PoProfile.PULSE_RATE_PO);
// Version 3.2.0 and above, remove the pulse wave
// JSONArray pulseWave = obj.getJSONArray(PoProfile.PULSE_WAVE_PO);
// Only Version 3.2.0 or above.
int pi = obj.getInt(PoProfile.PI_PO);
int timeCalibration = obj.getInt(PoProfile.TIME_CALIBRATION);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
Disconnect the PO3
Po3Control control = iHealthDevicesManager.getInstance().getPo3Control(mDeviceMac);
control.disconnect();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceConnectionStateChange(String mac, String deviceType, int status, int errorID, Map manufactorData) {
if (iHealthDevicesManager.DEVICE_STATE_DISCONNECTED == status) {
Log.i("The device is disconnected");
}
}
}