mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-18 06:21:25 +02:00
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.health.openscale.core.bluetooth;
|
||||
|
||||
import static com.health.openscale.core.bluetooth.BluetoothCommunication.BT_STATUS.UNEXPECTED_ERROR;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
@@ -28,7 +30,6 @@ import com.health.openscale.core.utils.Converters;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
@@ -36,8 +37,6 @@ import java.util.UUID;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.health.openscale.core.bluetooth.BluetoothCommunication.BT_STATUS.UNEXPECTED_ERROR;
|
||||
|
||||
public class BluetoothMiScale2 extends BluetoothCommunication {
|
||||
private final UUID WEIGHT_MEASUREMENT_HISTORY_CHARACTERISTIC = UUID.fromString("00002a2f-0000-3512-2118-0009af100700");
|
||||
|
||||
@@ -74,13 +73,6 @@ public class BluetoothMiScale2 extends BluetoothCommunication {
|
||||
resumeMachineState();
|
||||
}
|
||||
|
||||
if (data.length == 26) {
|
||||
final byte[] firstWeight = Arrays.copyOfRange(data, 0, 10);
|
||||
final byte[] secondWeight = Arrays.copyOfRange(data, 10, 20);
|
||||
parseBytes(firstWeight);
|
||||
parseBytes(secondWeight);
|
||||
}
|
||||
|
||||
if (data.length == 13) {
|
||||
parseBytes(data);
|
||||
}
|
||||
@@ -141,13 +133,12 @@ public class BluetoothMiScale2 extends BluetoothCommunication {
|
||||
final byte ctrlByte1 = data[1];
|
||||
|
||||
final boolean isWeightRemoved = isBitSet(ctrlByte1, 7);
|
||||
final boolean isDateInvalid = isBitSet(ctrlByte1, 6);
|
||||
final boolean isStabilized = isBitSet(ctrlByte1, 5);
|
||||
final boolean isLBSUnit = isBitSet(ctrlByte0, 0);
|
||||
final boolean isCattyUnit = isBitSet(ctrlByte1, 6);
|
||||
final boolean isImpedance = isBitSet(ctrlByte1, 1);
|
||||
|
||||
if (isStabilized && !isWeightRemoved && !isDateInvalid) {
|
||||
if (isStabilized && !isWeightRemoved) {
|
||||
|
||||
final int year = ((data[3] & 0xFF) << 8) | (data[2] & 0xFF);
|
||||
final int month = (int) data[4];
|
||||
|
Reference in New Issue
Block a user