WIP regarding heart rate profile

This commit is contained in:
cpfeiffer 2016-09-25 22:52:26 +02:00
parent 0341c7f61f
commit d4b134a490
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.heartrate;
/**
* The Body Sensor Location characteristic of the device is used to describe the intended location of the heart rate measurement for the device.
*
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.body_sensor_location.xml
*/
public enum BodySensorLocation {
Other(0),
Checst(1),
Wrist(2),
Finger(3),
Hand(4),
EarLobe(5),
Foot(6);
// others are reserved
private final int val;
BodySensorLocation(int val) {
this.val = val;
}
}

View File

@ -0,0 +1,51 @@
package nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.heartrate;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic;
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.AbstractBleProfile;
/**
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.heart_rate.xml
*/
public class HeartRateProfile<T extends AbstractBTLEDeviceSupport> extends AbstractBleProfile<T> {
/**
* Returned when a request to the heart rate control point is not supported by the device
*/
public static final int ERR_CONTROL_POINT_NOT_SUPPORTED = 0x80;
public HeartRateProfile(T support) {
super(support);
}
public void resetEnergyExpended(TransactionBuilder builder) {
writeToControlPoint((byte) 0x01, builder);
}
protected void writeToControlPoint(byte value, TransactionBuilder builder) {
builder.write(getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), new byte[] { value });
}
public void requestBodySensorLocation(TransactionBuilder builder) {
}
public void requestHeartRateMeasurement(TransactionBuilder builder) {
}
@Override
public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
// if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
// int flag = characteristic.getProperties();
// int format = -1;
// if ((flag & 0x01) != 0) {
// format = BluetoothGattCharacteristic.FORMAT_UINT16;
// } else {
// format = BluetoothGattCharacteristic.FORMAT_UINT8;
// }
// final int heartRate = characteristic.getIntValue(format, 1); }
}