mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 19:36:50 +01:00
added SetTime request
This commit is contained in:
parent
4772ec714c
commit
1af8daba7a
@ -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.SetCountdownSettings;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.SetCurrentTimeServiceRequest;
|
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.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.SetVibrationStrengthRequest;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.UploadFileRequest;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.UploadFileRequest;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.VibrateRequest;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.VibrateRequest;
|
||||||
@ -268,7 +269,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
public void onSetTime() {
|
public void onSetTime() {
|
||||||
long millis = System.currentTimeMillis();
|
long millis = System.currentTimeMillis();
|
||||||
TimeZone zone = new GregorianCalendar().getTimeZone();
|
TimeZone zone = new GregorianCalendar().getTimeZone();
|
||||||
SetCurrentTimeServiceRequest request = new SetCurrentTimeServiceRequest(
|
SetTimeRequest request = new SetTimeRequest(
|
||||||
(int) (millis / 1000 + timeOffset * 60),
|
(int) (millis / 1000 + timeOffset * 60),
|
||||||
(short) (millis % 1000),
|
(short) (millis % 1000),
|
||||||
(short) ((zone.getRawOffset() + zone.getDSTSavings()) / 60000));
|
(short) ((zone.getRawOffset() + zone.getDSTSavings()) / 60000));
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user