diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiConstants.java index 7e9ce39fc..78f728497 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiConstants.java @@ -36,6 +36,7 @@ public final class HuaweiConstants { public static final int TAG_RESULT = 127; public static final byte[] RESULT_SUCCESS = new byte[]{0x00, 0x01, (byte)0x86, (byte)0xA0}; + public static final int RESULT_SUCCESS_INT = 0x186a0; public static class CryptoTags { public static final int encryption = 124; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/Weather.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/Weather.java index 4478c42af..1bd226d83 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/Weather.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/packets/Weather.java @@ -469,6 +469,20 @@ public class Weather { } } + public static class WeatherDeviceRequest extends HuaweiPacket { + public static final byte id = 0x04; + + public WeatherDeviceRequest(ParamsProvider paramsProvider, int responseValue) { + super(paramsProvider); + + this.serviceId = Weather.id; + this.commandId = id; + this.tlv = new HuaweiTLV().put(0x01, responseValue); + this.isEncrypted = false; + this.complete = true; + } + } + public static class WeatherUnitRequest extends HuaweiPacket { public static final byte id = 0x05; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendWeatherDeviceRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendWeatherDeviceRequest.java index 64a3c2ce0..2c7c45a9c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendWeatherDeviceRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendWeatherDeviceRequest.java @@ -18,14 +18,12 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests; import java.util.List; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket; -import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiTLV; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Weather; -import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider; public class SendWeatherDeviceRequest extends Request { - WeatherSpec weatherSpec; public SendWeatherDeviceRequest(HuaweiSupportProvider support) { super(support); @@ -36,13 +34,7 @@ public class SendWeatherDeviceRequest extends Request { @Override protected List createRequest() throws RequestCreationException { try { - // TODO: move this to the weather packet class - HuaweiPacket response = new HuaweiPacket(supportProvider.getParamsProvider()); - response.serviceId = this.serviceId; - response.commandId = this.commandId; - response.setTlv(new HuaweiTLV().put(0x01, 0x186a0)); - response.setEncryption(false); - return response.serialize(); + return new Weather.WeatherDeviceRequest(paramsProvider, HuaweiConstants.RESULT_SUCCESS_INT).serialize(); } catch (HuaweiPacket.CryptoException e) { throw new RequestCreationException(e); }