From 938085b5fa8da6854ae91b3d8efe12165775e64b Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Sat, 4 Jan 2025 14:50:26 +0100 Subject: [PATCH] Moyoung: Add support for world clocks --- .../moyoung/ColmiI28UltraCoordinator.java | 10 +++++ .../devices/moyoung/MoyoungConstants.java | 2 +- .../devices/moyoung/MoyoungDeviceSupport.java | 38 +++++++++++++++---- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/ColmiI28UltraCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/ColmiI28UltraCoordinator.java index bf2b0474e..408b4e392 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/ColmiI28UltraCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/ColmiI28UltraCoordinator.java @@ -65,4 +65,14 @@ public class ColmiI28UltraCoordinator extends AbstractMoyoungDeviceCoordinator { public int getAlarmSlotCount(GBDevice device) { return 8; } + + @Override + public int getWorldClocksSlotCount() { + return 6; + } + + @Override + public int getWorldClocksLabelLength() { + return 30; + } } \ No newline at end of file diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java index 26542ef69..9e902889e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java @@ -212,7 +212,7 @@ public class MoyoungConstants { public static final byte CMD_SET_ALARM_CLOCK = 17; // (?) {id, enable ? 1 : 0, repeat, hour, minute, i >> 8, i, repeatMode}, repeatMode is 0(SINGLE), 127(EVERYDAY), or bitmask of 1,2,4,8,16,32,64(SUNDAY-SATURDAY) is 0,1,2, i is ((year << 12) + (month << 8) + day) where year is 2015-based, month and day start at 1 for repeatMode=SINGLE and 0 otherwise, repeat is 0(SINGLE),1(EVERYDAY),2(OTHER) public static final byte CMD_ADVANCED_QUERY = (byte) 0xb9; - public static final byte CMD_DAGPT = (byte) 0xbb; + public static final byte CMD_ADVANCED_CMD = (byte) 0xbb; public static final byte CMD_QUERY_POWER_SAVING = (byte) 0xa4; public static final byte CMD_SET_POWER_SAVING = (byte) 0x94; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungDeviceSupport.java index 984ef7eb1..e60ed1e7b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungDeviceSupport.java @@ -47,6 +47,7 @@ import java.util.List; import java.util.Locale; import java.util.Objects; import java.util.Set; +import java.util.TimeZone; import java.util.UUID; import de.greenrobot.dao.query.QueryBuilder; @@ -489,12 +490,6 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport { return true; } - if (packetType == MoyoungConstants.CMD_DAGPT) - { - LOG.info("Da GPT started on watch"); - return true; - } - if (packetType == MoyoungConstants.CMD_FIND_MY_PHONE) { LOG.info("Find my phone started on watch"); @@ -838,7 +833,36 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport { @Override public void onSetWorldClocks(ArrayList clocks) { - // TODO + final TimeZone localTZ = Calendar.getInstance().getTimeZone(); + try { + TransactionBuilder builder = performInitialized("sendWorldClocks"); + for (byte i=1; i