mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-21 07:51:46 +02:00
Wait for scale to ack unit set command before continuing
Otherwise it seems like it doesn't take effect.
This commit is contained in:
@@ -177,10 +177,13 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
setUnitCommand();
|
setUnitCommand();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
|
// Wait for "unit" ack from scale
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
// Request general user information
|
// Request general user information
|
||||||
writeBytes(new byte[]{(byte) startByte, (byte) 0x33});
|
writeBytes(new byte[]{(byte) startByte, (byte) 0x33});
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 7:
|
||||||
// Wait for ack of all users
|
// Wait for ack of all users
|
||||||
if (seenUsers.size() < countRegisteredScaleUsers || (countRegisteredScaleUsers == -1)) {
|
if (seenUsers.size() < countRegisteredScaleUsers || (countRegisteredScaleUsers == -1)) {
|
||||||
// Request this state again
|
// Request this state again
|
||||||
@@ -233,7 +236,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
Timber.d("scaleuserid: %d, registered users: %d, extracted users: %d",
|
Timber.d("scaleuserid: %d, registered users: %d, extracted users: %d",
|
||||||
currentScaleUserId, countRegisteredScaleUsers, seenUsers.size());
|
currentScaleUserId, countRegisteredScaleUsers, seenUsers.size());
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 8:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Finish init if everything is done
|
// Finish init if everything is done
|
||||||
@@ -288,8 +291,9 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
@Override
|
@Override
|
||||||
public void onBluetoothDataChange(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic) {
|
public void onBluetoothDataChange(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic) {
|
||||||
byte[] data = gattCharacteristic.getValue();
|
byte[] data = gattCharacteristic.getValue();
|
||||||
if (data.length == 0)
|
if (data.length == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((data[0] & 0xFF) == getAlternativeStartByte(6) && (data[1] & 0xFF) == 0x00) {
|
if ((data[0] & 0xFF) == getAlternativeStartByte(6) && (data[1] & 0xFF) == 0x00) {
|
||||||
Timber.d("ACK Scale is ready");
|
Timber.d("ACK Scale is ready");
|
||||||
@@ -297,6 +301,12 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0xf0 && data[2] == 0x4d) {
|
||||||
|
Timber.d("ACK Unit set");
|
||||||
|
nextMachineStateStep();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0xf0 && data[2] == 0x33) {
|
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0xf0 && data[2] == 0x33) {
|
||||||
Timber.d("ACK Got general user information");
|
Timber.d("ACK Got general user information");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user