1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-22 00:06:48 +02:00

BluetoothSwpSBF77: send user activity level to scale (Beurer BF950 and SBF77);

This commit is contained in:
Krisjans Blukis
2021-08-07 19:15:37 +03:00
parent 400327dd28
commit 6013508cca

View File

@@ -20,6 +20,7 @@
package com.health.openscale.core.bluetooth;
import android.content.Context;
import com.health.openscale.core.utils.Converters;
import com.welie.blessed.BluetoothBytesParser;
import java.util.Arrays;
@@ -34,6 +35,7 @@ class BluetoothGattUuidSBF77 extends BluetoothGattUuid {
public static final UUID SERVICE_CUSTOM_SBF77 = fromShortCode(0xffff);
public static final UUID CHARACTERISTIC_SBF77_USER_LIST = fromShortCode(0x0001);
public static final UUID CHARACTERISTIC_SBF77_INITIALS = fromShortCode(0x0002);
public static final UUID CHARACTERISTIC_SBF77_ACTIVITY_LEVEL = fromShortCode(0x0004);
}
public class BluetoothSwpSBF77 extends BluetoothStandardWeightProfile {
@@ -58,6 +60,16 @@ public class BluetoothSwpSBF77 extends BluetoothStandardWeightProfile {
Arrays.copyOfRange(parser.getValue(), 0, 3));
}
@Override
protected void writeActivityLevel() {
Converters.ActivityLevel al = selectedUser.getActivityLevel();
BluetoothBytesParser parser = new BluetoothBytesParser(new byte[]{0});
parser.setIntValue(al.toInt() + 1, FORMAT_UINT8, 0);
Timber.d(String.format("setCurrentUserData Activity level: %d", al.toInt() + 1));
writeBytes(BluetoothGattUuidSBF77.SERVICE_CUSTOM_SBF77,
BluetoothGattUuidSBF77.CHARACTERISTIC_SBF77_ACTIVITY_LEVEL, parser.getValue());
}
@Override
protected void setNotifyVendorSpecificUserList() {
if (setNotificationOn(BluetoothGattUuidSBF77.SERVICE_CUSTOM_SBF77,