mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-05 09:47:01 +01:00
Garmin: Send phone volume to watch
This commit is contained in:
parent
47e3cbcb33
commit
0f8889498e
@ -22,6 +22,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Timer;
|
||||
@ -648,6 +649,15 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetPhoneVolume(final float volume) {
|
||||
final Map<MusicControlEntityUpdateMessage.MusicEntity, String> attributes = new HashMap<>();
|
||||
|
||||
attributes.put(MusicControlEntityUpdateMessage.PLAYER.VOLUME, String.format(Locale.ROOT, "%.2f", volume / 100f));
|
||||
|
||||
sendOutgoingMessage("set phone volume", new MusicControlEntityUpdateMessage(attributes));
|
||||
}
|
||||
|
||||
private boolean alreadyDownloaded(final FileTransferHandler.DirectoryEntry entry) {
|
||||
final Optional<File> file = getFile(entry.getFileName());
|
||||
if (file.isPresent()) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MusicControlEntityUpdateMessage extends GFDIMessage {
|
||||
@ -14,6 +15,36 @@ public class MusicControlEntityUpdateMessage extends GFDIMessage {
|
||||
|
||||
}
|
||||
|
||||
public static MusicControlEntityUpdateMessage parseIncoming(MessageReader reader, GarminMessage garminMessage) {
|
||||
final Map<MusicEntity, String> attributes = new HashMap<>();
|
||||
|
||||
while (reader.remaining() > 0) {
|
||||
final int len = reader.readByte();
|
||||
final int entityId = reader.readByte();
|
||||
final int ordinal = reader.readByte();
|
||||
final int zero = reader.readByte();
|
||||
byte[] bytes = reader.readBytes(len - 3);
|
||||
final String str = new String(bytes, StandardCharsets.UTF_8);
|
||||
|
||||
switch (entityId) {
|
||||
case 0:
|
||||
PLAYER player = PLAYER.values()[ordinal];
|
||||
break;
|
||||
case 1:
|
||||
QUEUE queue = QUEUE.values()[ordinal];
|
||||
break;
|
||||
case 2:
|
||||
TRACK track = TRACK.values()[ordinal];
|
||||
break;
|
||||
default:
|
||||
LOG.warn("Unknown entity {}", entityId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return new MusicControlEntityUpdateMessage(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean generateOutgoing() {
|
||||
final MessageWriter writer = new MessageWriter(response);
|
||||
|
Loading…
Reference in New Issue
Block a user