1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 06:22:55 +01:00

Small cleanup

This commit is contained in:
Martin.JM 2024-02-18 14:00:13 +01:00 committed by José Rebelo
parent 5ebfe9b39f
commit 1c2516186d
3 changed files with 17 additions and 10 deletions

View File

@ -36,6 +36,7 @@ public final class HuaweiConstants {
public static final int TAG_RESULT = 127; public static final int TAG_RESULT = 127;
public static final byte[] RESULT_SUCCESS = new byte[]{0x00, 0x01, (byte)0x86, (byte)0xA0}; 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 class CryptoTags {
public static final int encryption = 124; public static final int encryption = 124;

View File

@ -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 class WeatherUnitRequest extends HuaweiPacket {
public static final byte id = 0x05; public static final byte id = 0x05;

View File

@ -18,14 +18,12 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
import java.util.List; import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket; 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.devices.huawei.packets.Weather;
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider; import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
public class SendWeatherDeviceRequest extends Request { public class SendWeatherDeviceRequest extends Request {
WeatherSpec weatherSpec;
public SendWeatherDeviceRequest(HuaweiSupportProvider support) { public SendWeatherDeviceRequest(HuaweiSupportProvider support) {
super(support); super(support);
@ -36,13 +34,7 @@ public class SendWeatherDeviceRequest extends Request {
@Override @Override
protected List<byte[]> createRequest() throws RequestCreationException { protected List<byte[]> createRequest() throws RequestCreationException {
try { try {
// TODO: move this to the weather packet class return new Weather.WeatherDeviceRequest(paramsProvider, HuaweiConstants.RESULT_SUCCESS_INT).serialize();
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();
} catch (HuaweiPacket.CryptoException e) { } catch (HuaweiPacket.CryptoException e) {
throw new RequestCreationException(e); throw new RequestCreationException(e);
} }