1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-23 16:53:04 +02:00

Updated code with correct starting byte xf7

This commit is contained in:
linuxlurak
2017-12-15 09:55:00 +01:00
committed by GitHub
parent 1c06a491df
commit 4b31eb4ae0

View File

@@ -159,7 +159,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
break; break;
case 3: case 3:
// Request general user information // Request general user information
writeBytes(new byte[]{(byte) 0xe7, (byte) 0x33}); writeBytes(new byte[]{(byte) 0xf7, (byte) 0x33});
break; break;
case 4: case 4:
// Wait for ack of all users // Wait for ack of all users
@@ -192,7 +192,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
Log.d(TAG, "Create User:" + selectedUser.user_name); Log.d(TAG, "Create User:" + selectedUser.user_name);
writeBytes(new byte[]{ 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) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
(byte) (seenUsers.size() > 0 ? Collections.max(seenUsers) + 1 : 101), (byte) (seenUsers.size() > 0 ? Collections.max(seenUsers) + 1 : 101),
nick[0], nick[1], nick[2], nick[0], nick[1], nick[2],
@@ -206,7 +206,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
// Get existing user information // Get existing user information
Log.d(TAG, "Request getUserInfo " + currentScaleUserId); Log.d(TAG, "Request getUserInfo " + currentScaleUserId);
writeBytes(new byte[]{ 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 (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"); Log.d(TAG, "Request Saved User Measurements");
writeBytes(new byte[]{ 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; break;
@@ -281,7 +281,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
return; 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"); Log.d(TAG, "ACK Got general user information");
int count = (byte) (data[4] & 0xFF); int count = (byte) (data[4] & 0xFF);
@@ -295,10 +295,10 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
maxRegisteredScaleUser = maxUsers; maxRegisteredScaleUser = maxUsers;
nextMachineStateStep(); 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"); Log.d(TAG, "Ack Get UUIDSs List of Users");
byte currentUserMax = (byte) (data[2] & 0xFF); byte currentUserMax = (byte) (data[2] & 0xFF);
@@ -324,7 +324,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
} }
Log.d(TAG, "Send ack gotUser"); Log.d(TAG, "Send ack gotUser");
writeBytes(new byte[]{ writeBytes(new byte[]{
(byte) 0xe7, (byte) 0xf1, (byte) 0x34, currentUserMax, (byte) 0xf7, (byte) 0xf1, (byte) 0x34, currentUserMax,
currentUserID currentUserID
}); });
} }
@@ -332,7 +332,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
return; 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"); Log.d(TAG, "Ack Get User Info Initials");
String name = new String(data, 4, 3); String name = new String(data, 4, 3);
byte year = (byte) (data[7] & 0xFF); byte year = (byte) (data[7] & 0xFF);
@@ -349,7 +349,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
// Get scale status for user // Get scale status for user
writeBytes(new byte[]{ 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 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) currentScaleUserId
}); });
@@ -357,7 +357,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
return; 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"); Log.d(TAG, "Ack Get scale status");
int unknown = data[3]; int unknown = data[3];
@@ -377,7 +377,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
return; 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"); Log.d(TAG, "Acknowledge creation of user");
// Indicate user to step on scale // Indicate user to step on scale
@@ -385,7 +385,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
// Request basement measurement // Request basement measurement
writeBytes(new byte[]{ 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) (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"); Log.d(TAG, "Will start to receive measurements User Specific");
byte nr_measurements = data[3]; byte nr_measurements = data[3];
@@ -403,7 +403,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
return; 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"); Log.d(TAG, "Specific measurement User specific");
// Measurements are split into two parts // Measurements are split into two parts
@@ -424,7 +424,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
// Send acknowledgement // Send acknowledgement
writeBytes(new byte[]{ 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) (byte) (data[3] & 0xFF)
}); });
@@ -445,7 +445,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
return; return;
} }
if ((data[0] & 0xFF) == 0xe7 && (data[1] & 0xFF) == 0x58) { if ((data[0] & 0xFF) == 0xf7 && (data[1] & 0xFF) == 0x58) {
Log.d(TAG, "Active measurement"); Log.d(TAG, "Active measurement");
if ((data[2] & 0xFF) != 0x00) { if ((data[2] & 0xFF) != 0x00) {
// little endian // little endian
@@ -468,7 +468,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
writeBytes(new byte[]{ 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), (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 // Get stable measurement results
Log.d(TAG, "Get measurement data " + ((int) data[3])); 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 // Send ack that we got the data
writeBytes(new byte[]{ writeBytes(new byte[]{
(byte) 0xe7, (byte) 0xf1, (byte) 0xf7, (byte) 0xf1,
(byte) (data[1] & 0xFF), (byte) (data[2] & 0xFF), (byte) (data[1] & 0xFF), (byte) (data[2] & 0xFF),
(byte) (data[3] & 0xFF), (byte) (data[3] & 0xFF),
}); });
@@ -517,7 +517,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
return; 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."); Log.d(TAG, "Acknowledge: Data deleted.");
return; return;
} }
@@ -527,7 +527,7 @@ public class BluetoothBeurerBF700 extends BluetoothCommunication {
private void deleteScaleData() { private void deleteScaleData() {
writeBytes(new byte[]{ 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) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
(byte) currentScaleUserId (byte) currentScaleUserId
}); });