mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +01:00
Zepp OS: Add statistics fetch operation
We do not know what they are or how to parse them, but syncing them helps free up space from the band.
This commit is contained in:
parent
5a65bbf8f4
commit
f090898aef
@ -229,6 +229,7 @@ public class HuamiService {
|
|||||||
public static final byte COMMAND_ACTIVITY_DATA_TYPE_STRESS_AUTOMATIC = 0x13;
|
public static final byte COMMAND_ACTIVITY_DATA_TYPE_STRESS_AUTOMATIC = 0x13;
|
||||||
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SPO2_NORMAL = 0x25;
|
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SPO2_NORMAL = 0x25;
|
||||||
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SPO2_SLEEP = 0x26;
|
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SPO2_SLEEP = 0x26;
|
||||||
|
public static final byte COMMAND_ACTIVITY_DATA_TYPE_STATISTICS = 0x2c;
|
||||||
public static final byte COMMAND_ACTIVITY_DATA_TYPE_TEMPERATURE = 0x2e;
|
public static final byte COMMAND_ACTIVITY_DATA_TYPE_TEMPERATURE = 0x2e;
|
||||||
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SLEEP_RESPIRATORY_RATE = 0x38;
|
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SLEEP_RESPIRATORY_RATE = 0x38;
|
||||||
public static final byte COMMAND_ACTIVITY_DATA_TYPE_RESTING_HEART_RATE = 0x3a;
|
public static final byte COMMAND_ACTIVITY_DATA_TYPE_RESTING_HEART_RATE = 0x3a;
|
||||||
|
@ -28,6 +28,7 @@ public class RecordedDataTypes {
|
|||||||
public static final int TYPE_HEART_RATE = 0x00000080;
|
public static final int TYPE_HEART_RATE = 0x00000080;
|
||||||
public static final int TYPE_PAI = 0x00000100;
|
public static final int TYPE_PAI = 0x00000100;
|
||||||
public static final int TYPE_SLEEP_RESPIRATORY_RATE = 0x00000200;
|
public static final int TYPE_SLEEP_RESPIRATORY_RATE = 0x00000200;
|
||||||
|
public static final int TYPE_HUAMI_STATISTICS = 0x00000400;
|
||||||
|
|
||||||
public static final int TYPE_ALL = (int)0xffffffff;
|
public static final int TYPE_ALL = (int)0xffffffff;
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.AbstractFetchOperation;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.AbstractFetchOperation;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.FetchStatisticsOperation;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.FetchTemperatureOperation;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.FetchTemperatureOperation;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.FetchHeartRateManualOperation;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.FetchHeartRateManualOperation;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.FetchHeartRateMaxOperation;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.FetchHeartRateMaxOperation;
|
||||||
@ -1705,6 +1706,10 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((dataTypes & RecordedDataTypes.TYPE_HUAMI_STATISTICS) != 0) {
|
||||||
|
this.fetchOperationQueue.add(new FetchStatisticsOperation(this));
|
||||||
|
}
|
||||||
|
|
||||||
final AbstractFetchOperation nextOperation = this.fetchOperationQueue.poll();
|
final AbstractFetchOperation nextOperation = this.fetchOperationQueue.poll();
|
||||||
if (nextOperation != null) {
|
if (nextOperation != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
/* Copyright (C) 2023 José Rebelo
|
||||||
|
|
||||||
|
This file is part of Gadgetbridge.
|
||||||
|
|
||||||
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published
|
||||||
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Gadgetbridge is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An operation that fetches statistics from /storage/statistics/ (hm_statis_data* files). We do not
|
||||||
|
* know what these are or how to parse them, but syncing them helps free up memory.
|
||||||
|
*/
|
||||||
|
public class FetchStatisticsOperation extends AbstractRepeatingFetchOperation {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(FetchStatisticsOperation.class);
|
||||||
|
|
||||||
|
public FetchStatisticsOperation(final HuamiSupport support) {
|
||||||
|
super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_STATISTICS, "statistics data");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String taskDescription() {
|
||||||
|
return getContext().getString(R.string.busy_task_fetch_statistics);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) {
|
||||||
|
LOG.debug("Ignoring {} bytes of statistics", bytes.length);
|
||||||
|
|
||||||
|
timestamp.setTime(new Date());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected GregorianCalendar getLastSuccessfulSyncTime() {
|
||||||
|
// One minute ago - we don't really care about this data, and we don't want to fetch it all
|
||||||
|
final GregorianCalendar sinceWhen = BLETypeConversions.createCalendar();
|
||||||
|
sinceWhen.add(Calendar.MINUTE, -1);
|
||||||
|
return sinceWhen;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getLastSyncTimeKey() {
|
||||||
|
return "lastStatisticsTimeMillis";
|
||||||
|
}
|
||||||
|
}
|
@ -631,6 +631,7 @@
|
|||||||
<string name="busy_task_fetch_hr_data">Fetching heart rate data</string>
|
<string name="busy_task_fetch_hr_data">Fetching heart rate data</string>
|
||||||
<string name="busy_task_fetch_sleep_respiratory_rate_data">Fetching sleep respiratory rate data</string>
|
<string name="busy_task_fetch_sleep_respiratory_rate_data">Fetching sleep respiratory rate data</string>
|
||||||
<string name="busy_task_fetch_temperature">Fetching temperature data</string>
|
<string name="busy_task_fetch_temperature">Fetching temperature data</string>
|
||||||
|
<string name="busy_task_fetch_statistics">Fetching statistics</string>
|
||||||
<string name="sleep_activity_date_range">From %1$s to %2$s</string>
|
<string name="sleep_activity_date_range">From %1$s to %2$s</string>
|
||||||
<string name="prefs_wearside">Wearing left or right?</string>
|
<string name="prefs_wearside">Wearing left or right?</string>
|
||||||
<string name="prefs_weardirection">Wearing direction</string>
|
<string name="prefs_weardirection">Wearing direction</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user