1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-28 11:35:48 +01:00

Amazfit Cor: allow music control

This commit is contained in:
Andreas Shimokawa 2018-08-02 22:35:02 +02:00
parent 66391e10c9
commit fe401bdcf5
2 changed files with 32 additions and 1 deletions

View File

@ -30,4 +30,5 @@ public class HuamiDeviceEvent {
public static final byte BUTTON_PRESSED_LONG = 0x0b;
public static final byte TICK_30MIN = 0x0e; // unsure
public static final byte FIND_PHONE_STOP = 0x0f;
public static final byte MUSIC_CONTROL = (byte) 0xfe;
}

View File

@ -54,6 +54,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.ActivateDisplayOnLift;
@ -937,7 +938,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
}
public void handleDeviceEvent(byte[] value) {
if (value == null || value.length != 1) {
if (value == null || value.length == 0) {
return;
}
GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl();
@ -988,6 +989,35 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
findPhoneEvent.event = GBDeviceEventFindPhone.Event.STOP;
evaluateGBDeviceEvent(findPhoneEvent);
break;
case HuamiDeviceEvent.MUSIC_CONTROL:
LOG.info("got music control");
GBDeviceEventMusicControl deviceEventMusicControl = new GBDeviceEventMusicControl();
switch (value[1]) {
case 0:
deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.PLAY;
break;
case 1:
deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.PAUSE;
break;
case 3:
deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.NEXT;
break;
case 4:
deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.PREVIOUS;
break;
case 5:
deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.VOLUMEUP;
break;
case 6:
deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.VOLUMEDOWN;
break;
default:
LOG.info("unhandled music control event " + value[1]);
return;
}
evaluateGBDeviceEvent(deviceEventMusicControl);
break;
default:
LOG.warn("unhandled event " + value[0]);
}