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

Recognize later revisions of inlife scales

But don't add any measurement as we need someone that owns the scale
to test the support.
This commit is contained in:
Erik Johansson
2018-11-20 20:34:32 +01:00
parent 38b1649dd5
commit 8740d55361
2 changed files with 24 additions and 2 deletions

View File

@@ -86,7 +86,8 @@ public class BluetoothFactory {
// Trisa Body Analyze 4.0, aka Transtek GBF-1257-B
return new BluetoothTrisaBodyAnalyze(context);
}
if (deviceName.equals("000FatScale01")) {
if (deviceName.equals("000FatScale01") || deviceName.equals("000FatScale02")
|| deviceName.equals("042FatScale01")) {
return new BluetoothInlife(context);
}
return null;

View File

@@ -20,6 +20,7 @@ import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.content.Context;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
@@ -139,9 +140,15 @@ public class BluetoothInlife extends BluetoothCommunication {
case (byte) 0xd8:
float weight = Converters.fromUnsignedInt16Be(data, 2) / 10.0f;
Timber.d("Current weight %.2f kg", weight);
sendMessage(R.string.info_measuring, weight);
break;
case (byte) 0xdd:
processMeasurementData(data);
if (data[11] == (byte) 0x80 || data[11] == (byte) 0x81) {
processMeasurementDataNewVersion(data);
}
else {
processMeasurementData(data);
}
break;
case (byte) 0xdf:
Timber.d("Data received by scale: %s", data[2] == 0 ? "OK" : "error");
@@ -158,6 +165,11 @@ public class BluetoothInlife extends BluetoothCommunication {
float visceralFactor = Converters.fromUnsignedInt16Be(data, 7) / 10.0f;
float bmr = Converters.fromUnsignedInt16Be(data, 9) / 10.0f;
if (lbm == 0xffffff / 1000.0f) {
Timber.e("Measurement failed; feet not correctly placed on scale?");
return;
}
Timber.d("weight=%.1f, LBM=%.3f, visceral factor=%.1f, BMR=%.1f",
weight, lbm, visceralFactor, bmr);
@@ -221,4 +233,13 @@ public class BluetoothInlife extends BluetoothCommunication {
sendCommand(0xd4, null);
}
void processMeasurementDataNewVersion(byte[] data) {
float weight = Converters.fromUnsignedInt16Be(data, 2) / 10.0f;
long impedance = Converters.fromUnsignedInt32Be(data, 4);
Timber.d("weight=%.2f, impedance=%d", weight, impedance);
// Uses the same library as 1byone, but we need someone that has the scale to be able to
// test if it works the same way.
}
}