1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-07 01:06:57 +02:00

invoke BT_RETRIEVE_SCALE_DATA message only if a new scale data is available

This commit is contained in:
OliE
2016-12-17 09:37:15 +01:00
parent c6355f7e32
commit 447046abb4

View File

@@ -154,7 +154,11 @@ class BluetoothCustomOpenScale extends BluetoothCommunication {
btLine.append(btChar); btLine.append(btChar);
if (btLine.charAt(btLine.length() - 1) == '\n') { if (btLine.charAt(btLine.length() - 1) == '\n') {
callbackBtHandler.obtainMessage(BluetoothCommunication.BT_RETRIEVE_SCALE_DATA, parseBtString(btLine.toString())).sendToTarget(); ScaleData scaleData = parseBtString(btLine.toString());
if (scaleData != null) {
callbackBtHandler.obtainMessage(BluetoothCommunication.BT_RETRIEVE_SCALE_DATA, scaleData).sendToTarget();
}
btLine.setLength(0); btLine.setLength(0);
} }
@@ -215,6 +219,8 @@ class BluetoothCustomOpenScale extends BluetoothCommunication {
scaleBtData.fat = Float.parseFloat(csvField[7]); scaleBtData.fat = Float.parseFloat(csvField[7]);
scaleBtData.water = Float.parseFloat(csvField[8]); scaleBtData.water = Float.parseFloat(csvField[8]);
scaleBtData.muscle = Float.parseFloat(csvField[9]); scaleBtData.muscle = Float.parseFloat(csvField[9]);
return scaleBtData;
} else { } else {
callbackBtHandler.obtainMessage(BluetoothCommunication.BT_UNEXPECTED_ERROR, "Error calculated checksum (" + checksum + ") and received checksum (" + btChecksum + ") is different").sendToTarget(); callbackBtHandler.obtainMessage(BluetoothCommunication.BT_UNEXPECTED_ERROR, "Error calculated checksum (" + checksum + ") and received checksum (" + btChecksum + ") is different").sendToTarget();
} }
@@ -228,7 +234,7 @@ class BluetoothCustomOpenScale extends BluetoothCommunication {
callbackBtHandler.obtainMessage(BluetoothCommunication.BT_UNEXPECTED_ERROR, "Error unknown MCU command").sendToTarget(); callbackBtHandler.obtainMessage(BluetoothCommunication.BT_UNEXPECTED_ERROR, "Error unknown MCU command").sendToTarget();
} }
return scaleBtData; return null;
} }
public void write(byte[] bytes) { public void write(byte[] bytes) {