This commit is contained in:
Dennis Guse
2019-10-29 23:05:17 +01:00
parent 9e877e4762
commit e52b1188a3
4 changed files with 16 additions and 22 deletions
@@ -18,6 +18,7 @@ package de.dennisguse.opentracks.util;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattCharacteristic;
import java.util.List;
import java.util.Set;
@@ -27,9 +28,9 @@ import java.util.Set;
*
* @author Rodrigo Damazio
*/
public class BluetoothDeviceUtils {
public class BluetoothUtils {
private BluetoothDeviceUtils() {
private BluetoothUtils() {
}
/**
@@ -53,4 +54,13 @@ public class BluetoothDeviceUtils {
}
}
}
public static int parseHeartRate(BluetoothGattCharacteristic characteristic) {
//DOCUMENTATION https://www.bluetooth.com/specifications/gatt/characteristics/
byte[] raw = characteristic.getValue();
int index = ((raw[0] & 0x1) == 1) ? 2 : 1;
int format = (index == 1) ? BluetoothGattCharacteristic.FORMAT_UINT8 : BluetoothGattCharacteristic.FORMAT_UINT16;
return characteristic.getIntValue(format, index);
}
}