From 0050ec46ff9e24ca500afa79f487afc2ef6a0aaa Mon Sep 17 00:00:00 2001 From: OliE Date: Wed, 14 Feb 2018 18:35:51 +0100 Subject: [PATCH] update Hesley scale command code. --- .../openscale/core/bluetooth/BluetoothHesley.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothHesley.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothHesley.java index 05c27efa..984e4395 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothHesley.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothHesley.java @@ -51,6 +51,10 @@ public class BluetoothHesley extends BluetoothCommunication { case 0: setNotificationOn(WEIGHT_MEASUREMENT_SERVICE, WEIGHT_MEASUREMENT_CHARACTERISTIC, WEIGHT_MEASUREMENT_CONFIG); break; + case 1: + byte[] magicBytes = {(byte)0xa5, (byte)0x01, (byte)0x2c, (byte)0xab, (byte)0x50, (byte)0x5a, (byte)0x29}; + writeBytes(WEIGHT_MEASUREMENT_SERVICE, CMD_MEASUREMENT_CHARACTERISTIC, magicBytes); + break; default: return false; } @@ -72,10 +76,12 @@ public class BluetoothHesley extends BluetoothCommunication { public void onBluetoothDataChange(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic) { final byte[] data = gattCharacteristic.getValue(); + if (data != null && data.length > 0) { - // if data is valid data - if (data[1] == (byte)0x01 && data.length == 20) { + if (data.length == 20) { parseBytes(data); + + } } } @@ -101,4 +107,4 @@ public class BluetoothHesley extends BluetoothCommunication { addScaleData(scaleBtData); } -} +} \ No newline at end of file