1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-26 20:06:52 +01:00

Moyoung: Fix HR history packet parsing and activity sample provider

This commit is contained in:
Arjan Schrijver 2024-09-02 22:34:32 +02:00
parent 9b463a8bd1
commit 1ad3500453
2 changed files with 9 additions and 3 deletions

View File

@ -165,7 +165,12 @@ public class MoyoungActivitySampleProvider extends AbstractSampleProvider<Moyoun
);
final long nanoStart = System.nanoTime();
final List<MoyoungActivitySample> samples = super.getGBActivitySamples(timestamp_from, timestamp_to);
final List<MoyoungActivitySample> samples = fillGaps(
super.getGBActivitySamples(timestamp_from, timestamp_to),
timestamp_from,
timestamp_to
);
final Map<Integer, MoyoungActivitySample> sampleByTs = new HashMap<>();
for (final MoyoungActivitySample sample : samples) {
sampleByTs.put(sample.getTimestamp(), sample);

View File

@ -701,13 +701,14 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
final Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, -daysAgo);
cal.set(Calendar.SECOND, 0);
LOG.info("Received HR history packet: index={}, daysAgo={}, startHour={}", packetIndex, daysAgo, startHour);
int index = 1;
for (int hour=startHour; hour<startHour+6; hour++) {
cal.set(Calendar.HOUR_OF_DAY, hour);
for (int minute=0; minute<60; minute+=5) {
cal.set(Calendar.MINUTE, minute);
int hr = data[index] & 0xff;
if (HeartRateUtils.getInstance().isValidHeartRateValue(hr)) {
if (HeartRateUtils.getInstance().isValidHeartRateValue(hr) && cal.getTimeInMillis() < System.currentTimeMillis()) {
MoyoungHeartRateSample sample = new MoyoungHeartRateSample();
sample.setTimestamp(cal.getTimeInMillis());
sample.setHeartRate(hr);
@ -1191,7 +1192,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
switch (config) {
case ActivityUser.PREF_USER_HEIGHT_CM:
case ActivityUser.PREF_USER_WEIGHT_KG:
case ActivityUser.PREF_USER_YEAR_OF_BIRTH:
case ActivityUser.PREF_USER_DATE_OF_BIRTH:
case ActivityUser.PREF_USER_GENDER:
sendSetting(getSetting("USER_INFO"), new ActivityUser());
break;