Session - custom fields do not show up anywhere

What I try to do is following:

  • start a workout
  • add custom fields to it
  • stop it

But I can't get this working - at least the part with the custom fields...

I would like to add native exercises and reps but as far as I've found out no one ever achieved this and this seems to be not possible... So alternatively I want to add custom fields to my workout session. Here's what I do:

Code

// create a session
session = ActivityRecording.createSession({
	:sport => ActivityRecording.SPORT_TRAINING, 
	:subSport => ActivityRecording.SUB_SPORT_STRENGTH_TRAINING, 
	:name => "Workout"
});

// create 2 custom fields
fExercises = session.createField("Exercises", 	1, FitContributor.DATA_TYPE_UINT32, { :mesgType => FitContributor.MESG_TYPE_RECORD, :units => "s" });
fTotalSets = session.createField("Sets", 		2, FitContributor.DATA_TYPE_UINT32, { :mesgType => FitContributor.MESG_TYPE_RECORD, :units => "sets" });

// then I start the session and add exercises/sets
session.start();
// ... session is running, data is saved to my data models
session.stop();

// finally I save the session and copy the data from my data model
fExercises.setData(workout.exercises);
fTotalSets.setData(workout.sets);
session.save();

XML Definition

<fitContributions>

    <fitField 
	 	id="1" 
	 	displayInChart="true" 
	 	displayInActivitySummary="true" 
	 	sortOrder = "0" 
	 	precision="0" 
	 	chartTitle="@Strings.fit_exercises" 
	 	dataLabel="@Strings.fit_exercises" 
	 	unitLabel="@Strings.fit_unit_s"
	 	fillColor="#FF0000" />

	<fitField 
	 	id="2" 
	 	displayInChart="true" 
	 	displayInActivitySummary="true" 
	 	sortOrder = "0" 
	 	precision="0" 
	 	chartTitle="@Strings.fit_sets" 
	 	dataLabel="@Strings.fit_sets" 
	 	unitLabel="@Strings.fit_unit_sets"
	 	fillColor="#00FF00" />
	 	
</fitContributions>

Result

The session is saved successfully and heart rate and duration is fine (on my real device) but the custom data does not show up anywhere.

When trying to debug this with monkey graph, I don't see anything at all though like following:

Any ideas what I'm doing wrong here?

  • From what I see, it looks like you are only doing the setData() once per field,  You want that to be ongoing (like on a timer, every second).  In a data field, you'd do the setData() in compute, so every second.

  • So you mean I can't use a custom field for an aggregate value but must submit the single data to the field and let garmin do the aggregation? So I need to call setData(1) 10 times to tell the field that 10 exercises have been done? I will try this... Still I'd assume that my usage should show a single entry in the graph + my data should show up in the summary somewhere

  • You are using FitContributor.MESG_TYPE_RECORD, so it will be in the fit file every second, but what's there is based on calling setData all the time.

    Are you sure you don't want to use FitContributor.MESG_TYPE_LAP (every lap mark) or FitContributor.MESG_TYPE_SESSION (totals for the session)?

  • the comment "every lap mark" does explain how to combine data fields with the no param function addLap - I will test this in the future. Now I simply tried to use the MESG_TYPE_SESSION which is what I want to use in my example, you're totally right. I tried this type with DATA_TYPE_UINT32 and DATA_TYPE_SINT32 but in both cases I just get following:

    Any ideas why? The data I save via setData is a numeric value

  • Based on your code you don't call setData at all before you stop recording.  The field is there but has no data.

  • Sadly this does not help - but you say, that setting session data must be done before stop and can't be done between stop and save anymore?

  • You've stopped recording, so nothing is recorded based on setData().

  • As I said, I already tried changing this to set the data before stopping the session... But I just testet it live because I found a 5 year old issue saying, that the session data fields don't show up correctly in the monkey graph tool and it's correct.

    Thanks for your help again, everything is working now - at least live.