mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +01:00
Zepp OS: Add temperature fetch operation (no DB / UI)
This commit is contained in:
parent
81501ef750
commit
5a65bbf8f4
@ -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_SPO2_NORMAL = 0x25;
|
||||
public static final byte COMMAND_ACTIVITY_DATA_TYPE_SPO2_SLEEP = 0x26;
|
||||
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_RESTING_HEART_RATE = 0x3a;
|
||||
public static final byte COMMAND_ACTIVITY_DATA_TYPE_MAX_HEART_RATE = 0x3d;
|
||||
|
@ -122,6 +122,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.AbstractFetchOperation;
|
||||
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.FetchHeartRateMaxOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.FetchHeartRateRestingOperation;
|
||||
@ -174,7 +175,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.NotificationS
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.RealtimeSamplesSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.AlarmUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
||||
@ -1698,7 +1698,11 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
|
||||
if ((dataTypes & RecordedDataTypes.TYPE_SLEEP_RESPIRATORY_RATE) != 0 && coordinator.supportsSleepRespiratoryRate()) {
|
||||
this.fetchOperationQueue.add(new FetchSleepRespiratoryRateOperation(this));
|
||||
}
|
||||
}
|
||||
|
||||
if ((dataTypes & RecordedDataTypes.TYPE_TEMPERATURE) != 0) {
|
||||
this.fetchOperationQueue.add(new FetchTemperatureOperation(this));
|
||||
}
|
||||
}
|
||||
|
||||
final AbstractFetchOperation nextOperation = this.fetchOperationQueue.poll();
|
||||
|
@ -0,0 +1,71 @@
|
||||
/* 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.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
/**
|
||||
* An operation that fetches temperature data.
|
||||
*/
|
||||
public class FetchTemperatureOperation extends AbstractRepeatingFetchOperation {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FetchTemperatureOperation.class);
|
||||
|
||||
public FetchTemperatureOperation(final HuamiSupport support) {
|
||||
super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_TEMPERATURE, "body temperature data");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String taskDescription() {
|
||||
return getContext().getString(R.string.busy_task_fetch_temperature);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) {
|
||||
if (bytes.length % 8 != 0) {
|
||||
LOG.info("Unexpected buffered temperature data size {} is not a multiple of 8", bytes.length);
|
||||
return false;
|
||||
}
|
||||
|
||||
final ByteBuffer buffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
while (buffer.position() < bytes.length) {
|
||||
final int temperature = buffer.getShort();
|
||||
final byte[] unknown = new byte[6];
|
||||
buffer.get(unknown);
|
||||
|
||||
// TODO persist / parse rest
|
||||
LOG.warn("Temperature: {}, unknown={}", temperature, GB.hexdump(unknown));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLastSyncTimeKey() {
|
||||
return "lastTemperatureTimeMillis";
|
||||
}
|
||||
}
|
@ -630,6 +630,7 @@
|
||||
<string name="busy_task_fetch_spo2_data">Fetching SpO2 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_temperature">Fetching temperature data</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_weardirection">Wearing direction</string>
|
||||
|
Loading…
Reference in New Issue
Block a user