1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-20 05:40:58 +02:00

Zepp OS: Add experimental sync of SpO2, stress, PAI, HR stats and sleep respiratory rate

This commit is contained in:
José Rebelo 2023-06-10 17:19:22 +01:00
parent 58704a0eec
commit a3c59b0e0e
5 changed files with 28 additions and 20 deletions

View File

@ -418,7 +418,7 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
@Override
public void onClick(View v) {
showTransientSnackbar(R.string.busy_task_fetch_activity_data);
GBApplication.deviceService(device).onFetchRecordedData(RecordedDataTypes.TYPE_ACTIVITY);
GBApplication.deviceService(device).onFetchRecordedData(RecordedDataTypes.TYPE_SYNC);
}
}
);

View File

@ -74,7 +74,7 @@ public class IntentApiReceiver extends BroadcastReceiver {
}
dataTypes = Integer.parseInt(matcher.group(1), 16);
} else {
dataTypes = RecordedDataTypes.TYPE_ACTIVITY;
dataTypes = RecordedDataTypes.TYPE_SYNC;
}
LOG.info("Triggering activity sync for data types {}", String.format("0x%08x", dataTypes));

View File

@ -30,4 +30,9 @@ public class RecordedDataTypes {
public static final int TYPE_SLEEP_RESPIRATORY_RATE = 0x00000200;
public static final int TYPE_ALL = (int)0xffffffff;
// Types to fetch during sync - scheduled, sync button, etc.
// Does not include debug logs or workouts
public static final int TYPE_SYNC = TYPE_ACTIVITY | TYPE_SPO2 | TYPE_STRESS |
TYPE_HEART_RATE | TYPE_PAI | TYPE_SLEEP_RESPIRATORY_RATE;
}

View File

@ -89,6 +89,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.ActivateDisplayOnLift;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.ActivateDisplayOnLiftSensitivity;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.DisconnectNotificationSetting;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Service;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -1668,27 +1669,29 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
this.fetchOperationQueue.add(new HuamiFetchDebugLogsOperation(this));
}
if ((dataTypes & RecordedDataTypes.TYPE_SPO2) != 0 && coordinator.supportsSpo2()) {
this.fetchOperationQueue.add(new FetchSpo2NormalOperation(this));
}
if (Huami2021Coordinator.experimentalFeatures(getDevice())) {
if ((dataTypes & RecordedDataTypes.TYPE_SPO2) != 0 && coordinator.supportsSpo2()) {
this.fetchOperationQueue.add(new FetchSpo2NormalOperation(this));
}
if ((dataTypes & RecordedDataTypes.TYPE_STRESS) != 0 && coordinator.supportsStressMeasurement()) {
this.fetchOperationQueue.add(new FetchStressAutoOperation(this));
this.fetchOperationQueue.add(new FetchStressManualOperation(this));
}
if ((dataTypes & RecordedDataTypes.TYPE_STRESS) != 0 && coordinator.supportsStressMeasurement()) {
this.fetchOperationQueue.add(new FetchStressAutoOperation(this));
this.fetchOperationQueue.add(new FetchStressManualOperation(this));
}
if ((dataTypes & RecordedDataTypes.TYPE_HEART_RATE) != 0 && coordinator.supportsHeartRateStats()) {
this.fetchOperationQueue.add(new FetchHeartRateManualOperation(this));
this.fetchOperationQueue.add(new FetchHeartRateMaxOperation(this));
this.fetchOperationQueue.add(new FetchHeartRateRestingOperation(this));
}
if ((dataTypes & RecordedDataTypes.TYPE_HEART_RATE) != 0 && coordinator.supportsHeartRateStats()) {
this.fetchOperationQueue.add(new FetchHeartRateManualOperation(this));
this.fetchOperationQueue.add(new FetchHeartRateMaxOperation(this));
this.fetchOperationQueue.add(new FetchHeartRateRestingOperation(this));
}
if ((dataTypes & RecordedDataTypes.TYPE_PAI) != 0 && coordinator.supportsPai()) {
this.fetchOperationQueue.add(new FetchPaiOperation(this));
}
if ((dataTypes & RecordedDataTypes.TYPE_PAI) != 0 && coordinator.supportsPai()) {
this.fetchOperationQueue.add(new FetchPaiOperation(this));
}
if ((dataTypes & RecordedDataTypes.TYPE_SLEEP_RESPIRATORY_RATE) != 0 && coordinator.supportsSleepRespiratoryRate()) {
this.fetchOperationQueue.add(new FetchSleepRespiratoryRateOperation(this));
if ((dataTypes & RecordedDataTypes.TYPE_SLEEP_RESPIRATORY_RATE) != 0 && coordinator.supportsSleepRespiratoryRate()) {
this.fetchOperationQueue.add(new FetchSleepRespiratoryRateOperation(this));
}
}
final AbstractFetchOperation nextOperation = this.fetchOperationQueue.poll();

View File

@ -35,7 +35,7 @@ public class GBAutoFetchReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Date nextSync = DateUtils.addMinutes(lastSync, GBApplication.getPrefs().getInt("auto_fetch_interval_limit", 0));
if (nextSync.before(new Date())) {
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_ACTIVITY);
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_SYNC);
lastSync = new Date();
}
}