I have try to create java program which should add one extra Field to Workout message
Field 16 is the only one which makes difference between Strength, Joga or Pilates workouts created directly on Garmin Connect and after edit preset ones.
I have started with this information:
Read and write back fit file adds extra bytes - Discussion - FIT SDK - Garmin Forums
My code looks like this:
@Override
public void onMesg(Mesg mesg) {
Short[] values16 = new Short[16];
Arrays.fill(values16, (short) 0); // Fill with 0
values16[15] = 1; // Set last element to 1
if(mesg.getNum() == MesgNum.WORKOUT) {
System.out.println("Workout:");
if(mesg.hasField(16)) {
// encoder.write(mesg); // or encoder.write(recordMesg) should not matter.
System.out.println(" have Field #16");
} else {
Field field = Factory.createField(mesg.getNum(), 16);
mesg.addField(field)
mesg.setFieldValue(16, 0, values16, Fit.SUBFIELD_INDEX_MAIN_FIELD);
// encoder.write(workoutMesg);
System.out.println(" do not have Field #16");
}
}
}
I guess due to missing definition of Field 16 in WorkoutMesg my new field has num 255 (INVALID) instead expected 16
And one more thing instead of Array of Shorts I get in that Field 255 simple Short value.
Can someone help me, what would be the best way to implement this?
Thanks