1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-14 12:44:15 +02:00

Update BluetoothOKOK.java (#931)

Support for additional OKOK/Chipsea-BLE based scale
This commit is contained in:
rrooggiieerr
2023-02-26 19:10:07 +01:00
committed by GitHub
parent 09966709dd
commit 437166483f

View File

@@ -22,6 +22,7 @@ import timber.log.Timber;
public class BluetoothOKOK extends BluetoothCommunication {
private static final int MANUFACTURER_DATA_ID_V20 = 0x20ca; // 16-bit little endian "header" 0xca 0x20
private static final int MANUFACTURER_DATA_ID_V11 = 0x11ca; // 16-bit little endian "header" 0xca 0x11
private static final int MANUFACTURER_DATA_ID_VF0 = 0xf0ff; // 16-bit little endian "header" 0xff 0xf0
private static final int IDX_V20_FINAL = 6;
private static final int IDX_V20_WEIGHT_MSB = 8;
private static final int IDX_V20_WEIGHT_LSB = 9;
@@ -34,6 +35,9 @@ public class BluetoothOKOK extends BluetoothCommunication {
private static final int IDX_V11_BODY_PROPERTIES = 9;
private static final int IDX_V11_CHECKSUM = 16;
private static final int IDX_VF0_WEIGHT_MSB = 3;
private static final int IDX_VF0_WEIGHT_LSB = 2;
private BluetoothCentralManager central;
private final BluetoothCentralManagerCallback btCallback = new BluetoothCentralManagerCallback() {
@Override
@@ -115,6 +119,16 @@ public class BluetoothOKOK extends BluetoothCommunication {
entry.setWeight(extraWeight + weight / divider);
addScaleMeasurement(entry);
disconnect();
} else if (manufacturerSpecificData.indexOfKey(MANUFACTURER_DATA_ID_VF0) > -1) {
byte[] data = manufacturerSpecificData.get(MANUFACTURER_DATA_ID_VF0);
float divider = 10.0f;
int weight = data[IDX_VF0_WEIGHT_MSB] & 0xff;
weight = weight << 8 | (data[IDX_VF0_WEIGHT_LSB] & 0xff);
Timber.d("Got weight: %f", weight / divider);
ScaleMeasurement entry = new ScaleMeasurement();
entry.setWeight(weight / divider);
addScaleMeasurement(entry);
disconnect();
}
}
};