Huami: Persist heart rate max, resting and manual samples

This commit is contained in:
José Rebelo
2023-05-27 18:59:12 +01:00
parent 592356faf1
commit 24f78655c2
19 changed files with 612 additions and 217 deletions

View File

@@ -122,6 +122,11 @@ public abstract class Huami2021Coordinator extends HuamiCoordinator {
return true;
}
@Override
public boolean supportsHeartRateStats() {
return true;
}
@Override
public boolean supportsMusicInfo() {
return true;

View File

@@ -150,6 +150,21 @@ public abstract class HuamiCoordinator extends AbstractBLEDeviceCoordinator {
return new HuamiSpo2SampleProvider(device, session);
}
@Override
public HuamiHeartRateMaxSampleProvider getHeartRateMaxSampleProvider(final GBDevice device, final DaoSession session) {
return new HuamiHeartRateMaxSampleProvider(device, session);
}
@Override
public HuamiHeartRateRestingSampleProvider getHeartRateRestingSampleProvider(final GBDevice device, final DaoSession session) {
return new HuamiHeartRateRestingSampleProvider(device, session);
}
@Override
public HuamiHeartRateManualSampleProvider getHeartRateManualSampleProvider(final GBDevice device, final DaoSession session) {
return new HuamiHeartRateManualSampleProvider(device, session);
}
@Override
public ActivitySummaryParser getActivitySummaryParser(final GBDevice device) {
return new HuamiActivitySummaryParser();

View File

@@ -0,0 +1,56 @@
/* 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.devices.huami;
import androidx.annotation.NonNull;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractTimeSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.HuamiHeartRateManualSample;
import nodomain.freeyourgadget.gadgetbridge.entities.HuamiHeartRateManualSampleDao;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class HuamiHeartRateManualSampleProvider extends AbstractTimeSampleProvider<HuamiHeartRateManualSample> {
public HuamiHeartRateManualSampleProvider(final GBDevice device, final DaoSession session) {
super(device, session);
}
@NonNull
@Override
public AbstractDao<HuamiHeartRateManualSample, ?> getSampleDao() {
return getSession().getHuamiHeartRateManualSampleDao();
}
@NonNull
@Override
protected Property getTimestampSampleProperty() {
return HuamiHeartRateManualSampleDao.Properties.Timestamp;
}
@NonNull
@Override
protected Property getDeviceIdentifierSampleProperty() {
return HuamiHeartRateManualSampleDao.Properties.DeviceId;
}
@Override
public HuamiHeartRateManualSample createSample() {
return new HuamiHeartRateManualSample();
}
}

View File

@@ -0,0 +1,56 @@
/* 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.devices.huami;
import androidx.annotation.NonNull;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractTimeSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.HuamiHeartRateMaxSample;
import nodomain.freeyourgadget.gadgetbridge.entities.HuamiHeartRateMaxSampleDao;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class HuamiHeartRateMaxSampleProvider extends AbstractTimeSampleProvider<HuamiHeartRateMaxSample> {
public HuamiHeartRateMaxSampleProvider(final GBDevice device, final DaoSession session) {
super(device, session);
}
@NonNull
@Override
public AbstractDao<HuamiHeartRateMaxSample, ?> getSampleDao() {
return getSession().getHuamiHeartRateMaxSampleDao();
}
@NonNull
@Override
protected Property getTimestampSampleProperty() {
return HuamiHeartRateMaxSampleDao.Properties.Timestamp;
}
@NonNull
@Override
protected Property getDeviceIdentifierSampleProperty() {
return HuamiHeartRateMaxSampleDao.Properties.DeviceId;
}
@Override
public HuamiHeartRateMaxSample createSample() {
return new HuamiHeartRateMaxSample();
}
}

View File

@@ -0,0 +1,56 @@
/* 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.devices.huami;
import androidx.annotation.NonNull;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractTimeSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.HuamiHeartRateRestingSample;
import nodomain.freeyourgadget.gadgetbridge.entities.HuamiHeartRateRestingSampleDao;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class HuamiHeartRateRestingSampleProvider extends AbstractTimeSampleProvider<HuamiHeartRateRestingSample> {
public HuamiHeartRateRestingSampleProvider(final GBDevice device, final DaoSession session) {
super(device, session);
}
@NonNull
@Override
public AbstractDao<HuamiHeartRateRestingSample, ?> getSampleDao() {
return getSession().getHuamiHeartRateRestingSampleDao();
}
@NonNull
@Override
protected Property getTimestampSampleProperty() {
return HuamiHeartRateRestingSampleDao.Properties.Timestamp;
}
@NonNull
@Override
protected Property getDeviceIdentifierSampleProperty() {
return HuamiHeartRateRestingSampleDao.Properties.DeviceId;
}
@Override
public HuamiHeartRateRestingSample createSample() {
return new HuamiHeartRateRestingSample();
}
}