From 7e848d19fbc1c881e5a97d11e685696aa7d9b5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Sat, 26 Aug 2023 15:47:04 +0100 Subject: [PATCH] Zepp OS: Handle watchface change --- .../zeppos/services/ZeppOsWatchfaceService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsWatchfaceService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsWatchfaceService.java index bd7e5ac5a..f2ac6b06c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsWatchfaceService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsWatchfaceService.java @@ -54,6 +54,7 @@ public class ZeppOsWatchfaceService extends AbstractZeppOsService { public static final byte CMD_SET_ACK = 0x08; public static final byte CMD_CURRENT_GET = 0x09; public static final byte CMD_CURRENT_RET = 0x0a; + public static final byte CMD_WATCHFACE_CHANGED = (byte) 0xff; public enum Watchface { // Codes are from GTR 4, not sure if they match on other watches @@ -132,6 +133,10 @@ public class ZeppOsWatchfaceService extends AbstractZeppOsService { LOG.info("Got current watchface = {}", watchfaceHex); getSupport().evaluateGBDeviceEvent(new GBDeviceEventUpdatePreferences(PREF_WATCHFACE, watchfaceHex)); break; + case CMD_WATCHFACE_CHANGED: + LOG.info("Watchface changed"); + requestCurrentWatchface(); + break; default: LOG.warn("Unexpected watchface byte {}", String.format("0x%02x", payload[0])); } @@ -164,6 +169,16 @@ public class ZeppOsWatchfaceService extends AbstractZeppOsService { write(builder, CMD_LIST_GET); } + public void requestCurrentWatchface() { + try { + final TransactionBuilder builder = new TransactionBuilder("request current watchface"); + requestCurrentWatchface(builder); + builder.queue(getSupport().getQueue()); + } catch (final Exception e) { + LOG.error("Failed to request current watchface", e); + } + } + public void requestCurrentWatchface(final TransactionBuilder builder) { write(builder, CMD_CURRENT_GET); }