mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Mi Band 8: Weather temperature unit
This commit is contained in:
parent
f978329711
commit
e21b35981b
@ -19,15 +19,25 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.services;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.proto.xiaomi.XiaomiProto;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public class XiaomiWeatherService extends AbstractXiaomiService {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(XiaomiWeatherService.class);
|
||||
|
||||
public static final int COMMAND_TYPE = 10;
|
||||
|
||||
private static final int CMD_TEMPERATURE_UNIT_GET = 9;
|
||||
private static final int CMD_TEMPERATURE_UNIT_SET = 10;
|
||||
|
||||
public XiaomiWeatherService(final XiaomiSupport support) {
|
||||
super(support);
|
||||
}
|
||||
@ -37,7 +47,42 @@ public class XiaomiWeatherService extends AbstractXiaomiService {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(final TransactionBuilder builder) {
|
||||
// TODO setMeasurementSystem();, or request
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSendConfiguration(final String config, final Prefs prefs) {
|
||||
switch (config) {
|
||||
case SettingsActivity.PREF_MEASUREMENT_SYSTEM:
|
||||
setMeasurementSystem();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onSendWeather(final WeatherSpec weatherSpec) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
private void setMeasurementSystem() {
|
||||
final Prefs prefs = getDevicePrefs();
|
||||
final String measurementSystem = prefs.getString(SettingsActivity.PREF_MEASUREMENT_SYSTEM, "metric");
|
||||
LOG.info("Setting measurement system to {}", measurementSystem);
|
||||
|
||||
final int unitValue = "metric".equals(measurementSystem) ? 1 : 2;
|
||||
|
||||
getSupport().sendCommand(
|
||||
"set temperature unit",
|
||||
XiaomiProto.Command.newBuilder()
|
||||
.setType(COMMAND_TYPE)
|
||||
.setSubtype(CMD_TEMPERATURE_UNIT_SET)
|
||||
.setWeather(XiaomiProto.Weather.newBuilder().setTemperatureUnit(
|
||||
XiaomiProto.WeatherTemperatureUnit.newBuilder().setUnit(unitValue)
|
||||
))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user