mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-24 16:21:16 +02: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 final byte id = 0x07;
|
||||
public CurrentGPSRequest (
|
||||
ParamsProvider paramsProvider
|
||||
ParamsProvider paramsProvider,
|
||||
int timestamp,
|
||||
double lat,
|
||||
double lon
|
||||
) {
|
||||
super(paramsProvider);
|
||||
|
||||
this.serviceId = GpsAndTime.id;
|
||||
this.commandId = id;
|
||||
this.tlv = new HuaweiTLV();
|
||||
this.tlv.put(0x01, (int) 0);
|
||||
this.tlv.put(0x02, (long) 0);
|
||||
this.tlv.put(0x03, (long) 0);
|
||||
this.tlv = new HuaweiTLV()
|
||||
.put(0x01, timestamp)
|
||||
.put(0x02, lon)
|
||||
.put(0x03, lat);
|
||||
this.isEncrypted = true;
|
||||
this.complete = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public class SendGpsAndTimeToDeviceRequest extends Request {
|
||||
|
||||
|
||||
public SendGpsAndTimeToDeviceRequest(HuaweiSupportProvider support) {
|
||||
super(support);
|
||||
this.serviceId = GpsAndTime.id;
|
||||
@ -21,12 +22,16 @@ public class SendGpsAndTimeToDeviceRequest extends Request {
|
||||
try {
|
||||
// TODO: support multiple units
|
||||
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
// Backdating a bit seems to work better
|
||||
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();
|
||||
} catch (HuaweiPacket.CryptoException e) {
|
||||
throw new RequestCreationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user