diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiService.java
index 9e73198f9..995cdc240 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiService.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiService.java
@@ -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;
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java
index 47edc7769..dca37ae70 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java
@@ -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();
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchTemperatureOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchTemperatureOperation.java
new file mode 100644
index 000000000..6dab0e9c5
--- /dev/null
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchTemperatureOperation.java
@@ -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 . */
+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";
+ }
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index de0401877..bfd319de3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -630,6 +630,7 @@
Fetching SpO2 data
Fetching heart rate data
Fetching sleep respiratory rate data
+ Fetching temperature data
From %1$s to %2$s
Wearing left or right?
Wearing direction