mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 09:01:55 +01:00
parent
b6f9b9e9db
commit
cf308c93ad
@ -223,10 +223,26 @@ public class HuaweiTLV {
|
||||
return getBytes(tag)[0];
|
||||
}
|
||||
|
||||
public Byte getByte(int tag, Byte defaultValue) {
|
||||
try {
|
||||
return getByte(tag);
|
||||
} catch (HuaweiPacket.MissingTagException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean getBoolean(int tag) throws HuaweiPacket.MissingTagException {
|
||||
return getBytes(tag)[0] == 1;
|
||||
}
|
||||
|
||||
public Boolean getBoolean(int tag, Boolean defaultValue) {
|
||||
try {
|
||||
return getBoolean(tag);
|
||||
} catch (HuaweiPacket.MissingTagException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getInteger(int tag) throws HuaweiPacket.MissingTagException {
|
||||
return ByteBuffer.wrap(getBytes(tag)).getInt();
|
||||
}
|
||||
@ -243,6 +259,14 @@ public class HuaweiTLV {
|
||||
return ByteBuffer.wrap(getBytes(tag)).getShort();
|
||||
}
|
||||
|
||||
public Short getShort(int tag, Short defaultValue) {
|
||||
try {
|
||||
return getShort(tag);
|
||||
} catch (HuaweiPacket.MissingTagException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getAsInteger(int tag) throws HuaweiPacket.MissingTagException {
|
||||
byte[] bytes = getBytes(tag);
|
||||
if(bytes.length == 1) {
|
||||
|
@ -92,11 +92,11 @@ public class Alarms {
|
||||
|
||||
public SmartAlarm(HuaweiTLV tlv) throws ParseException {
|
||||
this.index = tlv.getByte(0x03);
|
||||
this.status = tlv.getBoolean(0x04);
|
||||
this.startHour = (byte) ((tlv.getShort(0x05) >> 8) & 0xFF);
|
||||
this.startMinute = (byte) (tlv.getShort(0x05) & 0xFF);
|
||||
this.repeat = tlv.getByte(0x06);
|
||||
this.aheadTime = tlv.getByte(0x07);
|
||||
this.status = tlv.getBoolean(0x04, false);
|
||||
this.startHour = (byte) ((tlv.getShort(0x05, (short) 0) >> 8) & 0xFF);
|
||||
this.startMinute = (byte) (tlv.getShort(0x05, (short) 0) & 0xFF);
|
||||
this.repeat = tlv.getByte(0x06, (byte) 0);
|
||||
this.aheadTime = tlv.getByte(0x07, (byte) 0);
|
||||
}
|
||||
|
||||
public SmartAlarm(boolean status, byte startHour, byte startMinute, byte repeat, byte aheadTime) {
|
||||
|
@ -277,6 +277,7 @@ public class HuaweiWeatherManager {
|
||||
if (response.getTlv().getInteger(0x7f, -1) == 0x000186AA) {
|
||||
// Send weather
|
||||
final ArrayList<WeatherSpec> specs = new ArrayList<>(nodomain.freeyourgadget.gadgetbridge.model.Weather.getInstance().getWeatherSpecs());
|
||||
// TODO: could be empty, not really an issue but we need to check what to send back in that case
|
||||
this.sendWeather(specs.get(0));
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user