Mi2: display heart rate result from Debug screen as a toast #323

This commit is contained in:
cpfeiffer 2016-10-24 00:23:59 +02:00
parent b20a9c9ccc
commit de46555e37

View File

@ -87,6 +87,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
private static final Logger LOG = LoggerFactory.getLogger(MiBand2Support.class); private static final Logger LOG = LoggerFactory.getLogger(MiBand2Support.class);
private final DeviceInfoProfile<MiBand2Support> deviceInfoProfile; private final DeviceInfoProfile<MiBand2Support> deviceInfoProfile;
private final HeartRateProfile<MiBand2Support> heartRateProfile;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() { private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
@ -120,6 +121,8 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
deviceInfoProfile = new DeviceInfoProfile<>(this); deviceInfoProfile = new DeviceInfoProfile<>(this);
addSupportedProfile(deviceInfoProfile); addSupportedProfile(deviceInfoProfile);
heartRateProfile = new HeartRateProfile<MiBand2Support>(this);
addSupportedProfile(heartRateProfile);
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext()); LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext());
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
@ -675,8 +678,8 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
if (supportsHeartRate()) { if (supportsHeartRate()) {
try { try {
TransactionBuilder builder = performInitialized("HeartRateTest"); TransactionBuilder builder = performInitialized("HeartRateTest");
HeartRateProfile<MiBand2Support> profile = new HeartRateProfile<>(this); heartRateProfile.requestHeartRateMeasurement(builder);
profile.requestHeartRateMeasurement(builder); // profile.resetEnergyExpended(builder);
// builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementContinuous); // builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementContinuous);
// builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementManual); // builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), stopHeartMeasurementManual);
// builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), startHeartMeasurementManual); // builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_CONTROL_POINT), startHeartMeasurementManual);