Bluetooth pressure data parse

This commit is contained in:
denta58
2022-12-04 21:01:57 +01:00
committed by Dennis Guse
parent ebcc7dc46e
commit 0395394e26
2 changed files with 30 additions and 0 deletions
@@ -69,6 +69,11 @@ public class BluetoothUtils {
))
);
public static final ServiceMeasurementUUID PRESSURE = new ServiceMeasurementUUID(
new UUID(0x181A00001000L, 0x800000805f9b34fbL),
new UUID(0x2A6D00001000L, 0x800000805f9b34fbL)
);
public static final ServiceMeasurementUUID CYCLING_POWER = new ServiceMeasurementUUID(
new UUID(0x181800001000L, 0x800000805f9b34fbL),
new UUID(0x2A6300001000L, 0x800000805f9b34fbL)
@@ -137,6 +142,17 @@ public class BluetoothUtils {
return null;
}
public static Integer parsePressure(BluetoothGattCharacteristic characteristic) {
byte[] raw = characteristic.getValue();
if (raw.length < 4) {
return null;
}
Float fPressure = characteristic.getFloatValue(BluetoothGattCharacteristic.FORMAT_FLOAT, 0);
return Math.round(fPressure);
}
public static SensorDataCyclingPower.Data parseCyclingPower(String address, String sensorName, BluetoothGattCharacteristic characteristic) {
// DOCUMENTATION https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.cycling_power_measurement.xml
int valueLength = characteristic.getValue().length;