Colmi R09: Add preference to toggle temperature measurements

This commit is contained in:
Arjan Schrijver 2025-01-02 22:43:34 +01:00
parent 603f9421d0
commit 43a1613f95
6 changed files with 31 additions and 0 deletions

View File

@ -206,6 +206,7 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_SPO2_ALL_DAY_MONITORING = "spo2_all_day_monitoring_enabled";
public static final String PREF_SPO2_LOW_ALERT_THRESHOLD = "spo2_low_alert_threshold";
public static final String PREF_HRV_ALL_DAY_MONITORING = "hrv_all_day_monitoring_enabled";
public static final String PREF_TEMPERATURE_ALL_DAY_MONITORING = "continuous_skin_temperature_measurement";
public static final String PREF_AUTOHEARTRATE_SWITCH = "pref_autoheartrate_switch";
public static final String PREF_AUTOHEARTRATE_SLEEP = "pref_autoheartrate_sleep";

View File

@ -554,6 +554,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
addPreferenceHandlerFor(PREF_SPO2_ALL_DAY_MONITORING);
addPreferenceHandlerFor(PREF_SPO2_LOW_ALERT_THRESHOLD);
addPreferenceHandlerFor(PREF_HRV_ALL_DAY_MONITORING);
addPreferenceHandlerFor(PREF_TEMPERATURE_ALL_DAY_MONITORING);
addPreferenceHandlerFor(PREF_DO_NOT_DISTURB_NOAUTO);
addPreferenceHandlerFor(PREF_DO_NOT_DISTURB_NOAUTO_START);
addPreferenceHandlerFor(PREF_DO_NOT_DISTURB_NOAUTO_END);

View File

@ -235,6 +235,9 @@ public abstract class AbstractColmiR0xCoordinator extends AbstractBLEDeviceCoord
final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
final List<Integer> health = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.HEALTH);
health.add(R.xml.devicesettings_colmi_r0x);
if (supportsContinuousTemperature()) {
health.add(R.xml.devicesettings_temperature_automatic_enable);
}
return deviceSpecificSettings;
}
}

View File

@ -40,6 +40,7 @@ public class ColmiR0xConstants {
public static final byte CMD_SYNC_STRESS = 0x37;
public static final byte CMD_AUTO_HRV_PREF = 0x38;
public static final byte CMD_SYNC_HRV = 0x39;
public static final byte CMD_AUTO_TEMP_PREF = 0x3a;
public static final byte CMD_SYNC_ACTIVITY = 0x43;
public static final byte CMD_FIND_DEVICE = 0x50;
public static final byte CMD_MANUAL_HEART_RATE = 0x69;

View File

@ -111,6 +111,17 @@ public class ColmiR0xPacketHandler {
support.evaluateGBDeviceEvent(eventUpdatePreferences);
}
public static void tempSettings(ColmiR0xDeviceSupport support, byte[] value) {
boolean enabled = value[3] == 0x01;
LOG.info("Received temperature preference: {}", enabled ? "enabled" : "disabled");
GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences();
eventUpdatePreferences.withPreference(
DeviceSettingsPreferenceConst.PREF_TEMPERATURE_ALL_DAY_MONITORING,
enabled
);
support.evaluateGBDeviceEvent(eventUpdatePreferences);
}
public static void goalsSettings(byte[] value) {
int steps = BLETypeConversions.toUint32(value[2], value[3], value[4], (byte) 0);
int calories = BLETypeConversions.toUint32(value[5], value[6], value[7], (byte) 0);

View File

@ -270,6 +270,11 @@ public class ColmiR0xDeviceSupport extends AbstractBTLEDeviceSupport {
case ColmiR0xConstants.CMD_AUTO_HRV_PREF:
ColmiR0xPacketHandler.hrvSettings(this, value);
break;
case ColmiR0xConstants.CMD_AUTO_TEMP_PREF:
if (value[1] == 0x03) { // so far always observed to be 0x03
ColmiR0xPacketHandler.tempSettings(this, value);
}
break;
case ColmiR0xConstants.CMD_SYNC_STRESS:
ColmiR0xPacketHandler.historicalStress(getDevice(), getContext(), value);
if (!getDevice().isBusy()) {
@ -511,6 +516,12 @@ public class ColmiR0xDeviceSupport extends AbstractBTLEDeviceSupport {
LOG.info("HRV preference request sent: {}", StringUtils.bytesToHex(hrvPrefsPacket));
sendWrite("hrvPreferenceRequest", hrvPrefsPacket);
break;
case DeviceSettingsPreferenceConst.PREF_TEMPERATURE_ALL_DAY_MONITORING:
final boolean tempEnabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_TEMPERATURE_ALL_DAY_MONITORING, false);
byte[] tempPrefsPacket = buildPacket(new byte[]{ColmiR0xConstants.CMD_AUTO_TEMP_PREF, 0x03, ColmiR0xConstants.PREF_WRITE, (byte) (tempEnabled ? 0x01 : 0x00)});
LOG.info("Temperature preference request sent: {}", StringUtils.bytesToHex(tempPrefsPacket));
sendWrite("tempPreferenceRequest", tempPrefsPacket);
break;
}
}
@ -574,6 +585,9 @@ public class ColmiR0xDeviceSupport extends AbstractBTLEDeviceSupport {
request = buildPacket(new byte[]{ColmiR0xConstants.CMD_AUTO_HRV_PREF, ColmiR0xConstants.PREF_READ});
LOG.info("Request HRV measurement setting from ring: {}", StringUtils.bytesToHex(request));
sendWrite("hrvSettingRequest", request);
request = buildPacket(new byte[]{ColmiR0xConstants.CMD_AUTO_TEMP_PREF, 0x03, ColmiR0xConstants.PREF_READ});
LOG.info("Request temperature measurement setting from ring: {}", StringUtils.bytesToHex(request));
sendWrite("tempSettingRequest", request);
request = buildPacket(new byte[]{ColmiR0xConstants.CMD_GOALS, ColmiR0xConstants.PREF_READ});
LOG.info("Request goals from ring: {}", StringUtils.bytesToHex(request));
sendWrite("goalsSettingRequest", request);