1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 13:26:50 +01:00

added SetTime request

This commit is contained in:
dakhnod 2019-07-25 11:47:08 +02:00
parent 4772ec714c
commit 1af8daba7a
2 changed files with 26 additions and 1 deletions

View File

@ -63,6 +63,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.Req
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.SetCountdownSettings;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.SetCurrentTimeServiceRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.SetStepGoalRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.SetTimeRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.SetVibrationStrengthRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.UploadFileRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.VibrateRequest;
@ -268,7 +269,7 @@ public class QHybridSupport extends QHybridBaseSupport {
public void onSetTime() {
long millis = System.currentTimeMillis();
TimeZone zone = new GregorianCalendar().getTimeZone();
SetCurrentTimeServiceRequest request = new SetCurrentTimeServiceRequest(
SetTimeRequest request = new SetTimeRequest(
(int) (millis / 1000 + timeOffset * 60),
(short) (millis % 1000),
(short) ((zone.getRawOffset() + zone.getDSTSavings()) / 60000));

View File

@ -0,0 +1,24 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests;
import java.nio.ByteBuffer;
public class SetTimeRequest extends Request {
public SetTimeRequest(int epochSeconds, short millis, short minutesOffset) {
ByteBuffer buffer = createBuffer();
buffer.putInt(epochSeconds);
buffer.putShort(millis);
buffer.putShort(minutesOffset);
this.data = buffer.array();
}
@Override
public byte[] getStartSequence() {
return new byte[]{2, 4};
}
@Override
public int getPayloadLength() {
return 10;
}
}