1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-02 03:16:07 +02:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vivomovehr/ams/AmsEntityAttribute.java
Mormegil 3a58314db6 Garmin Vivomove HR support
- communication protocols
- device support implementation
- download FIT file storage

Features:
- basic connectivity: time sync, battery status, HW/FW version info
- real-time activity tracking
- fitness data sync
- find the device, find the phone
- factory reset

Features implemented but not working:
- notifications: fully implemented, seem to communicate correctly, but not shown on watch

Features implemented partially (not expected to work now):
- weather information (and in future possibly weather alerts)
- music info
- firmware update: only the initial file upload implemented, not used

Things to improve/change:
- Device name hardcoded in `VivomoveHrCoordinator.getSupportedType`, service UUIDs not available
- Download FIT file storage: Should be store (and offer the user to export?) the FIT data forever?
- Obviously, various code improvements, cleanup, etc.
2023-07-20 20:30:14 +00:00

43 lines
1.6 KiB
Java

package nodomain.freeyourgadget.gadgetbridge.service.devices.vivomovehr.ams;
import nodomain.freeyourgadget.gadgetbridge.service.devices.vivomovehr.messages.MessageWriter;
import java.nio.charset.StandardCharsets;
public class AmsEntityAttribute {
public static final int PLAYER_ATTRIBUTE_NAME = 0;
public static final int PLAYER_ATTRIBUTE_PLAYBACK_INFO = 1;
public static final int PLAYER_ATTRIBUTE_VOLUME = 2;
public static final int QUEUE_ATTRIBUTE_INDEX = 0;
public static final int QUEUE_ATTRIBUTE_COUNT = 1;
public static final int QUEUE_ATTRIBUTE_SHUFFLE_MODE = 2;
public static final int QUEUE_ATTRIBUTE_REPEAT_MODE = 3;
public static final int TRACK_ATTRIBUTE_ARTIST = 0;
public static final int TRACK_ATTRIBUTE_ALBUM = 1;
public static final int TRACK_ATTRIBUTE_TITLE = 2;
public static final int TRACK_ATTRIBUTE_DURATION = 3;
public final AmsEntity entity;
public final int attributeID;
public final int updateFlags;
public final byte[] value;
public AmsEntityAttribute(AmsEntity entity, int attributeID, int updateFlags, String value) {
this.entity = entity;
this.attributeID = attributeID;
this.updateFlags = updateFlags;
this.value = value.getBytes(StandardCharsets.UTF_8);
if (this.value.length > 255) throw new IllegalArgumentException("Too long value");
}
public void writeToMessage(MessageWriter writer) {
writer.writeByte(entity.ordinal());
writer.writeByte(attributeID);
writer.writeByte(updateFlags);
writer.writeByte(value.length);
writer.writeBytes(value);
}
}