mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Moyoung: Fix HR history packet parsing and activity sample provider
This commit is contained in:
parent
c0878cd214
commit
fa070579be
@ -165,7 +165,12 @@ public class MoyoungActivitySampleProvider extends AbstractSampleProvider<Moyoun
|
|||||||
);
|
);
|
||||||
final long nanoStart = System.nanoTime();
|
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<>();
|
final Map<Integer, MoyoungActivitySample> sampleByTs = new HashMap<>();
|
||||||
for (final MoyoungActivitySample sample : samples) {
|
for (final MoyoungActivitySample sample : samples) {
|
||||||
sampleByTs.put(sample.getTimestamp(), sample);
|
sampleByTs.put(sample.getTimestamp(), sample);
|
||||||
|
@ -701,13 +701,14 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
final Calendar cal = Calendar.getInstance();
|
final Calendar cal = Calendar.getInstance();
|
||||||
cal.add(Calendar.DAY_OF_MONTH, -daysAgo);
|
cal.add(Calendar.DAY_OF_MONTH, -daysAgo);
|
||||||
cal.set(Calendar.SECOND, 0);
|
cal.set(Calendar.SECOND, 0);
|
||||||
|
LOG.info("Received HR history packet: index={}, daysAgo={}, startHour={}", packetIndex, daysAgo, startHour);
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (int hour=startHour; hour<startHour+6; hour++) {
|
for (int hour=startHour; hour<startHour+6; hour++) {
|
||||||
cal.set(Calendar.HOUR_OF_DAY, hour);
|
cal.set(Calendar.HOUR_OF_DAY, hour);
|
||||||
for (int minute=0; minute<60; minute+=5) {
|
for (int minute=0; minute<60; minute+=5) {
|
||||||
cal.set(Calendar.MINUTE, minute);
|
cal.set(Calendar.MINUTE, minute);
|
||||||
int hr = data[index] & 0xff;
|
int hr = data[index] & 0xff;
|
||||||
if (HeartRateUtils.getInstance().isValidHeartRateValue(hr)) {
|
if (HeartRateUtils.getInstance().isValidHeartRateValue(hr) && cal.getTimeInMillis() < System.currentTimeMillis()) {
|
||||||
MoyoungHeartRateSample sample = new MoyoungHeartRateSample();
|
MoyoungHeartRateSample sample = new MoyoungHeartRateSample();
|
||||||
sample.setTimestamp(cal.getTimeInMillis());
|
sample.setTimestamp(cal.getTimeInMillis());
|
||||||
sample.setHeartRate(hr);
|
sample.setHeartRate(hr);
|
||||||
@ -1191,7 +1192,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
switch (config) {
|
switch (config) {
|
||||||
case ActivityUser.PREF_USER_HEIGHT_CM:
|
case ActivityUser.PREF_USER_HEIGHT_CM:
|
||||||
case ActivityUser.PREF_USER_WEIGHT_KG:
|
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:
|
case ActivityUser.PREF_USER_GENDER:
|
||||||
sendSetting(getSetting("USER_INFO"), new ActivityUser());
|
sendSetting(getSetting("USER_INFO"), new ActivityUser());
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user