BG5S
info
- BG5S is a low-power Bluetooth glucose meter with indicator lights, a screen and button.
- When you use BG5S for first time or haven't used it for a long time, Please charge it for 2~4 hours to make BG5S have enough power, and then start using it.
- The BG5S support two way to turn on. One is turn on by inserting test strip, the other is turn on by pressing button.
- BG5S support online measurement and offline measurement.
- Once the device is turned on, it begins Bluetooth broadcasting and can be scanned and connected to by the app.
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_BG5S);
iHealthDevicesManager.getInstance().addCallbackFilterForAddress(callbackId, String... macs)
2.Scan for BG5S devices
iHealthDevicesManager.getInstance().startDiscovery(DiscoveryTypeEnum.BG5S);
3.Connect to BG5S devices
iHealthDevicesManager.getInstance().connectDevice("", mac, iHealthDevicesManager.TYPE_BG5S)
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
API reference
Get status information from BG5S
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
control.getStatusInfo();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Bg5sProfile.ACTION_GET_STATUS_INFO.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
// The battery level of BG5S.
int batteryLevel = obj.getInt(Bg5sProfile.INFO_BATTERY_LEVEL);
// The time of BG5S.
String timeStr = obj.getString(Bg5sProfile.INFO_TIME);
// The timezone of BG5S.
int timeZone = obj.getInt(Bg5sProfile.INFO_TIMEZONE);
// The number of test strips used.
int usedStrip = obj.getInt(Bg5sProfile.INFO_USED_STRIP);
// The number of offline data.
int offlineDataNum = obj.getInt(Bg5sProfile.INFO_OFFLINE_DATA_NUM);
// The code version of strip.
int mCodeVersionBlood = obj.getInt(Bg5sProfile.INFO_CODE_VERSION_BLOOD);
// The code version of control solution strip.
int mCodeVersionCTL = obj.getInt(Bg5sProfile.INFO_CODE_VERSION_CTL);
// The unit of BG5S.
int unit = obj.getInt(Bg5sProfile.INFO_UNIT);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
Set offline measurement mode
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
/**
* @param enable enable offline measurement.
*/
control.setOfflineMeasurementMode(boolean enable);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Bg5sProfile.ACTION_SET_OFFLINE_MEASUREMENT_MODE.equals(action)) {
Log.i("", "Set offline measurement mode");
}
}
}
Set time to BG5 device
/**
* @param date
* @param timeZone
*/
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
control.setTime(Date date, float timeZone);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Bg5sProfile.ACTION_SET_TIME.equals(action)) {
Log.i("", "Set time success");
}
}
}
Set unit to BG5S device
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
/**
* @param unitType the unit type set to BG5S: Bg5sProfile.UNIT_MMOL; Bg5sProfile.UNIT_MG
*/
control.setUnit(int type);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Bg5sProfile.ACTION_SET_UNIT.equals(action)) {
Log.i("", "Set unit success");
}
}
}
Set BG5S display mode
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
/**
* @param mode enable display mode.
*/
control.setDisplayMode(boolean mode);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Bg5sProfile.ACTION_SET_DISPLAY_MODE.equals(action)) {
Log.i("", "Set display mode success");
}
}
}
Delete number of test strips used.
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
control.deleteUsedStrip();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Bg5sProfile.ACTION_DELETE_USED_STRIP.equals(action)) {
Log.i("", "Delete success");
}
}
}
Delete offline data of BG5S
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
control.deleteOfflineData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Bg5sProfile.ACTION_DELETE_OFFLINE_DATA.equals(action)) {
Log.i("", "Delete success");
}
}
}
Get offline data from BG5S
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
control.getOfflineData();
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Bg5sProfile.ACTION_GET_OFFLINE_DATA.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
JSONArray historyArr = obj.getgetJSONArray(Bg5sProfile.OFFLINE_DATA);
for (int i = 0; i < historyArr.length(); i++) {
JSONObject obj = historyArr.getJSONObject(i);
boolean dateStr = obj.getBoolean(Bg5sProfile.DATA_TIME_PROOF);
int value = obj.getString(Bg5sProfile.DATA_VALUE);
String time = obj.getString(Bg5sProfile.DATA_MEASURE_TIME);
float timezone = obj.getString(Bg5sProfile.DATA_MEASURE_TIMEZONE);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
Start measure
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
/**
* @param measureType the measure type set to BG5S.Bg5sProfile.MEASURE_BLOOD Bg5sProfile.MEASURE_CTL
*/
control.startMeasure(int measureType);
// Return value
private iHealthDevicesCallback miHealthDevicesCallback = new iHealthDevicesCallback() {
@Override
public void onDeviceNotify(String mac, String deviceType, String action, String message) {
if (Bg5sProfile.ACTION_START_MEASURE.equals(action)) {
Log.i("start a measure")
} else if (Bg5sProfile.ACTION_STRIP_IN.equals(action)) {
Log.i("test strip in")
} else if (Bg5sProfile.ACTION_GET_BLOOD.equals(action)) {
Log.i("test drop blood")
} else if (Bg5sProfile.ACTION_RESULT.equals(action)) {
try {
JSONObject obj = new JSONObject(message);
int value = obj.getInt(Bg5sProfile.RESULT_VALUE);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (Bg5sProfile.ACTION_STRIP_OUT.equals(action)) {
Log.i("test strip out")
}
}
}
Correct date of offline data
When you use BG5S for first time or haven't used it for a long time, before you take an offline measurement, you need to connect your phone to sync the time. But if you forget to sunc the time and take an offline measurement, this API can correct the time.
Bg5sControl control = iHealthDevicesManager.getInstance().getBg5sControl(mDeviceMac);
/**
* @param timeString The device time from getStatusInfo API
* @param originData The origin data from getOfflineData API
* @return Correct offline data
*/
String newOfflineData = control.adjustOfflineData(String timeString, String originData);