From 744f4f88a8a3ecd152e0fe82aa549b4fe9623738 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Tue, 3 Sep 2024 16:47:06 +0200 Subject: [PATCH] Moyoung: Add music and volume control --- .../devices/moyoung/MoyoungConstants.java | 3 ++ .../devices/moyoung/MoyoungDeviceSupport.java | 50 +++++++++++++++++++ 2 files changed, 53 insertions(+) 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 6032532a2..de722d697 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 @@ -197,6 +197,9 @@ public class MoyoungConstants { public static final byte ARG_OPERATION_PREV_SONG = 1; public static final byte ARG_OPERATION_NEXT_SONG = 2; public static final byte ARG_OPERATION_DROP_INCOMING_CALL = 3; + public static final byte ARG_OPERATION_VOLUME_UP = 4; + public static final byte ARG_OPERATION_VOLUME_DOWN = 5; + public static final byte ARG_OPERATION_PLAY = 6; public static final byte CMD_QUERY_ALARM_CLOCK = 33; // (?) {} -> a list of entries like below 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) 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 e2eebec26..7fac3ba90 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 @@ -86,12 +86,16 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser; import nodomain.freeyourgadget.gadgetbridge.model.Alarm; +import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; import nodomain.freeyourgadget.gadgetbridge.model.DeviceService; +import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; +import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes; import nodomain.freeyourgadget.gadgetbridge.model.Weather; import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; +import nodomain.freeyourgadget.gadgetbridge.model.WorldClock; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService; @@ -371,6 +375,27 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport { evaluateGBDeviceEvent(callCmd); return true; } + if (operation == MoyoungConstants.ARG_OPERATION_VOLUME_UP) + { + GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl(); + musicCmd.event = GBDeviceEventMusicControl.Event.VOLUMEUP; + evaluateGBDeviceEvent(musicCmd); + return true; + } + if (operation == MoyoungConstants.ARG_OPERATION_VOLUME_DOWN) + { + GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl(); + musicCmd.event = GBDeviceEventMusicControl.Event.VOLUMEDOWN; + evaluateGBDeviceEvent(musicCmd); + return true; + } + if (operation == MoyoungConstants.ARG_OPERATION_PLAY) + { + GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl(); + musicCmd.event = GBDeviceEventMusicControl.Event.PLAYPAUSE; + evaluateGBDeviceEvent(musicCmd); + return true; + } } if (packetType == MoyoungConstants.CMD_SWITCH_CAMERA_VIEW) @@ -645,6 +670,31 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport { } } + @Override + public void onSetMusicState(MusicStateSpec stateSpec) { + // TODO + } + + @Override + public void onSetMusicInfo(MusicSpec musicSpec) { + // TODO + } + + @Override + public void onSetWorldClocks(ArrayList clocks) { + // TODO + } + + @Override + public void onAddCalendarEvent(CalendarEventSpec calendarEventSpec) { + // TODO + } + + @Override + public void onDeleteCalendarEvent(byte type, long id) { + // TODO + } + @Override public void onFetchRecordedData(int dataTypes) { if ((dataTypes & RecordedDataTypes.TYPE_ACTIVITY) != 0)