Is it possible to write to the FIT file "Summary" from within a complex datafield

I have success with the Namste sample App project. I can write successfully to the FIT file and in Garmin Connect I can see the graphs and the summary data below in the Stats section.

When I try and do the same thing from my complex datafield I can get the graphs to work, But the final summary results to not appear in the Stats section of Garmin Connect.

Looking inside my FIT file I cannot see any sign of the data that should be written from the 

So this first line works correctly and creates a graph:

gps_acc_field = createField("GPS_Acc",0, FitContributor.DATA_TYPE_FLOAT,{:mesgType=>Fit.MESG_TYPE_RECORD, :units=>"B"});


But this line does nothing
twosecfield= createField("twosec" ,1, FitContributor.DATA_TYPE_FLOAT,{:mesgType=>Fit.MESG_TYPE_SESSION, :units=>"kts"});

Thanks

  • Where do you set data? Not shown in your excerpt.

    I have found;

    1. I need to store the field in a class var (if it's a var scoped to method, it will be cleaned up afterwards and then it is gone forever)

    2. I need to call .setData() after creation

    But, otherwise, it is pretty bomb-proof.

  • I'm thinking the same thing, where the summary data isn't being saved before the fit file itself is saved.

  • I have tried writing the data as various times. At the start, every ten seconds and just at the end, Nothing appears to work.

    I have been examining the Namaste example, (which I can get to work) the only difference I can see is that in Namaste there is code to create the FIT logging  mSession = ActivityRecording.createSession whilst in my datafield I am writting to the already created "RUN" activity FIT file. Does this make a difference?, can I write SESSION data into the FIT file which is running in the "RUN" app

  • Yes it makes a difference or yes I can write Session data to a FIT file?

  • This is getting really annoying. I have 

    class TopSpeedDevView extends WatchUi.DataField {

    var test1field;
    var test2field;
    var test3field;
    var test4field;

    function initialize() {
    DataField.initialize();

    test1field = createField("test1", 1, FitContributor.DATA_TYPE_FLOAT, {:mesgType => FitContributor.MESG_TYPE_SESSION});
    test2field = createField("test2", 2, FitContributor.DATA_TYPE_FLOAT, {:mesgType => FitContributor.MESG_TYPE_RECORD});
    test3field = createField("test3", 3, FitContributor.DATA_TYPE_FLOAT, {:mesgType => FitContributor.MESG_TYPE_SESSION});
    test4field = createField("test4", 4, FitContributor.DATA_TYPE_FLOAT, {:mesgType => FitContributor.MESG_TYPE_RECORD});

    and then in 

       function compute(info) {

    test1field.setData(pointer + 10);
    test2field.setData(pointer + 20);
    test3field.setData(pointer + 30);
    test4field.setData(pointer + 40);

    In the FIT file I get data written every second for test2 and test4, there is nothing in the fit file for test 1 or 3

    I tried the Message type LAP and that worked as well.

  • I haven't tried your code, but I don't see anything wrong with it at first glance and similar code gives me impeccable results all the time, so... perhaps it is something else!

    How are you testing?

    before the fit file itself is saved.

    I am not sure when the summary / session data gets written to the .fit file. It would certainly make sense to me if summary data was stored in memory and written to the file when the file is finalised and stored. ETA: I HAVE CHECKED IN AN EXPORTED CSV AND THIS LOOKS TO BE THE CASE.

    Are you formally ending the session to commit and save the final file, or are you just running for a while and then evaluating what has been written to the FIT file by a given point?

    Another thing you might try is to use "build for device" and sideload it onto your watch and then take a look at the .fit file from an exercise that uses it.

  • I am testing by uploading to Garmin IQ and actually loading the Datafield onto my Fenix 3. The datafield is running inside the normal "Run" activity. I go out side. "Start" wait a while then "stop" and save the activity. After it uploads to garmin connect, I download the FIT, convert it to a CSV and inpect. I can see the fields and data created by test2 and test4, I even get graphs for them in Garmin Connect. But there is nothing in the CSV file relating to test1 or test 3. It's driving me nuts!