mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-06-01 19:06:06 +02:00
Garmin: Map all known files types
This commit is contained in:
parent
c58fea1a67
commit
919441cfa8
|
@ -12,6 +12,8 @@ import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.deviceevents.FileDownloadedDeviceEvent;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.deviceevents.FileDownloadedDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.DownloadRequestMessage;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.DownloadRequestMessage;
|
||||||
|
@ -31,6 +33,15 @@ public class FileTransferHandler implements MessageHandler {
|
||||||
private final Download download;
|
private final Download download;
|
||||||
private final Upload upload;
|
private final Upload upload;
|
||||||
|
|
||||||
|
private static final Set<FileType.FILETYPE> FILE_TYPES_TO_PROCESS = new HashSet<FileType.FILETYPE>() {{
|
||||||
|
add(FileType.FILETYPE.DIRECTORY);
|
||||||
|
add(FileType.FILETYPE.ACTIVITY);
|
||||||
|
add(FileType.FILETYPE.MONITOR);
|
||||||
|
add(FileType.FILETYPE.METRICS);
|
||||||
|
add(FileType.FILETYPE.CHANGELOG);
|
||||||
|
add(FileType.FILETYPE.SLEEP);
|
||||||
|
}};
|
||||||
|
|
||||||
public FileTransferHandler(GarminSupport deviceSupport) {
|
public FileTransferHandler(GarminSupport deviceSupport) {
|
||||||
this.deviceSupport = deviceSupport;
|
this.deviceSupport = deviceSupport;
|
||||||
this.download = new Download();
|
this.download = new Download();
|
||||||
|
@ -156,6 +167,8 @@ public class FileTransferHandler implements MessageHandler {
|
||||||
final DirectoryEntry directoryEntry = new DirectoryEntry(fileIndex, filetype, fileNumber, specificFlags, fileFlags, fileSize, fileDate);
|
final DirectoryEntry directoryEntry = new DirectoryEntry(fileIndex, filetype, fileNumber, specificFlags, fileFlags, fileSize, fileDate);
|
||||||
if (directoryEntry.filetype == null) //silently discard unsupported files
|
if (directoryEntry.filetype == null) //silently discard unsupported files
|
||||||
continue;
|
continue;
|
||||||
|
if (!FILE_TYPES_TO_PROCESS.contains(directoryEntry.filetype))
|
||||||
|
continue;
|
||||||
deviceSupport.addFileToDownloadList(directoryEntry);
|
deviceSupport.addFileToDownloadList(directoryEntry);
|
||||||
}
|
}
|
||||||
currentlyDownloading = null;
|
currentlyDownloading = null;
|
||||||
|
@ -325,7 +338,7 @@ public class FileTransferHandler implements MessageHandler {
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
|
||||||
String dateString = dateFormat.format(fileDate);
|
String dateString = dateFormat.format(fileDate);
|
||||||
return getFiletype().name() + "_" + getFileIndex() + "_" + dateString + (getFiletype().isFitFile() ? ".fit" : "");
|
return getFiletype().name() + "_" + getFileIndex() + "_" + dateString + (getFiletype().isFitFile() ? ".fit" : ".bin");
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
|
@ -35,15 +35,38 @@ public class FileType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FILETYPE { //TODO: add specialized method to parse each file type to the enum?
|
public enum FILETYPE { //TODO: add specialized method to parse each file type to the enum?
|
||||||
|
// virtual/undocumented
|
||||||
|
DIRECTORY(0, 0),
|
||||||
|
|
||||||
|
// fit files
|
||||||
ACTIVITY(128, 4),
|
ACTIVITY(128, 4),
|
||||||
|
WORKOUTS(128, 5),
|
||||||
|
SCHEDULES(128, 7),
|
||||||
|
LOCATION(128, 8),
|
||||||
|
TOTALS(128, 10),
|
||||||
|
GOALS(128, 11),
|
||||||
|
SUMMARY(128, 20),
|
||||||
|
RECORDS(128, 29),
|
||||||
MONITOR(128, 32),
|
MONITOR(128, 32),
|
||||||
|
CLUBS(128, 37),
|
||||||
|
SCORE(128, 38),
|
||||||
|
ADJUSTMENTS(128, 39),
|
||||||
CHANGELOG(128, 41),
|
CHANGELOG(128, 41),
|
||||||
METRICS(128, 44),
|
METRICS(128, 44),
|
||||||
SLEEP(128, 49),
|
SLEEP(128, 49),
|
||||||
|
MUSCLE_MAP(128, 59),
|
||||||
|
ECG(128, 61),
|
||||||
|
BENCHMARK(128, 62),
|
||||||
|
HRV_STATUS(128, 68),
|
||||||
|
HSA(128, 70),
|
||||||
|
FBT_BACKUP(128, 72),
|
||||||
|
SKIN_TEMP(128, 73),
|
||||||
|
FBT_PTD_BACKUP(128, 74),
|
||||||
|
|
||||||
//"virtual" and/or undocumented file types
|
// Other files
|
||||||
DIRECTORY(0, 0),
|
ERROR_SHUTDOWN_REPORTS(255, 245),
|
||||||
//SETTINGS(Pair.create(128,2)),
|
IQ_ERROR_REPORTS(255, 244),
|
||||||
|
ULF_LOGS(255, 247),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final int type;
|
private final int type;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class SupportedFileTypesStatusMessage extends GFDIStatusMessage {
|
||||||
final String garminDeviceFileType = reader.readString();
|
final String garminDeviceFileType = reader.readString();
|
||||||
FileType fileType = new FileType(fileDataType, fileSubType, garminDeviceFileType);
|
FileType fileType = new FileType(fileDataType, fileSubType, garminDeviceFileType);
|
||||||
if (fileType.getFileType() == null) {
|
if (fileType.getFileType() == null) {
|
||||||
LOG.warn("Watch supports a filetype that we do not support: {}", garminDeviceFileType);
|
LOG.warn("Watch supports a filetype that we do not support: {}/{}: {}", fileDataType, fileSubType, garminDeviceFileType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
types.add(fileType);
|
types.add(fileType);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user