mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-26 17:47:34 +01:00
Hookup Huawei GPS values
This commit is contained in:
parent
d379b11535
commit
4b70f3fcdb
@ -9,19 +9,21 @@ public class GpsAndTime {
|
|||||||
public static class CurrentGPSRequest extends HuaweiPacket {
|
public static class CurrentGPSRequest extends HuaweiPacket {
|
||||||
public static final byte id = 0x07;
|
public static final byte id = 0x07;
|
||||||
public CurrentGPSRequest (
|
public CurrentGPSRequest (
|
||||||
ParamsProvider paramsProvider
|
ParamsProvider paramsProvider,
|
||||||
|
int timestamp,
|
||||||
|
double lat,
|
||||||
|
double lon
|
||||||
) {
|
) {
|
||||||
super(paramsProvider);
|
super(paramsProvider);
|
||||||
|
|
||||||
this.serviceId = GpsAndTime.id;
|
this.serviceId = GpsAndTime.id;
|
||||||
this.commandId = id;
|
this.commandId = id;
|
||||||
this.tlv = new HuaweiTLV();
|
this.tlv = new HuaweiTLV()
|
||||||
this.tlv.put(0x01, (int) 0);
|
.put(0x01, timestamp)
|
||||||
this.tlv.put(0x02, (long) 0);
|
.put(0x02, lon)
|
||||||
this.tlv.put(0x03, (long) 0);
|
.put(0x03, lat);
|
||||||
this.isEncrypted = true;
|
this.isEncrypted = true;
|
||||||
this.complete = true;
|
this.complete = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
|
|
||||||
public class SendGpsAndTimeToDeviceRequest extends Request {
|
public class SendGpsAndTimeToDeviceRequest extends Request {
|
||||||
|
|
||||||
|
|
||||||
public SendGpsAndTimeToDeviceRequest(HuaweiSupportProvider support) {
|
public SendGpsAndTimeToDeviceRequest(HuaweiSupportProvider support) {
|
||||||
super(support);
|
super(support);
|
||||||
this.serviceId = GpsAndTime.id;
|
this.serviceId = GpsAndTime.id;
|
||||||
@ -21,12 +22,16 @@ public class SendGpsAndTimeToDeviceRequest extends Request {
|
|||||||
try {
|
try {
|
||||||
// TODO: support multiple units
|
// TODO: support multiple units
|
||||||
|
|
||||||
|
Prefs prefs = GBApplication.getPrefs();
|
||||||
|
// Backdating a bit seems to work better
|
||||||
return new GpsAndTime.CurrentGPSRequest(
|
return new GpsAndTime.CurrentGPSRequest(
|
||||||
this.paramsProvider
|
this.paramsProvider,
|
||||||
|
(int) (Calendar.getInstance().getTime().getTime() / 1000L) - 60,
|
||||||
|
prefs.getFloat("location_latitude", 0),
|
||||||
|
prefs.getFloat("location_longitude", 0)
|
||||||
).serialize();
|
).serialize();
|
||||||
} catch (HuaweiPacket.CryptoException e) {
|
} catch (HuaweiPacket.CryptoException e) {
|
||||||
throw new RequestCreationException(e);
|
throw new RequestCreationException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user