From ed2c099c0a8aaa12a190996501e4f7f98fd7ee12 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Mon, 30 Apr 2018 12:58:06 +0200 Subject: [PATCH] First byte is user id not scale type See #248 --- .../openscale/core/bluetooth/BluetoothExingtechY1.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java index efe1aff5..f9de7a81 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java @@ -83,16 +83,13 @@ public class BluetoothExingtechY1 extends BluetoothCommunication { public void onBluetoothDataChange(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic) { final byte[] data = gattCharacteristic.getValue(); - if (data != null && data.length > 0) { - // if data is body scale type - if (data[0] == (byte)0x01 && data.length == 20) { - parseBytes(data); - } + if (data != null && data.length == 20) { + parseBytes(data); } } private void parseBytes(byte[] weightBytes) { - int userId = weightBytes[0] & 0x0F; + int userId = weightBytes[0] & 0xFF; int gender = weightBytes[1] & 0xFF; // 0x00 male; 0x01 female int age = weightBytes[2] & 0xFF; // 10 ~ 99 int height = weightBytes[3] & 0xFF; // 0 ~ 255