mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-07-04 03:52:02 +02:00
makibes hr3.
download progress notification (needs to be tested).
This commit is contained in:
parent
cd3558cd50
commit
fdffe813f2
|
@ -242,6 +242,7 @@ public final class BtLEQueue {
|
||||||
mBluetoothGattServer.addService(service);
|
mBluetoothGattServer.addService(service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mGattMonitor) {
|
synchronized (mGattMonitor) {
|
||||||
// connectGatt with true doesn't really work ;( too often connection problems
|
// connectGatt with true doesn't really work ;( too often connection problems
|
||||||
if (GBApplication.isRunningMarshmallowOrLater()) {
|
if (GBApplication.isRunningMarshmallowOrLater()) {
|
||||||
|
@ -259,6 +260,7 @@ public final class BtLEQueue {
|
||||||
|
|
||||||
private void setDeviceConnectionState(State newState) {
|
private void setDeviceConnectionState(State newState) {
|
||||||
LOG.debug("new device connection state: " + newState);
|
LOG.debug("new device connection state: " + newState);
|
||||||
|
|
||||||
mGbDevice.setState(newState);
|
mGbDevice.setState(newState);
|
||||||
mGbDevice.sendDeviceUpdateIntent(mContext);
|
mGbDevice.sendDeviceUpdateIntent(mContext);
|
||||||
if (mConnectionLatch != null && newState == State.CONNECTED) {
|
if (mConnectionLatch != null && newState == State.CONNECTED) {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
// TODO: GB sometimes fails to connect until a connection with WearFit was made. This must be caused
|
// TODO: GB sometimes fails to connect until a connection with WearFit was made. This must be caused
|
||||||
// TODO: by GB, not by makibes hr3 support.
|
// TODO: by GB, not by makibes hr3 support. Charging the watch or attempting to pair might also
|
||||||
|
// TODO: help. This needs further research.
|
||||||
|
|
||||||
// TODO: Where can I view today's steps in GB?
|
// TODO: Where can I view today's steps in GB?
|
||||||
// TODO: GB accumulates all step samples, even if they're part of the same day.
|
// TODO: GB accumulates all step samples, even if they're part of the same day.
|
||||||
|
|
||||||
// TODO: Activity history download progress.
|
|
||||||
|
|
||||||
// TODO: All the commands that aren't supported by GB should be added to device specific settings.
|
// TODO: All the commands that aren't supported by GB should be added to device specific settings.
|
||||||
|
|
||||||
// TODO: It'd be cool if we could change the language. There's no official way to do so, but the
|
// TODO: It'd be cool if we could change the language. There's no official way to do so, but the
|
||||||
|
@ -20,6 +19,7 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.VibrationEffect;
|
import android.os.VibrationEffect;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
|
@ -38,6 +38,7 @@ import java.util.GregorianCalendar;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||||
|
@ -76,6 +77,19 @@ public class MakibesHR3DeviceSupport extends AbstractBTLEDeviceSupport implement
|
||||||
private Handler mVibrationHandler = new Handler();
|
private Handler mVibrationHandler = new Handler();
|
||||||
private Vibrator mVibrator;
|
private Vibrator mVibrator;
|
||||||
|
|
||||||
|
private CountDownTimer mFetchCountDown = new CountDownTimer(1000, 1000) {
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() {
|
||||||
|
LOG.debug("download finished");
|
||||||
|
GB.updateTransferNotification(null, "", false, 100, getContext());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private BluetoothGattCharacteristic mControlCharacteristic = null;
|
private BluetoothGattCharacteristic mControlCharacteristic = null;
|
||||||
private BluetoothGattCharacteristic mReportCharacteristic = null;
|
private BluetoothGattCharacteristic mReportCharacteristic = null;
|
||||||
|
|
||||||
|
@ -86,6 +100,20 @@ public class MakibesHR3DeviceSupport extends AbstractBTLEDeviceSupport implement
|
||||||
addSupportedService(MakibesHR3Constants.UUID_SERVICE);
|
addSupportedService(MakibesHR3Constants.UUID_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called whenever data is received to postpone the removing of the progress notification.
|
||||||
|
* @param start Start showing the notification
|
||||||
|
*/
|
||||||
|
private void fetch(boolean start) {
|
||||||
|
if (start) {
|
||||||
|
// We don't know how long the watch is going to take to reply. Keep progress at 0.
|
||||||
|
GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, 0, getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.mFetchCountDown.cancel();
|
||||||
|
this.mFetchCountDown.start();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean useAutoConnect() {
|
public boolean useAutoConnect() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -434,7 +462,7 @@ public class MakibesHR3DeviceSupport extends AbstractBTLEDeviceSupport implement
|
||||||
}
|
}
|
||||||
|
|
||||||
private MakibesHR3DeviceSupport sendUserInfo(TransactionBuilder builder) {
|
private MakibesHR3DeviceSupport sendUserInfo(TransactionBuilder builder) {
|
||||||
syncPreferences(builder);
|
this.syncPreferences(builder);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -455,11 +483,14 @@ public class MakibesHR3DeviceSupport extends AbstractBTLEDeviceSupport implement
|
||||||
activityUser.getWeightKg(),
|
activityUser.getWeightKg(),
|
||||||
activityUser.getStepsGoal() / 1000);
|
activityUser.getStepsGoal() / 1000);
|
||||||
|
|
||||||
|
|
||||||
// setLanguage(transaction);
|
// setLanguage(transaction);
|
||||||
// setScreenTime(transaction);
|
// setScreenTime(transaction);
|
||||||
// setUnit(transaction);
|
// setUnit(transaction);
|
||||||
// setAllDayHeart(transaction);
|
// setAllDayHeart(transaction);
|
||||||
|
|
||||||
|
this.fetch(true);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,6 +513,8 @@ public class MakibesHR3DeviceSupport extends AbstractBTLEDeviceSupport implement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
||||||
|
GB.updateTransferNotification(null, getContext().getString(R.string.busy_task_fetch_activity_data), true, 0, getContext());
|
||||||
|
|
||||||
gbDevice.setState(GBDevice.State.INITIALIZING);
|
gbDevice.setState(GBDevice.State.INITIALIZING);
|
||||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
gbDevice.sendDeviceUpdateIntent(getContext());
|
||||||
|
|
||||||
|
@ -644,6 +677,8 @@ public class MakibesHR3DeviceSupport extends AbstractBTLEDeviceSupport implement
|
||||||
if (data.length < 6)
|
if (data.length < 6)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
this.fetch(false);
|
||||||
|
|
||||||
UUID characteristicUuid = characteristic.getUuid();
|
UUID characteristicUuid = characteristic.getUuid();
|
||||||
|
|
||||||
if (characteristicUuid.equals(mReportCharacteristic.getUuid())) {
|
if (characteristicUuid.equals(mReportCharacteristic.getUuid())) {
|
||||||
|
@ -791,6 +826,8 @@ public class MakibesHR3DeviceSupport extends AbstractBTLEDeviceSupport implement
|
||||||
int yearHeartRateAfter, int monthHeartRateAfter, int dayHeartRateAfter,
|
int yearHeartRateAfter, int monthHeartRateAfter, int dayHeartRateAfter,
|
||||||
int hourHeartRateAfter, int minuteHeartRateAfter) {
|
int hourHeartRateAfter, int minuteHeartRateAfter) {
|
||||||
|
|
||||||
|
this.fetch(true);
|
||||||
|
|
||||||
byte[] data = this.craftData(MakibesHR3Constants.CMD_REQUEST_FITNESS,
|
byte[] data = this.craftData(MakibesHR3Constants.CMD_REQUEST_FITNESS,
|
||||||
new byte[]{
|
new byte[]{
|
||||||
(byte) 0x00,
|
(byte) 0x00,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user