1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-20 23:41:45 +02:00

First byte is user id not scale type

See #248
This commit is contained in:
Erik Johansson
2018-04-30 12:58:06 +02:00
parent 61649dec95
commit ed2c099c0a

View File

@@ -83,16 +83,13 @@ public class BluetoothExingtechY1 extends BluetoothCommunication {
public void onBluetoothDataChange(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic) { public void onBluetoothDataChange(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic) {
final byte[] data = gattCharacteristic.getValue(); final byte[] data = gattCharacteristic.getValue();
if (data != null && data.length > 0) { if (data != null && data.length == 20) {
// if data is body scale type parseBytes(data);
if (data[0] == (byte)0x01 && data.length == 20) {
parseBytes(data);
}
} }
} }
private void parseBytes(byte[] weightBytes) { 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 gender = weightBytes[1] & 0xFF; // 0x00 male; 0x01 female
int age = weightBytes[2] & 0xFF; // 10 ~ 99 int age = weightBytes[2] & 0xFF; // 10 ~ 99
int height = weightBytes[3] & 0xFF; // 0 ~ 255 int height = weightBytes[3] & 0xFF; // 0 ~ 255