Hello,
I'm on FIT SDK version 21.84.00. I'm working on a Java tool to crop fit files (e.g. because the activity wasn't stopped during the recording for hours after the real end of the activity).
I think I may have some issues here and there, but first and foremost, I think that again simply reading and writing back the fit file is not working as it should.
The original file is downloaded from Strava and is 96KB and the one I'm saving back to disk is 113KB. Here are the files:
Now, the Java code to write back the file is taken (more or less) from the tutorial. I did not change any message in the file (just read and then write back).
FileEncoder fileEncoder;
try {
fileEncoder = new FileEncoder(filePath.toFile(), com.garmin.fit.Fit.ProtocolVersion.V2_0);
} catch (FitRuntimeException e) {
throw new FitSerializationException(e);
}
FitMessages fitMessages = fit.getFitMessages();
// Then for each message type
List<Mesg> messages = //... e.g. fitMessages.getFileIdMesgs();
for (int i = 0; i <messages.size(); i++) {
final Mesg mesg = messages.get(i);
// remove computed fields that were not in the original file
mesg.removeExpandedFields();
fileEncoder.write(mesg);
}
I don't get where these extra bytes come from. Any hint?
May it be that Strava doesn't use the Garmin fit SDK to persist the messages into a fit file and so maybe they also use different field types (e.g. Short instead of Integer, etc.)?