1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-14 09:00:04 +02:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/messages/status/SupportedFileTypesStatusMessage.java
Daniele Gobbetti fa8f09e95a Garmin protocol: basic file transfer and notification handling
adds synchronization of supported files from watch to external directory
adds support for Activity and Monitoring files (workouts and activity samples), but those are not integrated yet
adds upload functionality (not used ATM and not tested)
adds notification support without actions
introduces centralized processing of "messageHandlers" (protobuf, file transfer, notifications)

also properly dispose of the music timer when disconnecting
2024-05-01 23:35:16 +01:00

48 lines
1.9 KiB
Java

package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.status;
import java.util.ArrayList;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.FileType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.deviceevents.SupportedFileTypesDeviceEvent;
public class SupportedFileTypesStatusMessage extends GFDIStatusMessage {
private final Status status;
private final List<FileType> fileTypeInfoList;
public SupportedFileTypesStatusMessage(GarminMessage garminMessage, Status status, List<FileType> fileTypeInfoList) {
this.garminMessage = garminMessage;
this.status = status;
this.fileTypeInfoList = fileTypeInfoList;
}
public static SupportedFileTypesStatusMessage parseIncoming(MessageReader reader, GarminMessage garminMessage) {
final Status status = Status.fromCode(reader.readByte());
if (!status.equals(Status.ACK)) {
return null;
}
final int typeCount = reader.readByte();
final List<FileType> types = new ArrayList<>(typeCount);
for (int i = 0; i < typeCount; ++i) {
final int fileDataType = reader.readByte();
final int fileSubType = reader.readByte();
final String garminDeviceFileType = reader.readString();
FileType fileType = new FileType(fileDataType, fileSubType, garminDeviceFileType);
if (fileType.getFileType() == null) {
LOG.warn("Watch supports a filetype that we do not support: {}", garminDeviceFileType);
continue;
}
types.add(fileType);
}
return new SupportedFileTypesStatusMessage(garminMessage, status, types);
}
@Override
public SupportedFileTypesDeviceEvent getGBDeviceEvent() {
return new SupportedFileTypesDeviceEvent(fileTypeInfoList);
}
}