From 4b31eb4ae09ba61d4bef03a5f2505682299dba31 Mon Sep 17 00:00:00 2001 From: linuxlurak Date: Fri, 15 Dec 2017 09:55:00 +0100 Subject: [PATCH] Updated code with correct starting byte xf7 --- .../core/bluetooth/BluetoothBeurerBF700.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothBeurerBF700.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothBeurerBF700.java index 5583aa7b..f7bebadd 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothBeurerBF700.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothBeurerBF700.java @@ -159,7 +159,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { break; case 3: // Request general user information - writeBytes(new byte[]{(byte) 0xe7, (byte) 0x33}); + writeBytes(new byte[]{(byte) 0xf7, (byte) 0x33}); break; case 4: // Wait for ack of all users @@ -192,7 +192,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { Log.d(TAG, "Create User:" + selectedUser.user_name); writeBytes(new byte[]{ - (byte) 0xe7, (byte) 0x31, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xf7, (byte) 0x31, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) (seenUsers.size() > 0 ? Collections.max(seenUsers) + 1 : 101), nick[0], nick[1], nick[2], @@ -206,7 +206,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { // Get existing user information Log.d(TAG, "Request getUserInfo " + currentScaleUserId); writeBytes(new byte[]{ - (byte) 0xe7, (byte) 0x36, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xf7, (byte) 0x36, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) currentScaleUserId }); @@ -238,7 +238,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { Log.d(TAG, "Request Saved User Measurements"); writeBytes(new byte[]{ - (byte) 0xe7, (byte) 0x41, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) currentScaleUserId + (byte) 0xf7, (byte) 0x41, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) currentScaleUserId }); break; @@ -281,7 +281,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { return; } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0xf0 && data[2] == 0x33) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0xf0 && data[2] == 0x33) { Log.d(TAG, "ACK Got general user information"); int count = (byte) (data[4] & 0xFF); @@ -295,10 +295,10 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { maxRegisteredScaleUser = maxUsers; nextMachineStateStep(); - return; + return } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0x34) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0x34) { Log.d(TAG, "Ack Get UUIDSs List of Users"); byte currentUserMax = (byte) (data[2] & 0xFF); @@ -324,7 +324,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { } Log.d(TAG, "Send ack gotUser"); writeBytes(new byte[]{ - (byte) 0xe7, (byte) 0xf1, (byte) 0x34, currentUserMax, + (byte) 0xf7, (byte) 0xf1, (byte) 0x34, currentUserMax, currentUserID }); } @@ -332,7 +332,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { return; } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0xF0 && (data[2] & 0xFF) == 0x36) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0xF0 && (data[2] & 0xFF) == 0x36) { Log.d(TAG, "Ack Get User Info Initials"); String name = new String(data, 4, 3); byte year = (byte) (data[7] & 0xFF); @@ -349,7 +349,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { // Get scale status for user writeBytes(new byte[]{ - (byte) 0xe7, (byte) 0x4f, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xf7, (byte) 0x4f, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) currentScaleUserId }); @@ -357,7 +357,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { return; } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0xf0 && (data[2] & 0xFF) == 0x4F) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0xf0 && (data[2] & 0xFF) == 0x4F) { Log.d(TAG, "Ack Get scale status"); int unknown = data[3]; @@ -377,7 +377,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { return; } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0xf0 && data[2] == 0x31) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0xf0 && data[2] == 0x31) { Log.d(TAG, "Acknowledge creation of user"); // Indicate user to step on scale @@ -385,7 +385,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { // Request basement measurement writeBytes(new byte[]{ - (byte) 0xe7, 0x40, 0, 0, 0, 0, 0, 0, 0, + (byte) 0xf7, 0x40, 0, 0, 0, 0, 0, 0, 0, (byte) (seenUsers.size() > 0 ? Collections.max(seenUsers) + 1 : 101) }); @@ -394,7 +394,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0xf0 && (data[2] & 0xFF) == 0x41) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0xf0 && (data[2] & 0xFF) == 0x41) { Log.d(TAG, "Will start to receive measurements User Specific"); byte nr_measurements = data[3]; @@ -403,7 +403,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { return; } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0x42) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0x42) { Log.d(TAG, "Specific measurement User specific"); // Measurements are split into two parts @@ -424,7 +424,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { // Send acknowledgement writeBytes(new byte[]{ - (byte) 0xe7, (byte) 0xf1, (byte) 0x42, (byte) (data[2] & 0xFF), + (byte) 0xf7, (byte) 0xf1, (byte) 0x42, (byte) (data[2] & 0xFF), (byte) (data[3] & 0xFF) }); @@ -445,7 +445,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { return; } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0x58) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0x58) { Log.d(TAG, "Active measurement"); if ((data[2] & 0xFF) != 0x00) { // little endian @@ -468,7 +468,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { writeBytes(new byte[]{ - (byte) 0xe7, (byte) 0xf1, (byte) (data[1] & 0xFF), + (byte) 0xf7, (byte) 0xf1, (byte) (data[1] & 0xFF), (byte) (data[2] & 0xFF), (byte) (data[3] & 0xFF), }); @@ -476,7 +476,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0x59) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0x59) { // Get stable measurement results Log.d(TAG, "Get measurement data " + ((int) data[3])); @@ -496,7 +496,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { // Send ack that we got the data writeBytes(new byte[]{ - (byte) 0xe7, (byte) 0xf1, + (byte) 0xf7, (byte) 0xf1, (byte) (data[1] & 0xFF), (byte) (data[2] & 0xFF), (byte) (data[3] & 0xFF), }); @@ -517,7 +517,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { return; } - if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0xf0 && (data[2] & 0xFF) == 0x43) { + if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0xf0 && (data[2] & 0xFF) == 0x43) { Log.d(TAG, "Acknowledge: Data deleted."); return; } @@ -527,7 +527,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication { private void deleteScaleData() { writeBytes(new byte[]{ - (byte) 0xe7, (byte) 0x43, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xf7, (byte) 0x43, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) currentScaleUserId });